From: Marius Gavrilescu Date: Sun, 8 Mar 2015 09:35:39 +0000 (+0200) Subject: Update zepto X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=f4e194efb08afa353940b77fb04dc4b5ae5da0e1;p=gruntmaster-page.git Update zepto --- diff --git a/js/00-zepto.js b/js/00-zepto.js index aa969f9..76726cd 100644 --- a/js/00-zepto.js +++ b/js/00-zepto.js @@ -1,4 +1,4 @@ -/* Zepto v1.1.4-13-geba5344 - zepto event data ie - zeptojs.com/license */ +/* Zepto v1.1.4-80-ga9184b2 - zepto event data ie - zeptojs.com/license */ var Zepto = (function() { var undefined, key, $, classList, emptyArray = [], concat = emptyArray.concat, filter = emptyArray.filter, slice = emptyArray.slice, @@ -254,11 +254,11 @@ var Zepto = (function() { maybeClass = !maybeID && selector[0] == '.', nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked isSimple = simpleSelectorRE.test(nameOnly) - return (isDocument(element) && isSimple && maybeID) ? + return (element.getElementById && isSimple && maybeID) ? // Safari DocumentFragment doesn't have getElementById ( (found = element.getElementById(nameOnly)) ? [found] : [] ) : - (element.nodeType !== 1 && element.nodeType !== 9) ? [] : + (element.nodeType !== 1 && element.nodeType !== 9 && element.nodeType !== 11) ? [] : slice.call( - isSimple && !maybeID ? + isSimple && !maybeID && element.getElementsByClassName ? // DocumentFragment doesn't have getElementsByClassName/TagName maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class element.getElementsByTagName(selector) : // Or a tag element.querySelectorAll(selector) // Or it's not simple, and we need to query all @@ -305,13 +305,12 @@ var Zepto = (function() { // JSON => parse if valid // String => self function deserializeValue(value) { - var num try { return value ? value == "true" || ( value == "false" ? false : value == "null" ? null : - !/^0/.test(value) && !isNaN(num = Number(value)) ? num : + +value + "" == value ? +value : /^[\[\{]/.test(value) ? $.parseJSON(value) : value ) : value @@ -345,6 +344,7 @@ var Zepto = (function() { $.uuid = 0 $.support = { } $.expr = { } + $.noop = function() {} $.map = function(elements, callback){ var value, values = [], i, key @@ -490,7 +490,7 @@ var Zepto = (function() { }, find: function(selector){ var result, $this = this - if (!selector) result = [] + if (!selector) result = $() else if (typeof selector == 'object') result = $(selector).filter(function(){ var node = this @@ -527,7 +527,7 @@ var Zepto = (function() { return filtered(this.map(function(){ return children(this) }), selector) }, contents: function() { - return this.map(function() { return slice.call(this.childNodes) }) + return this.map(function() { return this.contentDocument || slice.call(this.childNodes) }) }, siblings: function(selector){ return filtered(this.map(function(i, el){ @@ -676,6 +676,8 @@ var Zepto = (function() { $this.css(props) }) if (!this.length) return null + if (!$.contains(document.documentElement, this[0])) + return {top: 0, left: 0} var obj = this[0].getBoundingClientRect() return { left: obj.left + window.pageXOffset, @@ -686,8 +688,9 @@ var Zepto = (function() { }, css: function(property, value){ if (arguments.length < 2) { - var element = this[0], computedStyle = getComputedStyle(element, '') + var computedStyle, element = this[0] if(!element) return + computedStyle = getComputedStyle(element, '') if (typeof property == 'string') return element.style[camelize(property)] || computedStyle.getPropertyValue(property) else if (isArray(property)) { @@ -1078,7 +1081,7 @@ window.$ === undefined && (window.$ = Zepto) if (!isString(selector) && !isFunction(callback) && callback !== false) callback = data, data = selector, selector = undefined - if (isFunction(data) || data === false) + if (callback === undefined || data === false) callback = data, data = undefined if (callback === false) callback = returnFalse @@ -1123,8 +1126,10 @@ window.$ === undefined && (window.$ = Zepto) event = (isString(event) || $.isPlainObject(event)) ? $.Event(event) : compatible(event) event._args = args return this.each(function(){ + // handle focus(), blur() by calling them directly + if (event.type in focus && typeof this[event.type] == "function") this[event.type]() // items in the collection might not be DOM elements - if('dispatchEvent' in this) this.dispatchEvent(event) + else if ('dispatchEvent' in this) this.dispatchEvent(event) else $(this).triggerHandler(event, args) }) } @@ -1146,27 +1151,16 @@ window.$ === undefined && (window.$ = Zepto) } // shortcut methods for `.bind(event, fn)` for each event type - ;('focusin focusout load resize scroll unload click dblclick '+ + ;('focusin focusout focus blur load resize scroll unload click dblclick '+ 'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+ 'change select keydown keypress keyup error').split(' ').forEach(function(event) { $.fn[event] = function(callback) { - return callback ? + return (0 in arguments) ? this.bind(event, callback) : this.trigger(event) } }) - ;['focus', 'blur'].forEach(function(name) { - $.fn[name] = function(callback) { - if (callback) this.bind(name, callback) - else this.each(function(){ - try { this[name]() } - catch(e) {} - }) - return this - } - }) - $.Event = function(type, props) { if (!isString(type)) props = type, type = props.type var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true