X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2Fjquery.js;h=3816296a81107268ec17fb97eb3b4aac25ef2e51;hb=4bcb578c794acd913ec1f42793ce4b1a7388025c;hp=6f35c999f6f595d773f514b08cd7b9515b290d81;hpb=ba7dc19416cf087c6b9c590234bac78b218d5874;p=jquery.git
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 6f35c99..3816296 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -28,7 +28,7 @@ window.undefined = window.undefined;
* @name jQuery
* @cat Core
*/
-jQuery = function(a,c) {
+var jQuery = function(a,c) {
// Shortcut for document ready (because $(document).each() is silly)
if ( a && typeof a == "function" && jQuery.fn.ready )
@@ -63,12 +63,14 @@ jQuery = function(a,c) {
// Find the matching elements and save them for later
jQuery.find( a, c ) );
- // See if an extra function was provided
+ // See if an extra function was provided
var fn = arguments[ arguments.length - 1 ];
// If so, execute it in context
if ( fn && typeof fn == "function" )
this.each(fn);
+
+ return this;
};
// Map over the $ in case of overwrite
@@ -447,6 +449,10 @@ jQuery.fn = jQuery.prototype = {
* ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
* $("#check2").attr('checked', false);
* ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
+ * $("#text1").attr('readonly', true);
+ * ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
+ * $("#text1").attr('readonly', false);
+ * ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
*
* @test stop();
* $.get('data/dashboard.xml', function(xml) {
@@ -532,6 +538,14 @@ jQuery.fn = jQuery.prototype = {
* ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
* $('#foo').css({display: 'block'});
* ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+ * $('#floatTest').css({styleFloat: 'right'});
+ * ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
+ * $('#floatTest').css({cssFloat: 'left'});
+ * ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
+ * $('#floatTest').css({'float': 'right'});
+ * ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
+ * $('#floatTest').css({'font-size': '30px'});
+ * ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
*
* @name css
* @type jQuery
@@ -553,6 +567,14 @@ jQuery.fn = jQuery.prototype = {
* ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
* $('#foo').css('display', 'block');
* ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+ * $('#floatTest').css('styleFloat', 'left');
+ * ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
+ * $('#floatTest').css('cssFloat', 'right');
+ * ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
+ * $('#floatTest').css('float', 'left');
+ * ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
+ * $('#floatTest').css('font-size', '20px');
+ * ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
*
* @name css
* @type jQuery
@@ -683,6 +705,7 @@ jQuery.fn = jQuery.prototype = {
* @test var defaultText = 'Try them out:'
* var result = $('#first').append('buga');
* ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
+ * ok( $('#select3').append('').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
*
* @name append
* @type jQuery
@@ -746,6 +769,7 @@ jQuery.fn = jQuery.prototype = {
* @test var defaultText = 'Try them out:'
* var result = $('#first').prepend('buga');
* ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
+ * ok( $('#select3').prepend('').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
*
* @name prepend
* @type jQuery
@@ -1031,6 +1055,7 @@ jQuery.fn = jQuery.prototype = {
for ( var i = 0; i < t.length; i++ )
if ( jQuery.filter(t[i],[a]).r.length )
return a;
+ return false;
}) ||
t.constructor == Boolean &&
@@ -1294,8 +1319,17 @@ jQuery.fn = jQuery.prototype = {
* @cat Javascript
*/
jQuery.extend = jQuery.fn.extend = function(obj,prop) {
+ // Watch for the case where null or undefined gets passed in by accident
+ if ( arguments.length > 1 && (prop === null || prop == undefined) )
+ return obj;
+
+ // If no property object was provided, then we're extending jQuery
if ( !prop ) { prop = obj; obj = this; }
+
+ // Extend the base object
for ( var i in prop ) obj[i] = prop[i];
+
+ // Return the modified object
return obj;
};
@@ -1384,7 +1418,7 @@ jQuery.extend({
each: function( obj, fn, args ) {
if ( obj.length == undefined )
for ( var i in obj )
- if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
+ fn.apply( obj[i], args || [i, obj[i]] );
else
for ( var i = 0; i < obj.length; i++ )
if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
@@ -1445,9 +1479,11 @@ jQuery.extend({
oHeight = e.offsetHeight;
oWidth = e.offsetWidth;
} else {
- e = jQuery(e.cloneNode(true)).css({
- visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
- }).appendTo(e.parentNode)[0];
+ e = jQuery(e.cloneNode(true))
+ .find(":radio").removeAttr("checked").end()
+ .css({
+ visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
+ }).appendTo(e.parentNode)[0];
var parPos = jQuery.css(e.parentNode,"position");
if ( parPos == "" || parPos == "static" )
@@ -1489,6 +1525,9 @@ jQuery.extend({
} else if (document.defaultView && document.defaultView.getComputedStyle) {
+ if (prop == "cssFloat" || prop == "styleFloat")
+ prop = "float";
+
prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
var cur = document.defaultView.getComputedStyle(elem, null);
@@ -1505,44 +1544,37 @@ jQuery.extend({
return ret;
},
-
+
clean: function(a) {
var r = [];
for ( var i = 0; i < a.length; i++ ) {
- if ( a[i].constructor == String ) {
- // trim whitespace, otherwise indexOf won't work as expected
- a[i] = jQuery.trim(a[i]);
-
- var table = "";
-
- if ( !a[i].indexOf("" + a[i] + "";
- } else if ( !a[i].indexOf("" + a[i] + "";
- } else if ( !a[i].indexOf("