/*
- * jQuery - New Wave Javascript
+ * jQuery @VERSION - New Wave Javascript
*
* Copyright (c) 2006 John Resig (jquery.com)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* @result [ <p>two</p> ]
*
* @example $("<div><p>Hello</p></div>").appendTo("#body")
- * @desc Creates a div element (and all of its contents) dynamically, and appends it to the element with the ID of body.
+ * @desc Creates a div element (and all of its contents) dynamically,
+ * and appends it to the element with the ID of body. Internally, an
+ * element is created and it's innerHTML property set to the given markup.
+ * It is therefore both quite flexible and limited.
*
* @name $
* @param String expr An expression to search with, or a string of HTML to create on the fly.
* behaves just like $(document).ready(), in that it should be used to wrap
* all of the other $() operations on your page. While this function is,
* technically, chainable - there really isn't much use for chaining against it.
+ * You can have as many $(document).ready events on your page as you like.
*
* @example $(function(){
* // Document is ready
jQuery.fn = jQuery.prototype = {
/**
- * The current SVN version of jQuery.
+ * The current version of jQuery.
*
* @private
* @property
* @type String
* @cat Core
*/
- jquery: "$Rev$",
+ jquery: "@VERSION",
/**
* The number of elements currently matched.
* ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
* ok( $('#name').attr('name') == "name", 'Check for name attribute' );
* ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
- * ok( $('#form').attr('action') == "formaction", 'Check for action attribute' );
- *
+ * ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
+ *
* @name attr
* @type Object
* @param String name The name of the property to access.
* representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
* borderStyle, borderBottomWidth etc.
*
- * @test ok( $('#foo').css("display") == 'block', 'Check for css property "display"');
+ * @test ok( $('#main').css("display") == 'none', 'Check for css property "display"');
*
* @name css
* @type Object
// Insert it before the element to be wrapped
this.parentNode.insertBefore( b, this );
- // Find he deepest point in the wrap structure
+ // Find the deepest point in the wrap structure
while ( b.firstChild )
b = b.firstChild;
* var result = $('#first').append('<b>buga</b>');
* ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
*
- * reset();
- * var expected = "Try them out: bla ";
- * $('#first').append(" ");
- * $('#first').append("bla ");
- * ok( expected == $('#first').text(), "Check for appending of spaces" );
- *
* @name append
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
* @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
*
* @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" );
+ * @test $("input").filter(":checked",function(i){
+ * ok( this == q("radio2", "check1")[i], "Filter elements, context" );
+ * });
+ * @test $("#main > p#ap > a").filter("#foobar",function(){},function(i){
+ * ok( this == q("google","groups", "mark")[i], "Filter elements, else context" );
+ * });
*
* @name filter
* @type jQuery
* @example $("p").not("#selected")
* @before <p>Hello</p><p id="selected">Hello Again</p>
* @result [ <p>Hello</p> ]
+ *
* @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
*
* @name not
is: function(expr) {
return expr ? jQuery.filter(expr,this).r.length > 0 : false;
},
-
+
/**
*
*
*/
pushStack: function(a,args) {
var fn = args && args[args.length-1];
+ var fn2 = args && args[args.length-2];
+
+ if ( fn && fn.constructor != Function ) fn = null;
+ if ( fn2 && fn2.constructor != Function ) fn2 = null;
- if ( !fn || fn.constructor != Function ) {
+ if ( !fn ) {
if ( !this.stack ) this.stack = [];
this.stack.push( this.get() );
this.get( a );
} else {
var old = this.get();
this.get( a );
- if ( typeof fn == "function" )
- this.each( fn );
- this.get( old );
+
+ if ( fn2 && a.length || !fn2 )
+ this.each( fn2 || fn ).get( old );
+ else
+ this.get( old ).each( fn );
}
return this;
o.className += ( o.className ? " " : "" ) + c;
},
remove: function(o,c){
- /*
- o.className = !c ? "" :
- o.className.replace(
- new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");*/
if( !c ) {
o.className = "";
} else {
});
return p == "height" ? oHeight : oWidth;
- } else if ( p == "opacity" && jQuery.browser.msie )
- return parseFloat( jQuery.curCSS(e,"filter").replace(/[^0-9.]/,"") ) || 1;
+ }
return jQuery.curCSS( e, p );
},
curCSS: function(elem, prop, force) {
var ret;
+
+ if (prop == 'opacity' && jQuery.browser.msie)
+ return jQuery.attr(elem.style, 'opacity');
if (!force && elem.style[prop]) {
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("<thead") || !a[i].indexOf("<tbody") ) {
enabled: "!a.disabled",
disabled: "a.disabled",
checked: "a.checked",
- selected: "a.selected",
+ selected: "a.selected || jQuery.attr(a, 'selected')",
// Form elements
text: "a.type=='text'",
disabled: "disabled",
checked: "checked"
};
+
+ // IE actually uses filters for opacity ... elem is actually elem.style
+ if (name == "opacity" && jQuery.browser.msie && value != undefined) {
+ // IE has trouble with opacity if it does not have layout
+ // Would prefer to check element.hasLayout first but don't have access to the element here
+ elem['zoom'] = 1;
+ if (value == 1) // Remove filter to avoid more IE weirdness
+ return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"");
+ else
+ return elem["filter"] = elem["filter"].replace(/alpha\([^\)]*\)/gi,"") + "alpha(opacity=" + value * 100 + ")";
+ } else if (name == "opacity" && jQuery.browser.msie) {
+ return elem["filter"] ? parseFloat( elem["filter"].match(/alpha\(opacity=(.*)\)/)[1] )/100 : 1;
+ }
+
+ // Mozilla doesn't play well with opacity 1
+ if (name == "opacity" && jQuery.browser.mozilla && value == 1) value = 0.9999;
if ( fix[name] ) {
if ( value != undefined ) elem[fix[name]] = value;
return elem[fix[name]];
+ } else if( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == 'FORM' && (name == 'action' || name == 'method') ) {
+ return elem.getAttributeNode(name).nodeValue;
} else if ( elem.getAttribute != undefined ) {
if ( value != undefined ) elem.setAttribute( name, value );
return elem.getAttribute( name, 2 );
// The regular expressions that power the parsing engine
parse: [
// Match: [@value='test'], [@foo]
- "\\[ *(@)S *([!*$^=]*)Q\\]",
+ "\\[ *(@)S *([!*$^=]*) *('?\"?)(.*?)\\4 *\\]",
// Match: [div], [div p]
- "(\\[)Q\\]",
+ "(\\[)\s*(.*?)\s*\\]",
// Match: :contains('foo')
- "(:)S\\(Q\\)",
+ "(:)S\\(\"?'?([^\\)]*?)\"?'?\\)",
// Match: :even, :last-chlid
"([:.#]*)S"
var p = jQuery.parse;
for ( var i = 0; i < p.length; i++ ) {
- // get number for backreference
- var br = 0;
- if(p[i].indexOf('Q') != -1){
- br = p[i].replace(/\\\(/g,'').match(/\(|S/g).length+1;
- }
- var re = new RegExp( "^" + p[i]
-
- // Look for a string-like sequence
- .replace( 'S', "([a-z*_-][a-z0-9_-]*)" )
-
- // Look for something (optionally) enclosed with quotes
- .replace( 'Q', " *('|\"|)([^'\"]*?)\\"+br+" *" ), "i" );
+
+ // Look for, and replace, string-like sequences
+ // and finally build a regexp out of it
+ var re = new RegExp(
+ "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" );
var m = re.exec( t );
if ( m ) {
- // Re-organize the match
- if(br == 4){
+ // Re-organize the first match
+ if ( !i )
m = ["",m[1], m[3], m[2], m[5]];
- } else if(br != 0) {
- m.splice(br,1);
- }
+
// Remove what we just matched
t = t.replace( re, "" );