diff --git a/.gitattributes b/.gitattributes index 30b22a98e82e7088b9e858d964bfd4526a171c9d..40359253f42b69ab30d5de1726243c2e8dd05f9a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -239,15 +239,12 @@ dist/javascript/articles_tous_edite.js -text dist/javascript/async_upload.js -text dist/javascript/bgiframe.js -text dist/javascript/dragdrop_interface.js -text -dist/javascript/form.js -text +dist/javascript/jquery.form.js -text dist/javascript/jquery.iepnghack.js -text dist/javascript/jquery.js -text -dist/javascript/jquery.tabs.min.js -text dist/javascript/multilang.js -text dist/javascript/pause.js -text dist/jquery.js.html -text -dist/jquery.tabs-ie.css -text -dist/jquery.tabs.css -text dist/minipres.css -text dist/modeles/article_mots.html -text dist/modeles/article_traductions.html -text @@ -447,7 +444,6 @@ ecrire/configuration/documents.php -text ecrire/configuration/futurs.php -text ecrire/configuration/index.php -text ecrire/configuration/indexeur.php -text -ecrire/configuration/interfaceur.php -text ecrire/configuration/langue.php -text ecrire/configuration/locuteur.php -text ecrire/configuration/logos.php -text diff --git a/dist/javascript/form.js b/dist/javascript/jquery.form.js similarity index 93% rename from dist/javascript/form.js rename to dist/javascript/jquery.form.js index 67134b35beed9be754105f55379cdf4474b832a1..56f87d8bc522c5d71790f7b893890281df82b1dc 100644 --- a/dist/javascript/form.js +++ b/dist/javascript/jquery.form.js @@ -1,5 +1,5 @@ /* - * jQuery form plugin + * jQuery Form Plugin * @requires jQuery v1.1 or later * * Examples at: http://malsup.com/jquery/form/ @@ -7,8 +7,7 @@ * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * - * Revision: $Id: jquery.form.js 2261 2007-07-07 19:16:35Z malsup $ - * Version: 1.0.1 Jul-07-2007 + * Revision: $Id: jquery.form.js 3028 2007-08-31 13:37:36Z joern.zaefferer $ */ (function($) { /** @@ -30,6 +29,8 @@ * type: The method in which the form data should be submitted, 'GET' or 'POST'. * default value: value of form's 'method' attribute (or 'GET' if none found) * + * data: Additional data to add to the request, specified as key/value pairs (see $.ajax). + * * beforeSubmit: Callback method to be invoked before the form is submitted. * default value: null * @@ -64,10 +65,10 @@ * The dataType option provides a means for specifying how the server response should be handled. * This maps directly to the jQuery.httpData method. The following values are supported: * - * 'xml': if dataType == 'xml' the server response is treated as XML and the 'after' + * 'xml': if dataType == 'xml' the server response is treated as XML and the 'success' * callback method, if specified, will be passed the responseXML value * 'json': if dataType == 'json' the server response will be evaluted and passed to - * the 'after' callback, if specified + * the 'success' callback, if specified * 'script': if dataType == 'script' the server response is evaluated in the global context * * @@ -183,16 +184,24 @@ $.fn.ajaxSubmit = function(options) { type: this.attr('method') || 'GET' }, options || {}); + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + $.event.trigger('form.pre.serialize', [this, options, veto]); + if (veto.veto) return this; + var a = this.formToArray(options.semantic); + if (options.data) { + for (var n in options.data) + a.push( { name: n, value: options.data[n] } ); + } // give pre-submit callback an opportunity to abort the submit if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) return this; // fire vetoable 'validate' event - var veto = {}; $.event.trigger('form.submit.validate', [a, this, options, veto]); - if (veto.veto) - return this; + if (veto.veto) return this; var q = $.param(a);//.replace(/%20/g,'+'); @@ -209,9 +218,12 @@ $.fn.ajaxSubmit = function(options) { // perform a load on the target only if dataType is not provided if (!options.dataType && options.target) { - var oldSuccess = options.success;// || function(){}; - callbacks.push(function(data, status) { - $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, [data, status]); + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + if (this.evalScripts) + $(options.target).attr("innerHTML", data).evalScripts().each(oldSuccess, arguments); + else // jQuery v1.1.4 + $(options.target).html(data).each(oldSuccess, arguments); }); } else if (options.success) @@ -219,14 +231,14 @@ $.fn.ajaxSubmit = function(options) { options.success = function(data, status) { for (var i=0, max=callbacks.length; i < max; i++) - callbacks[i](data, status); + callbacks[i](data, status, $form); }; // are there files to upload? var files = $('input:file', this).fieldValue(); var found = false; for (var j=0; j < files.length; j++) - if (files[j]) + if (files[j]) found = true; if (options.iframe || found) // options.iframe allows user to force iframe mode @@ -243,7 +255,7 @@ $.fn.ajaxSubmit = function(options) { function fileUpload() { var form = $form[0]; var opts = $.extend({}, $.ajaxSettings, options); - + var id = 'jqFormIO' + $.fn.ajaxSubmit.counter++; var $io = $('<iframe id="' + id + '" name="' + id + '" />'); var io = $io[0]; @@ -260,30 +272,30 @@ $.fn.ajaxSubmit = function(options) { getResponseHeader: function() {}, setRequestHeader: function() {} }; - + var g = opts.global; // trigger ajax global events so that activity/block indicators work like normal if (g && ! $.active++) $.event.trigger("ajaxStart"); if (g) $.event.trigger("ajaxSend", [xhr, opts]); - + var cbInvoked = 0; var timedOut = 0; - + // take a breath so that pending repaints get some cpu time before the upload starts setTimeout(function() { $io.appendTo('body'); // jQuery's event binding doesn't work for iframe events in IE io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false); - + // make sure form attrs are set var encAttr = form.encoding ? 'encoding' : 'enctype'; var t = $form.attr('target'); $form.attr({ target: id, method: 'POST', - encAttr: 'multipart/form-data', action: opts.url }); + form[encAttr] = 'multipart/form-data'; // support timout if (opts.timeout) @@ -292,10 +304,10 @@ $.fn.ajaxSubmit = function(options) { form.submit(); $form.attr('target', t); // reset target }, 10); - + function cb() { if (cbInvoked++) return; - + io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false); var ok = true; @@ -306,7 +318,7 @@ $.fn.ajaxSubmit = function(options) { doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document; xhr.responseText = doc.body ? doc.body.innerHTML : null; xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; - + if (opts.dataType == 'json' || opts.dataType == 'script') { var ta = doc.getElementsByTagName('textarea')[0]; data = ta ? ta.value : xhr.responseText; @@ -339,12 +351,12 @@ $.fn.ajaxSubmit = function(options) { if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error'); // clean up - setTimeout(function() { - $io.remove(); + setTimeout(function() { + $io.remove(); xhr.responseXML = null; }, 100); }; - + function toXml(s, doc) { if (window.ActiveXObject) { doc = new ActiveXObject('Microsoft.XMLDOM'); @@ -517,13 +529,13 @@ $.fn.formToArray = function(semantic) { a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); continue; } + var v = $.fieldValue(el, true); - if (v === null) continue; - if (v.constructor == Array) { + if (v && v.constructor == Array) { for(var j=0, jmax=v.length; j < jmax; j++) a.push({name: n, value: v[j]}); } - else + else if (v !== null && typeof v != 'undefined') a.push({name: n, value: v}); } diff --git a/dist/javascript/jquery.js b/dist/javascript/jquery.js index de4910674a54e84548fd286162efb8c8bba84b61..c267041a939ca1d30c9bf3395c5ecbf15c43b483 100644 --- a/dist/javascript/jquery.js +++ b/dist/javascript/jquery.js @@ -1,67 +1,87 @@ -// prevent execution of jQuery if included more than once -if(typeof window.jQuery == "undefined") { +(function(){ /* - * jQuery 1.1.3.1 - New Wave Javascript + * jQuery 1.2.1 - New Wave Javascript * * Copyright (c) 2007 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * - * $Date: 2007-07-05 10:19:18 +0200 (Thu, 05 Jul 2007) $ - * $Rev: 2248 $ + * $Date: 2007-09-18 16:35:41 +0200 (Tue, 18 Sep 2007) $ + * $Rev: 3387 $ */ -// Global undefined variable -window.undefined = window.undefined; -var jQuery = function(a,c) { - // If the context is global, return a new object - if ( window == this || !this.init ) - return new jQuery(a,c); - - return this.init(a,c); +// Map over jQuery in case of overwrite +if ( typeof jQuery != "undefined" ) + var _jQuery = jQuery; + +var jQuery = window.jQuery = function(selector, context) { + // If the context is a namespace object, return a new object + return this instanceof jQuery ? + this.init(selector, context) : + new jQuery(selector, context); }; // Map over the $ in case of overwrite if ( typeof $ != "undefined" ) - jQuery._$ = $; + var _$ = $; // Map the jQuery namespace to the '$' one -var $ = jQuery; +window.$ = jQuery; + +var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; jQuery.fn = jQuery.prototype = { - init: function(a,c) { + init: function(selector, context) { // Make sure that a selection was provided - a = a || document; - - // HANDLE: $(function) - // Shortcut for document ready - if ( jQuery.isFunction(a) ) - return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a ); + selector = selector || document; // Handle HTML strings - if ( typeof a == "string" ) { - // HANDLE: $(html) -> $(array) - var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a); - if ( m ) - a = jQuery.clean( [ m[1] ] ); + if ( typeof selector == "string" ) { + var m = quickExpr.exec(selector); + if ( m && (m[1] || !context) ) { + // HANDLE: $(html) -> $(array) + if ( m[1] ) + selector = jQuery.clean( [ m[1] ], context ); + + // HANDLE: $("#id") + else { + var tmp = document.getElementById( m[3] ); + if ( tmp ) + // Handle the case where IE and Opera return items + // by name instead of ID + if ( tmp.id != m[3] ) + return jQuery().find( selector ); + else { + this[0] = tmp; + this.length = 1; + return this; + } + else + selector = []; + } // HANDLE: $(expr) - else - return new jQuery( c ).find( a ); - } + } else + return new jQuery( context ).find( selector ); + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction(selector) ) + return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( selector ); return this.setArray( // HANDLE: $(array) - a.constructor == Array && a || + selector.constructor == Array && selector || // HANDLE: $(arraylike) // Watch for when an array-like object is passed as the selector - (a.jquery || a.length && a != window && !a.nodeType && a[0] != undefined && a[0].nodeType) && jQuery.makeArray( a ) || + (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) || // HANDLE: $(*) - [ a ] ); + [ selector ] ); }, - jquery: "1.1.3.1", + + jquery: "1.2.1", size: function() { return this.length; @@ -78,19 +98,23 @@ jQuery.fn = jQuery.prototype = { // Return just the object this[num]; }, + pushStack: function( a ) { var ret = jQuery(a); ret.prevObject = this; return ret; }, + setArray: function( a ) { this.length = 0; - [].push.apply( this, a ); + Array.prototype.push.apply( this, a ); return this; }, + each: function( fn, args ) { return jQuery.each( this, fn, args ); }, + index: function( obj ) { var pos = -1; this.each(function(i){ @@ -127,7 +151,7 @@ jQuery.fn = jQuery.prototype = { }, text: function(e) { - if ( typeof e == "string" ) + if ( typeof e != "object" && e != null ) return this.empty().append( document.createTextNode( e ) ); var t = ""; @@ -141,89 +165,101 @@ jQuery.fn = jQuery.prototype = { return t; }, - wrap: function() { - // The elements to wrap the target around - var a, args = arguments; - - // Wrap each of the matched elements individually - return this.each(function(){ - if ( !a ) - a = jQuery.clean(args, this.ownerDocument); - - // Clone the structure that we're using to wrap - var b = a[0].cloneNode(true); + wrapAll: function(html) { + if ( this[0] ) + // The elements to wrap the target around + jQuery(html, this[0].ownerDocument) + .clone() + .insertBefore(this[0]) + .map(function(){ + var elem = this; + while ( elem.firstChild ) + elem = elem.firstChild; + return elem; + }) + .append(this); - // Insert it before the element to be wrapped - this.parentNode.insertBefore( b, this ); + return this; + }, - // Find the deepest point in the wrap structure - while ( b.firstChild ) - b = b.firstChild; + wrapInner: function(html) { + return this.each(function(){ + jQuery(this).contents().wrapAll(html); + }); + }, - // Move the matched element to within the wrap structure - b.appendChild( this ); + wrap: function(html) { + return this.each(function(){ + jQuery(this).wrapAll(html); }); }, + append: function() { return this.domManip(arguments, true, 1, function(a){ this.appendChild( a ); }); }, + prepend: function() { return this.domManip(arguments, true, -1, function(a){ this.insertBefore( a, this.firstChild ); }); }, + before: function() { return this.domManip(arguments, false, 1, function(a){ this.parentNode.insertBefore( a, this ); }); }, + after: function() { return this.domManip(arguments, false, -1, function(a){ this.parentNode.insertBefore( a, this.nextSibling ); }); }, + end: function() { return this.prevObject || jQuery([]); }, + find: function(t) { var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? jQuery.unique( data ) : data ); }, - clone: function(deep) { - // Need to remove events on the element and its descendants - var $this = this.add(this.find("*")); - $this.each(function() { - this._$events = {}; - for (var type in this.$events) - this._$events[type] = jQuery.extend({},this.$events[type]); - }).unbind(); + clone: function(events) { // Do the clone - var r = this.pushStack( jQuery.map( this, function(a){ - return a.cloneNode( deep != undefined ? deep : true ); - }) ); - - // Add the events back to the original and its descendants - $this.each(function() { - var events = this._$events; - for (var type in events) - for (var handler in events[type]) - jQuery.event.add(this, type, events[type][handler], events[type][handler].data); - this._$events = null; + var ret = this.map(function(){ + return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true); }); + // Need to set the expando to null on the cloned set if it exists + // removeData doesn't work here, IE removes it from the original as well + // this is primarily for IE but the data expando shouldn't be copied over in any browser + var clone = ret.find("*").andSelf().each(function(){ + if ( this[ expando ] != undefined ) + this[ expando ] = null; + }); + + // Copy the events from the original to the clone + if (events === true) + this.find("*").andSelf().each(function(i) { + var events = jQuery.data(this, "events"); + for ( var type in events ) + for ( var handler in events[type] ) + jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data); + }); + // Return the cloned set - return r; + return ret; }, filter: function(t) { return this.pushStack( jQuery.isFunction( t ) && jQuery.grep(this, function(el, index){ - return t.apply(el, [index]) + return t.apply(el, [index]); }) || jQuery.multiFilter(t,this) ); @@ -247,26 +283,106 @@ jQuery.fn = jQuery.prototype = { this.get(), t.constructor == String ? jQuery(t).get() : - t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ? + t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ? t : [t] ) ); }, + is: function(expr) { return expr ? jQuery.multiFilter(expr,this).length > 0 : false; }, - val: function( val ) { - return val == undefined ? - ( this.length ? this[0].value : null ) : - this.attr( "value", val ); + hasClass: function(expr) { + return this.is("." + expr); }, + + val: function( val ) { + if ( val == undefined ) { + if ( this.length ) { + var elem = this[0]; + + // We need to handle select boxes special + if ( jQuery.nodeName(elem, "select") ) { + var index = elem.selectedIndex, + a = [], + options = elem.options, + one = elem.type == "select-one"; + + // Nothing was selected + if ( index < 0 ) + return null; + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[i]; + if ( option.selected ) { + // Get the specifc value for the option + var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value; + + // We don't need an array for one selects + if ( one ) + return val; + + // Multi-Selects return an array + a.push(val); + } + } + + return a; + + // Everything else, we just grab the value + } else + return this[0].value.replace(/\r/g, ""); + } + } else + return this.each(function(){ + if ( val.constructor == Array && /radio|checkbox/.test(this.type) ) + this.checked = (jQuery.inArray(this.value, val) >= 0 || + jQuery.inArray(this.name, val) >= 0); + else if ( jQuery.nodeName(this, "select") ) { + var tmp = val.constructor == Array ? val : [val]; + + jQuery("option", this).each(function(){ + this.selected = (jQuery.inArray(this.value, tmp) >= 0 || + jQuery.inArray(this.text, tmp) >= 0); + }); + if ( !tmp.length ) + this.selectedIndex = -1; + } else + this.value = val; + }); + }, + html: function( val ) { return val == undefined ? ( this.length ? this[0].innerHTML : null ) : this.empty().append( val ); }, - domManip: function(args, table, dir, fn){ + + replaceWith: function( val ) { + return this.after( val ).remove(); + }, + + eq: function(i){ + return this.slice(i, i+1); + }, + + slice: function() { + return this.pushStack( Array.prototype.slice.apply( this, arguments ) ); + }, + + map: function(fn) { + return this.pushStack(jQuery.map( this, function(elem,i){ + return fn.call( elem, i, elem ); + })); + }, + + andSelf: function() { + return this.add( this.prevObject ); + }, + + domManip: function(args, table, dir, fn) { var clone = this.length > 1, a; return this.each(function(){ @@ -282,35 +398,79 @@ jQuery.fn = jQuery.prototype = { obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody")); jQuery.each( a, function(){ - fn.apply( obj, [ clone ? this.cloneNode(true) : this ] ); + var elem = clone ? this.cloneNode(true) : this; + if ( !evalScript(0, elem) ) + fn.call( obj, elem ); }); - }); } }; +function evalScript(i, elem){ + var script = jQuery.nodeName(elem, "script"); + + if ( script ) { + if ( elem.src ) + jQuery.ajax({ url: elem.src, async: false, dataType: "script" }); + else + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); + + if ( elem.parentNode ) + elem.parentNode.removeChild(elem); + + } else if ( elem.nodeType == 1 ) + jQuery("script", elem).each(evalScript); + + return script; +} + jQuery.extend = jQuery.fn.extend = function() { // copy reference to target object - var target = arguments[0], a = 1; + var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false; + + // Handle a deep copy situation + if ( target.constructor == Boolean ) { + deep = target; + target = arguments[1] || {}; + } // extend jQuery itself if only one argument is passed - if ( arguments.length == 1 ) { + if ( al == 1 ) { target = this; a = 0; } + var prop; - while ( (prop = arguments[a++]) != null ) - // Extend the base object - for ( var i in prop ) target[i] = prop[i]; + + for ( ; a < al; a++ ) + // Only deal with non-null/undefined values + if ( (prop = arguments[a]) != null ) + // Extend the base object + for ( var i in prop ) { + // Prevent never-ending loop + if ( target == prop[i] ) + continue; + + // Recurse if we're merging object values + if ( deep && typeof prop[i] == 'object' && target[i] ) + jQuery.extend( target[i], prop[i] ); + + // Don't bring in undefined values + else if ( prop[i] != undefined ) + target[i] = prop[i]; + } // Return the modified object return target; }; +var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {}; + jQuery.extend({ - noConflict: function() { - if ( jQuery._$ ) - $ = jQuery._$; + noConflict: function(deep) { + window.$ = _$; + if ( deep ) + window.jQuery = _jQuery; return jQuery; }, @@ -323,20 +483,108 @@ jQuery.extend({ // check if an element is in a XML document isXMLDoc: function(elem) { - return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; + return elem.documentElement && !elem.body || + elem.tagName && elem.ownerDocument && !elem.ownerDocument.body; + }, + + // Evalulates a script in a global context + // Evaluates Async. in Safari 2 :-( + globalEval: function( data ) { + data = jQuery.trim( data ); + if ( data ) { + if ( window.execScript ) + window.execScript( data ); + else if ( jQuery.browser.safari ) + // safari doesn't provide a synchronous global eval + window.setTimeout( data, 0 ); + else + eval.call( window, data ); + } }, nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); }, + + cache: {}, + + data: function( elem, name, data ) { + elem = elem == window ? win : elem; + + var id = elem[ expando ]; + + // Compute a unique ID for the element + if ( !id ) + id = elem[ expando ] = ++uuid; + + // Only generate the data cache if we're + // trying to access or manipulate it + if ( name && !jQuery.cache[ id ] ) + jQuery.cache[ id ] = {}; + + // Prevent overriding the named cache with undefined values + if ( data != undefined ) + jQuery.cache[ id ][ name ] = data; + + // Return the named cache data, or the ID for the element + return name ? jQuery.cache[ id ][ name ] : id; + }, + + removeData: function( elem, name ) { + elem = elem == window ? win : elem; + + var id = elem[ expando ]; + + // If we want to remove a specific section of the element's data + if ( name ) { + if ( jQuery.cache[ id ] ) { + // Remove the section of cache data + delete jQuery.cache[ id ][ name ]; + + // If we've removed all the data, remove the element's cache + name = ""; + for ( name in jQuery.cache[ id ] ) break; + if ( !name ) + jQuery.removeData( elem ); + } + + // Otherwise, we want to remove all of the element's data + } else { + // Clean up the element expando + try { + delete elem[ expando ]; + } catch(e){ + // IE has trouble directly removing the expando + // but it's ok with using removeAttribute + if ( elem.removeAttribute ) + elem.removeAttribute( expando ); + } + + // Completely remove the data cache + delete jQuery.cache[ id ]; + } + }, + // args is for internal usage only each: function( obj, fn, args ) { - if ( obj.length == undefined ) - for ( var i in obj ) - fn.apply( obj[i], args || [i, obj[i]] ); - else - for ( var i = 0, ol = obj.length; i < ol; i++ ) - if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break; + if ( args ) { + if ( obj.length == undefined ) + for ( var i in obj ) + fn.apply( obj[i], args ); + else + for ( var i = 0, ol = obj.length; i < ol; i++ ) + if ( fn.apply( obj[i], args ) === false ) break; + + // A special, fast, case for the most common use of each + } else { + if ( obj.length == undefined ) + for ( var i in obj ) + fn.call( obj[i], i, obj[i] ); + else + for ( var i = 0, ol = obj.length, val = obj[0]; + i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){} + } + return obj; }, @@ -357,7 +605,7 @@ jQuery.extend({ className: { // internal only, use addClass("class") add: function( elem, c ){ - jQuery.each( c.split(/\s+/), function(i, cur){ + jQuery.each( (c || "").split(/\s+/), function(i, cur){ if ( !jQuery.className.has( elem.className, cur ) ) elem.className += ( elem.className ? " " : "" ) + cur; }); @@ -376,6 +624,7 @@ jQuery.extend({ return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1; } }, + swap: function(e,o,f) { for ( var i in o ) { e.style["old"+i] = e.style[i]; @@ -427,7 +676,16 @@ jQuery.extend({ }, curCSS: function(elem, prop, force) { - var ret; + var ret, stack = [], swap = []; + + // A helper method for determining if an element's values are broken + function color(a){ + if ( !jQuery.browser.safari ) + return false; + + var ret = document.defaultView.getComputedStyle(a,null); + return !ret || ret.getPropertyValue("color") == ""; + } if (prop == "opacity" && jQuery.browser.msie) { ret = jQuery.attr(elem.style, "opacity"); @@ -435,7 +693,7 @@ jQuery.extend({ } if (prop.match(/float/i)) - prop = jQuery.styleFloat; + prop = styleFloat; if (!force && elem.style[prop]) ret = elem.style[prop]; @@ -448,19 +706,57 @@ jQuery.extend({ prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase(); var cur = document.defaultView.getComputedStyle(elem, null); - if ( cur ) + if ( cur && !color(elem) ) ret = cur.getPropertyValue(prop); - else if ( prop == "display" ) - ret = "none"; - else - jQuery.swap(elem, { display: "block" }, function() { - var c = document.defaultView.getComputedStyle(this, ""); - ret = c && c.getPropertyValue(prop) || ""; - }); + + // If the element isn't reporting its values properly in Safari + // then some display: none elements are involved + else { + // Locate all of the parent display: none elements + for ( var a = elem; a && color(a); a = a.parentNode ) + stack.unshift(a); + + // Go through and make them visible, but in reverse + // (It would be better if we knew the exact display type that they had) + for ( a = 0; a < stack.length; a++ ) + if ( color(stack[a]) ) { + swap[a] = stack[a].style.display; + stack[a].style.display = "block"; + } + + // Since we flip the display style, we have to handle that + // one special, otherwise get the value + ret = prop == "display" && swap[stack.length-1] != null ? + "none" : + document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || ""; + + // Finally, revert the display styles back + for ( a = 0; a < swap.length; a++ ) + if ( swap[a] != null ) + stack[a].style.display = swap[a]; + } + + if ( prop == "opacity" && ret == "" ) + ret = "1"; } else if (elem.currentStyle) { var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();}); ret = elem.currentStyle[prop] || elem.currentStyle[newProp]; + + // From the awesome hack by Dean Edwards + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 + + // If we're not dealing with a regular pixel number + // but a number that has a weird ending, we need to convert it to pixels + if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) { + var style = elem.style.left; + var runtimeStyle = elem.runtimeStyle.left; + elem.runtimeStyle.left = elem.currentStyle.left; + elem.style.left = ret || 0; + ret = elem.style.pixelLeft + "px"; + elem.style.left = style; + elem.runtimeStyle.left = runtimeStyle; + } } return ret; @@ -478,6 +774,11 @@ jQuery.extend({ // Convert html string into DOM nodes if ( typeof arg == "string" ) { + // Fix "XHTML"-style tags in all browsers + arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){ + return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+"></"+tag+">"; + }); + // Trim whitespace, otherwise indexOf won't work as expected var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = []; @@ -489,7 +790,7 @@ jQuery.extend({ !s.indexOf("<leg") && [1, "<fieldset>", "</fieldset>"] || - (!s.indexOf("<thead") || !s.indexOf("<tbody") || !s.indexOf("<tfoot") || !s.indexOf("<colg")) && + s.match(/^<(thead|tbody|tfoot|colg|cap)/) && [1, "<table>", "</table>"] || !s.indexOf("<tr") && @@ -500,7 +801,11 @@ jQuery.extend({ [3, "<table><tbody><tr>", "</tr></tbody></table>"] || !s.indexOf("<col") && - [2, "<table><colgroup>", "</colgroup></table>"] || + [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] || + + // IE can't serialize <link> and <script> tags normally + jQuery.browser.msie && + [1, "div<div>", "</div>"] || [0,"",""]; @@ -509,7 +814,7 @@ jQuery.extend({ // Move to the right depth while ( wrap[0]-- ) - div = div.firstChild; + div = div.lastChild; // Remove IE's autoinserted <tbody> from table fragments if ( jQuery.browser.msie ) { @@ -525,7 +830,11 @@ jQuery.extend({ for ( var n = tb.length-1; n >= 0 ; --n ) if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length ) tb[n].parentNode.removeChild(tb[n]); - + + // IE completely kills leading whitespace when innerHTML is used + if ( /^\s/.test(arg) ) + div.insertBefore( doc.createTextNode( arg.match(/^\s*/)[0] ), div.firstChild ); + } arg = jQuery.makeArray( div.childNodes ); @@ -546,22 +855,34 @@ jQuery.extend({ attr: function(elem, name, value){ var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props; + + // Safari mis-reports the default selected property of a hidden option + // Accessing the parent's selectedIndex property fixes it + if ( name == "selected" && jQuery.browser.safari ) + elem.parentNode.selectedIndex; // Certain attributes only work when accessed via the old DOM 0 way if ( fix[name] ) { if ( value != undefined ) elem[fix[name]] = value; return elem[fix[name]]; + } else if ( jQuery.browser.msie && name == "style" ) + return jQuery.attr( elem.style, "cssText", value ); - } else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") ) + else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") ) return elem.getAttributeNode(name).nodeValue; // IE elem.getAttribute passes even for style else if ( elem.tagName ) { - - if ( value != undefined ) elem.setAttribute( name, value ); + if ( value != undefined ) { + if ( name == "type" && jQuery.nodeName(elem,"input") && elem.parentNode ) + throw "type property can't be changed"; + elem.setAttribute( name, value ); + } + if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) return elem.getAttribute( name, 2 ); + return elem.getAttribute( name ); // elem is actually elem.style ... set the style @@ -586,8 +907,9 @@ jQuery.extend({ return elem[name]; } }, + trim: function(t){ - return t.replace(/^\s+|\s+$/g, ""); + return (t||"").replace(/^\s+|\s+$/g, ""); }, makeArray: function( a ) { @@ -609,31 +931,47 @@ jQuery.extend({ return i; return -1; }, + merge: function(first, second) { // We have to loop this way because IE & Opera overwrite the length // expando of getElementsByTagName - for ( var i = 0; second[i]; i++ ) - first.push(second[i]); + + // Also, we need to make sure that the correct elements are being returned + // (IE returns comment nodes in a '*' query) + if ( jQuery.browser.msie ) { + for ( var i = 0; second[i]; i++ ) + if ( second[i].nodeType != 8 ) + first.push(second[i]); + } else + for ( var i = 0; second[i]; i++ ) + first.push(second[i]); + return first; }, + unique: function(first) { - var r = [], num = jQuery.mergeNum++; + var r = [], done = {}; - for ( var i = 0, fl = first.length; i < fl; i++ ) - if ( num != first[i].mergeNum ) { - first[i].mergeNum = num; - r.push(first[i]); + try { + for ( var i = 0, fl = first.length; i < fl; i++ ) { + var id = jQuery.data(first[i]); + if ( !done[id] ) { + done[id] = true; + r.push(first[i]); + } } + } catch(e) { + r = first; + } return r; }, - mergeNum: 0, grep: function(elems, fn, inv) { // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) - fn = new Function("a","i","return " + fn); + fn = eval("false||function(a,i){return " + fn + "}"); var result = []; @@ -645,11 +983,12 @@ jQuery.extend({ return result; }, + map: function(elems, fn) { // If a string is passed in for the function, make a function // for it (a handy shortcut) if ( typeof fn == "string" ) - fn = new Function("a","return " + fn); + fn = eval("false||function(a){return " + fn + "}"); var result = []; @@ -667,38 +1006,32 @@ jQuery.extend({ return result; } }); - -/* - * Whether the W3C compliant box model is being used. - * - * @property - * @name $.boxModel - * @type Boolean - * @cat JavaScript - */ -new function() { - var b = navigator.userAgent.toLowerCase(); - - // Figure out what browser is being used - jQuery.browser = { - version: (b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], - safari: /webkit/.test(b), - opera: /opera/.test(b), - msie: /msie/.test(b) && !/opera/.test(b), - mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b) - }; - // Check to see if the W3C box model is being used - jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat"; +var userAgent = navigator.userAgent.toLowerCase(); - jQuery.styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat", +// Figure out what browser is being used +jQuery.browser = { + version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1], + safari: /webkit/.test(userAgent), + opera: /opera/.test(userAgent), + msie: /msie/.test(userAgent) && !/opera/.test(userAgent), + mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) +}; - jQuery.props = { +var styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat"; + +jQuery.extend({ + // Check to see if the W3C box model is being used + boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat", + + styleFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat", + + props: { "for": "htmlFor", "class": "className", - "float": jQuery.styleFloat, - cssFloat: jQuery.styleFloat, - styleFloat: jQuery.styleFloat, + "float": styleFloat, + cssFloat: styleFloat, + styleFloat: styleFloat, innerHTML: "innerHTML", className: "className", value: "value", @@ -706,23 +1039,27 @@ new function() { checked: "checked", readonly: "readOnly", selected: "selected", - maxlength: "maxLength" - }; -}; + maxlength: "maxLength", + selectedIndex: "selectedIndex" + } +}); jQuery.each({ parent: "a.parentNode", - parents: "jQuery.parents(a)", + parents: "jQuery.dir(a,'parentNode')", next: "jQuery.nth(a,2,'nextSibling')", prev: "jQuery.nth(a,2,'previousSibling')", + nextAll: "jQuery.dir(a,'nextSibling')", + prevAll: "jQuery.dir(a,'previousSibling')", siblings: "jQuery.sibling(a.parentNode.firstChild,a)", - children: "jQuery.sibling(a.firstChild)" + children: "jQuery.sibling(a.firstChild)", + contents: "jQuery.nodeName(a,'iframe')?a.contentDocument||a.contentWindow.document:jQuery.makeArray(a.childNodes)" }, function(i,n){ jQuery.fn[ i ] = function(a) { var ret = jQuery.map(this,n); if ( a && typeof a == "string" ) ret = jQuery.multiFilter(a,ret); - return this.pushStack( ret ); + return this.pushStack( jQuery.unique(ret) ); }; }); @@ -730,7 +1067,8 @@ jQuery.each({ appendTo: "append", prependTo: "prepend", insertBefore: "before", - insertAfter: "after" + insertAfter: "after", + replaceAll: "replaceWith" }, function(i,n){ jQuery.fn[ i ] = function(){ var a = arguments; @@ -756,10 +1094,15 @@ jQuery.each( { jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c); }, remove: function(a){ - if ( !a || jQuery.filter( a, [this] ).r.length ) + if ( !a || jQuery.filter( a, [this] ).r.length ) { + jQuery.removeData( this ); this.parentNode.removeChild( this ); + } }, empty: function() { + // Clean up the cache + jQuery("*", this).each(function(){ jQuery.removeData(this); }); + while ( this.firstChild ) this.removeChild( this.firstChild ); } @@ -769,19 +1112,42 @@ jQuery.each( { }; }); -jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){ - jQuery.fn[ n ] = function(num,fn) { - return this.filter( ":" + n + "(" + num + ")", fn ); - }; -}); - -jQuery.each( [ "height", "width" ], function(i,n){ +jQuery.each( [ "Height", "Width" ], function(i,name){ + var n = name.toLowerCase(); + jQuery.fn[ n ] = function(h) { - return h == undefined ? - ( this.length ? jQuery.css( this[0], n ) : null ) : - this.css( n, h.constructor == String ? h : h + "px" ); + // Get window width or height + return this[0] == window ? + // Opera reports document.body.client[Width/Height] properly in both quirks and standards + jQuery.browser.opera && document.body["client" + name] || + + // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths) + jQuery.browser.safari && self["inner" + name] || + + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode + document.compatMode == "CSS1Compat" && document.documentElement["client" + name] || document.body["client" + name] : + + // Get document width or height + this[0] == document ? + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth) + Math.max( document.body["scroll" + name], document.body["offset" + name] ) : + + // Get or set width or height on the element + h == undefined ? + // Get width or height on the element + ( this.length ? jQuery.css( this[0], n ) : null ) : + // Set the width or height on the element (default to pixels if value is unitless) + this.css( n, h.constructor == String ? h : h + "px" ); }; }); + +var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ? + "(?:[\\w*_-]|\\\\.)" : + "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)", + quickChild = new RegExp("^>\\s*(" + chars + "+)"), + quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"), + quickClass = new RegExp("^([#.]?)(" + chars + "*)"); + jQuery.extend({ expr: { "": "m[2]=='*'||jQuery.nodeName(a,m[2])", @@ -807,7 +1173,7 @@ jQuery.extend({ empty: "!a.firstChild", // Text Check - contains: "(a.textContent||a.innerText||'').indexOf(m[3])>=0", + contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0", // Visibility visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"', @@ -829,25 +1195,29 @@ jQuery.extend({ image: "'image'==a.type", reset: "'reset'==a.type", button: '"button"==a.type||jQuery.nodeName(a,"button")', - input: "/input|select|textarea|button/i.test(a.nodeName)" - }, - "[": "jQuery.find(m[2],a).length" + input: "/input|select|textarea|button/i.test(a.nodeName)", + + // :has() + has: "jQuery.find(m[3],a).length", + + // :header + header: "/h\\d/i.test(a.nodeName)", + + // :animated + animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length" + } }, // The regular expressions that power the parsing engine parse: [ // Match: [@value='test'], [@foo] - /^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, - - // Match: [div], [div p] - /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/, + /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, // Match: :contains('foo') /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/, // Match: :even, :last-chlid, #id, .class - new RegExp("^([:.#]*)(" + - ( jQuery.chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ? "(?:[\\w*_-]|\\\\.)" : "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)") + new RegExp("^([:.#]*)(" + chars + "+)") ], multiFilter: function( expr, elems, not ) { @@ -862,6 +1232,7 @@ jQuery.extend({ return cur; }, + find: function( t, context ) { // Quickly handle non-string expressions if ( typeof t != "string" ) @@ -874,19 +1245,6 @@ jQuery.extend({ // Set the correct context (if none is provided) context = context || document; - // Handle the common XPath // expression - if ( !t.indexOf("//") ) { - context = context.documentElement; - t = t.substr(2,t.length); - - // And the / root expression - } else if ( !t.indexOf("/") && !context.ownerDocument ) { - context = context.documentElement; - t = t.substr(1,t.length); - if ( t.indexOf("/") >= 1 ) - t = t.substr(t.indexOf("/"),t.length); - } - // Initialize the search var ret = [context], done = [], last; @@ -896,13 +1254,13 @@ jQuery.extend({ var r = []; last = t; - t = jQuery.trim(t).replace( /^\/\//, "" ); + t = jQuery.trim(t); var foundToken = false; // An attempt at speeding up child selectors that // point to a specific element tag - var re = new RegExp("^[/>]\\s*(" + jQuery.chars + "+)"); + var re = quickChild; var m = re.exec(t); if ( m ) { @@ -919,30 +1277,30 @@ jQuery.extend({ if ( t.indexOf(" ") == 0 ) continue; foundToken = true; } else { - re = /^((\/?\.\.)|([>\/+~]))\s*([a-z]*)/i; + re = /^([>+~])\s*(\w*)/i; if ( (m = re.exec(t)) != null ) { r = []; - var nodeName = m[4], mergeNum = jQuery.mergeNum++; + var nodeName = m[2], merge = {}; m = m[1]; - for ( var j = 0, rl = ret.length; j < rl; j++ ) - if ( m.indexOf("..") < 0 ) { - var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; - for ( ; n; n = n.nextSibling ) - if ( n.nodeType == 1 ) { - if ( m == "~" && n.mergeNum == mergeNum ) break; - - if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) { - if ( m == "~" ) n.mergeNum = mergeNum; - r.push( n ); - } - - if ( m == "+" ) break; + for ( var j = 0, rl = ret.length; j < rl; j++ ) { + var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild; + for ( ; n; n = n.nextSibling ) + if ( n.nodeType == 1 ) { + var id = jQuery.data(n); + + if ( m == "~" && merge[id] ) break; + + if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) { + if ( m == "~" ) merge[id] = true; + r.push( n ); } - } else - r.push( ret[j].parentNode ); + + if ( m == "+" ) break; + } + } ret = r; @@ -971,7 +1329,7 @@ jQuery.extend({ } else { // Optimize for the case nodeName#idName - var re2 = new RegExp("^(" + jQuery.chars + "+)(#)(" + jQuery.chars + "+)"); + var re2 = quickID; var m = re2.exec(t); // Re-organize the results, so that they're consistent @@ -981,7 +1339,7 @@ jQuery.extend({ } else { // Otherwise, do a traditional filter check for // ID, class, and element selectors - re2 = new RegExp("^([#.]?)(" + jQuery.chars + "*)"); + re2 = quickClass; m = re2.exec(t); } @@ -990,7 +1348,7 @@ jQuery.extend({ var elem = ret[ret.length-1]; // Try to do a global search by ID, where we can - if ( m[1] == "#" && elem && elem.getElementById ) { + if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) { // Optimization for HTML document case var oid = elem.getElementById(m[2]); @@ -1007,7 +1365,7 @@ jQuery.extend({ // We need to find all descendant elements for ( var i = 0; ret[i]; i++ ) { // Grab the tag name being searched for - var tag = m[1] != "" || m[0] == "" ? "*" : m[2]; + var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2]; // Handle IE7 being really dumb about <object>s if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" ) @@ -1110,13 +1468,13 @@ jQuery.extend({ else if ( m[1] == "." ) r = jQuery.classFilter(r, m[2], not); - else if ( m[1] == "@" ) { + else if ( m[1] == "[" ) { var tmp = [], type = m[3]; for ( var i = 0, rl = r.length; i < rl; i++ ) { var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ]; - if ( z == null || /href|src/.test(m[2]) ) + if ( z == null || /href|src|selected/.test(m[2]) ) z = jQuery.attr(a,m[2]) || ''; if ( (type == "" && !!z || @@ -1132,23 +1490,23 @@ jQuery.extend({ // We can get a speed boost by handling nth-child here } else if ( m[1] == ":" && m[2] == "nth-child" ) { - var num = jQuery.mergeNum++, tmp = [], + var merge = {}, tmp = [], test = /(\d*)n\+?(\d*)/.exec( m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" || !/\D/.test(m[3]) && "n+" + m[3] || m[3]), first = (test[1] || 1) - 0, last = test[2] - 0; for ( var i = 0, rl = r.length; i < rl; i++ ) { - var node = r[i], parentNode = node.parentNode; + var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode); - if ( num != parentNode.mergeNum ) { + if ( !merge[id] ) { var c = 1; for ( var n = parentNode.firstChild; n; n = n.nextSibling ) if ( n.nodeType == 1 ) n.nodeIndex = c++; - parentNode.mergeNum = num; + merge[id] = true; } var add = false; @@ -1172,7 +1530,7 @@ jQuery.extend({ f = jQuery.expr[m[1]][m[2]]; // Build a custom macro to enclose it - eval("f = function(a,i){return " + f + "}"); + f = eval("false||function(a,i){return " + f + "}"); // Execute it against the current filter r = jQuery.grep( r, f, not ); @@ -1183,15 +1541,18 @@ jQuery.extend({ // and the modified expression string (t) return { r: r, t: t }; }, - parents: function( elem ){ + + dir: function( elem, dir ){ var matched = []; - var cur = elem.parentNode; + var cur = elem[dir]; while ( cur && cur != document ) { - matched.push( cur ); - cur = cur.parentNode; + if ( cur.nodeType == 1 ) + matched.push( cur ); + cur = cur[dir]; } return matched; }, + nth: function(cur,result,dir,elem){ result = result || 1; var num = 0; @@ -1202,6 +1563,7 @@ jQuery.extend({ return cur; }, + sibling: function( n, elem ) { var r = []; @@ -1227,14 +1589,14 @@ jQuery.event = { // around, causing it to be cloned in the process if ( jQuery.browser.msie && element.setInterval != undefined ) element = window; - + // Make sure that the function being executed has a unique ID if ( !handler.guid ) handler.guid = this.guid++; // if data is passed, bind to handler if( data != undefined ) { - // Create temporary function pointer to original handler + // Create temporary function pointer to original handler var fn = handler; // Create unique handler function, wrapped around original handler @@ -1250,48 +1612,47 @@ jQuery.event = { handler.guid = fn.guid; } + // Namespaced event handlers + var parts = type.split("."); + type = parts[0]; + handler.type = parts[1]; + // Init the element's event structure - if (!element.$events) - element.$events = {}; + var events = jQuery.data(element, "events") || jQuery.data(element, "events", {}); - if (!element.$handle) - element.$handle = function() { - // returned undefined or false - var val; - - // Handle the second event of a trigger and when - // an event is called after a page has unloaded - if ( typeof jQuery == "undefined" || jQuery.event.triggered ) - return val; - - val = jQuery.event.handle.apply(element, arguments); - + var handle = jQuery.data(element, "handle", function(){ + // returned undefined or false + var val; + + // Handle the second event of a trigger and when + // an event is called after a page has unloaded + if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return val; - }; + + val = jQuery.event.handle.apply(element, arguments); + + return val; + }); // Get the current list of functions bound to this event - var handlers = element.$events[type]; + var handlers = events[type]; // Init the event handler queue if (!handlers) { - handlers = element.$events[type] = {}; + handlers = events[type] = {}; // And bind the global event handler to the element if (element.addEventListener) - element.addEventListener(type, element.$handle, false); + element.addEventListener(type, handle, false); else - element.attachEvent("on" + type, element.$handle); + element.attachEvent("on" + type, handle); } // Add the function to the element's handler list handlers[handler.guid] = handler; - // Remember the function in a global list (for triggering) - if (!this.global[type]) - this.global[type] = []; - // Only add the element to the global list once - if (jQuery.inArray(element, this.global[type]) == -1) - this.global[type].push( element ); + // Keep track of which events have been used, for global triggering + this.global[type] = true; }, guid: 1, @@ -1299,7 +1660,13 @@ jQuery.event = { // Detach an event or set of events from an element remove: function(element, type, handler) { - var events = element.$events, ret, index; + var events = jQuery.data(element, "events"), ret, index; + + // Namespaced event handlers + if ( typeof type == "string" ) { + var parts = type.split("."); + type = parts[0]; + } if ( events ) { // type is actually an event object here @@ -1319,58 +1686,81 @@ jQuery.event = { // remove all handlers for the given type else - for ( handler in element.$events[type] ) - delete events[type][handler]; + for ( handler in events[type] ) + // Handle the removal of namespaced events + if ( !parts[1] || events[type][handler].type == parts[1] ) + delete events[type][handler]; // remove generic event handler if no more handlers exist for ( ret in events[type] ) break; if ( !ret ) { if (element.removeEventListener) - element.removeEventListener(type, element.$handle, false); + element.removeEventListener(type, jQuery.data(element, "handle"), false); else - element.detachEvent("on" + type, element.$handle); + element.detachEvent("on" + type, jQuery.data(element, "handle")); ret = null; delete events[type]; - - // Remove element from the global event type cache - while ( this.global[type] && ( (index = jQuery.inArray(element, this.global[type])) >= 0 ) ) - delete this.global[type][index]; } } // Remove the expando if it's no longer used for ( ret in events ) break; - if ( !ret ) - element.$handle = element.$events = null; + if ( !ret ) { + jQuery.removeData( element, "events" ); + jQuery.removeData( element, "handle" ); + } } }, - trigger: function(type, data, element) { + trigger: function(type, data, element, donative, extra) { // Clone the incoming data, if any data = jQuery.makeArray(data || []); // Handle a global trigger - if ( !element ) - jQuery.each( this.global[type] || [], function(){ - jQuery.event.trigger( type, data, this ); - }); + if ( !element ) { + // Only trigger if we've ever bound an event for it + if ( this.global[type] ) + jQuery("*").add([window, document]).trigger(type, data); // Handle triggering a single element - else { - var val, ret, fn = jQuery.isFunction( element[ type ] || null ); + } else { + var val, ret, fn = jQuery.isFunction( element[ type ] || null ), + // Check to see if we need to provide a fake event, or not + evt = !data[0] || !data[0].preventDefault; // Pass along a fake event - data.unshift( this.fix({ type: type, target: element }) ); + if ( evt ) + data.unshift( this.fix({ type: type, target: element }) ); + + // Enforce the right trigger type + data[0].type = type; // Trigger the event - if ( jQuery.isFunction(element.$handle) && (val = element.$handle.apply( element, data )) !== false ) - this.triggered = true; + if ( jQuery.isFunction( jQuery.data(element, "handle") ) ) + val = jQuery.data(element, "handle").apply( element, data ); + + // Handle triggering native .onfoo handlers + if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false ) + val = false; + + // Extra functions don't get the custom event object + if ( evt ) + data.shift(); - if ( fn && val !== false && !jQuery.nodeName(element, 'a') ) + // Handle triggering of extra function + if ( extra && extra.apply( element, data ) === false ) + val = false; + + // Trigger the native events (except for clicks on links) + if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) { + this.triggered = true; element[ type ](); + } this.triggered = false; } + + return val; }, handle: function(event) { @@ -1380,7 +1770,11 @@ jQuery.event = { // Empty object is for triggered events with no data event = jQuery.event.fix( event || window.event || {} ); - var c = this.$events && this.$events[event.type], args = [].slice.call( arguments, 1 ); + // Namespaced event handlers + var parts = event.type.split("."); + event.type = parts[0]; + + var c = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 ); args.unshift( event ); for ( var j in c ) { @@ -1389,10 +1783,17 @@ jQuery.event = { args[0].handler = c[j]; args[0].data = c[j].data; - if ( c[j].apply( this, args ) === false ) { - event.preventDefault(); - event.stopPropagation(); - val = false; + // Filter the functions by class + if ( !parts[1] || c[j].type == parts[1] ) { + var tmp = c[j].apply( this, args ); + + if ( val !== false ) + val = tmp; + + if ( tmp === false ) { + event.preventDefault(); + event.stopPropagation(); + } } } @@ -1415,14 +1816,14 @@ jQuery.event = { event.preventDefault = function() { // if preventDefault exists run it on the original event if (originalEvent.preventDefault) - return originalEvent.preventDefault(); + originalEvent.preventDefault(); // otherwise set the returnValue property of the original event to false (IE) originalEvent.returnValue = false; }; event.stopPropagation = function() { // if stopPropagation exists run it on the original event if (originalEvent.stopPropagation) - return originalEvent.stopPropagation(); + originalEvent.stopPropagation(); // otherwise set the cancelBubble property of the original event to true (IE) originalEvent.cancelBubble = true; }; @@ -1442,8 +1843,8 @@ jQuery.event = { // Calculate pageX/Y if missing and clientX/Y available if ( event.pageX == null && event.clientX != null ) { var e = document.documentElement, b = document.body; - event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft); - event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop); + event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft || 0); + event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop || 0); } // Add which for key events @@ -1469,6 +1870,7 @@ jQuery.fn.extend({ jQuery.event.add( this, type, fn || data, fn && data ); }); }, + one: function( type, data, fn ) { return this.each(function(){ jQuery.event.add( this, type, function(event) { @@ -1477,16 +1879,24 @@ jQuery.fn.extend({ }, fn && data); }); }, + unbind: function( type, fn ) { return this.each(function(){ jQuery.event.remove( this, type, fn ); }); }, - trigger: function( type, data ) { + + trigger: function( type, data, fn ) { return this.each(function(){ - jQuery.event.trigger( type, data, this ); + jQuery.event.trigger( type, data, this, true, fn ); }); }, + + triggerHandler: function( type, data, fn ) { + if ( this[0] ) + return jQuery.event.trigger( type, data, this[0], false, fn ); + }, + toggle: function() { // Save reference to arguments for access in closure var a = arguments; @@ -1502,6 +1912,7 @@ jQuery.fn.extend({ return a[this.lastToggle].apply( this, [e] ) || false; }); }, + hover: function(f,g) { // A private function for handling mouse 'hovering' @@ -1510,7 +1921,7 @@ jQuery.fn.extend({ var p = e.relatedTarget; // Traverse up the tree - while ( p && p != this ) try { p = p.parentNode } catch(e) { p = this; }; + while ( p && p != this ) try { p = p.parentNode; } catch(e) { p = this; }; // If we actually just moused on to a sub-element, ignore it if ( p == this ) return false; @@ -1522,7 +1933,11 @@ jQuery.fn.extend({ // Bind the function to the two event listeners return this.mouseover(handleHover).mouseout(handleHover); }, + ready: function(f) { + // Attach the listeners + bindReady(); + // If the DOM is already ready if ( jQuery.isReady ) // Execute the function immediately @@ -1531,7 +1946,7 @@ jQuery.fn.extend({ // Otherwise, remember the function for later else // Add the function to the wait list - jQuery.readyList.push( function() { return f.apply(this, [jQuery]) } ); + jQuery.readyList.push( function() { return f.apply(this, [jQuery]); } ); return this; } @@ -1572,19 +1987,22 @@ jQuery.extend({ } }); -new function(){ - - jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + - "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + - "submit,keydown,keypress,keyup,error").split(","), function(i,o){ - - // Handle event binding - jQuery.fn[o] = function(f){ - return f ? this.bind(o, f) : this.trigger(o); - }; - - }); +jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + + "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + + "submit,keydown,keypress,keyup,error").split(","), function(i,o){ + // Handle event binding + jQuery.fn[o] = function(f){ + return f ? this.bind(o, f) : this.trigger(o); + }; +}); + +var readyBound = false; + +function bindReady(){ + if ( readyBound ) return; + readyBound = true; + // If Mozilla is used if ( jQuery.browser.mozilla || jQuery.browser.opera ) // Use the handy event callback @@ -1630,29 +2048,18 @@ new function(){ // A fallback to window.onload, that will always work jQuery.event.add( window, "load", jQuery.ready ); - -}; - -// Clean up after IE to avoid memory leaks -if (jQuery.browser.msie) - jQuery(window).one("unload", function() { - var global = jQuery.event.global; - for ( var type in global ) { - var els = global[type], i = els.length; - if ( i && type != 'unload' ) - do - els[i-1] && jQuery.event.remove(els[i-1], type); - while (--i); - } - }); +} jQuery.fn.extend({ - loadIfModified: function( url, params, callback ) { - this.load( url, params, callback, 1 ); - }, - load: function( url, params, callback, ifModified ) { + load: function( url, params, callback ) { if ( jQuery.isFunction( url ) ) return this.bind("load", url); + var off = url.indexOf(" "); + if ( off >= 0 ) { + var selector = url.slice(off, url.length); + url = url.slice(0, off); + } + callback = callback || function(){}; // Default to a GET request @@ -1679,45 +2086,68 @@ jQuery.fn.extend({ url: url, type: type, data: params, - ifModified: ifModified, complete: function(res, status){ - if ( status == "success" || !ifModified && status == "notmodified" ) - // Inject the HTML into all the matched elements - self.attr("innerHTML", res.responseText) - // Execute all the scripts inside of the newly-injected HTML - .evalScripts() - // Execute callback - .each( callback, [res.responseText, status, res] ); - else - callback.apply( self, [res.responseText, status, res] ); + // If successful, inject the HTML into all the matched elements + if ( status == "success" || status == "notmodified" ) + // See if a selector was specified + self.html( selector ? + // Create a dummy div to hold the results + jQuery("<div/>") + // inject the contents of the document in, removing the scripts + // to avoid any 'Permission Denied' errors in IE + .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) + + // Locate the specified elements + .find(selector) : + + // If not, just inject the full result + res.responseText ); + + // Add delay to account for Safari's delay in globalEval + setTimeout(function(){ + self.each( callback, [res.responseText, status, res] ); + }, 13); } }); return this; }, + serialize: function() { - return jQuery.param( this ); - }, - evalScripts: function() { - return this.find("script").each(function(){ - if ( this.src ) - jQuery.getScript( this.src ); - else - jQuery.globalEval( this.text || this.textContent || this.innerHTML || "" ); - }).end(); + return jQuery.param(this.serializeArray()); + }, + serializeArray: function() { + return this.map(function(){ + return jQuery.nodeName(this, "form") ? + jQuery.makeArray(this.elements) : this; + }) + .filter(function(){ + return this.name && !this.disabled && + (this.checked || /select|textarea/i.test(this.nodeName) || + /text|hidden|password/i.test(this.type)); + }) + .map(function(i, elem){ + var val = jQuery(this).val(); + return val == null ? null : + val.constructor == Array ? + jQuery.map( val, function(val, i){ + return {name: elem.name, value: val}; + }) : + {name: elem.name, value: val}; + }).get(); } - }); // Attach a bunch of functions for handling common AJAX events - jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ jQuery.fn[o] = function(f){ return this.bind(o, f); }; }); +var jsc = (new Date).getTime(); + jQuery.extend({ - get: function( url, data, callback, type, ifModified ) { + get: function( url, data, callback, type ) { // shift arguments if data argument was ommited if ( jQuery.isFunction( data ) ) { callback = data; @@ -1729,19 +2159,18 @@ jQuery.extend({ url: url, data: data, success: callback, - dataType: type, - ifModified: ifModified + dataType: type }); }, - getIfModified: function( url, data, callback, type ) { - return jQuery.get(url, data, callback, type, 1); - }, + getScript: function( url, callback ) { return jQuery.get(url, null, callback, "script"); }, + getJSON: function( url, data, callback ) { return jQuery.get(url, data, callback, "json"); }, + post: function( url, data, callback, type ) { if ( jQuery.isFunction( data ) ) { callback = data; @@ -1756,9 +2185,7 @@ jQuery.extend({ dataType: type }); }, - ajaxTimeout: function( timeout ) { - jQuery.ajaxSettings.timeout = timeout; - }, + ajaxSetup: function( settings ) { jQuery.extend( jQuery.ajaxSettings, settings ); }, @@ -1775,28 +2202,99 @@ jQuery.extend({ // Last-Modified header cache for next request lastModified: {}, + ajax: function( s ) { - // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout - s = jQuery.extend({}, jQuery.ajaxSettings, s); - - // if data available - if ( s.data ) { - // convert data if not already a string - if (s.processData && typeof s.data != "string") - s.data = jQuery.param(s.data); - // append data to url for get requests - if( s.type.toLowerCase() == "get" ) { - // "?" + data or "&" + data (in case there are already params) - s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data; - // IE likes to send both get and post data, prevent this - s.data = null; - } + var jsonp, jsre = /=(\?|%3F)/g, status, data; + + // Extend the settings, but re-extend 's' so that it can be + // checked again later (in the test suite, specifically) + s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); + + // convert data if not already a string + if ( s.data && s.processData && typeof s.data != "string" ) + s.data = jQuery.param(s.data); + + // Handle JSONP Parameter Callbacks + if ( s.dataType == "jsonp" ) { + if ( s.type.toLowerCase() == "get" ) { + if ( !s.url.match(jsre) ) + s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; + } else if ( !s.data || !s.data.match(jsre) ) + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; + s.dataType = "json"; + } + + // Build temporary JSONP function + if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { + jsonp = "jsonp" + jsc++; + + // Replace the =? sequence both in the query string and the data + if ( s.data ) + s.data = s.data.replace(jsre, "=" + jsonp); + s.url = s.url.replace(jsre, "=" + jsonp); + + // We need to make sure + // that a JSONP style response is executed properly + s.dataType = "script"; + + // Handle JSONP-style loading + window[ jsonp ] = function(tmp){ + data = tmp; + success(); + complete(); + // Garbage collect + window[ jsonp ] = undefined; + try{ delete window[ jsonp ]; } catch(e){} + }; + } + + if ( s.dataType == "script" && s.cache == null ) + s.cache = false; + + if ( s.cache === false && s.type.toLowerCase() == "get" ) + s.url += (s.url.match(/\?/) ? "&" : "?") + "_=" + (new Date()).getTime(); + + // If data is available, append data to url for get requests + if ( s.data && s.type.toLowerCase() == "get" ) { + s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; + + // IE likes to send both get and post data, prevent this + s.data = null; } // Watch for a new set of requests if ( s.global && ! jQuery.active++ ) jQuery.event.trigger( "ajaxStart" ); + // If we're requesting a remote document + // and trying to load JSON or Script + if ( !s.url.indexOf("http") && s.dataType == "script" ) { + var head = document.getElementsByTagName("head")[0]; + var script = document.createElement("script"); + script.src = s.url; + + // Handle Script loading + if ( !jsonp && (s.success || s.complete) ) { + var done = false; + + // Attach handlers for all browsers + script.onload = script.onreadystatechange = function(){ + if ( !done && (!this.readyState || + this.readyState == "loaded" || this.readyState == "complete") ) { + done = true; + success(); + complete(); + head.removeChild( script ); + } + }; + } + + head.appendChild(script); + + // We handle everything using the script element injection + return; + } + var requestDone = false; // Create the request object; Microsoft failed to properly @@ -1819,7 +2317,7 @@ jQuery.extend({ xml.setRequestHeader("X-Requested-With", "XMLHttpRequest"); // Allow custom headers/mimetypes - if( s.beforeSend ) + if ( s.beforeSend ) s.beforeSend(xml); if ( s.global ) @@ -1828,7 +2326,7 @@ jQuery.extend({ // Wait for a response to come back var onreadystatechange = function(isTimeout){ // The transfer is complete and the data is available, or the request timed out - if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) { + if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) { requestDone = true; // clear poll interval @@ -1837,71 +2335,64 @@ jQuery.extend({ ival = null; } - var status; - try { - status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ? - s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error"; - // Make sure that the request was successful or notmodified - if ( status != "error" ) { - // Cache Last-Modified header, if ifModified mode. - var modRes; - try { - modRes = xml.getResponseHeader("Last-Modified"); - } catch(e) {} // swallow exception thrown by FF if header is not available - - if ( s.ifModified && modRes ) - jQuery.lastModified[s.url] = modRes; - + status = isTimeout == "timeout" && "timeout" || + !jQuery.httpSuccess( xml ) && "error" || + s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" || + "success"; + + if ( status == "success" ) { + // Watch for, and catch, XML document parse errors + try { // process the data (runs the xml through httpData regardless of callback) - var data = jQuery.httpData( xml, s.dataType ); - - // If a local callback was specified, fire it and pass it the data - if ( s.success ) - s.success( data, status ); - - // Fire the global callback - if( s.global ) - jQuery.event.trigger( "ajaxSuccess", [xml, s] ); - } else - jQuery.handleError(s, xml, status); - } catch(e) { - status = "error"; - jQuery.handleError(s, xml, status, e); + data = jQuery.httpData( xml, s.dataType ); + } catch(e) { + status = "parsererror"; + } } - // The request was completed - if( s.global ) - jQuery.event.trigger( "ajaxComplete", [xml, s] ); + // Make sure that the request was successful or notmodified + if ( status == "success" ) { + // Cache Last-Modified header, if ifModified mode. + var modRes; + try { + modRes = xml.getResponseHeader("Last-Modified"); + } catch(e) {} // swallow exception thrown by FF if header is not available + + if ( s.ifModified && modRes ) + jQuery.lastModified[s.url] = modRes; - // Handle the global AJAX counter - if ( s.global && ! --jQuery.active ) - jQuery.event.trigger( "ajaxStop" ); + // JSONP handles its own success callback + if ( !jsonp ) + success(); + } else + jQuery.handleError(s, xml, status); - // Process result - if ( s.complete ) - s.complete(xml, status); + // Fire the complete handlers + complete(); // Stop memory leaks - if(s.async) + if ( s.async ) xml = null; } }; - // don't attach the handler to the request, just poll it instead - var ival = setInterval(onreadystatechange, 13); - - // Timeout checker - if ( s.timeout > 0 ) - setTimeout(function(){ - // Check to see if the request is still happening - if ( xml ) { - // Cancel the request - xml.abort(); - - if( !requestDone ) - onreadystatechange( "timeout" ); - } - }, s.timeout); + if ( s.async ) { + // don't attach the handler to the request, just poll it instead + var ival = setInterval(onreadystatechange, 13); + + // Timeout checker + if ( s.timeout > 0 ) + setTimeout(function(){ + // Check to see if the request is still happening + if ( xml ) { + // Cancel the request + xml.abort(); + + if( !requestDone ) + onreadystatechange( "timeout" ); + } + }, s.timeout); + } // Send the data try { @@ -1916,6 +2407,30 @@ jQuery.extend({ // return XMLHttpRequest to allow aborting the request etc. return xml; + + function success(){ + // If a local callback was specified, fire it and pass it the data + if ( s.success ) + s.success( data, status ); + + // Fire the global callback + if ( s.global ) + jQuery.event.trigger( "ajaxSuccess", [xml, s] ); + } + + function complete(){ + // Process result + if ( s.complete ) + s.complete(xml, status); + + // The request was completed + if ( s.global ) + jQuery.event.trigger( "ajaxComplete", [xml, s] ); + + // Handle the global AJAX counter + if ( s.global && ! --jQuery.active ) + jQuery.event.trigger( "ajaxStop" ); + } }, handleError: function( s, xml, status, e ) { @@ -1952,16 +2467,13 @@ jQuery.extend({ return false; }, - /* Get the data out of an XMLHttpRequest. - * Return parsed XML if content-type header is "xml" and type is "xml" or omitted, - * otherwise return plain text. - * (String) data - The type of data that you're expecting back, - * (e.g. "xml", "html", "script") - */ httpData: function( r, type ) { var ct = r.getResponseHeader("content-type"); - var data = !type && ct && ct.indexOf("xml") >= 0; - data = type == "xml" || data ? r.responseXML : r.responseText; + var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; + var data = xml ? r.responseXML : r.responseText; + + if ( xml && data.documentElement.tagName == "parsererror" ) + throw "parsererror"; // If the type is "script", eval it in global context if ( type == "script" ) @@ -1971,10 +2483,6 @@ jQuery.extend({ if ( type == "json" ) data = eval("(" + data + ")"); - // evaluate scripts within html - if ( type == "html" ) - jQuery("<div>").html(data).evalScripts(); - return data; }, @@ -2004,24 +2512,11 @@ jQuery.extend({ s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) ); // Return the resulting serialization - return s.join("&"); - }, - - // evalulates a script in global context - // not reliable for safari - globalEval: function( data ) { - if ( window.execScript ) - window.execScript( data ); - else if ( jQuery.browser.safari ) - // safari doesn't provide a synchronous global eval - window.setTimeout( data, 0 ); - else - eval.call( window, data ); + return s.join("&").replace(/%20/g, "+"); } }); jQuery.fn.extend({ - show: function(speed,callback){ return speed ? this.animate({ @@ -2034,7 +2529,7 @@ jQuery.fn.extend({ this.style.display = "block"; }).end(); }, - + hide: function(speed,callback){ return speed ? this.animate({ @@ -2051,6 +2546,7 @@ jQuery.fn.extend({ // Save the old toggle function _toggle: jQuery.fn.toggle, + toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : @@ -2062,29 +2558,37 @@ jQuery.fn.extend({ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); }); }, + slideDown: function(speed,callback){ return this.animate({height: "show"}, speed, callback); }, + slideUp: function(speed,callback){ return this.animate({height: "hide"}, speed, callback); }, + slideToggle: function(speed, callback){ return this.animate({height: "toggle"}, speed, callback); }, + fadeIn: function(speed, callback){ return this.animate({opacity: "show"}, speed, callback); }, + fadeOut: function(speed, callback){ return this.animate({opacity: "hide"}, speed, callback); }, + fadeTo: function(speed,to,callback){ return this.animate({opacity: to}, speed, callback); }, + animate: function( prop, speed, easing, callback ) { - return this.queue(function(){ - var hidden = jQuery(this).is(":hidden"), - opt = jQuery.speed(speed, easing, callback), - self = this; + var opt = jQuery.speed(speed, easing, callback); + + return this[ opt.queue === false ? "each" : "queue" ](function(){ + opt = jQuery.extend({}, opt); + var hidden = jQuery(this).is(":hidden"), self = this; for ( var p in prop ) { if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) @@ -2102,39 +2606,102 @@ jQuery.fn.extend({ if ( opt.overflow != null ) this.style.overflow = "hidden"; - this.curAnim = jQuery.extend({}, prop); + opt.curAnim = jQuery.extend({}, prop); jQuery.each( prop, function(name, val){ var e = new jQuery.fx( self, opt, name ); - if ( val.constructor == Number ) - e.custom( e.cur(), val ); - else + + if ( /toggle|show|hide/.test(val) ) e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); + else { + var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), + start = e.cur(true) || 0; + + if ( parts ) { + var end = parseFloat(parts[2]), + unit = parts[3] || "px"; + + // We need to compute starting value + if ( unit != "px" ) { + self.style[ name ] = (end || 1) + unit; + start = ((end || 1) / e.cur(true)) * start; + self.style[ name ] = start + unit; + } + + // If a +=/-= token was provided, we're doing a relative animation + if ( parts[1] ) + end = ((parts[1] == "-=" ? -1 : 1) * end) + start; + + e.custom( start, end, unit ); + } else + e.custom( start, val, "" ); + } }); + + // For JS strict compliance + return true; }); }, - queue: function(type,fn){ - if ( !fn ) { + + queue: function(type, fn){ + if ( jQuery.isFunction(type) ) { fn = type; type = "fx"; } - + + if ( !type || (typeof type == "string" && !fn) ) + return queue( this[0], type ); + return this.each(function(){ - if ( !this.queue ) - this.queue = {}; - - if ( !this.queue[type] ) - this.queue[type] = []; - - this.queue[type].push( fn ); - - if ( this.queue[type].length == 1 ) - fn.apply(this); + if ( fn.constructor == Array ) + queue(this, type, fn); + else { + queue(this, type).push( fn ); + + if ( queue(this, type).length == 1 ) + fn.apply(this); + } }); + }, + + stop: function(){ + var timers = jQuery.timers; + + return this.each(function(){ + for ( var i = 0; i < timers.length; i++ ) + if ( timers[i].elem == this ) + timers.splice(i--, 1); + }).dequeue(); } }); +var queue = function( elem, type, array ) { + if ( !elem ) + return; + + var q = jQuery.data( elem, type + "queue" ); + + if ( !q || array ) + q = jQuery.data( elem, type + "queue", + array ? jQuery.makeArray(array) : [] ); + + return q; +}; + +jQuery.fn.dequeue = function(type){ + type = type || "fx"; + + return this.each(function(){ + var q = queue(this, type); + + q.shift(); + + if ( q.length ) + q[0].apply( this ); + }); +}; + jQuery.extend({ speed: function(speed, easing, fn) { @@ -2142,7 +2709,7 @@ jQuery.extend({ complete: fn || !fn && easing || jQuery.isFunction( speed ) && speed, duration: speed, - easing: fn && easing || easing && easing.constructor != Function && easing || (jQuery.easing.swing ? "swing" : "linear") + easing: fn && easing || easing && easing.constructor != Function && easing }; opt.duration = (opt.duration && opt.duration.constructor == Number ? @@ -2152,7 +2719,7 @@ jQuery.extend({ // Queueing opt.old = opt.complete; opt.complete = function(){ - jQuery.dequeue(this, "fx"); + jQuery(this).dequeue(); if ( jQuery.isFunction( opt.old ) ) opt.old.apply( this ); }; @@ -2169,176 +2736,269 @@ jQuery.extend({ } }, - queue: {}, - - dequeue: function(elem,type){ - type = type || "fx"; - - if ( elem.queue && elem.queue[type] ) { - // Remove self - elem.queue[type].shift(); - - // Get next function - var f = elem.queue[type][0]; - - if ( f ) f.apply( elem ); - } - }, - timers: [], - /* - * I originally wrote fx() as a clone of moo.fx and in the process - * of making it small in size the code became illegible to sane - * people. You've been warned. - */ - fx: function( elem, options, prop ){ + this.options = options; + this.elem = elem; + this.prop = prop; - var z = this; - - // The styles - var y = elem.style; - - // Simple function for setting a style value - z.a = function(){ - if ( options.step ) - options.step.apply( elem, [ z.now ] ); + if ( !options.orig ) + options.orig = {}; + } - if ( prop == "opacity" ) - jQuery.attr(y, "opacity", z.now); // Let attr handle opacity - else { - y[prop] = parseInt(z.now) + "px"; - y.display = "block"; // Set display property to block for animation - } - }; +}); - // Figure out the maximum number to run to - z.max = function(){ - return parseFloat( jQuery.css(elem,prop) ); - }; +jQuery.fx.prototype = { - // Get the current size - z.cur = function(){ - var r = parseFloat( jQuery.curCSS(elem, prop) ); - return r && r > -10000 ? r : z.max(); - }; + // Simple function for setting a style value + update: function(){ + if ( this.options.step ) + this.options.step.apply( this.elem, [ this.now, this ] ); - // Start an animation from one number to another - z.custom = function(from,to){ - z.startTime = (new Date()).getTime(); - z.now = from; - z.a(); + (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); - jQuery.timers.push(function(){ - return z.step(from, to); - }); + // Set display property to block for height/width animations + if ( this.prop == "height" || this.prop == "width" ) + this.elem.style.display = "block"; + }, - if ( jQuery.timers.length == 1 ) { - var timer = setInterval(function(){ - var timers = jQuery.timers; - - for ( var i = 0; i < timers.length; i++ ) - if ( !timers[i]() ) - timers.splice(i--, 1); + // Get the current size + cur: function(force){ + if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null ) + return this.elem[ this.prop ]; - if ( !timers.length ) - clearInterval( timer ); - }, 13); - } - }; + var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force)); + return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0; + }, - // Simple 'show' function - z.show = function(){ - if ( !elem.orig ) elem.orig = {}; + // Start an animation from one number to another + custom: function(from, to, unit){ + this.startTime = (new Date()).getTime(); + this.start = from; + this.end = to; + this.unit = unit || this.unit || "px"; + this.now = this.start; + this.pos = this.state = 0; + this.update(); - // Remember where we started, so that we can go back to it later - elem.orig[prop] = jQuery.attr( elem.style, prop ); + var self = this; + function t(){ + return self.step(); + } - options.show = true; + t.elem = this.elem; - // Begin the animation - z.custom(0, this.cur()); + jQuery.timers.push(t); - // Make sure that we start at a small width/height to avoid any - // flash of content - if ( prop != "opacity" ) - y[prop] = "1px"; - - // Start by showing the element - jQuery(elem).show(); - }; + if ( jQuery.timers.length == 1 ) { + var timer = setInterval(function(){ + var timers = jQuery.timers; + + for ( var i = 0; i < timers.length; i++ ) + if ( !timers[i]() ) + timers.splice(i--, 1); - // Simple 'hide' function - z.hide = function(){ - if ( !elem.orig ) elem.orig = {}; + if ( !timers.length ) + clearInterval( timer ); + }, 13); + } + }, - // Remember where we started, so that we can go back to it later - elem.orig[prop] = jQuery.attr( elem.style, prop ); + // Simple 'show' function + show: function(){ + // Remember where we started, so that we can go back to it later + this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); + this.options.show = true; - options.hide = true; + // Begin the animation + this.custom(0, this.cur()); - // Begin the animation - z.custom(this.cur(), 0); - }; + // Make sure that we start at a small width/height to avoid any + // flash of content + if ( this.prop == "width" || this.prop == "height" ) + this.elem.style[this.prop] = "1px"; + + // Start by showing the element + jQuery(this.elem).show(); + }, - // Each step of an animation - z.step = function(firstNum, lastNum){ - var t = (new Date()).getTime(); + // Simple 'hide' function + hide: function(){ + // Remember where we started, so that we can go back to it later + this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); + this.options.hide = true; - if (t > options.duration + z.startTime) { - z.now = lastNum; - z.a(); + // Begin the animation + this.custom(this.cur(), 0); + }, - if (elem.curAnim) elem.curAnim[ prop ] = true; + // Each step of an animation + step: function(){ + var t = (new Date()).getTime(); - var done = true; - for ( var i in elem.curAnim ) - if ( elem.curAnim[i] !== true ) - done = false; + if ( t > this.options.duration + this.startTime ) { + this.now = this.end; + this.pos = this.state = 1; + this.update(); - if ( done ) { - if ( options.display != null ) { - // Reset the overflow - y.overflow = options.overflow; - - // Reset the display - y.display = options.display; - if ( jQuery.css(elem, "display") == "none" ) - y.display = "block"; - } + this.options.curAnim[ this.prop ] = true; - // Hide the element if the "hide" operation was done - if ( options.hide ) - y.display = "none"; + var done = true; + for ( var i in this.options.curAnim ) + if ( this.options.curAnim[i] !== true ) + done = false; - // Reset the properties, if the item has been hidden or shown - if ( options.hide || options.show ) - for ( var p in elem.curAnim ) - jQuery.attr(y, p, elem.orig[p]); + if ( done ) { + if ( this.options.display != null ) { + // Reset the overflow + this.elem.style.overflow = this.options.overflow; + + // Reset the display + this.elem.style.display = this.options.display; + if ( jQuery.css(this.elem, "display") == "none" ) + this.elem.style.display = "block"; } - // If a callback was provided, execute it - if ( done && jQuery.isFunction( options.complete ) ) - // Execute the complete function - options.complete.apply( elem ); - - return false; - } else { - var n = t - this.startTime; - // Figure out where in the animation we are and set the number - var p = n / options.duration; - - // Perform the easing function, defaults to swing - z.now = jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration); + // Hide the element if the "hide" operation was done + if ( this.options.hide ) + this.elem.style.display = "none"; - // Perform the next step of the animation - z.a(); + // Reset the properties, if the item has been hidden or shown + if ( this.options.hide || this.options.show ) + for ( var p in this.options.curAnim ) + jQuery.attr(this.elem.style, p, this.options.orig[p]); } - return true; - }; + // If a callback was provided, execute it + if ( done && jQuery.isFunction( this.options.complete ) ) + // Execute the complete function + this.options.complete.apply( this.elem ); + + return false; + } else { + var n = t - this.startTime; + this.state = n / this.options.duration; + + // Perform the easing function, defaults to swing + this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); + this.now = this.start + ((this.end - this.start) * this.pos); + + // Perform the next step of the animation + this.update(); + } + + return true; + } + +}; + +jQuery.fx.step = { + scrollLeft: function(fx){ + fx.elem.scrollLeft = fx.now; + }, + + scrollTop: function(fx){ + fx.elem.scrollTop = fx.now; + }, + + opacity: function(fx){ + jQuery.attr(fx.elem.style, "opacity", fx.now); + }, + + _default: function(fx){ + fx.elem.style[ fx.prop ] = fx.now + fx.unit; + } +}; +// The Offset Method +// Originally By Brandon Aaron, part of the Dimension Plugin +// http://jquery.com/plugins/project/dimensions +jQuery.fn.offset = function() { + var left = 0, top = 0, elem = this[0], results; + if ( elem ) with ( jQuery.browser ) { + var absolute = jQuery.css(elem, "position") == "absolute", + parent = elem.parentNode, + offsetParent = elem.offsetParent, + doc = elem.ownerDocument, + safari2 = safari && parseInt(version) < 522; + + // Use getBoundingClientRect if available + if ( elem.getBoundingClientRect ) { + var box = elem.getBoundingClientRect(); + + // Add the document scroll offsets + add( + box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft), + box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop) + ); + + // IE adds the HTML element's border, by default it is medium which is 2px + // IE 6 and IE 7 quirks mode the border width is overwritable by the following css html { border: 0; } + // IE 7 standards mode, the border is always 2px + if ( msie ) { + var border = jQuery("html").css("borderWidth"); + border = (border == "medium" || jQuery.boxModel && parseInt(version) >= 7) && 2 || border; + add( -border, -border ); + } + + // Otherwise loop through the offsetParents and parentNodes + } else { + + // Initial element offsets + add( elem.offsetLeft, elem.offsetTop ); + + // Get parent offsets + while ( offsetParent ) { + // Add offsetParent offsets + add( offsetParent.offsetLeft, offsetParent.offsetTop ); + + // Mozilla and Safari > 2 does not include the border on offset parents + // However Mozilla adds the border for table cells + if ( mozilla && !/^t[d|h]$/i.test(offsetParent.tagName) || safari && parseInt(version) >= 522 ) + border( offsetParent ); + + // Safari <= 2 doubles body offsets with an absolutely positioned element or parent + if ( safari2 && !absolute && jQuery.css(offsetParent, "position") == "absolute" ) + absolute = true; + + // Get next offsetParent + offsetParent = offsetParent.offsetParent; + } + + // Get parent scroll offsets + while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) { + // Work around opera inline/table scrollLeft/Top bug + if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) ) + // Subtract parent scroll offsets + add( -parent.scrollLeft, -parent.scrollTop ); + + // Mozilla does not add the border for a parent that has overflow != visible + if ( mozilla && jQuery.css(parent, "overflow") != "visible" ) + border( parent ); + + // Get next parent + parent = parent.parentNode; + } + + // Safari doubles body offsets with an absolutely positioned element or parent + if ( safari2 && absolute ) + add( -doc.body.offsetLeft, -doc.body.offsetTop ); + } + + // Return an object with top and left properties + results = { top: top, left: left }; } -}); -} + + return results; + + function border(elem) { + add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") ); + } + + function add(l, t) { + left += parseInt(l) || 0; + top += parseInt(t) || 0; + } +}; +})(); diff --git a/dist/javascript/jquery.tabs.min.js b/dist/javascript/jquery.tabs.min.js deleted file mode 100644 index 674fc5cc3336c01753f08ec0111ff5fa69835233..0000000000000000000000000000000000000000 --- a/dist/javascript/jquery.tabs.min.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Tabs - jQuery plugin for accessible, unobtrusive tabs - * @requires jQuery v1.1.1 - * - * http://stilbuero.de/tabs/ - * - * Copyright (c) 2006 Klaus Hartl (stilbuero.de) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - * Version: 2.7.4 - */ -(function($){$.extend({tabs:{remoteCount:0}});$.fn.tabs=function(initial,settings){if(typeof initial=='object')settings=initial;settings=$.extend({initial:(initial&&typeof initial=='number'&&initial>0)?--initial:0,disabled:null,bookmarkable:$.ajaxHistory?true:false,remote:false,spinner:'Loading…',hashPrefix:'remote-tab-',fxFade:null,fxSlide:null,fxShow:null,fxHide:null,fxSpeed:'normal',fxShowSpeed:null,fxHideSpeed:null,fxAutoHeight:false,onClick:null,onHide:null,onShow:null,navClass:'tabs-nav',selectedClass:'tabs-selected',disabledClass:'tabs-disabled',containerClass:'tabs-container',hideClass:'tabs-hide',loadingClass:'tabs-loading',tabStruct:'div'},settings||{});$.browser.msie6=$.browser.msie&&($.browser.version&&$.browser.version<7||/MSIE 6.0/.test(navigator.userAgent));function unFocus(){scrollTo(0,0);}return this.each(function(){var container=this;var nav=$('ul.'+settings.navClass,container);nav=nav.size()&&nav||$('>ul:eq(0)',container);var tabs=$('a',nav);if(settings.remote){tabs.each(function(){var id=settings.hashPrefix+(++$.tabs.remoteCount),hash='#'+id,url=this.href;this.href=hash;$('<div id="'+id+'" class="'+settings.containerClass+'"></div>').appendTo(container);$(this).bind('loadRemoteTab',function(e,callback){var $$=$(this).addClass(settings.loadingClass),span=$('span',this)[0],tabTitle=span.innerHTML;if(settings.spinner){span.innerHTML='<em>'+settings.spinner+'</em>';}setTimeout(function(){$(hash).load(url,function(){if(settings.spinner){span.innerHTML=tabTitle;}$$.removeClass(settings.loadingClass);callback&&callback();});},0);});});}var containers=$('div.'+settings.containerClass,container);containers=containers.size()&&containers||$('>'+settings.tabStruct,container);nav.is('.'+settings.navClass)||nav.addClass(settings.navClass);containers.each(function(){var $$=$(this);$$.is('.'+settings.containerClass)||$$.addClass(settings.containerClass);});var hasSelectedClass=$('li',nav).index($('li.'+settings.selectedClass,nav)[0]);if(hasSelectedClass>=0){settings.initial=hasSelectedClass;}if(location.hash){tabs.each(function(i){if(this.hash==location.hash){settings.initial=i;if(($.browser.msie||$.browser.opera)&&!settings.remote){var toShow=$(location.hash);var toShowId=toShow.attr('id');toShow.attr('id','');setTimeout(function(){toShow.attr('id',toShowId);},500);}unFocus();return false;}});}if($.browser.msie){unFocus();}containers.filter(':eq('+settings.initial+')').show().end().not(':eq('+settings.initial+')').addClass(settings.hideClass);$('li',nav).removeClass(settings.selectedClass).eq(settings.initial).addClass(settings.selectedClass);tabs.eq(settings.initial).trigger('loadRemoteTab').end();if(settings.fxAutoHeight){var _setAutoHeight=function(reset){var heights=$.map(containers.get(),function(el){var h,jq=$(el);if(reset){if($.browser.msie6){el.style.removeExpression('behaviour');el.style.height='';el.minHeight=null;}h=jq.css({'min-height':''}).height();}else{h=jq.height();}return h;}).sort(function(a,b){return b-a;});if($.browser.msie6){containers.each(function(){this.minHeight=heights[0]+'px';this.style.setExpression('behaviour','this.style.height = this.minHeight ? this.minHeight : "1px"');});}else{containers.css({'min-height':heights[0]+'px'});}};_setAutoHeight();var cachedWidth=container.offsetWidth;var cachedHeight=container.offsetHeight;var watchFontSize=$('#tabs-watch-font-size').get(0)||$('<span id="tabs-watch-font-size">M</span>').css({display:'block',position:'absolute',visibility:'hidden'}).appendTo(document.body).get(0);var cachedFontSize=watchFontSize.offsetHeight;setInterval(function(){var currentWidth=container.offsetWidth;var currentHeight=container.offsetHeight;var currentFontSize=watchFontSize.offsetHeight;if(currentHeight>cachedHeight||currentWidth!=cachedWidth||currentFontSize!=cachedFontSize){_setAutoHeight((currentWidth>cachedWidth||currentFontSize<cachedFontSize));cachedWidth=currentWidth;cachedHeight=currentHeight;cachedFontSize=currentFontSize;}},50);}var showAnim={},hideAnim={},showSpeed=settings.fxShowSpeed||settings.fxSpeed,hideSpeed=settings.fxHideSpeed||settings.fxSpeed;if(settings.fxSlide||settings.fxFade){if(settings.fxSlide){showAnim['height']='show';hideAnim['height']='hide';}if(settings.fxFade){showAnim['opacity']='show';hideAnim['opacity']='hide';}}else{if(settings.fxShow){showAnim=settings.fxShow;}else{showAnim['min-width']=0;showSpeed=1;}if(settings.fxHide){hideAnim=settings.fxHide;}else{hideAnim['min-width']=0;hideSpeed=1;}}var onClick=settings.onClick,onHide=settings.onHide,onShow=settings.onShow;tabs.bind('triggerTab',function(){var li=$(this).parents('li:eq(0)');if(container.locked||li.is('.'+settings.selectedClass)||li.is('.'+settings.disabledClass)){return false;}var hash=this.hash;if($.browser.msie){$(this).trigger('click');if(settings.bookmarkable){$.ajaxHistory.update(hash);location.hash=hash.replace('#','');}}else if($.browser.safari){var tempForm=$('<form action="'+hash+'"><div><input type="submit" value="h" /></div></form>').get(0);tempForm.submit();$(this).trigger('click');if(settings.bookmarkable){$.ajaxHistory.update(hash);}}else{if(settings.bookmarkable){location.hash=hash.replace('#','');}else{$(this).trigger('click');}}});tabs.bind('disableTab',function(){var li=$(this).parents('li:eq(0)');if($.browser.safari){li.animate({opacity:0},1,function(){li.css({opacity:''});});}li.addClass(settings.disabledClass);});if(settings.disabled&&settings.disabled.length){for(var i=0,k=settings.disabled.length;i<k;i++){tabs.eq(--settings.disabled[i]).trigger('disableTab').end();}};tabs.bind('enableTab',function(){var li=$(this).parents('li:eq(0)');li.removeClass(settings.disabledClass);if($.browser.safari){li.animate({opacity:1},1,function(){li.css({opacity:''});});}});tabs.bind('click',function(e){var trueClick=e.clientX;var clicked=this,li=$(this).parents('li:eq(0)'),toShow=$(this.hash),toHide=containers.filter(':visible');if(container['locked']||li.is('.'+settings.selectedClass)||li.is('.'+settings.disabledClass)||typeof onClick=='function'&&onClick(this,toShow[0],toHide[0])===false){this.blur();return false;}container['locked']=true;if(toShow.size()){if($.browser.msie&&settings.bookmarkable){var toShowId=this.hash.replace('#','');toShow.attr('id','');setTimeout(function(){toShow.attr('id',toShowId);},0);}var resetCSS={display:'',overflow:'',height:''};if(!$.browser.msie){resetCSS['opacity']='';}function switchTab(){if(settings.bookmarkable&&trueClick){$.ajaxHistory.update(clicked.hash);}toHide.animate(hideAnim,hideSpeed,function(){$(clicked).parents('li:eq(0)').addClass(settings.selectedClass).siblings().removeClass(settings.selectedClass);toHide.addClass(settings.hideClass).css(resetCSS);if(typeof onHide=='function'){onHide(clicked,toShow[0],toHide[0]);}if(!(settings.fxSlide||settings.fxFade||settings.fxShow)){toShow.css('display','block');}toShow.animate(showAnim,showSpeed,function(){toShow.removeClass(settings.hideClass).css(resetCSS);if($.browser.msie){toHide[0].style.filter='';toShow[0].style.filter='';}if(typeof onShow=='function'){onShow(clicked,toShow[0],toHide[0]);}container['locked']=null;});});}if(!settings.remote){switchTab();}else{$(clicked).trigger('loadRemoteTab',[switchTab]);}}else{alert('There is no such container.');}var scrollX=window.pageXOffset||document.documentElement&&document.documentElement.scrollLeft||document.body.scrollLeft||0;var scrollY=window.pageYOffset||document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop||0;setTimeout(function(){window.scrollTo(scrollX,scrollY);},0);this.blur();return settings.bookmarkable&&!!trueClick;});if(settings.bookmarkable){$.ajaxHistory.initialize(function(){tabs.eq(settings.initial).trigger('click').end();});}});};var tabEvents=['triggerTab','disableTab','enableTab'];for(var i=0;i<tabEvents.length;i++){$.fn[tabEvents[i]]=(function(tabEvent){return function(tab){return this.each(function(){var nav=$('ul.tabs-nav',this);nav=nav.size()&&nav||$('>ul:eq(0)',this);var a;if(!tab||typeof tab=='number'){a=$('li a',nav).eq((tab&&tab>0&&tab-1||0));}else if(typeof tab=='string'){a=$('li a[@href$="#'+tab+'"]',nav);}a.trigger(tabEvent);});};})(tabEvents[i]);}$.fn.activeTab=function(){var selectedTabs=[];this.each(function(){var nav=$('ul.tabs-nav',this);nav=nav.size()&&nav||$('>ul:eq(0)',this);var lis=$('li',nav);selectedTabs.push(lis.index(lis.filter('.tabs-selected')[0])+1);});return selectedTabs[0];};})(jQuery); \ No newline at end of file diff --git a/dist/jquery.js.html b/dist/jquery.js.html index 5566e8da7688153c5a039d180737aa03dda2f23f..2e0400857d81bbd05e094875f0572fe02ea484f0 100644 --- a/dist/jquery.js.html +++ b/dist/jquery.js.html @@ -5,7 +5,7 @@ ]#CACHE{7*24*3600,cache-client} #HTTP_HEADER{'Content-Type: text/javascript'} /* - * jQuery 1.1.3.1 - New Wave Javascript + * jQuery 1.2.1 - New Wave Javascript * * Copyright (c) 2007 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) @@ -15,18 +15,8 @@ * + ajaxCallback.js (www.spip.net) */ [(#INCLURE{javascript/jquery.js}|compacte_js)] -[(#INCLURE{javascript/form.js}|compacte_js)] +[(#INCLURE{javascript/jquery.form.js}|compacte_js)] [(#INCLURE{javascript/ajaxCallback.js}|compacte_js)] - - -[(#REM) - onglets (interface experimentale) - -][(#CONFIG{interface_mode}|=={onglets}|?{ - [(#INCLURE{javascript/jquery.tabs.min.js}|compacte_js)]} -)] - - [(#REM) js ajoutee par les plugin et a la volee] [(#ENV{script}|charge_scripts|compacte_js)] diff --git a/dist/jquery.tabs-ie.css b/dist/jquery.tabs-ie.css deleted file mode 100644 index b0dd7f4ec661cfbc3112cdf7facd440556b717ea..0000000000000000000000000000000000000000 --- a/dist/jquery.tabs-ie.css +++ /dev/null @@ -1,20 +0,0 @@ -/* -Tabs - additional IE specific bug fixes - -Recommended usage (Conditional Comments): -<!--[if lte IE 7]> -<link rel="stylesheet" href="tabs_ie.css" type="text/css" media="projection, screen" /> -<![endif]--> - -*/ -.tabs-nav { /* auto clear */ - display: inline-block; -} -.tabs-nav .tabs-disabled { - position: relative; /* fixes opacity */ - filter: alpha(opacity=40); -} -.tabs-nav .tabs-disabled a span { - _height: 19px; /* for some reason the height is 1px to less with opacity... */ - min-height: 19px; /* ...in both IE 6 and 7 */ -} diff --git a/dist/jquery.tabs.css b/dist/jquery.tabs.css deleted file mode 100644 index e65a42f314618c2642185907d4dd4a4616164703..0000000000000000000000000000000000000000 --- a/dist/jquery.tabs.css +++ /dev/null @@ -1,96 +0,0 @@ -/* Caution! Ensure accessibility in print and other media types... */ -@media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */ - .tabs-hide { - display: none; - } -} - -/* Hide useless elements in print layouts... */ -@media print { - .tabs-nav { - display: none; - } -} - -/* Skin */ -.tabs-nav { - list-style: none; - margin: 0; - padding: 0 0 0 4px; -} -.tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */ - display: block; - clear: both; - content: " "; -} -.tabs-nav li { - float: left; - margin: 0 0 0 1px; - min-width: 84px; /* be nice to Opera */ -} -.tabs-nav a, .tabs-nav a span { - display: block; - padding: 0 10px; - background: url(dist/images/tab.png) no-repeat; -} -.tabs-nav a { - position: relative; - top: 1px; - z-index: 2; - padding-left: 0; - color: #000; - font-size: 1em; - line-height: 1.2; - text-align: center; - text-decoration: none; - white-space: nowrap; /* required in IE 6 */ -} -.tabs-nav .tabs-selected a { - color: #000; -} -.tabs-nav .tabs-selected a, .tabs-nav a:hover, .tabs-nav a:focus, .tabs-nav a:active { - background-position: 100% -150px; - outline: 0; /* prevent dotted border in Firefox */ -} -.tabs-nav a, .tabs-nav .tabs-disabled a:hover, .tabs-nav .tabs-disabled a:focus, .tabs-nav .tabs-disabled a:active { - background-position: 100% -100px; -} -.tabs-nav a span { - width: 64px; /* IE 6 treats width as min-width */ - min-width: 64px; - height: 18px; /* IE 6 treats height as min-height */ - min-height: 18px; - padding-top: 6px; - padding-right: 0; -} -*>.tabs-nav a span { /* hide from IE 6 */ - width: auto; - height: auto; -} -.tabs-nav .tabs-selected a span { - padding-top: 7px; -} -.tabs-nav .tabs-selected a span, .tabs-nav a:hover span, .tabs-nav a:focus span, .tabs-nav a:active span { - background-position: 0 -50px; -} -.tabs-nav a span, .tabs-nav .tabs-disabled a:hover span, .tabs-nav .tabs-disabled a:focus span, .tabs-nav .tabs-disabled a:active span { - background-position: 0 0; -} -.tabs-nav .tabs-selected a:link, .tabs-nav .tabs-selected a:visited, .tabs-nav .tabs-disabled a:link, .tabs-nav .tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */ - cursor: text; -} -.tabs-nav a:hover, .tabs-nav a:focus, .tabs-nav a:active { /* @ Opera, we need to be explicit again here now... */ - cursor: pointer; -} -.tabs-nav .tabs-disabled { - opacity: .4; -} -.tabs-container { - border-top: 1px solid #999; - padding: 1em 0 0 0; - background: #f8f7f3; /* declare background color for container to avoid distorted fonts in IE while fading */ -} -.tabs-loading em { - padding: 0 0 0 20px; - background: url(dist/images/loading.gif) no-repeat 0 50%; -} diff --git a/dist/style_prive.html b/dist/style_prive.html index 408bec1e9f4c100c0fb5a44f223853dce356918e..8e63acd8546a98ccfa0956c97ada21fb4f8d8845 100644 --- a/dist/style_prive.html +++ b/dist/style_prive.html @@ -665,7 +665,6 @@ div.puce_article_popup, span.puce_article_popup { width: 55px; } div.puce_breve_popup, span.puce_breve_popup { width: 27px; } -[(#INCLURE{dist/jquery.tabs.css})] .boite_onglets {clear:both; margin-top:15px; } .tabs-nav a { color: #GET{foncee}; } diff --git a/ecrire/configuration/interfaceur.php b/ecrire/configuration/interfaceur.php deleted file mode 100644 index d9a296b8acc3793b4c6f5d9ac6e33f42080553c2..0000000000000000000000000000000000000000 --- a/ecrire/configuration/interfaceur.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -/***************************************************************************\ - * SPIP, Systeme de publication pour l'internet * - * * - * Copyright (c) 2001-2007 * - * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * - * * - * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * - * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * -\***************************************************************************/ - -if (!defined("_ECRIRE_INC_VERSION")) return; - -include_spip('inc/presentation'); -include_spip('inc/config'); - -// Formulaire (provisoire ?) pour passer de l'interface onglet a linterface lineaire -// Gestion des libelles a revoir - -function configuration_interfaceur_dist() -{ - - global $spip_lang_right; - - $res = "<div class='verdana2'>" - . _L('Vous pouvez definir le mode de présentation des articles :') - . "</div>" - . "<div class='verdana2'>" - . afficher_choix('interface_mode',$GLOBALS['meta']["interface_mode"] , - array('' => _L('Utiliser la présentation traditionnelle de SPIP'), - 'onglets' => _L('Utiliser les onglets pour présenter les articles') - )) - . "</div>"; - - $res = debut_cadre_trait_couleur("article-24.gif", true, "", _L('Choix de l\'interface')) - . ajax_action_post('configurer', 'interfaceur', 'config_fonctions', '', $res) - . fin_cadre_trait_couleur(true); - - return ajax_action_greffe("configurer-interfaceur", '', $res); - -} -?> diff --git a/ecrire/exec/config_fonctions.php b/ecrire/exec/config_fonctions.php index 42bd57f05edf66c21735c8a4b2f6f583e2b0acce..463ae94f1bfda2791a1aa55dc4a8a54afd274401 100644 --- a/ecrire/exec/config_fonctions.php +++ b/ecrire/exec/config_fonctions.php @@ -49,7 +49,6 @@ function exec_config_fonctions_dist() $versionneur = charger_fonction('versionneur', 'configuration'); $previsualiseur = charger_fonction('previsualiseur', 'configuration'); $relayeur = charger_fonction('relayeur', 'configuration'); - $interfaceur = charger_fonction('interfaceur', 'configuration'); echo @@ -66,9 +65,9 @@ function exec_config_fonctions_dist() $previsualiseur(), // Previsualisation sur le site public $relayeur(_request('retour_proxy')), // Proxy pour syndication & doc - - $interfaceur(); // choix du mode de presentation de l'interface - + + ''; + // // Choix supplementaires proposees par les plugins // diff --git a/ecrire/inc/config.php b/ecrire/inc/config.php index 78117d0838b7e1bb065149789518a38c6a75e0db..ec1a4747fcc7458b3fed179a08d9491d8c83cf12 100644 --- a/ecrire/inc/config.php +++ b/ecrire/inc/config.php @@ -88,8 +88,7 @@ function liste_metas() 'multi_rubriques' => 'non', 'multi_secteurs' => 'non', 'gerer_trad' => 'non', - 'langues_multilingue' => '', - 'interface_mode' => '' + 'langues_multilingue' => '' ); } diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php index ef9fc1fab46c51513b8d5bc2ea73379719316b95..e914ff78dcf4141b4f3e864566687b07efd9d88d 100644 --- a/ecrire/inc/presentation.php +++ b/ecrire/inc/presentation.php @@ -19,7 +19,7 @@ include_spip('inc/puce_statut'); define('_ACTIVER_PUCE_RAPIDE', true); define('_SIGNALER_ECHOS', true); -define('_INTERFACE_ONGLETS', $GLOBALS['meta']['interface_mode']==='onglets'); +define('_INTERFACE_ONGLETS', false); // http://doc.spip.org/@echo_log function echo_log($f, $ret) {