Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmert committed Jun 11, 2014
2 parents 576de65 + 7bcfe37 commit 508d753
Show file tree
Hide file tree
Showing 117 changed files with 1,099 additions and 744 deletions.
41 changes: 23 additions & 18 deletions coffee/maxmertkit.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MaxmertkitEvent


registerCallback: ( callback, el, id ) ->
@callbacks.push
@callbacks.push
id: id
el: el
callback: callback
Expand Down Expand Up @@ -89,7 +89,7 @@ class MaxmertkitReactor
clearInterval timer
timer = null
, 1000

eventId


Expand Down Expand Up @@ -257,39 +257,44 @@ class MaxmertkitHelpers
_outerWidth: (el) ->
el = el or @el
width = el.offsetWidth
try
style = el.currentStyle or getComputedStyle(el)
if style
if style.paddingLeft? and style.paddingLeft isnt '' then width += parseInt(style.paddingLeft)
if style.paddingRight? and style.paddingRight isnt '' then width += parseInt(style.paddingRight)
# try
# style = el.currentStyle or getComputedStyle(el)
# if style
# if style.paddingLeft? and style.paddingLeft isnt '' then width += parseInt(style.paddingLeft)
# if style.paddingRight? and style.paddingRight isnt '' then width += parseInt(style.paddingRight)
width

_outerHeight: (el) ->
el = el or @el
height = el.offsetHeight
try
style = el.currentStyle or getComputedStyle(el)
if style?
if style.paddingTop? and style.paddingTop isnt '' then height += parseInt(style.paddingTop)
if style.paddingBottom? and style.paddingBottom isnt '' then height += parseInt(style.paddingBottom)
# try
# style = el.currentStyle or getComputedStyle(el)
# if style?
# if style.paddingTop? and style.paddingTop isnt '' then height += parseInt(style.paddingTop)
# if style.paddingBottom? and style.paddingBottom isnt '' then height += parseInt(style.paddingBottom)
height

_getPosition: (el) ->
el = el or @el
curleft = curtop = 0

### FIXME: Not sure if it needed to calculate with style margin ###
# try
# style = el.currentStyle or getComputedStyle(el)
# if style?
# if style.marginTop? and style.marginTop isnt '' then curtop -= parseInt(style.marginTop)
# if style.marginBottom? and style.marginBottom isnt '' then curtop += parseInt(style.marginBottom)
# if style.marginLeft? and style.marginLeft isnt '' then curleft += parseInt(style.marginLeft)
# if style.marginRight? and style.marginRight isnt '' then curleft -= parseInt(style.marginRight)

if el.offsetParent
loop

### FIXME: Not sure if it needed to calculate with style margin ###
try
style = el.currentStyle or getComputedStyle(el)
# if style?
# if style.marginTop? and style.marginTop isnt '' then curtop -= parseInt(style.marginTop)
# if style.marginLeft? and style.marginLeft isnt '' then curleft -= parseInt(style.marginLeft)
curleft += el.offsetLeft
curtop += el.offsetTop
break unless el = el.offsetParent


left: curleft,
top: curtop

Expand Down
17 changes: 10 additions & 7 deletions coffee/modal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class Modal extends MaxmertkitHelpers
# Boolean; close other instances of Modal when current is opening
selfish: @el.getAttribute('data-selfish') or yes

# Boolean; hide scroll of the container element when modal window appears
hideScroll: @el.getAttribute('data-hide-scroll') or yes


# Events
beforeactive: ->
Expand All @@ -70,7 +73,7 @@ class Modal extends MaxmertkitHelpers
@closerF = @close.bind @
@clickerF = @clicker.bind @
@backdropClickF = _backdropClick.bind @


@_setOptions @options

Expand Down Expand Up @@ -105,8 +108,8 @@ class Modal extends MaxmertkitHelpers
@_addEventListener closer, value, @closerF

when 'backdrop'
if @options.backdrop then @_removeEventListener @el, "click", @backdropClickF
if value then @_addEventListener @el, "click", @backdropClickF
if @options.backdrop then @_removeEventListener @target, "click", @backdropClickF
if value then @_addEventListener @target, "click", @backdropClickF

when 'push'
if value
Expand Down Expand Up @@ -160,7 +163,7 @@ _pushStop = ->
@push.style['-webkit-overflow-scrolling'] = 'auto'

_backdropClick = ( event ) ->
if @_hasClass('-modal', event.target) and @opened
if @_hasClass('-holder', event.target) and @opened
@close()


Expand Down Expand Up @@ -192,7 +195,7 @@ _beforeactivate = ->

_activate = ->
if @push then @_addClass '_perspective_', document.body
@_addClass '_no-scroll_', document.body
if @options.hideScroll then @_addClass '_no-scroll_', document.body

@target.style.display = 'table'
# setTimeout =>
Expand Down Expand Up @@ -234,7 +237,7 @@ _deactivate = ->
setTimeout =>
@_removeClass '_visible_ -start-- -stop--', @target
@_removeClass '_visible_ -start-- -stop--', @dialog
@_removeClass '_no-scroll_', document.body
if @options.hideScroll then @_removeClass '_no-scroll_', document.body
if @push then @_removeClass '_perspective_', document.body
@target.style.display = 'none'
, 1000
Expand Down Expand Up @@ -270,4 +273,4 @@ if Element? then Element::modal = window['mkitModal']
if jQuery?
$.fn[_name] = (options) ->
@each ->
window['mkitModal'].call( @, options )
window['mkitModal'].call( @, options )
7 changes: 6 additions & 1 deletion coffee/popup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class Popup extends MaxmertkitHelpers
@target.style.visibility = 'hidden'
@target.style.display = 'block'

arrow = @target.querySelector '.-arrow'
arrowSize =
width: @_outerWidth arrow
height: @_outerHeight arrow

targetSize =
width: @_outerWidth @target
height: @_outerHeight @target
Expand Down Expand Up @@ -314,4 +319,4 @@ if Element? then Element::popup = window['mkitPopup']
if jQuery?
$.fn[_name] = (options) ->
@each ->
window['mkitPopup'].call( @, options )
window['mkitPopup'].call( @, options )
8 changes: 6 additions & 2 deletions coffee/skyline.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Skyline extends MaxmertkitHelpers
# Number or function, returning Number; in ms, delay before start animation
delay: @el.getAttribute( 'data-delay' ) or 300

# Boolean; show only once and don't hide after that
once: @el.getAttribute( 'data-once' ) or no

# Boolean; on spying on mobile devices
onMobile: @el.getAttribute( 'data-on-mobile' ) or no

Expand Down Expand Up @@ -104,6 +107,7 @@ class Skyline extends MaxmertkitHelpers
@_addClass '-start--'
@_removeClass '-stop--'
@active = yes
if @options.once then @stop()
, delay

deactivate: ->
Expand All @@ -116,7 +120,7 @@ class Skyline extends MaxmertkitHelpers

refresh: ->
_windowSize = _getWindowSize()
@spyParams =
@spyParams =
offset: @_getPosition @el
height: @_outerHeight()

Expand Down Expand Up @@ -268,4 +272,4 @@ if Element? then Element::skyline = window['mkitSkyline']
if jQuery?
$.fn[_name] = (options) ->
@each ->
window['mkitSkyline'].call( @, options )
window['mkitSkyline'].call( @, options )
Loading

0 comments on commit 508d753

Please sign in to comment.