Skip to content

Commit

Permalink
Update to Zepto 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Dec 1, 2010
1 parent e0cb5ee commit de44d9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/test-zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Backbone Test Suite</title>
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="vendor/json2.js"></script>
<script type="text/javascript" src="vendor/zepto.js"></script>
<script type="text/javascript" src="vendor/zepto-0.2.js"></script>
<script type="text/javascript" src="vendor/qunit.js"></script>
<script type="text/javascript" src="vendor/jslitmus.js"></script>
<script type="text/javascript" src="vendor/underscore-1.1.0.js"></script>
Expand Down
28 changes: 14 additions & 14 deletions test/vendor/zepto.js → test/vendor/zepto-0.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
Expand All @@ -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){
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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');
Expand All @@ -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) }
});
Expand Down Expand Up @@ -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;
Expand All @@ -261,7 +261,7 @@ var Zepto = (function() {
})(Zepto);
(function($){
var cache = [], timeout;

$.fn.remove = function(){
return this.each(function(el){
if(el.tagName=='IMG'){
Expand All @@ -272,5 +272,5 @@ var Zepto = (function() {
}
el.parentNode.removeChild(el);
});
}
}
})(Zepto);

0 comments on commit de44d9e

Please sign in to comment.