Commit 774e518b authored by Terion's avatar Terion

add some funcs

parent c8ecb0ed
......@@ -146,4 +146,58 @@ getLocation = (href) ->
port: match[4]
pathname: match[5]
search: match[6]
hash: match[7]
\ No newline at end of file
hash: match[7]
isHidden = (el)-> return (el.offsetParent == null)
((e) ->
e.closest = e.closest or (css) ->
if @parentNode then (if @matches(css) then this else closest.call(@parentNode, css)) else null
return
)(Element.prototype)
nodeListToArray = (nodeList)-> Array.prototype.slice.call(nodeList)
nodeIndex = (node, nodeList)-> nodeListToArray(nodeList).indexOf(node)
if (!window.CustomEvent)
window.CustomEvent = do ->
NativeCustomEvent = window.CustomEvent
###*
# Cross-browser `CustomEvent` constructor.
#
# https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent
#
# @public
###
useNative = ->
try
p = new NativeCustomEvent('cat', detail: foo: 'bar')
return 'cat' == p.type and 'bar' == p.detail.foo
catch e
false
event = if useNative() then NativeCustomEvent else if 'function' == typeof document.createEvent then ((type, params) ->
e = document.createEvent('CustomEvent')
if params
e.initCustomEvent type, params.bubbles, params.cancelable, params.detail
else
e.initCustomEvent type, false, false, undefined
e
) else ((type, params) ->
e = document.createEventObject()
e.type = type
if params
e.bubbles = Boolean(params.bubbles)
e.cancelable = Boolean(params.cancelable)
e.detail = params.detail
else
e.bubbles = false
e.cancelable = false
e.detail = undefined
e
)
return event
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment