X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=jquery%2Fjquery.js;h=4a960a902d2b8dd787e83a6624edf9b72cafb62c;hb=0ababc8fea6a6003be1649cfc3817d6c5628f0c7;hp=563fc295f4958acb28025ff21a446060a929c908;hpb=f0034d64e3890553f214db0708b9a831476ea46a;p=jquery.git diff --git a/jquery/jquery.js b/jquery/jquery.js index 563fc29..4a960a9 100644 --- a/jquery/jquery.js +++ b/jquery/jquery.js @@ -1,7 +1,9 @@ /* - * jQuery (http://jquery.com/) - * By John Resig (http://ejohn.org/) - * Under an Attribution, Share Alike License + * jQuery (jquery.com) + * + * Copyright (c) 2006 John Resig (ejohn.org) + * Licensed under the MIT License: + * http://www.opensource.org/licenses/mit-license.php * * $Date$ * $Rev$ @@ -67,13 +69,14 @@ function $(a,c) { }, css: function(a,b) { - return this.each(function(){ - if ( !b ) - for ( var j in a ) - $.attr(this.style,j,a[j]); - else - $.attr(this.style,a,b); - }); + return a.constructor != String || b ? + this.each(function(){ + if ( !b ) + for ( var j in a ) + $.attr(this.style,j,a[j]); + else + $.attr(this.style,a,b); + }) : $.css( this.get(0), a ); }, toggle: function() { return this.each(function(){ @@ -105,7 +108,9 @@ function $(a,c) { }, removeClass: function(c) { return this.each(function(){ - this.className = c == null ? '' : + if ( c == null ) + this.className = ''; + else this.className.replace( new RegExp('(^|\\s*\\b[^-])'+c+'($|\\b(?=[^-]))', 'g'), ''); }); @@ -141,7 +146,7 @@ function $(a,c) { var clone = this.size() > 1; var a = $.clean(arguments); return this.each(function(){ - for ( var i in a ) + for ( var i = 0; i < a.length; i++ ) this.appendChild( clone ? a[i].cloneNode(true) : a[i] ); }); }, @@ -167,7 +172,7 @@ function $(a,c) { var clone = this.size() > 1; var a = $.clean(arguments); return this.each(function(){ - for ( var i in a ) + for ( var i = 0; i < a.length; i++ ) this.parentNode.insertBefore( clone ? a[i].cloneNode(true) : a[i], this ); }); }, @@ -383,7 +388,7 @@ $.g = { checked: "a.checked" }, // TODO: Write getAttribute helper - ".": "$.hasWord(a.className||a.getAttribute('class'),m[2])", + ".": "$.hasWord(a,m[2])", "@": { "=": "$.attr(a,m[3]) == m[4]", "!=": "$.attr(a,m[3]) != m[4]", @@ -697,9 +702,10 @@ function removeEvent(element, type, handler) { } }; -function triggerEvent(element,type) { - if ( element["on" + type] ) - element["on" + type]({ type: type }); +function triggerEvent(element,type,data) { + data = data || [{ type: type }]; + if ( element && element["on" + type] ) + $.apply( element, element["on" + type], data ); } function handleEvent(event) {