From de44d9ec349904e867104b5e39e939e0ef4740bc Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Wed, 1 Dec 2010 11:02:08 -0600 Subject: [PATCH] Update to Zepto 0.2 --- test/test-zepto.html | 2 +- test/vendor/{zepto.js => zepto-0.2.js} | 28 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) rename test/vendor/{zepto.js => zepto-0.2.js} (97%) diff --git a/test/test-zepto.html b/test/test-zepto.html index c9f54877c..44ce2a2ee 100644 --- a/test/test-zepto.html +++ b/test/test-zepto.html @@ -4,7 +4,7 @@ Backbone Test Suite - + diff --git a/test/vendor/zepto.js b/test/vendor/zepto-0.2.js similarity index 97% rename from test/vendor/zepto.js rename to test/vendor/zepto-0.2.js index 59de84a95..306342bb2 100644 --- a/test/vendor/zepto.js +++ b/test/vendor/zepto-0.2.js @@ -22,7 +22,7 @@ var Zepto = (function() { camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) } $.fn = { - ready: function(callback){ + ready: function(callback){ d.addEventListener('DOMContentLoaded', callback, false); return this; }, compact: function(){ this.dom=compact(this.dom); return this }, @@ -34,7 +34,7 @@ var Zepto = (function() { filter: function(selector){ return $(this.dom.filter(function(el){ return $$(el.parentNode, selector).indexOf(el)>=0; })); }, - is: function(selector){ + is: function(selector){ return this.dom.length>0 && $(this.dom[0]).filter(selector).dom.length>0; }, first: function(callback){ this.dom=compact([this.dom[0]]); return this }, @@ -52,8 +52,8 @@ var Zepto = (function() { prev: function(){ return $(this.pluck('previousElementSibling')) }, next: function(){ return $(this.pluck('nextElementSibling')) }, html: function(html){ - return html === un ? - (this.dom.length>0 ? this.dom[0].innerHTML : null) : + return html === un ? + (this.dom.length>0 ? this.dom[0].innerHTML : null) : this.each(function(el){ el.innerHTML = html }); }, text: function(text){ @@ -62,7 +62,7 @@ var Zepto = (function() { this.each(function(el){ el.innerText = text }); }, attr: function(name,value){ - return (typeof name == 'string' && value === un) ? + return (typeof name == 'string' && value === un) ? (this.dom.length>0 ? this.dom[0].getAttribute(name) || undefined : null) : this.each(function(el){ if (typeof name == 'object') for(k in name) el.setAttribute(k, name[k]) @@ -92,7 +92,7 @@ var Zepto = (function() { return this.each(function(el){ el.className = el.className.replace(classRE(name), ' ').trim() }); } }; - + ['width','height'].forEach(function(m){ $.fn[m] = function(){ return this.offset()[m] }}); for(k in ADJ_OPS) @@ -184,11 +184,11 @@ var Zepto = (function() { })(Zepto); (function($){ var touch={}, touchTimeout; - + function parentIfText(node){ return 'tagName' in node ? node : node.parentNode; } - + $(document).ready(function(){ $(document.body).bind('touchstart', function(e){ var now = Date.now(), delta = now-(touch.last || now); @@ -197,8 +197,8 @@ var Zepto = (function() { touch.x1 = e.touches[0].pageX; if (delta > 0 && delta <= 250) touch.isDoubleTap = true; touch.last = now; - }).bind('touchmove', function(e){ - touch.x2 = e.touches[0].pageX + }).bind('touchmove', function(e){ + touch.x2 = e.touches[0].pageX }).bind('touchend', function(e){ if (touch.isDoubleTap) { $(touch.target).trigger('doubleTap'); @@ -215,7 +215,7 @@ var Zepto = (function() { } }).bind('touchcancel', function(){ touch={} }); }); - + ['swipe', 'doubleTap', 'tap'].forEach(function(m){ $.fn[m] = function(callback){ return this.bind(m, callback) } }); @@ -245,7 +245,7 @@ var Zepto = (function() { $.getJSON = function(url, success){ $.get(url, function(json){ success(JSON.parse(json)) }); }; - + $.fn.load = function(url, success){ var self = this, parts = url.split(/\s/), selector; if(!this.dom.length) return this; @@ -261,7 +261,7 @@ var Zepto = (function() { })(Zepto); (function($){ var cache = [], timeout; - + $.fn.remove = function(){ return this.each(function(el){ if(el.tagName=='IMG'){ @@ -272,5 +272,5 @@ var Zepto = (function() { } el.parentNode.removeChild(el); }); - } + } })(Zepto);