JBoss Rich Faces SVN: r12378 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-23 04:42:59 -0500 (Fri, 23 Jan 2009)
New Revision: 12378
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5563
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/tabPanel/tabPanelAutoTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-23 02:51:47 UTC (rev 12377)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/TabPanelTest.java 2009-01-23 09:42:59 UTC (rev 12378)
@@ -146,6 +146,14 @@
}
@Test
+ public void testBypassUpdatesAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, INIT_AJAX_CORE_TEST);
+ writeStatus("Test component with bypassUpdates = true skips update model values phase");
+ tester.testBypassUpdate();
+ }
+
+ @Test
public void testValidatorAndValidatorMessageAttributes(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, INIT_AJAX_CORE_TEST);
15 years, 11 months
JBoss Rich Faces SVN: r12377 - in trunk/framework/impl: src/main/javascript/jquery and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-01-22 21:51:47 -0500 (Thu, 22 Jan 2009)
New Revision: 12377
Added:
trunk/framework/impl/src/main/javascript/jquery/jquery-1.3.1.js
Modified:
trunk/framework/impl/generatescript.xml
Log:
https://jira.jboss.org/jira/browse/RF-5846
Modified: trunk/framework/impl/generatescript.xml
===================================================================
--- trunk/framework/impl/generatescript.xml 2009-01-22 16:11:58 UTC (rev 12376)
+++ trunk/framework/impl/generatescript.xml 2009-01-23 02:51:47 UTC (rev 12377)
@@ -50,7 +50,7 @@
-->
<filelist id="jquery"
dir="${basedir}/src/main/javascript/jquery"
- files="jquery-1.2.6.js,noConflict.js,../memory.js,patches.js">
+ files="jquery-1.3.1.js,noConflict.js,../memory.js,patches.js">
</filelist>
<filelist id="scriptaculous"
Added: trunk/framework/impl/src/main/javascript/jquery/jquery-1.3.1.js
===================================================================
--- trunk/framework/impl/src/main/javascript/jquery/jquery-1.3.1.js (rev 0)
+++ trunk/framework/impl/src/main/javascript/jquery/jquery-1.3.1.js 2009-01-23 02:51:47 UTC (rev 12377)
@@ -0,0 +1,4246 @@
+/*!
+ * jQuery JavaScript Library v1.3.1
+ * http://jquery.com/
+ *
+ * Copyright (c) 2009 John Resig
+ * Dual licensed under the MIT and GPL licenses.
+ * http://docs.jquery.com/License
+ *
+ * Date: 2009-01-21 20:42:16 -0500 (Wed, 21 Jan 2009)
+ * Revision: 6158
+ */
+(function(){
+
+var
+ // Will speed up references to window, and allows munging its name.
+ window = this,
+ // Will speed up references to undefined, and allows munging its name.
+ undefined,
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ jQuery = window.jQuery = window.$ = function( selector, context ) {
+ // added for RichFaces components
+ if (arguments[0] == arguments.callee) {
+ return arguments.callee;
+ }
+
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/;
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ // Make sure that a selection was provided
+ selector = selector || document;
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this[0] = selector;
+ this.length = 1;
+ this.context = selector;
+ return this;
+ }
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ var match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] )
+ selector = jQuery.clean( [ match[1] ], context );
+
+ // HANDLE: $("#id")
+ else {
+ var elem = document.getElementById( match[3] );
+
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem && elem.id != match[3] )
+ return jQuery().find( selector );
+
+ // Otherwise, we inject the element directly into the jQuery object
+ var ret = jQuery( elem || [] );
+ ret.context = document;
+ ret.selector = selector;
+ return ret;
+ }
+
+ // HANDLE: $(expr, [context])
+ // (which is just equivalent to: $(content).find(expr)
+ } else
+ return jQuery( context ).find( selector );
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) )
+ return jQuery( document ).ready( selector );
+
+ // Make sure that old selector state is passed along
+ if ( selector.selector && selector.context ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return this.setArray(jQuery.makeArray(selector));
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.3.1",
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num === undefined ?
+
+ // Return a 'clean' array
+ jQuery.makeArray( this ) :
+
+ // Return just the object
+ this[ num ];
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery( elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" )
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ else if ( name )
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Force the current matched set of elements to become
+ // the specified array of elements (destroying the stack in the process)
+ // You should use pushStack() in order to do this, but maintain the stack
+ setArray: function( elems ) {
+ // Resetting the length to 0, then using the native Array push
+ // is a super-fast way to populate an object with array-like properties
+ this.length = 0;
+ Array.prototype.push.apply( this, elems );
+
+ return this;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem && elem.jquery ? elem[0] : elem
+ , this );
+ },
+
+ attr: function( name, value, type ) {
+ var options = name;
+
+ // Look for the case where we're accessing a style value
+ if ( typeof name === "string" )
+ if ( value === undefined )
+ return this[0] && jQuery[ type || "attr" ]( this[0], name );
+
+ else {
+ options = {};
+ options[ name ] = value;
+ }
+
+ // Check to see if we're setting style values
+ return this.each(function(i){
+ // Set all the styles
+ for ( name in options )
+ jQuery.attr(
+ type ?
+ this.style :
+ this,
+ name, jQuery.prop( this, options[ name ], type, i, name )
+ );
+ });
+ },
+
+ css: function( key, value ) {
+ // ignore negative width and height values
+ if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
+ value = undefined;
+ return this.attr( key, value, "curCSS" );
+ },
+
+ text: function( text ) {
+ if ( typeof text !== "object" && text != null )
+ return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
+
+ var ret = "";
+
+ jQuery.each( text || this, function(){
+ jQuery.each( this.childNodes, function(){
+ if ( this.nodeType != 8 )
+ ret += this.nodeType != 1 ?
+ this.nodeValue :
+ jQuery.fn.text( [ this ] );
+ });
+ });
+
+ return ret;
+ },
+
+ wrapAll: function( html ) {
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).clone();
+
+ if ( this[0].parentNode )
+ wrap.insertBefore( this[0] );
+
+ wrap.map(function(){
+ var elem = this;
+
+ while ( elem.firstChild )
+ elem = elem.firstChild;
+
+ return elem;
+ }).append(this);
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ return this.each(function(){
+ jQuery( this ).contents().wrapAll( html );
+ });
+ },
+
+ wrap: function( html ) {
+ return this.each(function(){
+ jQuery( this ).wrapAll( html );
+ });
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function(elem){
+ if (this.nodeType == 1)
+ this.appendChild( elem );
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function(elem){
+ if (this.nodeType == 1)
+ this.insertBefore( elem, this.firstChild );
+ });
+ },
+
+ before: function() {
+ return this.domManip(arguments, false, function(elem){
+ this.parentNode.insertBefore( elem, this );
+ });
+ },
+
+ after: function() {
+ return this.domManip(arguments, false, function(elem){
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ },
+
+ end: function() {
+ return this.prevObject || jQuery( [] );
+ },
+
+ // For internal use only.
+ // Behaves like an Array's .push method, not like a jQuery method.
+ push: [].push,
+
+ find: function( selector ) {
+ if ( this.length === 1 && !/,/.test(selector) ) {
+ var ret = this.pushStack( [], "find", selector );
+ ret.length = 0;
+ jQuery.find( selector, this[0], ret );
+ return ret;
+ } else {
+ var elems = jQuery.map(this, function(elem){
+ return jQuery.find( selector, elem );
+ });
+
+ return this.pushStack( /[^+>] [^+>]/.test( selector ) ?
+ jQuery.unique( elems ) :
+ elems, "find", selector );
+ }
+ },
+
+ clone: function( events ) {
+ // Do the clone
+ var ret = this.map(function(){
+ if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
+ // IE copies events bound via attachEvent when
+ // using cloneNode. Calling detachEvent on the
+ // clone will also remove the events from the orignal
+ // In order to get around this, we use innerHTML.
+ // Unfortunately, this means some modifications to
+ // attributes in IE that are actually only stored
+ // as properties will not be copied (such as the
+ // the name attribute on an input).
+ var clone = this.cloneNode(true),
+ container = document.createElement("div");
+ container.appendChild(clone);
+ return jQuery.clean([container.innerHTML])[0];
+ } else
+ return 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){
+ if (this.nodeType == 3)
+ return;
+ 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 ret;
+ },
+
+ filter: function( selector ) {
+ return this.pushStack(
+ jQuery.isFunction( selector ) &&
+ jQuery.grep(this, function(elem, i){
+ return selector.call( elem, i );
+ }) ||
+
+ jQuery.multiFilter( selector, jQuery.grep(this, function(elem){
+ return elem.nodeType === 1;
+ }) ), "filter", selector );
+ },
+
+ closest: function( selector ) {
+ var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null;
+
+ return this.map(function(){
+ var cur = this;
+ while ( cur && cur.ownerDocument ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) )
+ return cur;
+ cur = cur.parentNode;
+ }
+ });
+ },
+
+ not: function( selector ) {
+ if ( typeof selector === "string" )
+ // test special case where just one selector is passed in
+ if ( isSimple.test( selector ) )
+ return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector );
+ else
+ selector = jQuery.multiFilter( selector, this );
+
+ var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
+ return this.filter(function() {
+ return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
+ });
+ },
+
+ add: function( selector ) {
+ return this.pushStack( jQuery.unique( jQuery.merge(
+ this.get(),
+ typeof selector === "string" ?
+ jQuery( selector ) :
+ jQuery.makeArray( selector )
+ )));
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.multiFilter( selector, this ).length > 0;
+ },
+
+ hasClass: function( selector ) {
+ return !!selector && this.is( "." + selector );
+ },
+
+ val: function( value ) {
+ if ( value === undefined ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if( jQuery.nodeName( elem, 'option' ) )
+ return (elem.attributes.value || {}).specified ? elem.value : elem.text;
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ 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
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one )
+ return value;
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(/\r/g, "");
+
+ }
+
+ return undefined;
+ }
+
+ if ( typeof value === "number" )
+ value += '';
+
+ return this.each(function(){
+ if ( this.nodeType != 1 )
+ return;
+
+ if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) )
+ this.checked = (jQuery.inArray(this.value, value) >= 0 ||
+ jQuery.inArray(this.name, value) >= 0);
+
+ else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(value);
+
+ jQuery( "option", this ).each(function(){
+ this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
+ jQuery.inArray( this.text, values ) >= 0);
+ });
+
+ if ( !values.length )
+ this.selectedIndex = -1;
+
+ } else
+ this.value = value;
+ });
+ },
+
+ html: function( value ) {
+ return value === undefined ?
+ (this[0] ?
+ this[0].innerHTML :
+ null) :
+ this.empty().append( value );
+ },
+
+ replaceWith: function( value ) {
+ return this.after( value ).remove();
+ },
+
+ eq: function( i ) {
+ return this.slice( i, +i + 1 );
+ },
+
+ slice: function() {
+ return this.pushStack( Array.prototype.slice.apply( this, arguments ),
+ "slice", Array.prototype.slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function(elem, i){
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ },
+
+ domManip: function( args, table, callback ) {
+ if ( this[0] ) {
+ var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(),
+ scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ),
+ first = fragment.firstChild,
+ extra = this.length > 1 ? fragment.cloneNode(true) : fragment;
+
+ if ( first )
+ for ( var i = 0, l = this.length; i < l; i++ )
+ callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );
+
+ if ( scripts )
+ jQuery.each( scripts, evalScript );
+ }
+
+ return this;
+
+ function root( elem, cur ) {
+ return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+ }
+ }
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+function evalScript( i, elem ) {
+ 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 );
+}
+
+function now(){
+ return +new Date;
+}
+
+jQuery.extend = jQuery.fn.extend = function() {
+ // copy reference to target object
+ var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) )
+ target = {};
+
+ // extend jQuery itself if only one argument is passed
+ if ( length == i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ )
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null )
+ // Extend the base object
+ for ( var name in options ) {
+ var src = target[ name ], copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy )
+ continue;
+
+ // Recurse if we're merging object values
+ if ( deep && copy && typeof copy === "object" && !copy.nodeType )
+ target[ name ] = jQuery.extend( deep,
+ // Never move original objects, clone them
+ src || ( copy.length != null ? [ ] : { } )
+ , copy );
+
+ // Don't bring in undefined values
+ else if ( copy !== undefined )
+ target[ name ] = copy;
+
+ }
+
+ // Return the modified object
+ return target;
+};
+
+// exclude the following css properties to add px
+var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
+ // cache defaultView
+ defaultView = document.defaultView || {},
+ toString = Object.prototype.toString;
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep )
+ window.jQuery = _jQuery;
+
+ return jQuery;
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
+ },
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
+ },
+
+ // check if an element is in a (or is an) XML document
+ isXMLDoc: function( elem ) {
+ return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
+ !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument );
+ },
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ data = jQuery.trim( data );
+
+ if ( data ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom...
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+ if ( jQuery.support.scriptEval )
+ script.appendChild( document.createTextNode( data ) );
+ else
+ script.text = data;
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0, length = object.length;
+
+ if ( args ) {
+ if ( length === undefined ) {
+ for ( name in object )
+ if ( callback.apply( object[ name ], args ) === false )
+ break;
+ } else
+ for ( ; i < length; )
+ if ( callback.apply( object[ i++ ], args ) === false )
+ break;
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( length === undefined ) {
+ for ( name in object )
+ if ( callback.call( object[ name ], name, object[ name ] ) === false )
+ break;
+ } else
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
+ }
+
+ return object;
+ },
+
+ prop: function( elem, value, type, i, name ) {
+ // Handle executable functions
+ if ( jQuery.isFunction( value ) )
+ value = value.call( elem, i );
+
+ // Handle passing in a number to a CSS property
+ return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
+ value + "px" :
+ value;
+ },
+
+ className: {
+ // internal only, use addClass("class")
+ add: function( elem, classNames ) {
+ jQuery.each((classNames || "").split(/\s+/), function(i, className){
+ if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) )
+ elem.className += (elem.className ? " " : "") + className;
+ });
+ },
+
+ // internal only, use removeClass("class")
+ remove: function( elem, classNames ) {
+ if (elem.nodeType == 1)
+ elem.className = classNames !== undefined ?
+ jQuery.grep(elem.className.split(/\s+/), function(className){
+ return !jQuery.className.has( classNames, className );
+ }).join(" ") :
+ "";
+ },
+
+ // internal only, use hasClass("class")
+ has: function( elem, className ) {
+ return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
+ }
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var old = {};
+ // Remember the old values, and insert the new ones
+ for ( var name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ callback.call( elem );
+
+ // Revert the old values
+ for ( var name in options )
+ elem.style[ name ] = old[ name ];
+ },
+
+ css: function( elem, name, force ) {
+ if ( name == "width" || name == "height" ) {
+ var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
+
+ function getWH() {
+ val = name == "width" ? elem.offsetWidth : elem.offsetHeight;
+ var padding = 0, border = 0;
+ jQuery.each( which, function() {
+ padding += parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
+ border += parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
+ });
+ val -= Math.round(padding + border);
+ }
+
+ if ( jQuery(elem).is(":visible") )
+ getWH();
+ else
+ jQuery.swap( elem, props, getWH );
+
+ return Math.max(0, val);
+ }
+
+ return jQuery.curCSS( elem, name, force );
+ },
+
+ curCSS: function( elem, name, force ) {
+ var ret, style = elem.style;
+
+ // We need to handle opacity special in IE
+ if ( name == "opacity" && !jQuery.support.opacity ) {
+ ret = jQuery.attr( style, "opacity" );
+
+ return ret == "" ?
+ "1" :
+ ret;
+ }
+
+ // Make sure we're using the right name for getting the float value
+ if ( name.match( /float/i ) )
+ name = styleFloat;
+
+ if ( !force && style && style[ name ] )
+ ret = style[ name ];
+
+ else if ( defaultView.getComputedStyle ) {
+
+ // Only "float" is needed here
+ if ( name.match( /float/i ) )
+ name = "float";
+
+ name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
+
+ var computedStyle = defaultView.getComputedStyle( elem, null );
+
+ if ( computedStyle )
+ ret = computedStyle.getPropertyValue( name );
+
+ // We should always get a number back from opacity
+ if ( name == "opacity" && ret == "" )
+ ret = "1";
+
+ } else if ( elem.currentStyle ) {
+ var camelCase = name.replace(/\-(\w)/g, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
+
+ // 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 ) ) {
+ // Remember the original values
+ var left = style.left, rsLeft = elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ style.left = ret || 0;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret;
+ },
+
+ clean: function( elems, context, fragment ) {
+ context = context || document;
+
+ // !context.createElement fails in IE with an error but returns typeof 'object'
+ if ( typeof context.createElement === "undefined" )
+ context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) {
+ var match = /^<(\w+)\s*\/?>$/.exec(elems[0]);
+ if ( match )
+ return [ context.createElement( match[1] ) ];
+ }
+
+ var ret = [], scripts = [], div = context.createElement("div");
+
+ jQuery.each(elems, function(i, elem){
+ if ( typeof elem === "number" )
+ elem += '';
+
+ if ( !elem )
+ return;
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" ) {
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
+ return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
+ all :
+ front + "></" + tag + ">";
+ });
+
+ // Trim whitespace, otherwise indexOf won't work as expected
+ var tags = jQuery.trim( elem ).toLowerCase();
+
+ var wrap =
+ // option or optgroup
+ !tags.indexOf("<opt") &&
+ [ 1, "<select multiple='multiple'>", "</select>" ] ||
+
+ !tags.indexOf("<leg") &&
+ [ 1, "<fieldset>", "</fieldset>" ] ||
+
+ tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
+ [ 1, "<table>", "</table>" ] ||
+
+ !tags.indexOf("<tr") &&
+ [ 2, "<table><tbody>", "</tbody></table>" ] ||
+
+ // <thead> matched above
+ (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
+ [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
+
+ !tags.indexOf("<col") &&
+ [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
+
+ // IE can't serialize <link> and <script> tags normally
+ !jQuery.support.htmlSerialize &&
+ [ 1, "div<div>", "</div>" ] ||
+
+ [ 0, "", "" ];
+
+ // Go to html and back, then peel off extra wrappers
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( wrap[0]-- )
+ div = div.lastChild;
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
+ div.childNodes :
+ [];
+
+ for ( var j = tbody.length - 1; j >= 0 ; --j )
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length )
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
+ div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
+
+ elem = jQuery.makeArray( div.childNodes );
+ }
+
+ if ( elem.nodeType )
+ ret.push( elem );
+ else
+ ret = jQuery.merge( ret, elem );
+
+ });
+
+ if ( fragment ) {
+ for ( var i = 0; ret[i]; i++ ) {
+ if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
+ scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ } else {
+ if ( ret[i].nodeType === 1 )
+ ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
+ fragment.appendChild( ret[i] );
+ }
+ }
+
+ return scripts;
+ }
+
+ return ret;
+ },
+
+ attr: function( elem, name, value ) {
+ // don't set attributes on text and comment nodes
+ if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
+ return undefined;
+
+ var notxml = !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // Only do all the following if this is a node (faster for style)
+ // IE elem.getAttribute passes even for style
+ if ( elem.tagName ) {
+
+ // These attributes require special treatment
+ var special = /href|src|style/.test( name );
+
+ // Safari mis-reports the default selected property of a hidden option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name == "selected" && elem.parentNode )
+ elem.parentNode.selectedIndex;
+
+ // If applicable, access the attribute via the DOM 0 way
+ if ( name in elem && notxml && !special ) {
+ if ( set ){
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
+ throw "type property can't be changed";
+
+ elem[ name ] = value;
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) )
+ return elem.getAttributeNode( name ).nodeValue;
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabi...
+ if ( name == "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+ return attributeNode && attributeNode.specified
+ ? attributeNode.value
+ : elem.nodeName.match(/(button|input|object|select|textarea)/i)
+ ? 0
+ : elem.nodeName.match(/^(a|area)$/i) && elem.href
+ ? 0
+ : undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name == "style" )
+ return jQuery.attr( elem.style, "cssText", value );
+
+ if ( set )
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special
+ // Some attributes require a special call on IE
+ ? elem.getAttribute( name, 2 )
+ : elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+
+ // elem is actually elem.style ... set the style
+
+ // IE uses filters for opacity
+ if ( !jQuery.support.opacity && name == "opacity" ) {
+ if ( set ) {
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ elem.zoom = 1;
+
+ // Set the alpha filter to set the opacity
+ elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
+ (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
+ }
+
+ return elem.filter && elem.filter.indexOf("opacity=") >= 0 ?
+ (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '':
+ "";
+ }
+
+ name = name.replace(/-([a-z])/ig, function(all, letter){
+ return letter.toUpperCase();
+ });
+
+ if ( set )
+ elem[ name ] = value;
+
+ return elem[ name ];
+ },
+
+ trim: function( text ) {
+ return (text || "").replace( /^\s+|\s+$/g, "" );
+ },
+
+ makeArray: function( array ) {
+ var ret = [];
+
+ if( array != null ){
+ var i = array.length;
+ // The window, strings (and functions) also have 'length'
+ if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
+ ret[0] = array;
+ else
+ while( i )
+ ret[--i] = array[i];
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ for ( var i = 0, length = array.length; i < length; i++ )
+ // Use === because on IE, window == document
+ if ( array[ i ] === elem )
+ return i;
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ // We have to loop this way because IE & Opera overwrite the length
+ // expando of getElementsByTagName
+ var i = 0, elem, pos = first.length;
+ // Also, we need to make sure that the correct elements are being returned
+ // (IE returns comment nodes in a '*' query)
+ if ( !jQuery.support.getAll ) {
+ while ( (elem = second[ i++ ]) != null )
+ if ( elem.nodeType != 8 )
+ first[ pos++ ] = elem;
+
+ } else
+ while ( (elem = second[ i++ ]) != null )
+ first[ pos++ ] = elem;
+
+ return first;
+ },
+
+ unique: function( array ) {
+ var ret = [], done = {};
+
+ try {
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ var id = jQuery.data( array[ i ] );
+
+ if ( !done[ id ] ) {
+ done[ id ] = true;
+ ret.push( array[ i ] );
+ }
+ }
+
+ } catch( e ) {
+ ret = array;
+ }
+
+ return ret;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [];
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ )
+ if ( !inv != !callback( elems[ i ], i ) )
+ ret.push( elems[ i ] );
+
+ return ret;
+ },
+
+ map: function( elems, callback ) {
+ var ret = [];
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ var value = callback( elems[ i ], i );
+
+ if ( value != null )
+ ret[ ret.length ] = value;
+ }
+
+ return ret.concat.apply( [], ret );
+ }
+});
+
+// Use of jQuery.browser is deprecated.
+// It's included for backwards compatibility and plugins,
+// although they should work to migrate away.
+
+var userAgent = navigator.userAgent.toLowerCase();
+
+// Figure out what browser is being used
+jQuery.browser = {
+ version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[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.each({
+ parent: function(elem){return elem.parentNode;},
+ parents: function(elem){return jQuery.dir(elem,"parentNode");},
+ next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
+ prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
+ nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
+ prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
+ siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
+ children: function(elem){return jQuery.sibling(elem.firstChild);},
+ contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
+}, function(name, fn){
+ jQuery.fn[ name ] = function( selector ) {
+ var ret = jQuery.map( this, fn );
+
+ if ( selector && typeof selector == "string" )
+ ret = jQuery.multiFilter( selector, ret );
+
+ return this.pushStack( jQuery.unique( ret ), name, selector );
+ };
+});
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function(name, original){
+ jQuery.fn[ name ] = function() {
+ var args = arguments;
+
+ return this.each(function(){
+ for ( var i = 0, length = args.length; i < length; i++ )
+ jQuery( args[ i ] )[ original ]( this );
+ });
+ };
+});
+
+jQuery.each({
+ removeAttr: function( name ) {
+ jQuery.attr( this, name, "" );
+ if (this.nodeType == 1)
+ this.removeAttribute( name );
+ },
+
+ addClass: function( classNames ) {
+ jQuery.className.add( this, classNames );
+ },
+
+ removeClass: function( classNames ) {
+ jQuery.className.remove( this, classNames );
+ },
+
+ toggleClass: function( classNames, state ) {
+ if( typeof state !== "boolean" )
+ state = !jQuery.className.has( this, classNames );
+ jQuery.className[ state ? "add" : "remove" ]( this, classNames );
+ },
+
+ remove: function( selector ) {
+ if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
+ // Prevent memory leaks
+ jQuery( "*", this ).add([this]).each(function(){
+ jQuery.event.remove(this);
+ jQuery.removeData(this);
+ });
+ if (this.parentNode)
+ this.parentNode.removeChild( this );
+ }
+ },
+
+ empty: function() {
+ // Remove element nodes and prevent memory leaks
+ jQuery( ">*", this ).remove();
+
+ // Remove any remaining nodes
+ while ( this.firstChild )
+ this.removeChild( this.firstChild );
+ }
+}, function(name, fn){
+ jQuery.fn[ name ] = function(){
+ return this.each( fn, arguments );
+ };
+});
+
+// Helper function used by the dimensions and offset modules
+function num(elem, prop) {
+ return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0;
+}
+var expando = jQuery.expando = "jQuery" + now(), uuid = 0, windowData = {};
+
+jQuery.extend({
+ cache: {},
+
+ data: function( elem, name, data ) {
+ elem = elem == window ?
+ windowData :
+ 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 ?
+ windowData :
+ 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 ];
+ }
+ },
+ queue: function( elem, type, data ) {
+ if ( elem ){
+
+ type = (type || "fx") + "queue";
+
+ var q = jQuery.data( elem, type );
+
+ if ( !q || jQuery.isArray(data) )
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+ else if( data )
+ q.push( data );
+
+ }
+ return q;
+ },
+
+ dequeue: function( elem, type ){
+ var queue = jQuery.queue( elem, type ),
+ fn = queue.shift();
+
+ if( !type || type === "fx" )
+ fn = queue[0];
+
+ if( fn !== undefined )
+ fn.call(elem);
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ){
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ if ( data === undefined && this.length )
+ data = jQuery.data( this[0], key );
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ } else
+ return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
+ jQuery.data( this, key, value );
+ });
+ },
+
+ removeData: function( key ){
+ return this.each(function(){
+ jQuery.removeData( this, key );
+ });
+ },
+ queue: function(type, data){
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined )
+ return jQuery.queue( this[0], type );
+
+ return this.each(function(){
+ var queue = jQuery.queue( this, type, data );
+
+ if( type == "fx" && queue.length == 1 )
+ queue[0].call(this);
+ });
+ },
+ dequeue: function(type){
+ return this.each(function(){
+ jQuery.dequeue( this, type );
+ });
+ }
+});/*!
+ * Sizzle CSS Selector Engine - v0.9.3
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]+['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[]+)+|[>+~])(\s*,\s*)?/g,
+ done = 0,
+ toString = Object.prototype.toString;
+
+var Sizzle = function(selector, context, results, seed) {
+ results = results || [];
+ context = context || document;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 )
+ return [];
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var parts = [], m, set, checkSet, check, mode, extra, prune = true;
+
+ // Reset the position of the chunker regexp (start from head)
+ chunker.lastIndex = 0;
+
+ while ( (m = chunker.exec(selector)) !== null ) {
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = RegExp.rightContext;
+ break;
+ }
+ }
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] )
+ selector += parts.shift();
+
+ set = posProcess( selector, set );
+ }
+ }
+ } else {
+ var ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) );
+ set = Sizzle.filter( ret.expr, ret.set );
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray(set);
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ var cur = parts.pop(), pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, isXML(context) );
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ throw "Syntax error, unrecognized expression: " + (cur || selector);
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+ } else if ( context.nodeType === 1 ) {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+ } else {
+ for ( var i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, context, results, seed );
+ }
+
+ return results;
+};
+
+Sizzle.matches = function(expr, set){
+ return Sizzle(expr, null, null, set);
+};
+
+Sizzle.find = function(expr, context, isXML){
+ var set, match;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var type = Expr.order[i], match;
+
+ if ( (match = Expr.match[ type ].exec( expr )) ) {
+ var left = RegExp.leftContext;
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName("*");
+ }
+
+ return {set: set, expr: expr};
+};
+
+Sizzle.filter = function(expr, set, inplace, not){
+ var old = expr, result = [], curLoop = set, match, anyFound;
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.match[ type ].exec( expr )) != null ) {
+ var filter = Expr.filter[ type ], found, item;
+ anyFound = false;
+
+ if ( curLoop == result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not );
+
+ if ( !match ) {
+ anyFound = found = true;
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+ } else {
+ curLoop[i] = false;
+ }
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ expr = expr.replace(/\s*,\s*/, "");
+
+ // Improper expression
+ if ( expr == old ) {
+ if ( anyFound == null ) {
+ throw "Syntax error, unrecognized expression: " + expr;
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
+ },
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+ attrHandle: {
+ href: function(elem){
+ return elem.getAttribute("href");
+ }
+ },
+ relative: {
+ "+": function(checkSet, part){
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var cur = elem.previousSibling;
+ while ( cur && cur.nodeType !== 1 ) {
+ cur = cur.previousSibling;
+ }
+ checkSet[i] = typeof part === "string" ?
+ cur || false :
+ cur === part;
+ }
+ }
+
+ if ( typeof part === "string" ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+ ">": function(checkSet, part, isXML){
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ part = isXML ? part : part.toUpperCase();
+
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName === part ? parent : false;
+ }
+ }
+ } else {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ checkSet[i] = typeof part === "string" ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( typeof part === "string" ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+ "": function(checkSet, part, isXML){
+ var doneName = "done" + (done++), checkFn = dirCheck;
+
+ if ( !part.match(/\W/) ) {
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
+ },
+ "~": function(checkSet, part, isXML){
+ var doneName = "done" + (done++), checkFn = dirCheck;
+
+ if ( typeof part === "string" && !part.match(/\W/) ) {
+ var nodeCheck = part = isXML ? part : part.toUpperCase();
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
+ }
+ },
+ find: {
+ ID: function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? [m] : [];
+ }
+ },
+ NAME: function(match, context, isXML){
+ if ( typeof context.getElementsByName !== "undefined" && !isXML ) {
+ return context.getElementsByName(match[1]);
+ }
+ },
+ TAG: function(match, context){
+ return context.getElementsByTagName(match[1]);
+ }
+ },
+ preFilter: {
+ CLASS: function(match, curLoop, inplace, result, not){
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ var elem;
+ for ( var i = 0; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (" " + elem.className + " ").indexOf(match) >= 0 ) {
+ if ( !inplace )
+ result.push( elem );
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+ ID: function(match){
+ return match[1].replace(/\\/g, "");
+ },
+ TAG: function(match, curLoop){
+ for ( var i = 0; curLoop[i] === false; i++ ){}
+ return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
+ },
+ CHILD: function(match){
+ if ( match[1] == "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = "done" + (done++);
+
+ return match;
+ },
+ ATTR: function(match){
+ var name = match[1].replace(/\\/g, "");
+
+ if ( Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+ PSEUDO: function(match, curLoop, inplace, result, not){
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( match[3].match(chunker).length > 1 ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+ return false;
+ }
+ } else if ( Expr.match.POS.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+ POS: function(match){
+ match.unshift( true );
+ return match;
+ }
+ },
+ filters: {
+ enabled: function(elem){
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+ disabled: function(elem){
+ return elem.disabled === true;
+ },
+ checked: function(elem){
+ return elem.checked === true;
+ },
+ selected: function(elem){
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+ return elem.selected === true;
+ },
+ parent: function(elem){
+ return !!elem.firstChild;
+ },
+ empty: function(elem){
+ return !elem.firstChild;
+ },
+ has: function(elem, i, match){
+ return !!Sizzle( match[3], elem ).length;
+ },
+ header: function(elem){
+ return /h\d/i.test( elem.nodeName );
+ },
+ text: function(elem){
+ return "text" === elem.type;
+ },
+ radio: function(elem){
+ return "radio" === elem.type;
+ },
+ checkbox: function(elem){
+ return "checkbox" === elem.type;
+ },
+ file: function(elem){
+ return "file" === elem.type;
+ },
+ password: function(elem){
+ return "password" === elem.type;
+ },
+ submit: function(elem){
+ return "submit" === elem.type;
+ },
+ image: function(elem){
+ return "image" === elem.type;
+ },
+ reset: function(elem){
+ return "reset" === elem.type;
+ },
+ button: function(elem){
+ return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
+ },
+ input: function(elem){
+ return /input|select|textarea|button/i.test(elem.nodeName);
+ }
+ },
+ setFilters: {
+ first: function(elem, i){
+ return i === 0;
+ },
+ last: function(elem, i, match, array){
+ return i === array.length - 1;
+ },
+ even: function(elem, i){
+ return i % 2 === 0;
+ },
+ odd: function(elem, i){
+ return i % 2 === 1;
+ },
+ lt: function(elem, i, match){
+ return i < match[3] - 0;
+ },
+ gt: function(elem, i, match){
+ return i > match[3] - 0;
+ },
+ nth: function(elem, i, match){
+ return match[3] - 0 == i;
+ },
+ eq: function(elem, i, match){
+ return match[3] - 0 == i;
+ }
+ },
+ filter: {
+ CHILD: function(elem, match){
+ var type = match[1], parent = elem.parentNode;
+
+ var doneName = match[0];
+
+ if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
+ var count = 1;
+
+ for ( var node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType == 1 ) {
+ node.nodeIndex = count++;
+ }
+ }
+
+ parent[ doneName ] = count - 1;
+ }
+
+ if ( type == "first" ) {
+ return elem.nodeIndex == 1;
+ } else if ( type == "last" ) {
+ return elem.nodeIndex == parent[ doneName ];
+ } else if ( type == "only" ) {
+ return parent[ doneName ] == 1;
+ } else if ( type == "nth" ) {
+ var add = false, first = match[2], last = match[3];
+
+ if ( first == 1 && last == 0 ) {
+ return true;
+ }
+
+ if ( first == 0 ) {
+ if ( elem.nodeIndex == last ) {
+ add = true;
+ }
+ } else if ( (elem.nodeIndex - last) % first == 0 && (elem.nodeIndex - last) / first >= 0 ) {
+ add = true;
+ }
+
+ return add;
+ }
+ },
+ PSEUDO: function(elem, match, i, array){
+ var name = match[1], filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var i = 0, l = not.length; i < l; i++ ) {
+ if ( not[i] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ },
+ ID: function(elem, match){
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+ TAG: function(elem, match){
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
+ },
+ CLASS: function(elem, match){
+ return match.test( elem.className );
+ },
+ ATTR: function(elem, match){
+ var result = Expr.attrHandle[ match[1] ] ? Expr.attrHandle[ match[1] ]( elem ) : elem[ match[1] ] || elem.getAttribute( match[1] ), value = result + "", type = match[2], check = match[4];
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !match[4] ?
+ result :
+ type === "!=" ?
+ value != check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+ POS: function(elem, match, i, array){
+ var name = match[2], filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS;
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
+}
+
+var makeArray = function(array, results) {
+ array = Array.prototype.slice.call( array );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes );
+
+// Provide a fallback method if it does not work
+} catch(e){
+ makeArray = function(array, results) {
+ var ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var i = 0, l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+ } else {
+ for ( var i = 0; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("form"),
+ id = "script" + (new Date).getTime();
+ form.innerHTML = "<input name='" + id + "'/>";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ var root = document.documentElement;
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( !!document.getElementById( id ) ) {
+ Expr.find.ID = function(match, context, isXML){
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
+ }
+ };
+
+ Expr.filter.ID = function(elem, match){
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function(match, context){
+ var results = context.getElementsByTagName(match[1]);
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "<a href='#'></a>";
+ if ( div.firstChild && div.firstChild.getAttribute("href") !== "#" ) {
+ Expr.attrHandle.href = function(elem){
+ return elem.getAttribute("href", 2);
+ };
+ }
+})();
+
+if ( document.querySelectorAll ) (function(){
+ var oldSizzle = Sizzle, div = document.createElement("div");
+ div.innerHTML = "<p class='TEST'></p>";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function(query, context, extra, seed){
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && context.nodeType === 9 && !isXML(context) ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(e){}
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ Sizzle.find = oldSizzle.find;
+ Sizzle.filter = oldSizzle.filter;
+ Sizzle.selectors = oldSizzle.selectors;
+ Sizzle.matches = oldSizzle.matches;
+})();
+
+if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) {
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function(match, context) {
+ return context.getElementsByClassName(match[1]);
+ };
+}
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem && elem.nodeType ) {
+ var done = elem[doneName];
+ if ( done ) {
+ match = checkSet[ done ];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML )
+ elem[doneName] = i;
+
+ if ( elem.nodeName === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+ if ( elem ) {
+ elem = elem[dir];
+ var match = false;
+
+ while ( elem && elem.nodeType ) {
+ if ( elem[doneName] ) {
+ match = checkSet[ elem[doneName] ];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML )
+ elem[doneName] = i;
+
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+var contains = document.compareDocumentPosition ? function(a, b){
+ return a.compareDocumentPosition(b) & 16;
+} : function(a, b){
+ return a !== b && (a.contains ? a.contains(b) : true);
+};
+
+var isXML = function(elem){
+ return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
+ !!elem.ownerDocument && isXML( elem.ownerDocument );
+};
+
+var posProcess = function(selector, context){
+ var tmpSet = [], later = "", match,
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.filter = Sizzle.filter;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+
+Sizzle.selectors.filters.hidden = function(elem){
+ return "hidden" === elem.type ||
+ jQuery.css(elem, "display") === "none" ||
+ jQuery.css(elem, "visibility") === "hidden";
+};
+
+Sizzle.selectors.filters.visible = function(elem){
+ return "hidden" !== elem.type &&
+ jQuery.css(elem, "display") !== "none" &&
+ jQuery.css(elem, "visibility") !== "hidden";
+};
+
+Sizzle.selectors.filters.animated = function(elem){
+ return jQuery.grep(jQuery.timers, function(fn){
+ return elem === fn.elem;
+ }).length;
+};
+
+jQuery.multiFilter = function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return Sizzle.matches(expr, elems);
+};
+
+jQuery.dir = function( elem, dir ){
+ var matched = [], cur = elem[dir];
+ while ( cur && cur != document ) {
+ if ( cur.nodeType == 1 )
+ matched.push( cur );
+ cur = cur[dir];
+ }
+ return matched;
+};
+
+jQuery.nth = function(cur, result, dir, elem){
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] )
+ if ( cur.nodeType == 1 && ++num == result )
+ break;
+
+ return cur;
+};
+
+jQuery.sibling = function(n, elem){
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType == 1 && n != elem )
+ r.push( n );
+ }
+
+ return r;
+};
+
+return;
+
+window.Sizzle = Sizzle;
+
+})();
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function(elem, types, handler, data) {
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( elem.setInterval && elem != window )
+ elem = 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
+ var fn = handler;
+
+ // Create unique handler function, wrapped around original handler
+ handler = this.proxy( fn );
+
+ // Store data in unique handler
+ handler.data = data;
+ }
+
+ // Init the element's event structure
+ var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
+ handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply(arguments.callee.elem, arguments) :
+ undefined;
+ });
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native
+ // event in IE.
+ handle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type) {
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ handler.type = namespaces.slice().sort().join(".");
+
+ // Get the current list of functions bound to this event
+ var handlers = events[type];
+
+ if ( jQuery.event.specialAll[type] )
+ jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
+
+ // Init the event handler queue
+ if (!handlers) {
+ handlers = events[type] = {};
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) {
+ // Bind the global event handler to the element
+ if (elem.addEventListener)
+ elem.addEventListener(type, handle, false);
+ else if (elem.attachEvent)
+ elem.attachEvent("on" + type, handle);
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers[handler.guid] = handler;
+
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[type] = true;
+ });
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ guid: 1,
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function(elem, types, handler) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
+ return;
+
+ var events = jQuery.data(elem, "events"), ret, index;
+
+ if ( events ) {
+ // Unbind all events for the element
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
+ for ( var type in events )
+ this.remove( elem, type + (types || "") );
+ else {
+ // types is actually an event object here
+ if ( types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Handle multiple events seperated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ jQuery.each(types.split(/\s+/), function(index, type){
+ // Namespaced event handlers
+ var namespaces = type.split(".");
+ type = namespaces.shift();
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
+
+ if ( events[type] ) {
+ // remove the given handler for the given type
+ if ( handler )
+ delete events[type][handler.guid];
+
+ // remove all handlers for the given type
+ else
+ for ( var handle in events[type] )
+ // Handle the removal of namespaced events
+ if ( namespace.test(events[type][handle].type) )
+ delete events[type][handle];
+
+ if ( jQuery.event.specialAll[type] )
+ jQuery.event.specialAll[type].teardown.call(elem, namespaces);
+
+ // remove generic event handler if no more handlers exist
+ for ( ret in events[type] ) break;
+ if ( !ret ) {
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
+ if (elem.removeEventListener)
+ elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
+ else if (elem.detachEvent)
+ elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
+ }
+ ret = null;
+ delete events[type];
+ }
+ }
+ });
+ }
+
+ // Remove the expando if it's no longer used
+ for ( ret in events ) break;
+ if ( !ret ) {
+ var handle = jQuery.data( elem, "handle" );
+ if ( handle ) handle.elem = null;
+ jQuery.removeData( elem, "events" );
+ jQuery.removeData( elem, "handle" );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem, bubbling ) {
+ // Event object or event type
+ var type = event.type || event;
+
+ if( !bubbling ){
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[expando] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+ // Only trigger if we've ever bound an event for it
+ if ( this.global[type] )
+ jQuery.each( jQuery.cache, function(){
+ if ( this.events && this.events[type] )
+ jQuery.event.trigger( event, data, this.handle.elem );
+ });
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
+ return undefined;
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray(data);
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = jQuery.data(elem, "handle");
+ if ( handle )
+ handle.apply( elem, data );
+
+ // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
+ if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
+ event.result = false;
+
+ // Trigger the native events (except for clicks on links)
+ if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
+ this.triggered = true;
+ try {
+ elem[ type ]();
+ // prevent IE from throwing an error for some hidden elements
+ } catch (e) {}
+ }
+
+ this.triggered = false;
+
+ if ( !event.isPropagationStopped() ) {
+ var parent = elem.parentNode || elem.ownerDocument;
+ if ( parent )
+ jQuery.event.trigger(event, data, parent, true);
+ }
+ },
+
+ handle: function(event) {
+ // returned undefined or false
+ var all, handlers;
+
+ event = arguments[0] = jQuery.event.fix( event || window.event );
+
+ // Namespaced event handlers
+ var namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+
+ // Cache this now, all = true means, any handler
+ all = !namespaces.length && !event.exclusive;
+
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
+
+ handlers = ( jQuery.data(this, "events") || {} )[event.type];
+
+ for ( var j in handlers ) {
+ var handler = handlers[j];
+
+ // Filter the functions by class
+ if ( all || namespace.test(handler.type) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handler;
+ event.data = handler.data;
+
+ var ret = handler.apply(this, arguments);
+
+ if( ret !== undefined ){
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if( event.isImmediatePropagationStopped() )
+ break;
+
+ }
+ }
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function(event) {
+ if ( event[expando] )
+ return event;
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ){
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target )
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType == 3 )
+ event.target = event.target.parentNode;
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement )
+ event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement, body = document.body;
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
+ event.which = event.charCode || event.keyCode;
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey )
+ event.metaKey = event.ctrlKey;
+
+ // Add which for click: 1 == left; 2 == middle; 3 == right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button )
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+
+ return event;
+ },
+
+ proxy: function( fn, proxy ){
+ proxy = proxy || function(){ return fn.apply(this, arguments); };
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: bindReady,
+ teardown: function() {}
+ }
+ },
+
+ specialAll: {
+ live: {
+ setup: function( selector, namespaces ){
+ jQuery.event.add( this, namespaces[0], liveHandler );
+ },
+ teardown: function( namespaces ){
+ if ( namespaces.length ) {
+ var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+ jQuery.each( (jQuery.data(this, "events").live || {}), function(){
+ if ( name.test(this.type) )
+ remove++;
+ });
+
+ if ( remove < 1 )
+ jQuery.event.remove( this, namespaces[0], liveHandler );
+ }
+ }
+ }
+ }
+};
+
+jQuery.Event = function( src ){
+ // Allow instantiation without the 'new' keyword
+ if( !this.preventDefault )
+ return new jQuery.Event(src);
+
+ // Event object
+ if( src && src.type ){
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ }else
+ this.type = src;
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
+
+ // Mark it as fixed
+ this[expando] = true;
+};
+
+function returnFalse(){
+ return false;
+}
+function returnTrue(){
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-bind...
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if( !e )
+ return;
+ // if preventDefault exists run it on the original event
+ if (e.preventDefault)
+ e.preventDefault();
+ // otherwise set the returnValue property of the original event to false (IE)
+ e.returnValue = false;
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if( !e )
+ return;
+ // if stopPropagation exists run it on the original event
+ if (e.stopPropagation)
+ e.stopPropagation();
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation:function(){
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function(event) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+ // Traverse up the tree
+ while ( parent && parent != this )
+ try { parent = parent.parentNode; }
+ catch(e) { parent = this; }
+
+ if( parent != this ){
+ // set the correct event type
+ event.type = event.data;
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+};
+
+jQuery.each({
+ mouseover: 'mouseenter',
+ mouseout: 'mouseleave'
+}, function( orig, fix ){
+ jQuery.event.special[ fix ] = {
+ setup: function(){
+ jQuery.event.add( this, orig, withinElement, fix );
+ },
+ teardown: function(){
+ jQuery.event.remove( this, orig, withinElement );
+ }
+ };
+});
+
+jQuery.fn.extend({
+ bind: function( type, data, fn ) {
+ return type == "unload" ? this.one(type, data, fn) : this.each(function(){
+ jQuery.event.add( this, type, fn || data, fn && data );
+ });
+ },
+
+ one: function( type, data, fn ) {
+ var one = jQuery.event.proxy( fn || data, function(event) {
+ jQuery(this).unbind(event, one);
+ return (fn || data).apply( this, arguments );
+ });
+ return this.each(function(){
+ jQuery.event.add( this, type, one, fn && data);
+ });
+ },
+
+ unbind: function( type, fn ) {
+ return this.each(function(){
+ jQuery.event.remove( this, type, fn );
+ });
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function(){
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if( this[0] ){
+ var event = jQuery.Event(type);
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments, i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while( i < args.length )
+ jQuery.event.proxy( fn, args[i++] );
+
+ return this.click( jQuery.event.proxy( fn, function(event) {
+ // Figure out which function to execute
+ this.lastToggle = ( this.lastToggle || 0 ) % i;
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ this.lastToggle++ ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function(fnOver, fnOut) {
+ return this.mouseenter(fnOver).mouseleave(fnOut);
+ },
+
+ ready: function(fn) {
+ // Attach the listeners
+ bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady )
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ else
+ // Add the function to the wait list
+ jQuery.readyList.push( fn );
+
+ return this;
+ },
+
+ live: function( type, fn ){
+ var proxy = jQuery.event.proxy( fn );
+ proxy.guid += this.selector + type;
+
+ jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );
+
+ return this;
+ },
+
+ die: function( type, fn ){
+ jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
+ return this;
+ }
+});
+
+function liveHandler( event ){
+ var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
+ stop = true,
+ elems = [];
+
+ jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
+ if ( check.test(fn.type) ) {
+ var elem = jQuery(event.target).closest(fn.data)[0];
+ if ( elem )
+ elems.push({ elem: elem, fn: fn });
+ }
+ });
+
+ jQuery.each(elems, function(){
+ if ( this.fn.call(this.elem, event, this.fn.data) === false )
+ stop = false;
+ });
+
+ return stop;
+}
+
+function liveConvert(type, selector){
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join(".");
+}
+
+jQuery.extend({
+ isReady: false,
+ readyList: [],
+ // Handle when the DOM is ready
+ ready: function() {
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.isReady ) {
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If there are functions bound, to execute
+ if ( jQuery.readyList ) {
+ // Execute all of them
+ jQuery.each( jQuery.readyList, function(){
+ this.call( document, jQuery );
+ });
+
+ // Reset the list of functions
+ jQuery.readyList = null;
+ }
+
+ // Trigger any bound ready events
+ jQuery(document).triggerHandler("ready");
+ }
+ }
+});
+
+var readyBound = false;
+
+function bindReady(){
+ if ( readyBound ) return;
+ readyBound = true;
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", function(){
+ document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
+ jQuery.ready();
+ }, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", function(){
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", arguments.callee );
+ jQuery.ready();
+ }
+ });
+
+ // If IE and not an iframe
+ // continually check to see if the document is ready
+ if ( document.documentElement.doScroll && typeof window.frameElement === "undefined" ) (function(){
+ if ( jQuery.isReady ) return;
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch( error ) {
+ setTimeout( arguments.callee, 0 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+ })();
+ }
+
+ // A fallback to window.onload, that will always work
+ jQuery.event.add( window, "load", jQuery.ready );
+}
+
+jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
+ "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
+ "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
+
+ // Handle event binding
+ jQuery.fn[name] = function(fn){
+ return fn ? this.bind(name, fn) : this.trigger(name);
+ };
+});
+
+// Prevent memory leaks in IE
+// And prevent errors on refresh with events like mouseover in other browsers
+// Window isn't included so as not to unbind existing unload events
+jQuery( window ).bind( 'unload', function(){
+ for ( var id in jQuery.cache )
+ // Skip the window
+ if ( id != 1 && jQuery.cache[ id ].handle )
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+});
+(function(){
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + (new Date).getTime();
+
+ div.style.display = "none";
+ div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType == 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that you can get all elements in an <object> element
+ // IE 7 always returns no results
+ objectAll: !!div.getElementsByTagName("object")[0]
+ .getElementsByTagName("*").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ opacity: a.style.opacity === "0.5",
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Will be defined later
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null
+ };
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e){}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function(){
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", arguments.callee);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ jQuery(function(){
+ var div = document.createElement("div");
+ div.style.width = "1px";
+ div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+ document.body.removeChild( div );
+ });
+})();
+
+var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ "float": styleFloat,
+ cssFloat: styleFloat,
+ styleFloat: styleFloat,
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ tabindex: "tabIndex"
+};
+jQuery.fn.extend({
+ // Keep a copy of the old load
+ _load: jQuery.fn.load,
+
+ load: function( url, params, callback ) {
+ if ( typeof url !== "string" )
+ return this._load( url );
+
+ var off = url.indexOf(" ");
+ if ( off >= 0 ) {
+ var selector = url.slice(off, url.length);
+ url = url.slice(0, off);
+ }
+
+ // Default to a GET request
+ var type = "GET";
+
+ // If the second parameter was provided
+ if ( params )
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+ // We assume that it's the callback
+ callback = params;
+ params = null;
+
+ // Otherwise, build a param string
+ } else if( typeof params === "object" ) {
+ params = jQuery.param( params );
+ type = "POST";
+ }
+
+ var self = this;
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+ type: type,
+ dataType: "html",
+ data: params,
+ complete: function(res, status){
+ // 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 );
+
+ if( callback )
+ self.each( callback, [res.responseText, status, res] );
+ }
+ });
+ return this;
+ },
+
+ serialize: function() {
+ return jQuery.param(this.serializeArray());
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ return this.elements ? 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 :
+ jQuery.isArray(val) ?
+ 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 = now();
+
+jQuery.extend({
+
+ get: function( url, data, callback, type ) {
+ // shift arguments if data argument was ommited
+ if ( jQuery.isFunction( data ) ) {
+ callback = data;
+ data = null;
+ }
+
+ return jQuery.ajax({
+ type: "GET",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ 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;
+ data = {};
+ }
+
+ return jQuery.ajax({
+ type: "POST",
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ },
+
+ ajaxSetup: function( settings ) {
+ jQuery.extend( jQuery.ajaxSettings, settings );
+ },
+
+ ajaxSettings: {
+ url: location.href,
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ username: null,
+ password: null,
+ */
+ // Create the request object; Microsoft failed to properly
+ // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
+ // This function can be overriden by calling jQuery.ajaxSetup
+ xhr:function(){
+ return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
+ },
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ script: "text/javascript, application/javascript",
+ json: "application/json, text/javascript",
+ text: "text/plain",
+ _default: "*/*"
+ }
+ },
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+
+ ajax: function( s ) {
+ // 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));
+
+ var jsonp, jsre = /=\?(&|$)/g, status, data,
+ type = s.type.toUpperCase();
+
+ // 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 ( type == "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 + "$1");
+ s.url = s.url.replace(jsre, "=" + jsonp + "$1");
+
+ // 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 ( head )
+ head.removeChild( script );
+ };
+ }
+
+ if ( s.dataType == "script" && s.cache == null )
+ s.cache = false;
+
+ if ( s.cache === false && type == "GET" ) {
+ var ts = now();
+ // try replacing _= if it is there
+ var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2");
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : "");
+ }
+
+ // If data is available, append data to url for get requests
+ if ( s.data && type == "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" );
+
+ // Matches an absolute URL, and saves the domain
+ var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url );
+
+ // If we're requesting a remote document
+ // and trying to load JSON or Script with a GET
+ if ( s.dataType == "script" && type == "GET" && parts
+ && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){
+
+ var head = document.getElementsByTagName("head")[0];
+ var script = document.createElement("script");
+ script.src = s.url;
+ if (s.scriptCharset)
+ script.charset = s.scriptCharset;
+
+ // Handle Script loading
+ if ( !jsonp ) {
+ 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 undefined;
+ }
+
+ var requestDone = false;
+
+ // Create the request object
+ var xhr = s.xhr();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if( s.username )
+ xhr.open(type, s.url, s.async, s.username, s.password);
+ else
+ xhr.open(type, s.url, s.async);
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ // Set the correct header, if data is being sent
+ if ( s.data )
+ xhr.setRequestHeader("Content-Type", s.contentType);
+
+ // Set the If-Modified-Since header, if ifModified mode.
+ if ( s.ifModified )
+ xhr.setRequestHeader("If-Modified-Since",
+ jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
+
+ // Set header so the called script knows that it's an XMLHttpRequest
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+
+ // Set the Accepts header for the server, depending on the dataType
+ xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
+ s.accepts[ s.dataType ] + ", */*" :
+ s.accepts._default );
+ } catch(e){}
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && s.beforeSend(xhr, s) === false ) {
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ // close opended socket
+ xhr.abort();
+ return false;
+ }
+
+ if ( s.global )
+ jQuery.event.trigger("ajaxSend", [xhr, s]);
+
+ // Wait for a response to come back
+ var onreadystatechange = function(isTimeout){
+ // The request was aborted, clear the interval and decrement jQuery.active
+ if (xhr.readyState == 0) {
+ if (ival) {
+ // clear poll interval
+ clearInterval(ival);
+ ival = null;
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ // The transfer is complete and the data is available, or the request timed out
+ } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) {
+ requestDone = true;
+
+ // clear poll interval
+ if (ival) {
+ clearInterval(ival);
+ ival = null;
+ }
+
+ status = isTimeout == "timeout" ? "timeout" :
+ !jQuery.httpSuccess( xhr ) ? "error" :
+ s.ifModified && jQuery.httpNotModified( xhr, 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)
+ data = jQuery.httpData( xhr, s.dataType, s );
+ } catch(e) {
+ status = "parsererror";
+ }
+ }
+
+ // Make sure that the request was successful or notmodified
+ if ( status == "success" ) {
+ // Cache Last-Modified header, if ifModified mode.
+ var modRes;
+ try {
+ modRes = xhr.getResponseHeader("Last-Modified");
+ } catch(e) {} // swallow exception thrown by FF if header is not available
+
+ if ( s.ifModified && modRes )
+ jQuery.lastModified[s.url] = modRes;
+
+ // JSONP handles its own success callback
+ if ( !jsonp )
+ success();
+ } else
+ jQuery.handleError(s, xhr, status);
+
+ // Fire the complete handlers
+ complete();
+
+ if ( isTimeout )
+ xhr.abort();
+
+ // Stop memory leaks
+ if ( s.async )
+ xhr = null;
+ }
+ };
+
+ 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 ( xhr && !requestDone )
+ onreadystatechange( "timeout" );
+ }, s.timeout);
+ }
+
+ // Send the data
+ try {
+ xhr.send(s.data);
+ } catch(e) {
+ jQuery.handleError(s, xhr, null, e);
+ }
+
+ // firefox 1.5 doesn't fire statechange for sync requests
+ if ( !s.async )
+ onreadystatechange();
+
+ 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", [xhr, s] );
+ }
+
+ function complete(){
+ // Process result
+ if ( s.complete )
+ s.complete(xhr, status);
+
+ // The request was completed
+ if ( s.global )
+ jQuery.event.trigger( "ajaxComplete", [xhr, s] );
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+ }
+
+ // return XMLHttpRequest to allow aborting the request etc.
+ return xhr;
+ },
+
+ handleError: function( s, xhr, status, e ) {
+ // If a local callback was specified, fire it
+ if ( s.error ) s.error( xhr, status, e );
+
+ // Fire the global callback
+ if ( s.global )
+ jQuery.event.trigger( "ajaxError", [xhr, s, e] );
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Determines if an XMLHttpRequest was successful or not
+ httpSuccess: function( xhr ) {
+ try {
+ // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
+ return !xhr.status && location.protocol == "file:" ||
+ ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223;
+ } catch(e){}
+ return false;
+ },
+
+ // Determines if an XMLHttpRequest returns NotModified
+ httpNotModified: function( xhr, url ) {
+ try {
+ var xhrRes = xhr.getResponseHeader("Last-Modified");
+
+ // Firefox always returns 200. check Last-Modified date
+ return xhr.status == 304 || xhrRes == jQuery.lastModified[url];
+ } catch(e){}
+ return false;
+ },
+
+ httpData: function( xhr, type, s ) {
+ var ct = xhr.getResponseHeader("content-type"),
+ xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
+ data = xml ? xhr.responseXML : xhr.responseText;
+
+ if ( xml && data.documentElement.tagName == "parsererror" )
+ throw "parsererror";
+
+ // Allow a pre-filtering function to sanitize the response
+ // s != null is checked to keep backwards compatibility
+ if( s && s.dataFilter )
+ data = s.dataFilter( data, type );
+
+ // The filter can actually parse the response
+ if( typeof data === "string" ){
+
+ // If the type is "script", eval it in global context
+ if ( type == "script" )
+ jQuery.globalEval( data );
+
+ // Get the JavaScript object, if JSON is used.
+ if ( type == "json" )
+ data = window["eval"]("(" + data + ")");
+ }
+
+ return data;
+ },
+
+ // Serialize an array of form elements or a set of
+ // key/values into a query string
+ param: function( a ) {
+ var s = [ ];
+
+ function add( key, value ){
+ s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value);
+ };
+
+ // If an array was passed in, assume that it is an array
+ // of form elements
+ if ( jQuery.isArray(a) || a.jquery )
+ // Serialize the form elements
+ jQuery.each( a, function(){
+ add( this.name, this.value );
+ });
+
+ // Otherwise, assume that it's an object of key/value pairs
+ else
+ // Serialize the key/values
+ for ( var j in a )
+ // If the value is an array then the key names need to be repeated
+ if ( jQuery.isArray(a[j]) )
+ jQuery.each( a[j], function(){
+ add( j, this );
+ });
+ else
+ add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] );
+
+ // Return the resulting serialization
+ return s.join("&").replace(/%20/g, "+");
+ }
+
+});
+var elemdisplay = {},
+ timerId,
+ fxAttrs = [
+ // height animations
+ [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
+ // width animations
+ [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
+ // opacity animations
+ [ "opacity" ]
+ ];
+
+function genFx( type, num ){
+ var obj = {};
+ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){
+ obj[ this ] = type;
+ });
+ return obj;
+}
+
+jQuery.fn.extend({
+ show: function(speed,callback){
+ if ( speed ) {
+ return this.animate( genFx("show", 3), speed, callback);
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ){
+ var old = jQuery.data(this[i], "olddisplay");
+
+ this[i].style.display = old || "";
+
+ if ( jQuery.css(this[i], "display") === "none" ) {
+ var tagName = this[i].tagName, display;
+
+ if ( elemdisplay[ tagName ] ) {
+ display = elemdisplay[ tagName ];
+ } else {
+ var elem = jQuery("<" + tagName + " />").appendTo("body");
+
+ display = elem.css("display");
+ if ( display === "none" )
+ display = "block";
+
+ elem.remove();
+
+ elemdisplay[ tagName ] = display;
+ }
+
+ this[i].style.display = jQuery.data(this[i], "olddisplay", display);
+ }
+ }
+
+ return this;
+ }
+ },
+
+ hide: function(speed,callback){
+ if ( speed ) {
+ return this.animate( genFx("hide", 3), speed, callback);
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ){
+ var old = jQuery.data(this[i], "olddisplay");
+ if ( !old && old !== "none" )
+ jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
+ this[i].style.display = "none";
+ }
+ return this;
+ }
+ },
+
+ // Save the old toggle function
+ _toggle: jQuery.fn.toggle,
+
+ toggle: function( fn, fn2 ){
+ var bool = typeof fn === "boolean";
+
+ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
+ this._toggle.apply( this, arguments ) :
+ fn == null || bool ?
+ this.each(function(){
+ var state = bool ? fn : jQuery(this).is(":hidden");
+ jQuery(this)[ state ? "show" : "hide" ]();
+ }) :
+ this.animate(genFx("toggle", 3), fn, fn2);
+ },
+
+ fadeTo: function(speed,to,callback){
+ return this.animate({opacity: to}, speed, callback);
+ },
+
+ animate: function( prop, speed, easing, callback ) {
+ var optall = jQuery.speed(speed, easing, callback);
+
+ return this[ optall.queue === false ? "each" : "queue" ](function(){
+
+ var opt = jQuery.extend({}, optall), p,
+ hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
+ self = this;
+
+ for ( p in prop ) {
+ if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+ return opt.complete.call(this);
+
+ if ( ( p == "height" || p == "width" ) && this.style ) {
+ // Store display property
+ opt.display = jQuery.css(this, "display");
+
+ // Make sure that nothing sneaks out
+ opt.overflow = this.style.overflow;
+ }
+ }
+
+ if ( opt.overflow != null )
+ this.style.overflow = "hidden";
+
+ opt.curAnim = jQuery.extend({}, prop);
+
+ jQuery.each( prop, function(name, val){
+ var e = new jQuery.fx( self, opt, name );
+
+ 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;
+ });
+ },
+
+ stop: function(clearQueue, gotoEnd){
+ var timers = jQuery.timers;
+
+ if (clearQueue)
+ this.queue([]);
+
+ this.each(function(){
+ // go in reverse order so anything added to the queue during the loop is ignored
+ for ( var i = timers.length - 1; i >= 0; i-- )
+ if ( timers[i].elem == this ) {
+ if (gotoEnd)
+ // force the next step to be the last
+ timers[i](true);
+ timers.splice(i, 1);
+ }
+ });
+
+ // start the next in the queue if the last step wasn't forced
+ if (!gotoEnd)
+ this.dequeue();
+
+ return this;
+ }
+
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show", 1),
+ slideUp: genFx("hide", 1),
+ slideToggle: genFx("toggle", 1),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+}, function( name, props ){
+ jQuery.fn[ name ] = function( speed, callback ){
+ return this.animate( props, speed, callback );
+ };
+});
+
+jQuery.extend({
+
+ speed: function(speed, easing, fn) {
+ var opt = typeof speed === "object" ? speed : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
+
+ // Queueing
+ opt.old = opt.complete;
+ opt.complete = function(){
+ if ( opt.queue !== false )
+ jQuery(this).dequeue();
+ if ( jQuery.isFunction( opt.old ) )
+ opt.old.call( this );
+ };
+
+ return opt;
+ },
+
+ easing: {
+ linear: function( p, n, firstNum, diff ) {
+ return firstNum + diff * p;
+ },
+ swing: function( p, n, firstNum, diff ) {
+ return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
+ }
+ },
+
+ timers: [],
+
+ fx: function( elem, options, prop ){
+ this.options = options;
+ this.elem = elem;
+ this.prop = prop;
+
+ if ( !options.orig )
+ options.orig = {};
+ }
+
+});
+
+jQuery.fx.prototype = {
+
+ // Simple function for setting a style value
+ update: function(){
+ if ( this.options.step )
+ this.options.step.call( this.elem, this.now, this );
+
+ (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
+
+ // Set display property to block for height/width animations
+ if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style )
+ this.elem.style.display = "block";
+ },
+
+ // Get the current size
+ cur: function(force){
+ if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) )
+ return this.elem[ this.prop ];
+
+ var r = parseFloat(jQuery.css(this.elem, this.prop, force));
+ return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
+ },
+
+ // Start an animation from one number to another
+ custom: function(from, to, unit){
+ this.startTime = now();
+ this.start = from;
+ this.end = to;
+ this.unit = unit || this.unit || "px";
+ this.now = this.start;
+ this.pos = this.state = 0;
+
+ var self = this;
+ function t(gotoEnd){
+ return self.step(gotoEnd);
+ }
+
+ t.elem = this.elem;
+
+ if ( t() && jQuery.timers.push(t) == 1 ) {
+ timerId = setInterval(function(){
+ var timers = jQuery.timers;
+
+ for ( var i = 0; i < timers.length; i++ )
+ if ( !timers[i]() )
+ timers.splice(i--, 1);
+
+ if ( !timers.length ) {
+ clearInterval( timerId );
+ }
+ }, 13);
+ }
+ },
+
+ // 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;
+
+ // Begin the animation
+ // Make sure that we start at a small width/height to avoid any
+ // flash of content
+ this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur());
+
+ // Start by showing the element
+ jQuery(this.elem).show();
+ },
+
+ // 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;
+
+ // Begin the animation
+ this.custom(this.cur(), 0);
+ },
+
+ // Each step of an animation
+ step: function(gotoEnd){
+ var t = now();
+
+ if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ this.now = this.end;
+ this.pos = this.state = 1;
+ this.update();
+
+ this.options.curAnim[ this.prop ] = true;
+
+ var done = true;
+ for ( var i in this.options.curAnim )
+ if ( this.options.curAnim[i] !== true )
+ done = false;
+
+ 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";
+ }
+
+ // Hide the element if the "hide" operation was done
+ if ( this.options.hide )
+ jQuery(this.elem).hide();
+
+ // 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]);
+
+ // Execute the complete function
+ this.options.complete.call( 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.extend( jQuery.fx, {
+ speeds:{
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+ },
+ step: {
+
+ opacity: function(fx){
+ jQuery.attr(fx.elem.style, "opacity", fx.now);
+ },
+
+ _default: function(fx){
+ if ( fx.elem.style && fx.elem.style[ fx.prop ] != null )
+ fx.elem.style[ fx.prop ] = fx.now + fx.unit;
+ else
+ fx.elem[ fx.prop ] = fx.now;
+ }
+ }
+});
+if ( document.documentElement["getBoundingClientRect"] )
+ jQuery.fn.offset = function() {
+ if ( !this[0] ) return { top: 0, left: 0 };
+ if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
+ var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement,
+ clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
+ top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
+ left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
+ return { top: top, left: left };
+ };
+else
+ jQuery.fn.offset = function() {
+ if ( !this[0] ) return { top: 0, left: 0 };
+ if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
+ jQuery.offset.initialized || jQuery.offset.initialize();
+
+ var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem,
+ doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
+ body = doc.body, defaultView = doc.defaultView,
+ prevComputedStyle = defaultView.getComputedStyle(elem, null),
+ top = elem.offsetTop, left = elem.offsetLeft;
+
+ while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
+ computedStyle = defaultView.getComputedStyle(elem, null);
+ top -= elem.scrollTop, left -= elem.scrollLeft;
+ if ( elem === offsetParent ) {
+ top += elem.offsetTop, left += elem.offsetLeft;
+ if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) )
+ top += parseInt( computedStyle.borderTopWidth, 10) || 0,
+ left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
+ prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
+ }
+ if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" )
+ top += parseInt( computedStyle.borderTopWidth, 10) || 0,
+ left += parseInt( computedStyle.borderLeftWidth, 10) || 0;
+ prevComputedStyle = computedStyle;
+ }
+
+ if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" )
+ top += body.offsetTop,
+ left += body.offsetLeft;
+
+ if ( prevComputedStyle.position === "fixed" )
+ top += Math.max(docElem.scrollTop, body.scrollTop),
+ left += Math.max(docElem.scrollLeft, body.scrollLeft);
+
+ return { top: top, left: left };
+ };
+
+jQuery.offset = {
+ initialize: function() {
+ if ( this.initialized ) return;
+ var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop,
+ html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';
+
+ rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' };
+ for ( prop in rules ) container.style[prop] = rules[prop];
+
+ container.innerHTML = html;
+ body.insertBefore(container, body.firstChild);
+ innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild;
+
+ this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
+ this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
+
+ innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
+ this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
+
+ body.style.marginTop = '1px';
+ this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0);
+ body.style.marginTop = bodyMarginTop;
+
+ body.removeChild(container);
+ this.initialized = true;
+ },
+
+ bodyOffset: function(body) {
+ jQuery.offset.initialized || jQuery.offset.initialize();
+ var top = body.offsetTop, left = body.offsetLeft;
+ if ( jQuery.offset.doesNotIncludeMarginInBodyOffset )
+ top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0,
+ left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;
+ return { top: top, left: left };
+ }
+};
+
+
+jQuery.fn.extend({
+ position: function() {
+ var left = 0, top = 0, results;
+
+ if ( this[0] ) {
+ // Get *real* offsetParent
+ var offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= num( this, 'marginTop' );
+ offset.left -= num( this, 'marginLeft' );
+
+ // Add offsetParent borders
+ parentOffset.top += num( offsetParent, 'borderTopWidth' );
+ parentOffset.left += num( offsetParent, 'borderLeftWidth' );
+
+ // Subtract the two offsets
+ results = {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ }
+
+ return results;
+ },
+
+ offsetParent: function() {
+ var offsetParent = this[0].offsetParent || document.body;
+ while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
+ offsetParent = offsetParent.offsetParent;
+ return jQuery(offsetParent);
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( ['Left', 'Top'], function(i, name) {
+ var method = 'scroll' + name;
+
+ jQuery.fn[ method ] = function(val) {
+ if (!this[0]) return null;
+
+ return val !== undefined ?
+
+ // Set the scroll offset
+ this.each(function() {
+ this == window || this == document ?
+ window.scrollTo(
+ !i ? val : jQuery(window).scrollLeft(),
+ i ? val : jQuery(window).scrollTop()
+ ) :
+ this[ method ] = val;
+ }) :
+
+ // Return the scroll offset
+ this[0] == window || this[0] == document ?
+ self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
+ jQuery.boxModel && document.documentElement[ method ] ||
+ document.body[ method ] :
+ this[0][ method ];
+ };
+});
+// Create innerHeight, innerWidth, outerHeight and outerWidth methods
+jQuery.each([ "Height", "Width" ], function(i, name){
+
+ var tl = i ? "Left" : "Top", // top or left
+ br = i ? "Right" : "Bottom"; // bottom or right
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function(){
+ return this[ name.toLowerCase() ]() +
+ num(this, "padding" + tl) +
+ num(this, "padding" + br);
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function(margin) {
+ return this["inner" + name]() +
+ num(this, "border" + tl + "Width") +
+ num(this, "border" + br + "Width") +
+ (margin ?
+ num(this, "margin" + tl) + num(this, "margin" + br) : 0);
+ };
+
+ var type = name.toLowerCase();
+
+ jQuery.fn[ type ] = function( size ) {
+ // Get window width or height
+ return this[0] == window ?
+ // 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
+ Math.max(
+ document.documentElement["client" + name],
+ document.body["scroll" + name], document.documentElement["scroll" + name],
+ document.body["offset" + name], document.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ (this.length ? jQuery.css( this[0], type ) : null) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css( type, typeof size === "string" ? size : size + "px" );
+ };
+
+});})();
15 years, 11 months
JBoss Rich Faces SVN: r12376 - trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2009-01-22 11:11:58 -0500 (Thu, 22 Jan 2009)
New Revision: 12376
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
https://jira.jboss.org/jira/browse/RF-5766
Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-01-22 15:32:51 UTC (rev 12375)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2009-01-22 16:11:58 UTC (rev 12376)
@@ -1907,10 +1907,11 @@
var isDateChange = false;
if ( (oldSelectedDate - newSelectedDate) && (oldSelectedDate!=null || newSelectedDate!=null) )
{
- isDateChange = this.invokeEvent("dateselect", eventData.element, eventData.event, date);
+ isDateChange = true;
+ flag = this.invokeEvent("dateselect", eventData.element, eventData.event, date);
}
- if (isDateChange)
+ if (flag)
{
if (newSelectedDate!=null)
{
15 years, 11 months
JBoss Rich Faces SVN: r12375 - in trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd: generator and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-01-22 10:32:51 -0500 (Thu, 22 Jan 2009)
New Revision: 12375
Modified:
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
Log:
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java 2009-01-22 15:23:51 UTC (rev 12374)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/Components.java 2009-01-22 15:32:51 UTC (rev 12375)
@@ -29,8 +29,6 @@
return this.components;
}
-
-
@Override
public int hashCode() {
final int prime = 31;
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-01-22 15:23:51 UTC (rev 12374)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ResourcesGenerator.java 2009-01-22 15:32:51 UTC (rev 12375)
@@ -93,7 +93,6 @@
return assemblyFile;
}
-
public void setAssemblyFile(File assemblyFile) {
this.assemblyFile = assemblyFile;
}
@@ -102,37 +101,30 @@
return resources;
}
-
public void setResources(Collection<String> resources) {
this.resources = resources;
}
-
public List<String> getIncludesBefore() {
return includesBefore;
}
-
public void setIncludesBefore(List<String> includesBefore) {
this.includesBefore = includesBefore;
}
-
public List<String> getIncludesAfter() {
return includesAfter;
}
-
public void setIncludesAfter(List<String> includesAfter) {
this.includesAfter = includesAfter;
}
-
public ResourceAssembler getAssembler() {
return assembler;
}
-
public void setAssembler(ResourceAssembler assembler) {
this.assembler = assembler;
}
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java 2009-01-22 15:23:51 UTC (rev 12374)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/ScriptAssembler.java 2009-01-22 15:32:51 UTC (rev 12375)
@@ -38,13 +38,10 @@
Log log = new SystemStreamLog();
- private StringBuilder builder;
+ private StringBuilder builder = new StringBuilder();
public void assembly(URL resource) {
log.info("process resource : " + resource.getFile());
- if (builder == null) {
- builder = new StringBuilder();
- }
try {
builder.append(IOUtil.toString(resource.openStream()));
} catch (IOException e) {
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-01-22 15:23:51 UTC (rev 12374)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-01-22 15:32:51 UTC (rev 12375)
@@ -31,29 +31,31 @@
private StringBuilder builder = new StringBuilder();
+
public void assembly(URL resource) {
String file = resource.getFile();
log.info("process resource: " + file);
-
try {
InputStream resourceInputStream = resource.openStream();
- if(file.endsWith(".xcss")) {
- XMLBody xmlBody = new XMLBody();
- try {
- xmlBody.loadXML(resourceInputStream,true);
- builder.append(xmlBody.getContent());
- } catch (ParsingException e) {
- log.error("Error processing xcss: " + e.getMessage(), e);
- } finally {
- resourceInputStream.close();
+ try {
+ if(file.endsWith(".xcss")) {
+ XMLBody xmlBody = new XMLBody();
+ try {
+ xmlBody.loadXML(resourceInputStream,true);
+ builder.append(xmlBody.getContent());
+ } catch (ParsingException e) {
+ log.error("Error processing xcss: " + e.getMessage(), e);
+ }
+ } else {
+ builder.append(IOUtil.toString(resourceInputStream));
}
- } else {
- builder.append(IOUtil.toString(resourceInputStream));
+ } finally {
+ resourceInputStream.close();
}
} catch (IOException e) {
- log.error("Error load xcss file " + resource.getFile() + " : " + e.getMessage(), e);
+ log.error("Error process css file " + file + " : " + e.getMessage(), e);
}
}
Modified: trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java
===================================================================
--- trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-01-22 15:23:51 UTC (rev 12374)
+++ trunk/sandbox/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/mojo/ResourceDependencyMojo.java 2009-01-22 15:32:51 UTC (rev 12375)
@@ -12,7 +12,6 @@
import javax.xml.parsers.SAXParserFactory;
import org.ajax4jsf.builder.mojo.Library;
-import org.ajax4jsf.builder.xml.XMLBodyMerge;
import org.apache.commons.digester.Digester;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
@@ -138,13 +137,13 @@
* beforeIncludes
* @parameter
*/
- private List beforeStylesIncludes;
+ private List beforeStyleIncludes;
/**
* afterIncludes
* @parameter
*/
- private List afterStylesIncludes;
+ private List afterStyleIncludes;
/**
*
@@ -185,11 +184,10 @@
Set <String> styles = handler.getStyles();
if(!styles.isEmpty()) {
- XMLBodyMerge xmlBodyMerge = new XMLBodyMerge(null);
File assemblyFile = new File(outputStyleDirectory, stylePackName + ".xcss");
StyleAssembler styleAssembler = new StyleAssembler();
styleAssembler.setVelocityComponent(velocity);
- mergeResources(assemblyFile, styleAssembler, beforeStylesIncludes, afterStylesIncludes, styles);
+ mergeResources(assemblyFile, styleAssembler, beforeStyleIncludes, afterStyleIncludes, styles);
}
}
Thread.currentThread().setContextClassLoader(oldClassLoader);
15 years, 11 months
JBoss Rich Faces SVN: r12374 - trunk/sandbox/samples/maven-rd-plugin-sample.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-01-22 10:23:51 -0500 (Thu, 22 Jan 2009)
New Revision: 12374
Modified:
trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml
Log:
Modified: trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml
===================================================================
--- trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml 2009-01-22 15:23:27 UTC (rev 12373)
+++ trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml 2009-01-22 15:23:51 UTC (rev 12374)
@@ -38,6 +38,15 @@
<afterScriptIncludes>
<afterScriptInclude>org/test/scripts/after.js</afterScriptInclude>
</afterScriptIncludes>
+ <outputStyleDirectory>
+ ${basedir}/src/main/webapp/styles
+ </outputStyleDirectory>
+ <beforeStyleIncludes>
+ <beforeStyleInclude>org/test/styles/before.css</beforeStyleInclude>
+ </beforeStyleIncludes>
+ <afterStyleIncludes>
+ <afterStyleInclude>org/test/styles/after.css</afterStyleInclude>
+ </afterStyleIncludes>
</configuration>
<executions>
<execution>
15 years, 11 months
JBoss Rich Faces SVN: r12371 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-22 10:17:48 -0500 (Thu, 22 Jan 2009)
New Revision: 12371
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenuItem/panelMenuItemAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5795
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenuItem/panelMenuItemAutoTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java 2009-01-22 14:29:06 UTC (rev 12370)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuItemTest.java 2009-01-22 15:17:48 UTC (rev 12371)
@@ -50,6 +50,14 @@
tester.testOncomplete();
}
+ @Test
+ public void testLimitToListAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, null);
+ writeStatus("Test component with limitToList = true skips ajaxRendered areas update");
+ tester.testLimitToList();
+ }
+
@Override
public void sendAjax() {
clickAjaxCommandAndWait("icon" + getAutoTester(this).getClientId("") + "item");
@@ -64,4 +72,5 @@
public String getTestUrl() {
return null;
}
+
}
15 years, 11 months
JBoss Rich Faces SVN: r12370 - trunk/sandbox/samples/maven-rd-plugin-sample.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-01-22 09:29:06 -0500 (Thu, 22 Jan 2009)
New Revision: 12370
Modified:
trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml
Log:
Modified: trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml
===================================================================
--- trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml 2009-01-22 14:28:38 UTC (rev 12369)
+++ trunk/sandbox/samples/maven-rd-plugin-sample/pom.xml 2009-01-22 14:29:06 UTC (rev 12370)
@@ -28,23 +28,22 @@
<namespaces>
<namespace>http://richfaces.org/rich</namespace>
<namespace>http://richfaces.org/a4j</namespace>
- </namespaces>
- <outputScriptDirectory>
- ${basedir}/src/main/webapp/scripts
- </outputScriptDirectory>
- <beforeIncludes>
- <beforeInclude>org/test/scripts/before.js</beforeInclude>
- </beforeIncludes>
- <afterIncludes>
- <afterInclude>org/test/scripts/after.js</afterInclude>
- </afterIncludes>
+ </namespaces>
+ <outputScriptDirectory>
+ ${basedir}/src/main/webapp/scripts
+ </outputScriptDirectory>
+ <beforeScriptIncludes>
+ <beforeScriptInclude>org/test/scripts/before.js</beforeScriptInclude>
+ </beforeScriptIncludes>
+ <afterScriptIncludes>
+ <afterScriptInclude>org/test/scripts/after.js</afterScriptInclude>
+ </afterScriptIncludes>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
- <goal>assemblyScripts</goal>
- <goal>assemblyStyles</goal>
+ <goal>assemblyResources</goal>
</goals>
</execution>
</executions>
15 years, 11 months
JBoss Rich Faces SVN: r12369 - trunk/sandbox/samples/maven-rd-plugin-sample/src/main/webapp/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-01-22 09:28:38 -0500 (Thu, 22 Jan 2009)
New Revision: 12369
Removed:
trunk/sandbox/samples/maven-rd-plugin-sample/src/main/webapp/scripts/custom-dependencies.js
Log:
Deleted: trunk/sandbox/samples/maven-rd-plugin-sample/src/main/webapp/scripts/custom-dependencies.js
===================================================================
--- trunk/sandbox/samples/maven-rd-plugin-sample/src/main/webapp/scripts/custom-dependencies.js 2009-01-22 14:26:55 UTC (rev 12368)
+++ trunk/sandbox/samples/maven-rd-plugin-sample/src/main/webapp/scripts/custom-dependencies.js 2009-01-22 14:28:38 UTC (rev 12369)
@@ -1,10121 +0,0 @@
-//=========================== before =====================
-/* Prototype JavaScript framework, version 1.6.0.3
- * (c) 2005-2008 Sam Stephenson
- *
- * Prototype is freely distributable under the terms of an MIT-style license.
- * For details, see the Prototype web site: http://www.prototypejs.org/
- *
- *--------------------------------------------------------------------------*/
-
-var Prototype = {
- Version: '1.6.0.3',
-
- Browser: {
- IE: !!(window.attachEvent &&
- navigator.userAgent.indexOf('Opera') === -1),
- Opera: navigator.userAgent.indexOf('Opera') > -1,
- WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
- Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
- navigator.userAgent.indexOf('KHTML') === -1,
- MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
- },
-
- BrowserFeatures: {
- XPath: !!document.evaluate,
- SelectorsAPI: !!document.querySelector,
- ElementExtensions: !!window.HTMLElement,
- SpecificElementExtensions:
- document.createElement('div')['__proto__'] &&
- document.createElement('div')['__proto__'] !==
- document.createElement('form')['__proto__']
- },
-
- ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
- JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
-
- emptyFunction: function() { },
- K: function(x) { return x }
-};
-
-if (Prototype.Browser.MobileSafari)
- Prototype.BrowserFeatures.SpecificElementExtensions = false;
-
-
-/* Based on Alex Arnell's inheritance implementation. */
-var Class = {
- create: function() {
- var parent = null, properties = $A(arguments);
- if (Object.isFunction(properties[0]))
- parent = properties.shift();
-
- function klass() {
- this.initialize.apply(this, arguments);
- }
-
- Object.extend(klass, Class.Methods);
- klass.superclass = parent;
- klass.subclasses = [];
-
- if (parent) {
- var subclass = function() { };
- subclass.prototype = parent.prototype;
- klass.prototype = new subclass;
- parent.subclasses.push(klass);
- }
-
- for (var i = 0; i < properties.length; i++)
- klass.addMethods(properties[i]);
-
- if (!klass.prototype.initialize)
- klass.prototype.initialize = Prototype.emptyFunction;
-
- klass.prototype.constructor = klass;
-
- return klass;
- }
-};
-
-Class.Methods = {
- addMethods: function(source) {
- var ancestor = this.superclass && this.superclass.prototype;
- var properties = Object.keys(source);
-
- if (!Object.keys({ toString: true }).length)
- properties.push("toString", "valueOf");
-
- for (var i = 0, length = properties.length; i < length; i++) {
- var property = properties[i], value = source[property];
- if (ancestor && Object.isFunction(value) &&
- value.argumentNames().first() == "$super") {
- var method = value;
- value = (function(m) {
- return function() { return ancestor[m].apply(this, arguments) };
- })(property).wrap(method);
-
- value.valueOf = method.valueOf.bind(method);
- value.toString = method.toString.bind(method);
- }
- this.prototype[property] = value;
- }
-
- return this;
- }
-};
-
-var Abstract = { };
-
-Object.extend = function(destination, source) {
- for (var property in source)
- destination[property] = source[property];
- return destination;
-};
-
-Object.extend(Object, {
- inspect: function(object) {
- try {
- if (Object.isUndefined(object)) return 'undefined';
- if (object === null) return 'null';
- return object.inspect ? object.inspect() : String(object);
- } catch (e) {
- if (e instanceof RangeError) return '...';
- throw e;
- }
- },
-
- toJSON: function(object) {
- var type = typeof object;
- switch (type) {
- case 'undefined':
- case 'function':
- case 'unknown': return;
- case 'boolean': return object.toString();
- }
-
- if (object === null) return 'null';
- if (object.toJSON) return object.toJSON();
- if (Object.isElement(object)) return;
-
- var results = [];
- for (var property in object) {
- var value = Object.toJSON(object[property]);
- if (!Object.isUndefined(value))
- results.push(property.toJSON() + ': ' + value);
- }
-
- return '{' + results.join(', ') + '}';
- },
-
- toQueryString: function(object) {
- return $H(object).toQueryString();
- },
-
- toHTML: function(object) {
- return object && object.toHTML ? object.toHTML() : String.interpret(object);
- },
-
- keys: function(object) {
- var keys = [];
- for (var property in object)
- keys.push(property);
- return keys;
- },
-
- values: function(object) {
- var values = [];
- for (var property in object)
- values.push(object[property]);
- return values;
- },
-
- clone: function(object) {
- return Object.extend({ }, object);
- },
-
- isElement: function(object) {
- return !!(object && object.nodeType == 1);
- },
-
- isArray: function(object) {
- return object != null && typeof object == "object" &&
- 'splice' in object && 'join' in object;
- },
-
- isHash: function(object) {
- return object instanceof Hash;
- },
-
- isFunction: function(object) {
- return typeof object == "function";
- },
-
- isString: function(object) {
- return typeof object == "string";
- },
-
- isNumber: function(object) {
- return typeof object == "number";
- },
-
- isUndefined: function(object) {
- return typeof object == "undefined";
- }
-});
-
-Object.extend(Function.prototype, {
- argumentNames: function() {
- var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
- .replace(/\s+/g, '').split(',');
- return names.length == 1 && !names[0] ? [] : names;
- },
-
- bind: function() {
- if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
- var __method = this, args = $A(arguments), object = args.shift();
- return function() {
- return __method.apply(object, args.concat($A(arguments)));
- }
- },
-
- bindAsEventListener: function() {
- var __method = this, args = $A(arguments), object = args.shift();
- return function(event) {
- return __method.apply(object, [event || window.event].concat(args));
- }
- },
-
- curry: function() {
- if (!arguments.length) return this;
- var __method = this, args = $A(arguments);
- return function() {
- return __method.apply(this, args.concat($A(arguments)));
- }
- },
-
- delay: function() {
- var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
- return window.setTimeout(function() {
- return __method.apply(__method, args);
- }, timeout);
- },
-
- defer: function() {
- var args = [0.01].concat($A(arguments));
- return this.delay.apply(this, args);
- },
-
- wrap: function(wrapper) {
- var __method = this;
- return function() {
- return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
- }
- },
-
- methodize: function() {
- if (this._methodized) return this._methodized;
- var __method = this;
- return this._methodized = function() {
- return __method.apply(null, [this].concat($A(arguments)));
- };
- }
-});
-
-Date.prototype.toJSON = function() {
- return '"' + this.getUTCFullYear() + '-' +
- (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
- this.getUTCDate().toPaddedString(2) + 'T' +
- this.getUTCHours().toPaddedString(2) + ':' +
- this.getUTCMinutes().toPaddedString(2) + ':' +
- this.getUTCSeconds().toPaddedString(2) + 'Z"';
-};
-
-var Try = {
- these: function() {
- var returnValue;
-
- for (var i = 0, length = arguments.length; i < length; i++) {
- var lambda = arguments[i];
- try {
- returnValue = lambda();
- break;
- } catch (e) { }
- }
-
- return returnValue;
- }
-};
-
-RegExp.prototype.match = RegExp.prototype.test;
-
-RegExp.escape = function(str) {
- return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
-};
-
-/*--------------------------------------------------------------------------*/
-
-var PeriodicalExecuter = Class.create({
- initialize: function(callback, frequency) {
- this.callback = callback;
- this.frequency = frequency;
- this.currentlyExecuting = false;
-
- this.registerCallback();
- },
-
- registerCallback: function() {
- this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
- },
-
- execute: function() {
- this.callback(this);
- },
-
- stop: function() {
- if (!this.timer) return;
- clearInterval(this.timer);
- this.timer = null;
- },
-
- onTimerEvent: function() {
- if (!this.currentlyExecuting) {
- try {
- this.currentlyExecuting = true;
- this.execute();
- } finally {
- this.currentlyExecuting = false;
- }
- }
- }
-});
-Object.extend(String, {
- interpret: function(value) {
- return value == null ? '' : String(value);
- },
- specialChar: {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '\\': '\\\\'
- }
-});
-
-Object.extend(String.prototype, {
- gsub: function(pattern, replacement) {
- var result = '', source = this, match;
- replacement = arguments.callee.prepareReplacement(replacement);
-
- while (source.length > 0) {
- if (match = source.match(pattern)) {
- result += source.slice(0, match.index);
- result += String.interpret(replacement(match));
- source = source.slice(match.index + match[0].length);
- } else {
- result += source, source = '';
- }
- }
- return result;
- },
-
- sub: function(pattern, replacement, count) {
- replacement = this.gsub.prepareReplacement(replacement);
- count = Object.isUndefined(count) ? 1 : count;
-
- return this.gsub(pattern, function(match) {
- if (--count < 0) return match[0];
- return replacement(match);
- });
- },
-
- scan: function(pattern, iterator) {
- this.gsub(pattern, iterator);
- return String(this);
- },
-
- truncate: function(length, truncation) {
- length = length || 30;
- truncation = Object.isUndefined(truncation) ? '...' : truncation;
- return this.length > length ?
- this.slice(0, length - truncation.length) + truncation : String(this);
- },
-
- strip: function() {
- return this.replace(/^\s+/, '').replace(/\s+$/, '');
- },
-
- stripTags: function() {
- return this.replace(/<\/?[^>]+>/gi, '');
- },
-
- stripScripts: function() {
- return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
- },
-
- extractScripts: function() {
- var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
- var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
- return (this.match(matchAll) || []).map(function(scriptTag) {
- var result = (scriptTag.match(matchOne) || ['', ''])[1];
- result = result.replace(/</,"<").replace(/\s*<!--[^\r\n]*/, "");
- return result;
- });
- },
-
- evalScripts: function() {
- return this.extractScripts().map(function(script) { return eval(script) });
- },
-
- escapeHTML: function() {
- var self = arguments.callee;
- self.text.data = this;
- return self.div.innerHTML;
- },
-
- unescapeHTML: function() {
- var div = new Element('div');
- div.innerHTML = this.stripTags();
- return div.childNodes[0] ? (div.childNodes.length > 1 ?
- $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
- div.childNodes[0].nodeValue) : '';
- },
-
- toQueryParams: function(separator) {
- var match = this.strip().match(/([^?#]*)(#.*)?$/);
- if (!match) return { };
-
- return match[1].split(separator || '&').inject({ }, function(hash, pair) {
- if ((pair = pair.split('='))[0]) {
- var key = decodeURIComponent(pair.shift());
- var value = pair.length > 1 ? pair.join('=') : pair[0];
- if (value != undefined) value = decodeURIComponent(value);
-
- if (key in hash) {
- if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
- hash[key].push(value);
- }
- else hash[key] = value;
- }
- return hash;
- });
- },
-
- toArray: function() {
- return this.split('');
- },
-
- succ: function() {
- return this.slice(0, this.length - 1) +
- String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
- },
-
- times: function(count) {
- return count < 1 ? '' : new Array(count + 1).join(this);
- },
-
- camelize: function() {
- var parts = this.split('-'), len = parts.length;
- if (len == 1) return parts[0];
-
- var camelized = this.charAt(0) == '-'
- ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
- : parts[0];
-
- for (var i = 1; i < len; i++)
- camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
-
- return camelized;
- },
-
- capitalize: function() {
- return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
- },
-
- underscore: function() {
- return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
- },
-
- dasherize: function() {
- return this.gsub(/_/,'-');
- },
-
- inspect: function(useDoubleQuotes) {
- var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
- var character = String.specialChar[match[0]];
- return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
- });
- if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
- return "'" + escapedString.replace(/'/g, '\\\'') + "'";
- },
-
- toJSON: function() {
- return this.inspect(true);
- },
-
- unfilterJSON: function(filter) {
- return this.sub(filter || Prototype.JSONFilter, '#{1}');
- },
-
- isJSON: function() {
- var str = this;
- if (str.blank()) return false;
- str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
- return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
- },
-
- evalJSON: function(sanitize) {
- var json = this.unfilterJSON();
- try {
- if (!sanitize || json.isJSON()) return eval('(' + json + ')');
- } catch (e) { }
- throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
- },
-
- include: function(pattern) {
- return this.indexOf(pattern) > -1;
- },
-
- startsWith: function(pattern) {
- return this.indexOf(pattern) === 0;
- },
-
- endsWith: function(pattern) {
- var d = this.length - pattern.length;
- return d >= 0 && this.lastIndexOf(pattern) === d;
- },
-
- empty: function() {
- return this == '';
- },
-
- blank: function() {
- return /^\s*$/.test(this);
- },
-
- interpolate: function(object, pattern) {
- return new Template(this, pattern).evaluate(object);
- }
-});
-
-if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
- escapeHTML: function() {
- return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- },
- unescapeHTML: function() {
- return this.stripTags().replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- }
-});
-
-String.prototype.gsub.prepareReplacement = function(replacement) {
- if (Object.isFunction(replacement)) return replacement;
- var template = new Template(replacement);
- return function(match) { return template.evaluate(match) };
-};
-
-String.prototype.parseQuery = String.prototype.toQueryParams;
-
-Object.extend(String.prototype.escapeHTML, {
- div: document.createElement('div'),
- text: document.createTextNode('')
-});
-
-String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);
-
-var Template = Class.create({
- initialize: function(template, pattern) {
- this.template = template.toString();
- this.pattern = pattern || Template.Pattern;
- },
-
- evaluate: function(object) {
- if (Object.isFunction(object.toTemplateReplacements))
- object = object.toTemplateReplacements();
-
- return this.template.gsub(this.pattern, function(match) {
- if (object == null) return '';
-
- var before = match[1] || '';
- if (before == '\\') return match[2];
-
- var ctx = object, expr = match[3];
- var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
- match = pattern.exec(expr);
- if (match == null) return before;
-
- while (match != null) {
- var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
- ctx = ctx[comp];
- if (null == ctx || '' == match[3]) break;
- expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
- match = pattern.exec(expr);
- }
-
- return before + String.interpret(ctx);
- });
- }
-});
-Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
-
-var $break = { };
-
-var Enumerable = {
- each: function(iterator, context) {
- var index = 0;
- try {
- this._each(function(value) {
- iterator.call(context, value, index++);
- });
- } catch (e) {
- if (e != $break) throw e;
- }
- return this;
- },
-
- eachSlice: function(number, iterator, context) {
- var index = -number, slices = [], array = this.toArray();
- if (number < 1) return array;
- while ((index += number) < array.length)
- slices.push(array.slice(index, index+number));
- return slices.collect(iterator, context);
- },
-
- all: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var result = true;
- this.each(function(value, index) {
- result = result && !!iterator.call(context, value, index);
- if (!result) throw $break;
- });
- return result;
- },
-
- any: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var result = false;
- this.each(function(value, index) {
- if (result = !!iterator.call(context, value, index))
- throw $break;
- });
- return result;
- },
-
- collect: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var results = [];
- this.each(function(value, index) {
- results.push(iterator.call(context, value, index));
- });
- return results;
- },
-
- detect: function(iterator, context) {
- var result;
- this.each(function(value, index) {
- if (iterator.call(context, value, index)) {
- result = value;
- throw $break;
- }
- });
- return result;
- },
-
- findAll: function(iterator, context) {
- var results = [];
- this.each(function(value, index) {
- if (iterator.call(context, value, index))
- results.push(value);
- });
- return results;
- },
-
- grep: function(filter, iterator, context) {
- iterator = iterator || Prototype.K;
- var results = [];
-
- if (Object.isString(filter))
- filter = new RegExp(filter);
-
- this.each(function(value, index) {
- if (filter.match(value))
- results.push(iterator.call(context, value, index));
- });
- return results;
- },
-
- include: function(object) {
- if (Object.isFunction(this.indexOf))
- if (this.indexOf(object) != -1) return true;
-
- var found = false;
- this.each(function(value) {
- if (value == object) {
- found = true;
- throw $break;
- }
- });
- return found;
- },
-
- inGroupsOf: function(number, fillWith) {
- fillWith = Object.isUndefined(fillWith) ? null : fillWith;
- return this.eachSlice(number, function(slice) {
- while(slice.length < number) slice.push(fillWith);
- return slice;
- });
- },
-
- inject: function(memo, iterator, context) {
- this.each(function(value, index) {
- memo = iterator.call(context, memo, value, index);
- });
- return memo;
- },
-
- invoke: function(method) {
- var args = $A(arguments).slice(1);
- return this.map(function(value) {
- return value[method].apply(value, args);
- });
- },
-
- max: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var result;
- this.each(function(value, index) {
- value = iterator.call(context, value, index);
- if (result == null || value >= result)
- result = value;
- });
- return result;
- },
-
- min: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var result;
- this.each(function(value, index) {
- value = iterator.call(context, value, index);
- if (result == null || value < result)
- result = value;
- });
- return result;
- },
-
- partition: function(iterator, context) {
- iterator = iterator || Prototype.K;
- var trues = [], falses = [];
- this.each(function(value, index) {
- (iterator.call(context, value, index) ?
- trues : falses).push(value);
- });
- return [trues, falses];
- },
-
- pluck: function(property) {
- var results = [];
- this.each(function(value) {
- results.push(value[property]);
- });
- return results;
- },
-
- reject: function(iterator, context) {
- var results = [];
- this.each(function(value, index) {
- if (!iterator.call(context, value, index))
- results.push(value);
- });
- return results;
- },
-
- sortBy: function(iterator, context) {
- return this.map(function(value, index) {
- return {
- value: value,
- criteria: iterator.call(context, value, index)
- };
- }).sort(function(left, right) {
- var a = left.criteria, b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }).pluck('value');
- },
-
- toArray: function() {
- return this.map();
- },
-
- zip: function() {
- var iterator = Prototype.K, args = $A(arguments);
- if (Object.isFunction(args.last()))
- iterator = args.pop();
-
- var collections = [this].concat(args).map($A);
- return this.map(function(value, index) {
- return iterator(collections.pluck(index));
- });
- },
-
- size: function() {
- return this.toArray().length;
- },
-
- inspect: function() {
- return '#<Enumerable:' + this.toArray().inspect() + '>';
- }
-};
-
-Object.extend(Enumerable, {
- map: Enumerable.collect,
- find: Enumerable.detect,
- select: Enumerable.findAll,
- filter: Enumerable.findAll,
- member: Enumerable.include,
- entries: Enumerable.toArray,
- every: Enumerable.all,
- some: Enumerable.any
-});
-function $A(iterable) {
- if (!iterable) return [];
- if (iterable.toArray) return iterable.toArray();
- var length = iterable.length || 0, results = new Array(length);
- while (length--) results[length] = iterable[length];
- return results;
-}
-
-if (Prototype.Browser.WebKit) {
- $A = function(iterable) {
- if (!iterable) return [];
- // In Safari, only use the `toArray` method if it's not a NodeList.
- // A NodeList is a function, has an function `item` property, and a numeric
- // `length` property. Adapted from Google Doctype.
- if (!(typeof iterable === 'function' && typeof iterable.length ===
- 'number' && typeof iterable.item === 'function') && iterable.toArray)
- return iterable.toArray();
- var length = iterable.length || 0, results = new Array(length);
- while (length--) results[length] = iterable[length];
- return results;
- };
-}
-
-Array.from = $A;
-
-Object.extend(Array.prototype, Enumerable);
-
-if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse;
-
-Object.extend(Array.prototype, {
- _each: function(iterator) {
- for (var i = 0, length = this.length; i < length; i++)
- iterator(this[i]);
- },
-
- clear: function() {
- this.length = 0;
- return this;
- },
-
- first: function() {
- return this[0];
- },
-
- last: function() {
- return this[this.length - 1];
- },
-
- compact: function() {
- return this.select(function(value) {
- return value != null;
- });
- },
-
- flatten: function() {
- return this.inject([], function(array, value) {
- return array.concat(Object.isArray(value) ?
- value.flatten() : [value]);
- });
- },
-
- without: function() {
- var values = $A(arguments);
- return this.select(function(value) {
- return !values.include(value);
- });
- },
-
- reverse: function(inline) {
- return (inline !== false ? this : this.toArray())._reverse();
- },
-
- reduce: function() {
- return this.length > 1 ? this : this[0];
- },
-
- uniq: function(sorted) {
- return this.inject([], function(array, value, index) {
- if (0 == index || (sorted ? array.last() != value : !array.include(value)))
- array.push(value);
- return array;
- });
- },
-
- intersect: function(array) {
- return this.uniq().findAll(function(item) {
- return array.detect(function(value) { return item === value });
- });
- },
-
- clone: function() {
- return [].concat(this);
- },
-
- size: function() {
- return this.length;
- },
-
- inspect: function() {
- return '[' + this.map(Object.inspect).join(', ') + ']';
- },
-
- toJSON: function() {
- var results = [];
- this.each(function(object) {
- var value = Object.toJSON(object);
- if (!Object.isUndefined(value)) results.push(value);
- });
- return '[' + results.join(', ') + ']';
- }
-});
-
-// use native browser JS 1.6 implementation if available
-if (Object.isFunction(Array.prototype.forEach))
- Array.prototype._each = Array.prototype.forEach;
-
-if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) {
- i || (i = 0);
- var length = this.length;
- if (i < 0) i = length + i;
- for (; i < length; i++)
- if (this[i] === item) return i;
- return -1;
-};
-
-if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) {
- i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
- var n = this.slice(0, i).reverse().indexOf(item);
- return (n < 0) ? n : i - n - 1;
-};
-
-Array.prototype.toArray = Array.prototype.clone;
-
-function $w(string) {
- if (!Object.isString(string)) return [];
- string = string.strip();
- return string ? string.split(/\s+/) : [];
-}
-
-if (Prototype.Browser.Opera){
- Array.prototype.concat = function() {
- var array = [];
- for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
- for (var i = 0, length = arguments.length; i < length; i++) {
- if (Object.isArray(arguments[i])) {
- for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
- array.push(arguments[i][j]);
- } else {
- array.push(arguments[i]);
- }
- }
- return array;
- };
-}
-Object.extend(Number.prototype, {
- toColorPart: function() {
- return this.toPaddedString(2, 16);
- },
-
- succ: function() {
- return this + 1;
- },
-
- times: function(iterator, context) {
- $R(0, this, true).each(iterator, context);
- return this;
- },
-
- toPaddedString: function(length, radix) {
- var string = this.toString(radix || 10);
- return '0'.times(length - string.length) + string;
- },
-
- toJSON: function() {
- return isFinite(this) ? this.toString() : 'null';
- }
-});
-
-$w('abs round ceil floor').each(function(method){
- Number.prototype[method] = Math[method].methodize();
-});
-function $H(object) {
- return new Hash(object);
-};
-
-var Hash = Class.create(Enumerable, (function() {
-
- function toQueryPair(key, value) {
- if (Object.isUndefined(value)) return key;
- return key + '=' + encodeURIComponent(String.interpret(value));
- }
-
- return {
- initialize: function(object) {
- this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
- },
-
- _each: function(iterator) {
- for (var key in this._object) {
- var value = this._object[key], pair = [key, value];
- pair.key = key;
- pair.value = value;
- iterator(pair);
- }
- },
-
- set: function(key, value) {
- return this._object[key] = value;
- },
-
- get: function(key) {
- // simulating poorly supported hasOwnProperty
- if (this._object[key] !== Object.prototype[key])
- return this._object[key];
- },
-
- unset: function(key) {
- var value = this._object[key];
- delete this._object[key];
- return value;
- },
-
- toObject: function() {
- return Object.clone(this._object);
- },
-
- keys: function() {
- return this.pluck('key');
- },
-
- values: function() {
- return this.pluck('value');
- },
-
- index: function(value) {
- var match = this.detect(function(pair) {
- return pair.value === value;
- });
- return match && match.key;
- },
-
- merge: function(object) {
- return this.clone().update(object);
- },
-
- update: function(object) {
- return new Hash(object).inject(this, function(result, pair) {
- result.set(pair.key, pair.value);
- return result;
- });
- },
-
- toQueryString: function() {
- return this.inject([], function(results, pair) {
- var key = encodeURIComponent(pair.key), values = pair.value;
-
- if (values && typeof values == 'object') {
- if (Object.isArray(values))
- return results.concat(values.map(toQueryPair.curry(key)));
- } else results.push(toQueryPair(key, values));
- return results;
- }).join('&');
- },
-
- inspect: function() {
- return '#<Hash:{' + this.map(function(pair) {
- return pair.map(Object.inspect).join(': ');
- }).join(', ') + '}>';
- },
-
- toJSON: function() {
- return Object.toJSON(this.toObject());
- },
-
- clone: function() {
- return new Hash(this);
- }
- }
-})());
-
-Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
-Hash.from = $H;
-var ObjectRange = Class.create(Enumerable, {
- initialize: function(start, end, exclusive) {
- this.start = start;
- this.end = end;
- this.exclusive = exclusive;
- },
-
- _each: function(iterator) {
- var value = this.start;
- while (this.include(value)) {
- iterator(value);
- value = value.succ();
- }
- },
-
- include: function(value) {
- if (value < this.start)
- return false;
- if (this.exclusive)
- return value < this.end;
- return value <= this.end;
- }
-});
-
-var $R = function(start, end, exclusive) {
- return new ObjectRange(start, end, exclusive);
-};
-
-var Ajax = {
- getTransport: function() {
- return Try.these(
- function() {return new XMLHttpRequest()},
- function() {return new ActiveXObject('Msxml2.XMLHTTP')},
- function() {return new ActiveXObject('Microsoft.XMLHTTP')}
- ) || false;
- },
-
- activeRequestCount: 0
-};
-
-Ajax.Responders = {
- responders: [],
-
- _each: function(iterator) {
- this.responders._each(iterator);
- },
-
- register: function(responder) {
- if (!this.include(responder))
- this.responders.push(responder);
- },
-
- unregister: function(responder) {
- this.responders = this.responders.without(responder);
- },
-
- dispatch: function(callback, request, transport, json) {
- this.each(function(responder) {
- if (Object.isFunction(responder[callback])) {
- try {
- responder[callback].apply(responder, [request, transport, json]);
- } catch (e) { }
- }
- });
- }
-};
-
-Object.extend(Ajax.Responders, Enumerable);
-
-Ajax.Responders.register({
- onCreate: function() { Ajax.activeRequestCount++ },
- onComplete: function() { Ajax.activeRequestCount-- }
-});
-
-Ajax.Base = Class.create({
- initialize: function(options) {
- this.options = {
- method: 'post',
- asynchronous: true,
- contentType: 'application/x-www-form-urlencoded',
- encoding: 'UTF-8',
- parameters: '',
- evalJSON: true,
- evalJS: true
- };
- Object.extend(this.options, options || { });
-
- this.options.method = this.options.method.toLowerCase();
-
- if (Object.isString(this.options.parameters))
- this.options.parameters = this.options.parameters.toQueryParams();
- else if (Object.isHash(this.options.parameters))
- this.options.parameters = this.options.parameters.toObject();
- }
-});
-
-Ajax.Request = Class.create(Ajax.Base, {
- _complete: false,
-
- initialize: function($super, url, options) {
- $super(options);
- this.transport = Ajax.getTransport();
- this.request(url);
- },
-
- request: function(url) {
- this.url = url;
- this.method = this.options.method;
- var params = Object.clone(this.options.parameters);
-
- if (!['get', 'post'].include(this.method)) {
- // simulate other verbs over post
- params['_method'] = this.method;
- this.method = 'post';
- }
-
- this.parameters = params;
-
- if (params = Object.toQueryString(params)) {
- // when GET, append parameters to URL
- if (this.method == 'get')
- this.url += (this.url.include('?') ? '&' : '?') + params;
- else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
- params += '&_=';
- }
-
- try {
- var response = new Ajax.Response(this);
- if (this.options.onCreate) this.options.onCreate(response);
- Ajax.Responders.dispatch('onCreate', this, response);
-
- this.transport.open(this.method.toUpperCase(), this.url,
- this.options.asynchronous);
-
- if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
-
- this.transport.onreadystatechange = this.onStateChange.bind(this);
- this.setRequestHeaders();
-
- this.body = this.method == 'post' ? (this.options.postBody || params) : null;
- this.transport.send(this.body);
-
- /* Force Firefox to handle ready state 4 for synchronous requests */
- if (!this.options.asynchronous && this.transport.overrideMimeType)
- this.onStateChange();
-
- }
- catch (e) {
- this.dispatchException(e);
- }
- },
-
- onStateChange: function() {
- var readyState = this.transport.readyState;
- if (readyState > 1 && !((readyState == 4) && this._complete))
- this.respondToReadyState(this.transport.readyState);
- },
-
- setRequestHeaders: function() {
- var headers = {
- 'X-Requested-With': 'XMLHttpRequest',
- 'X-Prototype-Version': Prototype.Version,
- 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
- };
-
- if (this.method == 'post') {
- headers['Content-type'] = this.options.contentType +
- (this.options.encoding ? '; charset=' + this.options.encoding : '');
-
- /* Force "Connection: close" for older Mozilla browsers to work
- * around a bug where XMLHttpRequest sends an incorrect
- * Content-length header. See Mozilla Bugzilla #246651.
- */
- if (this.transport.overrideMimeType &&
- (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
- headers['Connection'] = 'close';
- }
-
- // user-defined headers
- if (typeof this.options.requestHeaders == 'object') {
- var extras = this.options.requestHeaders;
-
- if (Object.isFunction(extras.push))
- for (var i = 0, length = extras.length; i < length; i += 2)
- headers[extras[i]] = extras[i+1];
- else
- $H(extras).each(function(pair) { headers[pair.key] = pair.value });
- }
-
- for (var name in headers)
- this.transport.setRequestHeader(name, headers[name]);
- },
-
- success: function() {
- var status = this.getStatus();
- return !status || (status >= 200 && status < 300);
- },
-
- getStatus: function() {
- try {
- return this.transport.status || 0;
- } catch (e) { return 0 }
- },
-
- respondToReadyState: function(readyState) {
- var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
-
- if (state == 'Complete') {
- try {
- this._complete = true;
- (this.options['on' + response.status]
- || this.options['on' + (this.success() ? 'Success' : 'Failure')]
- || Prototype.emptyFunction)(response, response.headerJSON);
- } catch (e) {
- this.dispatchException(e);
- }
-
- var contentType = response.getHeader('Content-type');
- if (this.options.evalJS == 'force'
- || (this.options.evalJS && this.isSameOrigin() && contentType
- && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
- this.evalResponse();
- }
-
- try {
- (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
- Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
- } catch (e) {
- this.dispatchException(e);
- }
-
- if (state == 'Complete') {
- // avoid memory leak in MSIE: clean up
- this.transport.onreadystatechange = Prototype.emptyFunction;
- }
- },
-
- isSameOrigin: function() {
- var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
- return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
- protocol: location.protocol,
- domain: document.domain,
- port: location.port ? ':' + location.port : ''
- }));
- },
-
- getHeader: function(name) {
- try {
- return this.transport.getResponseHeader(name) || null;
- } catch (e) { return null }
- },
-
- evalResponse: function() {
- try {
- return eval((this.transport.responseText || '').unfilterJSON());
- } catch (e) {
- this.dispatchException(e);
- }
- },
-
- dispatchException: function(exception) {
- (this.options.onException || Prototype.emptyFunction)(this, exception);
- Ajax.Responders.dispatch('onException', this, exception);
- }
-});
-
-Ajax.Request.Events =
- ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
-
-Ajax.Response = Class.create({
- initialize: function(request){
- this.request = request;
- var transport = this.transport = request.transport,
- readyState = this.readyState = transport.readyState;
-
- if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
- this.status = this.getStatus();
- this.statusText = this.getStatusText();
- this.responseText = String.interpret(transport.responseText);
- this.headerJSON = this._getHeaderJSON();
- }
-
- if(readyState == 4) {
- var xml = transport.responseXML;
- this.responseXML = Object.isUndefined(xml) ? null : xml;
- this.responseJSON = this._getResponseJSON();
- }
- },
-
- status: 0,
- statusText: '',
-
- getStatus: Ajax.Request.prototype.getStatus,
-
- getStatusText: function() {
- try {
- return this.transport.statusText || '';
- } catch (e) { return '' }
- },
-
- getHeader: Ajax.Request.prototype.getHeader,
-
- getAllHeaders: function() {
- try {
- return this.getAllResponseHeaders();
- } catch (e) { return null }
- },
-
- getResponseHeader: function(name) {
- return this.transport.getResponseHeader(name);
- },
-
- getAllResponseHeaders: function() {
- return this.transport.getAllResponseHeaders();
- },
-
- _getHeaderJSON: function() {
- var json = this.getHeader('X-JSON');
- if (!json) return null;
- json = decodeURIComponent(escape(json));
- try {
- return json.evalJSON(this.request.options.sanitizeJSON ||
- !this.request.isSameOrigin());
- } catch (e) {
- this.request.dispatchException(e);
- }
- },
-
- _getResponseJSON: function() {
- var options = this.request.options;
- if (!options.evalJSON || (options.evalJSON != 'force' &&
- !(this.getHeader('Content-type') || '').include('application/json')) ||
- this.responseText.blank())
- return null;
- try {
- return this.responseText.evalJSON(options.sanitizeJSON ||
- !this.request.isSameOrigin());
- } catch (e) {
- this.request.dispatchException(e);
- }
- }
-});
-
-Ajax.Updater = Class.create(Ajax.Request, {
- initialize: function($super, container, url, options) {
- this.container = {
- success: (container.success || container),
- failure: (container.failure || (container.success ? null : container))
- };
-
- options = Object.clone(options);
- var onComplete = options.onComplete;
- options.onComplete = (function(response, json) {
- this.updateContent(response.responseText);
- if (Object.isFunction(onComplete)) onComplete(response, json);
- }).bind(this);
-
- $super(url, options);
- },
-
- updateContent: function(responseText) {
- var receiver = this.container[this.success() ? 'success' : 'failure'],
- options = this.options;
-
- if (!options.evalScripts) responseText = responseText.stripScripts();
-
- if (receiver = $(receiver)) {
- if (options.insertion) {
- if (Object.isString(options.insertion)) {
- var insertion = { }; insertion[options.insertion] = responseText;
- receiver.insert(insertion);
- }
- else options.insertion(receiver, responseText);
- }
- else receiver.update(responseText);
- }
- }
-});
-
-Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
- initialize: function($super, container, url, options) {
- $super(options);
- this.onComplete = this.options.onComplete;
-
- this.frequency = (this.options.frequency || 2);
- this.decay = (this.options.decay || 1);
-
- this.updater = { };
- this.container = container;
- this.url = url;
-
- this.start();
- },
-
- start: function() {
- this.options.onComplete = this.updateComplete.bind(this);
- this.onTimerEvent();
- },
-
- stop: function() {
- this.updater.options.onComplete = undefined;
- clearTimeout(this.timer);
- (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
- },
-
- updateComplete: function(response) {
- if (this.options.decay) {
- this.decay = (response.responseText == this.lastText ?
- this.decay * this.options.decay : 1);
-
- this.lastText = response.responseText;
- }
- this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
- },
-
- onTimerEvent: function() {
- this.updater = new Ajax.Updater(this.container, this.url, this.options);
- }
-});
-function $(element) {
- if (arguments.length > 1) {
- for (var i = 0, elements = [], length = arguments.length; i < length; i++)
- elements.push($(arguments[i]));
- return elements;
- }
- if (Object.isString(element))
- element = document.getElementById(element);
- return Element.extend(element);
-}
-
-if (Prototype.BrowserFeatures.XPath) {
- document._getElementsByXPath = function(expression, parentElement) {
- var results = [];
- var query = document.evaluate(expression, $(parentElement) || document,
- null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
- for (var i = 0, length = query.snapshotLength; i < length; i++)
- results.push(Element.extend(query.snapshotItem(i)));
- return results;
- };
-}
-
-/*--------------------------------------------------------------------------*/
-
-if (!window.Node) var Node = { };
-
-if (!Node.ELEMENT_NODE) {
- // DOM level 2 ECMAScript Language Binding
- Object.extend(Node, {
- ELEMENT_NODE: 1,
- ATTRIBUTE_NODE: 2,
- TEXT_NODE: 3,
- CDATA_SECTION_NODE: 4,
- ENTITY_REFERENCE_NODE: 5,
- ENTITY_NODE: 6,
- PROCESSING_INSTRUCTION_NODE: 7,
- COMMENT_NODE: 8,
- DOCUMENT_NODE: 9,
- DOCUMENT_TYPE_NODE: 10,
- DOCUMENT_FRAGMENT_NODE: 11,
- NOTATION_NODE: 12
- });
-}
-
-(function() {
- var element = this.Element;
- this.Element = function(tagName, attributes) {
- attributes = attributes || { };
- tagName = tagName.toLowerCase();
- var cache = Element.cache;
- if (Prototype.Browser.IE && attributes.name) {
- tagName = '<' + tagName + ' name="' + attributes.name + '">';
- delete attributes.name;
- return Element.writeAttribute(document.createElement(tagName), attributes);
- }
- if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
- return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
- };
- Object.extend(this.Element, element || { });
- if (element) this.Element.prototype = element.prototype;
-}).call(window);
-
-Element.cache = { };
-
-Element.Methods = {
- visible: function(element) {
- return $(element).style.display != 'none';
- },
-
- toggle: function(element) {
- element = $(element);
- Element[Element.visible(element) ? 'hide' : 'show'](element);
- return element;
- },
-
- hide: function(element) {
- element = $(element);
- element.style.display = 'none';
- return element;
- },
-
- show: function(element) {
- element = $(element);
- element.style.display = '';
- return element;
- },
-
- remove: function(element) {
- element = $(element);
- element.parentNode.removeChild(element);
- return element;
- },
-
- update: function(element, content) {
- element = $(element);
- if (content && content.toElement) content = content.toElement();
- if (Object.isElement(content)) return element.update().insert(content);
- content = Object.toHTML(content);
- element.innerHTML = content.stripScripts();
- content.evalScripts.bind(content).defer();
- return element;
- },
-
- replace: function(element, content) {
- element = $(element);
- if (content && content.toElement) content = content.toElement();
- else if (!Object.isElement(content)) {
- content = Object.toHTML(content);
- var range = element.ownerDocument.createRange();
- range.selectNode(element);
- content.evalScripts.bind(content).defer();
- content = range.createContextualFragment(content.stripScripts());
- }
- element.parentNode.replaceChild(content, element);
- return element;
- },
-
- insert: function(element, insertions) {
- element = $(element);
-
- if (Object.isString(insertions) || Object.isNumber(insertions) ||
- Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
- insertions = {bottom:insertions};
-
- var content, insert, tagName, childNodes;
-
- for (var position in insertions) {
- content = insertions[position];
- position = position.toLowerCase();
- insert = Element._insertionTranslations[position];
-
- if (content && content.toElement) content = content.toElement();
- if (Object.isElement(content)) {
- insert(element, content);
- continue;
- }
-
- content = Object.toHTML(content);
-
- tagName = ((position == 'before' || position == 'after')
- ? element.parentNode : element).tagName.toUpperCase();
-
- childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
-
- if (position == 'top' || position == 'after') childNodes.reverse();
- childNodes.each(insert.curry(element));
-
- content.evalScripts.bind(content).defer();
- }
-
- return element;
- },
-
- wrap: function(element, wrapper, attributes) {
- element = $(element);
- if (Object.isElement(wrapper))
- $(wrapper).writeAttribute(attributes || { });
- else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
- else wrapper = new Element('div', wrapper);
- if (element.parentNode)
- element.parentNode.replaceChild(wrapper, element);
- wrapper.appendChild(element);
- return wrapper;
- },
-
- inspect: function(element) {
- element = $(element);
- var result = '<' + element.tagName.toLowerCase();
- $H({'id': 'id', 'className': 'class'}).each(function(pair) {
- var property = pair.first(), attribute = pair.last();
- var value = (element[property] || '').toString();
- if (value) result += ' ' + attribute + '=' + value.inspect(true);
- });
- return result + '>';
- },
-
- recursivelyCollect: function(element, property) {
- element = $(element);
- var elements = [];
- while (element = element[property])
- if (element.nodeType == 1)
- elements.push(Element.extend(element));
- return elements;
- },
-
- ancestors: function(element) {
- return $(element).recursivelyCollect('parentNode');
- },
-
- descendants: function(element) {
- return $(element).select("*");
- },
-
- firstDescendant: function(element) {
- element = $(element).firstChild;
- while (element && element.nodeType != 1) element = element.nextSibling;
- return $(element);
- },
-
- immediateDescendants: function(element) {
- if (!(element = $(element).firstChild)) return [];
- while (element && element.nodeType != 1) element = element.nextSibling;
- if (element) return [element].concat($(element).nextSiblings());
- return [];
- },
-
- previousSiblings: function(element) {
- return $(element).recursivelyCollect('previousSibling');
- },
-
- nextSiblings: function(element) {
- return $(element).recursivelyCollect('nextSibling');
- },
-
- siblings: function(element) {
- element = $(element);
- return element.previousSiblings().reverse().concat(element.nextSiblings());
- },
-
- match: function(element, selector) {
- if (Object.isString(selector))
- selector = new Selector(selector);
- return selector.match($(element));
- },
-
- up: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(element.parentNode);
- var ancestors = element.ancestors();
- return Object.isNumber(expression) ? ancestors[expression] :
- Selector.findElement(ancestors, expression, index);
- },
-
- down: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return element.firstDescendant();
- return Object.isNumber(expression) ? element.descendants()[expression] :
- Element.select(element, expression)[index || 0];
- },
-
- previous: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
- var previousSiblings = element.previousSiblings();
- return Object.isNumber(expression) ? previousSiblings[expression] :
- Selector.findElement(previousSiblings, expression, index);
- },
-
- next: function(element, expression, index) {
- element = $(element);
- if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
- var nextSiblings = element.nextSiblings();
- return Object.isNumber(expression) ? nextSiblings[expression] :
- Selector.findElement(nextSiblings, expression, index);
- },
-
- select: function() {
- var args = $A(arguments), element = $(args.shift());
- return Selector.findChildElements(element, args);
- },
-
- adjacent: function() {
- var args = $A(arguments), element = $(args.shift());
- return Selector.findChildElements(element.parentNode, args).without(element);
- },
-
- identify: function(element) {
- element = $(element);
- var id = element.readAttribute('id'), self = arguments.callee;
- if (id) return id;
- do { id = 'anonymous_element_' + self.counter++ } while ($(id));
- element.writeAttribute('id', id);
- return id;
- },
-
- readAttribute: function(element, name) {
- element = $(element);
- if (Prototype.Browser.IE) {
- var t = Element._attributeTranslations.read;
- if (t.values[name]) return t.values[name](element, name);
- if (t.names[name]) name = t.names[name];
- if (name.include(':')) {
- return (!element.attributes || !element.attributes[name]) ? null :
- element.attributes[name].value;
- }
- }
- return element.getAttribute(name);
- },
-
- writeAttribute: function(element, name, value) {
- element = $(element);
- var attributes = { }, t = Element._attributeTranslations.write;
-
- if (typeof name == 'object') attributes = name;
- else attributes[name] = Object.isUndefined(value) ? true : value;
-
- for (var attr in attributes) {
- name = t.names[attr] || attr;
- value = attributes[attr];
- if (t.values[attr]) name = t.values[attr](element, value);
- if (value === false || value === null)
- element.removeAttribute(name);
- else if (value === true)
- element.setAttribute(name, name);
- else element.setAttribute(name, value);
- }
- return element;
- },
-
- getHeight: function(element) {
- return $(element).getDimensions().height;
- },
-
- getWidth: function(element) {
- return $(element).getDimensions().width;
- },
-
- classNames: function(element) {
- return new Element.ClassNames(element);
- },
-
- hasClassName: function(element, className) {
- if (!(element = $(element))) return;
- var elementClassName = element.className;
- return (elementClassName.length > 0 && (elementClassName == className ||
- new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
- },
-
- addClassName: function(element, className) {
- if (!(element = $(element))) return;
- if (!element.hasClassName(className))
- element.className += (element.className ? ' ' : '') + className;
- return element;
- },
-
- removeClassName: function(element, className) {
- if (!(element = $(element))) return;
- element.className = element.className.replace(
- new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
- return element;
- },
-
- toggleClassName: function(element, className) {
- if (!(element = $(element))) return;
- return element[element.hasClassName(className) ?
- 'removeClassName' : 'addClassName'](className);
- },
-
- // removes whitespace-only text node children
- cleanWhitespace: function(element) {
- element = $(element);
- var node = element.firstChild;
- while (node) {
- var nextNode = node.nextSibling;
- if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
- element.removeChild(node);
- node = nextNode;
- }
- return element;
- },
-
- empty: function(element) {
- return $(element).innerHTML.blank();
- },
-
- descendantOf: function(element, ancestor) {
- element = $(element), ancestor = $(ancestor);
-
- if (element.compareDocumentPosition)
- return (element.compareDocumentPosition(ancestor) & 8) === 8;
-
- if (ancestor.contains)
- return ancestor.contains(element) && ancestor !== element;
-
- while (element = element.parentNode)
- if (element == ancestor) return true;
-
- return false;
- },
-
- scrollTo: function(element) {
- element = $(element);
- var pos = element.cumulativeOffset();
- window.scrollTo(pos[0], pos[1]);
- return element;
- },
-
- getStyle: function(element, style) {
- element = $(element);
- style = style == 'float' ? 'cssFloat' : style.camelize();
- var value = element.style[style];
- if (!value || value == 'auto') {
- var css = document.defaultView.getComputedStyle(element, null);
- value = css ? css[style] : null;
- }
- if (style == 'opacity') return value ? parseFloat(value) : 1.0;
- return value == 'auto' ? null : value;
- },
-
- getOpacity: function(element) {
- return $(element).getStyle('opacity');
- },
-
- setStyle: function(element, styles) {
- element = $(element);
- var elementStyle = element.style, match;
- if (Object.isString(styles)) {
- element.style.cssText += ';' + styles;
- return styles.include('opacity') ?
- element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
- }
- for (var property in styles)
- if (property == 'opacity') element.setOpacity(styles[property]);
- else
- elementStyle[(property == 'float' || property == 'cssFloat') ?
- (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') :
- property] = styles[property];
-
- return element;
- },
-
- setOpacity: function(element, value) {
- element = $(element);
- element.style.opacity = (value == 1 || value === '') ? '' :
- (value < 0.00001) ? 0 : value;
- return element;
- },
-
- getDimensions: function(element) {
- element = $(element);
- var display = element.getStyle('display');
- if (display != 'none' && display != null) // Safari bug
- return {width: element.offsetWidth, height: element.offsetHeight};
-
- // All *Width and *Height properties give 0 on elements with display none,
- // so enable the element temporarily
- var els = element.style;
- var originalVisibility = els.visibility;
- var originalPosition = els.position;
- var originalDisplay = els.display;
- els.visibility = 'hidden';
- els.position = 'absolute';
- els.display = 'block';
- var originalWidth = element.clientWidth;
- var originalHeight = element.clientHeight;
- els.display = originalDisplay;
- els.position = originalPosition;
- els.visibility = originalVisibility;
- return {width: originalWidth, height: originalHeight};
- },
-
- makePositioned: function(element) {
- element = $(element);
- var pos = Element.getStyle(element, 'position');
- if (pos == 'static' || !pos) {
- element._madePositioned = true;
- element.style.position = 'relative';
- // Opera returns the offset relative to the positioning context, when an
- // element is position relative but top and left have not been defined
- if (Prototype.Browser.Opera) {
- element.style.top = 0;
- element.style.left = 0;
- }
- }
- return element;
- },
-
- undoPositioned: function(element) {
- element = $(element);
- if (element._madePositioned) {
- element._madePositioned = undefined;
- element.style.position =
- element.style.top =
- element.style.left =
- element.style.bottom =
- element.style.right = '';
- }
- return element;
- },
-
- makeClipping: function(element) {
- element = $(element);
- if (element._overflow) return element;
- element._overflow = Element.getStyle(element, 'overflow') || 'auto';
- if (element._overflow !== 'hidden')
- element.style.overflow = 'hidden';
- return element;
- },
-
- undoClipping: function(element) {
- element = $(element);
- if (!element._overflow) return element;
- element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
- element._overflow = null;
- return element;
- },
-
- cumulativeOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- element = element.offsetParent;
- } while (element);
- return Element._returnOffset(valueL, valueT);
- },
-
- positionedOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- element = element.offsetParent;
- if (element) {
- if (element.tagName.toUpperCase() == 'BODY') break;
- var p = Element.getStyle(element, 'position');
- if (p !== 'static') break;
- }
- } while (element);
- return Element._returnOffset(valueL, valueT);
- },
-
- absolutize: function(element) {
- element = $(element);
- if (element.getStyle('position') == 'absolute') return element;
- // Position.prepare(); // To be done manually by Scripty when it needs it.
-
- var offsets = element.positionedOffset();
- var top = offsets[1];
- var left = offsets[0];
- var width = element.clientWidth;
- var height = element.clientHeight;
-
- element._originalLeft = left - parseFloat(element.style.left || 0);
- element._originalTop = top - parseFloat(element.style.top || 0);
- element._originalWidth = element.style.width;
- element._originalHeight = element.style.height;
-
- element.style.position = 'absolute';
- element.style.top = top + 'px';
- element.style.left = left + 'px';
- element.style.width = width + 'px';
- element.style.height = height + 'px';
- return element;
- },
-
- relativize: function(element) {
- element = $(element);
- if (element.getStyle('position') == 'relative') return element;
- // Position.prepare(); // To be done manually by Scripty when it needs it.
-
- element.style.position = 'relative';
- var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
- var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
-
- element.style.top = top + 'px';
- element.style.left = left + 'px';
- element.style.height = element._originalHeight;
- element.style.width = element._originalWidth;
- return element;
- },
-
- cumulativeScrollOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.scrollTop || 0;
- valueL += element.scrollLeft || 0;
- element = element.parentNode;
- } while (element);
- return Element._returnOffset(valueL, valueT);
- },
-
- getOffsetParent: function(element) {
- if (element.offsetParent) return $(element.offsetParent);
- if (element == document.body) return $(element);
-
- while ((element = element.parentNode) && element != document.body
- && Object.isElement(element)/* changed by Nick - http://dev.rubyonrails.org/ticket/11007 */)
- if (Element.getStyle(element, 'position') != 'static')
- return $(element);
-
- return $(document.body);
- },
-
- viewportOffset: function(forElement) {
- var valueT = 0, valueL = 0;
-
- var element = forElement;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
-
- // Safari fix
- if (element.offsetParent == document.body &&
- Element.getStyle(element, 'position') == 'absolute') break;
-
- } while (element = element.offsetParent);
-
- element = forElement;
- do {
- if (!Prototype.Browser.Opera || (element.tagName && (element.tagName.toUpperCase() == 'BODY'))) {
- valueT -= element.scrollTop || 0;
- valueL -= element.scrollLeft || 0;
- }
- } while (element = element.parentNode);
-
- return Element._returnOffset(valueL, valueT);
- },
-
- clonePosition: function(element, source) {
- var options = Object.extend({
- setLeft: true,
- setTop: true,
- setWidth: true,
- setHeight: true,
- offsetTop: 0,
- offsetLeft: 0
- }, arguments[2] || { });
-
- // find page position of source
- source = $(source);
- var p = source.viewportOffset();
-
- // find coordinate system to use
- element = $(element);
- var delta = [0, 0];
- var parent = null;
- // delta [0,0] will do fine with position: fixed elements,
- // position:absolute needs offsetParent deltas
- if (Element.getStyle(element, 'position') == 'absolute') {
- parent = element.getOffsetParent();
- delta = parent.viewportOffset();
- }
-
- // correct by body offsets (fixes Safari)
- if (parent == document.body) {
- delta[0] -= document.body.offsetLeft;
- delta[1] -= document.body.offsetTop;
- }
-
- // set position
- if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
- if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
- if (options.setWidth) element.style.width = source.offsetWidth + 'px';
- if (options.setHeight) element.style.height = source.offsetHeight + 'px';
- return element;
- }
-};
-
-Element.Methods.identify.counter = 1;
-
-Object.extend(Element.Methods, {
- getElementsBySelector: Element.Methods.select,
- childElements: Element.Methods.immediateDescendants
-});
-
-Element._attributeTranslations = {
- write: {
- names: {
- className: 'class',
- htmlFor: 'for'
- },
- values: { }
- }
-};
-
-if (Prototype.Browser.Opera) {
- Element.Methods.getStyle = Element.Methods.getStyle.wrap(
- function(proceed, element, style) {
- switch (style) {
- case 'left': case 'top': case 'right': case 'bottom':
- if (proceed(element, 'position') === 'static') return null;
- case 'height': case 'width':
- // returns '0px' for hidden elements; we want it to return null
- if (!Element.visible(element)) return null;
-
- // returns the border-box dimensions rather than the content-box
- // dimensions, so we subtract padding and borders from the value
- var dim = parseInt(proceed(element, style), 10);
-
- if (dim !== element['offset' + style.capitalize()])
- return dim + 'px';
-
- var properties;
- if (style === 'height') {
- properties = ['border-top-width', 'padding-top',
- 'padding-bottom', 'border-bottom-width'];
- }
- else {
- properties = ['border-left-width', 'padding-left',
- 'padding-right', 'border-right-width'];
- }
- return properties.inject(dim, function(memo, property) {
- var val = proceed(element, property);
- return val === null ? memo : memo - parseInt(val, 10);
- }) + 'px';
- default: return proceed(element, style);
- }
- }
- );
-
- Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
- function(proceed, element, attribute) {
- if (attribute === 'title') return element.title;
- return proceed(element, attribute);
- }
- );
-}
-
-else if (Prototype.Browser.IE) {
- // IE doesn't report offsets correctly for static elements, so we change them
- // to "relative" to get the values, then change them back.
- Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
- function(proceed, element) {
- element = $(element);
- // IE throws an error if element is not in document
- try { element.offsetParent }
- catch(e) { return $(document.body) }
- var position = element.getStyle('position');
- if (position !== 'static') return proceed(element);
- element.setStyle({ position: 'relative' });
- var value = proceed(element);
- element.setStyle({ position: position });
- return value;
- }
- );
-
- $w('positionedOffset viewportOffset').each(function(method) {
- Element.Methods[method] = Element.Methods[method].wrap(
- function(proceed, element) {
- element = $(element);
- try { element.offsetParent }
- catch(e) { return Element._returnOffset(0,0) }
- var position = element.getStyle('position');
- if (position !== 'static') return proceed(element);
- // Trigger hasLayout on the offset parent so that IE6 reports
- // accurate offsetTop and offsetLeft values for position: fixed.
- var offsetParent = element.getOffsetParent();
- if (offsetParent && offsetParent.getStyle('position') === 'fixed')
- offsetParent.setStyle({ zoom: 1 });
- element.setStyle({ position: 'relative' });
- var value = proceed(element);
- element.setStyle({ position: position });
- return value;
- }
- );
- });
-
- Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
- function(proceed, element) {
- try { element.offsetParent }
- catch(e) { return Element._returnOffset(0,0) }
- return proceed(element);
- }
- );
-
- Element.Methods.getStyle = function(element, style) {
- element = $(element);
- style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
- var value = element.style[style];
- if (!value && element.currentStyle) value = element.currentStyle[style];
-
- if (style == 'opacity') {
- if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
- if (value[1]) return parseFloat(value[1]) / 100;
- return 1.0;
- }
-
- if (value == 'auto') {
- if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
- return element['offset' + style.capitalize()] + 'px';
- return null;
- }
- return value;
- };
-
- Element.Methods.setOpacity = function(element, value) {
- function stripAlpha(filter){
- return filter.replace(/alpha\([^\)]*\)/gi,'');
- }
- element = $(element);
- var currentStyle = element.currentStyle;
- if ((currentStyle && !currentStyle.hasLayout) ||
- (!currentStyle && element.style.zoom == 'normal'))
- element.style.zoom = 1;
-
- var filter = element.getStyle('filter'), style = element.style;
- if (value == 1 || value === '') {
- (filter = stripAlpha(filter)) ?
- style.filter = filter : style.removeAttribute('filter');
- return element;
- } else if (value < 0.00001) value = 0;
- style.filter = stripAlpha(filter) +
- 'alpha(opacity=' + (value * 100) + ')';
- return element;
- };
-
- Element._attributeTranslations = {
- read: {
- names: {
- 'class': 'className',
- 'for': 'htmlFor'
- },
- values: {
- _getAttr: function(element, attribute) {
- return element.getAttribute(attribute, 2);
- },
- _getAttrNode: function(element, attribute) {
- var node = element.getAttributeNode(attribute);
- return node ? node.value : "";
- },
- _getEv: function(element, attribute) {
- attribute = element.getAttribute(attribute);
- return attribute ? attribute.toString().slice(23, -2) : null;
- },
- _flag: function(element, attribute) {
- return $(element).hasAttribute(attribute) ? attribute : null;
- },
- style: function(element) {
- return element.style.cssText.toLowerCase();
- },
- title: function(element) {
- return element.title;
- }
- }
- }
- };
-
- Element._attributeTranslations.write = {
- names: Object.extend({
- cellpadding: 'cellPadding',
- cellspacing: 'cellSpacing'
- }, Element._attributeTranslations.read.names),
- values: {
- checked: function(element, value) {
- element.checked = !!value;
- },
-
- style: function(element, value) {
- element.style.cssText = value ? value : '';
- }
- }
- };
-
- Element._attributeTranslations.has = {};
-
- $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
- 'encType maxLength readOnly longDesc frameBorder').each(function(attr) {
- Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
- Element._attributeTranslations.has[attr.toLowerCase()] = attr;
- });
-
- (function(v) {
- Object.extend(v, {
- href: v._getAttr,
- src: v._getAttr,
- type: v._getAttr,
- action: v._getAttrNode,
- disabled: v._flag,
- checked: v._flag,
- readonly: v._flag,
- multiple: v._flag,
- onload: v._getEv,
- onunload: v._getEv,
- onclick: v._getEv,
- ondblclick: v._getEv,
- onmousedown: v._getEv,
- onmouseup: v._getEv,
- onmouseover: v._getEv,
- onmousemove: v._getEv,
- onmouseout: v._getEv,
- onfocus: v._getEv,
- onblur: v._getEv,
- onkeypress: v._getEv,
- onkeydown: v._getEv,
- onkeyup: v._getEv,
- onsubmit: v._getEv,
- onreset: v._getEv,
- onselect: v._getEv,
- onchange: v._getEv
- });
- })(Element._attributeTranslations.read.values);
-}
-
-else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
- Element.Methods.setOpacity = function(element, value) {
- element = $(element);
- element.style.opacity = (value == 1) ? 0.999999 :
- (value === '') ? '' : (value < 0.00001) ? 0 : value;
- return element;
- };
-}
-
-else if (Prototype.Browser.WebKit) {
- Element.Methods.setOpacity = function(element, value) {
- element = $(element);
- element.style.opacity = (value == 1 || value === '') ? '' :
- (value < 0.00001) ? 0 : value;
-
- if (value == 1)
- if(element.tagName.toUpperCase() == 'IMG' && element.width) {
- element.width++; element.width--;
- } else try {
- var n = document.createTextNode(' ');
- element.appendChild(n);
- element.removeChild(n);
- } catch (e) { }
-
- return element;
- };
-
- // Safari returns margins on body which is incorrect if the child is absolutely
- // positioned. For performance reasons, redefine Element#cumulativeOffset for
- // KHTML/WebKit only.
- Element.Methods.cumulativeOffset = function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- if (element.offsetParent == document.body)
- if (Element.getStyle(element, 'position') == 'absolute') break;
-
- element = element.offsetParent;
- } while (element);
-
- return Element._returnOffset(valueL, valueT);
- };
-}
-
-if (Prototype.Browser.IE || Prototype.Browser.Opera) {
- // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements
- Element.Methods.update = function(element, content) {
- element = $(element);
-
- if (content && content.toElement) content = content.toElement();
- if (Object.isElement(content)) return element.update().insert(content);
-
- content = Object.toHTML(content);
- var tagName = element.tagName.toUpperCase();
-
- if (tagName in Element._insertionTranslations.tags) {
- $A(element.childNodes).each(function(node) { element.removeChild(node) });
- Element._getContentFromAnonymousElement(tagName, content.stripScripts())
- .each(function(node) { element.appendChild(node) });
- }
- else element.innerHTML = content.stripScripts();
-
- content.evalScripts.bind(content).defer();
- return element;
- };
-}
-
-if ('outerHTML' in document.createElement('div')) {
- Element.Methods.replace = function(element, content) {
- element = $(element);
-
- if (content && content.toElement) content = content.toElement();
- if (Object.isElement(content)) {
- element.parentNode.replaceChild(content, element);
- return element;
- }
-
- content = Object.toHTML(content);
- var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
-
- if (Element._insertionTranslations.tags[tagName]) {
- var nextSibling = element.next();
- var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
- parent.removeChild(element);
- if (nextSibling)
- fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
- else
- fragments.each(function(node) { parent.appendChild(node) });
- }
- else element.outerHTML = content.stripScripts();
-
- content.evalScripts.bind(content).defer();
- return element;
- };
-}
-
-Element._returnOffset = function(l, t) {
- var result = [l, t];
- result.left = l;
- result.top = t;
- return result;
-};
-
-Element._getContentFromAnonymousElement = function(tagName, html) {
- var div = new Element('div'), t = Element._insertionTranslations.tags[tagName];
- if (t) {
- div.innerHTML = t[0] + html + t[1];
- t[2].times(function() { div = div.firstChild });
- } else div.innerHTML = html;
- return $A(div.childNodes);
-};
-
-Element._insertionTranslations = {
- before: function(element, node) {
- element.parentNode.insertBefore(node, element);
- },
- top: function(element, node) {
- element.insertBefore(node, element.firstChild);
- },
- bottom: function(element, node) {
- element.appendChild(node);
- },
- after: function(element, node) {
- element.parentNode.insertBefore(node, element.nextSibling);
- },
- tags: {
- TABLE: ['<table>', '</table>', 1],
- TBODY: ['<table><tbody>', '</tbody></table>', 2],
- TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3],
- TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
- SELECT: ['<select>', '</select>', 1]
- }
-};
-
-(function() {
- Object.extend(this.tags, {
- THEAD: this.tags.TBODY,
- TFOOT: this.tags.TBODY,
- TH: this.tags.TD
- });
-}).call(Element._insertionTranslations);
-
-Element.Methods.Simulated = {
- hasAttribute: function(element, attribute) {
- attribute = Element._attributeTranslations.has[attribute] || attribute;
- var node = $(element).getAttributeNode(attribute);
- return !!(node && node.specified);
- }
-};
-
-Element.Methods.ByTag = { };
-
-Object.extend(Element, Element.Methods);
-
-if (!Prototype.BrowserFeatures.ElementExtensions &&
- document.createElement('div')['__proto__']) {
- window.HTMLElement = { };
- window.HTMLElement.prototype = document.createElement('div')['__proto__'];
- Prototype.BrowserFeatures.ElementExtensions = true;
-}
-
-Element.extend = (function() {
- if (Prototype.BrowserFeatures.SpecificElementExtensions)
- return Prototype.K;
-
- var Methods = { }, ByTag = Element.Methods.ByTag;
-
- var extend = Object.extend(function(element) {
- if (!element || element._extendedByPrototype ||
- element.nodeType != 1 || element == window) return element;
-
- var methods = Object.clone(Methods),
- tagName = element.tagName.toUpperCase(), property, value;
-
- // extend methods for specific tags
- if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
-
- for (property in methods) {
- value = methods[property];
- if (Object.isFunction(value) && !(property in element))
- element[property] = value.methodize();
- }
-
- element._extendedByPrototype = Prototype.emptyFunction;
- return element;
-
- }, {
- refresh: function() {
- // extend methods for all tags (Safari doesn't need this)
- if (!Prototype.BrowserFeatures.ElementExtensions) {
- Object.extend(Methods, Element.Methods);
- Object.extend(Methods, Element.Methods.Simulated);
- }
- }
- });
-
- extend.refresh();
- return extend;
-})();
-
-Element.hasAttribute = function(element, attribute) {
- if (element.hasAttribute) return element.hasAttribute(attribute);
- return Element.Methods.Simulated.hasAttribute(element, attribute);
-};
-
-Element.addMethods = function(methods) {
- var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
-
- if (!methods) {
- Object.extend(Form, Form.Methods);
- Object.extend(Form.Element, Form.Element.Methods);
- Object.extend(Element.Methods.ByTag, {
- "FORM": Object.clone(Form.Methods),
- "INPUT": Object.clone(Form.Element.Methods),
- "SELECT": Object.clone(Form.Element.Methods),
- "TEXTAREA": Object.clone(Form.Element.Methods)
- });
- }
-
- if (arguments.length == 2) {
- var tagName = methods;
- methods = arguments[1];
- }
-
- if (!tagName) Object.extend(Element.Methods, methods || { });
- else {
- if (Object.isArray(tagName)) tagName.each(extend);
- else extend(tagName);
- }
-
- function extend(tagName) {
- tagName = tagName.toUpperCase();
- if (!Element.Methods.ByTag[tagName])
- Element.Methods.ByTag[tagName] = { };
- Object.extend(Element.Methods.ByTag[tagName], methods);
- }
-
- function copy(methods, destination, onlyIfAbsent) {
- onlyIfAbsent = onlyIfAbsent || false;
- for (var property in methods) {
- var value = methods[property];
- if (!Object.isFunction(value)) continue;
- if (!onlyIfAbsent || !(property in destination))
- destination[property] = value.methodize();
- }
- }
-
- function findDOMClass(tagName) {
- var klass;
- var trans = {
- "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
- "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
- "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
- "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
- "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
- "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
- "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
- "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
- "FrameSet", "IFRAME": "IFrame"
- };
- if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
- if (window[klass]) return window[klass];
- klass = 'HTML' + tagName + 'Element';
- if (window[klass]) return window[klass];
- klass = 'HTML' + tagName.capitalize() + 'Element';
- if (window[klass]) return window[klass];
-
- window[klass] = { };
- window[klass].prototype = document.createElement(tagName)['__proto__'];
- return window[klass];
- }
-
- if (F.ElementExtensions) {
- copy(Element.Methods, HTMLElement.prototype);
- copy(Element.Methods.Simulated, HTMLElement.prototype, true);
- }
-
- if (F.SpecificElementExtensions) {
- for (var tag in Element.Methods.ByTag) {
- var klass = findDOMClass(tag);
- if (Object.isUndefined(klass)) continue;
- copy(T[tag], klass.prototype);
- }
- }
-
- Object.extend(Element, Element.Methods);
- delete Element.ByTag;
-
- if (Element.extend.refresh) Element.extend.refresh();
- Element.cache = { };
-};
-
-document.viewport = {
- getDimensions: function() {
- var dimensions = { }, B = Prototype.Browser;
- $w('width height').each(function(d) {
- var D = d.capitalize();
- if (B.WebKit && !document.evaluate) {
- // Safari <3.0 needs self.innerWidth/Height
- dimensions[d] = self['inner' + D];
- } else if (B.Opera && parseFloat(window.opera.version()) < 9.5) {
- // Opera <9.5 needs document.body.clientWidth/Height
- dimensions[d] = document.body['client' + D]
- } else {
- dimensions[d] = document.documentElement['client' + D];
- }
- });
- return dimensions;
- },
-
- getWidth: function() {
- return this.getDimensions().width;
- },
-
- getHeight: function() {
- return this.getDimensions().height;
- },
-
- getScrollOffsets: function() {
- return Element._returnOffset(
- window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
- window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
- }
-};
-/* Portions of the Selector class are derived from Jack Slocum's DomQuery,
- * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style
- * license. Please see http://www.yui-ext.com/ for more information. */
-
-var Selector = Class.create({
- initialize: function(expression) {
- this.expression = expression.strip();
-
- if (this.shouldUseSelectorsAPI()) {
- this.mode = 'selectorsAPI';
- } else if (this.shouldUseXPath()) {
- this.mode = 'xpath';
- this.compileXPathMatcher();
- } else {
- this.mode = "normal";
- this.compileMatcher();
- }
-
- },
-
- shouldUseXPath: function() {
- if (!Prototype.BrowserFeatures.XPath) return false;
-
- var e = this.expression;
-
- // Safari 3 chokes on :*-of-type and :empty
- if (Prototype.Browser.WebKit &&
- (e.include("-of-type") || e.include(":empty")))
- return false;
-
- // XPath can't do namespaced attributes, nor can it read
- // the "checked" property from DOM nodes
- if ((/(\[[\w-]*?:|:checked)/).test(e))
- return false;
-
- return true;
- },
-
- shouldUseSelectorsAPI: function() {
- if (!Prototype.BrowserFeatures.SelectorsAPI) return false;
-
- if (!Selector._div) Selector._div = new Element('div');
-
- // Make sure the browser treats the selector as valid. Test on an
- // isolated element to minimize cost of this check.
- try {
- Selector._div.querySelector(this.expression);
- } catch(e) {
- return false;
- }
-
- return true;
- },
-
- compileMatcher: function() {
- var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
- c = Selector.criteria, le, p, m;
-
- if (Selector._cache[e]) {
- this.matcher = Selector._cache[e];
- return;
- }
-
- this.matcher = ["this.matcher = function(root) {",
- "var r = root, h = Selector.handlers, c = false, n;"];
-
- while (e && le != e && (/\S/).test(e)) {
- le = e;
- for (var i in ps) {
- p = ps[i];
- if (m = e.match(p)) {
- this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
- new Template(c[i]).evaluate(m));
- e = e.replace(m[0], '');
- break;
- }
- }
- }
-
- this.matcher.push("return h.unique(n);\n}");
- eval(this.matcher.join('\n'));
- Selector._cache[this.expression] = this.matcher;
- },
-
- compileXPathMatcher: function() {
- var e = this.expression, ps = Selector.patterns,
- x = Selector.xpath, le, m;
-
- if (Selector._cache[e]) {
- this.xpath = Selector._cache[e]; return;
- }
-
- this.matcher = ['.//*'];
- while (e && le != e && (/\S/).test(e)) {
- le = e;
- for (var i in ps) {
- if (m = e.match(ps[i])) {
- this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
- new Template(x[i]).evaluate(m));
- e = e.replace(m[0], '');
- break;
- }
- }
- }
-
- this.xpath = this.matcher.join('');
- Selector._cache[this.expression] = this.xpath;
- },
-
- findElements: function(root) {
- root = root || document;
- var e = this.expression, results;
-
- switch (this.mode) {
- case 'selectorsAPI':
- // querySelectorAll queries document-wide, then filters to descendants
- // of the context element. That's not what we want.
- // Add an explicit context to the selector if necessary.
- if (root !== document) {
- var oldId = root.id, id = $(root).identify();
-
- // https://jira.jboss.org/jira/browse/RF-5416
- e = "#" + id.replace(/:/g, '\\:') + " " + e
- //e = "#" + id + " " + e;
- }
-
- results = $A(root.querySelectorAll(e)).map(Element.extend);
- root.id = oldId;
-
- return results;
- case 'xpath':
- return document._getElementsByXPath(this.xpath, root);
- default:
- return this.matcher(root);
- }
- },
-
- match: function(element) {
- this.tokens = [];
-
- var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
- var le, p, m;
-
- while (e && le !== e && (/\S/).test(e)) {
- le = e;
- for (var i in ps) {
- p = ps[i];
- if (m = e.match(p)) {
- // use the Selector.assertions methods unless the selector
- // is too complex.
- if (as[i]) {
- this.tokens.push([i, Object.clone(m)]);
- e = e.replace(m[0], '');
- } else {
- // reluctantly do a document-wide search
- // and look for a match in the array
- return this.findElements(document).include(element);
- }
- }
- }
- }
-
- var match = true, name, matches;
- for (var i = 0, token; token = this.tokens[i]; i++) {
- name = token[0], matches = token[1];
- if (!Selector.assertions[name](element, matches)) {
- match = false; break;
- }
- }
-
- return match;
- },
-
- toString: function() {
- return this.expression;
- },
-
- inspect: function() {
- return "#<Selector:" + this.expression.inspect() + ">";
- }
-});
-
-Object.extend(Selector, {
- _cache: { },
-
- xpath: {
- descendant: "//*",
- child: "/*",
- adjacent: "/following-sibling::*[1]",
- laterSibling: '/following-sibling::*',
- tagName: function(m) {
- if (m[1] == '*') return '';
- return "[local-name()='" + m[1].toLowerCase() +
- "' or local-name()='" + m[1].toUpperCase() + "']";
- },
- className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
- id: "[@id='#{1}']",
- attrPresence: function(m) {
- m[1] = m[1].toLowerCase();
- return new Template("[@#{1}]").evaluate(m);
- },
- attr: function(m) {
- m[1] = m[1].toLowerCase();
- m[3] = m[5] || m[6];
- return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
- },
- pseudo: function(m) {
- var h = Selector.xpath.pseudos[m[1]];
- if (!h) return '';
- if (Object.isFunction(h)) return h(m);
- return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
- },
- operators: {
- '=': "[@#{1}='#{3}']",
- '!=': "[@#{1}!='#{3}']",
- '^=': "[starts-with(@#{1}, '#{3}')]",
- '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
- '*=': "[contains(@#{1}, '#{3}')]",
- '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
- '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
- },
- pseudos: {
- 'first-child': '[not(preceding-sibling::*)]',
- 'last-child': '[not(following-sibling::*)]',
- 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
- 'empty': "[count(*) = 0 and (count(text()) = 0)]",
- 'checked': "[@checked]",
- 'disabled': "[(@disabled) and (@type!='hidden')]",
- 'enabled': "[not(@disabled) and (@type!='hidden')]",
- 'not': function(m) {
- var e = m[6], p = Selector.patterns,
- x = Selector.xpath, le, v;
-
- var exclusion = [];
- while (e && le != e && (/\S/).test(e)) {
- le = e;
- for (var i in p) {
- if (m = e.match(p[i])) {
- v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
- exclusion.push("(" + v.substring(1, v.length - 1) + ")");
- e = e.replace(m[0], '');
- break;
- }
- }
- }
- return "[not(" + exclusion.join(" and ") + ")]";
- },
- 'nth-child': function(m) {
- return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
- },
- 'nth-last-child': function(m) {
- return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
- },
- 'nth-of-type': function(m) {
- return Selector.xpath.pseudos.nth("position() ", m);
- },
- 'nth-last-of-type': function(m) {
- return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
- },
- 'first-of-type': function(m) {
- m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
- },
- 'last-of-type': function(m) {
- m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
- },
- 'only-of-type': function(m) {
- var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
- },
- nth: function(fragment, m) {
- var mm, formula = m[6], predicate;
- if (formula == 'even') formula = '2n+0';
- if (formula == 'odd') formula = '2n+1';
- if (mm = formula.match(/^(\d+)$/)) // digit only
- return '[' + fragment + "= " + mm[1] + ']';
- if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
- if (mm[1] == "-") mm[1] = -1;
- var a = mm[1] ? Number(mm[1]) : 1;
- var b = mm[2] ? Number(mm[2]) : 0;
- predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
- "((#{fragment} - #{b}) div #{a} >= 0)]";
- return new Template(predicate).evaluate({
- fragment: fragment, a: a, b: b });
- }
- }
- }
- },
-
- criteria: {
- tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
- className: 'n = h.className(n, r, "#{1}", c); c = false;',
- id: 'n = h.id(n, r, "#{1}", c); c = false;',
- attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
- attr: function(m) {
- m[3] = (m[5] || m[6]);
- return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
- },
- pseudo: function(m) {
- if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
- return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
- },
- descendant: 'c = "descendant";',
- child: 'c = "child";',
- adjacent: 'c = "adjacent";',
- laterSibling: 'c = "laterSibling";'
- },
-
- patterns: {
- // combinators must be listed first
- // (and descendant needs to be last combinator)
- laterSibling: /^\s*~\s*/,
- child: /^\s*>\s*/,
- adjacent: /^\s*\+\s*/,
- descendant: /^\s/,
-
- // selectors follow
- tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
- id: /^#([\w\-\*]+)(\b|$)/,
- className: /^\.([\w\-\*]+)(\b|$)/,
- pseudo:
-/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
- attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
- attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
- },
-
- // for Selector.match and Element#match
- assertions: {
- tagName: function(element, matches) {
- return matches[1].toUpperCase() == element.tagName.toUpperCase();
- },
-
- className: function(element, matches) {
- return Element.hasClassName(element, matches[1]);
- },
-
- id: function(element, matches) {
- return element.id === matches[1];
- },
-
- attrPresence: function(element, matches) {
- return Element.hasAttribute(element, matches[1]);
- },
-
- attr: function(element, matches) {
- var nodeValue = Element.readAttribute(element, matches[1]);
- return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
- }
- },
-
- handlers: {
- // UTILITY FUNCTIONS
- // joins two collections
- concat: function(a, b) {
- for (var i = 0, node; node = b[i]; i++)
- a.push(node);
- return a;
- },
-
- // marks an array of nodes for counting
- mark: function(nodes) {
- var _true = Prototype.emptyFunction;
- for (var i = 0, node; node = nodes[i]; i++)
- node._countedByPrototype = _true;
- return nodes;
- },
-
- unmark: function(nodes) {
- for (var i = 0, node; node = nodes[i]; i++)
- node._countedByPrototype = undefined;
- return nodes;
- },
-
- // mark each child node with its position (for nth calls)
- // "ofType" flag indicates whether we're indexing for nth-of-type
- // rather than nth-child
- index: function(parentNode, reverse, ofType) {
- parentNode._countedByPrototype = Prototype.emptyFunction;
- if (reverse) {
- for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
- var node = nodes[i];
- if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
- }
- } else {
- for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
- if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
- }
- },
-
- // filters out duplicates and extends all nodes
- unique: function(nodes) {
- if (nodes.length == 0) return nodes;
- var results = [], n;
- for (var i = 0, l = nodes.length; i < l; i++)
- if (!(n = nodes[i])._countedByPrototype) {
- n._countedByPrototype = Prototype.emptyFunction;
- results.push(Element.extend(n));
- }
- return Selector.handlers.unmark(results);
- },
-
- // COMBINATOR FUNCTIONS
- descendant: function(nodes) {
- var h = Selector.handlers;
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- h.concat(results, node.getElementsByTagName('*'));
- return results;
- },
-
- child: function(nodes) {
- var h = Selector.handlers;
- for (var i = 0, results = [], node; node = nodes[i]; i++) {
- for (var j = 0, child; child = node.childNodes[j]; j++)
- if (child.nodeType == 1 && child.tagName != '!') results.push(child);
- }
- return results;
- },
-
- adjacent: function(nodes) {
- for (var i = 0, results = [], node; node = nodes[i]; i++) {
- var next = this.nextElementSibling(node);
- if (next) results.push(next);
- }
- return results;
- },
-
- laterSibling: function(nodes) {
- var h = Selector.handlers;
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- h.concat(results, Element.nextSiblings(node));
- return results;
- },
-
- nextElementSibling: function(node) {
- while (node = node.nextSibling)
- if (node.nodeType == 1) return node;
- return null;
- },
-
- previousElementSibling: function(node) {
- while (node = node.previousSibling)
- if (node.nodeType == 1) return node;
- return null;
- },
-
- // TOKEN FUNCTIONS
- tagName: function(nodes, root, tagName, combinator) {
- var uTagName = tagName.toUpperCase();
- var results = [], h = Selector.handlers;
- if (nodes) {
- if (combinator) {
- // fastlane for ordinary descendant combinators
- if (combinator == "descendant") {
- for (var i = 0, node; node = nodes[i]; i++)
- h.concat(results, node.getElementsByTagName(tagName));
- return results;
- } else nodes = this[combinator](nodes);
- if (tagName == "*") return nodes;
- }
- for (var i = 0, node; node = nodes[i]; i++)
- if (node.tagName.toUpperCase() === uTagName) results.push(node);
- return results;
- } else return root.getElementsByTagName(tagName);
- },
-
- id: function(nodes, root, id, combinator) {
- var targetNode = $(id), h = Selector.handlers;
- if (!targetNode) return [];
- if (!nodes && root == document) return [targetNode];
- if (nodes) {
- if (combinator) {
- if (combinator == 'child') {
- for (var i = 0, node; node = nodes[i]; i++)
- if (targetNode.parentNode == node) return [targetNode];
- } else if (combinator == 'descendant') {
- for (var i = 0, node; node = nodes[i]; i++)
- if (Element.descendantOf(targetNode, node)) return [targetNode];
- } else if (combinator == 'adjacent') {
- for (var i = 0, node; node = nodes[i]; i++)
- if (Selector.handlers.previousElementSibling(targetNode) == node)
- return [targetNode];
- } else nodes = h[combinator](nodes);
- }
- for (var i = 0, node; node = nodes[i]; i++)
- if (node == targetNode) return [targetNode];
- return [];
- }
- return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
- },
-
- className: function(nodes, root, className, combinator) {
- if (nodes && combinator) nodes = this[combinator](nodes);
- return Selector.handlers.byClassName(nodes, root, className);
- },
-
- byClassName: function(nodes, root, className) {
- if (!nodes) nodes = Selector.handlers.descendant([root]);
- var needle = ' ' + className + ' ';
- for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
- nodeClassName = node.className;
- if (nodeClassName.length == 0) continue;
- if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
- results.push(node);
- }
- return results;
- },
-
- attrPresence: function(nodes, root, attr, combinator) {
- if (!nodes) nodes = root.getElementsByTagName("*");
- if (nodes && combinator) nodes = this[combinator](nodes);
- var results = [];
- for (var i = 0, node; node = nodes[i]; i++)
- if (Element.hasAttribute(node, attr)) results.push(node);
- return results;
- },
-
- attr: function(nodes, root, attr, value, operator, combinator) {
- if (!nodes) nodes = root.getElementsByTagName("*");
- if (nodes && combinator) nodes = this[combinator](nodes);
- var handler = Selector.operators[operator], results = [];
- for (var i = 0, node; node = nodes[i]; i++) {
- var nodeValue = Element.readAttribute(node, attr);
- if (nodeValue === null) continue;
- if (handler(nodeValue, value)) results.push(node);
- }
- return results;
- },
-
- pseudo: function(nodes, name, value, root, combinator) {
- if (nodes && combinator) nodes = this[combinator](nodes);
- if (!nodes) nodes = root.getElementsByTagName("*");
- return Selector.pseudos[name](nodes, value, root);
- }
- },
-
- pseudos: {
- 'first-child': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++) {
- if (Selector.handlers.previousElementSibling(node)) continue;
- results.push(node);
- }
- return results;
- },
- 'last-child': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++) {
- if (Selector.handlers.nextElementSibling(node)) continue;
- results.push(node);
- }
- return results;
- },
- 'only-child': function(nodes, value, root) {
- var h = Selector.handlers;
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
- results.push(node);
- return results;
- },
- 'nth-child': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, formula, root);
- },
- 'nth-last-child': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, formula, root, true);
- },
- 'nth-of-type': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, formula, root, false, true);
- },
- 'nth-last-of-type': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, formula, root, true, true);
- },
- 'first-of-type': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, "1", root, false, true);
- },
- 'last-of-type': function(nodes, formula, root) {
- return Selector.pseudos.nth(nodes, "1", root, true, true);
- },
- 'only-of-type': function(nodes, formula, root) {
- var p = Selector.pseudos;
- return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
- },
-
- // handles the an+b logic
- getIndices: function(a, b, total) {
- if (a == 0) return b > 0 ? [b] : [];
- return $R(1, total).inject([], function(memo, i) {
- if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
- return memo;
- });
- },
-
- // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
- nth: function(nodes, formula, root, reverse, ofType) {
- if (nodes.length == 0) return [];
- if (formula == 'even') formula = '2n+0';
- if (formula == 'odd') formula = '2n+1';
- var h = Selector.handlers, results = [], indexed = [], m;
- h.mark(nodes);
- for (var i = 0, node; node = nodes[i]; i++) {
- if (!node.parentNode._countedByPrototype) {
- h.index(node.parentNode, reverse, ofType);
- indexed.push(node.parentNode);
- }
- }
- if (formula.match(/^\d+$/)) { // just a number
- formula = Number(formula);
- for (var i = 0, node; node = nodes[i]; i++)
- if (node.nodeIndex == formula) results.push(node);
- } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
- if (m[1] == "-") m[1] = -1;
- var a = m[1] ? Number(m[1]) : 1;
- var b = m[2] ? Number(m[2]) : 0;
- var indices = Selector.pseudos.getIndices(a, b, nodes.length);
- for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
- for (var j = 0; j < l; j++)
- if (node.nodeIndex == indices[j]) results.push(node);
- }
- }
- h.unmark(nodes);
- h.unmark(indexed);
- return results;
- },
-
- 'empty': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++) {
- // IE treats comments as element nodes
- if (node.tagName == '!' || node.firstChild) continue;
- results.push(node);
- }
- return results;
- },
-
- 'not': function(nodes, selector, root) {
- var h = Selector.handlers, selectorType, m;
- var exclusions = new Selector(selector).findElements(root);
- h.mark(exclusions);
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (!node._countedByPrototype) results.push(node);
- h.unmark(exclusions);
- return results;
- },
-
- 'enabled': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (!node.disabled && (!node.type || node.type !== 'hidden'))
- results.push(node);
- return results;
- },
-
- 'disabled': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (node.disabled) results.push(node);
- return results;
- },
-
- 'checked': function(nodes, value, root) {
- for (var i = 0, results = [], node; node = nodes[i]; i++)
- if (node.checked) results.push(node);
- return results;
- }
- },
-
- operators: {
- '=': function(nv, v) { return nv == v; },
- '!=': function(nv, v) { return nv != v; },
- '^=': function(nv, v) { return nv == v || nv && nv.startsWith(v); },
- '$=': function(nv, v) { return nv == v || nv && nv.endsWith(v); },
- '*=': function(nv, v) { return nv == v || nv && nv.include(v); },
- '$=': function(nv, v) { return nv.endsWith(v); },
- '*=': function(nv, v) { return nv.include(v); },
- '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
- '|=': function(nv, v) { return ('-' + (nv || "").toUpperCase() +
- '-').include('-' + (v || "").toUpperCase() + '-'); }
- },
-
- split: function(expression) {
- var expressions = [];
- expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
- expressions.push(m[1].strip());
- });
- return expressions;
- },
-
- matchElements: function(elements, expression) {
- var matches = $$(expression), h = Selector.handlers;
- h.mark(matches);
- for (var i = 0, results = [], element; element = elements[i]; i++)
- if (element._countedByPrototype) results.push(element);
- h.unmark(matches);
- return results;
- },
-
- findElement: function(elements, expression, index) {
- if (Object.isNumber(expression)) {
- index = expression; expression = false;
- }
- return Selector.matchElements(elements, expression || '*')[index || 0];
- },
-
- findChildElements: function(element, expressions) {
- expressions = Selector.split(expressions.join(','));
- var results = [], h = Selector.handlers;
- for (var i = 0, l = expressions.length, selector; i < l; i++) {
- selector = new Selector(expressions[i].strip());
- h.concat(results, selector.findElements(element));
- }
- return (l > 1) ? h.unique(results) : results;
- }
-});
-
-if (Prototype.Browser.IE) {
- Object.extend(Selector.handlers, {
- // IE returns comment nodes on getElementsByTagName("*").
- // Filter them out.
- concat: function(a, b) {
- for (var i = 0, node; node = b[i]; i++)
- if (node.tagName !== "!") a.push(node);
- return a;
- },
-
- // IE improperly serializes _countedByPrototype in (inner|outer)HTML.
- unmark: function(nodes) {
- for (var i = 0, node; node = nodes[i]; i++)
- node.removeAttribute('_countedByPrototype');
- return nodes;
- }
- });
-}
-
-function $$() {
- return Selector.findChildElements(document, $A(arguments));
-}
-var Form = {
- reset: function(form) {
- $(form).reset();
- return form;
- },
-
- serializeElements: function(elements, options) {
- if (typeof options != 'object') options = { hash: !!options };
- else if (Object.isUndefined(options.hash)) options.hash = true;
- var key, value, submitted = false, submit = options.submit;
-
- var data = elements.inject({ }, function(result, element) {
- if (!element.disabled && element.name) {
- key = element.name; value = $(element).getValue();
- if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
- submit !== false && (!submit || key == submit) && (submitted = true)))) {
- if (key in result) {
- // a key is already present; construct an array of values
- if (!Object.isArray(result[key])) result[key] = [result[key]];
- result[key].push(value);
- }
- else result[key] = value;
- }
- }
- return result;
- });
-
- return options.hash ? data : Object.toQueryString(data);
- }
-};
-
-Form.Methods = {
- serialize: function(form, options) {
- return Form.serializeElements(Form.getElements(form), options);
- },
-
- getElements: function(form) {
- return $A($(form).getElementsByTagName('*')).inject([],
- function(elements, child) {
- if (Form.Element.Serializers[child.tagName.toLowerCase()])
- elements.push(Element.extend(child));
- return elements;
- }
- );
- },
-
- getInputs: function(form, typeName, name) {
- form = $(form);
- var inputs = form.getElementsByTagName('input');
-
- if (!typeName && !name) return $A(inputs).map(Element.extend);
-
- for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
- var input = inputs[i];
- if ((typeName && input.type != typeName) || (name && input.name != name))
- continue;
- matchingInputs.push(Element.extend(input));
- }
-
- return matchingInputs;
- },
-
- disable: function(form) {
- form = $(form);
- Form.getElements(form).invoke('disable');
- return form;
- },
-
- enable: function(form) {
- form = $(form);
- Form.getElements(form).invoke('enable');
- return form;
- },
-
- findFirstElement: function(form) {
- var elements = $(form).getElements().findAll(function(element) {
- return 'hidden' != element.type && !element.disabled;
- });
- var firstByIndex = elements.findAll(function(element) {
- return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
- }).sortBy(function(element) { return element.tabIndex }).first();
-
- return firstByIndex ? firstByIndex : elements.find(function(element) {
- return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
- });
- },
-
- focusFirstElement: function(form) {
- form = $(form);
- form.findFirstElement().activate();
- return form;
- },
-
- request: function(form, options) {
- form = $(form), options = Object.clone(options || { });
-
- var params = options.parameters, action = form.readAttribute('action') || '';
- if (action.blank()) action = window.location.href;
- options.parameters = form.serialize(true);
-
- if (params) {
- if (Object.isString(params)) params = params.toQueryParams();
- Object.extend(options.parameters, params);
- }
-
- if (form.hasAttribute('method') && !options.method)
- options.method = form.method;
-
- return new Ajax.Request(action, options);
- }
-};
-
-/*--------------------------------------------------------------------------*/
-
-Form.Element = {
- focus: function(element) {
- $(element).focus();
- return element;
- },
-
- select: function(element) {
- $(element).select();
- return element;
- }
-};
-
-Form.Element.Methods = {
- serialize: function(element) {
- element = $(element);
- if (!element.disabled && element.name) {
- var value = element.getValue();
- if (value != undefined) {
- var pair = { };
- pair[element.name] = value;
- return Object.toQueryString(pair);
- }
- }
- return '';
- },
-
- getValue: function(element) {
- element = $(element);
- var method = element.tagName.toLowerCase();
- return Form.Element.Serializers[method](element);
- },
-
- setValue: function(element, value) {
- element = $(element);
- var method = element.tagName.toLowerCase();
- Form.Element.Serializers[method](element, value);
- return element;
- },
-
- clear: function(element) {
- $(element).value = '';
- return element;
- },
-
- present: function(element) {
- return $(element).value != '';
- },
-
- activate: function(element) {
- element = $(element);
- try {
- element.focus();
- if (element.select && (element.tagName.toLowerCase() != 'input' ||
- !['button', 'reset', 'submit'].include(element.type)))
- element.select();
- } catch (e) { }
- return element;
- },
-
- disable: function(element) {
- element = $(element);
- element.disabled = true;
- return element;
- },
-
- enable: function(element) {
- element = $(element);
- element.disabled = false;
- return element;
- }
-};
-
-/*--------------------------------------------------------------------------*/
-
-var Field = Form.Element;
-var $F = Form.Element.Methods.getValue;
-
-/*--------------------------------------------------------------------------*/
-
-Form.Element.Serializers = {
- input: function(element, value) {
- switch (element.type.toLowerCase()) {
- case 'checkbox':
- case 'radio':
- return Form.Element.Serializers.inputSelector(element, value);
- default:
- return Form.Element.Serializers.textarea(element, value);
- }
- },
-
- inputSelector: function(element, value) {
- if (Object.isUndefined(value)) return element.checked ? element.value : null;
- else element.checked = !!value;
- },
-
- textarea: function(element, value) {
- if (Object.isUndefined(value)) return element.value;
- else element.value = value;
- },
-
- select: function(element, value) {
- if (Object.isUndefined(value))
- return this[element.type == 'select-one' ?
- 'selectOne' : 'selectMany'](element);
- else {
- var opt, currentValue, single = !Object.isArray(value);
- for (var i = 0, length = element.length; i < length; i++) {
- opt = element.options[i];
- currentValue = this.optionValue(opt);
- if (single) {
- if (currentValue == value) {
- opt.selected = true;
- return;
- }
- }
- else opt.selected = value.include(currentValue);
- }
- }
- },
-
- selectOne: function(element) {
- var index = element.selectedIndex;
- return index >= 0 ? this.optionValue(element.options[index]) : null;
- },
-
- selectMany: function(element) {
- var values, length = element.length;
- if (!length) return null;
-
- for (var i = 0, values = []; i < length; i++) {
- var opt = element.options[i];
- if (opt.selected) values.push(this.optionValue(opt));
- }
- return values;
- },
-
- optionValue: function(opt) {
- // extend element because hasAttribute may not be native
- return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
- }
-};
-
-/*--------------------------------------------------------------------------*/
-
-Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
- initialize: function($super, element, frequency, callback) {
- $super(callback, frequency);
- this.element = $(element);
- this.lastValue = this.getValue();
- },
-
- execute: function() {
- var value = this.getValue();
- if (Object.isString(this.lastValue) && Object.isString(value) ?
- this.lastValue != value : String(this.lastValue) != String(value)) {
- this.callback(this.element, value);
- this.lastValue = value;
- }
- }
-});
-
-Form.Element.Observer = Class.create(Abstract.TimedObserver, {
- getValue: function() {
- return Form.Element.getValue(this.element);
- }
-});
-
-Form.Observer = Class.create(Abstract.TimedObserver, {
- getValue: function() {
- return Form.serialize(this.element);
- }
-});
-
-/*--------------------------------------------------------------------------*/
-
-Abstract.EventObserver = Class.create({
- initialize: function(element, callback) {
- this.element = $(element);
- this.callback = callback;
-
- this.lastValue = this.getValue();
- if (this.element.tagName.toLowerCase() == 'form')
- this.registerFormCallbacks();
- else
- this.registerCallback(this.element);
- },
-
- onElementEvent: function() {
- var value = this.getValue();
- if (this.lastValue != value) {
- this.callback(this.element, value);
- this.lastValue = value;
- }
- },
-
- registerFormCallbacks: function() {
- Form.getElements(this.element).each(this.registerCallback, this);
- },
-
- registerCallback: function(element) {
- if (element.type) {
- switch (element.type.toLowerCase()) {
- case 'checkbox':
- case 'radio':
- Event.observe(element, 'click', this.onElementEvent.bind(this));
- break;
- default:
- Event.observe(element, 'change', this.onElementEvent.bind(this));
- break;
- }
- }
- }
-});
-
-Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
- getValue: function() {
- return Form.Element.getValue(this.element);
- }
-});
-
-Form.EventObserver = Class.create(Abstract.EventObserver, {
- getValue: function() {
- return Form.serialize(this.element);
- }
-});
-if (!window.Event) var Event = { };
-
-Object.extend(Event, {
- KEY_BACKSPACE: 8,
- KEY_TAB: 9,
- KEY_RETURN: 13,
- KEY_ESC: 27,
- KEY_LEFT: 37,
- KEY_UP: 38,
- KEY_RIGHT: 39,
- KEY_DOWN: 40,
- KEY_DELETE: 46,
- KEY_HOME: 36,
- KEY_END: 35,
- KEY_PAGEUP: 33,
- KEY_PAGEDOWN: 34,
- KEY_INSERT: 45,
-
- cache: { },
-
- relatedTarget: function(event) {
- var element;
- switch(event.type) {
- case 'mouseover': element = event.fromElement; break;
- case 'mouseout': element = event.toElement; break;
- default: return null;
- }
- return Element.extend(element);
- }
-});
-
-Event.Methods = (function() {
- var isButton;
-
- if (Prototype.Browser.IE) {
- var buttonMap = { 0: 1, 1: 4, 2: 2 };
- isButton = function(event, code) {
- return event.button == buttonMap[code];
- };
-
- } else if (Prototype.Browser.WebKit) {
- isButton = function(event, code) {
- switch (code) {
- case 0: return event.which == 1 && !event.metaKey;
- case 1: return event.which == 1 && event.metaKey;
- default: return false;
- }
- };
-
- } else {
- isButton = function(event, code) {
- return event.which ? (event.which === code + 1) : (event.button === code);
- };
- }
-
- return {
- isLeftClick: function(event) { return isButton(event, 0) },
- isMiddleClick: function(event) { return isButton(event, 1) },
- isRightClick: function(event) { return isButton(event, 2) },
-
- element: function(event) {
- event = Event.extend(event);
-
- var node = event.target,
- type = event.type,
- currentTarget = event.currentTarget;
-
- if (currentTarget && currentTarget.tagName) {
- // Firefox screws up the "click" event when moving between radio buttons
- // via arrow keys. It also screws up the "load" and "error" events on images,
- // reporting the document as the target instead of the original image.
- if (type === 'load' || type === 'error' ||
- (type === 'click' && currentTarget.tagName.toLowerCase() === 'input'
- && currentTarget.type === 'radio'))
- node = currentTarget;
- }
- if (node.nodeType == Node.TEXT_NODE) node = node.parentNode;
- return Element.extend(node);
- },
-
- findElement: function(event, expression) {
- var element = Event.element(event);
- if (!expression) return element;
- var elements = [element].concat(element.ancestors());
- return Selector.findElement(elements, expression, 0);
- },
-
- pointer: function(event) {
- var docElement = document.documentElement,
- body = document.body || { scrollLeft: 0, scrollTop: 0 };
- return {
- x: event.pageX || (event.clientX +
- (docElement.scrollLeft || body.scrollLeft) -
- (docElement.clientLeft || 0)),
- y: event.pageY || (event.clientY +
- (docElement.scrollTop || body.scrollTop) -
- (docElement.clientTop || 0))
- };
- },
-
- pointerX: function(event) { return Event.pointer(event).x },
- pointerY: function(event) { return Event.pointer(event).y },
-
- stop: function(event) {
- Event.extend(event);
- event.preventDefault();
- event.stopPropagation();
- event.stopped = true;
- }
- };
-})();
-
-Event.extend = (function() {
- var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
- m[name] = Event.Methods[name].methodize();
- return m;
- });
-
- if (Prototype.Browser.IE) {
- Object.extend(methods, {
- stopPropagation: function() { this.cancelBubble = true },
- preventDefault: function() { this.returnValue = false },
- inspect: function() { return "[object Event]" }
- });
-
- return function(event) {
- if (!event) return false;
- if (event._extendedByPrototype) return event;
-
- event._extendedByPrototype = Prototype.emptyFunction;
- var pointer = Event.pointer(event);
- Object.extend(event, {
- target: event.srcElement,
- relatedTarget: Event.relatedTarget(event),
- pageX: pointer.x,
- pageY: pointer.y
- });
- return Object.extend(event, methods);
- };
-
- } else {
- Event.prototype = Event.prototype || document.createEvent("HTMLEvents")['__proto__'];
- Object.extend(Event.prototype, methods);
- return Prototype.K;
- }
-})();
-
-Object.extend(Event, (function() {
- var cache = Event.cache;
-
- function getEventID(element) {
- if (element._prototypeEventID) return element._prototypeEventID[0];
- arguments.callee.id = arguments.callee.id || 1;
- return element._prototypeEventID = [++arguments.callee.id];
- }
-
- function getDOMEventName(eventName) {
- if (eventName && eventName.include(':')) return "dataavailable";
- return eventName;
- }
-
- function getCacheForID(id) {
- return cache[id] = cache[id] || { };
- }
-
- function getWrappersForEventName(id, eventName) {
- var c = getCacheForID(id);
- return c[eventName] = c[eventName] || [];
- }
-
- function createWrapper(element, eventName, handler) {
- var id = getEventID(element);
- var c = getWrappersForEventName(id, eventName);
- if (c.pluck("handler").include(handler)) return false;
-
- var wrapper = function(event) {
- if (!Event || !Event.extend ||
- (event.eventName && event.eventName != eventName))
- return false;
-
- Event.extend(event);
- handler.call(element, event);
- };
-
- wrapper.handler = handler;
- c.push(wrapper);
- return wrapper;
- }
-
- function findWrapper(id, eventName, handler) {
- var c = getWrappersForEventName(id, eventName);
- return c.find(function(wrapper) { return wrapper.handler == handler });
- }
-
- function destroyWrapper(id, eventName, handler) {
- var c = getCacheForID(id);
- if (!c[eventName]) return false;
- c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
- }
-
- //commented by Nick for RichFaces
- /*
- function destroyCache() {
- for (var id in cache)
- for (var eventName in cache[id])
- cache[id][eventName] = null;
- }
-
-
- // Internet Explorer needs to remove event handlers on page unload
- // in order to avoid memory leaks.
- if (window.attachEvent) {
- window.attachEvent("onunload", destroyCache);
- }
- */
- //commented
-
- // Safari has a dummy event handler on page unload so that it won't
- // use its bfcache. Safari <= 3.1 has an issue with restoring the "document"
- // object when page is returned to via the back button using its bfcache.
- if (Prototype.Browser.WebKit) {
- window.addEventListener('unload', Prototype.emptyFunction, false);
- }
-
- return {
- //added by Nick for RichFaces
- getDOMEventName: getDOMEventName,
- //added
-
- observe: function(element, eventName, handler) {
- element = $(element);
- var name = getDOMEventName(eventName);
-
- var wrapper = createWrapper(element, eventName, handler);
- if (!wrapper) return element;
-
- if (element.addEventListener) {
- element.addEventListener(name, wrapper, false);
- } else {
- element.attachEvent("on" + name, wrapper);
- }
-
- return element;
- },
-
- stopObserving: function(element, eventName, handler) {
- element = $(element);
- var id = getEventID(element), name = getDOMEventName(eventName);
-
- if (!handler && eventName) {
- getWrappersForEventName(id, eventName).each(function(wrapper) {
- element.stopObserving(eventName, wrapper.handler);
- });
- return element;
-
- } else if (!eventName) {
- Object.keys(getCacheForID(id)).each(function(eventName) {
- element.stopObserving(eventName);
- });
- return element;
- }
-
- var wrapper = findWrapper(id, eventName, handler);
- if (!wrapper) return element;
-
- if (element.removeEventListener) {
- element.removeEventListener(name, wrapper, false);
- } else {
- element.detachEvent("on" + name, wrapper);
- }
-
- destroyWrapper(id, eventName, handler);
-
- return element;
- },
-
- fire: function(element, eventName, memo) {
- element = $(element);
- if (element == document && document.createEvent && !element.dispatchEvent)
- element = document.documentElement;
-
- var event;
- if (document.createEvent) {
- event = document.createEvent("HTMLEvents");
- event.initEvent("dataavailable", true, true);
- } else {
- event = document.createEventObject();
- event.eventType = "ondataavailable";
- }
-
- event.eventName = eventName;
- event.memo = memo || { };
-
- if (document.createEvent) {
- element.dispatchEvent(event);
- } else {
- element.fireEvent(event.eventType, event);
- }
-
- return Event.extend(event);
- }
- };
-})());
-
-Object.extend(Event, Event.Methods);
-
-Element.addMethods({
- fire: Event.fire,
- observe: Event.observe,
- stopObserving: Event.stopObserving
-});
-
-Object.extend(document, {
- fire: Element.Methods.fire.methodize(),
- observe: Element.Methods.observe.methodize(),
- stopObserving: Element.Methods.stopObserving.methodize(),
- loaded: false
-});
-
-(function() {
- /* Support for the DOMContentLoaded event is based on work by Dan Webb,
- Matthias Miller, Dean Edwards and John Resig. */
-
- var timer;
-
- function fireContentLoadedEvent() {
- if (document.loaded) return;
- if (timer) window.clearInterval(timer);
- document.fire("dom:loaded");
- document.loaded = true;
- }
-
- if (document.addEventListener) {
- if (Prototype.Browser.WebKit) {
- timer = window.setInterval(function() {
- if (/loaded|complete/.test(document.readyState))
- fireContentLoadedEvent();
- }, 0);
-
- Event.observe(window, "load", fireContentLoadedEvent);
-
- } else {
- document.addEventListener("DOMContentLoaded",
- fireContentLoadedEvent, false);
- }
-
- } else {
- // added by Pavel Yaschenko // http://jira.jboss.com/jira/browse/RF-3879
-
- // for 1.6.0.3
- if (document.loaded) return;
-
- if (document.readyState != "complete") { // added by Pavel Yaschenko
- document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
- $("__onDOMContentLoaded").onreadystatechange = function() {
- if (this.readyState == "complete") {
- this.onreadystatechange = null;
- fireContentLoadedEvent();
- }
- };
- } // added by Pavel Yaschenko
- }
-})();
-/*------------------------------- DEPRECATED -------------------------------*/
-
-Hash.toQueryString = Object.toQueryString;
-
-var Toggle = { display: Element.toggle };
-
-Element.Methods.childOf = Element.Methods.descendantOf;
-
-var Insertion = {
- Before: function(element, content) {
- return Element.insert(element, {before:content});
- },
-
- Top: function(element, content) {
- return Element.insert(element, {top:content});
- },
-
- Bottom: function(element, content) {
- return Element.insert(element, {bottom:content});
- },
-
- After: function(element, content) {
- return Element.insert(element, {after:content});
- }
-};
-
-var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
-
-// This should be moved to script.aculo.us; notice the deprecated methods
-// further below, that map to the newer Element methods.
-var Position = {
- // set to true if needed, warning: firefox performance problems
- // NOT neeeded for page scrolling, only if draggable contained in
- // scrollable elements
- includeScrollOffsets: false,
-
- // must be called before calling withinIncludingScrolloffset, every time the
- // page is scrolled
- prepare: function() {
- this.deltaX = window.pageXOffset
- || document.documentElement.scrollLeft
- || document.body.scrollLeft
- || 0;
- this.deltaY = window.pageYOffset
- || document.documentElement.scrollTop
- || document.body.scrollTop
- || 0;
- },
-
- // caches x/y coordinate pair to use with overlap
- within: function(element, x, y) {
- if (this.includeScrollOffsets)
- return this.withinIncludingScrolloffsets(element, x, y);
- this.xcomp = x;
- this.ycomp = y;
- this.offset = Element.cumulativeOffset(element);
-
- return (y >= this.offset[1] &&
- y < this.offset[1] + element.offsetHeight &&
- x >= this.offset[0] &&
- x < this.offset[0] + element.offsetWidth);
- },
-
- withinIncludingScrolloffsets: function(element, x, y) {
- var offsetcache = Element.cumulativeScrollOffset(element);
-
- this.xcomp = x + offsetcache[0] - this.deltaX;
- this.ycomp = y + offsetcache[1] - this.deltaY;
- this.offset = Element.cumulativeOffset(element);
-
- return (this.ycomp >= this.offset[1] &&
- this.ycomp < this.offset[1] + element.offsetHeight &&
- this.xcomp >= this.offset[0] &&
- this.xcomp < this.offset[0] + element.offsetWidth);
- },
-
- // within must be called directly before
- overlap: function(mode, element) {
- if (!mode) return 0;
- if (mode == 'vertical')
- return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
- element.offsetHeight;
- if (mode == 'horizontal')
- return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
- element.offsetWidth;
- },
-
- // Deprecation layer -- use newer Element methods now (1.5.2).
-
- cumulativeOffset: Element.Methods.cumulativeOffset,
-
- positionedOffset: Element.Methods.positionedOffset,
-
- absolutize: function(element) {
- Position.prepare();
- return Element.absolutize(element);
- },
-
- relativize: function(element) {
- Position.prepare();
- return Element.relativize(element);
- },
-
- realOffset: Element.Methods.cumulativeScrollOffset,
-
- offsetParent: Element.Methods.getOffsetParent,
-
- page: Element.Methods.viewportOffset,
-
- clone: function(source, target, options) {
- options = options || { };
- return Element.clonePosition(target, source, options);
- }
-};
-
-/*--------------------------------------------------------------------------*/
-
-if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
- function iter(name) {
- return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
- }
-
- instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
- function(element, className) {
- className = className.toString().strip();
- var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
- return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
- } : function(element, className) {
- className = className.toString().strip();
- var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
- if (!classNames && !className) return elements;
-
- var nodes = $(element).getElementsByTagName('*');
- className = ' ' + className + ' ';
-
- for (var i = 0, child, cn; child = nodes[i]; i++) {
- if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
- (classNames && classNames.all(function(name) {
- return !name.toString().blank() && cn.include(' ' + name + ' ');
- }))))
- elements.push(Element.extend(child));
- }
- return elements;
- };
-
- return function(className, parentElement) {
- return $(parentElement || document.body).getElementsByClassName(className);
- };
-}(Element.Methods);
-
-/*--------------------------------------------------------------------------*/
-
-Element.ClassNames = Class.create();
-Element.ClassNames.prototype = {
- initialize: function(element) {
- this.element = $(element);
- },
-
- _each: function(iterator) {
- this.element.className.split(/\s+/).select(function(name) {
- return name.length > 0;
- })._each(iterator);
- },
-
- set: function(className) {
- this.element.className = className;
- },
-
- add: function(classNameToAdd) {
- if (this.include(classNameToAdd)) return;
- this.set($A(this).concat(classNameToAdd).join(' '));
- },
-
- remove: function(classNameToRemove) {
- if (!this.include(classNameToRemove)) return;
- this.set($A(this).without(classNameToRemove).join(' '));
- },
-
- toString: function() {
- return $A(this).join(' ');
- }
-};
-
-Object.extend(Element.ClassNames.prototype, Enumerable);
-
-/*--------------------------------------------------------------------------*/
-
-Element.addMethods();
-//memory-leaks sanitizing code
-if (!window.RichFaces) {
- window.RichFaces = {};
-}
-
-if (!window.RichFaces.Memory) {
- window.RichFaces.Memory = {
-
- nodeCleaners: {},
- componentCleaners: {},
-
- addCleaner: function (name, cleaner) {
- this.nodeCleaners[name] = cleaner;
- },
-
- addComponentCleaner: function (name, cleaner, checker) {
- this.componentCleaners[name] = {cleaner: cleaner, checker: checker};
- },
-
- applyCleaners: function (node, isAjax, componentNodes) {
- for (var name in this.nodeCleaners) {
- this.nodeCleaners[name](node, isAjax);
- }
- for (var name in this.componentCleaners) {
- if (this.componentCleaners[name].checker(node, isAjax))
- componentNodes.push(node);
- }
- },
-
- _clean: function (oldNode, isAjax, componentNodes) {
- if (oldNode) {
- this.applyCleaners(oldNode, isAjax, componentNodes);
-
- //node.all is quicker than recursive traversing
- //window doesn't have "all" attribute
- var all = oldNode.all;
-
- if (all) {
- var counter = 0;
- var length = all.length;
-
- for (var counter = 0; counter < length; counter++ ) {
- this.applyCleaners(all[counter], isAjax, componentNodes);
- }
- } else {
- var node = oldNode.firstChild;
- while (node) {
- this._clean(node, isAjax, componentNodes);
- node = node.nextSibling;
- }
- }
- }
- },
-
- _cleanComponentNodes: function (oldNodes, isAjax) {
- for (var i=0; i<oldNodes.length; i++) {
- var node = oldNodes[i];
- for (var name in this.componentCleaners) {
- this.componentCleaners[name].cleaner(node, isAjax);
- }
- }
- },
-
- clean: function (oldNode, isAjax) {
- var componentNodes = [];
- this._clean(oldNode, isAjax, componentNodes);
- this._cleanComponentNodes(componentNodes, isAjax);
- componentNodes = null;
- }
- };
-
- window.RichFaces.Memory.addComponentCleaner("richfaces", function(node, isAjax) {
- var component = node.component;
- if (component) {
- var destructorName = component["rich:destructor"];
- //destructor name is required to be back-compatible
- if (destructorName) {
- var destructor = component[destructorName];
- if (destructor) {
- destructor.call(component, isAjax);
- }
- }
- }
- }, function(node, isAjax) {
- return (node.component && node.component["rich:destructor"]);
- });
-
- if (window.attachEvent) {
- window.attachEvent("onunload", function() {
- var memory = window.RichFaces.Memory;
- memory.clean(document);
- memory.clean(window);
- });
- }
-}
-
-//
-/**
-* MyFaces compatibility issue
-**/
-Function.prototype.indexOf = function(){
- return -1;
-}
-
-/**
-* Clear children
-**/
-
-Element.clearChildren = function(element) {
- element = $(element);
- while(element.firstChild) {
- element.removeChild(element.firstChild);
- }
- return element;
-};
-/**
- * Detect if element is child of another one
- * @param {DomNode} node
- * @param {DomNode} supposedParent
- */
-Element.isChildOf = function(node, supposedParent){
- while(node && supposedParent !=node) {
- node = node.parentNode;
- }
-
- return supposedParent == node;
-};
-
-if (typeof Node == "undefined") {
- Node = {
- ELEMENT_NODE: 1,
- ATTRIBUTE_NODE: 2,
- TEXT_NODE: 3,
- CDATA_SECTION_NODE: 4,
- ENTITY_REFERENCE_NODE: 5,
- ENTITY_NODE: 6,
- PROCESSING_INSTRUCTION_NODE: 7,
- COMMENT_NODE: 8,
- DOCUMENT_NODE: 9,
- DOCUMENT_TYPE_NODE: 10,
- DOCUMENT_FRAGMENT_NODE: 11,
- NOTATION_NODE: 12
- };
-};
-
-Element.isUninitialized = function(element) {
- if (element) {
- if (element.nodeType == Node.ELEMENT_NODE) {
-
- if (!element.parentNode || element.document && element.document.readyState == "uninitialized") {
- return true;
- } else
- {
- return !Element.descendantOf(element, document.documentElement);
- }
-
- return false;
- }
- }
-};
-
-if (window.RichFaces && window.RichFaces.Memory) {
- window.RichFaces.Memory.addCleaner("prototype", function(node, isAjax) {
- var eventID = node._prototypeEventID ? node._prototypeEventID[0] : undefined;
- if (eventID) {
- var cache = Event.cache[eventID];
-
- for (var eventName in cache) {
- var wrappers = cache[eventName];
- var domEventName = Event.getDOMEventName(eventName);
-
- wrappers.each(function(wrapper) {
- if (node.removeEventListener) {
- node.removeEventListener(domEventName, wrapper, false);
- } else {
- node.detachEvent("on" + domEventName, wrapper);
- }
- });
-
- cache[eventName] = null;
- }
-
- delete Event.cache[eventID];
- }
- });
-}
-
-//
-
-/*
- * Prolog for created Ajax4Jsf library
- */
-if (!window.A4J) { window.A4J= {};}
-
-//if(window.A4J.AJAX && window.A4J.AJAX.XMLHttpRequest) return;
-/*
- * ====================================================================
- * About Sarissa: http://dev.abiss.gr/sarissa
- * ====================================================================
- * Sarissa is an ECMAScript library acting as a cross-browser wrapper for native XML APIs.
- * The library supports Gecko based browsers like Mozilla and Firefox,
- * Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and Opera
- * @author: Copyright 2004-2007 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
- * ====================================================================
- * Licence
- * ====================================================================
- * Sarissa is free software distributed under the GNU GPL version 2 (see <a href="gpl.txt">gpl.txt</a>) or higher,
- * GNU LGPL version 2.1 (see <a href="lgpl.txt">lgpl.txt</a>) or higher and Apache Software License 2.0 or higher
- * (see <a href="asl.txt">asl.txt</a>). This means you can choose one of the three and use that if you like. If
- * you make modifications under the ASL, i would appreciate it if you submitted those.
- * In case your copy of Sarissa does not include the license texts, you may find
- * them online in various formats at <a href="http://www.gnu.org">http://www.gnu.org</a> and
- * <a href="http://www.apache.org">http://www.apache.org</a>.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
- * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
- * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-/**
- * <p>Sarissa is a utility class. Provides "static" methods for DOMDocument,
- * DOM Node serialization to XML strings and other utility goodies.</p>
- * @constructor
- * @static
- */
-function Sarissa(){}
-Sarissa.VERSION = "0.9.9.3";
-Sarissa.PARSED_OK = "Document contains no parsing errors";
-Sarissa.PARSED_EMPTY = "Document is empty";
-Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
-Sarissa.IS_ENABLED_TRANSFORM_NODE = false;
-Sarissa.REMOTE_CALL_FLAG = "gr.abiss.sarissa.REMOTE_CALL_FLAG";
-/** @private */
-Sarissa._sarissa_iNsCounter = 0;
-/** @private */
-Sarissa._SARISSA_IEPREFIX4XSLPARAM = "";
-/** @private */
-Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
-/** @private */
-Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT = Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
-/** @private */
-Sarissa._SARISSA_HAS_DOM_FEATURE = Sarissa._SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
-/** @private */
-Sarissa._SARISSA_IS_MOZ = Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT && Sarissa._SARISSA_HAS_DOM_FEATURE;
-/** @private */
-Sarissa._SARISSA_IS_SAFARI = navigator.userAgent.toLowerCase().indexOf("safari") != -1 || navigator.userAgent.toLowerCase().indexOf("konqueror") != -1;
-/** @private */
-Sarissa._SARISSA_IS_SAFARI_OLD = Sarissa._SARISSA_IS_SAFARI && (parseInt((navigator.userAgent.match(/AppleWebKit\/(\d+)/)||{})[1], 10) < 420);
-/** @private */
-Sarissa._SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
-/** @private */
-Sarissa._SARISSA_IS_OPERA = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
-if(!window.Node || !Node.ELEMENT_NODE){
- Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
-}
-
-//This breaks for(x in o) loops in the old Safari
-if(Sarissa._SARISSA_IS_SAFARI_OLD){
- HTMLHtmlElement = document.createElement("html").constructor;
- Node = HTMLElement = {};
- HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;
- HTMLDocument = Document = document.constructor;
- var x = new DOMParser();
- XMLDocument = x.constructor;
- Element = x.parseFromString("<Single />", "text/xml").documentElement.constructor;
- x = null;
-}
-if(typeof XMLDocument == "undefined" && typeof Document !="undefined"){ XMLDocument = Document; }
-
-// IE initialization
-if(Sarissa._SARISSA_IS_IE){
- // for XSLT parameter names, prefix needed by IE
- Sarissa._SARISSA_IEPREFIX4XSLPARAM = "xsl:";
- // used to store the most recent ProgID available out of the above
- var _SARISSA_DOM_PROGID = "";
- var _SARISSA_XMLHTTP_PROGID = "";
- var _SARISSA_DOM_XMLWRITER = "";
- /**
- * Called when the sarissa.js file is parsed, to pick most recent
- * ProgIDs for IE, then gets destroyed.
- * @memberOf Sarissa
- * @private
- * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
- * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
- */
- Sarissa.pickRecentProgID = function (idList){
- // found progID flag
- var bFound = false, e;
- var o2Store;
- for(var i=0; i < idList.length && !bFound; i++){
- try{
- var oDoc = new ActiveXObject(idList[i]);
- o2Store = idList[i];
- bFound = true;
- }catch (objException){
- // trap; try next progID
- e = objException;
- }
- }
- if (!bFound) {
- throw "Could not retrieve a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
- }
- idList = null;
- return o2Store;
- };
- // pick best available MSXML progIDs
- _SARISSA_DOM_PROGID = null;
- _SARISSA_THREADEDDOM_PROGID = null;
- _SARISSA_XSLTEMPLATE_PROGID = null;
- _SARISSA_XMLHTTP_PROGID = null;
- // commenting the condition out; we need to redefine XMLHttpRequest
- // anyway as IE7 hardcodes it to MSXML3.0 causing version problems
- // between different activex controls
- //if(!window.XMLHttpRequest){
- /**
- * Emulate XMLHttpRequest
- * @constructor
- */
- XMLHttpRequest = function() {
- if(!_SARISSA_XMLHTTP_PROGID){
- _SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
- }
- return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
- };
- //}
- // we dont need this anymore
- //============================================
- // Factory methods (IE)
- //============================================
- // see non-IE version
- Sarissa.getDomDocument = function(sUri, sName){
- if(!_SARISSA_DOM_PROGID){
- _SARISSA_DOM_PROGID = Sarissa.pickRecentProgID(["Msxml2.DOMDocument.6.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]);
- }
- var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
- // if a root tag name was provided, we need to load it in the DOM object
- if (sName){
- // create an artifical namespace prefix
- // or reuse existing prefix if applicable
- var prefix = "";
- if(sUri){
- if(sName.indexOf(":") > 1){
- prefix = sName.substring(0, sName.indexOf(":"));
- sName = sName.substring(sName.indexOf(":")+1);
- }else{
- prefix = "a" + (Sarissa._sarissa_iNsCounter++);
- }
- }
- // use namespaces if a namespace URI exists
- if(sUri){
- oDoc.loadXML('<' + prefix+':'+sName + " xmlns:" + prefix + "=\"" + sUri + "\"" + " />");
- } else {
- oDoc.loadXML('<' + sName + " />");
- }
- }
- return oDoc;
- };
- // see non-IE version
- Sarissa.getParseErrorText = function (oDoc) {
- var parseErrorText = Sarissa.PARSED_OK;
- if(oDoc && oDoc.parseError && oDoc.parseError.errorCode && oDoc.parseError.errorCode != 0){
- parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason +
- "\nLocation: " + oDoc.parseError.url +
- "\nLine Number " + oDoc.parseError.line + ", Column " +
- oDoc.parseError.linepos +
- ":\n" + oDoc.parseError.srcText +
- "\n";
- for(var i = 0; i < oDoc.parseError.linepos;i++){
- parseErrorText += "-";
- }
- parseErrorText += "^\n";
- }
- else if(oDoc.documentElement === null){
- parseErrorText = Sarissa.PARSED_EMPTY;
- }
- return parseErrorText;
- };
- // see non-IE version
- Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
- oDoc.setProperty("SelectionLanguage", "XPath");
- oDoc.setProperty("SelectionNamespaces", sNsSet);
- };
- /**
- * A class that reuses the same XSLT stylesheet for multiple transforms.
- * @constructor
- */
- XSLTProcessor = function(){
- if(!_SARISSA_XSLTEMPLATE_PROGID){
- _SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID(["Msxml2.XSLTemplate.6.0", "MSXML2.XSLTemplate.3.0"]);
- }
- this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
- this.processor = null;
- };
- /**
- * Imports the given XSLT DOM and compiles it to a reusable transform
- * <b>Note:</b> If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
- * @argument xslDoc The XSLT DOMDocument to import
- */
- XSLTProcessor.prototype.importStylesheet = function(xslDoc){
- if(!_SARISSA_THREADEDDOM_PROGID){
- _SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID(["MSXML2.FreeThreadedDOMDocument.6.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
- }
- xslDoc.setProperty("SelectionLanguage", "XPath");
- xslDoc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
- // convert stylesheet to free threaded
- var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
- // make included/imported stylesheets work if exist and xsl was originally loaded from url
- try{
- converted.resolveExternals = true;
- converted.setProperty("AllowDocumentFunction", true);
- }
- catch(e){
- // Ignore. "AllowDocumentFunction" is only supported in MSXML 3.0 SP4 and later.
- }
- if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
- converted.async = false;
- converted.load(xslDoc.url);
- }
- else {
- converted.loadXML(xslDoc.xml);
- }
- converted.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
- var output = converted.selectSingleNode("//xsl:output");
- //this.outputMethod = output ? output.getAttribute("method") : "html";
- if(output) {
- this.outputMethod = output.getAttribute("method");
- }
- else {
- delete this.outputMethod;
- }
- this.template.stylesheet = converted;
- this.processor = this.template.createProcessor();
- // for getParameter and clearParameters
- this.paramsSet = [];
- };
-
- /**
- * Transform the given XML DOM and return the transformation result as a new DOM document
- * @argument sourceDoc The XML DOMDocument to transform
- * @return The transformation result as a DOM Document
- */
- XSLTProcessor.prototype.transformToDocument = function(sourceDoc){
- // fix for bug 1549749
- var outDoc;
- if(_SARISSA_THREADEDDOM_PROGID){
- this.processor.input=sourceDoc;
- outDoc=new ActiveXObject(_SARISSA_DOM_PROGID);
- this.processor.output=outDoc;
- this.processor.transform();
- return outDoc;
- }
- else{
- if(!_SARISSA_DOM_XMLWRITER){
- _SARISSA_DOM_XMLWRITER = Sarissa.pickRecentProgID(["Msxml2.MXXMLWriter.6.0", "Msxml2.MXXMLWriter.3.0", "MSXML2.MXXMLWriter", "MSXML.MXXMLWriter", "Microsoft.XMLDOM"]);
- }
- this.processor.input = sourceDoc;
- outDoc = new ActiveXObject(_SARISSA_DOM_XMLWRITER);
- this.processor.output = outDoc;
- this.processor.transform();
- var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
- oDoc.loadXML(outDoc.output+"");
- return oDoc;
- }
- };
-
- /**
- * Transform the given XML DOM and return the transformation result as a new DOM fragment.
- * <b>Note</b>: The xsl:output method must match the nature of the owner document (XML/HTML).
- * @argument sourceDoc The XML DOMDocument to transform
- * @argument ownerDoc The owner of the result fragment
- * @return The transformation result as a DOM Document
- */
- XSLTProcessor.prototype.transformToFragment = function (sourceDoc, ownerDoc) {
- this.processor.input = sourceDoc;
- this.processor.transform();
- var s = this.processor.output;
- var f = ownerDoc.createDocumentFragment();
- var container;
- if (this.outputMethod == 'text') {
- f.appendChild(ownerDoc.createTextNode(s));
- } else if (ownerDoc.body && ownerDoc.body.innerHTML) {
- container = ownerDoc.createElement('div');
- container.innerHTML = s;
- while (container.hasChildNodes()) {
- f.appendChild(container.firstChild);
- }
- }
- else {
- var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
- if (s.substring(0, 5) == '<?xml') {
- s = s.substring(s.indexOf('?>') + 2);
- }
- var xml = ''.concat('<my>', s, '</my>');
- oDoc.loadXML(xml);
- container = oDoc.documentElement;
- while (container.hasChildNodes()) {
- f.appendChild(container.firstChild);
- }
- }
- return f;
- };
-
- /**
- * Set global XSLT parameter of the imported stylesheet
- * @argument nsURI The parameter namespace URI
- * @argument name The parameter base name
- * @argument value The new parameter value
- */
- XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
- // make value a zero length string if null to allow clearing
- value = value ? value : "";
- // nsURI is optional but cannot be null
- if(nsURI){
- this.processor.addParameter(name, value, nsURI);
- }else{
- this.processor.addParameter(name, value);
- }
- // update updated params for getParameter
- nsURI = "" + (nsURI || "");
- if(!this.paramsSet[nsURI]){
- this.paramsSet[nsURI] = [];
- }
- this.paramsSet[nsURI][name] = value;
- };
- /**
- * Gets a parameter if previously set by setParameter. Returns null
- * otherwise
- * @argument name The parameter base name
- * @argument value The new parameter value
- * @return The parameter value if reviously set by setParameter, null otherwise
- */
- XSLTProcessor.prototype.getParameter = function(nsURI, name){
- nsURI = "" + (nsURI || "");
- if(this.paramsSet[nsURI] && this.paramsSet[nsURI][name]){
- return this.paramsSet[nsURI][name];
- }else{
- return null;
- }
- };
-
- /**
- * Clear parameters (set them to default values as defined in the stylesheet itself)
- */
- XSLTProcessor.prototype.clearParameters = function(){
- for(var nsURI in this.paramsSet){
- for(var name in this.paramsSet[nsURI]){
- if(nsURI!=""){
- this.processor.addParameter(name, "", nsURI);
- }else{
- this.processor.addParameter(name, "");
- }
- }
- }
- this.paramsSet = [];
- };
-}else{ /* end IE initialization, try to deal with real browsers now ;-) */
- if(Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT){
- /**
- * <p>Ensures the document was loaded correctly, otherwise sets the
- * parseError to -1 to indicate something went wrong. Internal use</p>
- * @private
- */
- Sarissa.__handleLoad__ = function(oDoc){
- Sarissa.__setReadyState__(oDoc, 4);
- };
- /**
- * <p>Attached by an event handler to the load event. Internal use.</p>
- * @private
- */
- _sarissa_XMLDocument_onload = function(){
- Sarissa.__handleLoad__(this);
- };
- /**
- * <p>Sets the readyState property of the given DOM Document object.
- * Internal use.</p>
- * @memberOf Sarissa
- * @private
- * @argument oDoc the DOM Document object to fire the
- * readystatechange event
- * @argument iReadyState the number to change the readystate property to
- */
- Sarissa.__setReadyState__ = function(oDoc, iReadyState){
- oDoc.readyState = iReadyState;
- oDoc.readystate = iReadyState;
- if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") {
- oDoc.onreadystatechange();
- }
- };
-
- Sarissa.getDomDocument = function(sUri, sName){
- var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
- if(!oDoc.onreadystatechange){
-
- /**
- * <p>Emulate IE's onreadystatechange attribute</p>
- */
- oDoc.onreadystatechange = null;
- }
- if(!oDoc.readyState){
- /**
- * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
- * <ul><li>1 == LOADING,</li>
- * <li>2 == LOADED,</li>
- * <li>3 == INTERACTIVE,</li>
- * <li>4 == COMPLETED</li></ul>
- */
- oDoc.readyState = 0;
- }
- oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
- return oDoc;
- };
- if(window.XMLDocument){
- // do nothing
- }// TODO: check if the new document has content before trying to copynodes, check for error handling in DOM 3 LS
- else if(Sarissa._SARISSA_HAS_DOM_FEATURE && window.Document && !Document.prototype.load && document.implementation.hasFeature('LS', '3.0')){
- //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good
- /**
- * <p>Factory method to obtain a new DOM Document object</p>
- * @memberOf Sarissa
- * @argument sUri the namespace of the root node (if any)
- * @argument sUri the local name of the root node (if any)
- * @returns a new DOM Document
- */
- Sarissa.getDomDocument = function(sUri, sName){
- var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
- return oDoc;
- };
- }
- else {
- Sarissa.getDomDocument = function(sUri, sName){
- var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
- // looks like safari does not create the root element for some unknown reason
- if(oDoc && (sUri || sName) && !oDoc.documentElement){
- oDoc.appendChild(oDoc.createElementNS(sUri, sName));
- }
- return oDoc;
- };
- }
- }//if(Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT)
-}
-//==========================================
-// Common stuff
-//==========================================
-if(!window.DOMParser){
- if(Sarissa._SARISSA_IS_SAFARI){
- /*
- * DOMParser is a utility class, used to construct DOMDocuments from XML strings
- * @constructor
- */
- DOMParser = function() { };
- /**
- * Construct a new DOM Document from the given XMLstring
- * @param sXml the given XML string
- * @param contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
- * @return a new DOM Document from the given XML string
- */
- DOMParser.prototype.parseFromString = function(sXml, contentType){
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
- xmlhttp.send(null);
- return xmlhttp.responseXML;
- };
- }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
- DOMParser = function() { };
- DOMParser.prototype.parseFromString = function(sXml, contentType){
- var doc = Sarissa.getDomDocument();
- doc.loadXML(sXml);
- return doc;
- };
- }
-}
-
-if((typeof(document.importNode) == "undefined") && Sarissa._SARISSA_IS_IE){
- try{
- /**
- * Implementation of importNode for the context window document in IE.
- * If <code>oNode</code> is a TextNode, <code>bChildren</code> is ignored.
- * @param oNode the Node to import
- * @param bChildren whether to include the children of oNode
- * @returns the imported node for further use
- */
- document.importNode = function(oNode, bChildren){
- var tmp;
- if (oNode.nodeName=='#text') {
- return document.createTextNode(oNode.data);
- }
- else {
- var tbody = false;
- if(oNode.nodeName == "tbody" && oNode.parentNode){
- oNode = oNode.parentNode;
- tbody = true;
- }
- else if(oNode.nodeName == "tbody" || oNode.nodeName == "tr"){
- tmp = document.createElement("tr");
- }
- else if(oNode.nodeName == "td"){
- tmp = document.createElement("tr");
- }
- else if(oNode.nodeName == "option"){
- tmp = document.createElement("select");
- }
- if(!tmp){
- tmp = document.createElement("div");
- }
- if(bChildren){
- tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
- }else{
- tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
- }
- if (tbody) {
- return tmp.firstChild.tBodies[0];
- } else {
- return tmp.getElementsByTagName("*")[0];
- }
- }
- };
- }catch(e){ }
-}
-if(!Sarissa.getParseErrorText){
- /**
- * <p>Returns a human readable description of the parsing error. Usefull
- * for debugging. Tip: append the returned error string in a <pre>
- * element if you want to render it.</p>
- * <p>Many thanks to Christian Stocker for the initial patch.</p>
- * @memberOf Sarissa
- * @argument oDoc The target DOM document
- * @returns The parsing error description of the target Document in
- * human readable form (preformated text)
- */
- Sarissa.getParseErrorText = function (oDoc){
- var parseErrorText = Sarissa.PARSED_OK;
- if(!oDoc.documentElement){
- parseErrorText = Sarissa.PARSED_EMPTY;
- } else if(oDoc.documentElement.tagName == "parsererror"){
- parseErrorText = oDoc.documentElement.firstChild.data;
- parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
- } else if(oDoc.getElementsByTagName("parsererror").length > 0){
- var parsererror = oDoc.getElementsByTagName("parsererror")[0];
- parseErrorText = Sarissa.getText(parsererror, true)+"\n";
- } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){
- parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
- }
- return parseErrorText;
- };
-}
-/**
- * Get a string with the concatenated values of all string nodes under the given node
- * @memberOf Sarissa
- * @argument oNode the given DOM node
- * @argument deep whether to recursively scan the children nodes of the given node for text as well. Default is <code>false</code>
- */
-Sarissa.getText = function(oNode, deep){
- var s = "";
- var nodes = oNode.childNodes;
- for(var i=0; i < nodes.length; i++){
- var node = nodes[i];
- var nodeType = node.nodeType;
- if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
- s += node.data;
- } else if(deep === true && (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
- s += Sarissa.getText(node, true);
- }
- }
- return s;
-};
-if(!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("","foo", null).xml){
- /**
- * Utility class to serialize DOM Node objects to XML strings
- * @constructor
- */
- XMLSerializer = function(){};
- /**
- * Serialize the given DOM Node to an XML string
- * @param oNode the DOM Node to serialize
- */
- XMLSerializer.prototype.serializeToString = function(oNode) {
- return oNode.xml;
- };
-}
-
-/**
- * Strips tags from the given markup string. If the given string is
- * <code>undefined</code>, <code>null</code> or empty, it is returned as is.
- * @memberOf Sarissa
- */
-Sarissa.stripTags = function (s) {
- return s?s.replace(/<[^>]+>/g,""):s;
-};
-/**
- * <p>Deletes all child nodes of the given node</p>
- * @memberOf Sarissa
- * @argument oNode the Node to empty
- */
-Sarissa.clearChildNodes = function(oNode) {
- // need to check for firstChild due to opera 8 bug with hasChildNodes
- while(oNode.firstChild) {
- oNode.removeChild(oNode.firstChild);
- }
-};
-/**
- * <p> Copies the childNodes of nodeFrom to nodeTo</p>
- * <p> <b>Note:</b> The second object's original content is deleted before
- * the copy operation, unless you supply a true third parameter</p>
- * @memberOf Sarissa
- * @argument nodeFrom the Node to copy the childNodes from
- * @argument nodeTo the Node to copy the childNodes to
- * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is false
- */
-Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
- if(Sarissa._SARISSA_IS_SAFARI && nodeTo.nodeType == Node.DOCUMENT_NODE){ // SAFARI_OLD ??
- nodeTo = nodeTo.documentElement; //Apparently there's a bug in safari where you can't appendChild to a document node
- }
-
- if((!nodeFrom) || (!nodeTo)){
- throw "Both source and destination nodes must be provided";
- }
- if(!bPreserveExisting){
- Sarissa.clearChildNodes(nodeTo);
- }
- var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
- var nodes = nodeFrom.childNodes;
- var i;
- if(typeof(ownerDoc.importNode) != "undefined") {
- for(i=0;i < nodes.length;i++) {
- nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
- }
- } else {
- for(i=0;i < nodes.length;i++) {
- nodeTo.appendChild(nodes[i].cloneNode(true));
- }
- }
-};
-
-/**
- * <p> Moves the childNodes of nodeFrom to nodeTo</p>
- * <p> <b>Note:</b> The second object's original content is deleted before
- * the move operation, unless you supply a true third parameter</p>
- * @memberOf Sarissa
- * @argument nodeFrom the Node to copy the childNodes from
- * @argument nodeTo the Node to copy the childNodes to
- * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is
- */
-Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
- if((!nodeFrom) || (!nodeTo)){
- throw "Both source and destination nodes must be provided";
- }
- if(!bPreserveExisting){
- Sarissa.clearChildNodes(nodeTo);
- }
- var nodes = nodeFrom.childNodes;
- // if within the same doc, just move, else copy and delete
- if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
- while(nodeFrom.firstChild){
- nodeTo.appendChild(nodeFrom.firstChild);
- }
- } else {
- var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
- var i;
- if(typeof(ownerDoc.importNode) != "undefined") {
- for(i=0;i < nodes.length;i++) {
- nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
- }
- }else{
- for(i=0;i < nodes.length;i++) {
- nodeTo.appendChild(nodes[i].cloneNode(true));
- }
- }
- Sarissa.clearChildNodes(nodeFrom);
- }
-};
-
-/**
- * <p>Serialize any <strong>non</strong> DOM object to an XML string. All properties are serialized using the property name
- * as the XML element name. Array elements are rendered as <code>array-item</code> elements,
- * using their index/key as the value of the <code>key</code> attribute.</p>
- * @memberOf Sarissa
- * @argument anyObject the object to serialize
- * @argument objectName a name for that object
- * @return the XML serialization of the given object as a string
- */
-Sarissa.xmlize = function(anyObject, objectName, indentSpace){
- indentSpace = indentSpace?indentSpace:'';
- var s = indentSpace + '<' + objectName + '>';
- var isLeaf = false;
- if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String || anyObject instanceof Boolean || anyObject instanceof Date){
- s += Sarissa.escape(""+anyObject);
- isLeaf = true;
- }else{
- s += "\n";
- var isArrayItem = anyObject instanceof Array;
- for(var name in anyObject){
- s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + " ");
- }
- s += indentSpace;
- }
- return (s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n"));
-};
-
-/**
- * Escape the given string chacters that correspond to the five predefined XML entities
- * @memberOf Sarissa
- * @param sXml the string to escape
- */
-Sarissa.escape = function(sXml){
- return sXml.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
-};
-
-/**
- * Unescape the given string. This turns the occurences of the predefined XML
- * entities to become the characters they represent correspond to the five predefined XML entities
- * @memberOf Sarissa
- * @param sXml the string to unescape
- */
-Sarissa.unescape = function(sXml){
- return sXml.replace(/'/g,"'").replace(/"/g,"\"").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
-};
-
-/** @private */
-Sarissa.updateCursor = function(oTargetElement, sValue) {
- if(oTargetElement && oTargetElement.style && oTargetElement.style.cursor != undefined ){
- oTargetElement.style.cursor = sValue;
- }
-};
-
-/**
- * Asynchronously update an element with response of a GET request on the given URL. Passing a configured XSLT
- * processor will result in transforming and updating oNode before using it to update oTargetElement.
- * You can also pass a callback function to be executed when the update is finished. The function will be called as
- * <code>functionName(oNode, oTargetElement);</code>
- * @memberOf Sarissa
- * @param sFromUrl the URL to make the request to
- * @param oTargetElement the element to update
- * @param xsltproc (optional) the transformer to use on the returned
- * content before updating the target element with it
- * @param callback (optional) a Function object to execute once the update is finished successfuly, called as <code>callback(sFromUrl, oTargetElement)</code>.
- * In case an exception is thrown during execution, the callback is called as called as <code>callback(sFromUrl, oTargetElement, oException)</code>
- * @param skipCache (optional) whether to skip any cache
- */
-Sarissa.updateContentFromURI = function(sFromUrl, oTargetElement, xsltproc, callback, skipCache) {
- try{
- Sarissa.updateCursor(oTargetElement, "wait");
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open("GET", sFromUrl, true);
- xmlhttp.onreadystatechange = function() {
- if (xmlhttp.readyState == 4) {
- try{
- var oDomDoc = xmlhttp.responseXML;
- if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
- Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
- callback(sFromUrl, oTargetElement);
- }
- else{
- throw Sarissa.getParseErrorText(oDomDoc);
- }
- }
- catch(e){
- if(callback){
- callback(sFromUrl, oTargetElement, e);
- }
- else{
- throw e;
- }
- }
- }
- };
- if (skipCache) {
- var oldage = "Sat, 1 Jan 2000 00:00:00 GMT";
- xmlhttp.setRequestHeader("If-Modified-Since", oldage);
- }
- xmlhttp.send("");
- }
- catch(e){
- Sarissa.updateCursor(oTargetElement, "auto");
- if(callback){
- callback(sFromUrl, oTargetElement, e);
- }
- else{
- throw e;
- }
- }
-};
-
-/**
- * Update an element's content with the given DOM node. Passing a configured XSLT
- * processor will result in transforming and updating oNode before using it to update oTargetElement.
- * You can also pass a callback function to be executed when the update is finished. The function will be called as
- * <code>functionName(oNode, oTargetElement);</code>
- * @memberOf Sarissa
- * @param oNode the URL to make the request to
- * @param oTargetElement the element to update
- * @param xsltproc (optional) the transformer to use on the given
- * DOM node before updating the target element with it
- */
-Sarissa.updateContentFromNode = function(oNode, oTargetElement, xsltproc) {
- try {
- Sarissa.updateCursor(oTargetElement, "wait");
- Sarissa.clearChildNodes(oTargetElement);
- // check for parsing errors
- var ownerDoc = oNode.nodeType == Node.DOCUMENT_NODE?oNode:oNode.ownerDocument;
- if(ownerDoc.parseError && ownerDoc.parseError.errorCode != 0) {
- var pre = document.createElement("pre");
- pre.appendChild(document.createTextNode(Sarissa.getParseErrorText(ownerDoc)));
- oTargetElement.appendChild(pre);
- }
- else {
- // transform if appropriate
- if(xsltproc) {
- oNode = xsltproc.transformToDocument(oNode);
- }
- // be smart, maybe the user wants to display the source instead
- if(oTargetElement.tagName.toLowerCase() == "textarea" || oTargetElement.tagName.toLowerCase() == "input") {
- oTargetElement.value = new XMLSerializer().serializeToString(oNode);
- }
- else {
- // ok that was not smart; it was paranoid. Keep up the good work by trying to use DOM instead of innerHTML
- if(oNode.nodeType == Node.DOCUMENT_NODE || oNode.ownerDocument.documentElement == oNode) {
- oTargetElement.innerHTML = new XMLSerializer().serializeToString(oNode);
- }
- else{
- oTargetElement.appendChild(oTargetElement.ownerDocument.importNode(oNode, true));
- }
- }
- }
- }
- catch(e) {
- throw e;
- }
- finally{
- Sarissa.updateCursor(oTargetElement, "auto");
- }
-};
-
-
-/**
- * Creates an HTTP URL query string from the given HTML form data
- * @memberOf Sarissa
- */
-Sarissa.formToQueryString = function(oForm){
- var qs = "";
- for(var i = 0;i < oForm.elements.length;i++) {
- var oField = oForm.elements[i];
- var sFieldName = oField.getAttribute("name") ? oField.getAttribute("name") : oField.getAttribute("id");
- // ensure we got a proper name/id and that the field is not disabled
- if(sFieldName &&
- ((!oField.disabled) || oField.type == "hidden")) {
- switch(oField.type) {
- case "hidden":
- case "text":
- case "textarea":
- case "password":
- qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
- break;
- case "select-one":
- qs += sFieldName + "=" + encodeURIComponent(oField.options[oField.selectedIndex].value) + "&";
- break;
- case "select-multiple":
- for (var j = 0; j < oField.length; j++) {
- var optElem = oField.options[j];
- if (optElem.selected === true) {
- qs += sFieldName + "[]" + "=" + encodeURIComponent(optElem.value) + "&";
- }
- }
- break;
- case "checkbox":
- case "radio":
- if(oField.checked) {
- qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
- }
- break;
- }
- }
- }
- // return after removing last '&'
- return qs.substr(0, qs.length - 1);
-};
-
-
-/**
- * Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission. <p>The form <code>action</code> and
- * <code>method</code> attributess will be followed. Passing a configured XSLT processor will result in
- * transforming and updating the server response before using it to update the target element.
- * You can also pass a callback function to be executed when the update is finished. The function will be called as
- * <code>functionName(oNode, oTargetElement);</code></p>
- * <p>Here is an example of using this in a form element:</p>
- * <pre name="code" class="xml">
- * <div id="targetId"> this content will be updated</div>
- * <form action="/my/form/handler" method="post"
- * onbeforesubmit="return Sarissa.updateContentFromForm(this, document.getElementById('targetId'));"><pre>
- * <p>If JavaScript is supported, the form will not be submitted. Instead, Sarissa will
- * scan the form and make an appropriate AJAX request, also adding a parameter
- * to signal to the server that this is an AJAX call. The parameter is
- * constructed as <code>Sarissa.REMOTE_CALL_FLAG = "=true"</code> so you can change the name in your webpage
- * simply by assigning another value to Sarissa.REMOTE_CALL_FLAG. If JavaScript is not supported
- * the form will be submitted normally.
- * @memberOf Sarissa
- * @param oForm the form submition to emulate
- * @param oTargetElement the element to update
- * @param xsltproc (optional) the transformer to use on the returned
- * content before updating the target element with it
- * @param callback (optional) a Function object to execute once the update is finished successfuly, called as <code>callback(oNode, oTargetElement)</code>.
- * In case an exception occurs during excecution and a callback function was provided, the exception is cought and the callback is called as
- * <code>callback(oForm, oTargetElement, exception)</code>
- */
-Sarissa.updateContentFromForm = function(oForm, oTargetElement, xsltproc, callback) {
- try{
- Sarissa.updateCursor(oTargetElement, "wait");
- // build parameters from form fields
- var params = Sarissa.formToQueryString(oForm) + "&" + Sarissa.REMOTE_CALL_FLAG + "=true";
- var xmlhttp = new XMLHttpRequest();
- var bUseGet = oForm.getAttribute("method") && oForm.getAttribute("method").toLowerCase() == "get";
- if(bUseGet) {
- xmlhttp.open("GET", oForm.getAttribute("action")+"?"+params, true);
- }
- else{
- xmlhttp.open('POST', oForm.getAttribute("action"), true);
- xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xmlhttp.setRequestHeader("Content-length", params.length);
- xmlhttp.setRequestHeader("Connection", "close");
- }
- xmlhttp.onreadystatechange = function() {
- try{
- if (xmlhttp.readyState == 4) {
- var oDomDoc = xmlhttp.responseXML;
- if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
- Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
- callback(oForm, oTargetElement);
- }
- else{
- throw Sarissa.getParseErrorText(oDomDoc);
- }
- }
- }
- catch(e){
- if(callback){
- callback(oForm, oTargetElement, e);
- }
- else{
- throw e;
- }
- }
- };
- xmlhttp.send(bUseGet?"":params);
- }
- catch(e){
- Sarissa.updateCursor(oTargetElement, "auto");
- if(callback){
- callback(oForm, oTargetElement, e);
- }
- else{
- throw e;
- }
- }
- return false;
-};
-
-// EOF
-// Global Variables
-// var timeout = null;
-
-// TODO - use sarissa for standard XMLHttpRequest Support.
-
-
-// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
-
-// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
-
-A4J.AJAX = {};
-
-/**
- * XMLHttp transport class - incapsulate most of client-specifiv functions for call server requests.
- */
-A4J.AJAX.XMLHttpRequest = function(query){
- this._query = query;
-
- // Store document element, to check page replacement.
- this._documentElement = window.document.documentElement;
- };
-
-A4J.AJAX.XMLHttpRequest.prototype = {
- _query : null,
- _timeout : 0,
- _timeoutID : null,
- onready : null,
- _parsingStatus : Sarissa.PARSED_EMPTY,
- _errorMessage : "XML Response object not set",
- _contentType : null,
- _onerror : function(req,status,message) {
- // Status not 200 - error !
- // window.alert(message);
- if(status !=599 && req.getResponseText()){
- A4J.AJAX.replacePage(req);
- }
- },
- onfinish : null,
- options : {},
- domEvt : null,
- form : null,
- _request : null,
- _aborted : false,
- _documentElement : null,
- setRequestTimeout : function(timeout){
- this._timeout = timeout;
- },
- /**
- * Send request to server with parameters from query ( POST or GET depend on client type )
- */
- send : function(){
- this._request = new XMLHttpRequest();
- var _this = this;
- this._request.onreadystatechange = function(){
- if(window.document.documentElement != _this._documentElement){
- LOG.warn("Page for current request have been unloaded - abort processing" );
- _this.abort();
- return;
- };
- if(_this._aborted){
- return;
- };
- LOG.debug("Reqest state : "+_this._request.readyState );
- if (_this._request.readyState == 4 ) {
- LOG.debug("Reqest end with state 4");
- if(_this._timeoutID){
- window.clearTimeout(_this._timeoutID);
- }
- var requestStatus;
- var requestStatusText;
- try{
- requestStatus = _this._request.status;
- requestStatusText = _this._request.statusText;
- } catch(e){
- LOG.error("request don't have status code - network problem, "+e.message);
- requestStatus = 599;
- requestStatusText = "Network error";
- }
- if(requestStatus == 200){
- try {
- LOG.debug("Response with content-type: "+ _this.getResponseHeader('Content-Type'));
- LOG.debug("Full response content: ", _this.getResponseText());
- } catch(e) {
- // IE Can throw exception for any responses
- }
- // Prepare XML, if exist.
- if(_this._request.responseXML ){
- _this._parsingStatus = Sarissa.getParseErrorText(_this._request.responseXML);
- if(_this._parsingStatus == Sarissa.PARSED_OK && Sarissa.setXpathNamespaces ){
- Sarissa.setXpathNamespaces(_this._request.responseXML,"xmlns='http://www.w3.org/1999/xhtml'");
- }
- }
- if(_this.onready){
- _this.onready(_this);
- }
-
- } else {
- _this._errorMessage = "Reqest error, status : "+requestStatus +" " + requestStatusText ;
- LOG.error(_this._errorMessage);
- if(typeof(_this._onerror) == "function"){
- _this._onerror(_this,requestStatus,_this._errorMessage);
- }
- if (_this.onfinish)
- {
- _this.onfinish(_this);
- }
- }
-
- _this = undefined;
- }
- }; //this._onReady;
- try{
- LOG.debug("Start XmlHttpRequest");
- this._request.open('POST', this._query.getActionUrl("") , true);
- // Query use utf-8 encoding for prepare urlencode data, force request content-type and charset.
- var contentType = "application/x-www-form-urlencoded; charset=UTF-8";
- this._request.setRequestHeader( "Content-Type", contentType);
- } catch(e){
- // Opera 7-8 - force get
- LOG.debug("XmlHttpRequest not support setRequestHeader - use GET instead of POST");
- this._request.open('GET', this._query.getActionUrl("")+"?"+this._query.getQueryString() , true);
- }
- // send data.
- this._request.send(this._query.getQueryString());
- if(this._timeout > 0){
- this._timeoutID = window.setTimeout(function(){
- LOG.warn("request stopped due to timeout");
- if(!_this._aborted){
- A4J.AJAX.status(_this.containerId,_this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(_this);
- }
- }
- _this._aborted=true;
- _this._request.abort();
- if(_this._onerror){
- _this._errorMessage = "Request timeout";
- _this._onerror(_this,500,_this._errorMessage);
- }
- if(_this.onfinish){
- _this.onfinish(_this);
- }
- _this._request=undefined;
- _this = undefined;
- },this._timeout);
- }
- },
-
- abort: function(){
- if(!this._aborted){
- A4J.AJAX.status(this.containerId,this.options.status,false);
- if(typeof(A4J.AJAX.onAbort) == "function"){
- A4J.AJAX.onAbort(this);
- }
- }
- this._aborted=true;
- if(this._request){
- try{
-// this._request.abort();
- if(this._timeoutID){
- window.clearTimeout(this._timeoutID);
- }
- } catch (e){
- LOG.warn("Exception for abort current request "+e.Message);
- }
- }
- },
- getResponseText : function(){
- try {
- return this._request.responseText;
- } catch(e){
- return null;
- }
- },
- getError : function(){
- return this._errorMessage;
- },
- getParserStatus : function(){
- return this._parsingStatus;
- },
- getContentType : function(){
- if(!this._contentType){
- var contentType = this.getResponseHeader('Content-Type');
- if(contentType){
- var i = contentType.indexOf(';');
- if( i >= 0 ){
- this._contentType = contentType.substring(0,i);
- } else {
- this._contentType = contentType;
- }
- } else {
- this._contentType="text/html";
- }
- }
- return this._contentType;
- },
- getResponseHeader : function(name){
- var result;
- // Different behavior - for non-existing headers, Firefox throws exception,
- // IE return "" ,
- try{
- result = this._request.getResponseHeader(name);
- if(result === ""){
- result = undefined;
- }
- } catch(e) {
- }
- if(!result){
- // Header not exist or Opera <=8.0 error. Try to find <meta > tag with same name.
- LOG.debug("Header "+name+" not found, search in <meta>");
- if(this._parsingStatus == Sarissa.PARSED_OK){
- var metas = this.getElementsByTagName("meta");
- for(var i = 0; i < metas.length;i++){
- var meta = metas[i];
- LOG.debug("Find <meta name='"+meta.getAttribute('name')+"' content='"+meta.getAttribute('content')+"'>");
- if(meta.getAttribute("name") == name){
- result = meta.getAttribute("content");
- break;
- }
- }
- }
-
- }
- return result;
- },
- /**
- * get elements with elementname in responseXML or, if present - in element.
- */
- getElementsByTagName : function(elementname,element){
- if(!element){
- element = this._request.responseXML;
- }
- LOG.debug("search for elements by name '"+elementname+"' "+" in element "+element.nodeName);
- var elements;
- try
- {
- elements = element.selectNodes(".//*[local-name()=\""+
- elementname +"\"]");
- }
- catch (ex) {
- try {
- elements = element.getElementsByTagName(elementname);
- } catch(nf){
- LOG.debug("getElementsByTagName found no elements, "+nf.Message);
- }
- }
-// return document.getElementsByTagName(tagName);
-// elements = element.getElementsByTagNameNS("http://www.w3.org/1999/xhtml",elementname);
-// LOG.debug("getElementsByTagNameNS found "+elements.length);
- return elements;
- },
- /**
- * Find element in response by ID. Since in IE response not validated, use selectSingleNode instead.
- */
- getElementById : function(id){
- // first attempt - .getElementById.
- var oDoc = this._request.responseXML;
- if(oDoc){
- if(typeof(oDoc.getElementById) != 'undefined') {
- LOG.debug("call getElementById for id= "+id);
- return oDoc.getElementById(id);
- }
- else if(typeof(oDoc.selectSingleNode) != "undefined") {
- LOG.debug("call selectSingleNode for id= "+id);
- return oDoc.selectSingleNode("//*[@id='"+id+"']"); /* XPATH istead of ID */
- }
- // nodeFromID not worked since XML validation disabled by
- // default for MS
- else if(typeof(oDoc.nodeFromID) != "undefined") {
- LOG.debug("call nodeFromID for id= "+id);
- return oDoc.nodeFromID(id);
- }
- LOG.error("No functions for getElementById found ");
- } else {
- LOG.debug("No parsed XML document in response");
- }
- return null;
-
- },
-
- getJSON : function(id){
- var data;
- var dataElement = this.getElementById(id);
- if(dataElement){
- try {
- data = Sarissa.getText(dataElement,true);
- data = window.eval('('+data+')');
- } catch(e){
- LOG.error("Error on parsing JSON data "+e.message,data);
- }
- }
- return data;
- },
-
- _evaluateScript: function(node) {
- var includeComments = !A4J.AJAX.isXhtmlScriptMode();
- var newscript = A4J.AJAX.getText(node, includeComments) ; // TODO - Mozilla disable innerHTML in XML page ..."";
-
- try {
- LOG.debug("Evaluate script replaced area in document: ", newscript);
- if (window.execScript) {
- window.execScript( newscript );
- } else {
- window.eval(newscript);
- }
- LOG.debug("Script evaluation succeeded");
- } catch(e){
- LOG.error("ERROR Evaluate script: Error name: " + e.name + e.message?". Error message: "+e.message:"");
- }
- },
-
- evaluateQueueScript: function() {
- var queueScript = this.getElementById('org.ajax4jsf.queue_script');
- if (queueScript) {
- this._evaluateScript(queueScript);
- }
- },
-
- evalScripts : function(node, isLast){
- var newscripts = this.getElementsByTagName("script",node);
- LOG.debug("Scripts in updated part count : " + newscripts.length);
- if( newscripts.length > 0 ){
- var _this = this;
- window.setTimeout(function() {
- for (var i = 0; i < newscripts.length; i++){
- _this._evaluateScript(newscripts[i]);
- }
- newscripts = null;
- if (isLast)
- {
- _this.doFinish();
- }
- _this = undefined;
- }, 0);
- } else
- {
- if (isLast)
- {
- this.doFinish();
- }
- }
- },
-
- /**
- * Update DOM element with given ID by element with same ID in parsed responseXML
- */
- updatePagePart : function(id, isLast){
- var newnode = this.getElementById(id);
- if( ! newnode )
- {
- LOG.error("New node for ID "+id+" is not present in response");
- if (isLast)
- {
- this.doFinish();
- }
- return;
- }
- var oldnode = window.document.getElementById(id);
- if ( oldnode ) {
-
- // Remove unload prototype events for a removed elements.
- if (window.RichFaces && window.RichFaces.Memory) {
- window.RichFaces.Memory.clean(oldnode, true);
- }
-
- var anchor = oldnode.parentNode;
- if(!window.opera && oldnode.outerHTML && !oldnode.tagName.match( /(tbody|thead|tfoot|tr|th|td)/i ) ){
- LOG.debug("Replace content of node by outerHTML()");
- try {
- oldnode.innerHTML = "";
- } catch(e){
- LOG.error("Error to clear node content by innerHTML "+e.message);
- Sarissa.clearChildNodes(oldnode);
- }
- oldnode.outerHTML = new XMLSerializer().serializeToString(newnode);
- } else {
- // need to check for firstChild due to opera 8 bug with hasChildNodes
- Sarissa.clearChildNodes(oldnode);
- var importednode = window.document.importNode(newnode, true);
- //importednode.innerHTML = importednode.innerHTML;
- LOG.debug("Replace content of node by replaceChild()");
- anchor.replaceChild(importednode,oldnode);
- }
-
- // re-execute all script fragments in imported subtree...
- // TODO - opera 8 run scripts at replace content stage.
- if(!A4J.AJAX._scriptEvaluated){
- this.evalScripts(newnode, isLast);
- }
- LOG.debug("Update part of page for Id: "+id + " successful");
- } else {
- LOG.warn("Node for replace by response with id "+id+" not found in document");
- if (!A4J.AJAX._scriptEvaluated && isLast)
- {
- this.doFinish();
- }
- }
-
- if (A4J.AJAX._scriptEvaluated && isLast)
- {
- this.doFinish();
- }
-
- },
-
- doFinish: function() {
- if(this.onfinish){
- this.onfinish(this);
- }
- },
-
- appendNewHeadElements : function(callback){
- // Append scripts and styles to head, if not presented in page before.
- var includes = this._appendNewElements("script","src",null,null,["type","language","charset"]);
-
- var _this = this;
- includes.concat( this._appendNewElements("link","href","class",["component","user"],["type","rev","media"],{"class": "className"},
- function (element, script) {
- //IE requires to re-set rel or href after insertion to initialize correctly
- //see http://jira.jboss.com/jira/browse/RF-1627#action_12394642
- _this._copyAttribute(element,script,"rel");
- }
- ));
-
- if ( includes.length == 0) {
- callback();
- return;
- }
-
- A4J.AJAX.headElementsCounter = includes.length;
-
- var onReadyStateChange = function () {
- if (this.readyState == 'loaded' || this.readyState == 'complete') {
- this.onreadystatechange = null;
- this.onload = null;
- callback();
- }
- };
- var onLoad = function () {
- this.onreadystatechange = null;
- this.onload = null;
- callback();
- };
- for (var i = 0; i<includes.length; i++)
- {
- includes[i].onreadystatechange = onReadyStateChange;
- includes[i].onload = onLoad;
- }
- },
-
- _appendNewElements : function(tag,href,role,roles,attributes,mappings,callback){
- var head = document.getElementsByTagName("head")[0]||document.documentElement;
- var newscripts = this.getElementsByTagName(tag);
- var oldscripts = document.getElementsByTagName(tag);
- var mappedRole = (mappings && mappings[role]) || role;
- var elements = [];
-
- var roleAnchors = {};
- if (roles) {
- var i = 0;
-
- for(var j = 0; j < oldscripts.length; j++){
- var oldscript = oldscripts[j];
- var scriptRole = oldscript[mappedRole];
-
- for ( ; i < roles.length && roles[i] != scriptRole; i++) {
- roleAnchors[roles[i]] = oldscript;
- }
-
- if (i == roles.length) {
- break;
- }
- }
- }
-
- for(var i=0 ; i<newscripts.length;i++){
- var element = newscripts[i];
- var src = element.getAttribute(href);
- var elementRole;
-
- if (roles) {
- elementRole = element.getAttribute(role);
- }
-
- if(src){
- var exist = false;
- LOG.debug("<"+tag+"> in response with src="+src);
- for(var j = 0 ; j < oldscripts.length; j++){
- if(this._noSessionHref(src) == this._noSessionHref(oldscripts[j].getAttribute(href))){
- LOG.debug("Such element exist in document");
-
- if (role) {
- var oldRole = oldscripts[j][mappedRole];
- if ((!elementRole ^ !oldRole) || (elementRole && oldRole && elementRole != oldRole)) {
- LOG.warn("Roles are different");
- }
- }
-
- exist = true;
- break;
- }
- }
- if(!exist){
- // var script = window.document.importNode(element,true); //
- var script = document.createElement(tag);
- script.setAttribute(href,src);
- for(var j = 0 ; j < attributes.length; j++){
- this._copyAttribute(element,script,attributes[j]);
- }
-
- if (elementRole) {
- script[mappedRole] = elementRole;
- }
-
- LOG.debug("append element to document");
-
- for ( var j = 0; j < A4J.AJAX._headTransformers.length; j++) {
- A4J.AJAX._headTransformers[j](script);
- }
-
- var anchor = roleAnchors[elementRole];
- if (anchor && anchor.parentNode) {
- anchor.parentNode.insertBefore(script, anchor);
- } else {
- head.appendChild(script);
- }
-
- if (callback) {
- callback(element,script);
- }
- if (tag!="link" || script.type.toLowerCase()=="text/javascript") elements.push(script);
- }
- }
- }
- return elements;
- },
-
- _noSessionHref : function(href){
- var cref = href;
- if(href){
- var sessionid = href.lastIndexOf(";jsessionid=");
- if(sessionid>0){
- cref = href.substring(0,sessionid);
- var params = href.lastIndexOf("?");
- if(params>sessionid){
- cref=cref+href.substring(params);
- }
- }
- }
- return cref;
- },
-
- _copyAttribute : function(src,dst,attr){
- var value = src.getAttribute(attr);
- if(value){
- dst.setAttribute(attr,value);
- }
- }
-
-};
-
-//Listeners should be notified
-A4J.AJAX.Listener = function(onafterajax){
- this.onafterajax = onafterajax;
-};
-
-A4J.AJAX.AjaxListener = function(type, callback){
- this[type] = callback;
-};
-
-A4J.AJAX._listeners= [];
-A4J.AJAX.AddListener = function(listener){
- A4J.AJAX._listeners.push(listener);
-};
-A4J.AJAX.removeListeners = function(listener){
- A4J.AJAX._listeners = [];
-};
-A4J.AJAX.removeListener = function(listener){
- for (var i=A4J.AJAX._listeners.length-1;i>=0;i--){
- if (A4J.AJAX._listeners[i] == listener){
- A4J.AJAX._listeners.splice(i,1);
- }
- }
-};
-
-
-//head element transformers
-A4J.AJAX.HeadElementTransformer = function(elt){
- this.elt = elt;
-};
-
-A4J.AJAX._headTransformers = [];
-A4J.AJAX.AddHeadElementTransformer = function(listener){
- A4J.AJAX._headTransformers.push(listener);
-};
-
-A4J.AJAX.SetZeroRequestDelay = function(options) {
- if (typeof options.requestDelay == "undefined") {
- options.requestDelay = 0;
- }
-};
-
-// pollers timerId's
-A4J.AJAX._pollers = {};
-/*
- *
- *
- */
-A4J.AJAX.Poll = function( containerId, form, options ) {
- A4J.AJAX.StopPoll(options.pollId);
- if(!options.onerror){
- options.onerror = function(req,status,message){
- if(typeof(A4J.AJAX.onError)== "function"){
- A4J.AJAX.onError(req,status,message);
- }
- // For error, re-submit request.
- A4J.AJAX.Poll(containerId,form,options);
- };
- }
-
- if (!options.onqueuerequestdrop) {
- options.onqueuerequestdrop = function() {
- A4J.AJAX.Poll(containerId,form,options);
- };
- }
-
- A4J.AJAX.SetZeroRequestDelay(options);
-
- A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
- A4J.AJAX._pollers[options.pollId]=undefined;
- if((typeof(options.onsubmit) == 'function') && (options.onsubmit()==false)){
- // Onsubmit disable current poll, start next interval.
- A4J.AJAX.Poll(containerId,form,options);
- } else {
- A4J.AJAX.Submit(containerId,form,null,options);
- }
- },options.pollinterval);
-};
-
-A4J.AJAX.StopPoll = function( Id ) {
- if(A4J.AJAX._pollers[Id]){
- window.clearTimeout(A4J.AJAX._pollers[Id]);
- A4J.AJAX._pollers[Id] = undefined;
- }
-};
-
-/*
- *
- *
- */
-A4J.AJAX.Push = function( containerId, form, options ) {
- A4J.AJAX.StopPush(options.pushId);
- options.onerror = function(){
- // For error, re-submit request.
- A4J.AJAX.Push(containerId,form,options);
- };
-
- options.onqueuerequestdrop = function() {
- LOG.debug("Push main request dropped from queue");
- };
-
- A4J.AJAX._pollers[options.pushId] = window.setTimeout(function(){
- var request = new XMLHttpRequest();
- request.onreadystatechange = function(){
- if (request.readyState == 4 ) {
- try {
- if(request.status == 200){
- if(request.getResponseHeader("Ajax-Push-Status")=="READY"){
- A4J.AJAX.SetZeroRequestDelay(options);
- A4J.AJAX.Submit(containerId,form||options.dummyForm,null,options);
- }
- }
- } catch(e){
- // Network error.
- }
- // Clear variables.
- request=null;
- A4J.AJAX._pollers[options.pushId] = null;
- // Re-send request.
- A4J.AJAX.Push( containerId, form, options );
- }
- }
- A4J.AJAX.SendPush( request,options );
- },options.pushinterval);
-};
-
-A4J.AJAX.SendPush = function( request,options ) {
- var url = options.pushUrl || options.actionUrl;
- request.open('HEAD', url , true);
- request.setRequestHeader( "Ajax-Push-Key", options.pushId);
- if(options.timeout){
- request.setRequestHeader( "Timeout", options.timeout);
- }
- request.send(null);
-}
-
-A4J.AJAX.StopPush = function( Id ) {
- if(A4J.AJAX._pollers[Id]){
- window.clearTimeout(A4J.AJAX._pollers[Id]);
- A4J.AJAX._pollers[Id] = null;
- }
-};
-
-
-
-A4J.AJAX.CloneObject = function( obj, noFunctions ) {
- var cloned = {};
- for( var n in obj ){
- if(noFunctions && typeof(evt[prop]) == 'function'){
- continue;
- }
- cloned[n]=obj[n];
- }
- return cloned;
-}
-
-
-A4J.AJAX.SubmitForm = function( containerId, form, options ) {
- var opt = A4J.AJAX.CloneObject(options);
- // Setup active control if form submitted by button.
- if(A4J._formInput){
- LOG.debug("Form submitted by button "+A4J._formInput.id);
- opt.control = A4J._formInput;
- A4J._formInput = null;
- opt.submitByForm=true;
- }
- A4J.AJAX.Submit(containerId,form,null,opt);
-}
-
-/**
- * This method should be deprecated and maybe even removed?
- */
-A4J.AJAX.SubmiteventsQueue = function( eventsQueue ) {
- eventsQueue.submit();
-};
-
-A4J.AJAX.CloneEvent = function(evt) {
- var domEvt;
- evt = evt || window.event || null;
- if(evt){
- // Create copy of event object, since most of properties undefined outside of event capture.
- try {
- domEvt = A4J.AJAX.CloneObject(evt,false);
- } catch(e){
- LOG.warn("Exception on clone event "+e.name +":"+e.message);
- }
- LOG.debug("Have Event "+domEvt+" with properties: target: "+domEvt.target+", srcElement: "+domEvt.srcElement+", type: "+domEvt.type);
- }
-
- return domEvt;
-};
-
-A4J.AJAX.PrepareQuery = function(containerId, formId, domEvt, options) {
- // Process listeners.
- for(var li = 0; li < A4J.AJAX._listeners.length; li++){
- var listener = A4J.AJAX._listeners[li];
- if(listener.onbeforeajax){
- listener.onbeforeajax(formId,domEvt,options);
- }
- }
- // First - run onsubmit event for client-side validation.
- LOG.debug("Query preparation for form '" + formId + "' requested");
-// var form = A4J.AJAX.locateForm(event);
- var form = window.document.getElementById(formId);
- if( (!form || form.nodeName.toUpperCase() != "FORM") && domEvt ) {
- var srcElement = domEvt.target||domEvt.srcElement||null;
- if(srcElement){
- form = A4J.AJAX.locateForm(srcElement);
- };
- };
- // TODO - test for null of form object
- if(!options.submitByForm && form && form.onsubmit) {
- LOG.debug("Form have onsubmit function, call it" );
- if( form.onsubmit() == false ){
- return false;
- };
- };
- var tosend = new A4J.Query(containerId, form);
- tosend.appendFormControls(options.single, options.control);
- //appending options.control moved to appendFormControls
- //if(options.control){
- // tosend.appendControl(options.control,true);
- //};
- if(options.parameters){
- tosend.appendParameters(options.parameters);
- };
- if(options.actionUrl){
- tosend.setActionUrl(options.actionUrl);
- };
-
- return tosend;
-};
-
-A4J.AJAX.SubmitQuery = function (query, options, domEvt) {
- // build xxxHttpRequest. by Sarissa / JSHttpRequest class always defined.
- var req = new A4J.AJAX.XMLHttpRequest(query);
-
- var form = query._form;
- var containerId = query._containerId;
-
- req.options = options;
- req.containerId = containerId;
- req.domEvt = domEvt;
- req.form = form;
-
- if(options.timeout){
- req.setRequestTimeout(options.timeout);
- };
-
- // Event handler for process response result.
- req.onready = A4J.AJAX.processResponse;
-
- if(options.onerror){
- req._onerror = options.onerror;
- } else if(typeof(A4J.AJAX.onError)== "function"){
- req._onerror = A4J.AJAX.onError;
- }
-
- var _queueonerror = options.queueonerror;
- if (_queueonerror) {
- var _onerror = req._onerror;
- if (_onerror) {
- req._onerror = function() {
- _queueonerror.apply(this, arguments);
- _onerror.apply(this, arguments);
- };
- } else {
- req._onerror = _queueonerror;
- }
- }
-
- req.onfinish = A4J.AJAX.finishRequest;
-
- LOG.debug("NEW AJAX REQUEST !!! with form: " + (form.id || form.name || form));
-
- A4J.AJAX.status(containerId,options.status,true);
- req.send();
-
- return req;
-};
-
-//Submit or put in queue request. It not full queues - framework perform waiting only one request to same queue, new events simple replace last.
-//If request for same queue already performed, replace with current parameters.
-A4J.AJAX.Submit = function( containerId, formId, event , options ) {
- var domEvt = A4J.AJAX.CloneEvent(event);
- var query = A4J.AJAX.PrepareQuery(containerId, formId, domEvt, options);
- if (query) {
- var queue = A4J.AJAX.EventQueue.getOrCreateQueue(options, formId);
-
- if (queue) {
- queue.push(query, options, domEvt);
- } else {
- A4J.AJAX.SubmitQuery(query, options, domEvt);
- }
- }
-
- return false;
-};
-
-
- // Main request submitting functions.
- // parameters :
- // form - HtmlForm object for submit.
- // control - form element, called request, or, clientID for JSF view.
- // affected - Array of ID's for DOM Objects, updated after request. Override
- // list of updated areas in response.
- // statusID - DOM id request status tags.
- // oncomplete - function for call after complete request.
-A4J.AJAX.SubmitRequest = function( containerId, formId, event, options ) {
- var domEvt = A4J.AJAX.CloneEvent(event);
- var query = A4J.AJAX.PrepareQuery(containerId, formId, domEvt, options);
- if (query) {
- A4J.AJAX.SubmitQuery(query, options, domEvt);
- }
-
- return false;
-};
-
-A4J.AJAX.processResponseAfterUpdateHeadElements = function (req, ids)
-{
- req.evaluateQueueScript();
-
- for ( var k =0; k < ids.length ; k++ ) {
- var id = ids[k];
- LOG.debug("Update page part from call parameter for ID " + id);
- req.updatePagePart(id, k==ids.length-1);
- };
-}
-
-A4J.AJAX.headElementsCounter = 0;
-
-A4J.AJAX.processResponse = function(req) {
- A4J.AJAX.TestScriptEvaluation();
- var options = req.options;
- var ajaxResponse = req.getResponseHeader('Ajax-Response');
- // If view is expired, check user-defined handler.
- var expiredMsg = req.getResponseHeader('Ajax-Expired');
- if(expiredMsg && typeof(A4J.AJAX.onExpired) == 'function' ){
- var loc = A4J.AJAX.onExpired(window.location,expiredMsg);
- if(loc){
- window.location = loc;
- return;
- }
- }
- if( ajaxResponse != "true"){
- // NO Ajax header - new page.
- LOG.warn("No ajax response header ");
- var loc = req.getResponseHeader("Location");
- try{
- if(ajaxResponse == 'redirect' && loc){
- window.location = loc;
- } else if(ajaxResponse == "reload"){
- window.location.reload(true);
- } else {
- A4J.AJAX.replacePage(req);
- }
- } catch(e){
- LOG.error("Error redirect to new location ");
- }
- } else {
- if(req.getParserStatus() == Sarissa.PARSED_OK){
-
- // perform beforeupdate if exists
- if(options.onbeforedomupdate || options.queueonbeforedomupdate){
- var event = req.domEvt;
- var data = req.getJSON('_ajax:data');
-
- LOG.debug( "Call local onbeforedomupdate function before replacing elemements" );
-
- if (options.onbeforedomupdate) {
- options.onbeforedomupdate(req, event, data);
- }
-
- if (options.queueonbeforedomupdate) {
- options.queueonbeforedomupdate(req, event, data);
- }
- }
-
- var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
- var ids;
-
- var callback = function () {
- if (A4J.AJAX.headElementsCounter!=0) {
- LOG.debug("Script "+A4J.AJAX.headElementsCounter+" was loaded");
- --A4J.AJAX.headElementsCounter;
- }
- if (A4J.AJAX.headElementsCounter==0) {
- A4J.AJAX.processResponseAfterUpdateHeadElements(req, ids);
- }
- };
-
- // 3 strategy for replace :
- // if setted affected parameters - replace its
- if( options.affected ) {
- ids = options.affected;
- req.appendNewHeadElements(callback);
- // if resopnce contains element with ID "ajax:update" get id's from
- // child text element . like :
- // <div id="ajax:update" style="display none" >
- // <span>_id1:1234</span>
- // .........
- // </div>
- //
- } else if( idsFromResponse && idsFromResponse != "" ) {
- LOG.debug("Update page by list of rendered areas from response " + idsFromResponse );
- // Append scripts and styles to head, if not presented in page before.
- ids = idsFromResponse.split(",");
- req.appendNewHeadElements(callback);
- } else {
- // if none of above - error ?
- // A4J.AJAX.replace(form.id,A4J.AJAX.findElement(form.id,xmlDoc));
- LOG.warn("No information in response about elements to replace");
- req.doFinish();
- }
- // Replace client-side hidden inputs for JSF View state.
- var idsSpan = req.getElementById("ajax-view-state");
- LOG.debug("Hidden JSF state fields: "+idsSpan);
- if(idsSpan != null){
- // For a portal case, replace content in the current window only.
- var namespace = options.parameters['org.ajax4jsf.portlet.NAMESPACE'];
- LOG.debug("Namespace for hidden view-state input fields is "+namespace);
- var anchor = namespace?window.document.getElementById(namespace):window.document;
- var inputs = anchor.getElementsByTagName("input");
- try {
- var newinputs = req.getElementsByTagName("input",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- } catch(e){
- LOG.warn("No elements 'input' in response");
- }
- // For any cases, new state can be in uppercase element
- try {
- var newinputs = req.getElementsByTagName("INPUT",idsSpan);
- A4J.AJAX.replaceViewState(inputs,newinputs);
- } catch(e){
- LOG.warn("No elements 'INPUT' in response");
- }
- }
-
- // Process listeners.
- for(var li = 0; li < A4J.AJAX._listeners.length; li++){
- var listener = A4J.AJAX._listeners[li];
- if(listener.onafterajax){
- // Evaluate data as JSON String.
- var data = req.getJSON('_ajax:data');
- listener.onafterajax(req,req.domEvt,data);
- }
- }
- // Set focus, if nessesary.
- var focusId = req.getJSON("_A4J.AJAX.focus");
- if(focusId){
- LOG.debug("focus must be set to control "+focusId);
- var focusElement=false;
- if(req.form){
- // Attempt to get form control for name. By Richfaces naming convensions,
- // complex component must set clientId as DOM id for a root element ,
- // and as input element name.
- focusElement = req.form.elements[focusId];
- }
- if(!focusElement){
- // If not found as control element, search in DOM.
- LOG.debug("No control element "+focusId+" in submitted form");
- focusElement = document.getElementById(focusId);
- }
- if(focusElement){
- LOG.debug("Set focus to control ");
- focusElement.focus();
- if (focusElement.select) focusElement.select();
- } else {
- LOG.warn("Element for set focus not found");
- }
- } else {
- LOG.debug("No focus information in response");
- }
- } else {
- // No response XML
- LOG.error( "Error parsing XML" );
- LOG.error("Parse Error: " + req.getParserStatus());
- }
- }
- };
-
-
-A4J.AJAX.replacePage = function(req){
- if(!req.getResponseText()){
- LOG.warn("No content in response for replace current page");
- return;
- }
- LOG.debug("replace all page content with response");
- var isIE = Sarissa._SARISSA_IS_IE;
- // maksimkaszynski
- //Prevent "Permission denied in IE7"
- //Reset calling principal
- var oldDocOpen = window.document.open;
- if (isIE) {
- LOG.debug("setup custom document.open method");
- window.document.open = function() {
- oldDocOpen.apply(this, arguments);
- }
- }
- // /maksimkaszynski
- window.setTimeout(function() {
- var isDocOpen=false;
- try {
- window.document.open(req.getContentType(),true);
- LOG.debug("window.document has opened for writing");
- isDocOpen=true;
- window.document.write(req.getResponseText());
- LOG.debug("window.document has been writed");
- window.document.close();
- LOG.debug("window.document has been closed for writing");
- if(isIE){
- // For Ie , scripts on page not activated.
- window.location.reload(false);
- }
- } catch(e) {
- LOG.debug("exception during write page content "+e.Message);
- if(isDocOpen){
- window.document.close();
- }
- // Firefox/Mozilla in XHTML case don't support document.write()
- // Use dom manipulation instead.
- var oDomDoc = (new DOMParser()).parseFromString(req.getResponseText(), "text/xml");
- if(Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
- LOG.debug("response has parsed as DOM documnet.");
- Sarissa.clearChildNodes(window.document.documentElement);
- var docNodes = oDomDoc.documentElement.childNodes;
- for(var i = 0;i<docNodes.length;i++){
- if(docNodes[i].nodeType == 1){
- LOG.debug("append new node in document");
- var node = window.document.importNode(docNodes[i], true);
- window.document.documentElement.appendChild(node);
- }
- }
- //TODO - unloading cached observers?
- //if (window.RichFaces && window.RichFaces.Memory) {
- // window.RichFaces.Memory.clean(oldnode);
- //}
- } else {
- LOG.error("Error parsing response",Sarissa.getParseErrorText(oDomDoc));
- }
- // TODO - scripts reloading ?
- } finally {
- window.document.open = oldDocOpen;
- }
- LOG.debug("page content has been replaced");
- },0);
-}
-
-
-A4J.AJAX.replaceViewState = function(inputs,newinputs){
- LOG.debug("Replace value for inputs: "+inputs.length + " by new values: "+ newinputs.length);
- if( (newinputs.length > 0) && (inputs.length > 0) ){
- for(var i = 0 ; i < newinputs.length; i++){
- var newinput = newinputs[i];
- LOG.debug("Input in response: "+newinput.getAttribute("name"));
- for(var j = 0 ; j < inputs.length; j++){
- var input = inputs[j];
- if(input.name == newinput.getAttribute("name")){
- LOG.debug("Found same input on page with type: "+input.type);
- input.value = newinput.getAttribute("value");
- }
- }
- }
- }
-
-};
-/**
- *
- */
-A4J.AJAX.finishRequest = function(request){
- var options = request.options;
-
- // we can set listener for complete request - for example,
- // it can shedule next request for update page.
- var oncomp = request.getElementById('org.ajax4jsf.oncomplete');
- if(oncomp) {
- LOG.debug( "Call request oncomplete function after processing updates" );
- window.setTimeout(function(){
- var event = request.domEvt;
- var data = request.getJSON('_ajax:data');
-
- try {
- var target = null;
- if (event) {
- target = event.target ? event.target : event.srcElement;
- }
-
- var newscript = Sarissa.getText(oncomp,true);
- var oncomplete = new Function("request","event","data",newscript);
- oncomplete.call(target,request,event,data);
-
- if (options.queueoncomplete) {
- options.queueoncomplete.call(target, request, event, data);
- }
-
- } catch (e) {
- LOG.error('Error evaluate oncomplete function '+e.Message);
- }
-
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 0);
- } else if (options.oncomplete || options.queueoncomplete){
- LOG.debug( "Call local oncomplete function after processing updates" );
- window.setTimeout(function(){
- var event = request.domEvt;
- var data = request.getJSON('_ajax:data');
-
- if (options.oncomplete) {
- options.oncomplete(request, event, data);
- }
-
- if (options.queueoncomplete) {
- options.queueoncomplete(request, event, data);
- }
-
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);},
- 0);
-
- } else {
- LOG.debug( "Processing updates finished, no oncomplete function to call" );
-
- setTimeout(function() {
- // mark status object ( if any ) for complete request ;
- A4J.AJAX.status(request.containerId,options.status,false);
- }, 0)
- }
-
- if (request.shouldNotifyQueue && request.queue) {
- request.queue.pop();
- }
- };
-
-A4J.AJAX.getCursorPos = function(inp){
-
- if(inp.selectionEnd != null)
- return inp.selectionEnd;
-
- // IE specific code
- var range = document.selection.createRange();
- var isCollapsed = range.compareEndPoints("StartToEnd", range) == 0;
- if (!isCollapsed)
- range.collapse(false);
- var b = range.getBookmark();
- return b.charCodeAt(2) - 2;
- }
-
- // Locate enclosing form for object.
-A4J.AJAX.locateForm = function(obj){
-
- var parent = obj;
- while(parent && parent.nodeName.toLowerCase() != 'form'){
- parent = parent.parentNode;
- };
- return parent;
-
- };
-
-A4J.AJAX.getElementById = function(id,options){
- var namespace = options['org.ajax4jsf.portlet.NAMESPACE'];
- var anchor = namespace?window.document.getElementById(namespace):window.document;
- var element;
- if(anchor){
- element = anchor.getElementById(id);
- } else {
- LOG.error("No root element for portlet namespace "+namespace+" on page");
- }
- return element;
-}
-
- // hash for requests count for all ID's
-A4J.AJAX._requestsCounts = {};
- // Change status object on start/stop request.
- // on start, document object with targetID+".start" make visible,
- // document object with targetID+".stop" make invisible.
- // on stop - inverse.
-A4J.AJAX.status = function(regionID,targetID,start){
- try {
- var elem;
- targetID = targetID || regionID +":status";
- A4J.AJAX._requestsCounts[targetID]=(A4J.AJAX._requestsCounts[targetID]||0)+(start?1:-1);
- if(A4J.AJAX._requestsCounts[targetID]>0){
- elem = document.getElementById(targetID+".stop");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".start");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstart) == 'function'){
- elem.onstart();
- }
- }
- }else{
- elem = document.getElementById(targetID+".start");
- if(elem){elem.style.display="none";}
- elem = document.getElementById(targetID+".stop");
- if(elem){
- elem.style.display="";
- if(typeof(elem.onstop) == 'function'){
- elem.onstop();
- }
- }
- }
- } catch(e){
- LOG.error("Exception on status change: ");
- }
-};
-
-
-
-
-// Class for build query string.
-A4J.Query = function(containerId, form){
- // For detect AJAX Request.
- this._query = {AJAXREQUEST : containerId};
- this._oldSubmit = null ;
- this._form = form;
- this._containerId = containerId;
- this._actionUrl = ( this._form.action)?this._form.action:this._form;
- };
-
-A4J.Query.prototype = {
- _form : null,
- _actionUrl : null,
- _ext : "",
- _query : {},
- _oldSubmit : null,
- // init at loading time - script can change location at run time ? ...
- _pageBase : window.location.protocol+"//"+window.location.host,
- // hash for control elements query string functions
-
- hidden : function(control){
- this._value_query(control);
- // TODO - configurable mask for hidden command scripts.
- if( (control.name.length > 4) && (control.name.lastIndexOf("_idcl") == (control.name.length-5)) ){
- control.value="";
- // MYfaces version ...
- } else if( (control.name.length > 12) && (control.name.lastIndexOf("_link_hidden_") == (control.name.length-13)) ){
- control.value="";
- }
- },
-
- text : function(control){
- this._value_query(control);
- },
-
- textarea : function(control){
- this._value_query(control);
- },
-
- 'select-one' : function(control){
- // If none options selected, don't include parameter.
- if (control.selectedIndex != -1) {
- this._value_query(control);
- }
-// for( var i =0; i< control.childNodes.length; i++ ){
-// var child=control.childNodes[i];
-// if( child.selected ){
-// this._value_query(control);
-// break;
-// }
-// }
- },
-
- password : function(control){
- this._value_query(control);
- },
-
- file : function(control){
- this._value_query(control);
- },
-
- radio : function(control){
- this._radio_query(control);
- },
-
- checkbox : function(control){
- this._check_query(control);
- },
-
-
- 'select-multiple' : function(control){
- var cname = control.name;
- var options = control.options;
- for( var i=0 ;i< control.length;i++ ){
- var option = options[i];
- this._addOption(cname, option);
- }
- },
-
- _addOption : function(cname,option){
- if ( option.selected ){
- if( ! this._query[cname] ){
- this._query[cname]=[];
- }
- this._query[cname][this._query[cname].length]=option.value;
- }
-
- },
-// command inputs
-
- image : function( control, action ){
- if(action) this._value_query(control);
- },
- button : function( control, action ){
- if(action) this._value_query(control);
- },
-
- submit : function( control, action ){
- if(action) {
- this._value_query(control);
- }
- },
-
- // Anchor link pseudo-control.
- link : function(control, action ){
- if(action) {
- this._value_query(control);
- if(control.parameters){
- this.appendParameters(control.parameters);
- }
- }
- },
-
- // same as link, but have additional field - control, for input submit.
- input : function(control, action ){
- if(action) {
- this.link(control, action );
- // append original control.
- if( control.control ) {
- this.appendControl(control.control,action);
- }
- }
- },
-
- // Append one control to query.
- appendControl : function(control,action){
- if( this[control.type] ) {
- this[control.type](control,action);
- } else {
- this._appendById(control.id||control);
- }
-
- },
-
- // Append all non-hidden controls from form to query.
- appendFormControls : function(hiddenOnly, actionControl){
- try {
- var elems = this._form.elements;
- if(elems){
- var k = 0;
- for ( k=0;k<elems.length;k++ ) {
- var element=elems[k];
-
- //skip actionControl, we're going to add it later
- if (element == actionControl) {
- continue;
- }
-
- try {
- if( !hiddenOnly || element.type == "hidden") {
- this.appendControl(element,false) ;
- }
- } catch( ee ) {
- LOG.error("exception in building query ( append form control ) " + ee );
- }
- }
- }
- } catch(e) {
- LOG.warn("Error with append form controls to query "+e)
- }
-
- if (actionControl) {
- this.appendControl(actionControl, true);
- }
- },
-
- // append map of parameters to query.
- appendParameters : function(parameters){
- for( k in parameters ){
- if(typeof Object.prototype[k] == 'undefined'){
- LOG.debug( "parameter " + k + " with value "+parameters[k]);
- this.appendParameter(k,parameters[k]);
- }
- }
- },
-
- setActionUrl : function(actionUrl){
- this._actionUrl = actionUrl;
- },
-// Return action URL ( append extention, if present )
- getActionUrl : function( ext ) {
- var actionUrl = this._actionUrl ;
- var ask = actionUrl.indexOf('?');
- // create absolute reference - for Firefox XMLHttpRequest base url can vary
- if( actionUrl.substring(0,1) == '/' ) {
- actionUrl = this._pageBase+actionUrl;
- }
- if ( ! ext ) ext = this._ext ;
- if( ask >=0 )
- {
- return actionUrl.substring(0,ask) + ext + actionUrl.substring(ask);
- }
- else return actionUrl + ext;
- },
-
-
-// Build query string for send to server.
- getQueryString : function() {
- var qs = "";
- var iname ;
- for ( var k in this._query ){
- if(typeof Object.prototype[k] == 'undefined'){
- iname = this._query[k];
- if( iname instanceof Object ){
- for ( var l=0; l< iname.length; l++ ) {
- qs += this._encode(k) + "=" + this._encode(iname[l]) + "&";
- }
- } else {
- qs += this._encode(k) + "=" + this._encode(iname) + "&";
- }
- }
- }
- LOG.debug("QueryString: "+qs);
- return qs;
- },
- // private methods
-
- _appendById : function( id ) {
- this.appendParameter(this._form.id + "_link_hidden_", id);
- // JSF-ri version ...
- // this._query[this._form.id + "_idcl"]=id;
- },
-
-
- _value_query : function(control){
- if (control.name) {
- LOG.debug("Append "+control.type+" control "+control.name+" with value ["+control.value+"] and value attribute ["+control.getAttribute('value')+"]");
- if(null != control.value){
- this.appendParameter(control.name, control.value);
- }
- } else {
- LOG.debug("Ignored "+control.type+" no-name control with value ["+control.value+"] and value attribute ["+control.getAttribute('value')+"]");
- }
- },
-
- _check_query : function(control){
- if( control.checked ) {
- this.appendParameter(control.name, control.value?control.value:"on");
- }
- },
-
- _radio_query : function(control) {
- if( control.checked ) {
- this.appendParameter(control.name, control.value?control.value:"");
- }
- },
-
- // Append parameter to query. if name exist, append to array of parameters
- appendParameter: function(cname,value){
- if( ! this._query[cname] ){
- this._query[cname]=value;
- return;
- } else if( !(this._query[cname] instanceof Object) ){
- this._query[cname] = [this._query[cname]];
- }
- this._query[cname][this._query[cname].length]=value;
- },
-
- // Encode data string for request string
- _encode : function(string) {
- try {
- return encodeURIComponent(string);
- } catch(e) {
- var str = escape(string);
- // escape don't encode +. but form replace ' ' in fields by '+'
- return str.split('+').join('%2B');
- }
- }
-
-
- }
-
-
-A4J.AJAX.getText = function(oNode, includeComment) {
- var s = "";
- var nodes = oNode.childNodes;
- for(var i=0; i < nodes.length; i++){
- var node = nodes[i];
- var nodeType = node.nodeType;
-
- if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE ||
- (includeComment && nodeType == Node.COMMENT_NODE)){
-
- s += node.data;
- } else if(nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE){
- s += arguments.callee(node, includeComment);
- }
- }
- return s;
-}
-
-A4J.AJAX.isXhtmlScriptMode = function() {
- if (!this._xhtmlScriptMode) {
- var elt = document.createElement("div");
- elt.innerHTML = "<script type='text/javascript'><!--\r\n/**/\r\n//--></script>";
-
- var commentFound = false;
- var s = elt.firstChild;
-
- while (s) {
- if (s.nodeType == Node.ELEMENT_NODE) {
- var c = s.firstChild;
-
- while (c) {
- if (c.nodeType == Node.COMMENT_NODE) {
- commentFound = true;
- break;
- }
-
- c = c.nextSibling;
- }
-
- break;
- }
-
- s = s.nextSibling;
- }
-
- if (commentFound) {
- this._xhtmlScriptMode = 2;
- } else {
- this._xhtmlScriptMode = 1;
- }
- }
-
- return this._xhtmlScriptMode > 1;
-}
-
-//Test for re-evaluate Scripts in updated part. Opera & Safari do it.
-A4J.AJAX._scriptEvaluated=false;
-A4J.AJAX.TestScriptEvaluation = function () {
-if ((!document.all || window.opera) && !A4J.AJAX._scriptTested){
- try{
- // Simulate same calls as on XmlHttp
- var oDomDoc = Sarissa.getDomDocument();
- var _span = document.createElement("span");
- document.body.appendChild(_span);
- // If script evaluated with used replace method, variable will be set to true
- var xmlString = "<html xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript>A4J.AJAX._scriptEvaluated=true;</scr"+"ipt></html>";
- oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
- var _script=oDomDoc.getElementsByTagName("script")[0];
- if(!window.opera && _span.outerHTML){
- _span.outerHTML = new XMLSerializer().serializeToString(_script);
- } else {
- var importednode ;
- importednode = window.document.importNode(_script, true);
- document.body.replaceChild(importednode,_span);
- }
-
- } catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
-}
-A4J.AJAX._scriptTested = true;
-}
-A4J.AJAX._eventQueues = {};
-
-//queue constructor
-A4J.AJAX.EventQueue = function() {
- var DROP_NEW = 'dropNew';
- var DROP_NEXT = 'dropNext';
- var FIRE_NEW = 'fireNew';
- var FIRE_NEXT = 'fireNext';
-
- var extend = function(target, source) {
- for (var property in source) {
- target[property] = source[property];
- }
- };
-
- var extendOptions = function(options) {
- var opts = {};
-
- for (var name in options) {
- opts[name] = options[name];
- }
-
- for (var name in this.requestOptions) {
- if (typeof opts[name] == 'undefined') {
- opts[name] = this.requestOptions[name];
- }
- }
-
- return opts;
- };
-
- var QueueEntry = function() {
- var ctor = function(queue, query, options, event) {
- this.queue = queue;
- this.query = query;
- this.options = options;
- this.event = event;
-
- this.similarityGroupingId = this.options.similarityGroupingId;
- this.eventsCount = 1;
- };
-
- extend(ctor.prototype, {
-
- isIgnoreDupResponses: function() {
- return this.options.ignoreDupResponses;
- },
-
- getSimilarityGroupingId: function() {
- return this.similarityGroupingId;
- },
-
- setSimilarityGroupingId: function(id) {
- this.similarityGroupingId = id;
- },
-
- submit: function() {
- this.query.appendParameter("AJAX:EVENTS_COUNT", this.eventsCount);
- this.request = A4J.AJAX.SubmitQuery(this.query, this.options, this.event)
-
- var queue = this.queue; // TODO: move to next line
- this.request.queue = queue;
-
- return this.request;
- },
-
- abort: function() {
- if (this.request) {
- //tell request not to notify queue after its processing finished
- //request.queue = undefined
- //is not ok for this case because user might want to obtain queue in any event handler
- this.request.shouldNotifyQueue = false;
- this.request.abort();
- this.request = undefined;
- }
- },
-
- ondrop: function() {
- var callback = this.options.onqueuerequestdrop;
- if (callback) {
- callback.call(this.queue, this.query, this.options, this.event);
- }
- },
-
- onRequestDelayPassed: function() {
- this.readyToSubmit = true;
- this.queue.submitFirst();
- },
-
- startTimer: function() {
- var delay = this.options.requestDelay;
-
- LOG.debug("Queue will wait " + (delay || 0) + "ms before submit");
-
- if (delay) {
- var _this = this;
- this.timer = setTimeout(function() {
- try {
- _this.onRequestDelayPassed();
- } finally {
- _this.timer = undefined;
- _this = undefined;
- }
- }, delay);
- } else {
- this.onRequestDelayPassed();
- }
- },
-
- stopTimer: function() {
- if (this.timer) {
- clearTimeout(this.timer);
- this.timer = undefined;
- }
- },
-
- clearEntry: function() {
- this.stopTimer();
- if (this.request) {
- this.request.shouldNotifyQueue = false;
- this.request = undefined;
- }
- },
-
- getEventsCount: function() {
- return this.eventsCount;
- },
-
- setEventsCount: function(newCount) {
- this.eventsCount = newCount;
- },
-
- getEventArguments: function() {
- return [this.query, this.options, this.event];
- }
- });
-
- return ctor;
- }();
-
- var Queue = function(name, queueOptions, requestOptions) {
- this.items = new Array();
-
- this.name = name;
- this.queueOptions = queueOptions || {};
- this.requestOptions = requestOptions || {};
- };
-
- extend(Queue.prototype, {
-
- submitFirst: function() {
- var firstItem = this.items[0];
- if (firstItem) {
- if (!firstItem.request) {
- if (firstItem.readyToSubmit) {
- LOG.debug("Queue '" + this.name + "' will submit request NOW");
-
- var req = firstItem.submit();
-
- //see entry.abort() method for more details about this assignment
- req.shouldNotifyQueue = true;
-
- if (this.requestOptions.queueonsubmit) {
- this.requestOptions.queueonsubmit.call(this, req);
- }
- } else {
- LOG.debug("First item is not ready to be submitted yet");
- }
- }
- } else {
- LOG.debug("Queue is empty now");
- }
- },
-
- getSize: function() {
- return this.items.length;
- },
-
- getMaximumSize: function() {
- return this.queueOptions.size;
- },
-
- getSizeExceededBehavior: function() {
- var policy = this.queueOptions.sizeExceededBehavior;
- if (!policy) {
- policy = DROP_NEXT;
- }
-
- return policy;
- },
-
- queue: function(entry) {
- this.items.push(entry);
-
- if (this.queueOptions.onrequestqueue) {
- LOG.debug("Call onrequestqueue handler");
- this.queueOptions.onrequestqueue.apply(this, entry.getEventArguments());
- }
- },
-
- dequeue: function() {
- var entry = this.items.shift();
-
- if (this.queueOptions.onrequestdequeue) {
- LOG.debug("Call onrequestdequeue handler");
- this.queueOptions.onrequestdequeue.apply(this, entry.getEventArguments());
- }
- },
-
- push: function(query, opts, event) {
- var options = extendOptions.call(this, opts);
-
- var entry = new QueueEntry(this, query, options, event);
- var similarityGroupingId = entry.getSimilarityGroupingId();
-
- var lastIdx = this.items.length - 1;
- var last = this.items[lastIdx];
- var handled = false;
-
- if (last) {
- if (last.getSimilarityGroupingId() == similarityGroupingId) {
- LOG.debug("Similar request currently in queue '" + this.name + "'");
-
- if (last.request) {
- LOG.debug("Request has already beeen sent to server");
- if (entry.isIgnoreDupResponses()) {
- LOG.debug("Duplicate responses ignore requested, queue will abort current request");
-
- last.abort();
-
- LOG.debug("Current request in queue '" + this.name + "' has been aborted");
-
- //remove last (that is actually first) from queue - will be safer to do that in LinkedList
- this.dequeue();
- }
- } else {
- LOG.debug("Combine similar requests and reset timer");
-
- handled = true;
- last.stopTimer();
- entry.setEventsCount(last.getEventsCount() + 1);
-
- this.items[lastIdx] = entry;
- entry.startTimer();
- }
- } else {
- LOG.debug("Last queue entry is not the last anymore. Stopping requestDelay timer and marking entry as ready for submission")
-
- last.stopTimer();
- last.setSimilarityGroupingId(undefined);
- last.readyToSubmit = true;
- }
- }
-
- if (!handled) {
- if (this.queueOptions.size == this.items.length) {
- LOG.debug("Queue '" + this.name + "' is currently full")
-
- var b = this.getSizeExceededBehavior();
-
- var nextIdx = 0;
- while (this.items[nextIdx] && this.items[nextIdx].request) {
- nextIdx++;
- }
-
- if (this.queueOptions.onsizeexceeded) {
- this.queueOptions.onsizeexceeded.apply(this, entry.getEventArguments());
- }
- // TODO: create one function that will be implement this functionality // function (behaviorFlag, entry): should return handled flag
- if (b == DROP_NEW) {
- LOG.debug("Queue '" + this.name + "' is going to drop new item");
-
- entry.ondrop();
-
- handled = true;
- } else if (b == DROP_NEXT) {
- LOG.debug("Queue '" + this.name + "' is going to drop [" + nextIdx + "] item that is the next one");
-
- var nextEntry = this.items.splice(nextIdx, 1)[0];
- if (nextEntry) {
- LOG.debug("Item dropped from queue");
-
- nextEntry.stopTimer();
-
- nextEntry.ondrop();
- } else {
- LOG.debug("There's no such item, will handle new request instead");
-
- entry.ondrop();
-
- handled = true;
- }
- } else if (b == FIRE_NEW) {
- LOG.debug("Queue '" + this.name + "' will submit new request");
-
- entry.submit();
- handled = true;
- } else if (b == FIRE_NEXT) {
- LOG.debug("Queue '" + this.name + "' is going to drop and fire immediately [" + nextIdx + "] item that is the next one");
-
- var nextEntry = this.items.splice(nextIdx, 1)[0];
- if (nextEntry) {
- LOG.debug("Item dropped from queue");
- nextEntry.stopTimer();
- nextEntry.submit();
- } else {
- LOG.debug("There's no such item, will handle new request instead");
- entry.submit();
- handled = true;
- }
- }
- }
-
- this.submitFirst();
- }
-
- if (!handled) {
- this.queue(entry);
-
- LOG.debug("New request added to queue '" + this.name + "'. Queue similarityGroupingId changed to " + similarityGroupingId);
-
- entry.startTimer();
- }
- },
-
- pop: function() {
- LOG.debug("After request: queue '" + this.name + "'");
-
- this.dequeue();
-
- LOG.debug("There are " + this.items.length + " requests more in this queue");
-
- this.submitFirst();
- },
-
- clear: function() {
- var length = this.items.length;
- for ( var i = 0; i < this.items.length; i++) {
- this.items[i].clearEntry();
- }
-
- this.items.splice(0, length);
- }
- });
-
- return Queue;
-}();
-
-A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME = "org.richfaces.queue.global";
-
-A4J.AJAX.EventQueue.getQueue = function(name) {
- return A4J.AJAX._eventQueues[name];
-};
-
-A4J.AJAX.EventQueue.getQueues = function() {
- return A4J.AJAX._eventQueues;
-};
-
-A4J.AJAX.EventQueue.addQueue = function(queue) {
- var name = queue.name;
-
- if (A4J.AJAX._eventQueues[name]) {
- throw "Queue already registered";
- } else {
- LOG.debug("Adding queue '" + name + "' to queues registry");
- A4J.AJAX._eventQueues[name] = queue;
- }
-};
-
-A4J.AJAX.EventQueue.removeQueue = function(name) {
- var queue = A4J.AJAX._eventQueues[name];
-
- if (queue) {
- queue.clear();
- }
-
- delete A4J.AJAX._eventQueues[name];
-};
-
-A4J.AJAX.EventQueue.getOrCreateQueue = function(){
- var qualifyName = function(name, prefix) {
- if (prefix) {
- return prefix + ":" + name;
- } else {
- return name;
- }
- };
-
- var qualifyNamespace = function(name, prefix) {
- if (prefix) {
- return prefix + name;
- } else {
- return name;
- }
- };
-
- return function(options, formId) {
- var queueName = options.eventsQueue;
- var namespace = options.namespace;
-
- var formQueueName;
- var viewQueueName;
- var implicitQueueName;
-
- if (queueName) {
- LOG.debug("Look up queue with name '" + queueName + "'");
-
- formQueueName = qualifyName(queueName, formId);
- viewQueueName = qualifyNamespace(queueName, namespace);
-
- implicitQueueName = viewQueueName;
- } else {
- LOG.debug("Look up queue with default name");
-
- formQueueName = formId;
- viewQueueName = qualifyNamespace(A4J.AJAX.EventQueue.DEFAULT_QUEUE_NAME, namespace);
-
- implicitQueueName = options.implicitEventsQueue;
- }
-
- var queue = A4J.AJAX._eventQueues[formQueueName];
- if (!queue) {
- queue = A4J.AJAX._eventQueues[viewQueueName];
- if (!queue) {
- if (implicitQueueName) {
- queue = A4J.AJAX._eventQueues[implicitQueueName];
- if (!queue) {
- LOG.debug("Creating new transient queue '" + implicitQueueName + "' with default settings");
- queue = new A4J.AJAX.EventQueue(implicitQueueName);
- queue._transient = true;
-
- A4J.AJAX.EventQueue.addQueue(queue);
- } else {
- LOG.debug("Found transient queue '" + implicitQueueName + "'");
- }
- }
- } else {
- LOG.debug("Found view queue '" + viewQueueName + "'");
- }
- } else {
- LOG.debug("Found form queue '" + formQueueName + "'");
- }
-
- return queue;
- }
-}();
-
-(function () {
- var observer = function() {
- var queues = A4J.AJAX.EventQueue.getQueues();
- for (var queueName in queues) {
- var queue = queues[queueName];
- queue.clear();
- }
- };
-
- if (window.addEventListener) {
- window.addEventListener("unload", observer, false);
- } else {
- window.attachEvent("onunload", observer);
- }
-})();
-
-/**
- * Provide client side logging capabilities to AJAX applications.
- *
- * @author <a href="mailto:thespiegs@users.sourceforge.net">Eric Spiegelberg</a>
- * @see <a href="http://sourceforge.net/projects/log4ajax">Log4Ajax</a>
- */
-if (!window.LOG) {
- window.LOG = {};
-}
-
-LOG.Level = function(name, priority, color){
- this.name = name;
- this.priority = priority;
- if(color){
- this.color = color;
- }
-}
-
-LOG.OFF = new LOG.Level("off", 1000);
-LOG.FATAL = new LOG.Level("fatal", 900, "red");
-LOG.ERROR = new LOG.Level("error", 800, "red");
-LOG.WARN = new LOG.Level("warn", 500, "yellow");
-LOG.INFO = new LOG.Level("info", 400, "blue");
-LOG.DEBUG = new LOG.Level("debug", 300, "darkblue");
-LOG.ALL = new LOG.Level("all", 100);
-LOG.A4J_DEBUG = new LOG.Level("a4j_debug", 0, "green");
-
-LOG.LEVEL = LOG.OFF;
-
-LOG._window = null;
-LOG.transmitToServer = true;
-LOG.consoleDivId = "logConsole";
-LOG.styles = {
-a4j_debug: "green",
-debug : "darkblue",
-info : "blue",
-warn : "yellow",
-error : "red",
-fatal : "red"
-};
-
-LOG.a4j_debug = function(msg,pre)
-{
- LOG._log(msg, LOG.A4J_DEBUG ,pre);
-}
-
-LOG.debug = function(msg,pre)
-{
- LOG._log(msg, LOG.DEBUG ,pre);
-}
-
-LOG.info = function(msg,pre)
-{
- LOG._log(msg, LOG.INFO ,pre);
-}
-
-LOG.warn = function(msg,pre)
-{
- LOG._log(msg, LOG.WARN ,pre);
-}
-
-LOG.error = function(msg,pre)
-{
- LOG._log(msg, LOG.ERROR ,pre);
-}
-
-LOG.fatal = function(msg,pre)
-{
- LOG._log(msg, LOG.FATAL ,pre);
-}
-
-LOG.registerPopup = function(hotkey,name,width,height,level){
- if(!LOG._onkeydown){
- LOG._onkeydown = document.onkeydown;
- }
- var key = hotkey.toUpperCase();
- document.onkeydown = function(e){
- if (window.event){ e = window.event;};
- if (String.fromCharCode(e.keyCode) == key & e.shiftKey & e.ctrlKey){
- LOG.LEVEL = level;
- LOG.openWindow(name,'width='+width+',height='+height+',toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,left = '+((screen.width - width) / 2)+',top ='+((screen.height - height) / 2));
- } else {
- if(LOG._onkeydown) LOG._onkeydown(e);
- };
- }
-}
-
-LOG.clear = function() {
- if(LOG._window && LOG._window.document){
- consoleDiv = LOG._window.document.body;
- } else {
- consoleDiv = window.document.getElementById(LOG.consoleDivId);
- }
-
- consoleDiv.innerHTML = '<button onclick="LOG.clear()">Clear</button><br />';
-}
-
-LOG.openWindow = function(name,features){
- if(LOG._window){
- LOG._window.focus();
- } else {
- LOG._window = window.open("",name,features);
-
- LOG._window.LOG = LOG;
- LOG.clear();
-
- var _LOG = LOG;
- LOG._window.onunload = function(){
- _LOG._window.LOG = null;
- _LOG._window = null;
- _LOG.LEVEL = _LOG.OFF;
- _LOG=undefined;
- }
- }
-}
-
-LOG._log = function(msg, logLevel,pre)
-{
- if(logLevel.priority >= LOG.LEVEL.priority){
- LOG._logToConsole(msg, logLevel,pre);
-
- if (LOG.transmitToServer)
- {
- LOG._logToServer(msg, logLevel);
- }
- }
-}
-
-LOG._time = function(){
- var currentTime = new Date();
- var hours = currentTime.getHours();
- var minutes = currentTime.getMinutes();
- if (minutes < 10){
- minutes = "0" + minutes;
- }
- var seconds = currentTime.getSeconds();
- if (seconds < 10){
- seconds = "0" + seconds;
- }
- var millisec = currentTime.getTime()%1000;
- if(millisec<100){
- millisec = "0"+millisec;
- }
- if(millisec<10){
- millisec = "0"+millisec;
- }
- return hours+":"+minutes+":"+seconds+","+millisec;
-}
-
-LOG._logToConsole = function(msg, logLevel,preformat)
-{
- var consoleDiv ;
- var doc;
- if(LOG._window && LOG._window.document){
- doc = LOG._window.document;
- consoleDiv = LOG._window.document.body;
- } else {
- doc = window.document;
- consoleDiv = window.document.getElementById(LOG.consoleDivId);
- }
- if (consoleDiv)
- {
- var span = doc.createElement("span");
- span.style.color=logLevel.color;
- span.appendChild(doc.createTextNode(logLevel.name+"["+LOG._time()+"]: "));
- var div = doc.createElement("div");
- var textnode = doc.createTextNode(msg);
- div.appendChild(span);
- div.appendChild(textnode);
- // preformatted - for example, html
- if(preformat){
- var pre = doc.createElement("span");
- textnode = doc.createTextNode(preformat);
- pre.appendChild(textnode);
- div.appendChild(pre);
- }
- consoleDiv.appendChild(div);
-/*
- consoleDiv.innerHTML = "<span style='" + LOG.styles[logLevel] + "'>" +
- logLevel + "</span>: " + msg + "<br/>" +
- consoleDiv.innerHTML;*/
- }
- else
- {
- // If the consoleDiv is not available, you could create a
- // new div or open a new window.
- }
-}
-
-LOG._logToServer = function(msg, logLevel)
-{
- var data = logLevel.name.substring(0, 1) + msg;
- // TODO - use sarissa-enabled request.
- // Use request.js to make an AJAX transmission to the server
-// Http.get({
-// url: "log",
-// method: "POST",
-// body: data,
-// callback: LOG._requestCallBack
-// });
-}
-
-LOG._requestCallBack = function()
-{
- // Handle callback functionality here; if appropriate
-}
-/*
-* final trail for ajax jsf library
-*/
-// }
-//memory-leaks sanitizing code
-if (!window.RichFaces) {
- window.RichFaces = {};
-}
-
-if (!window.RichFaces.Memory) {
- window.RichFaces.Memory = {
-
- nodeCleaners: {},
- componentCleaners: {},
-
- addCleaner: function (name, cleaner) {
- this.nodeCleaners[name] = cleaner;
- },
-
- addComponentCleaner: function (name, cleaner, checker) {
- this.componentCleaners[name] = {cleaner: cleaner, checker: checker};
- },
-
- applyCleaners: function (node, isAjax, componentNodes) {
- for (var name in this.nodeCleaners) {
- this.nodeCleaners[name](node, isAjax);
- }
- for (var name in this.componentCleaners) {
- if (this.componentCleaners[name].checker(node, isAjax))
- componentNodes.push(node);
- }
- },
-
- _clean: function (oldNode, isAjax, componentNodes) {
- if (oldNode) {
- this.applyCleaners(oldNode, isAjax, componentNodes);
-
- //node.all is quicker than recursive traversing
- //window doesn't have "all" attribute
- var all = oldNode.all;
-
- if (all) {
- var counter = 0;
- var length = all.length;
-
- for (var counter = 0; counter < length; counter++ ) {
- this.applyCleaners(all[counter], isAjax, componentNodes);
- }
- } else {
- var node = oldNode.firstChild;
- while (node) {
- this._clean(node, isAjax, componentNodes);
- node = node.nextSibling;
- }
- }
- }
- },
-
- _cleanComponentNodes: function (oldNodes, isAjax) {
- for (var i=0; i<oldNodes.length; i++) {
- var node = oldNodes[i];
- for (var name in this.componentCleaners) {
- this.componentCleaners[name].cleaner(node, isAjax);
- }
- }
- },
-
- clean: function (oldNode, isAjax) {
- var componentNodes = [];
- this._clean(oldNode, isAjax, componentNodes);
- this._cleanComponentNodes(componentNodes, isAjax);
- componentNodes = null;
- }
- };
-
- window.RichFaces.Memory.addComponentCleaner("richfaces", function(node, isAjax) {
- var component = node.component;
- if (component) {
- var destructorName = component["rich:destructor"];
- //destructor name is required to be back-compatible
- if (destructorName) {
- var destructor = component[destructorName];
- if (destructor) {
- destructor.call(component, isAjax);
- }
- }
- }
- }, function(node, isAjax) {
- return (node.component && node.component["rich:destructor"]);
- });
-
- if (window.attachEvent) {
- window.attachEvent("onunload", function() {
- var memory = window.RichFaces.Memory;
- memory.clean(document);
- memory.clean(window);
- });
- }
-}
-
-//
-
-if (!window.RichFaces) window.RichFaces = {};
-
-
-
-RichFaces.SortController = function() {
- var controlsByTable = {};
-
- return {
- registerControl : function(control) {
- var tableId = control.tableId;
- var sortExpression = control.sortExpression;
- var controlId = control.id;
- var columnId = control.columnId;
-
- var byTable = controlsByTable[tableId];
- if (!byTable) {
- byTable = {columns: {}, expressions : {}};
- controlsByTable[tableId] = byTable;
- }
- var byExpression;
- if (sortExpression) {
- byExpression = byTable.expressions[sortExpression];
- if (!byExpression) {
- byExpression = {};
- byTable.expressions[sortExpression] = byExpression;
- }
- } else if (columnId) {
- byExpression = byTable.columns[columnId];
- if (!byExpression) {
- byExpression = {};
- byTable.columns[columnId] = byExpression;
- }
- }
- if(byExpression) {
- var byId = byExpression[controlId];
- if (byId) {
- //TODO: delete controls already registered??
- } else {
- byExpression[controlId] = control;
- }
- }
- },
-
- controlsByTable : function(tableId) {
- var map = controlsByTable[tableId] || {expressions: {}, columns :{}};
- var result = [];
- ['expressions', 'columns'].each(
- function(part) {
- var parts = map[part];
- if (parts) {
- $H(parts).values().each(
- function(x) {
- result = result.concat($H(x).values());
- }
- );
- }
-
- }
- );
- return result.uniq();
- },
- controls : function(tableId, sortExpression, columnId) {
- var map = controlsByTable[tableId] || {expressions: {}, columns :{}};
- var array;
- if (typeof sortExpression != 'undefined') {
- array = $H(map.expressions[sortExpression]).values();
- }
- if (typeof columnId != 'undefined') {
- var a = $H(map.columns[columnId]).values();
- if (array) {
- array = array.concat(a).uniq();
- } else {
- array = a;
- }
- }
- return array;
-
- }
- };
-}();
-
-
-RichFaces.SortControl = Class.create({
- initialize : function(id, tableId, sortExpression, columnId) {
- this.id = id;
- this.tableId = tableId;
- this.columnId = columnId;
- this.sortExpression = sortExpression;
- this.prepareEvents();
- //TODO:Set cursor via clazz
- //element.setStyle({cursor: "pointer"});
-
- RichFaces.SortController.registerControl(this);
-
- },
-
- prepareEvents : function() {
- this.onclick = this.invoke.bindAsEventListener(this);
- var element = this.getElement();
- element.observe("click", this.onclick);
- },
- getElement : function () {
- return $($(this.id)/*.parentNode*/);
- },
- displaySortedAscending : function() {
- this.getElement()
- .removeClassName("rich-sort-desc")
- .addClassName("rich-sort-asc");
- },
- displaySortedDescending : function() {
- this.getElement()
- .removeClassName("rich-sort-asc")
- .addClassName("rich-sort-desc");
- },
- displayNotSortedAtAll : function() {
- this.getElement()
- .removeClassName("rich-sort-desc")
- .removeClassName("rich-sort-asc");
- },
- invoke : function(event) {
- var sortExpression;
-
- if (this.sortExpression) {
- sortExpression = this.sortExpression;
- } else {
- var cell = Event.findElement(event, "th,td");
- if (cell) {
- sortExpression = cell.cellIndex;
- }
- }
- if (typeof sortExpression != 'undefined') {
- $(this.tableId).component.changeSorting(new RichFaces.SortOrder([new RichFaces.SortField(sortExpression)]), this.columnId);
- }
- }
-});
-
-RichFaces.SortOrder = Class.create({
- initialize : function(fields) {
- this.fieldz = fields || [];
- },
- fields : function() {
- return this.fieldz;
- }
-});
-
-
-
-
-RichFaces.SortField = function(sortExpression, asc) {
- this.sortExpression = sortExpression;
- this.asc = asc;
-};
-
-RichFaces.SortMode = Class.create({
- merge : function(oldSortOrder, newSortOrder) {
- return oldSortOrder;
- }
-});
-
-/**
- * Basically toggle any existing
- */
-RichFaces.SortMode.Single = Class.create(RichFaces.SortMode, {
- merge : function(oldSortOrder, newSortOrder) {
- var newFields = newSortOrder.fields();
- var oldFields = oldSortOrder.fields();
- var expr;
- var asc;
- if (oldFields.length > 0) {
- expr = oldFields[0].sortExpression;
- asc = oldFields[0].asc;
- }
- if (newFields.length > 0) {
- var xpr = newFields[0].sortExpression;
- if (xpr == expr) {
- asc = !asc;
- } else {
- expr = xpr;
- asc = true;
- }
- }
- oldSortOrder = new RichFaces.SortOrder([new RichFaces.SortField(expr, asc)]);
- return oldSortOrder;
- }
-});
-
-
-RichFaces.DataTable = Class.create({
- initialize : function(id, options) {
- var table = $(id);
- table.component = this;
-
- this.sortMode = options.sortMode || new RichFaces.SortMode();
- this.id = id;
- this.sortOrder = options.sortOrder || new RichFaces.SortOrder();
- this._compare = this.compare.bind(this);
- },
- /**
- * Call this method to sort the table
- * @param sortOrder - new sortOrder
- * @param force if true, new sortOrder will completely replace previous one, otherwise sortOrders are merged using sortMode
- */
- changeSorting : function(sortOrder, columnId, force){
- if (force) {
- this.sortOrder = sortOrder;
- } else {
- this.sortOrder = this.sortMode.merge(this.sortOrder, sortOrder);
- }
- this.sort();
- var tableId = this.id;
-
- var cbt = $A(RichFaces.SortController.controlsByTable(tableId));
- cbt.each(
- function(control) {
- control.displayNotSortedAtAll();
- }
- );
- $A(this.sortOrder.fields()).each(
- function(field) {
- var ctrls =
- RichFaces.SortController.controls(tableId, field.sortExpression, columnId);
- $A(ctrls).each(function(control) {
- if (field.asc) {
- control.displaySortedAscending();
- } else {
- control.displaySortedDescending();
- }
- });
- }
- );
- },
-
- sort : function() {
- var table = $(this.id);
- var tbody = table.tBodies[0];
- if (tbody) {
- var newTbody = tbody.cloneNode(false);
- var newCollection = $A(tbody.rows).clone();
- newCollection.sort(this._compare);
- for(var i = 0; i < newCollection.length; i++) {
- newTbody.appendChild(newCollection[i]);
- }
- tbody.parentNode.replaceChild(newTbody, tbody);
- }
-
- },
- compare : function(row1, row2) {
- var fields = this.sortOrder.fields();
- var result = 0;
- for(var i = 0; i < fields.length && result == 0; i++) {
- var field = fields[i];
- var expression = field.sortExpression;
- if (typeof (expression) == 'function') {
- result = expression(row1, row2);
- } else if (typeof (expression) == 'number') {
- var c1 = row1.cells[expression];
- var c2 = row2.cells[expression];
- if (c1) {
- c1 = c1.innerHTML.stripTags();
-
- }
- if (c2) {
- c2 = c2.innerHTML.stripTags();
- }
-
- result = ((c1 == c2) ? 0 : ((c1 < c2) ? -1 : 1));
- }
-
- if (field.asc == false) {
- result = -result;
- }
-
- }
- return result;
-
-
- }
-});
-RichFaces.SortControl.Server = Class.create(RichFaces.SortControl, {
- invoke : function(event) {
- $(this.id + 's').click();
- }
-});
-RichFaces.SortControl.Ajax = Class.create(RichFaces.SortControl, {
- initialize: function(id, f) {
- this.id = id;
- this.f = f;
- this.prepareEvents();
- },
- invoke : function(event) {
- this.f(event);
- }
-});
-
-RichFaces.blurFilterInput = function(event) {
- if (event.keyCode == Event.KEY_RETURN && Event.element(event)) {
- Event.element(event).blur();
- return false;
- }
-};
-
-if (!window.Richfaces) {
- window.Richfaces = {};
-}
-
-Richfaces.mergeStyles = function(userStyles,commonStyles) {
- var i;
- for(i in userStyles) {
- if (typeof userStyles[i] == "object") {
- this.mergeStyles(userStyles[i],commonStyles[i]);
- } else {
- commonStyles[i] += " " + userStyles[i];
- }
- }
- return commonStyles;
-};
-
-Richfaces.getComputedStyle = function(eltId, propertyName) {
- var elt = $(eltId);
-
- if (elt.nodeType != Node.ELEMENT_NODE) {
- return "";
- }
-
- if (elt.currentStyle) {
- return elt.currentStyle[propertyName];
- }
-
- if (document.defaultView && document.defaultView.getComputedStyle) {
-
- var styles = document.defaultView.getComputedStyle(elt, null);
- if (styles) {
- return styles.getPropertyValue(propertyName);
- }
-
- }
-
- return "";
-};
-
-Richfaces.getComputedStyleSize = function(eltId, propertyName) {
- var value = Richfaces.getComputedStyle(eltId, propertyName);
-
- if (value) {
- value = value.strip();
- value = value.replace(/px$/, "");
-
- return parseFloat(value);
- }
-
- return 0;
-};
-
-Richfaces.getWindowSize = function() {
- var myWidth = 0, myHeight = 0;
- if( typeof( window.innerWidth ) == 'number' ) {
- myWidth = window.innerWidth;
- myHeight = window.innerHeight;
- } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
- myWidth = document.documentElement.clientWidth;
- myHeight = document.documentElement.clientHeight;
- } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
- myWidth = document.body.clientWidth;
- myHeight = document.body.clientHeight;
- }
- return {"width":myWidth,"height":myHeight};
-};
-
-Richfaces.removePX = function(str) {
- var pxIndex = str.indexOf("px")
- if ( pxIndex == -1 ) return str;
- return str.substr(0,pxIndex);
-};
-
-Richfaces.visitTree = function(root, callback) {
- var node = root;
- if (!node) {
- node = document;
- }
-
- callback.call(this, node);
-
- var child = node.firstChild;
- while (child) {
- Richfaces.visitTree(child, callback);
- child = child.nextSibling;
- }
-};
-
-Richfaces.getNSAttribute = function (name, element) {
- if (element.getAttributeNS) {
- var attr = element.getAttributeNS('http://richfaces.ajax4jsf.org/rich', name);
- if (attr) {
- return attr;
- }
- }
-
- var attributes = element.attributes;
- var attrName = "rich:" + name;
- var attr = attributes[attrName];
- if (attr) {
- return attr.nodeValue;
- }
-
-// for (var i = 0; i < attributes.length; i++) {
-// attr = attributes[i];
-// if (attr && attrName == attr.nodeName) {
-// return attr.nodeValue;
-// }
-// }
-
- return null;
-};
-
-Richfaces.VARIABLE_NAME_PATTERN = /^\s*[_,A-Z,a-z][\w,_\.]*\s*$/;
-
-Richfaces.getObjectValue = function (str, object) {
- var a=str.split(".");
- var value=object[a[0]];
- var c=1;
- while (value && c<a.length) value = value[a[c++]];
- return (value ? value : "");
-}
-
-Richfaces.evalMacro = function(template, object)
-{
- var value="";
- // variable evaluation
- if (Richfaces.VARIABLE_NAME_PATTERN.test(template))
- {
- if (template.indexOf('.')==-1) {
- value = object[template];
- if (!value) value=window[template];
- }
- // object's variable evaluation
- else {
- value = Richfaces.getObjectValue(template, object);
- if (!value) value=Richfaces.getObjectValue(template, window);
- }
- if (value && typeof value=='function') value = value(object);
- if (!value) value="";
- }
- //js string evaluation
- else {
- try {
- if (Richfaces.browser.isObjectEval) {
- value = object.eval(template);
- }
- else with (object) {
- value = eval(template) ;
- }
-
- if (typeof value == 'function') {
- value = value(object);
- }
- } catch (e) { LOG.warn("Exception: "+e.Message + "\n[" + template + "]"); }
- }
- return value;
-}
-Richfaces.evalSimpleMacro = function(template, object)
-{
- var value = object[template];
- if (!value) {value=window[template]; if (!value) value="";}
- return value;
-}
-
-Richfaces.getComponent = function(componentType, element)
-{
- var attribute="richfacesComponent";
- var type = "richfaces:"+componentType;
- while (element.parentNode) {
- if (element[attribute] && element[attribute]==type)
- return element.component;
- else
- element = element.parentNode;
- }
-}
-
-Richfaces.browser= {
- isIE: (!window.opera && /MSIE/.test(navigator.userAgent)),
- isIE6: (!window.opera && /MSIE\s*[6][\d,\.]+;/.test(navigator.userAgent)),
- isSafari: /Safari/.test(navigator.userAgent),
- isOpera: !!window.opera,
- isObjectEval: (Richfaces.eval!=undefined),
- isFF3: (!window.opera && /Firefox\s*[\/]3[\.]/.test(navigator.userAgent))
-};
-
-Richfaces.eval = function(template, object) {
- var value = '';
-
- try {
- with (object) {
- value = eval(template) ;
- }
- } catch (e) {
- LOG.warn('Exception: ' + e.message + '\n[' + template + ']');
- }
-
- return value;
-};
-
-Richfaces.interpolate = function (placeholders, context) {
-
- for(var k in context) {
- var v = context[k];
- var regexp = new RegExp("\\{" + k + "\\}", "g");
- placeholders = placeholders.replace(regexp, v);
- }
-
- return placeholders;
-
-};
-
-if (!Richfaces.position) Richfaces.Position={};
-
-Richfaces.Position.setElementPosition = function(element, baseElement, jointPoint, direction, offset)
-{
- // parameters:
- // jointPoint: {x:,y:} or ('top-left','top-right','bottom'-left,'bottom-right')
- // direction: ('top-left','top-right','bottom'-left,'bottom-right', 'auto')
- // offset: {x:,y:}
-
- var elementDim = Richfaces.Position.getOffsetDimensions(element);
- var baseElementDim = Richfaces.Position.getOffsetDimensions(baseElement);
-
- var windowRect = Richfaces.Position.getWindowViewport();
-
- var baseOffset = Position.cumulativeOffset(baseElement);
-
- // jointPoint
- var ox=baseOffset[0];
- var oy=baseOffset[1];
- var re = /^(top|bottom)-(left|right)$/;
- var match;
-
- if (typeof jointPoint=='object') {ox = jointPoint.x; oy = jointPoint.y}
- else if ( jointPoint && (match=jointPoint.toLowerCase().match(re))!=null )
- {
- if (match[2]=='right') ox+=baseElementDim.width;
- if (match[1]=='bottom') oy+=baseElementDim.height;
- } else
- {
- // ??? auto
- }
-
- // direction
- if (direction && (match=direction.toLowerCase().match(re))!=null )
- {
- var d = direction.toLowerCase().split('-');
- if (match[2]=='left') { ox-=elementDim.width + offset.x; } else ox += offset.x;
- if (match[1]=='top') { oy-=elementDim.height + offset.y; } else oy += offset.y
- } else
- {
- // auto
- var theBest = {square:0};
- // jointPoint: bottom-right, direction: bottom-left
- var rect = {right: baseOffset[0] + baseElementDim.width, top: baseOffset[1] + baseElementDim.height};
- rect.left = rect.right - elementDim.width;
- rect.bottom = rect.top + elementDim.height;
- ox = rect.left; oy = rect.top;
- var s = Richfaces.Position.checkCollision(rect, windowRect);
- if (s!=0)
- {
- if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox, y:oy, square:s};
- // jointPoint: top-right, direction: top-left
- rect = {right: baseOffset[0] + baseElementDim.width, bottom: baseOffset[1]};
- rect.left = rect.right - elementDim.width;
- rect.top = rect.bottom - elementDim.height;
- ox = rect.left; oy = rect.top;
- s = Richfaces.Position.checkCollision(rect, windowRect);
- if (s!=0)
- {
- if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox, y:oy, square:s};
- // jointPoint: bottom-left, direction: bottom-right
- rect = {left: baseOffset[0], top: baseOffset[1] + baseElementDim.height};
- rect.right = rect.left + elementDim.width;
- rect.bottom = rect.top + elementDim.height;
- ox = rect.left; oy = rect.top;
- s = Richfaces.Position.checkCollision(rect, windowRect);
- if (s!=0)
- {
- if (ox>=0 && oy>=0 && theBest.square<s) theBest = {x:ox, y:oy, square:s};
- // jointPoint: top-left, direction: top-right
- rect = {left: baseOffset[0], bottom: baseOffset[1]};
- rect.right = rect.left + elementDim.width;
- rect.top = rect.bottom - elementDim.height;
- ox = rect.left; oy = rect.top;
- s = Richfaces.Position.checkCollision(rect, windowRect);
- if (s!=0)
- {
- // the best way selection
- if (ox<0 || oy<0 || theBest.square>s) {ox=theBest.x; oy=theBest.y}
- }
- }
- }
-
- }
- }
-
- element.style.left = ox + 'px';
- element.style.top = oy + 'px';
-};
-
-Richfaces.Position.getOffsetDimensions = function(element) {
- // from prototype 1.5.0 // Pavel Yascenko
- element = $(element);
- var display = $(element).getStyle('display');
- if (display != 'none' && display != null) // Safari bug
- return {width: element.offsetWidth, height: element.offsetHeight};
-
- // All *Width and *Height properties give 0 on elements with display none,
- // so enable the element temporarily
- var els = element.style;
- var originalVisibility = els.visibility;
- var originalPosition = els.position;
- var originalDisplay = els.display;
- els.visibility = 'hidden';
- els.position = 'absolute';
- els.display = 'block';
- var originalWidth = element.offsetWidth; // was element.clientWidth // Pavel Yascenko
- var originalHeight = element.offsetHeight; // was element.clientHeight // Pavel Yascenko
- els.display = originalDisplay;
- els.position = originalPosition;
- els.visibility = originalVisibility;
- return {width: originalWidth, height: originalHeight};
-};
-
-Richfaces.Position.checkCollision = function(elementRect, windowRect, windowOffset)
-{
- if (elementRect.left >= windowRect.left &&
- elementRect.top >= windowRect.top &&
- elementRect.right <= windowRect.right &&
- elementRect.bottom <= windowRect.bottom)
- return 0;
-
- var rect = {left: (elementRect.left>windowRect.left ? elementRect.left : windowRect.left),
- top: (elementRect.top>windowRect.top ? elementRect.top : windowRect.top),
- right: (elementRect.right<windowRect.right ? elementRect.right : windowRect.right),
- bottom: (elementRect.bottom<windowRect.bottom ? elementRect.bottom : windowRect.bottom)};
- return (rect.right-rect.left)* (rect.bottom-rect.top);
-};
-
-
-Richfaces.Position.getWindowDimensions = function() {
- var w = self.innerWidth
- || document.documentElement.clientWidth
- || document.body.clientWidth
- || 0;
- var h = self.innerHeight
- || document.documentElement.clientHeight
- || document.body.clientHeight
- || 0;
- return {width:w, height: h};
-};
-
-Richfaces.Position.getWindowScrollOffset = function() {
- var dx = window.pageXOffset
- || document.documentElement.scrollLeft
- || document.body.scrollLeft
- || 0;
- var dy = window.pageYOffset
- || document.documentElement.scrollTop
- || document.body.scrollTop
- || 0;
- return {left:dx, top: dy};
-};
-
-Richfaces.Position.getWindowViewport = function() {
- var windowDim = Richfaces.Position.getWindowDimensions();
- var windowOffset = Richfaces.Position.getWindowScrollOffset();
- return {left:windowOffset.left, top:windowOffset.top, right: windowDim.width+windowOffset.left, bottom: windowDim.height+windowOffset.top};
-};
-
-Richfaces.firstDescendant = function(node) {
- var n = node.firstChild;
- while (n && n.nodeType != 1) {
- n = n.nextSibling;
- }
-
- return n;
-};
-
-Richfaces.lastDescendant = function(node) {
- var n = node.lastChild;
- while (n && n.nodeType != 1) {
- n = n.previousSibling;
- }
-
- return n;
-};
-
-Richfaces.next = function(node) {
- var n = node;
- do {
- n = n.nextSibling;
- } while (n && n.nodeType != 1);
-
- return n;
-};
-
-Richfaces.previous = function(node) {
- var n = node;
- do {
- n = n.previousSibling;
- } while (n && n.nodeType != 1);
-
- return n;
-};
-
-Richfaces.removeNode = function(node) {
- if (node) {
- var parentNode = node.parentNode;
- if (parentNode) {
- parentNode.removeChild(node);
- }
- }
-};
-
-Richfaces.readAttribute = function(element, name) {
- var result = null;
-
- var node = element.getAttributeNode(name);
- if (node) {
- result = node.nodeValue;
- }
-
- return result;
-};
-
-Richfaces.writeAttribute = function(element, name, value) {
- var node = element.getAttributeNode(name);
-
- if (value !== null) {
- if (node) {
- node.nodeValue = value;
- } else {
- node = document.createAttribute(name);
- node.nodeValue = value;
- element.setAttributeNode(node);
- }
- } else {
- if (node) {
- element.removeAttributeNode(node);
- }
- }
-};
-
-Richfaces.mergeObjects = function() {
- var target = arguments[0];
- if (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- if (source) {
- for (var name in source) {
- if (!target[name]) {
- target[name] = source[name];
- }
- }
- }
- }
- }
-};
-
-Richfaces.invokeEvent = function(eventFunc, element, eventName, memo) {
- var result;
- if (eventFunc) {
- element = $(element);
- if (element == document && document.createEvent && !element.dispatchEvent)
- element = document.documentElement;
-
- var event;
- if (document.createEvent) {
- event = document.createEvent("HTMLEvents");
- event.initEvent("dataavailable", true, true);
- } else {
- event = document.createEventObject();
- event.eventType = "ondataavailable";
- }
-
- event.eventName = eventName;
- event.rich = {component:this};
- event.memo = memo || { };
- try {
- result = eventFunc.call(element,event);
- }
- catch (e) { LOG.warn("Exception: "+e.Message + "\n[on"+eventName + "]"); }
- }
- if (result!=false) result = true;
- return result;
-};
-if (!window.RichShuttleUtils) {
- window.RichShuttleUtils = {};
-}
-
-RichShuttleUtils.execOnLoad = function(func, condition, timeout) {
-
- if (condition()) {
- func();
- } else {
- window.setTimeout(
- function() {
- RichShuttleUtils.execOnLoad(func, condition, timeout);
- },
- timeout
- );
- }
-};
-RichShuttleUtils.Condition = {
- ElementPresent : function(el) {
- return function () {
- //var el = $(element);
- return el && el.offsetHeight > 0;
- };
- }
-};
-
-Array.prototype.remove = function(object) {
- var index = this.indexOf(object, 0, this.length);
- if (index == -1) return;
- if (index == 0) {
- this.shift();
- } else {
- this.splice(index, 1);
- }
-};
-if (!window.Richfaces) { window.Richfaces = {}; }
-
-Richfaces.getExternalClass = function(classes, index) {
- if (classes) {
- var len = classes.length;
- while (index >= len) {
- index -= len;
- }
- return (classes[index]) ? classes[index] : "";
- }
- return "";
-}
-
-Richfaces.SelectItem = Class.create();
-
-Richfaces.SelectItem.findElement = function(elt, id) {
- var e = elt;
-
- if (e) {
- if (e.id == id) {
- return e;
- }
-
- e = e.firstChild;
- while (e) {
- var result = arguments.callee(e, id);
-
- if (result) {
- return result;
- }
-
- e = e.nextSibling;
- }
- }
-
- return null;
-};
-
-Richfaces.SelectItem.prototype = {
- initialize : function(label, id, node) {
- this._label = label;
- this._node = node;
-
- this._node.item = this;
- this._id = id;
-
- //XXX 2 optimize
- this.input = Richfaces.SelectItem.findElement(node, node.id + "StateInput");
-
- this.selected = /^s/.test(this.input.value);
- this.active = /^s?a/.test(this.input.value);
- },
-
- destroy: function() {
- this._node.item = null;
- },
-
- doActive : function(rowStoredClass, cellStoredClasses) {
- var classes = this.CLASSES;
- var row = this._node;
- var rowClass = classes.ROW.ACTIVE;
- var cellClass = classes.CELL.ACTIVE;
- if (this.isSelected()) {
- rowClass = classes.ROW.SELECTED + " " + classes.ROW.ACTIVE;
- cellClass = classes.CELL.SELECTED + " " + classes.CELL.ACTIVE;
- }
- this.changeClass(row, rowClass, cellClass, rowStoredClass, cellStoredClasses);
-
- this.active = true;
-
- this.saveState();
- },
-
- doSelect : function(rowStoredClass, cellStoredClasses) {
- var row = this._node;
- var classes = this.CLASSES;
-
- this.changeClass(row, classes.ROW.SELECTED, classes.CELL.SELECTED, rowStoredClass, cellStoredClasses);
-
- this.selected = true;
-
- this.saveState();
- },
-
- doNormal : function(rowStoredClass, cellStoredClasses) {
- var row = this._node;
- var classes = this.CLASSES;
-
- this.changeClass(row, classes.ROW.NORMAL, classes.CELL.NORMAL, rowStoredClass, cellStoredClasses);
-
- this.active = false;
- this.selected = false;
-
- this.saveState();
- },
-
- isSelected : function() {
- return this.selected;
- },
-
- isActive : function() {
- return this.active;
- },
-
- changeClass : function(row, rowClassName, cellClassName, rowStoredClass, cellStoredClasses) {
- row.className = rowStoredClass + " " + rowClassName;
- var cells = row.cells;
- for (var i = 0; i < cells.length; i++) {
- var cell = cells[i];
- cell.className = Richfaces.getExternalClass(cellStoredClasses, cell.cellIndex) + " " + cellClassName;
- }
- },
-
- /*addClass : function(row, classNameRow, classNameCell) {
- if (row.addClassName) {
- row.addClassName(classNameRow);
- } else {
- Element.addClassName(row, classNameRow);
- }
-
- var cells = row.cells;
- for (var i = 0; i < cells.length; i++) {
- var cell = cells[i];
- if (cell.addClassName) {
- cell.addClassName(classNameCell);
- } else {
- Element.addClassName(cell, classNameCell);
- }
- }
- },
-
- removeClass : function(row, classNameRow, classNameCell) {
- if (row.removeClassName) {
- row.removeClassName(classNameRow);
- } else {
- Element.removeClassName(row, classNameRow);
- }
- var cells = row.cells;
- for (var i = 0; i < cells.length; i++) {
- var cell = cells[i];
-
- if (cell.removeClassName) {
- cell.removeClassName(classNameCell);
- } else {
- Element.removeClassName(cell, classNameCell);
- }
- }
- },*/
-
- saveState: function() {
- var regex = /^s?a?/;
-
- if (this.selected && this.active) {
- this.input.value = this.input.value.replace(regex, 'sa');
- } else if (this.selected) {
- this.input.value = this.input.value.replace(regex, 's');
- } else if (this.active) {
- this.input.value = this.input.value.replace(regex, 'a');
- } else {
- this.input.value = this.input.value.replace(regex, '');
- }
- }
-}
-
-LayoutManager = function(headerId, contentId) {
- this.headerTable = $(headerId);
- this.contentTable = $(contentId);
- this.headerDiv = (this.headerTable) ? this.headerTable.parentNode : null;
- this.contentDiv = this.contentTable.parentNode;
-
- Event.observe(this.contentDiv, "scroll", this.scrollHandler.bindAsEventListener(this));
-
-}
-
-LayoutManager.SCROLL_WIDTH = 17;
-
-LayoutManager.STYLE_CONTENTTD_BORDER = 1;
-LayoutManager.STYLE_CONTENTTD_PADDING = 4;
-
-LayoutManager.prototype.widthSynchronization = function() {
- if (Prototype.Browser.IE && this.contentDiv && this.contentTable && this.getScrollWidth()) {
- //IE displays unnecessary horizontal scroll
- //when vertical scroll's displayed
- if (this.contentTable.offsetWidth && ((this.contentTable.offsetWidth <= this.contentDiv.clientWidth))) {
- this.contentTable.style.width = this.contentDiv.clientWidth + "px";
- if (this.headerTable) {
- this.headerTable.style.width = this.contentDiv.offsetWidth + "px";
- }
- this.contentDiv.style.overflowX = 'hidden';
- }
- } else {
- this.contentTable.style.width = "100%";
- }
-
- var rows = this.contentTable.tBodies[0].rows;
- if (rows && rows[0]) {
- //table can be empty
- var contentCells = rows[0].cells;
- if (!this.headerTable || !this.headerTable.tHead)
- return ;
- var headerCells = this.headerTable.tHead.rows[0].cells;
- var width;
- for (var i = 0; i < contentCells.length; i++) {
- var curCell = contentCells[i];
- var headCell = headerCells[i];
-
- width = LayoutManager.calculateWidth(curCell, headCell).colWidth;
- if (i == contentCells.length - 1) {
- width = width + this.getScrollWidth();
- }
- headCell.firstChild.style.width = width + "px";
- headCell.style.width = width + "px";
- }
- } else {
- if (this.headerTable && this.headerTable.tHead) {
- this.headerTable.style.width = "100%";
- }
- }
-}
-
-LayoutManager.prototype.getScrollWidth = function() {
- if (this.contentDiv.clientWidth != 0) {
- return this.contentDiv.offsetWidth - this.contentDiv.clientWidth;
- }
- return 0;
-}
-
-LayoutManager.prototype.scrollHandler = function() {
- if (this.headerDiv) {
- this.headerDiv.scrollLeft = this.contentDiv.scrollLeft;
- }
-}
-
-LayoutManager.getHeaderWidth = function(visibleBox, realBox) {
- return realBox.offsetWidth + (visibleBox.offsetWidth - visibleBox.clientWidth);
-}
-
-LayoutManager.isIE = function() {
- return (/MSIE/.test(navigator.userAgent) && !window.opera);
-}
-
-LayoutManager.getElemXY = function(elem) {
- var x = elem.offsetLeft;
- var y = elem.offsetTop;
-
- for (var parent = elem.offsetParent; parent; parent = parent.offsetParent) {
- x += parent.offsetLeft;
- y += parent.offsetTop;
- }
- return {left: x, top: y};
-}
-
-LayoutManager.calculateWidth = function(srcElem, tgtElem) {
- var srcElemBorderWidth = LayoutManager.getBorderWidth(srcElem, "lr");
- var srcElemPaddingWidth = LayoutManager.getPaddingWidth(srcElem, "lr");
- var srcElemMarginWidth = LayoutManager.getMarginWidth(srcElem, "lr");
-
- var tgtElemBorderWidth = LayoutManager.getBorderWidth(tgtElem, "lr");
- var tgtElemPaddingWidth = LayoutManager.getPaddingWidth(tgtElem, "lr");
- var tgtElemMarginWidth = LayoutManager.getMarginWidth(tgtElem, "lr");
- var srcWidth = srcElem.offsetWidth - srcElemBorderWidth - srcElemPaddingWidth - srcElemMarginWidth;
- var colWidth = srcWidth + (srcElemBorderWidth - tgtElemBorderWidth)
- + (srcElemPaddingWidth - tgtElemPaddingWidth)
- + (srcElemMarginWidth - tgtElemMarginWidth);
- colWidth = (colWidth > 0) ? colWidth : 0;
- return {srcWidth : srcWidth, colWidth : colWidth};
-}
-
-LayoutManager.getBorderWidth = function(el, side) {
- return LayoutManager.getStyles(el, side, LayoutManager.borders);
-}
-
-LayoutManager.getPaddingWidth = function(el, side) {
- return LayoutManager.getStyles(el, side, LayoutManager.paddings);
-}
-
-LayoutManager.getMarginWidth = function(el, side) {
- return LayoutManager.getStyles(el, side, LayoutManager.margins);
-}
-
-LayoutManager.getStyles = function(el, sides, styles) {
- var val = 0;
- for(var i = 0, len = sides.length; i < len; i++){
- //if (el.getStyle) {
- var w = parseInt(Element.getStyle(el, styles[sides.charAt(i)]), 10);
- if(!isNaN(w)) val += w;
- //}
- }
- return val;
-}
-
-LayoutManager.borders = {l: 'border-left-width', r: 'border-right-width', t: 'border-top-width', b: 'border-bottom-width'},
-LayoutManager.paddings = {l: 'padding-left', r: 'padding-right', t: 'padding-top', b: 'padding-bottom'},
-LayoutManager.margins = {l: 'margin-left', r: 'margin-right', t: 'margin-top', b: 'margin-bottom'}
-
-if(!window.Richfaces) window.Richfaces = {};
-
-Richfaces.Control = Class.create();
-
-Richfaces.Control.eventStub = function() {
- return false;
-}
-
-Richfaces.Control.onfocus = function(element) {
- element.hasFocus = true;
-}
-
-Richfaces.Control.onblur = function(element) {
- element.hasFocus = undefined;
-}
-
-Richfaces.Control.prototype.initialize = function(eNode, dNode, isShown, isEnabled, action) {
- this.disabledNode = dNode;
- this.disabledNode.onselectstart = Richfaces.Control.eventStub;
-
- this.enabledNode = eNode
- this.enabledNode.onselectstart = Richfaces.Control.eventStub;
-
- this.isShown = isShown;
- this.isEnabled = isEnabled;
- this.action = action;
- //this.isEnabled ? this.doEnable() : this.doDisable();
- //this.isShown ? this.doShow() : this.doHide();
-}
-
-/*Control.CLASSES = {
- first : {hidden : "ol_button_border ol_control_hidden", shown : "ol_button_border ol_control_shown"},
- down : {hidden : "ol_button_border ol_control_hidden", shown : "ol_button_border ol_control_shown"},
- up : {hidden : "ol_button_border ol_control_hidden", shown : "ol_button_border ol_control_shown"},
- last : {hidden : "ol_button_border ol_control_hidden", shown : "ol_button_border ol_control_shown"}
-};*/
-
-Richfaces.Control.prototype.doShow = function() {
- this.isShown = true;
- if (this.isEnabled) {
- this.doHideNode(this.disabledNode);
- this.doShowNode(this.enabledNode);
- } else {
- this.doHideNode(this.enabledNode);
- this.doShowNode(this.disabledNode);
- }
-}
-
-Richfaces.Control.prototype.doHide = function() {
- this.isShown = false;
- this.doHideNode(this.disabledNode);
- this.doHideNode(this.enabledNode);
-}
-
-Richfaces.Control.prototype.doEnable = function() {
- this.isEnabled = true;
- this.doHideNode(this.disabledNode);
- this.doShowNode(this.enabledNode);
-}
-
-Richfaces.Control.prototype.doDisable = function() {
- this.isEnabled = false;
-
- var nodes = this.enabledNode.select("a[id='" + this.enabledNode.id + "link']");
-
- var newFocusNode = undefined;
-
- if (nodes && nodes[0]) {
- var link = nodes[0];
- if (link.hasFocus) {
- var disNodes = this.disabledNode.select("a[id='" + this.disabledNode.id + "link']");
- if (disNodes && disNodes[0]) {
- newFocusNode = disNodes[0];
- }
- }
- }
-
- this.doHideNode(this.enabledNode);
- this.doShowNode(this.disabledNode);
- if (newFocusNode && newFocusNode.focus) {
- //For IE
- newFocusNode.disabled = false;
- newFocusNode.focus();
- //For IE
- newFocusNode.disabled = true;
- }
-}
-
-Richfaces.Control.prototype.doHideNode = function(node) {
- //node.className = Richfaces.Control.CLASSES[this.action].hidden;
- node.hide();
-}
-
-Richfaces.Control.prototype.doShowNode = function(node) {
- //node.className = Richfaces.Control.CLASSES[this.action].shown;
- node.show();
-}
-
-
-
-if(!window.Richfaces) window.Richfaces = {};
-Richfaces.disableSelectionText = function(e) {
- e = window.event||e;
- if (e.srcElement) {
- if (e.srcElement.tagName) {
- var tagName = e.srcElement.tagName.toUpperCase();
-
- if (tagName != "INPUT" && tagName != "TEXTAREA" /* any items more? */) {
- return false;
- }
- }
- }
-};
-
-
-Richfaces.ListBase = Class.create();
-
-Richfaces.ListBase.compare = function(obj1, obj2) {
- return ((obj1 == obj2) ? 0 : ((obj1 < obj2) ? -1 : 1));
-}
-
-Richfaces.ListBase.ORDERING_LIST_CLASSES = {
- normal : "rich-ordering-list-items",
- disabled : "rich-ordering-list-disabled",
- active : "rich-ordering-list-active"
-}
-
-Richfaces.ListBase.ASC = "acs";
-Richfaces.ListBase.DESC = "desc";
-
-Richfaces.ListBase.CONTROL_SET = ["A", "INPUT", "TEXTAREA", "SELECT", "OPTION", "BUTTON"];
-
-Richfaces.ListBase.prototype = {
- initialize : function(containerId, contentTableId, headerTableId, focusKeeperId,
- onclickControlId, controlClass, columnsClasses, rowClasses) {
- this["rich:destructor"] = "destroy";
- this.selectedItems = new Array();
-
- //this.layoutManager = layoutManager;
- this.container = $(containerId);
- this.shuttleTable = $(contentTableId);
- this.shuttleTable.onselectstart = Richfaces.disableSelectionText;
- this.focusKeeper = $(focusKeeperId);
- this.focusKeeper.focused = false;
- //this.setFocus();
- this.focusKeeper.observe("keydown", (function(e) {this.onkeydownHandler(window.event || e)}).bindAsEventListener(this));
- this.focusKeeper.observe("blur", function (e) {this.focusListener(e);}.bindAsEventListener(this));
- this.focusKeeper.observe("focus", function (e) {this.onfocusHandler(e);}.bindAsEventListener(this));
-
- this.shuttleTbody = this.shuttleTable.tBodies[0];
-
- this.activeItem = null;
- this.pseudoActiveItem = null; //it services for items selection by Shift+click
- this.items = null;
-
- //FIX
- this.rowClasses = rowClasses;
- this.columnsClasses = columnsClasses;
-
- this.controlClass = controlClass;
- this.retrieveShuttleItems(containerId, controlClass);
- this.counter;
- this.shuttle = null;
- this.sortOrder = Richfaces.ListBase.ASC;
- this.clckHandler = function(e) {this.onclickHandler(window.event || e)}.bindAsEventListener(this);
- this.shuttleTable.observe("click", this.clckHandler);
-
- this.layoutManager = new LayoutManager(headerTableId, contentTableId);
-//--- http://jira.jboss.com/jira/browse/RF-3830 FF3 & Safari only!
- this.tableElement = document.getElementById(contentTableId);
- var rows = this.tableElement.tBodies[0].rows;
- if (rows && rows[0]) {
- this.firstTrElement = rows[0];
- if (this.firstTrElement.addEventListener && (Richfaces.browser.isFF3 || Richfaces.browser.isSafari)) {
- this.imagesOnLoad = this.imageLoadListener.bind(this);
- this.firstTrElement.addEventListener('load',this.imagesOnLoad, true);
- }
- }
-//---
- var synch = function() {this.layoutManager.widthSynchronization()}.bindAsEventListener(this);
- RichShuttleUtils.execOnLoad(
- synch, RichShuttleUtils.Condition.ElementPresent(this.container), 100
- );
- },
-
- imageLoadListener: function (evt){
- this.layoutManager.widthSynchronization();
- if (this.firstTrElement.removeEventListener && (Richfaces.browser.isFF3 || Richfaces.browser.isSafari)) {
- this.firstTrElement.removeEventListener('load',this.imagesOnLoad, true);
- }
- },
-
- destroy: function() {
- this.shuttleTable.onselectstart = null;
- var items = this.shuttleItems;
- for (var i = 0; i < items.length; i++) {
- items[i].destroy();
- }
-
- },
-
- setActiveItem : function(newActiveItem) {
- this.pseudoActiveItem = newActiveItem;
- this.activeItem = newActiveItem;
- },
-
- retrieveShuttleItems : function(containerId, controlClass) {
- var rows = this.shuttleTbody.rows;
- this.shuttleItems = new Array();
- var id;
-
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- id = row.id.split(containerId + ":")[1];
- var item = new controlClass(null, (id || i), row);
- if (item.isSelected()) {
- this.selectedItems.push(row);
- }
- if (item.isActive()) {
- this.setActiveItem(row);
- }
- this.shuttleItems[i] = item;
- }
- },
-
- getExtremeItem : function(position) { //FIXME
- var extremeItem = this.selectedItems[0];
- var currentItem;
-
- for (var i = 1; i < this.selectedItems.length; i++) {
- currentItem = this.selectedItems[i];
- if (position == "first") {
- if (currentItem.rowIndex < extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- } else {
- if (currentItem.rowIndex > extremeItem.rowIndex) {
- extremeItem = currentItem;
- }
- }
- }
- return extremeItem;
- },
-
- getEventTargetRow : function(event) {
- var activeElem;
- if (event.target) {
- //activeElem = event.rangeParent.parentNode;
- activeElem = event.target;
- } else {
- activeElem = event.srcElement;
- }
-
- if (activeElem == null) {
- return;
- }
-
- if (activeElem.tagName && Richfaces.ListBase.CONTROL_SET.indexOf(activeElem.tagName.toUpperCase()) != -1) {
- return;
- }
-
- while (activeElem.tagName.toLowerCase() != "tr") {
- activeElem = activeElem.parentNode;
- if (!activeElem.tagName) {
- return; //for IE
- }
- }
- return activeElem;
- },
-
- onfocusHandler: function (event) {
- if (!this.activeItem && this.shuttleItems.length != 0) {
- this.setActiveItem(this.shuttleItems[0]._node);
- }
-
- if (this.activeItem) {
- this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- }
- },
-
- onclickHandler : function(event) {
- if (event.srcElement && (event.srcElement.tagName.toLowerCase() == "tbody")) {
- return;
- }
- var activeElem = this.getEventTargetRow(event);
- if (activeElem != null) {
-
- if (event.ctrlKey) {
- this.addSelectedItem(activeElem);
- this.setActiveItem(activeElem);
- } else if (event.shiftKey) {
- if (!this.pseudoActiveItem) {
- this.selectionItem(activeElem);
- this.setActiveItem(activeElem);
- } else {
- this.selectItemGroup(activeElem);
- this.activeItem = activeElem; //given event works with pseudoActiveItem
- }
- } else {
- this.selectionItem(activeElem);
- this.setActiveItem(activeElem);
- }
-
-
- this.setFocus();
- }
- },
-
- onkeydownHandler : function(event) {
- var action = null;
- switch (event.keyCode) {
- case 38 : //up arrow
- action = 'up';
- this.moveActiveItem(action, event);
- Event.stop(event);
- break;
- case 40 : //down arrow
- action = 'down';
- this.moveActiveItem(action, event);
- Event.stop(event);
- break;
- case 65 : // Ctrl + A
- if (event.ctrlKey) {
- this.selectAll();
- }
- this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- Event.stop(event);
- break;
- }
- },
-
- moveActiveItem : function(action, event) {
- var item = this.activeItem;
- var rows = this.shuttleTbody.rows;
- if ((action == 'up') && (item.rowIndex > 0)) {
- this.changeActiveItems(rows[item.rowIndex - 1], item);
- } else if ((action == 'down') && (item.rowIndex < this.shuttleItems.length - 1)) {
- this.changeActiveItems(rows[item.rowIndex + 1], item);
- }
-
- this.autoScrolling(action, event);
-
- },
-
- changeActiveItems : function(newItem, item) {
- item.item.doNormal();
- this.resetMarked();
-
- newItem.item.doSelect(this.getExtRowClass(newItem.rowIndex), this.columnsClasses);
- newItem.item.doActive(this.getExtRowClass(newItem.rowIndex), this.columnsClasses);
- this.setActiveItem(newItem);
- this.selectedItems.push(newItem);
- },
-
- selectAll : function() {
- this.resetMarked();
- var startIndex = 0;
- var endIndex = this.shuttleItems.length - 1;
- this.selectItemRange(startIndex, endIndex);
- },
-
- /**
- * Click handler
- */
- selectionItem : function(activeItem) {
- var markedShuttleItem = activeItem;
-
- this.resetMarked();
- if (activeItem.item.isSelected()) {
- activeItem.item.doNormal(this.getExtRowClass(activeItem.rowIndex), this.columnsClasses);
- } else {
- activeItem.item.doSelect(this.getExtRowClass(activeItem.rowIndex), this.columnsClasses);
- this.selectedItems[0] = markedShuttleItem; //TODO: delete
- }
- },
-
- /**
- * CTRL+Click handler
- */
- addSelectedItem : function(activeItem) {
- var markedShuttleItem = activeItem;
-
- if (activeItem.item.isSelected()) {
- this.selectedItems.remove(markedShuttleItem); //TODO :delete
- activeItem.item.doNormal(this.getExtRowClass(activeItem.rowIndex), this.columnsClasses);
- } else {
- activeItem.item.doSelect(this.getExtRowClass(activeItem.rowIndex), this.columnsClasses);
- this.selectedItems.push(markedShuttleItem); //TODO :delete
- }
-
- if ((this.activeItem != null) && (this.activeItem.rowIndex != activeItem.rowIndex)) {
- //reset activity of an element
- if (this.activeItem.item.isSelected()) {
- this.activeItem.item.doSelect(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- } else {
- this.activeItem.item.doNormal(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- }
- }
- },
-
- /**
- * Shift+Click handler
- */
- selectItemGroup : function(currentItem) {
- //FIXME
- var activeItemIndex = this.pseudoActiveItem.rowIndex;
- var startIndex;
- var endIndex;
-
- if (currentItem.rowIndex > activeItemIndex) {
- startIndex = activeItemIndex;
- endIndex = currentItem.rowIndex;
- } else {
- startIndex = currentItem.rowIndex;
- endIndex = activeItemIndex;
- }
-
- this.resetMarked();
-
- this.selectItemRange(startIndex, endIndex);
- },
-
- selectItemRange : function(startIndex, endIndex) {
- var rows = this.shuttleTbody.rows;
- for (var i = startIndex; i <= endIndex; i++) {
- rows[i].item.doSelect(this.getExtRowClass(rows[i].rowIndex), this.columnsClasses);
- this.selectedItems.push(rows[i]);
- }
- },
-
- resetMarked : function() {
- var rows = this.selectedItems;
- var length = rows.length;
- for (var i = 0; i < length; i++) {
- var shuttleItem = rows[i];
- shuttleItem.item.doNormal(this.getExtRowClass(shuttleItem.rowIndex), this.columnsClasses);
- }
- this.selectedItems.length = 0;
-
- //need to reset active item
- },
-
- getSelectItemByNode : function(selectItemNode) {
- for (var i = 0; i < this.shuttleItems.length; i++) {
- var item = this.shuttleItems[i];
- if (selectItemNode.rowIndex == item._node.rowIndex) {
- return item;
- }
- }
- return null;
- },
-
- autoScrolling : function(action, event) {
- this.selectedItems.sort(this.compareByRowIndex);
- var increment;
- var scrollTop = this.shuttleTable.parentNode.scrollTop;
-
- var shuttleTop = LayoutManager.getElemXY(this.shuttleTable.parentNode).top;
-
- if (action == 'up' || action == 'first') {
- var targetItemTop = LayoutManager.getElemXY(this.selectedItems[0]).top;
- increment = (targetItemTop - scrollTop) - shuttleTop;
- if (increment < 0) {
- this.shuttleTable.parentNode.scrollTop += increment;
- }
- } else if (action == 'down' || action == 'last') {
- var item = this.selectedItems[this.selectedItems.length - 1];
- var targetItemBottom = LayoutManager.getElemXY(this.selectedItems[this.selectedItems.length - 1]).top + item.offsetHeight;
- var increment = (targetItemBottom - scrollTop) - (shuttleTop + this.shuttleTable.parentNode.clientHeight);
- if (increment > 0) {
- this.shuttleTable.parentNode.scrollTop += increment;
- }
- }
- if (event) Event.stop(event);
- },
-
- setFocus : function() {
- this.focusKeeper.focus();
- this.focusKeeper.focused = true;
- },
-
- focusListener : function(e) {
- e = e || window.event;
- this.focusKeeper.focused = false;
-
- if (this.activeItem) {
- if (this.activeItem.item.isSelected()) {
- this.activeItem.item.doSelect(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- } else {
- this.activeItem.item.doNormal(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- }
- }
- },
-
- compareByLabel : function(obj1, obj2) {
- obj1 = obj1._label;
- obj2 = obj2._label;
- return Richfaces.ListBase.compare(obj1, obj2);
- },
-
- compareByRowIndex : function(obj1, obj2) {
- obj1 = obj1.rowIndex;
- obj2 = obj2.rowIndex;
- return Richfaces.ListBase.compare(obj1, obj2);
- },
-
- isListActive : function() {
- if ((this.activeItem != null || this.selectedItems.length != 0) && this.focusKeeper.focused) {
- return true;
- }
- return false;
- },
-
- getExtRowClass : function(index) {
- return Richfaces.getExternalClass(this.rowClasses, index);
- },
-
- getSelection : function() {
- var result = [];
- for (var i = 0; i < this.selectedItems.length; i++) {
- result[i] = this.selectedItems[i].item;
- }
- return result;
- },
-
- getItems : function() {
- return this.shuttleTbody.rows;
- }
-}
-if(!window.Richfaces) window.Richfaces = {};
-
-Richfaces.OrderingListSelectItem = Class.create(Richfaces.SelectItem);
-Richfaces.OrderingListSelectItem.prototype.CLASSES = {
- ROW : {
- ACTIVE : "rich-ordering-list-row-active",
- SELECTED : "rich-ordering-list-row-selected",
- DISABLED : "rich-ordering-list-row-disabled",
- NORMAL : "rich-ordering-list-row"
- },
- CELL : {
- ACTIVE : "rich-ordering-list-cell-active",
- SELECTED : "rich-ordering-list-cell-selected",
- DISABLED : "rich-ordering-list-cell-disabled",
- NORMAL : "rich-ordering-list-cell",
- BEGIN: " rich-ordering-list-cell-first",
- END: " rich-ordering-list-cell-last"
- }
-},
-
-
-Richfaces.OrderingList = Class.create(Richfaces.ListBase, {
- initialize: function($super, containerId, contentTableId, headerTableId, focusKeeperId, ids, onclickControlId, events, controlClass, columnsClasses, rowClasses) {
- $super(containerId, contentTableId, headerTableId, focusKeeperId, onclickControlId, controlClass, columnsClasses, rowClasses);
-
- this.container.component = this;
-
- this.events = events;
- this.controlList = new Array();
- this.initControlList(containerId, ids);
-
- for (var e in this.events) {
- if (e && this.events[e]) {
- this.container.observe("rich:" + e.toString(), this.events[e]);
- }
- }
- },
-
- destroy: function($super) {
- $super();
-
- this.container.component = null;
- },
-
- initControlList : function(containerId, ids) {
- for (var i = 0; i < ids.length; i++) {
- var id = ids[i];
- var node = $(containerId + id[0]);
- var disNode = $(containerId + id[1]);
- if (node && disNode) {
- node.observe('click', Richfaces.OrderingList.HANDLERS[id[0]].bindAsEventListener(this));
- this.controlList[i] = new Richfaces.Control(node, disNode, false, false, id[0]);
- }
- }
- },
-
- controlListManager : function() {
- this.selectedItems.sort(this.compareByRowIndex);
- var control;
- //FIXME
- this.controlsProcessing(["first", "last", "down", "up"], "enable");
- if ((this.shuttleItems.length == 0) || (this.selectedItems.length == 0)) {
- this.controlsProcessing(["first", "last", "down", "up"], "disable");
- } else {
- if (this.selectedItems[0].rowIndex == 0)
- this.controlsProcessing(["first", "up"], "disable");
- if (this.selectedItems[this.selectedItems.length - 1].rowIndex == (this.shuttleItems.length - 1))
- this.controlsProcessing(["down", "last"], "disable");
- }
- },
-
- controlsProcessing : function(disabledControls , action) {
- for (var i = 0; i < this.controlList.length; i++) {
- control = this.controlList[i];
- if (control != null) {
- if (disabledControls != null && disabledControls.indexOf(control.action) != -1) {
- if (action == "disable") {
- control.doDisable();
- } else {
- control.doEnable();
- }
- }
- }
- }
- },
-
- onclickHandler : function($super, event) {
- $super(event);
- this.controlListManager();
- },
-
- moveActiveItem : function($super, action, event) {
- $super(action, event);
- this.controlListManager();
- },
-
- moveSelectedItems : function(action, event) {
- if (this.selectedItems.length > 0) {
-
- if (Richfaces.invokeEvent(this.events.onorderchange, this.container, "rich:onorderchange", {items: this.shuttleItems})) {
- event = window.event||event;
- var rows = this.shuttleTbody.rows;
- var item;
-
- this.selectedItems.sort(this.compareByRowIndex);
-
- if ((action == 'up') && this.getExtremeItem("first").previousSibling) {
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, item.previousSibling);
- }
- } else if ((action == 'down') && this.getExtremeItem("last").nextSibling) {
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item.nextSibling, item);
- }
- } else if (action == 'first') {
- var incr = this.selectedItems[0].rowIndex;
- for (var i = 0; i < this.selectedItems.length; i++) {
- item = this.selectedItems[i];
- item.parentNode.insertBefore(item, rows[item.rowIndex - incr]);
- }
- } else if (action == 'last') {
- var length = this.shuttleItems.length;
- var incr = length - this.selectedItems[this.selectedItems.length - 1].rowIndex;
- for (var i = this.selectedItems.length - 1; i > -1; i--) {
- item = this.selectedItems[i];
- if (item.rowIndex + incr > length - 1) {
- item.parentNode.insertBefore(item, null);
- } else {
- item.parentNode.insertBefore(item, rows[item.rowIndex + incr]);
- }
- }
- }
-
- this.shuttleItems = new Array();
- for (var i = 0; i < rows.length; i++) {
- this.shuttleItems.push(rows[i].item);
- }
- if (action != null)
- this.autoScrolling(action, event);
-
- this.container.fire("rich:onorderchanged", {items: this.shuttleItems});
- this.controlListManager();
- }
- }
- },
-
- onkeydownHandler : function(event) {
- var action = null;
- switch (event.keyCode) {
- case 34 : action = 'last';
- this.moveSelectedItems(action ,event);
- Event.stop(event);
- break; //page down
- case 33 : action = 'first';
- this.moveSelectedItems(action, event);
- Event.stop(event);
- break; //page up
- case 38 : //up arrow
- action = 'up';
- if (event.ctrlKey) {
- this.moveSelectedItems(action, event);
- } else {
- this.moveActiveItem(action, event);
- }
- Event.stop(event);
- break;
- case 40 : //down arrow
- action = 'down';
- if (event.ctrlKey) {
- this.moveSelectedItems(action ,event);
- } else {
- this.moveActiveItem(action, event);
- }
- Event.stop(event);
- break;
- case 65 : // Ctrl + A
- if (event.ctrlKey) {
- this.selectAll();
- }
- this.activeItem.item.doActive(this.getExtRowClass(this.activeItem.rowIndex), this.columnsClasses);
- this.controlListManager();
- Event.stop(event);
- break;
- }
- },
-
- top : function(e) {
- this.container.fire("rich:ontopclick", {items: this.shuttleItems, selection: this.getSelection()});
- this.moveSelectedItems("first", e);
- },
-
- bottom : function(e) {
- this.container.fire("rich:onbottomclick", {items: this.shuttleItems, selection: this.getSelection()});
- this.moveSelectedItems("last", e);
- },
-
- up : function(e) {
- this.container.fire("rich:onupclick", {items: this.shuttleItems, selection: this.getSelection()});
- this.moveSelectedItems("up", e);
- },
-
- down : function(e) {
- this.container.fire("rich:ondownclick", {items: this.shuttleItems, selection: this.getSelection()});
- this.moveSelectedItems("down", e);
- }
-
-});
-
-Richfaces.OrderingList.ACTIVITY_MARKER = "a";
-Richfaces.OrderingList.SELECTION_MARKER = "s";
-Richfaces.OrderingList.ITEM_SEPARATOR = ",";
-
-Richfaces.OrderingList.HANDLERS = {
- first: function (e) { this.top(e); return false; },
- last: function (e) { this.bottom(e); return false; },
- up: function (e) { this.up(e); return false; },
- down: function (e) { this.down(e); return false; }
-};
-if(!window.Richfaces) window.Richfaces = {};
-
-Richfaces.ListShuttle = Class.create();
-
-Richfaces.ListShuttle.Source = Class.create(Richfaces.ListBase);
-Richfaces.ListShuttle.Target = Class.create(Richfaces.OrderingList);
-
-Richfaces.ListShuttle.Source.SelectItem = Class.create(Richfaces.SelectItem);
-Richfaces.ListShuttle.Source.SelectItem.prototype.CLASSES = {
- ROW : {
- ACTIVE : "rich-shuttle-source-row-active",
- SELECTED : "rich-shuttle-source-row-selected",
- DISABLED : "rich-shuttle-source-row-disabled",
- NORMAL : "rich-shuttle-source-row"
- },
- CELL : {
- ACTIVE : "rich-shuttle-source-cell-active",
- SELECTED : "rich-shuttle-source-cell-selected",
- DISABLED : "rich-shuttle-source-cell-disabled",
- NORMAL : "rich-shuttle-source-cell",
- BEGIN: " rich-shuttle-source-cell-first",
- END: " rich-shuttle-source-cell-last"
- }
-}
-
-Richfaces.ListShuttle.Target.SelectItem = Class.create(Richfaces.SelectItem);
-Richfaces.ListShuttle.Target.SelectItem.prototype.CLASSES = {
- ROW : {
- ACTIVE : "rich-shuttle-target-row-active",
- SELECTED : "rich-shuttle-target-row-selected",
- DISABLED : "rich-shuttle-target-row-disabled",
- NORMAL : "rich-shuttle-target-row"
- },
- CELL : {
- ACTIVE : "rich-shuttle-target-cell-active",
- SELECTED : "rich-shuttle-target-cell-selected",
- DISABLED : "rich-shuttle-target-cell-disabled",
- NORMAL : "rich-shuttle-target-cell",
- BEGIN: " rich-shuttle-target-cell-first",
- END: " rich-shuttle-target-cell-last"
- }
-}
-
-Richfaces.ListShuttle.prototype = {
- initialize: function(targetList, sourceList, clientId, controlIds, switchByClick, events) {
- this.containerId = clientId;
- this["rich:destructor"] = "destroy";
-
- this.container = $(this.containerId);
- this.container.component = this;
-
- this.targetList = targetList;
- this.sourceList = sourceList;
-
- this.events = events;
-
- this.isFocused = false;
- this.wasMouseDown = false;
- this.skipBlurEvent = false;
-
- this.targetLayoutManager = targetList.layoutManager;
- this.sourceLayoutManager = sourceList.layoutManager;
-
- //for focus\blur custom events
- this.container.observe("focus", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
- this.container.observe("keypress", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
- this.container.observe("keydown", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
- this.container.observe("mousedown", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
- this.container.observe("click", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
- this.container.observe("blur", function (e) {this.focusOrBlurHandlerLS(e);}.bindAsEventListener(this));
-
- if (switchByClick == "true") {
- this.targetList.shuttleTable.observe("click", function(e) {this.moveItemByClick(window.event||e, this.targetList, this.sourceList)}.bindAsEventListener(this));
- this.sourceList.shuttleTable.observe("click", function(e) {this.moveItemByClick(window.event||e, this.sourceList, this.targetList)}.bindAsEventListener(this));
- Event.stopObserving(this.sourceList.shuttleTable, "click", this.sourceList.clckHandler);
- Event.stopObserving(this.targetList.shuttleTable, "click", this.targetList.clckHandler);
- } else {
- this.targetList.shuttleTable.observe("dblclick", function(e) {this.moveItemByClick(window.event||e, this.targetList, this.sourceList)}.bindAsEventListener(this));
- this.sourceList.shuttleTable.observe("dblclick", function(e) {this.moveItemByClick(window.event||e, this.sourceList, this.targetList)}.bindAsEventListener(this));
-
- sourceList._onclickHandler = sourceList.onclickHandler;
- sourceList.onclickHandler = function(e) { this.onclickHandler(e, sourceList); }.bindAsEventListener(this);
- targetList._onclickHandler = targetList.onclickHandler;
- targetList.onclickHandler = function(e) { this.onclickHandler(e, targetList); }.bindAsEventListener(this);
- }
-
- sourceList._onkeydownHandler = sourceList.onkeydownHandler;
- sourceList.onkeydownHandler = function(e) { this.onkeydownHandler(e, sourceList); }.bindAsEventListener(this);
- targetList._onkeydownHandler = targetList.onkeydownHandler;
- targetList.onkeydownHandler = function(e) { this.onkeydownHandler(e, targetList); }.bindAsEventListener(this);
-
- this.controlList = new Array();
- this.initControlList(clientId, controlIds);
-
- for (var e in this.events) {
- if (e && this.events[e]) {
- this.container.observe("rich:" + e.toString(), this.events[e]);
- }
- }
- },
-
- destroy: function() {
- this.container.component = null;
- this.targetList.destroy();
- this.sourceList.destroy();
- },
-
- initControlList : function(clientId, ids) {
- for (var i = 0; i < ids.length; i++) {
- var id = ids[i];
- var node = $(clientId + id[0]);
- var disNode = $(clientId + id[1]);
- if (node && disNode) {
- node.observe("click", Richfaces.ListShuttle.HANDLERS[id[0]].bindAsEventListener(this));
- this.controlList[i] = new Richfaces.Control(node, disNode, false, false, id[0]);
- }
- }
- //this.controlListManager();
- },
-
- controlListManager : function() {
- //this.controlsProcessing();
- this.controlsProcessing(["copy", "copyAll", "removeAll" ,"remove"], "enable");
- if (this.sourceList.shuttleItems.length < 1)
- this.controlsProcessing(["copy", "copyAll"], "disable");
- if (this.sourceList.selectedItems.length < 1)
- this.controlsProcessing(["copy"] , "disable");
- if (this.targetList.shuttleItems.length < 1)
- this.controlsProcessing(["removeAll" ,"remove"], "disable");
- if (this.targetList.selectedItems.length < 1) {
- this.controlsProcessing(["remove"], "disable");
- }
- },
-
- onclickHandler : function(event, component) {
- component._onclickHandler(event);
- this.controlListManager();
- //Event.stop(event); //bug: RF-2097
- },
-
- onkeydownHandler : function(event, component) {
- component._onkeydownHandler(event);
- this.controlListManager();
- },
-
- controlsProcessing : function(disabledControls , action) {
- for (var i = 0; i < this.controlList.length; i++) {
- control = this.controlList[i];
- if (control != null) {
- if (disabledControls != null && disabledControls.indexOf(control.action) != -1) {
- if (action == "disable") {
- control.doDisable();
- } else {
- control.doEnable();
- }
- }
- }
- }
- },
-
- moveItems : function(sourceComponent, targetComponent, items) {
- if (Richfaces.invokeEvent(this.events.onlistchange, this.container, "rich:onlistchange", {sourceItems: sourceComponent.shuttleItems, targetItems: targetComponent.shuttleItems})) {
- if (items.length > 0) {
- var length = items.length;
- for (var i = 0; items.length > 0;) {
- var item = items[i];
- this.moveItem(sourceComponent, targetComponent, item);
- }
- this.controlListManager();
- if (this.targetList.controlListManager) {
- this.targetList.controlListManager();
- }
-
- this.targetLayoutManager.widthSynchronization();
- this.sourceLayoutManager.widthSynchronization();
-
- this.container.fire("rich:onlistchanged", {sourceItems: sourceComponent.shuttleItems, targetItems: targetComponent.shuttleItems});
- }
- }
- },
-
- moveItem : function(sourceComponent, targetComponent, item) {
- if (!item) {
- return;
- }
- if (!(item instanceof Richfaces.SelectItem)) {
- item = sourceComponent.getSelectItemByNode(item);
- }
- if (!LayoutManager.isIE() && (targetComponent.shuttleTbody.rows.length == 0)) {
- var newItem = null;
- if (item instanceof Richfaces.ListShuttle.Target.SelectItem) {
- newItem = new this.targetList.controlClass(item._label, item._id, item._node.cloneNode(true));
- } else {
- newItem = new this.sourceList.controlClass(item._label, item._id, item._node.cloneNode(true));
- }
- this.tableUpdate(targetComponent);
- this.addItem(targetComponent, newItem);
-
- this.removeItem(sourceComponent, item);
- sourceComponent.shuttleTable.deleteRow(item._node.rowIndex);
- } else {
- this.addItem(targetComponent, item);
- this.removeItem(sourceComponent, item);
- }
- },
-
- removeItem : function(component, item) {
- var items = component.shuttleItems;
- component.selectedItems.remove(item._node);
- items.remove(item);
- if (item == component.activeItem) {
- component.activeItem == null;
- }
- },
-
- addItem : function(component, item) {
- item.doNormal(Richfaces.getExternalClass(item.rowIndex), component.columnsClasses);
-
- component.shuttleTbody.insertBefore(item._node, null);
- component.shuttleItems.push(item);
- },
-
- tableUpdate : function(component) {
- var table = component.shuttleTable;
- var tbody = table.tBodies[0];
- var newTbody = tbody.cloneNode(false);
- table.removeChild(tbody);
- table.appendChild(newTbody);
- component.shuttleTbody = table.tBodies[0];
- },
-
- moveItemByClick : function(event, sourceComponent, targetComponent, layoutManager) {
- if (Richfaces.invokeEvent(this.events.onlistchange, this.container, "rich:onlistchange", {sourceItems: sourceComponent.shuttleItems, targetItems: targetComponent.shuttleItems})) {
- var item = this.sourceList.getEventTargetRow(event);
- this.moveItem(sourceComponent, targetComponent, item);
-
- this.controlListManager();
- if (this.targetList.controlListManager) {
- this.targetList.controlListManager();
- }
-
- this.targetLayoutManager.widthSynchronization();
- this.sourceLayoutManager.widthSynchronization();
-
- this.container.fire("rich:onlistchanged", {sourceItems: sourceComponent.shuttleItems, targetItems: targetComponent.shuttleItems});
- }
- },
-
- copyAll : function() {
- this.container.fire("rich:oncopyallclick", {sourceItems: this.sourceList.shuttleItems, targetItems: this.targetList.shuttleItems, selection: this.sourceList.getSelection()});
- this.moveItems(this.sourceList, this.targetList, this.sourceList.shuttleItems);
- },
-
- copy : function() {
- this.container.fire("rich:oncopyclick", {sourceItems: this.sourceList.shuttleItems, targetItems: this.targetList.shuttleItems, selection: this.sourceList.getSelection()});
- this.moveItems(this.sourceList, this.targetList, this.sourceList.selectedItems);
- },
-
- removeAll : function() {
- this.container.fire("rich:onremoveallclick", {sourceItems: this.sourceList.shuttleItems, targetItems: this.targetList.shuttleItems, selection: this.targetList.getSelection()});
- this.moveItems(this.targetList, this.sourceList, this.targetList.shuttleItems);
- },
-
- remove : function() {
- this.container.fire("rich:onremoveclick", {sourceItems: this.sourceList.shuttleItems, targetItems: this.targetList.shuttleItems, selection: this.targetList.getSelection()});
- this.moveItems(this.targetList, this.sourceList, this.targetList.selectedItems);
- },
-
- up : function() {
- this.targetList.up();
- },
-
- down : function() {
- this.targetList.down();
- },
-
- top : function() {
- this.targetList.top();
- },
-
- bottom : function() {
- this.targetList.bottom();
- },
-
- focusOrBlurHandlerLS : function(e) {
- var componentID = e.target.id;
- if (e.type == "keydown") {
- var code = e.which;
- this.skipBlurEvent = false;
- this.wasKeyDown = true;
- if (Event.KEY_TAB == code) {
- if (e.shiftKey) {
- if ((componentID == this.sourceList.focusKeeper.id) && this.isFocused) {
- //blur:shift+tab keys were pressed
- this.fireOnblurEvent();
- } else {
- this.skipBlurEvent = true;
- }
- } else {
- if ((componentID == this.targetList.focusKeeper.id) && this.isFocused) {
- //blur:tab key was pressed
- this.fireOnblurEvent();
-
- } else {
- this.skipBlurEvent = true;
- }
- }
- }
- } else if (e.type == "mousedown") {
- this.skipBlurEvent = false;
- this.wasMouseDown = true;
- if (!this.isFocused) {
- this.fireOnfocusEvent();
- }
- } else if (e.type == "click") {
- this.wasMouseDown = false;
- } else if (e.type == "keypress") {
- this.wasKeyDown = false;
- } else if (e.type == "focus") {
- if (componentID == this.sourceList.focusKeeper.id && !this.wasMouseDown && !this.isFocused) {
- //focus:tab key was pressed
- this.fireOnfocusEvent();
- } else if (componentID == this.targetList.focusKeeper.id && !this.wasMouseDown && !this.isFocused) {
- //focus:shift+tab keys were pressed
- this.fireOnfocusEvent();
- }
- } else if (e.type == "blur") {
- //onblur event
- if (!this.wasMouseDown && !this.wasKeyDown && this.isFocused && !this.skipBlurEvent) {
- //blur:click component outside
- this.fireOnblurEvent();
- }
- }
- },
-
- fireOnfocusEvent : function() {
- //LOG.warn("fireOnfocusEvent|");
- this.isFocused = true;
- this.container.fire("rich:onfocus", {});
- },
-
- fireOnblurEvent : function() {
- //LOG.warn("fireOnblurEvent|");
- this.isFocused = false;
- this.container.fire("rich:onblur", {});
- }
-};
-
-Richfaces.ListShuttle.HANDLERS = {
- copy: function (e) { this.copy(); return false; },
- copyAll: function (e) { this.copyAll(); return false; },
- remove: function (e) { this.remove(); return false; },
- removeAll: function (e) { this.removeAll(); return false; }
-};
-// ============================= after ==========================
15 years, 11 months