r61045 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61044‎ | r61045 | r61046 >
Date:05:18, 14 January 2010
Author:ning
Status:deferred
Tags:
Comment:
Code style fix. Both spaces and tabs are used
Defined in code conventions.
Modified paths:
  • /trunk/extensions/SemanticNotifyMe/includes/SMW_NMDBHelper.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/SMW_NMStorage.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/SNM_Initialize.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/jobs/SMW_NMSendMailJob.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/storage/SMW_SQLStore2_QueriesNM.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/languages/SMW_NMLanguage.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguage.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageEn.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageUserEn.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/NotifyHelper.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/nm_tooltip.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/scripts/prototype.js (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NotAjaxAccess.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/libs/NM_yui_autocompletion.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NotAjaxAccess.php
@@ -32,31 +32,31 @@
3333 | format=table
3434 | link=all';
3535
36 - // parse params and answer query
37 - SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $params ), $querystring, $params, $printouts );
 36+ // parse params and answer query
 37+ SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $params ), $querystring, $params, $printouts );
3838
39 - $result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI );
 39+ $result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI );
4040 switch ( $params->format ) {
41 - case 'timeline':
42 - return $result;
43 - break;
44 - case 'eventline':
45 - return $result;
46 - break;
47 - case 'googlepie':
48 - return $result[0];
49 - break;
50 - case 'googlebar':
51 - return $result[0];
52 - break;
53 - case 'exhibit':
54 - return $result;
55 - break;
56 - default:
57 - }
 41+ case 'timeline':
 42+ return $result;
 43+ break;
 44+ case 'eventline':
 45+ return $result;
 46+ break;
 47+ case 'googlepie':
 48+ return $result[0];
 49+ break;
 50+ case 'googlebar':
 51+ return $result[0];
 52+ break;
 53+ case 'exhibit':
 54+ return $result;
 55+ break;
 56+ default:
 57+ }
5858 global $wgParser;
5959
60 - if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
 60+ if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
6161 $result = $wgParser->recursiveTagParse( $result );
6262 } else {
6363 global $wgTitle;
Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/libs/NM_yui_autocompletion.js
@@ -7,77 +7,77 @@
88 */
99
1010 function nm_autocomplete(input_name, container_name, values, delimiter) {
11 - if (values != null) {
12 - this.oACDS = new YAHOO.widget.DS_JSFunction(nmAutocompleteFunctionGenerator(values));
13 - this.oACDS.maxCacheEntries = 0;
14 - this.oAutoComp = new YAHOO.widget.AutoComplete(input_name, container_name, this.oACDS);
15 - }
 11+ if (values != null) {
 12+ this.oACDS = new YAHOO.widget.DS_JSFunction(nmAutocompleteFunctionGenerator(values));
 13+ this.oACDS.maxCacheEntries = 0;
 14+ this.oAutoComp = new YAHOO.widget.AutoComplete(input_name, container_name, this.oACDS);
 15+ }
1616
17 - // Instantiate AutoComplete
18 - this.oAutoComp.alwaysShowContainer = false;
19 - //this.oAutoComp.minQueryLength = 1;
20 - this.oAutoComp.maxResultsDisplayed = nmMaxResultsDisplayed;
21 - this.oAutoComp.animHoriz = false;
22 - this.oAutoComp.animVert = false;
23 - if (delimiter != '') {
24 - this.oAutoComp.delimChar = delimiter;
25 - }
26 - this.oAutoComp.minQueryLength = 0;
27 - this.oAutoComp.textboxFocusEvent.subscribe(
28 - function (sType, aArgs) {
29 - var oAutoComp = aArgs[0];
30 - oAutoComp.sendQuery("");
31 - });
32 -
33 - // don't set IFrame, which is meant to improve formatting on Internet
34 - // Explorer - currently, it only messes up the formatting
35 - //this.oAutoComp.useIFrame = true;
36 - // This function returns markup that bolds the original query
37 - this.oAutoComp.formatResult = function(aResultItem, sQuery) {
38 - var sKey = aResultItem[0]; // the entire result key
39 - var sKeyIndex = sKey.toLowerCase().indexOf(sQuery.toLowerCase());
40 - // if it's not the very beginning, make sure the query string
41 - // comes after a space
42 - if (sKeyIndex > 0) {
43 - sKeyIndex = sKey.toLowerCase().indexOf(' ' + sQuery.toLowerCase()) + 1;
44 - }
45 - var sKeyBefore = sKey;
46 - var sKeyQuery = "";
47 - var sKeyAfter = "";
48 - if (sKeyIndex >= 0) {
49 - sKeyBefore = sKey.substr(0, sKeyIndex);
50 - sKeyQuery = sKey.substr(sKeyIndex, sQuery.length); // the query itself
51 - sKeyAfter = sKey.substr(sKeyIndex + sQuery.length); // the rest of the result
52 - }
 17+ // Instantiate AutoComplete
 18+ this.oAutoComp.alwaysShowContainer = false;
 19+ //this.oAutoComp.minQueryLength = 1;
 20+ this.oAutoComp.maxResultsDisplayed = nmMaxResultsDisplayed;
 21+ this.oAutoComp.animHoriz = false;
 22+ this.oAutoComp.animVert = false;
 23+ if (delimiter != '') {
 24+ this.oAutoComp.delimChar = delimiter;
 25+ }
 26+ this.oAutoComp.minQueryLength = 0;
 27+ this.oAutoComp.textboxFocusEvent.subscribe(
 28+ function (sType, aArgs) {
 29+ var oAutoComp = aArgs[0];
 30+ oAutoComp.sendQuery("");
 31+ });
5332
54 - var aMarkup = sKeyBefore +
55 - "<span style='font-weight:bold'>" +
56 - sKeyQuery +
57 - "</span>" +
58 - sKeyAfter;
59 - return aMarkup;
60 - };
 33+ // don't set IFrame, which is meant to improve formatting on Internet
 34+ // Explorer - currently, it only messes up the formatting
 35+ //this.oAutoComp.useIFrame = true;
 36+ // This function returns markup that bolds the original query
 37+ this.oAutoComp.formatResult = function(aResultItem, sQuery) {
 38+ var sKey = aResultItem[0]; // the entire result key
 39+ var sKeyIndex = sKey.toLowerCase().indexOf(sQuery.toLowerCase());
 40+ // if it's not the very beginning, make sure the query string
 41+ // comes after a space
 42+ if (sKeyIndex > 0) {
 43+ sKeyIndex = sKey.toLowerCase().indexOf(' ' + sQuery.toLowerCase()) + 1;
 44+ }
 45+ var sKeyBefore = sKey;
 46+ var sKeyQuery = "";
 47+ var sKeyAfter = "";
 48+ if (sKeyIndex >= 0) {
 49+ sKeyBefore = sKey.substr(0, sKeyIndex);
 50+ sKeyQuery = sKey.substr(sKeyIndex, sQuery.length); // the query itself
 51+ sKeyAfter = sKey.substr(sKeyIndex + sQuery.length); // the rest of the result
 52+ }
6153
62 - // Show custom message if no results found
63 - this.myOnDataReturn = function(sType, aArgs) {
64 - var oAutoComp = aArgs[0];
65 - var sQuery = aArgs[1];
66 - var aResults = aArgs[2];
 54+ var aMarkup = sKeyBefore +
 55+ "<span style='font-weight:bold'>" +
 56+ sKeyQuery +
 57+ "</span>" +
 58+ sKeyAfter;
 59+ return aMarkup;
 60+ };
6761
68 - if(aResults.length == 0) {
69 - oAutoComp.setBody("<div>No matching results</div>");
70 - }
71 - };
 62+ // Show custom message if no results found
 63+ this.myOnDataReturn = function(sType, aArgs) {
 64+ var oAutoComp = aArgs[0];
 65+ var sQuery = aArgs[1];
 66+ var aResults = aArgs[2];
7267
73 - var itemSelectHandler = function (oAutoComp, listItem, dataArray) {
74 - }
 68+ if(aResults.length == 0) {
 69+ oAutoComp.setBody("<div>No matching results</div>");
 70+ }
 71+ };
7572
76 - // neither of these events are necessary to subscribe to yet
77 - //this.oAutoComp.itemSelectEvent.subscribe(itemSelectHandler);
78 - //this.oAutoComp.dataReturnEvent.subscribe(this.myOnDataReturn);
 73+ var itemSelectHandler = function (oAutoComp, listItem, dataArray) {
 74+ }
7975
80 - // Preload content in the container
81 - //this.oAutoComp.sendQuery("");
 76+ // neither of these events are necessary to subscribe to yet
 77+ //this.oAutoComp.itemSelectEvent.subscribe(itemSelectHandler);
 78+ //this.oAutoComp.dataReturnEvent.subscribe(this.myOnDataReturn);
 79+
 80+ // Preload content in the container
 81+ //this.oAutoComp.sendQuery("");
8282 };
8383
8484 /*
@@ -85,47 +85,47 @@
8686 * string, an array of values that match it
8787 */
8888 function nmAutocompleteFunctionGenerator(values_list) {
89 - return function (sQuery) {
90 - var primaryResults = [];
91 - var secondaryResults = [];
92 - if (sQuery && sQuery.length > 0) {
93 - // in some cases, decodeURI() doesn't handle colons correctly -
94 - // replace them manually
95 - query_str = decodeURI(sQuery).replace(/(%3A)/g, ":").toLowerCase();
96 - for (var i = 0; i < values_list.length; i++) {
97 - subarray = values_list[i];
98 - // workaround for strange IE bug
99 - var name;
100 - if (subarray.length > 1) {
101 - name = subarray;
102 - } else {
103 - name = subarray[0];
104 - }
105 - name_str = name.toLowerCase();
106 - var sKeyIndex = name_str.indexOf(query_str);
107 - if (sKeyIndex == 0) {
108 - primaryResults.push(subarray);
109 - } else {
110 - var index2 = name_str.indexOf(" " + query_str);
111 - if (index2 >= 0) {
112 - secondaryResults.push(subarray);
113 - }
114 - }
115 - }
116 - var aResults = primaryResults.concat(secondaryResults);
117 - // return no values if there's only one value, and the query
118 - // exactly matches it
119 - if (aResults.length == 1 && query_str.length == aResults[0][0].length) {
120 - return [];
121 - } else {
122 - return aResults;
123 - }
124 - }
125 - // Empty queries return all values
126 - else {
127 - return values_list;
128 - }
129 - }
 89+ return function (sQuery) {
 90+ var primaryResults = [];
 91+ var secondaryResults = [];
 92+ if (sQuery && sQuery.length > 0) {
 93+ // in some cases, decodeURI() doesn't handle colons correctly -
 94+ // replace them manually
 95+ query_str = decodeURI(sQuery).replace(/(%3A)/g, ":").toLowerCase();
 96+ for (var i = 0; i < values_list.length; i++) {
 97+ subarray = values_list[i];
 98+ // workaround for strange IE bug
 99+ var name;
 100+ if (subarray.length > 1) {
 101+ name = subarray;
 102+ } else {
 103+ name = subarray[0];
 104+ }
 105+ name_str = name.toLowerCase();
 106+ var sKeyIndex = name_str.indexOf(query_str);
 107+ if (sKeyIndex == 0) {
 108+ primaryResults.push(subarray);
 109+ } else {
 110+ var index2 = name_str.indexOf(" " + query_str);
 111+ if (index2 >= 0) {
 112+ secondaryResults.push(subarray);
 113+ }
 114+ }
 115+ }
 116+ var aResults = primaryResults.concat(secondaryResults);
 117+ // return no values if there's only one value, and the query
 118+ // exactly matches it
 119+ if (aResults.length == 1 && query_str.length == aResults[0][0].length) {
 120+ return [];
 121+ } else {
 122+ return aResults;
 123+ }
 124+ }
 125+ // Empty queries return all values
 126+ else {
 127+ return values_list;
 128+ }
 129+ }
130130 }
131131
132132 function nmAttachAutocompleteToAllFields()
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php
@@ -38,18 +38,18 @@
3939 global $smwgQDefaultNamespaces;
4040
4141 SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $querystring ), $querystring, $params, $printouts );
42 - $relatedArticles = array();
43 - foreach ( $printouts as $po ) {
44 - if ( $po == $params['sort'] ) $sorted = true;
 42+ $relatedArticles = array();
 43+ foreach ( $printouts as $po ) {
 44+ if ( $po == $params['sort'] ) $sorted = true;
4545 $printoutArticles[] = array(
4646 'namespace' => SMW_NS_PROPERTY,
4747 'title' => Title::makeTitle( SMW_NS_PROPERTY, $po->getText() )->getDBkey() );
48 - }
49 - if ( !$sorted && isset( $params['sort'] ) ) {
 48+ }
 49+ if ( !$sorted && isset( $params['sort'] ) ) {
5050 $printoutArticles[] = array(
5151 'namespace' => SMW_NS_PROPERTY,
5252 'title' => Title::makeTitle( SMW_NS_PROPERTY, $params['sort'] )->getDBkey() );
53 - }
 53+ }
5454
5555 $qp = new SMWNotifyParser( $notify_id, $printoutArticles );
5656 $qp->setDefaultNamespaces( $smwgQDefaultNamespaces );
@@ -482,11 +482,11 @@
483483 protected function getSubqueryDescription( &$setNS, &$label ) {
484484 global $smwgQPrintoutLimit;
485485 wfLoadExtensionMessages( 'SemanticMediaWiki' );
486 - $conjunction = NULL; // used for the current inner conjunction
487 - $disjuncts = array(); // (disjunctive) array of subquery conjunctions
 486+ $conjunction = NULL; // used for the current inner conjunction
 487+ $disjuncts = array(); // (disjunctive) array of subquery conjunctions
488488 $printrequests = array(); // the printrequests found for this query level
489489 $hasNamespaces = false; // does the current $conjnuction have its own namespace restrictions?
490 - $mustSetNS = $setNS; // must ns restrictions be set? (may become true even if $setNS is false)
 490+ $mustSetNS = $setNS; // must ns restrictions be set? (may become true even if $setNS is false)
491491
492492 // added by dch
493493 $subquery = $this->m_subquery;
@@ -1021,7 +1021,7 @@
10221022 protected function readChunk( $stoppattern = '', $consume = true, $trim = true ) {
10231023 if ( $stoppattern == '' ) {
10241024 $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|^' . $this->m_categoryprefix .
1025 - '|^' . $this->m_conceptprefix . '|\|\||\|';
 1025+ '|^' . $this->m_conceptprefix . '|\|\||\|';
10261026 }
10271027 $chunks = preg_split( '/[\s]*(' . $stoppattern . ')/u', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE );
10281028 if ( count( $chunks ) == 1 ) { // no matches anymore, strip spaces and finish
@@ -1608,36 +1608,36 @@
16091609 } else {
16101610 global $phpInterpreter;
16111611 if ( !isset( $phpInterpreter ) ) {
1612 - // if $phpInterpreter is not set, assume it is in search path
1613 - // if not, starting of bot will FAIL!
1614 - $phpInterpreter = "php";
1615 - }
1616 - // copy from SMW_GardeningBot.php
1617 - ob_start();
1618 - phpinfo();
1619 - $info = ob_get_contents();
1620 - ob_end_clean();
 1612+ // if $phpInterpreter is not set, assume it is in search path
 1613+ // if not, starting of bot will FAIL!
 1614+ $phpInterpreter = "php";
 1615+ }
 1616+ // copy from SMW_GardeningBot.php
 1617+ ob_start();
 1618+ phpinfo();
 1619+ $info = ob_get_contents();
 1620+ ob_end_clean();
16211621 // Get Systemstring
1622 - preg_match( '!\nSystem(.*?)\n!is', strip_tags( $info ), $ma );
 1622+ preg_match( '!\nSystem(.*?)\n!is', strip_tags( $info ), $ma );
16231623 // Check if it consists 'windows' as string
1624 - preg_match( '/[Ww]indows/', $ma[1], $os );
1625 - global $smwgNMIP ;
1626 - if ( $os[0] == '' && $os[0] == null ) {
 1624+ preg_match( '/[Ww]indows/', $ma[1], $os );
 1625+ global $smwgNMIP ;
 1626+ if ( $os[0] == '' && $os[0] == null ) {
16271627
1628 - // FIXME: $runCommand must allow whitespaces in paths too
1629 - $runCommand = "$phpInterpreter -q $smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php";
1630 - // TODO: test async code for linux.
1631 - // low prio
1632 - $nullResult = `$runCommand > /dev/null &`;
1633 - }
1634 - else // windowze
1635 - {
1636 - $runCommand = "\"\"$phpInterpreter\" -q \"$smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php\"\"";
1637 - $wshShell = new COM( "WScript.Shell" );
 1628+ // FIXME: $runCommand must allow whitespaces in paths too
 1629+ $runCommand = "$phpInterpreter -q $smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php";
 1630+ // TODO: test async code for linux.
 1631+ // low prio
 1632+ $nullResult = `$runCommand > /dev/null &`;
 1633+ }
 1634+ else // windowze
 1635+ {
 1636+ $runCommand = "\"\"$phpInterpreter\" -q \"$smwgNMIP/specials/SMWNotifyMe/SMW_NMSendMailAsync.php\"\"";
 1637+ $wshShell = new COM( "WScript.Shell" );
16381638 $runCommand = "cmd /C " . $runCommand;
16391639
1640 - $oExec = $wshShell->Run( $runCommand, 7, false );
1641 - }
 1640+ $oExec = $wshShell->Run( $runCommand, 7, false );
 1641+ }
16421642 }
16431643 }
16441644 // copy from user class
Index: trunk/extensions/SemanticNotifyMe/includes/SNM_Initialize.php
@@ -221,22 +221,22 @@
222222 $jsm->addCSSIf( $smwgNMScriptPath . '/skins/nm.css', "all", - 1, NS_SPECIAL . ":NotifyMe" );
223223 } else {
224224 global $wgRequest;
225 - $scripts = array();
226 - $$css = array();
 225+ $scripts = array();
 226+ $$css = array();
227227
228 - // read state
229 - if ( $wgRequest != NULL && $wgTitle != NULL ) {
230 - $action = $wgRequest->getVal( "action" );
231 - // $action of NULL or '' means view mode
232 - $action = $action == NULL || $action == '' ? "view" : $action;
233 - $namespace = $wgTitle->getNamespace();
234 - $page = $wgTitle->getNamespace() . ":" . $wgTitle->getText();
 228+ // read state
 229+ if ( $wgRequest != NULL && $wgTitle != NULL ) {
 230+ $action = $wgRequest->getVal( "action" );
 231+ // $action of NULL or '' means view mode
 232+ $action = $action == NULL || $action == '' ? "view" : $action;
 233+ $namespace = $wgTitle->getNamespace();
 234+ $page = $wgTitle->getNamespace() . ":" . $wgTitle->getText();
235235
236 - } else { // if no state could be read, set default -> load all!
237 - $action = "all";
238 - $namespace = - 1;
239 - $page = array();
240 - }
 236+ } else { // if no state could be read, set default -> load all!
 237+ $action = "all";
 238+ $namespace = - 1;
 239+ $page = array();
 240+ }
241241 if ( ( $namespace == NS_SPECIAL || $namespace == - 1 ) && ( $page == NS_SPECIAL . ":NotifyMe" ) ) {
242242 $out->addScript( '<script type="text/javascript" src="' . $smwgNMScriptPath . '/scripts/prototype.js"></script>' );
243243 $out->addScript( '<script type="text/javascript" src="' . $smwgScriptPath . '/skins/SMW_tooltip.js"></script>' );
Index: trunk/extensions/SemanticNotifyMe/includes/storage/SMW_SQLStore2_QueriesNM.php
@@ -78,10 +78,10 @@
7979 // Update database:
8080 $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' );
8181 $this->m_dbs->query( "INSERT IGNORE INTO " . $this->m_dbs->tableName( 'smw_conccache' ) .
82 - " SELECT DISTINCT $qobj->joinfield AS s_id, $cid AS o_id FROM " .
83 - $this->m_dbs->tableName( $qobj->jointable ) . " AS $qobj->alias" . $qobj->from .
84 - ( $qobj->where ? " WHERE ":'' ) . $qobj->where . " LIMIT $smwgQMaxLimit",
85 - 'SMW::refreshConceptCache' );
 82+ " SELECT DISTINCT $qobj->joinfield AS s_id, $cid AS o_id FROM " .
 83+ $this->m_dbs->tableName( $qobj->jointable ) . " AS $qobj->alias" . $qobj->from .
 84+ ( $qobj->where ? " WHERE ":'' ) . $qobj->where . " LIMIT $smwgQMaxLimit",
 85+ 'SMW::refreshConceptCache' );
8686 $this->m_dbs->update( 'smw_conc2', array( 'cache_date' => strtotime( "now" ), 'cache_count' => $this->m_dbs->affectedRows() ), array( 's_id' => $cid ), 'SMW::refreshConceptCache' );
8787 } else { // just delete old data if there is any
8888 $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' );
@@ -157,8 +157,8 @@
158158 $qobj = $this->m_queries[$rootid];
159159 if ( $qobj->joinfield !== '' ) {
160160 $sql = "SELECT DISTINCT $qobj->alias.smw_title AS t,$qobj->alias.smw_namespace AS ns FROM " .
161 - $this->m_dbs->tableName( $qobj->jointable ) . " AS $qobj->alias" . $qobj->from .
162 - ( ( $qobj->where == '' ) ? '':' WHERE ' ) . $qobj->where;
 161+ $this->m_dbs->tableName( $qobj->jointable ) . " AS $qobj->alias" . $qobj->from .
 162+ ( ( $qobj->where == '' ) ? '':' WHERE ' ) . $qobj->where;
163163 } else { // empty result, no query needed
164164 wfProfileOut( 'SMWSQLStore2Queries::getNMQueryResult (SMW)' );
165165 return false;
@@ -254,8 +254,8 @@
255255 } elseif ( $description instanceof SMWConceptDescription ) { // fetch concept definition and insert it here
256256 $cid = $this->m_store->getSMWPageID( $description->getConcept()->getDBKey(), SMW_NS_CONCEPT, '' );
257257 $row = $this->m_dbs->selectRow( 'smw_conc2',
258 - array( 'concept_txt', 'concept_features', 'concept_size', 'concept_depth', 'cache_date' ),
259 - array( 's_id' => $cid ), 'SMWSQLStore2Queries::compileQueries' );
 258+ array( 'concept_txt', 'concept_features', 'concept_size', 'concept_depth', 'cache_date' ),
 259+ array( 's_id' => $cid ), 'SMWSQLStore2Queries::compileQueries' );
260260 if ( $row === false ) { // no description found, concept does not exist
261261 // keep the above query object, it yields an empty result
262262 // /TODO: announce an error here? (maybe not, since the query processor can check for
@@ -263,11 +263,11 @@
264264 } else {
265265 global $smwgQConceptCaching, $smwgQMaxSize, $smwgQMaxDepth, $smwgQFeatures, $smwgQConceptCacheLifetime;
266266 $may_be_computed = ( $smwgQConceptCaching == CONCEPT_CACHE_NONE ) ||
267 - ( ( $smwgQConceptCaching == CONCEPT_CACHE_HARD ) && ( ( ~( ~( $row->concept_features + 0 ) | $smwgQFeatures ) ) == 0 ) &&
268 - ( $smwgQMaxSize >= $row->concept_size ) && ( $smwgQMaxDepth >= $row->concept_depth ) );
 267+ ( ( $smwgQConceptCaching == CONCEPT_CACHE_HARD ) && ( ( ~( ~( $row->concept_features + 0 ) | $smwgQFeatures ) ) == 0 ) &&
 268+ ( $smwgQMaxSize >= $row->concept_size ) && ( $smwgQMaxDepth >= $row->concept_depth ) );
269269 if ( $row->cache_date &&
270 - ( $row->cache_date > ( strtotime( "now" ) - $smwgQConceptCacheLifetime * 60 ) ||
271 - !$may_be_computed ) ) { // cached concept, use cache unless it is dead and can be revived
 270+ ( $row->cache_date > ( strtotime( "now" ) - $smwgQConceptCacheLifetime * 60 ) ||
 271+ !$may_be_computed ) ) { // cached concept, use cache unless it is dead and can be revived
272272 $query->jointable = 'smw_conccache';
273273 $query->joinfield = "$query->alias.s_id";
274274 $query->where = "$query->alias.o_id=" . $this->m_dbs->addQuotes( $cid );
@@ -511,7 +511,7 @@
512512 // modified by dch, disable TEMPORARY tables
513513 // if ($this->m_qmode !== SMWQuery::MODE_DEBUG) {
514514 // $this->m_dbs->query( "CREATE TEMPORARY TABLE " . $this->m_dbs->tableName($query->alias) .
515 -// ' ( id INT UNSIGNED KEY ) TYPE=MEMORY', 'SMW::executeQueries' );
 515+// ' ( id INT UNSIGNED KEY ) TYPE=MEMORY', 'SMW::executeQueries' );
516516 // }
517517 // $this->m_querylog[$query->alias] = array();
518518 foreach ( $query->components as $qid => $joinfield ) {
@@ -698,11 +698,11 @@
699699 } else {
700700 $result['ORDER BY'] .= ', ';
701701 }
702 - if ( 'RAND()' == $order ) {
703 - $result['ORDER BY'] .= " $order ";
704 - } else {
705 - $result['ORDER BY'] .= $qobj->sortfields[$propkey] . " $order ";
706 - }
 702+ if ( 'RAND()' == $order ) {
 703+ $result['ORDER BY'] .= " $order ";
 704+ } else {
 705+ $result['ORDER BY'] .= $qobj->sortfields[$propkey] . " $order ";
 706+ }
707707
708708 }
709709 }
Index: trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php
@@ -27,38 +27,38 @@
2828
2929 // page_id, monitored page id
3030 SNMDBHelper::setupTable( $smw_nm_monitor,
31 - array( 'notify_id' => 'INT(8) UNSIGNED NOT NULL',
32 - 'page_id' => 'INT(8) UNSIGNED NOT NULL' ), $db, $verbose );
 31+ array( 'notify_id' => 'INT(8) UNSIGNED NOT NULL',
 32+ 'page_id' => 'INT(8) UNSIGNED NOT NULL' ), $db, $verbose );
3333 SNMDBHelper::setupIndex( $smw_nm_monitor, array( 'page_id' ), $db );
3434 SNMDBHelper::setupTable( $smw_nm_query,
3535 array( 'notify_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
36 - 'user_id' => 'INT(8) UNSIGNED NOT NULL',
 36+ 'user_id' => 'INT(8) UNSIGNED NOT NULL',
3737 'delegate' => 'BLOB',
38 - 'name' => 'VARCHAR(255) binary NOT NULL',
39 - 'rep_all' => 'TINYINT(1) NOT NULL default \'1\'',
40 - 'show_all' => 'TINYINT(1) NOT NULL default \'0\'',
41 - 'query' => 'BLOB NOT NULL',
42 - 'nm_sql' => 'BLOB',
 38+ 'name' => 'VARCHAR(255) binary NOT NULL',
 39+ 'rep_all' => 'TINYINT(1) NOT NULL default \'1\'',
 40+ 'show_all' => 'TINYINT(1) NOT NULL default \'0\'',
 41+ 'query' => 'BLOB NOT NULL',
 42+ 'nm_sql' => 'BLOB',
4343 'nm_hierarchy' => 'BLOB',
44 - 'enable' => 'TINYINT(1) NOT NULL default \'0\'' ), $db, $verbose );
 44+ 'enable' => 'TINYINT(1) NOT NULL default \'0\'' ), $db, $verbose );
4545 SNMDBHelper::setupIndex( $smw_nm_query, array( 'user_id' ), $db );
4646 // page_id, related page / property id in notify query
4747 SNMDBHelper::setupTable( $smw_nm_relations,
48 - array( 'notify_id' => 'INT(8) UNSIGNED NOT NULL',
49 - 'smw_id' => 'INT(8) UNSIGNED NOT NULL',
 48+ array( 'notify_id' => 'INT(8) UNSIGNED NOT NULL',
 49+ 'smw_id' => 'INT(8) UNSIGNED NOT NULL',
5050 // 0 category, 1 instance, 2 property
51 - 'type' => 'INT(8) UNSIGNED NOT NULL',
52 - 'subquery' => 'INT(8) UNSIGNED NOT NULL default \'0\'' ), $db, $verbose );
 51+ 'type' => 'INT(8) UNSIGNED NOT NULL',
 52+ 'subquery' => 'INT(8) UNSIGNED NOT NULL default \'0\'' ), $db, $verbose );
5353 SNMDBHelper::setupIndex( $smw_nm_relations, array( 'smw_id', 'notify_id' ), $db );
5454 SNMDBHelper::setupTable( $smw_nm_rss,
55 - array( 'msg_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
56 - 'mailed' => 'TINYINT(1) NOT NULL default \'0\'',
57 - 'user_id' => 'INT(8) UNSIGNED',
58 - 'notify_id' => 'INT(8) UNSIGNED',
59 - 'title' => 'VARCHAR(255) binary NOT NULL',
60 - 'link' => 'BLOB',
61 - 'notify' => 'BLOB NOT NULL',
62 - 'timestamp' => 'VARCHAR(14) binary NOT NULL' ), $db, $verbose );
 55+ array( 'msg_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
 56+ 'mailed' => 'TINYINT(1) NOT NULL default \'0\'',
 57+ 'user_id' => 'INT(8) UNSIGNED',
 58+ 'notify_id' => 'INT(8) UNSIGNED',
 59+ 'title' => 'VARCHAR(255) binary NOT NULL',
 60+ 'link' => 'BLOB',
 61+ 'notify' => 'BLOB NOT NULL',
 62+ 'timestamp' => 'VARCHAR(14) binary NOT NULL' ), $db, $verbose );
6363 SNMDBHelper::setupIndex( $smw_nm_rss, array( 'user_id' ), $db );
6464
6565 SNMDBHelper::reportProgress( "... done!\n", $verbose );
@@ -152,9 +152,9 @@
153153 $new_rel = true;
154154 $relations[] = array(
155155 'notify_id' => $notify_id,
156 - 'smw_id' => $rel_smw_id,
 156+ 'smw_id' => $rel_smw_id,
157157 // $type: 0 category, 1 instance, 2 property
158 - 'type' => ( ( $smw['namespace'] == NS_CATEGORY ) ? 0:( ( $smw['namespace'] == SMW_NS_PROPERTY ) ? 2:1 ) ),
 158+ 'type' => ( ( $smw['namespace'] == NS_CATEGORY ) ? 0:( ( $smw['namespace'] == SMW_NS_PROPERTY ) ? 2:1 ) ),
159159 'subquery' => $subquery );
160160 }
161161 }
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NMStorage.php
@@ -34,20 +34,20 @@
3535 *
3636 */
3737 private function __construct() {
38 - if ( self::$mDatabase == NULL ) {
39 - global $smwgBaseStore;
40 - switch ( $smwgBaseStore ) {
41 - case ( SMW_STORE_TESTING ):
42 - trigger_error( 'Testing store not implemented for NotifyMe extension.' );
43 - break;
44 - case ( SMW_STORE_MWDB ):
45 - default:
46 - global $smwgNMIP;
47 - require_once( $smwgNMIP . '/includes/storage/SMW_NMStorageSQL.php' );
48 - self::$mDatabase = new NMStorageSQL();
49 - break;
50 - }
51 - }
 38+ if ( self::$mDatabase == NULL ) {
 39+ global $smwgBaseStore;
 40+ switch ( $smwgBaseStore ) {
 41+ case ( SMW_STORE_TESTING ):
 42+ trigger_error( 'Testing store not implemented for NotifyMe extension.' );
 43+ break;
 44+ case ( SMW_STORE_MWDB ):
 45+ default:
 46+ global $smwgNMIP;
 47+ require_once( $smwgNMIP . '/includes/storage/SMW_NMStorageSQL.php' );
 48+ self::$mDatabase = new NMStorageSQL();
 49+ break;
 50+ }
 51+ }
5252
5353 }
5454
@@ -57,26 +57,26 @@
5858 * Returns the single instance of this class.
5959 *
6060 * @return NMStorage
61 - * The single instance of this class.
 61+ * The single instance of this class.
6262 */
6363 public static function getInstance() {
64 - if ( !isset( self::$mInstance ) ) {
65 - $c = __CLASS__;
66 - self::$mInstance = new $c;
67 - }
 64+ if ( !isset( self::$mInstance ) ) {
 65+ $c = __CLASS__;
 66+ self::$mInstance = new $c;
 67+ }
6868
69 - return self::$mInstance;
 69+ return self::$mInstance;
7070 }
7171
7272 /**
7373 * Returns the actual database.
7474 *
7575 * @return object
76 - * The object to access the database.
 76+ * The object to access the database.
7777 */
7878 public static function getDatabase() {
79 - self::getInstance(); // Make sure, singleton is initialized
80 - return self::$mDatabase;
 79+ self::getInstance(); // Make sure, singleton is initialized
 80+ return self::$mDatabase;
8181 }
8282
8383 }
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NMDBHelper.php
@@ -6,53 +6,53 @@
77 */
88
99 class SNMDBHelper {
10 - /**
11 - * Make sure the table of the given name has the given fields, provided
12 - * as an array with entries fieldname => typeparams. typeparams should be
13 - * in a normalised form and order to match to existing values.
14 - *
15 - * The function returns an array that includes all columns that have been
16 - * changed. For each such column, the array contains an entry
17 - * columnname => action, where action is one of 'up', 'new', or 'del'
18 - * If the table was already fine or was created completely anew, an empty
19 - * array is returned (assuming that both cases require no action).
20 - *
21 - * NOTE: the function partly ignores the order in which fields are set up.
22 - * Only if the type of some field changes will its order be adjusted explicitly.
23 - *
24 - * @param string $primaryKeys
25 - * This optional string specifies the primary keys if there is more
26 - * than one. This is a comma separated list of column names. The primary
27 - * keys are not altered, if the table already exists.
28 - */
29 - public static function setupTable( $table, $fields, $db, $verbose, $primaryKeys = "" ) {
30 - global $wgDBname;
31 - SNMDBHelper::reportProgress( "Setting up table $table ...\n", $verbose );
32 - if ( $db->tableExists( $table ) === false ) { // create new table
33 - $sql = 'CREATE TABLE ' . $wgDBname . '.' . $table . ' (';
34 - $first = true;
35 - foreach ( $fields as $name => $type ) {
36 - if ( $first ) {
37 - $first = false;
38 - } else {
39 - $sql .= ',';
40 - }
41 - $sql .= $name . ' ' . $type;
42 - }
43 - if ( !empty( $primaryKeys ) ) {
44 - $sql .= ", PRIMARY KEY(" . $primaryKeys . ")";
45 - }
46 - $sql .= ') TYPE=myisam';
47 - $db->query( $sql, 'SNMDBHelper::setupTable' );
48 - SNMDBHelper::reportProgress( " ... new table created\n", $verbose );
49 - return array();
50 - } else { // check table signature
51 - SNMDBHelper::reportProgress( " ... table exists already, checking structure ...\n", $verbose );
52 - $res = $db->query( 'DESCRIBE ' . $table, 'SNMDBHelper::setupTable' );
53 - $curfields = array();
54 - $result = array();
55 - while ( $row = $db->fetchObject( $res ) ) {
56 - $type = strtoupper( $row->Type );
 10+ /**
 11+ * Make sure the table of the given name has the given fields, provided
 12+ * as an array with entries fieldname => typeparams. typeparams should be
 13+ * in a normalised form and order to match to existing values.
 14+ *
 15+ * The function returns an array that includes all columns that have been
 16+ * changed. For each such column, the array contains an entry
 17+ * columnname => action, where action is one of 'up', 'new', or 'del'
 18+ * If the table was already fine or was created completely anew, an empty
 19+ * array is returned (assuming that both cases require no action).
 20+ *
 21+ * NOTE: the function partly ignores the order in which fields are set up.
 22+ * Only if the type of some field changes will its order be adjusted explicitly.
 23+ *
 24+ * @param string $primaryKeys
 25+ * This optional string specifies the primary keys if there is more
 26+ * than one. This is a comma separated list of column names. The primary
 27+ * keys are not altered, if the table already exists.
 28+ */
 29+ public static function setupTable( $table, $fields, $db, $verbose, $primaryKeys = "" ) {
 30+ global $wgDBname;
 31+ SNMDBHelper::reportProgress( "Setting up table $table ...\n", $verbose );
 32+ if ( $db->tableExists( $table ) === false ) { // create new table
 33+ $sql = 'CREATE TABLE ' . $wgDBname . '.' . $table . ' (';
 34+ $first = true;
 35+ foreach ( $fields as $name => $type ) {
 36+ if ( $first ) {
 37+ $first = false;
 38+ } else {
 39+ $sql .= ',';
 40+ }
 41+ $sql .= $name . ' ' . $type;
 42+ }
 43+ if ( !empty( $primaryKeys ) ) {
 44+ $sql .= ", PRIMARY KEY(" . $primaryKeys . ")";
 45+ }
 46+ $sql .= ') TYPE=myisam';
 47+ $db->query( $sql, 'SNMDBHelper::setupTable' );
 48+ SNMDBHelper::reportProgress( " ... new table created\n", $verbose );
 49+ return array();
 50+ } else { // check table signature
 51+ SNMDBHelper::reportProgress( " ... table exists already, checking structure ...\n", $verbose );
 52+ $res = $db->query( 'DESCRIBE ' . $table, 'SNMDBHelper::setupTable' );
 53+ $curfields = array();
 54+ $result = array();
 55+ while ( $row = $db->fetchObject( $res ) ) {
 56+ $type = strtoupper( $row->Type );
5757 if ( substr( $type, 0, 8 ) == 'VARCHAR(' ) {
5858 $type .= ' binary'; // just assume this to be the case for VARCHAR, avoid collation checks
5959 }
@@ -70,230 +70,230 @@
7171 }
7272
7373 $curfields[$row->Field] = $type;
74 - }
75 - $position = 'FIRST';
76 - foreach ( $fields as $name => $type ) {
77 - if ( !array_key_exists( $name, $curfields ) ) {
78 - SNMDBHelper::reportProgress( " ... creating column $name ... ", $verbose );
79 - $db->query( "ALTER TABLE $table ADD `$name` $type $position", 'SNMDBHelper::setupTable' );
80 - $result[$name] = 'new';
81 - SNMDBHelper::reportProgress( "done \n", $verbose );
82 - } elseif ( $curfields[$name] != $type ) {// && stripos("auto_increment", $type) == -1) {
83 - SNMDBHelper::reportProgress( " ... changing type of column $name from '$curfields[$name]' to '$type' ... ", $verbose );
84 - $db->query( "ALTER TABLE $table CHANGE `$name` `$name` $type $position", 'SNMDBHelper::setupTable' );
85 - $result[$name] = 'up';
86 - $curfields[$name] = false;
87 - SNMDBHelper::reportProgress( "done.\n", $verbose );
88 - } else {
89 - SNMDBHelper::reportProgress( " ... column $name is fine\n", $verbose );
90 - $curfields[$name] = false;
91 - }
92 - $position = "AFTER $name";
93 - }
94 - foreach ( $curfields as $name => $value ) {
95 - if ( $value !== false ) { // not encountered yet --> delete
96 - SNMDBHelper::reportProgress( " ... deleting obsolete column $name ... ", $verbose );
97 - $db->query( "ALTER TABLE $table DROP COLUMN `$name`", 'SNMDBHelper::setupTable' );
98 - $result[$name] = 'del';
99 - SNMDBHelper::reportProgress( "done.\n", $verbose );
100 - }
101 - }
102 - SNMDBHelper::reportProgress( " ... table $table set up successfully.\n", $verbose );
103 - return $result;
104 - }
105 - }
 74+ }
 75+ $position = 'FIRST';
 76+ foreach ( $fields as $name => $type ) {
 77+ if ( !array_key_exists( $name, $curfields ) ) {
 78+ SNMDBHelper::reportProgress( " ... creating column $name ... ", $verbose );
 79+ $db->query( "ALTER TABLE $table ADD `$name` $type $position", 'SNMDBHelper::setupTable' );
 80+ $result[$name] = 'new';
 81+ SNMDBHelper::reportProgress( "done \n", $verbose );
 82+ } elseif ( $curfields[$name] != $type ) {// && stripos("auto_increment", $type) == -1) {
 83+ SNMDBHelper::reportProgress( " ... changing type of column $name from '$curfields[$name]' to '$type' ... ", $verbose );
 84+ $db->query( "ALTER TABLE $table CHANGE `$name` `$name` $type $position", 'SNMDBHelper::setupTable' );
 85+ $result[$name] = 'up';
 86+ $curfields[$name] = false;
 87+ SNMDBHelper::reportProgress( "done.\n", $verbose );
 88+ } else {
 89+ SNMDBHelper::reportProgress( " ... column $name is fine\n", $verbose );
 90+ $curfields[$name] = false;
 91+ }
 92+ $position = "AFTER $name";
 93+ }
 94+ foreach ( $curfields as $name => $value ) {
 95+ if ( $value !== false ) { // not encountered yet --> delete
 96+ SNMDBHelper::reportProgress( " ... deleting obsolete column $name ... ", $verbose );
 97+ $db->query( "ALTER TABLE $table DROP COLUMN `$name`", 'SNMDBHelper::setupTable' );
 98+ $result[$name] = 'del';
 99+ SNMDBHelper::reportProgress( "done.\n", $verbose );
 100+ }
 101+ }
 102+ SNMDBHelper::reportProgress( " ... table $table set up successfully.\n", $verbose );
 103+ return $result;
 104+ }
 105+ }
106106
107 - /**
108 - * Make sure that each of the column descriptions in the given array is indexed by *one* index
109 - * in the given DB table.
110 - */
111 - public static function setupIndex( $table, $columns, $db ) {
112 - $table = $db->tableName( $table );
113 - $res = $db->query( 'SHOW INDEX FROM ' . $table , 'SMW::SetupIndex' );
114 - if ( !$res ) {
115 - return false;
116 - }
117 - $indexes = array();
118 - while ( $row = $db->fetchObject( $res ) ) {
119 - if ( !array_key_exists( $row->Key_name, $indexes ) ) {
120 - $indexes[$row->Key_name] = array();
121 - }
122 - $indexes[$row->Key_name][$row->Seq_in_index] = $row->Column_name;
123 - }
124 - foreach ( $indexes as $key => $index ) { // clean up existing indexes
125 - $id = array_search( implode( ',', $index ), $columns );
126 - if ( $id !== false ) {
127 - $columns[$id] = false;
128 - } else { // duplicate or unrequired index
 107+ /**
 108+ * Make sure that each of the column descriptions in the given array is indexed by *one* index
 109+ * in the given DB table.
 110+ */
 111+ public static function setupIndex( $table, $columns, $db ) {
 112+ $table = $db->tableName( $table );
 113+ $res = $db->query( 'SHOW INDEX FROM ' . $table , 'SMW::SetupIndex' );
 114+ if ( !$res ) {
 115+ return false;
 116+ }
 117+ $indexes = array();
 118+ while ( $row = $db->fetchObject( $res ) ) {
 119+ if ( !array_key_exists( $row->Key_name, $indexes ) ) {
 120+ $indexes[$row->Key_name] = array();
 121+ }
 122+ $indexes[$row->Key_name][$row->Seq_in_index] = $row->Column_name;
 123+ }
 124+ foreach ( $indexes as $key => $index ) { // clean up existing indexes
 125+ $id = array_search( implode( ',', $index ), $columns );
 126+ if ( $id !== false ) {
 127+ $columns[$id] = false;
 128+ } else { // duplicate or unrequired index
129129 if ( $key != 'PRIMARY' ) {
130130 $db->query( 'DROP INDEX ' . $key . ' ON ' . $table, 'SMW::SetupIndex' );
131131 }
132 - }
133 - }
 132+ }
 133+ }
134134
135 - foreach ( $columns as $column ) { // add remaining indexes
136 - if ( $column != false ) {
137 - $db->query( "ALTER TABLE $table ADD INDEX ( $column )", 'SMW::SetupIndex' );
138 - }
139 - }
140 - return true;
141 - }
 135+ foreach ( $columns as $column ) { // add remaining indexes
 136+ if ( $column != false ) {
 137+ $db->query( "ALTER TABLE $table ADD INDEX ( $column )", 'SMW::SetupIndex' );
 138+ }
 139+ }
 140+ return true;
 141+ }
142142
143 - /**
144 - * Print some output to indicate progress. The output message is given by
145 - * $msg, while $verbose indicates whether or not output is desired at all.
146 - */
147 - public static function reportProgress( $msg, $verbose ) {
148 - if ( !$verbose ) {
149 - return;
150 - }
151 - if ( ob_get_level() == 0 ) { // be sure to have some buffer, otherwise some PHPs complain
152 - ob_start();
153 - }
154 - print $msg;
155 - ob_flush();
156 - flush();
157 - }
 143+ /**
 144+ * Print some output to indicate progress. The output message is given by
 145+ * $msg, while $verbose indicates whether or not output is desired at all.
 146+ */
 147+ public static function reportProgress( $msg, $verbose ) {
 148+ if ( !$verbose ) {
 149+ return;
 150+ }
 151+ if ( ob_get_level() == 0 ) { // be sure to have some buffer, otherwise some PHPs complain
 152+ ob_start();
 153+ }
 154+ print $msg;
 155+ ob_flush();
 156+ flush();
 157+ }
158158
159 - /**
160 - * Transform input parameters into a suitable array of SQL options.
161 - * The parameter $valuecol defines the string name of the column to which
162 - * sorting requests etc. are to be applied.
163 - */
164 - public static function getSQLOptions( $requestoptions, $valuecol = NULL ) {
165 - $sql_options = array();
166 - if ( $requestoptions !== NULL ) {
167 - if ( is_numeric( $requestoptions->limit ) && $requestoptions->limit >= 0 ) {
168 - $sql_options['LIMIT'] = $requestoptions->limit;
169 - }
170 - if ( is_numeric( $requestoptions->offset ) && $requestoptions->offset > 0 ) {
171 - $sql_options['OFFSET'] = $requestoptions->offset;
172 - }
173 - if ( ( $valuecol !== NULL ) && ( $requestoptions->sort ) ) {
174 - if ( is_array( $valuecol ) ) {
175 - $sql_options['ORDER BY'] = $requestoptions->ascending ? mysql_real_escape_string( implode( ",", $valuecol ) ) : mysql_real_escape_string( implode( ",", $valuecol ) ) . ' DESC';
176 - } else {
177 - $sql_options['ORDER BY'] = $requestoptions->ascending ? mysql_real_escape_string( $valuecol ) : mysql_real_escape_string( $valuecol ) . ' DESC';
178 - }
179 - }
180 - }
181 - return $sql_options;
182 - }
 159+ /**
 160+ * Transform input parameters into a suitable array of SQL options.
 161+ * The parameter $valuecol defines the string name of the column to which
 162+ * sorting requests etc. are to be applied.
 163+ */
 164+ public static function getSQLOptions( $requestoptions, $valuecol = NULL ) {
 165+ $sql_options = array();
 166+ if ( $requestoptions !== NULL ) {
 167+ if ( is_numeric( $requestoptions->limit ) && $requestoptions->limit >= 0 ) {
 168+ $sql_options['LIMIT'] = $requestoptions->limit;
 169+ }
 170+ if ( is_numeric( $requestoptions->offset ) && $requestoptions->offset > 0 ) {
 171+ $sql_options['OFFSET'] = $requestoptions->offset;
 172+ }
 173+ if ( ( $valuecol !== NULL ) && ( $requestoptions->sort ) ) {
 174+ if ( is_array( $valuecol ) ) {
 175+ $sql_options['ORDER BY'] = $requestoptions->ascending ? mysql_real_escape_string( implode( ",", $valuecol ) ) : mysql_real_escape_string( implode( ",", $valuecol ) ) . ' DESC';
 176+ } else {
 177+ $sql_options['ORDER BY'] = $requestoptions->ascending ? mysql_real_escape_string( $valuecol ) : mysql_real_escape_string( $valuecol ) . ' DESC';
 178+ }
 179+ }
 180+ }
 181+ return $sql_options;
 182+ }
183183
184 - public static function getSQLOptionsAsString( $requestoptions, $valuecol = NULL ) {
185 - $options = SNMDBHelper::getSQLOptions( $requestoptions, $valuecol );
186 - $limit = array_key_exists( 'LIMIT', $options ) && is_numeric( $options['LIMIT'] ) ? 'LIMIT ' . $options['LIMIT'] : '';
187 - $offset = array_key_exists( 'OFFSET', $options ) && is_numeric( $options['OFFSET'] ) ? 'OFFSET ' . $options['OFFSET'] : '';
188 - $orderby = array_key_exists( 'ORDER BY', $options ) ? 'ORDER BY ' . $options['ORDER BY'] : '';
189 - return $orderby . ' ' . $limit . ' ' . $offset;
190 - }
 184+ public static function getSQLOptionsAsString( $requestoptions, $valuecol = NULL ) {
 185+ $options = SNMDBHelper::getSQLOptions( $requestoptions, $valuecol );
 186+ $limit = array_key_exists( 'LIMIT', $options ) && is_numeric( $options['LIMIT'] ) ? 'LIMIT ' . $options['LIMIT'] : '';
 187+ $offset = array_key_exists( 'OFFSET', $options ) && is_numeric( $options['OFFSET'] ) ? 'OFFSET ' . $options['OFFSET'] : '';
 188+ $orderby = array_key_exists( 'ORDER BY', $options ) ? 'ORDER BY ' . $options['ORDER BY'] : '';
 189+ return $orderby . ' ' . $limit . ' ' . $offset;
 190+ }
191191
192 - /**
193 - * Transform input parameters into a suitable string of additional SQL conditions.
194 - * The parameter $valuecol defines the string name of the column to which
195 - * value restrictions etc. are to be applied.
196 - * @param $requestoptions object with options
197 - * @param $valuecol name of SQL column to which conditions apply
198 - * @param $labelcol name of SQL column to which string conditions apply, if any
199 - */
200 - public static function getSQLConditions( $requestoptions, $valuecol, $labelcol = NULL ) {
201 - $sql_conds = '';
202 - if ( $requestoptions !== NULL ) {
203 - $db =& wfGetDB( DB_SLAVE ); // TODO: use slave?
204 - if ( $requestoptions->boundary !== NULL ) { // apply value boundary
205 - if ( $requestoptions->ascending ) {
206 - if ( $requestoptions->include_boundary ) {
207 - $op = ' >= ';
208 - } else {
209 - $op = ' > ';
210 - }
211 - } else {
212 - if ( $requestoptions->include_boundary ) {
213 - $op = ' <= ';
214 - } else {
215 - $op = ' < ';
216 - }
217 - }
218 - $sql_conds .= ' AND ' . mysql_real_escape_string( $valuecol ) . $op . $db->addQuotes( $requestoptions->boundary );
219 - }
220 - $operator = isset( $requestoptions->disjunctiveStrings ) && $requestoptions->disjunctiveStrings === true ? ' OR ' : ' AND ';
221 - $neutral = isset( $requestoptions->disjunctiveStrings ) && $requestoptions->disjunctiveStrings === true ? ' FALSE ' : ' TRUE ';
222 - if ( $labelcol !== NULL ) { // apply string conditions
 192+ /**
 193+ * Transform input parameters into a suitable string of additional SQL conditions.
 194+ * The parameter $valuecol defines the string name of the column to which
 195+ * value restrictions etc. are to be applied.
 196+ * @param $requestoptions object with options
 197+ * @param $valuecol name of SQL column to which conditions apply
 198+ * @param $labelcol name of SQL column to which string conditions apply, if any
 199+ */
 200+ public static function getSQLConditions( $requestoptions, $valuecol, $labelcol = NULL ) {
 201+ $sql_conds = '';
 202+ if ( $requestoptions !== NULL ) {
 203+ $db =& wfGetDB( DB_SLAVE ); // TODO: use slave?
 204+ if ( $requestoptions->boundary !== NULL ) { // apply value boundary
 205+ if ( $requestoptions->ascending ) {
 206+ if ( $requestoptions->include_boundary ) {
 207+ $op = ' >= ';
 208+ } else {
 209+ $op = ' > ';
 210+ }
 211+ } else {
 212+ if ( $requestoptions->include_boundary ) {
 213+ $op = ' <= ';
 214+ } else {
 215+ $op = ' < ';
 216+ }
 217+ }
 218+ $sql_conds .= ' AND ' . mysql_real_escape_string( $valuecol ) . $op . $db->addQuotes( $requestoptions->boundary );
 219+ }
 220+ $operator = isset( $requestoptions->disjunctiveStrings ) && $requestoptions->disjunctiveStrings === true ? ' OR ' : ' AND ';
 221+ $neutral = isset( $requestoptions->disjunctiveStrings ) && $requestoptions->disjunctiveStrings === true ? ' FALSE ' : ' TRUE ';
 222+ if ( $labelcol !== NULL ) { // apply string conditions
223223
224 - $sql_conds .= ' AND ( ';
 224+ $sql_conds .= ' AND ( ';
225225
226 - foreach ( $requestoptions->getStringConditions() as $strcond ) {
227 - $string = str_replace( array( '_', ' ' ), array( '\_', '\_' ), $strcond->string );
228 - switch ( $strcond->condition ) {
229 - case SMWStringCondition::STRCOND_PRE:
230 - $string .= '%';
231 - break;
232 - case SMWStringCondition::STRCOND_POST:
233 - $string = '%' . $string;
234 - break;
235 - case SMWStringCondition::STRCOND_MID:
236 - $string = '%' . $string . '%';
237 - break;
238 - }
239 - if ( $requestoptions->isCaseSensitive ) {
240 - $sql_conds .= mysql_real_escape_string( $labelcol ) . ' LIKE ' . $db->addQuotes( $string ) . $operator;
241 - } else {
242 - $sql_conds .= ' UPPER(' . mysql_real_escape_string( $labelcol ) . ') LIKE UPPER(' . $db->addQuotes( $string ) . ') ' . $operator;
243 - }
244 - }
245 - $sql_conds .= ' ' . $neutral . ' ) ';
246 - }
247 - }
248 - return $sql_conds;
249 - }
 226+ foreach ( $requestoptions->getStringConditions() as $strcond ) {
 227+ $string = str_replace( array( '_', ' ' ), array( '\_', '\_' ), $strcond->string );
 228+ switch ( $strcond->condition ) {
 229+ case SMWStringCondition::STRCOND_PRE:
 230+ $string .= '%';
 231+ break;
 232+ case SMWStringCondition::STRCOND_POST:
 233+ $string = '%' . $string;
 234+ break;
 235+ case SMWStringCondition::STRCOND_MID:
 236+ $string = '%' . $string . '%';
 237+ break;
 238+ }
 239+ if ( $requestoptions->isCaseSensitive ) {
 240+ $sql_conds .= mysql_real_escape_string( $labelcol ) . ' LIKE ' . $db->addQuotes( $string ) . $operator;
 241+ } else {
 242+ $sql_conds .= ' UPPER(' . mysql_real_escape_string( $labelcol ) . ') LIKE UPPER(' . $db->addQuotes( $string ) . ') ' . $operator;
 243+ }
 244+ }
 245+ $sql_conds .= ' ' . $neutral . ' ) ';
 246+ }
 247+ }
 248+ return $sql_conds;
 249+ }
250250
251 - /**
252 - * Returns sql conditions of $requestoptions in an Array.
253 - * Warning! Does not support SMWAdvRequestOptions
254 - *
255 - * @param SMWRequestOptions $requestoptions
256 - * @param string $valuecol
257 - * @param string $labelcol
258 - * @return array
259 - */
260 - public static function getSQLConditionsAsArray( $requestoptions, $valuecol, $labelcol = NULL ) {
261 - $sql_conds = array();
262 - if ( $requestoptions !== NULL ) {
263 - $db =& wfGetDB( DB_SLAVE );
264 - if ( $requestoptions->boundary !== NULL ) { // apply value boundary
265 - if ( $requestoptions->ascending ) {
266 - if ( $requestoptions->include_boundary ) {
267 - $op = ' >= ';
268 - } else {
269 - $op = ' > ';
270 - }
271 - } else {
272 - if ( $requestoptions->include_boundary ) {
273 - $op = ' <= ';
274 - } else {
275 - $op = ' < ';
276 - }
277 - }
278 - $sql_conds[] = mysql_real_escape_string( $valuecol ) . $op . $db->addQuotes( $requestoptions->boundary );
279 - }
280 - if ( $labelcol !== NULL ) { // apply string conditions
281 - foreach ( $requestoptions->getStringConditions() as $strcond ) {
282 - $string = str_replace( array( '_', ' ' ), array( '\_', '\_' ), $strcond->string );
283 - switch ( $strcond->condition ) {
284 - case SMWStringCondition::STRCOND_PRE:
285 - $string .= '%';
286 - break;
287 - case SMWStringCondition::STRCOND_POST:
288 - $string = '%' . $string;
289 - break;
290 - case SMWStringCondition::STRCOND_MID:
291 - $string = '%' . $string . '%';
292 - break;
293 - }
294 - $sql_conds[] = 'UPPER(' . mysql_real_escape_string( $labelcol ) . ') LIKE UPPER(' . $db->addQuotes( $string ) . ')';
295 - }
296 - }
297 - }
298 - return $sql_conds;
299 - }
 251+ /**
 252+ * Returns sql conditions of $requestoptions in an Array.
 253+ * Warning! Does not support SMWAdvRequestOptions
 254+ *
 255+ * @param SMWRequestOptions $requestoptions
 256+ * @param string $valuecol
 257+ * @param string $labelcol
 258+ * @return array
 259+ */
 260+ public static function getSQLConditionsAsArray( $requestoptions, $valuecol, $labelcol = NULL ) {
 261+ $sql_conds = array();
 262+ if ( $requestoptions !== NULL ) {
 263+ $db =& wfGetDB( DB_SLAVE );
 264+ if ( $requestoptions->boundary !== NULL ) { // apply value boundary
 265+ if ( $requestoptions->ascending ) {
 266+ if ( $requestoptions->include_boundary ) {
 267+ $op = ' >= ';
 268+ } else {
 269+ $op = ' > ';
 270+ }
 271+ } else {
 272+ if ( $requestoptions->include_boundary ) {
 273+ $op = ' <= ';
 274+ } else {
 275+ $op = ' < ';
 276+ }
 277+ }
 278+ $sql_conds[] = mysql_real_escape_string( $valuecol ) . $op . $db->addQuotes( $requestoptions->boundary );
 279+ }
 280+ if ( $labelcol !== NULL ) { // apply string conditions
 281+ foreach ( $requestoptions->getStringConditions() as $strcond ) {
 282+ $string = str_replace( array( '_', ' ' ), array( '\_', '\_' ), $strcond->string );
 283+ switch ( $strcond->condition ) {
 284+ case SMWStringCondition::STRCOND_PRE:
 285+ $string .= '%';
 286+ break;
 287+ case SMWStringCondition::STRCOND_POST:
 288+ $string = '%' . $string;
 289+ break;
 290+ case SMWStringCondition::STRCOND_MID:
 291+ $string = '%' . $string . '%';
 292+ break;
 293+ }
 294+ $sql_conds[] = 'UPPER(' . mysql_real_escape_string( $labelcol ) . ') LIKE UPPER(' . $db->addQuotes( $string ) . ')';
 295+ }
 296+ }
 297+ }
 298+ return $sql_conds;
 299+ }
300300 }
Index: trunk/extensions/SemanticNotifyMe/includes/jobs/SMW_NMSendMailJob.php
@@ -20,23 +20,23 @@
2121 *
2222 * @param Title $title
2323 */
24 - function __construct( $title, $params ) {
25 - wfDebug( __METHOD__ . " " . get_class( $this ) . " \r\n" );
26 - wfProfileIn( __METHOD__ );
27 - parent::__construct( get_class( $this ), Title::newMainPage(), $params );
 24+ function __construct( $title, $params ) {
 25+ wfDebug( __METHOD__ . " " . get_class( $this ) . " \r\n" );
 26+ wfProfileIn( __METHOD__ );
 27+ parent::__construct( get_class( $this ), Title::newMainPage(), $params );
2828
29 - wfProfileOut( __METHOD__ );
30 - }
 29+ wfProfileOut( __METHOD__ );
 30+ }
3131
32 - /**
33 - * Run a SMW_NMSendMailJob job
34 - * @return boolean success
35 - */
36 - function run() {
37 - wfDebug( __METHOD__ );
38 - wfProfileIn( __METHOD__ );
 32+ /**
 33+ * Run a SMW_NMSendMailJob job
 34+ * @return boolean success
 35+ */
 36+ function run() {
 37+ wfDebug( __METHOD__ );
 38+ wfProfileIn( __METHOD__ );
3939
40 - UserMailer::send( // userMailer(
 40+ UserMailer::send( // userMailer(
4141 $this->params['to'],
4242 $this->params['from'],
4343 $this->params['subj'],
@@ -45,6 +45,6 @@
4646 );
4747
4848 wfProfileOut( __METHOD__ );
49 - return true;
50 - }
 49+ return true;
 50+ }
5151 }
Index: trunk/extensions/SemanticNotifyMe/languages/SMW_NMLanguage.php
@@ -53,7 +53,7 @@
5454 /**
5555 * Returns the label of the special property with the ID $propID.
5656 * @param int propID
57 - * ID of the special property
 57+ * ID of the special property
5858 * @return String Label of the special property
5959 */
6060 function getSpecialPropertyLabel( $propID ) {
@@ -100,9 +100,9 @@
101101 * Returns the name of the namespace with the ID <$namespaceID>.
102102 *
103103 * @param int $namespaceID
104 - * ID of the namespace whose name is requested
 104+ * ID of the namespace whose name is requested
105105 * @return string
106 - * Name of the namespace or <null>.
 106+ * Name of the namespace or <null>.
107107 *
108108 */
109109 public function getNamespace( $namespaceID ) {
@@ -113,7 +113,7 @@
114114 * Returns the array with all namespaces of the NM extension.
115115 *
116116 * @return string
117 - * Array of additional namespaces.
 117+ * Array of additional namespaces.
118118 *
119119 */
120120 public function getNamespaces() {
@@ -124,7 +124,7 @@
125125 * Returns the array with all namespace aliases of the NM extension.
126126 *
127127 * @return string
128 - * Array of additional namespace aliases.
 128+ * Array of additional namespace aliases.
129129 *
130130 */
131131 public function getNamespaceAliases() {
Index: trunk/extensions/SemanticNotifyMe/scripts/prototype.js
@@ -10,20 +10,20 @@
1111 Version: '1.6.0',
1212
1313 Browser: {
14 - IE: !!(window.attachEvent && !window.opera),
15 - Opera: !!window.opera,
16 - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
17 - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
18 - MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
 14+ IE: !!(window.attachEvent && !window.opera),
 15+ Opera: !!window.opera,
 16+ WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
 17+ Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
 18+ MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
1919 },
2020
2121 BrowserFeatures: {
22 - XPath: !!document.evaluate,
23 - ElementExtensions: !!window.HTMLElement,
24 - SpecificElementExtensions:
25 - document.createElement('div').__proto__ &&
26 - document.createElement('div').__proto__ !==
27 - document.createElement('form').__proto__
 22+ XPath: !!document.evaluate,
 23+ ElementExtensions: !!window.HTMLElement,
 24+ SpecificElementExtensions:
 25+ document.createElement('div').__proto__ &&
 26+ document.createElement('div').__proto__ !==
 27+ document.createElement('form').__proto__
2828 },
2929
3030 ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
@@ -42,60 +42,60 @@
4343 /* Based on Alex Arnell's inheritance implementation. */
4444 var Class = {
4545 create: function() {
46 - var parent = null, properties = $A(arguments);
47 - if (Object.isFunction(properties[0]))
48 - parent = properties.shift();
 46+ var parent = null, properties = $A(arguments);
 47+ if (Object.isFunction(properties[0]))
 48+ parent = properties.shift();
4949
50 - function klass() {
51 - this.initialize.apply(this, arguments);
52 - }
 50+ function klass() {
 51+ this.initialize.apply(this, arguments);
 52+ }
5353
54 - Object.extend(klass, Class.Methods);
55 - klass.superclass = parent;
56 - klass.subclasses = [];
 54+ Object.extend(klass, Class.Methods);
 55+ klass.superclass = parent;
 56+ klass.subclasses = [];
5757
58 - if (parent) {
59 - var subclass = function() { };
60 - subclass.prototype = parent.prototype;
61 - klass.prototype = new subclass;
62 - parent.subclasses.push(klass);
63 - }
 58+ if (parent) {
 59+ var subclass = function() { };
 60+ subclass.prototype = parent.prototype;
 61+ klass.prototype = new subclass;
 62+ parent.subclasses.push(klass);
 63+ }
6464
65 - for (var i = 0; i < properties.length; i++)
66 - klass.addMethods(properties[i]);
 65+ for (var i = 0; i < properties.length; i++)
 66+ klass.addMethods(properties[i]);
6767
68 - if (!klass.prototype.initialize)
69 - klass.prototype.initialize = Prototype.emptyFunction;
 68+ if (!klass.prototype.initialize)
 69+ klass.prototype.initialize = Prototype.emptyFunction;
7070
71 - klass.prototype.constructor = klass;
 71+ klass.prototype.constructor = klass;
7272
73 - return klass;
 73+ return klass;
7474 }
7575 };
7676
7777 Class.Methods = {
7878 addMethods: function(source) {
79 - var ancestor = this.superclass && this.superclass.prototype;
80 - var properties = Object.keys(source);
 79+ var ancestor = this.superclass && this.superclass.prototype;
 80+ var properties = Object.keys(source);
8181
82 - if (!Object.keys({ toString: true }).length)
83 - properties.push("toString", "valueOf");
 82+ if (!Object.keys({ toString: true }).length)
 83+ properties.push("toString", "valueOf");
8484
85 - for (var i = 0, length = properties.length; i < length; i++) {
86 - var property = properties[i], value = source[property];
87 - if (ancestor && Object.isFunction(value) &&
88 - value.argumentNames().first() == "$super") {
89 - var method = value, value = Object.extend((function(m) {
90 - return function() { return ancestor[m].apply(this, arguments) };
91 - })(property).wrap(method), {
92 - valueOf: function() { return method },
93 - toString: function() { return method.toString() }
94 - });
95 - }
96 - this.prototype[property] = value;
97 - }
 85+ for (var i = 0, length = properties.length; i < length; i++) {
 86+ var property = properties[i], value = source[property];
 87+ if (ancestor && Object.isFunction(value) &&
 88+ value.argumentNames().first() == "$super") {
 89+ var method = value, value = Object.extend((function(m) {
 90+ return function() { return ancestor[m].apply(this, arguments) };
 91+ })(property).wrap(method), {
 92+ valueOf: function() { return method },
 93+ toString: function() { return method.toString() }
 94+ });
 95+ }
 96+ this.prototype[property] = value;
 97+ }
9898
99 - return this;
 99+ return this;
100100 }
101101 };
102102
@@ -103,149 +103,149 @@
104104
105105 Object.extend = function(destination, source) {
106106 for (var property in source)
107 - destination[property] = source[property];
 107+ destination[property] = source[property];
108108 return destination;
109109 };
110110
111111 Object.extend(Object, {
112112 inspect: function(object) {
113 - try {
114 - if (object === undefined) return 'undefined';
115 - if (object === null) return 'null';
116 - return object.inspect ? object.inspect() : object.toString();
117 - } catch (e) {
118 - if (e instanceof RangeError) return '...';
119 - throw e;
120 - }
 113+ try {
 114+ if (object === undefined) return 'undefined';
 115+ if (object === null) return 'null';
 116+ return object.inspect ? object.inspect() : object.toString();
 117+ } catch (e) {
 118+ if (e instanceof RangeError) return '...';
 119+ throw e;
 120+ }
121121 },
122122
123123 toJSON: function(object) {
124 - var type = typeof object;
125 - switch (type) {
126 - case 'undefined':
127 - case 'function':
128 - case 'unknown': return;
129 - case 'boolean': return object.toString();
130 - }
 124+ var type = typeof object;
 125+ switch (type) {
 126+ case 'undefined':
 127+ case 'function':
 128+ case 'unknown': return;
 129+ case 'boolean': return object.toString();
 130+ }
131131
132 - if (object === null) return 'null';
133 - if (object.toJSON) return object.toJSON();
134 - if (Object.isElement(object)) return;
 132+ if (object === null) return 'null';
 133+ if (object.toJSON) return object.toJSON();
 134+ if (Object.isElement(object)) return;
135135
136 - var results = [];
137 - for (var property in object) {
138 - var value = Object.toJSON(object[property]);
139 - if (value !== undefined)
140 - results.push(property.toJSON() + ': ' + value);
141 - }
 136+ var results = [];
 137+ for (var property in object) {
 138+ var value = Object.toJSON(object[property]);
 139+ if (value !== undefined)
 140+ results.push(property.toJSON() + ': ' + value);
 141+ }
142142
143 - return '{' + results.join(', ') + '}';
 143+ return '{' + results.join(', ') + '}';
144144 },
145145
146146 toQueryString: function(object) {
147 - return $H(object).toQueryString();
 147+ return $H(object).toQueryString();
148148 },
149149
150150 toHTML: function(object) {
151 - return object && object.toHTML ? object.toHTML() : String.interpret(object);
 151+ return object && object.toHTML ? object.toHTML() : String.interpret(object);
152152 },
153153
154154 keys: function(object) {
155 - var keys = [];
156 - for (var property in object)
157 - keys.push(property);
158 - return keys;
 155+ var keys = [];
 156+ for (var property in object)
 157+ keys.push(property);
 158+ return keys;
159159 },
160160
161161 values: function(object) {
162 - var values = [];
163 - for (var property in object)
164 - values.push(object[property]);
165 - return values;
 162+ var values = [];
 163+ for (var property in object)
 164+ values.push(object[property]);
 165+ return values;
166166 },
167167
168168 clone: function(object) {
169 - return Object.extend({ }, object);
 169+ return Object.extend({ }, object);
170170 },
171171
172172 isElement: function(object) {
173 - return object && object.nodeType == 1;
 173+ return object && object.nodeType == 1;
174174 },
175175
176176 isArray: function(object) {
177 - return object && object.constructor === Array;
 177+ return object && object.constructor === Array;
178178 },
179179
180180 isHash: function(object) {
181 - return object instanceof Hash;
 181+ return object instanceof Hash;
182182 },
183183
184184 isFunction: function(object) {
185 - return typeof object == "function";
 185+ return typeof object == "function";
186186 },
187187
188188 isString: function(object) {
189 - return typeof object == "string";
 189+ return typeof object == "string";
190190 },
191191
192192 isNumber: function(object) {
193 - return typeof object == "number";
 193+ return typeof object == "number";
194194 },
195195
196196 isUndefined: function(object) {
197 - return typeof object == "undefined";
 197+ return typeof object == "undefined";
198198 }
199199 });
200200
201201 Object.extend(Function.prototype, {
202202 argumentNames: function() {
203 - var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
204 - return names.length == 1 && !names[0] ? [] : names;
 203+ var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");
 204+ return names.length == 1 && !names[0] ? [] : names;
205205 },
206206
207207 bind: function() {
208 - if (arguments.length < 2 && arguments[0] === undefined) return this;
209 - var __method = this, args = $A(arguments), object = args.shift();
210 - return function() {
211 - return __method.apply(object, args.concat($A(arguments)));
212 - }
 208+ if (arguments.length < 2 && arguments[0] === undefined) return this;
 209+ var __method = this, args = $A(arguments), object = args.shift();
 210+ return function() {
 211+ return __method.apply(object, args.concat($A(arguments)));
 212+ }
213213 },
214214
215215 bindAsEventListener: function() {
216 - var __method = this, args = $A(arguments), object = args.shift();
217 - return function(event) {
218 - return __method.apply(object, [event || window.event].concat(args));
219 - }
 216+ var __method = this, args = $A(arguments), object = args.shift();
 217+ return function(event) {
 218+ return __method.apply(object, [event || window.event].concat(args));
 219+ }
220220 },
221221
222222 curry: function() {
223 - if (!arguments.length) return this;
224 - var __method = this, args = $A(arguments);
225 - return function() {
226 - return __method.apply(this, args.concat($A(arguments)));
227 - }
 223+ if (!arguments.length) return this;
 224+ var __method = this, args = $A(arguments);
 225+ return function() {
 226+ return __method.apply(this, args.concat($A(arguments)));
 227+ }
228228 },
229229
230230 delay: function() {
231 - var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
232 - return window.setTimeout(function() {
233 - return __method.apply(__method, args);
234 - }, timeout);
 231+ var __method = this, args = $A(arguments), timeout = args.shift() * 1000;
 232+ return window.setTimeout(function() {
 233+ return __method.apply(__method, args);
 234+ }, timeout);
235235 },
236236
237237 wrap: function(wrapper) {
238 - var __method = this;
239 - return function() {
240 - return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
241 - }
 238+ var __method = this;
 239+ return function() {
 240+ return wrapper.apply(this, [__method.bind(this)].concat($A(arguments)));
 241+ }
242242 },
243243
244244 methodize: function() {
245 - if (this._methodized) return this._methodized;
246 - var __method = this;
247 - return this._methodized = function() {
248 - return __method.apply(null, [this].concat($A(arguments)));
249 - };
 245+ if (this._methodized) return this._methodized;
 246+ var __method = this;
 247+ return this._methodized = function() {
 248+ return __method.apply(null, [this].concat($A(arguments)));
 249+ };
250250 }
251251 });
252252
@@ -253,26 +253,26 @@
254254
255255 Date.prototype.toJSON = function() {
256256 return '"' + this.getUTCFullYear() + '-' +
257 - (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
258 - this.getUTCDate().toPaddedString(2) + 'T' +
259 - this.getUTCHours().toPaddedString(2) + ':' +
260 - this.getUTCMinutes().toPaddedString(2) + ':' +
261 - this.getUTCSeconds().toPaddedString(2) + 'Z"';
 257+ (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
 258+ this.getUTCDate().toPaddedString(2) + 'T' +
 259+ this.getUTCHours().toPaddedString(2) + ':' +
 260+ this.getUTCMinutes().toPaddedString(2) + ':' +
 261+ this.getUTCSeconds().toPaddedString(2) + 'Z"';
262262 };
263263
264264 var Try = {
265265 these: function() {
266 - var returnValue;
 266+ var returnValue;
267267
268 - for (var i = 0, length = arguments.length; i < length; i++) {
269 - var lambda = arguments[i];
270 - try {
271 - returnValue = lambda();
272 - break;
273 - } catch (e) { }
274 - }
 268+ for (var i = 0, length = arguments.length; i < length; i++) {
 269+ var lambda = arguments[i];
 270+ try {
 271+ returnValue = lambda();
 272+ break;
 273+ } catch (e) { }
 274+ }
275275
276 - return returnValue;
 276+ return returnValue;
277277 }
278278 };
279279
@@ -286,250 +286,250 @@
287287
288288 var PeriodicalExecuter = Class.create({
289289 initialize: function(callback, frequency) {
290 - this.callback = callback;
291 - this.frequency = frequency;
292 - this.currentlyExecuting = false;
 290+ this.callback = callback;
 291+ this.frequency = frequency;
 292+ this.currentlyExecuting = false;
293293
294 - this.registerCallback();
 294+ this.registerCallback();
295295 },
296296
297297 registerCallback: function() {
298 - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
 298+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
299299 },
300300
301301 execute: function() {
302 - this.callback(this);
 302+ this.callback(this);
303303 },
304304
305305 stop: function() {
306 - if (!this.timer) return;
307 - clearInterval(this.timer);
308 - this.timer = null;
 306+ if (!this.timer) return;
 307+ clearInterval(this.timer);
 308+ this.timer = null;
309309 },
310310
311311 onTimerEvent: function() {
312 - if (!this.currentlyExecuting) {
313 - try {
314 - this.currentlyExecuting = true;
315 - this.execute();
316 - } finally {
317 - this.currentlyExecuting = false;
318 - }
319 - }
 312+ if (!this.currentlyExecuting) {
 313+ try {
 314+ this.currentlyExecuting = true;
 315+ this.execute();
 316+ } finally {
 317+ this.currentlyExecuting = false;
 318+ }
 319+ }
320320 }
321321 });
322322 Object.extend(String, {
323323 interpret: function(value) {
324 - return value == null ? '' : String(value);
 324+ return value == null ? '' : String(value);
325325 },
326326 specialChar: {
327 - '\b': '\\b',
328 - '\t': '\\t',
329 - '\n': '\\n',
330 - '\f': '\\f',
331 - '\r': '\\r',
332 - '\\': '\\\\'
 327+ '\b': '\\b',
 328+ '\t': '\\t',
 329+ '\n': '\\n',
 330+ '\f': '\\f',
 331+ '\r': '\\r',
 332+ '\\': '\\\\'
333333 }
334334 });
335335
336336 Object.extend(String.prototype, {
337337 gsub: function(pattern, replacement) {
338 - var result = '', source = this, match;
339 - replacement = arguments.callee.prepareReplacement(replacement);
 338+ var result = '', source = this, match;
 339+ replacement = arguments.callee.prepareReplacement(replacement);
340340
341 - while (source.length > 0) {
342 - if (match = source.match(pattern)) {
343 - result += source.slice(0, match.index);
344 - result += String.interpret(replacement(match));
345 - source = source.slice(match.index + match[0].length);
346 - } else {
347 - result += source, source = '';
348 - }
349 - }
350 - return result;
 341+ while (source.length > 0) {
 342+ if (match = source.match(pattern)) {
 343+ result += source.slice(0, match.index);
 344+ result += String.interpret(replacement(match));
 345+ source = source.slice(match.index + match[0].length);
 346+ } else {
 347+ result += source, source = '';
 348+ }
 349+ }
 350+ return result;
351351 },
352352
353353 sub: function(pattern, replacement, count) {
354 - replacement = this.gsub.prepareReplacement(replacement);
355 - count = count === undefined ? 1 : count;
 354+ replacement = this.gsub.prepareReplacement(replacement);
 355+ count = count === undefined ? 1 : count;
356356
357 - return this.gsub(pattern, function(match) {
358 - if (--count < 0) return match[0];
359 - return replacement(match);
360 - });
 357+ return this.gsub(pattern, function(match) {
 358+ if (--count < 0) return match[0];
 359+ return replacement(match);
 360+ });
361361 },
362362
363363 scan: function(pattern, iterator) {
364 - this.gsub(pattern, iterator);
365 - return String(this);
 364+ this.gsub(pattern, iterator);
 365+ return String(this);
366366 },
367367
368368 truncate: function(length, truncation) {
369 - length = length || 30;
370 - truncation = truncation === undefined ? '...' : truncation;
371 - return this.length > length ?
372 - this.slice(0, length - truncation.length) + truncation : String(this);
 369+ length = length || 30;
 370+ truncation = truncation === undefined ? '...' : truncation;
 371+ return this.length > length ?
 372+ this.slice(0, length - truncation.length) + truncation : String(this);
373373 },
374374
375375 strip: function() {
376 - return this.replace(/^\s+/, '').replace(/\s+$/, '');
 376+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
377377 },
378378
379379 stripTags: function() {
380 - return this.replace(/<\/?[^>]+>/gi, '');
 380+ return this.replace(/<\/?[^>]+>/gi, '');
381381 },
382382
383383 stripScripts: function() {
384 - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
 384+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
385385 },
386386
387387 extractScripts: function() {
388 - var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
389 - var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
390 - return (this.match(matchAll) || []).map(function(scriptTag) {
391 - return (scriptTag.match(matchOne) || ['', ''])[1];
392 - });
 388+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
 389+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
 390+ return (this.match(matchAll) || []).map(function(scriptTag) {
 391+ return (scriptTag.match(matchOne) || ['', ''])[1];
 392+ });
393393 },
394394
395395 evalScripts: function() {
396 - return this.extractScripts().map(function(script) { return eval(script) });
 396+ return this.extractScripts().map(function(script) { return eval(script) });
397397 },
398398
399399 escapeHTML: function() {
400 - var self = arguments.callee;
401 - self.text.data = this;
402 - return self.div.innerHTML;
 400+ var self = arguments.callee;
 401+ self.text.data = this;
 402+ return self.div.innerHTML;
403403 },
404404
405405 unescapeHTML: function() {
406 - var div = new Element('div');
407 - div.innerHTML = this.stripTags();
408 - return div.childNodes[0] ? (div.childNodes.length > 1 ?
409 - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
410 - div.childNodes[0].nodeValue) : '';
 406+ var div = new Element('div');
 407+ div.innerHTML = this.stripTags();
 408+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
 409+ $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
 410+ div.childNodes[0].nodeValue) : '';
411411 },
412412
413413 toQueryParams: function(separator) {
414 - var match = this.strip().match(/([^?#]*)(#.*)?$/);
415 - if (!match) return { };
 414+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
 415+ if (!match) return { };
416416
417 - return match[1].split(separator || '&').inject({ }, function(hash, pair) {
418 - if ((pair = pair.split('='))[0]) {
419 - var key = decodeURIComponent(pair.shift());
420 - var value = pair.length > 1 ? pair.join('=') : pair[0];
421 - if (value != undefined) value = decodeURIComponent(value);
 417+ return match[1].split(separator || '&').inject({ }, function(hash, pair) {
 418+ if ((pair = pair.split('='))[0]) {
 419+ var key = decodeURIComponent(pair.shift());
 420+ var value = pair.length > 1 ? pair.join('=') : pair[0];
 421+ if (value != undefined) value = decodeURIComponent(value);
422422
423 - if (key in hash) {
424 - if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
425 - hash[key].push(value);
426 - }
427 - else hash[key] = value;
428 - }
429 - return hash;
430 - });
 423+ if (key in hash) {
 424+ if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
 425+ hash[key].push(value);
 426+ }
 427+ else hash[key] = value;
 428+ }
 429+ return hash;
 430+ });
431431 },
432432
433433 toArray: function() {
434 - return this.split('');
 434+ return this.split('');
435435 },
436436
437437 succ: function() {
438 - return this.slice(0, this.length - 1) +
439 - String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
 438+ return this.slice(0, this.length - 1) +
 439+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
440440 },
441441
442442 times: function(count) {
443 - return count < 1 ? '' : new Array(count + 1).join(this);
 443+ return count < 1 ? '' : new Array(count + 1).join(this);
444444 },
445445
446446 camelize: function() {
447 - var parts = this.split('-'), len = parts.length;
448 - if (len == 1) return parts[0];
 447+ var parts = this.split('-'), len = parts.length;
 448+ if (len == 1) return parts[0];
449449
450 - var camelized = this.charAt(0) == '-'
451 - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
452 - : parts[0];
 450+ var camelized = this.charAt(0) == '-'
 451+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
 452+ : parts[0];
453453
454 - for (var i = 1; i < len; i++)
455 - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
 454+ for (var i = 1; i < len; i++)
 455+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
456456
457 - return camelized;
 457+ return camelized;
458458 },
459459
460460 capitalize: function() {
461 - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
 461+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
462462 },
463463
464464 underscore: function() {
465 - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
 465+ return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
466466 },
467467
468468 dasherize: function() {
469 - return this.gsub(/_/,'-');
 469+ return this.gsub(/_/,'-');
470470 },
471471
472472 inspect: function(useDoubleQuotes) {
473 - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
474 - var character = String.specialChar[match[0]];
475 - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
476 - });
477 - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
478 - return "'" + escapedString.replace(/'/g, '\\\'') + "'";
 473+ var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
 474+ var character = String.specialChar[match[0]];
 475+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
 476+ });
 477+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
 478+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
479479 },
480480
481481 toJSON: function() {
482 - return this.inspect(true);
 482+ return this.inspect(true);
483483 },
484484
485485 unfilterJSON: function(filter) {
486 - return this.sub(filter || Prototype.JSONFilter, '#{1}');
 486+ return this.sub(filter || Prototype.JSONFilter, '#{1}');
487487 },
488488
489489 isJSON: function() {
490 - var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
491 - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
 490+ var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
 491+ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
492492 },
493493
494494 evalJSON: function(sanitize) {
495 - var json = this.unfilterJSON();
496 - try {
497 - if (!sanitize || json.isJSON()) return eval('(' + json + ')');
498 - } catch (e) { }
499 - throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
 495+ var json = this.unfilterJSON();
 496+ try {
 497+ if (!sanitize || json.isJSON()) return eval('(' + json + ')');
 498+ } catch (e) { }
 499+ throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
500500 },
501501
502502 include: function(pattern) {
503 - return this.indexOf(pattern) > -1;
 503+ return this.indexOf(pattern) > -1;
504504 },
505505
506506 startsWith: function(pattern) {
507 - return this.indexOf(pattern) === 0;
 507+ return this.indexOf(pattern) === 0;
508508 },
509509
510510 endsWith: function(pattern) {
511 - var d = this.length - pattern.length;
512 - return d >= 0 && this.lastIndexOf(pattern) === d;
 511+ var d = this.length - pattern.length;
 512+ return d >= 0 && this.lastIndexOf(pattern) === d;
513513 },
514514
515515 empty: function() {
516 - return this == '';
 516+ return this == '';
517517 },
518518
519519 blank: function() {
520 - return /^\s*$/.test(this);
 520+ return /^\s*$/.test(this);
521521 },
522522
523523 interpolate: function(object, pattern) {
524 - return new Template(this, pattern).evaluate(object);
 524+ return new Template(this, pattern).evaluate(object);
525525 }
526526 });
527527
528528 if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, {
529529 escapeHTML: function() {
530 - return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
 530+ return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
531531 },
532532 unescapeHTML: function() {
533 - return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
 533+ return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
534534 }
535535 });
536536
@@ -550,34 +550,34 @@
551551
552552 var Template = Class.create({
553553 initialize: function(template, pattern) {
554 - this.template = template.toString();
555 - this.pattern = pattern || Template.Pattern;
 554+ this.template = template.toString();
 555+ this.pattern = pattern || Template.Pattern;
556556 },
557557
558558 evaluate: function(object) {
559 - if (Object.isFunction(object.toTemplateReplacements))
560 - object = object.toTemplateReplacements();
 559+ if (Object.isFunction(object.toTemplateReplacements))
 560+ object = object.toTemplateReplacements();
561561
562 - return this.template.gsub(this.pattern, function(match) {
563 - if (object == null) return '';
 562+ return this.template.gsub(this.pattern, function(match) {
 563+ if (object == null) return '';
564564
565 - var before = match[1] || '';
566 - if (before == '\\') return match[2];
 565+ var before = match[1] || '';
 566+ if (before == '\\') return match[2];
567567
568 - var ctx = object, expr = match[3];
569 - var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
570 - if (match == null) return before;
 568+ var ctx = object, expr = match[3];
 569+ var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
 570+ if (match == null) return before;
571571
572 - while (match != null) {
573 - var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
574 - ctx = ctx[comp];
575 - if (null == ctx || '' == match[3]) break;
576 - expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
577 - match = pattern.exec(expr);
578 - }
 572+ while (match != null) {
 573+ var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
 574+ ctx = ctx[comp];
 575+ if (null == ctx || '' == match[3]) break;
 576+ expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
 577+ match = pattern.exec(expr);
 578+ }
579579
580 - return before + String.interpret(ctx);
581 - }.bind(this));
 580+ return before + String.interpret(ctx);
 581+ }.bind(this));
582582 }
583583 });
584584 Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
@@ -586,221 +586,221 @@
587587
588588 var Enumerable = {
589589 each: function(iterator, context) {
590 - var index = 0;
591 - iterator = iterator.bind(context);
592 - try {
593 - this._each(function(value) {
594 - iterator(value, index++);
595 - });
596 - } catch (e) {
597 - if (e != $break) throw e;
598 - }
599 - return this;
 590+ var index = 0;
 591+ iterator = iterator.bind(context);
 592+ try {
 593+ this._each(function(value) {
 594+ iterator(value, index++);
 595+ });
 596+ } catch (e) {
 597+ if (e != $break) throw e;
 598+ }
 599+ return this;
600600 },
601601
602602 eachSlice: function(number, iterator, context) {
603 - iterator = iterator ? iterator.bind(context) : Prototype.K;
604 - var index = -number, slices = [], array = this.toArray();
605 - while ((index += number) < array.length)
606 - slices.push(array.slice(index, index+number));
607 - return slices.collect(iterator, context);
 603+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 604+ var index = -number, slices = [], array = this.toArray();
 605+ while ((index += number) < array.length)
 606+ slices.push(array.slice(index, index+number));
 607+ return slices.collect(iterator, context);
608608 },
609609
610610 all: function(iterator, context) {
611 - iterator = iterator ? iterator.bind(context) : Prototype.K;
612 - var result = true;
613 - this.each(function(value, index) {
614 - result = result && !!iterator(value, index);
615 - if (!result) throw $break;
616 - });
617 - return result;
 611+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 612+ var result = true;
 613+ this.each(function(value, index) {
 614+ result = result && !!iterator(value, index);
 615+ if (!result) throw $break;
 616+ });
 617+ return result;
618618 },
619619
620620 any: function(iterator, context) {
621 - iterator = iterator ? iterator.bind(context) : Prototype.K;
622 - var result = false;
623 - this.each(function(value, index) {
624 - if (result = !!iterator(value, index))
625 - throw $break;
626 - });
627 - return result;
 621+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 622+ var result = false;
 623+ this.each(function(value, index) {
 624+ if (result = !!iterator(value, index))
 625+ throw $break;
 626+ });
 627+ return result;
628628 },
629629
630630 collect: function(iterator, context) {
631 - iterator = iterator ? iterator.bind(context) : Prototype.K;
632 - var results = [];
633 - this.each(function(value, index) {
634 - results.push(iterator(value, index));
635 - });
636 - return results;
 631+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 632+ var results = [];
 633+ this.each(function(value, index) {
 634+ results.push(iterator(value, index));
 635+ });
 636+ return results;
637637 },
638638
639639 detect: function(iterator, context) {
640 - iterator = iterator.bind(context);
641 - var result;
642 - this.each(function(value, index) {
643 - if (iterator(value, index)) {
644 - result = value;
645 - throw $break;
646 - }
647 - });
648 - return result;
 640+ iterator = iterator.bind(context);
 641+ var result;
 642+ this.each(function(value, index) {
 643+ if (iterator(value, index)) {
 644+ result = value;
 645+ throw $break;
 646+ }
 647+ });
 648+ return result;
649649 },
650650
651651 findAll: function(iterator, context) {
652 - iterator = iterator.bind(context);
653 - var results = [];
654 - this.each(function(value, index) {
655 - if (iterator(value, index))
656 - results.push(value);
657 - });
658 - return results;
 652+ iterator = iterator.bind(context);
 653+ var results = [];
 654+ this.each(function(value, index) {
 655+ if (iterator(value, index))
 656+ results.push(value);
 657+ });
 658+ return results;
659659 },
660660
661661 grep: function(filter, iterator, context) {
662 - iterator = iterator ? iterator.bind(context) : Prototype.K;
663 - var results = [];
 662+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 663+ var results = [];
664664
665 - if (Object.isString(filter))
666 - filter = new RegExp(filter);
 665+ if (Object.isString(filter))
 666+ filter = new RegExp(filter);
667667
668 - this.each(function(value, index) {
669 - if (filter.match(value))
670 - results.push(iterator(value, index));
671 - });
672 - return results;
 668+ this.each(function(value, index) {
 669+ if (filter.match(value))
 670+ results.push(iterator(value, index));
 671+ });
 672+ return results;
673673 },
674674
675675 include: function(object) {
676 - if (Object.isFunction(this.indexOf))
677 - if (this.indexOf(object) != -1) return true;
 676+ if (Object.isFunction(this.indexOf))
 677+ if (this.indexOf(object) != -1) return true;
678678
679 - var found = false;
680 - this.each(function(value) {
681 - if (value == object) {
682 - found = true;
683 - throw $break;
684 - }
685 - });
686 - return found;
 679+ var found = false;
 680+ this.each(function(value) {
 681+ if (value == object) {
 682+ found = true;
 683+ throw $break;
 684+ }
 685+ });
 686+ return found;
687687 },
688688
689689 inGroupsOf: function(number, fillWith) {
690 - fillWith = fillWith === undefined ? null : fillWith;
691 - return this.eachSlice(number, function(slice) {
692 - while(slice.length < number) slice.push(fillWith);
693 - return slice;
694 - });
 690+ fillWith = fillWith === undefined ? null : fillWith;
 691+ return this.eachSlice(number, function(slice) {
 692+ while(slice.length < number) slice.push(fillWith);
 693+ return slice;
 694+ });
695695 },
696696
697697 inject: function(memo, iterator, context) {
698 - iterator = iterator.bind(context);
699 - this.each(function(value, index) {
700 - memo = iterator(memo, value, index);
701 - });
702 - return memo;
 698+ iterator = iterator.bind(context);
 699+ this.each(function(value, index) {
 700+ memo = iterator(memo, value, index);
 701+ });
 702+ return memo;
703703 },
704704
705705 invoke: function(method) {
706 - var args = $A(arguments).slice(1);
707 - return this.map(function(value) {
708 - return value[method].apply(value, args);
709 - });
 706+ var args = $A(arguments).slice(1);
 707+ return this.map(function(value) {
 708+ return value[method].apply(value, args);
 709+ });
710710 },
711711
712712 max: function(iterator, context) {
713 - iterator = iterator ? iterator.bind(context) : Prototype.K;
714 - var result;
715 - this.each(function(value, index) {
716 - value = iterator(value, index);
717 - if (result == undefined || value >= result)
718 - result = value;
719 - });
720 - return result;
 713+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 714+ var result;
 715+ this.each(function(value, index) {
 716+ value = iterator(value, index);
 717+ if (result == undefined || value >= result)
 718+ result = value;
 719+ });
 720+ return result;
721721 },
722722
723723 min: function(iterator, context) {
724 - iterator = iterator ? iterator.bind(context) : Prototype.K;
725 - var result;
726 - this.each(function(value, index) {
727 - value = iterator(value, index);
728 - if (result == undefined || value < result)
729 - result = value;
730 - });
731 - return result;
 724+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 725+ var result;
 726+ this.each(function(value, index) {
 727+ value = iterator(value, index);
 728+ if (result == undefined || value < result)
 729+ result = value;
 730+ });
 731+ return result;
732732 },
733733
734734 partition: function(iterator, context) {
735 - iterator = iterator ? iterator.bind(context) : Prototype.K;
736 - var trues = [], falses = [];
737 - this.each(function(value, index) {
738 - (iterator(value, index) ?
739 - trues : falses).push(value);
740 - });
741 - return [trues, falses];
 735+ iterator = iterator ? iterator.bind(context) : Prototype.K;
 736+ var trues = [], falses = [];
 737+ this.each(function(value, index) {
 738+ (iterator(value, index) ?
 739+ trues : falses).push(value);
 740+ });
 741+ return [trues, falses];
742742 },
743743
744744 pluck: function(property) {
745 - var results = [];
746 - this.each(function(value) {
747 - results.push(value[property]);
748 - });
749 - return results;
 745+ var results = [];
 746+ this.each(function(value) {
 747+ results.push(value[property]);
 748+ });
 749+ return results;
750750 },
751751
752752 reject: function(iterator, context) {
753 - iterator = iterator.bind(context);
754 - var results = [];
755 - this.each(function(value, index) {
756 - if (!iterator(value, index))
757 - results.push(value);
758 - });
759 - return results;
 753+ iterator = iterator.bind(context);
 754+ var results = [];
 755+ this.each(function(value, index) {
 756+ if (!iterator(value, index))
 757+ results.push(value);
 758+ });
 759+ return results;
760760 },
761761
762762 sortBy: function(iterator, context) {
763 - iterator = iterator.bind(context);
764 - return this.map(function(value, index) {
765 - return {value: value, criteria: iterator(value, index)};
766 - }).sort(function(left, right) {
767 - var a = left.criteria, b = right.criteria;
768 - return a < b ? -1 : a > b ? 1 : 0;
769 - }).pluck('value');
 763+ iterator = iterator.bind(context);
 764+ return this.map(function(value, index) {
 765+ return {value: value, criteria: iterator(value, index)};
 766+ }).sort(function(left, right) {
 767+ var a = left.criteria, b = right.criteria;
 768+ return a < b ? -1 : a > b ? 1 : 0;
 769+ }).pluck('value');
770770 },
771771
772772 toArray: function() {
773 - return this.map();
 773+ return this.map();
774774 },
775775
776776 zip: function() {
777 - var iterator = Prototype.K, args = $A(arguments);
778 - if (Object.isFunction(args.last()))
779 - iterator = args.pop();
 777+ var iterator = Prototype.K, args = $A(arguments);
 778+ if (Object.isFunction(args.last()))
 779+ iterator = args.pop();
780780
781 - var collections = [this].concat(args).map($A);
782 - return this.map(function(value, index) {
783 - return iterator(collections.pluck(index));
784 - });
 781+ var collections = [this].concat(args).map($A);
 782+ return this.map(function(value, index) {
 783+ return iterator(collections.pluck(index));
 784+ });
785785 },
786786
787787 size: function() {
788 - return this.toArray().length;
 788+ return this.toArray().length;
789789 },
790790
791791 inspect: function() {
792 - return '#<Enumerable:' + this.toArray().inspect() + '>';
 792+ return '#<Enumerable:' + this.toArray().inspect() + '>';
793793 }
794794 };
795795
796796 Object.extend(Enumerable, {
797 - map: Enumerable.collect,
798 - find: Enumerable.detect,
 797+ map: Enumerable.collect,
 798+ find: Enumerable.detect,
799799 select: Enumerable.findAll,
800800 filter: Enumerable.findAll,
801801 member: Enumerable.include,
802802 entries: Enumerable.toArray,
803803 every: Enumerable.all,
804 - some: Enumerable.any
 804+ some: Enumerable.any
805805 });
806806 function $A(iterable) {
807807 if (!iterable) return [];
@@ -812,12 +812,12 @@
813813
814814 if (Prototype.Browser.WebKit) {
815815 function $A(iterable) {
816 - if (!iterable) return [];
817 - if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
818 - iterable.toArray) return iterable.toArray();
819 - var length = iterable.length, results = new Array(length);
820 - while (length--) results[length] = iterable[length];
821 - return results;
 816+ if (!iterable) return [];
 817+ if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
 818+ iterable.toArray) return iterable.toArray();
 819+ var length = iterable.length, results = new Array(length);
 820+ while (length--) results[length] = iterable[length];
 821+ return results;
822822 }
823823 }
824824
@@ -829,84 +829,84 @@
830830
831831 Object.extend(Array.prototype, {
832832 _each: function(iterator) {
833 - for (var i = 0, length = this.length; i < length; i++)
834 - iterator(this[i]);
 833+ for (var i = 0, length = this.length; i < length; i++)
 834+ iterator(this[i]);
835835 },
836836
837837 clear: function() {
838 - this.length = 0;
839 - return this;
 838+ this.length = 0;
 839+ return this;
840840 },
841841
842842 first: function() {
843 - return this[0];
 843+ return this[0];
844844 },
845845
846846 last: function() {
847 - return this[this.length - 1];
 847+ return this[this.length - 1];
848848 },
849849
850850 compact: function() {
851 - return this.select(function(value) {
852 - return value != null;
853 - });
 851+ return this.select(function(value) {
 852+ return value != null;
 853+ });
854854 },
855855
856856 flatten: function() {
857 - return this.inject([], function(array, value) {
858 - return array.concat(Object.isArray(value) ?
859 - value.flatten() : [value]);
860 - });
 857+ return this.inject([], function(array, value) {
 858+ return array.concat(Object.isArray(value) ?
 859+ value.flatten() : [value]);
 860+ });
861861 },
862862
863863 without: function() {
864 - var values = $A(arguments);
865 - return this.select(function(value) {
866 - return !values.include(value);
867 - });
 864+ var values = $A(arguments);
 865+ return this.select(function(value) {
 866+ return !values.include(value);
 867+ });
868868 },
869869
870870 reverse: function(inline) {
871 - return (inline !== false ? this : this.toArray())._reverse();
 871+ return (inline !== false ? this : this.toArray())._reverse();
872872 },
873873
874874 reduce: function() {
875 - return this.length > 1 ? this : this[0];
 875+ return this.length > 1 ? this : this[0];
876876 },
877877
878878 uniq: function(sorted) {
879 - return this.inject([], function(array, value, index) {
880 - if (0 == index || (sorted ? array.last() != value : !array.include(value)))
881 - array.push(value);
882 - return array;
883 - });
 879+ return this.inject([], function(array, value, index) {
 880+ if (0 == index || (sorted ? array.last() != value : !array.include(value)))
 881+ array.push(value);
 882+ return array;
 883+ });
884884 },
885885
886886 intersect: function(array) {
887 - return this.uniq().findAll(function(item) {
888 - return array.detect(function(value) { return item === value });
889 - });
 887+ return this.uniq().findAll(function(item) {
 888+ return array.detect(function(value) { return item === value });
 889+ });
890890 },
891891
892892 clone: function() {
893 - return [].concat(this);
 893+ return [].concat(this);
894894 },
895895
896896 size: function() {
897 - return this.length;
 897+ return this.length;
898898 },
899899
900900 inspect: function() {
901 - return '[' + this.map(Object.inspect).join(', ') + ']';
 901+ return '[' + this.map(Object.inspect).join(', ') + ']';
902902 },
903903
904904 toJSON: function() {
905 - var results = [];
906 - this.each(function(object) {
907 - var value = Object.toJSON(object);
908 - if (value !== undefined) results.push(value);
909 - });
910 - return '[' + results.join(', ') + ']';
 905+ var results = [];
 906+ this.each(function(object) {
 907+ var value = Object.toJSON(object);
 908+ if (value !== undefined) results.push(value);
 909+ });
 910+ return '[' + results.join(', ') + ']';
911911 }
912912 });
913913
@@ -919,7 +919,7 @@
920920 var length = this.length;
921921 if (i < 0) i = length + i;
922922 for (; i < length; i++)
923 - if (this[i] === item) return i;
 923+ if (this[i] === item) return i;
924924 return -1;
925925 };
926926
@@ -939,40 +939,40 @@
940940
941941 if (Prototype.Browser.Opera){
942942 Array.prototype.concat = function() {
943 - var array = [];
944 - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
945 - for (var i = 0, length = arguments.length; i < length; i++) {
946 - if (Object.isArray(arguments[i])) {
947 - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
948 - array.push(arguments[i][j]);
949 - } else {
950 - array.push(arguments[i]);
951 - }
952 - }
953 - return array;
 943+ var array = [];
 944+ for (var i = 0, length = this.length; i < length; i++) array.push(this[i]);
 945+ for (var i = 0, length = arguments.length; i < length; i++) {
 946+ if (Object.isArray(arguments[i])) {
 947+ for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++)
 948+ array.push(arguments[i][j]);
 949+ } else {
 950+ array.push(arguments[i]);
 951+ }
 952+ }
 953+ return array;
954954 };
955955 }
956956 Object.extend(Number.prototype, {
957957 toColorPart: function() {
958 - return this.toPaddedString(2, 16);
 958+ return this.toPaddedString(2, 16);
959959 },
960960
961961 succ: function() {
962 - return this + 1;
 962+ return this + 1;
963963 },
964964
965965 times: function(iterator) {
966 - $R(0, this, true).each(iterator);
967 - return this;
 966+ $R(0, this, true).each(iterator);
 967+ return this;
968968 },
969969
970970 toPaddedString: function(length, radix) {
971 - var string = this.toString(radix || 10);
972 - return '0'.times(length - string.length) + string;
 971+ var string = this.toString(radix || 10);
 972+ return '0'.times(length - string.length) + string;
973973 },
974974
975975 toJSON: function() {
976 - return isFinite(this) ? this.toString() : 'null';
 976+ return isFinite(this) ? this.toString() : 'null';
977977 }
978978 });
979979
@@ -985,115 +985,115 @@
986986
987987 var Hash = Class.create(Enumerable, (function() {
988988 if (function() {
989 - var i = 0, Test = function(value) { this.key = value };
990 - Test.prototype.key = 'foo';
991 - for (var property in new Test('bar')) i++;
992 - return i > 1;
 989+ var i = 0, Test = function(value) { this.key = value };
 990+ Test.prototype.key = 'foo';
 991+ for (var property in new Test('bar')) i++;
 992+ return i > 1;
993993 }()) {
994 - function each(iterator) {
995 - var cache = [];
996 - for (var key in this._object) {
997 - var value = this._object[key];
998 - if (cache.include(key)) continue;
999 - cache.push(key);
1000 - var pair = [key, value];
1001 - pair.key = key;
1002 - pair.value = value;
1003 - iterator(pair);
1004 - }
1005 - }
 994+ function each(iterator) {
 995+ var cache = [];
 996+ for (var key in this._object) {
 997+ var value = this._object[key];
 998+ if (cache.include(key)) continue;
 999+ cache.push(key);
 1000+ var pair = [key, value];
 1001+ pair.key = key;
 1002+ pair.value = value;
 1003+ iterator(pair);
 1004+ }
 1005+ }
10061006 } else {
1007 - function each(iterator) {
1008 - for (var key in this._object) {
1009 - var value = this._object[key], pair = [key, value];
1010 - pair.key = key;
1011 - pair.value = value;
1012 - iterator(pair);
1013 - }
1014 - }
 1007+ function each(iterator) {
 1008+ for (var key in this._object) {
 1009+ var value = this._object[key], pair = [key, value];
 1010+ pair.key = key;
 1011+ pair.value = value;
 1012+ iterator(pair);
 1013+ }
 1014+ }
10151015 }
10161016
10171017 function toQueryPair(key, value) {
1018 - if (Object.isUndefined(value)) return key;
1019 - return key + '=' + encodeURIComponent(String.interpret(value));
 1018+ if (Object.isUndefined(value)) return key;
 1019+ return key + '=' + encodeURIComponent(String.interpret(value));
10201020 }
10211021
10221022 return {
1023 - initialize: function(object) {
1024 - this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
1025 - },
 1023+ initialize: function(object) {
 1024+ this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
 1025+ },
10261026
1027 - _each: each,
 1027+ _each: each,
10281028
1029 - set: function(key, value) {
1030 - return this._object[key] = value;
1031 - },
 1029+ set: function(key, value) {
 1030+ return this._object[key] = value;
 1031+ },
10321032
1033 - get: function(key) {
1034 - return this._object[key];
1035 - },
 1033+ get: function(key) {
 1034+ return this._object[key];
 1035+ },
10361036
1037 - unset: function(key) {
1038 - var value = this._object[key];
1039 - delete this._object[key];
1040 - return value;
1041 - },
 1037+ unset: function(key) {
 1038+ var value = this._object[key];
 1039+ delete this._object[key];
 1040+ return value;
 1041+ },
10421042
1043 - toObject: function() {
1044 - return Object.clone(this._object);
1045 - },
 1043+ toObject: function() {
 1044+ return Object.clone(this._object);
 1045+ },
10461046
1047 - keys: function() {
1048 - return this.pluck('key');
1049 - },
 1047+ keys: function() {
 1048+ return this.pluck('key');
 1049+ },
10501050
1051 - values: function() {
1052 - return this.pluck('value');
1053 - },
 1051+ values: function() {
 1052+ return this.pluck('value');
 1053+ },
10541054
1055 - index: function(value) {
1056 - var match = this.detect(function(pair) {
1057 - return pair.value === value;
1058 - });
1059 - return match && match.key;
1060 - },
 1055+ index: function(value) {
 1056+ var match = this.detect(function(pair) {
 1057+ return pair.value === value;
 1058+ });
 1059+ return match && match.key;
 1060+ },
10611061
1062 - merge: function(object) {
1063 - return this.clone().update(object);
1064 - },
 1062+ merge: function(object) {
 1063+ return this.clone().update(object);
 1064+ },
10651065
1066 - update: function(object) {
1067 - return new Hash(object).inject(this, function(result, pair) {
1068 - result.set(pair.key, pair.value);
1069 - return result;
1070 - });
1071 - },
 1066+ update: function(object) {
 1067+ return new Hash(object).inject(this, function(result, pair) {
 1068+ result.set(pair.key, pair.value);
 1069+ return result;
 1070+ });
 1071+ },
10721072
1073 - toQueryString: function() {
1074 - return this.map(function(pair) {
1075 - var key = encodeURIComponent(pair.key), values = pair.value;
 1073+ toQueryString: function() {
 1074+ return this.map(function(pair) {
 1075+ var key = encodeURIComponent(pair.key), values = pair.value;
10761076
1077 - if (values && typeof values == 'object') {
1078 - if (Object.isArray(values))
1079 - return values.map(toQueryPair.curry(key)).join('&');
1080 - }
1081 - return toQueryPair(key, values);
1082 - }).join('&');
1083 - },
 1077+ if (values && typeof values == 'object') {
 1078+ if (Object.isArray(values))
 1079+ return values.map(toQueryPair.curry(key)).join('&');
 1080+ }
 1081+ return toQueryPair(key, values);
 1082+ }).join('&');
 1083+ },
10841084
1085 - inspect: function() {
1086 - return '#<Hash:{' + this.map(function(pair) {
1087 - return pair.map(Object.inspect).join(': ');
1088 - }).join(', ') + '}>';
1089 - },
 1085+ inspect: function() {
 1086+ return '#<Hash:{' + this.map(function(pair) {
 1087+ return pair.map(Object.inspect).join(': ');
 1088+ }).join(', ') + '}>';
 1089+ },
10901090
1091 - toJSON: function() {
1092 - return Object.toJSON(this.toObject());
1093 - },
 1091+ toJSON: function() {
 1092+ return Object.toJSON(this.toObject());
 1093+ },
10941094
1095 - clone: function() {
1096 - return new Hash(this);
1097 - }
 1095+ clone: function() {
 1096+ return new Hash(this);
 1097+ }
10981098 }
10991099 })());
11001100
@@ -1101,25 +1101,25 @@
11021102 Hash.from = $H;
11031103 var ObjectRange = Class.create(Enumerable, {
11041104 initialize: function(start, end, exclusive) {
1105 - this.start = start;
1106 - this.end = end;
1107 - this.exclusive = exclusive;
 1105+ this.start = start;
 1106+ this.end = end;
 1107+ this.exclusive = exclusive;
11081108 },
11091109
11101110 _each: function(iterator) {
1111 - var value = this.start;
1112 - while (this.include(value)) {
1113 - iterator(value);
1114 - value = value.succ();
1115 - }
 1111+ var value = this.start;
 1112+ while (this.include(value)) {
 1113+ iterator(value);
 1114+ value = value.succ();
 1115+ }
11161116 },
11171117
11181118 include: function(value) {
1119 - if (value < this.start)
1120 - return false;
1121 - if (this.exclusive)
1122 - return value < this.end;
1123 - return value <= this.end;
 1119+ if (value < this.start)
 1120+ return false;
 1121+ if (this.exclusive)
 1122+ return value < this.end;
 1123+ return value <= this.end;
11241124 }
11251125 });
11261126
@@ -1129,11 +1129,11 @@
11301130
11311131 var Ajax = {
11321132 getTransport: function() {
1133 - return Try.these(
1134 - function() {return new XMLHttpRequest()},
1135 - function() {return new ActiveXObject('Msxml2.XMLHTTP')},
1136 - function() {return new ActiveXObject('Microsoft.XMLHTTP')}
1137 - ) || false;
 1133+ return Try.these(
 1134+ function() {return new XMLHttpRequest()},
 1135+ function() {return new ActiveXObject('Msxml2.XMLHTTP')},
 1136+ function() {return new ActiveXObject('Microsoft.XMLHTTP')}
 1137+ ) || false;
11381138 },
11391139
11401140 activeRequestCount: 0
@@ -1143,26 +1143,26 @@
11441144 responders: [],
11451145
11461146 _each: function(iterator) {
1147 - this.responders._each(iterator);
 1147+ this.responders._each(iterator);
11481148 },
11491149
11501150 register: function(responder) {
1151 - if (!this.include(responder))
1152 - this.responders.push(responder);
 1151+ if (!this.include(responder))
 1152+ this.responders.push(responder);
11531153 },
11541154
11551155 unregister: function(responder) {
1156 - this.responders = this.responders.without(responder);
 1156+ this.responders = this.responders.without(responder);
11571157 },
11581158
11591159 dispatch: function(callback, request, transport, json) {
1160 - this.each(function(responder) {
1161 - if (Object.isFunction(responder[callback])) {
1162 - try {
1163 - responder[callback].apply(responder, [request, transport, json]);
1164 - } catch (e) { }
1165 - }
1166 - });
 1160+ this.each(function(responder) {
 1161+ if (Object.isFunction(responder[callback])) {
 1162+ try {
 1163+ responder[callback].apply(responder, [request, transport, json]);
 1164+ } catch (e) { }
 1165+ }
 1166+ });
11671167 }
11681168 };
11691169
@@ -1175,20 +1175,20 @@
11761176
11771177 Ajax.Base = Class.create({
11781178 initialize: function(options) {
1179 - this.options = {
1180 - method: 'post',
1181 - asynchronous: true,
1182 - contentType: 'application/x-www-form-urlencoded',
1183 - encoding: 'UTF-8',
1184 - parameters: '',
1185 - evalJSON: true,
1186 - evalJS: true
1187 - };
1188 - Object.extend(this.options, options || { });
 1179+ this.options = {
 1180+ method: 'post',
 1181+ asynchronous: true,
 1182+ contentType: 'application/x-www-form-urlencoded',
 1183+ encoding: 'UTF-8',
 1184+ parameters: '',
 1185+ evalJSON: true,
 1186+ evalJS: true
 1187+ };
 1188+ Object.extend(this.options, options || { });
11891189
1190 - this.options.method = this.options.method.toLowerCase();
1191 - if (Object.isString(this.options.parameters))
1192 - this.options.parameters = this.options.parameters.toQueryParams();
 1190+ this.options.method = this.options.method.toLowerCase();
 1191+ if (Object.isString(this.options.parameters))
 1192+ this.options.parameters = this.options.parameters.toQueryParams();
11931193 }
11941194 });
11951195
@@ -1196,160 +1196,160 @@
11971197 _complete: false,
11981198
11991199 initialize: function($super, url, options) {
1200 - $super(options);
1201 - this.transport = Ajax.getTransport();
1202 - this.request(url);
 1200+ $super(options);
 1201+ this.transport = Ajax.getTransport();
 1202+ this.request(url);
12031203 },
12041204
12051205 request: function(url) {
1206 - this.url = url;
1207 - this.method = this.options.method;
1208 - var params = Object.clone(this.options.parameters);
 1206+ this.url = url;
 1207+ this.method = this.options.method;
 1208+ var params = Object.clone(this.options.parameters);
12091209
1210 - if (!['get', 'post'].include(this.method)) {
1211 - // simulate other verbs over post
1212 - params['_method'] = this.method;
1213 - this.method = 'post';
1214 - }
 1210+ if (!['get', 'post'].include(this.method)) {
 1211+ // simulate other verbs over post
 1212+ params['_method'] = this.method;
 1213+ this.method = 'post';
 1214+ }
12151215
1216 - this.parameters = params;
 1216+ this.parameters = params;
12171217
1218 - if (params = Object.toQueryString(params)) {
1219 - // when GET, append parameters to URL
1220 - if (this.method == 'get')
1221 - this.url += (this.url.include('?') ? '&' : '?') + params;
1222 - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
1223 - params += '&_=';
1224 - }
 1218+ if (params = Object.toQueryString(params)) {
 1219+ // when GET, append parameters to URL
 1220+ if (this.method == 'get')
 1221+ this.url += (this.url.include('?') ? '&' : '?') + params;
 1222+ else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent))
 1223+ params += '&_=';
 1224+ }
12251225
1226 - try {
1227 - var response = new Ajax.Response(this);
1228 - if (this.options.onCreate) this.options.onCreate(response);
1229 - Ajax.Responders.dispatch('onCreate', this, response);
 1226+ try {
 1227+ var response = new Ajax.Response(this);
 1228+ if (this.options.onCreate) this.options.onCreate(response);
 1229+ Ajax.Responders.dispatch('onCreate', this, response);
12301230
1231 - this.transport.open(this.method.toUpperCase(), this.url,
1232 - this.options.asynchronous);
 1231+ this.transport.open(this.method.toUpperCase(), this.url,
 1232+ this.options.asynchronous);
12331233
1234 - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
 1234+ if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);
12351235
1236 - this.transport.onreadystatechange = this.onStateChange.bind(this);
1237 - this.setRequestHeaders();
 1236+ this.transport.onreadystatechange = this.onStateChange.bind(this);
 1237+ this.setRequestHeaders();
12381238
1239 - this.body = this.method == 'post' ? (this.options.postBody || params) : null;
1240 - this.transport.send(this.body);
 1239+ this.body = this.method == 'post' ? (this.options.postBody || params) : null;
 1240+ this.transport.send(this.body);
12411241
1242 - /* Force Firefox to handle ready state 4 for synchronous requests */
1243 - if (!this.options.asynchronous && this.transport.overrideMimeType)
1244 - this.onStateChange();
 1242+ /* Force Firefox to handle ready state 4 for synchronous requests */
 1243+ if (!this.options.asynchronous && this.transport.overrideMimeType)
 1244+ this.onStateChange();
12451245
1246 - }
1247 - catch (e) {
1248 - this.dispatchException(e);
1249 - }
 1246+ }
 1247+ catch (e) {
 1248+ this.dispatchException(e);
 1249+ }
12501250 },
12511251
12521252 onStateChange: function() {
1253 - var readyState = this.transport.readyState;
1254 - if (readyState > 1 && !((readyState == 4) && this._complete))
1255 - this.respondToReadyState(this.transport.readyState);
 1253+ var readyState = this.transport.readyState;
 1254+ if (readyState > 1 && !((readyState == 4) && this._complete))
 1255+ this.respondToReadyState(this.transport.readyState);
12561256 },
12571257
12581258 setRequestHeaders: function() {
1259 - var headers = {
1260 - 'X-Requested-With': 'XMLHttpRequest',
1261 - 'X-Prototype-Version': Prototype.Version,
1262 - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
1263 - };
 1259+ var headers = {
 1260+ 'X-Requested-With': 'XMLHttpRequest',
 1261+ 'X-Prototype-Version': Prototype.Version,
 1262+ 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
 1263+ };
12641264
1265 - if (this.method == 'post') {
1266 - headers['Content-type'] = this.options.contentType +
1267 - (this.options.encoding ? '; charset=' + this.options.encoding : '');
 1265+ if (this.method == 'post') {
 1266+ headers['Content-type'] = this.options.contentType +
 1267+ (this.options.encoding ? '; charset=' + this.options.encoding : '');
12681268
1269 - /* Force "Connection: close" for older Mozilla browsers to work
1270 - * around a bug where XMLHttpRequest sends an incorrect
1271 - * Content-length header. See Mozilla Bugzilla #246651.
1272 - */
1273 - if (this.transport.overrideMimeType &&
1274 - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
1275 - headers['Connection'] = 'close';
1276 - }
 1269+ /* Force "Connection: close" for older Mozilla browsers to work
 1270+ * around a bug where XMLHttpRequest sends an incorrect
 1271+ * Content-length header. See Mozilla Bugzilla #246651.
 1272+ */
 1273+ if (this.transport.overrideMimeType &&
 1274+ (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
 1275+ headers['Connection'] = 'close';
 1276+ }
12771277
1278 - // user-defined headers
1279 - if (typeof this.options.requestHeaders == 'object') {
1280 - var extras = this.options.requestHeaders;
 1278+ // user-defined headers
 1279+ if (typeof this.options.requestHeaders == 'object') {
 1280+ var extras = this.options.requestHeaders;
12811281
1282 - if (Object.isFunction(extras.push))
1283 - for (var i = 0, length = extras.length; i < length; i += 2)
1284 - headers[extras[i]] = extras[i+1];
1285 - else
1286 - $H(extras).each(function(pair) { headers[pair.key] = pair.value });
1287 - }
 1282+ if (Object.isFunction(extras.push))
 1283+ for (var i = 0, length = extras.length; i < length; i += 2)
 1284+ headers[extras[i]] = extras[i+1];
 1285+ else
 1286+ $H(extras).each(function(pair) { headers[pair.key] = pair.value });
 1287+ }
12881288
1289 - for (var name in headers)
1290 - this.transport.setRequestHeader(name, headers[name]);
 1289+ for (var name in headers)
 1290+ this.transport.setRequestHeader(name, headers[name]);
12911291 },
12921292
12931293 success: function() {
1294 - var status = this.getStatus();
1295 - return !status || (status >= 200 && status < 300);
 1294+ var status = this.getStatus();
 1295+ return !status || (status >= 200 && status < 300);
12961296 },
12971297
12981298 getStatus: function() {
1299 - try {
1300 - return this.transport.status || 0;
1301 - } catch (e) { return 0 }
 1299+ try {
 1300+ return this.transport.status || 0;
 1301+ } catch (e) { return 0 }
13021302 },
13031303
13041304 respondToReadyState: function(readyState) {
1305 - var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
 1305+ var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this);
13061306
1307 - if (state == 'Complete') {
1308 - try {
1309 - this._complete = true;
1310 - (this.options['on' + response.status]
1311 - || this.options['on' + (this.success() ? 'Success' : 'Failure')]
1312 - || Prototype.emptyFunction)(response, response.headerJSON);
1313 - } catch (e) {
1314 - this.dispatchException(e);
1315 - }
 1307+ if (state == 'Complete') {
 1308+ try {
 1309+ this._complete = true;
 1310+ (this.options['on' + response.status]
 1311+ || this.options['on' + (this.success() ? 'Success' : 'Failure')]
 1312+ || Prototype.emptyFunction)(response, response.headerJSON);
 1313+ } catch (e) {
 1314+ this.dispatchException(e);
 1315+ }
13161316
1317 - var contentType = response.getHeader('Content-type');
1318 - if (this.options.evalJS == 'force'
1319 - || (this.options.evalJS && contentType
1320 - && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
1321 - this.evalResponse();
1322 - }
 1317+ var contentType = response.getHeader('Content-type');
 1318+ if (this.options.evalJS == 'force'
 1319+ || (this.options.evalJS && contentType
 1320+ && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
 1321+ this.evalResponse();
 1322+ }
13231323
1324 - try {
1325 - (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
1326 - Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
1327 - } catch (e) {
1328 - this.dispatchException(e);
1329 - }
 1324+ try {
 1325+ (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON);
 1326+ Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON);
 1327+ } catch (e) {
 1328+ this.dispatchException(e);
 1329+ }
13301330
1331 - if (state == 'Complete') {
1332 - // avoid memory leak in MSIE: clean up
1333 - this.transport.onreadystatechange = Prototype.emptyFunction;
1334 - }
 1331+ if (state == 'Complete') {
 1332+ // avoid memory leak in MSIE: clean up
 1333+ this.transport.onreadystatechange = Prototype.emptyFunction;
 1334+ }
13351335 },
13361336
13371337 getHeader: function(name) {
1338 - try {
1339 - return this.transport.getResponseHeader(name);
1340 - } catch (e) { return null }
 1338+ try {
 1339+ return this.transport.getResponseHeader(name);
 1340+ } catch (e) { return null }
13411341 },
13421342
13431343 evalResponse: function() {
1344 - try {
1345 - return eval((this.transport.responseText || '').unfilterJSON());
1346 - } catch (e) {
1347 - this.dispatchException(e);
1348 - }
 1344+ try {
 1345+ return eval((this.transport.responseText || '').unfilterJSON());
 1346+ } catch (e) {
 1347+ this.dispatchException(e);
 1348+ }
13491349 },
13501350
13511351 dispatchException: function(exception) {
1352 - (this.options.onException || Prototype.emptyFunction)(this, exception);
1353 - Ajax.Responders.dispatch('onException', this, exception);
 1352+ (this.options.onException || Prototype.emptyFunction)(this, exception);
 1353+ Ajax.Responders.dispatch('onException', this, exception);
13541354 }
13551355 });
13561356
@@ -1358,174 +1358,174 @@
13591359
13601360 Ajax.Response = Class.create({
13611361 initialize: function(request){
1362 - this.request = request;
1363 - var transport = this.transport = request.transport,
1364 - readyState = this.readyState = transport.readyState;
 1362+ this.request = request;
 1363+ var transport = this.transport = request.transport,
 1364+ readyState = this.readyState = transport.readyState;
13651365
1366 - if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
1367 - this.status = this.getStatus();
1368 - this.statusText = this.getStatusText();
1369 - this.responseText = String.interpret(transport.responseText);
1370 - this.headerJSON = this._getHeaderJSON();
1371 - }
 1366+ if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) {
 1367+ this.status = this.getStatus();
 1368+ this.statusText = this.getStatusText();
 1369+ this.responseText = String.interpret(transport.responseText);
 1370+ this.headerJSON = this._getHeaderJSON();
 1371+ }
13721372
1373 - if(readyState == 4) {
1374 - var xml = transport.responseXML;
1375 - this.responseXML = xml === undefined ? null : xml;
1376 - this.responseJSON = this._getResponseJSON();
1377 - }
 1373+ if(readyState == 4) {
 1374+ var xml = transport.responseXML;
 1375+ this.responseXML = xml === undefined ? null : xml;
 1376+ this.responseJSON = this._getResponseJSON();
 1377+ }
13781378 },
13791379
1380 - status: 0,
 1380+ status: 0,
13811381 statusText: '',
13821382
13831383 getStatus: Ajax.Request.prototype.getStatus,
13841384
13851385 getStatusText: function() {
1386 - try {
1387 - return this.transport.statusText || '';
1388 - } catch (e) { return '' }
 1386+ try {
 1387+ return this.transport.statusText || '';
 1388+ } catch (e) { return '' }
13891389 },
13901390
13911391 getHeader: Ajax.Request.prototype.getHeader,
13921392
13931393 getAllHeaders: function() {
1394 - try {
1395 - return this.getAllResponseHeaders();
1396 - } catch (e) { return null }
 1394+ try {
 1395+ return this.getAllResponseHeaders();
 1396+ } catch (e) { return null }
13971397 },
13981398
13991399 getResponseHeader: function(name) {
1400 - return this.transport.getResponseHeader(name);
 1400+ return this.transport.getResponseHeader(name);
14011401 },
14021402
14031403 getAllResponseHeaders: function() {
1404 - return this.transport.getAllResponseHeaders();
 1404+ return this.transport.getAllResponseHeaders();
14051405 },
14061406
14071407 _getHeaderJSON: function() {
1408 - var json = this.getHeader('X-JSON');
1409 - if (!json) return null;
1410 - json = decodeURIComponent(escape(json));
1411 - try {
1412 - return json.evalJSON(this.request.options.sanitizeJSON);
1413 - } catch (e) {
1414 - this.request.dispatchException(e);
1415 - }
 1408+ var json = this.getHeader('X-JSON');
 1409+ if (!json) return null;
 1410+ json = decodeURIComponent(escape(json));
 1411+ try {
 1412+ return json.evalJSON(this.request.options.sanitizeJSON);
 1413+ } catch (e) {
 1414+ this.request.dispatchException(e);
 1415+ }
14161416 },
14171417
14181418 _getResponseJSON: function() {
1419 - var options = this.request.options;
1420 - if (!options.evalJSON || (options.evalJSON != 'force' &&
1421 - !(this.getHeader('Content-type') || '').include('application/json')))
1422 - return null;
1423 - try {
1424 - return this.transport.responseText.evalJSON(options.sanitizeJSON);
1425 - } catch (e) {
1426 - this.request.dispatchException(e);
1427 - }
 1419+ var options = this.request.options;
 1420+ if (!options.evalJSON || (options.evalJSON != 'force' &&
 1421+ !(this.getHeader('Content-type') || '').include('application/json')))
 1422+ return null;
 1423+ try {
 1424+ return this.transport.responseText.evalJSON(options.sanitizeJSON);
 1425+ } catch (e) {
 1426+ this.request.dispatchException(e);
 1427+ }
14281428 }
14291429 });
14301430
14311431 Ajax.Updater = Class.create(Ajax.Request, {
14321432 initialize: function($super, container, url, options) {
1433 - this.container = {
1434 - success: (container.success || container),
1435 - failure: (container.failure || (container.success ? null : container))
1436 - };
 1433+ this.container = {
 1434+ success: (container.success || container),
 1435+ failure: (container.failure || (container.success ? null : container))
 1436+ };
14371437
1438 - options = options || { };
1439 - var onComplete = options.onComplete;
1440 - options.onComplete = (function(response, param) {
1441 - this.updateContent(response.responseText);
1442 - if (Object.isFunction(onComplete)) onComplete(response, param);
1443 - }).bind(this);
 1438+ options = options || { };
 1439+ var onComplete = options.onComplete;
 1440+ options.onComplete = (function(response, param) {
 1441+ this.updateContent(response.responseText);
 1442+ if (Object.isFunction(onComplete)) onComplete(response, param);
 1443+ }).bind(this);
14441444
1445 - $super(url, options);
 1445+ $super(url, options);
14461446 },
14471447
14481448 updateContent: function(responseText) {
1449 - var receiver = this.container[this.success() ? 'success' : 'failure'],
1450 - options = this.options;
 1449+ var receiver = this.container[this.success() ? 'success' : 'failure'],
 1450+ options = this.options;
14511451
1452 - if (!options.evalScripts) responseText = responseText.stripScripts();
 1452+ if (!options.evalScripts) responseText = responseText.stripScripts();
14531453
1454 - if (receiver = $(receiver)) {
1455 - if (options.insertion) {
1456 - if (Object.isString(options.insertion)) {
1457 - var insertion = { }; insertion[options.insertion] = responseText;
1458 - receiver.insert(insertion);
1459 - }
1460 - else options.insertion(receiver, responseText);
1461 - }
1462 - else receiver.update(responseText);
1463 - }
 1454+ if (receiver = $(receiver)) {
 1455+ if (options.insertion) {
 1456+ if (Object.isString(options.insertion)) {
 1457+ var insertion = { }; insertion[options.insertion] = responseText;
 1458+ receiver.insert(insertion);
 1459+ }
 1460+ else options.insertion(receiver, responseText);
 1461+ }
 1462+ else receiver.update(responseText);
 1463+ }
14641464
1465 - if (this.success()) {
1466 - if (this.onComplete) this.onComplete.bind(this).defer();
1467 - }
 1465+ if (this.success()) {
 1466+ if (this.onComplete) this.onComplete.bind(this).defer();
 1467+ }
14681468 }
14691469 });
14701470
14711471 Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
14721472 initialize: function($super, container, url, options) {
1473 - $super(options);
1474 - this.onComplete = this.options.onComplete;
 1473+ $super(options);
 1474+ this.onComplete = this.options.onComplete;
14751475
1476 - this.frequency = (this.options.frequency || 2);
1477 - this.decay = (this.options.decay || 1);
 1476+ this.frequency = (this.options.frequency || 2);
 1477+ this.decay = (this.options.decay || 1);
14781478
1479 - this.updater = { };
1480 - this.container = container;
1481 - this.url = url;
 1479+ this.updater = { };
 1480+ this.container = container;
 1481+ this.url = url;
14821482
1483 - this.start();
 1483+ this.start();
14841484 },
14851485
14861486 start: function() {
1487 - this.options.onComplete = this.updateComplete.bind(this);
1488 - this.onTimerEvent();
 1487+ this.options.onComplete = this.updateComplete.bind(this);
 1488+ this.onTimerEvent();
14891489 },
14901490
14911491 stop: function() {
1492 - this.updater.options.onComplete = undefined;
1493 - clearTimeout(this.timer);
1494 - (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
 1492+ this.updater.options.onComplete = undefined;
 1493+ clearTimeout(this.timer);
 1494+ (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
14951495 },
14961496
14971497 updateComplete: function(response) {
1498 - if (this.options.decay) {
1499 - this.decay = (response.responseText == this.lastText ?
1500 - this.decay * this.options.decay : 1);
 1498+ if (this.options.decay) {
 1499+ this.decay = (response.responseText == this.lastText ?
 1500+ this.decay * this.options.decay : 1);
15011501
1502 - this.lastText = response.responseText;
1503 - }
1504 - this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
 1502+ this.lastText = response.responseText;
 1503+ }
 1504+ this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
15051505 },
15061506
15071507 onTimerEvent: function() {
1508 - this.updater = new Ajax.Updater(this.container, this.url, this.options);
 1508+ this.updater = new Ajax.Updater(this.container, this.url, this.options);
15091509 }
15101510 });
15111511 function $(element) {
15121512 if (arguments.length > 1) {
1513 - for (var i = 0, elements = [], length = arguments.length; i < length; i++)
1514 - elements.push($(arguments[i]));
1515 - return elements;
 1513+ for (var i = 0, elements = [], length = arguments.length; i < length; i++)
 1514+ elements.push($(arguments[i]));
 1515+ return elements;
15161516 }
15171517 if (Object.isString(element))
1518 - element = document.getElementById(element);
 1518+ element = document.getElementById(element);
15191519 return Element.extend(element);
15201520 }
15211521
15221522 if (Prototype.BrowserFeatures.XPath) {
15231523 document._getElementsByXPath = function(expression, parentElement) {
1524 - var results = [];
1525 - var query = document.evaluate(expression, $(parentElement) || document,
1526 - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
1527 - for (var i = 0, length = query.snapshotLength; i < length; i++)
1528 - results.push(Element.extend(query.snapshotItem(i)));
1529 - return results;
 1524+ var results = [];
 1525+ var query = document.evaluate(expression, $(parentElement) || document,
 1526+ null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
 1527+ for (var i = 0, length = query.snapshotLength; i < length; i++)
 1528+ results.push(Element.extend(query.snapshotItem(i)));
 1529+ return results;
15301530 };
15311531 }
15321532
@@ -1536,34 +1536,34 @@
15371537 if (!Node.ELEMENT_NODE) {
15381538 // DOM level 2 ECMAScript Language Binding
15391539 Object.extend(Node, {
1540 - ELEMENT_NODE: 1,
1541 - ATTRIBUTE_NODE: 2,
1542 - TEXT_NODE: 3,
1543 - CDATA_SECTION_NODE: 4,
1544 - ENTITY_REFERENCE_NODE: 5,
1545 - ENTITY_NODE: 6,
1546 - PROCESSING_INSTRUCTION_NODE: 7,
1547 - COMMENT_NODE: 8,
1548 - DOCUMENT_NODE: 9,
1549 - DOCUMENT_TYPE_NODE: 10,
1550 - DOCUMENT_FRAGMENT_NODE: 11,
1551 - NOTATION_NODE: 12
 1540+ ELEMENT_NODE: 1,
 1541+ ATTRIBUTE_NODE: 2,
 1542+ TEXT_NODE: 3,
 1543+ CDATA_SECTION_NODE: 4,
 1544+ ENTITY_REFERENCE_NODE: 5,
 1545+ ENTITY_NODE: 6,
 1546+ PROCESSING_INSTRUCTION_NODE: 7,
 1547+ COMMENT_NODE: 8,
 1548+ DOCUMENT_NODE: 9,
 1549+ DOCUMENT_TYPE_NODE: 10,
 1550+ DOCUMENT_FRAGMENT_NODE: 11,
 1551+ NOTATION_NODE: 12
15521552 });
15531553 }
15541554
15551555 (function() {
15561556 var element = this.Element;
15571557 this.Element = function(tagName, attributes) {
1558 - attributes = attributes || { };
1559 - tagName = tagName.toLowerCase();
1560 - var cache = Element.cache;
1561 - if (Prototype.Browser.IE && attributes.name) {
1562 - tagName = '<' + tagName + ' name="' + attributes.name + '">';
1563 - delete attributes.name;
1564 - return Element.writeAttribute(document.createElement(tagName), attributes);
1565 - }
1566 - if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
1567 - return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
 1558+ attributes = attributes || { };
 1559+ tagName = tagName.toLowerCase();
 1560+ var cache = Element.cache;
 1561+ if (Prototype.Browser.IE && attributes.name) {
 1562+ tagName = '<' + tagName + ' name="' + attributes.name + '">';
 1563+ delete attributes.name;
 1564+ return Element.writeAttribute(document.createElement(tagName), attributes);
 1565+ }
 1566+ if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
 1567+ return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);
15681568 };
15691569 Object.extend(this.Element, element || { });
15701570 }).call(window);
@@ -1572,585 +1572,585 @@
15731573
15741574 Element.Methods = {
15751575 visible: function(element) {
1576 - return $(element).style.display != 'none';
 1576+ return $(element).style.display != 'none';
15771577 },
15781578
15791579 toggle: function(element) {
1580 - element = $(element);
1581 - Element[Element.visible(element) ? 'hide' : 'show'](element);
1582 - return element;
 1580+ element = $(element);
 1581+ Element[Element.visible(element) ? 'hide' : 'show'](element);
 1582+ return element;
15831583 },
15841584
15851585 hide: function(element) {
1586 - $(element).style.display = 'none';
1587 - return element;
 1586+ $(element).style.display = 'none';
 1587+ return element;
15881588 },
15891589
15901590 show: function(element) {
1591 - $(element).style.display = '';
1592 - return element;
 1591+ $(element).style.display = '';
 1592+ return element;
15931593 },
15941594
15951595 remove: function(element) {
1596 - element = $(element);
1597 - element.parentNode.removeChild(element);
1598 - return element;
 1596+ element = $(element);
 1597+ element.parentNode.removeChild(element);
 1598+ return element;
15991599 },
16001600
16011601 update: function(element, content) {
1602 - element = $(element);
1603 - if (content && content.toElement) content = content.toElement();
1604 - if (Object.isElement(content)) return element.update().insert(content);
1605 - content = Object.toHTML(content);
1606 - element.innerHTML = content.stripScripts();
1607 - content.evalScripts.bind(content).defer();
1608 - return element;
 1602+ element = $(element);
 1603+ if (content && content.toElement) content = content.toElement();
 1604+ if (Object.isElement(content)) return element.update().insert(content);
 1605+ content = Object.toHTML(content);
 1606+ element.innerHTML = content.stripScripts();
 1607+ content.evalScripts.bind(content).defer();
 1608+ return element;
16091609 },
16101610
16111611 replace: function(element, content) {
1612 - element = $(element);
1613 - if (content && content.toElement) content = content.toElement();
1614 - else if (!Object.isElement(content)) {
1615 - content = Object.toHTML(content);
1616 - var range = element.ownerDocument.createRange();
1617 - range.selectNode(element);
1618 - content.evalScripts.bind(content).defer();
1619 - content = range.createContextualFragment(content.stripScripts());
1620 - }
1621 - element.parentNode.replaceChild(content, element);
1622 - return element;
 1612+ element = $(element);
 1613+ if (content && content.toElement) content = content.toElement();
 1614+ else if (!Object.isElement(content)) {
 1615+ content = Object.toHTML(content);
 1616+ var range = element.ownerDocument.createRange();
 1617+ range.selectNode(element);
 1618+ content.evalScripts.bind(content).defer();
 1619+ content = range.createContextualFragment(content.stripScripts());
 1620+ }
 1621+ element.parentNode.replaceChild(content, element);
 1622+ return element;
16231623 },
16241624
16251625 insert: function(element, insertions) {
1626 - element = $(element);
 1626+ element = $(element);
16271627
1628 - if (Object.isString(insertions) || Object.isNumber(insertions) ||
1629 - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
1630 - insertions = {bottom:insertions};
 1628+ if (Object.isString(insertions) || Object.isNumber(insertions) ||
 1629+ Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
 1630+ insertions = {bottom:insertions};
16311631
1632 - var content, t, range;
 1632+ var content, t, range;
16331633
1634 - for (position in insertions) {
1635 - content = insertions[position];
1636 - position = position.toLowerCase();
1637 - t = Element._insertionTranslations[position];
 1634+ for (position in insertions) {
 1635+ content = insertions[position];
 1636+ position = position.toLowerCase();
 1637+ t = Element._insertionTranslations[position];
16381638
1639 - if (content && content.toElement) content = content.toElement();
1640 - if (Object.isElement(content)) {
1641 - t.insert(element, content);
1642 - continue;
1643 - }
 1639+ if (content && content.toElement) content = content.toElement();
 1640+ if (Object.isElement(content)) {
 1641+ t.insert(element, content);
 1642+ continue;
 1643+ }
16441644
1645 - content = Object.toHTML(content);
 1645+ content = Object.toHTML(content);
16461646
1647 - range = element.ownerDocument.createRange();
1648 - t.initializeRange(element, range);
1649 - t.insert(element, range.createContextualFragment(content.stripScripts()));
 1647+ range = element.ownerDocument.createRange();
 1648+ t.initializeRange(element, range);
 1649+ t.insert(element, range.createContextualFragment(content.stripScripts()));
16501650
1651 - content.evalScripts.bind(content).defer();
1652 - }
 1651+ content.evalScripts.bind(content).defer();
 1652+ }
16531653
1654 - return element;
 1654+ return element;
16551655 },
16561656
16571657 wrap: function(element, wrapper, attributes) {
1658 - element = $(element);
1659 - if (Object.isElement(wrapper))
1660 - $(wrapper).writeAttribute(attributes || { });
1661 - else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
1662 - else wrapper = new Element('div', wrapper);
1663 - if (element.parentNode)
1664 - element.parentNode.replaceChild(wrapper, element);
1665 - wrapper.appendChild(element);
1666 - return wrapper;
 1658+ element = $(element);
 1659+ if (Object.isElement(wrapper))
 1660+ $(wrapper).writeAttribute(attributes || { });
 1661+ else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes);
 1662+ else wrapper = new Element('div', wrapper);
 1663+ if (element.parentNode)
 1664+ element.parentNode.replaceChild(wrapper, element);
 1665+ wrapper.appendChild(element);
 1666+ return wrapper;
16671667 },
16681668
16691669 inspect: function(element) {
1670 - element = $(element);
1671 - var result = '<' + element.tagName.toLowerCase();
1672 - $H({'id': 'id', 'className': 'class'}).each(function(pair) {
1673 - var property = pair.first(), attribute = pair.last();
1674 - var value = (element[property] || '').toString();
1675 - if (value) result += ' ' + attribute + '=' + value.inspect(true);
1676 - });
1677 - return result + '>';
 1670+ element = $(element);
 1671+ var result = '<' + element.tagName.toLowerCase();
 1672+ $H({'id': 'id', 'className': 'class'}).each(function(pair) {
 1673+ var property = pair.first(), attribute = pair.last();
 1674+ var value = (element[property] || '').toString();
 1675+ if (value) result += ' ' + attribute + '=' + value.inspect(true);
 1676+ });
 1677+ return result + '>';
16781678 },
16791679
16801680 recursivelyCollect: function(element, property) {
1681 - element = $(element);
1682 - var elements = [];
1683 - while (element = element[property])
1684 - if (element.nodeType == 1)
1685 - elements.push(Element.extend(element));
1686 - return elements;
 1681+ element = $(element);
 1682+ var elements = [];
 1683+ while (element = element[property])
 1684+ if (element.nodeType == 1)
 1685+ elements.push(Element.extend(element));
 1686+ return elements;
16871687 },
16881688
16891689 ancestors: function(element) {
1690 - return $(element).recursivelyCollect('parentNode');
 1690+ return $(element).recursivelyCollect('parentNode');
16911691 },
16921692
16931693 descendants: function(element) {
1694 - return $A($(element).getElementsByTagName('*')).each(Element.extend);
 1694+ return $A($(element).getElementsByTagName('*')).each(Element.extend);
16951695 },
16961696
16971697 firstDescendant: function(element) {
1698 - element = $(element).firstChild;
1699 - while (element && element.nodeType != 1) element = element.nextSibling;
1700 - return $(element);
 1698+ element = $(element).firstChild;
 1699+ while (element && element.nodeType != 1) element = element.nextSibling;
 1700+ return $(element);
17011701 },
17021702
17031703 immediateDescendants: function(element) {
1704 - if (!(element = $(element).firstChild)) return [];
1705 - while (element && element.nodeType != 1) element = element.nextSibling;
1706 - if (element) return [element].concat($(element).nextSiblings());
1707 - return [];
 1704+ if (!(element = $(element).firstChild)) return [];
 1705+ while (element && element.nodeType != 1) element = element.nextSibling;
 1706+ if (element) return [element].concat($(element).nextSiblings());
 1707+ return [];
17081708 },
17091709
17101710 previousSiblings: function(element) {
1711 - return $(element).recursivelyCollect('previousSibling');
 1711+ return $(element).recursivelyCollect('previousSibling');
17121712 },
17131713
17141714 nextSiblings: function(element) {
1715 - return $(element).recursivelyCollect('nextSibling');
 1715+ return $(element).recursivelyCollect('nextSibling');
17161716 },
17171717
17181718 siblings: function(element) {
1719 - element = $(element);
1720 - return element.previousSiblings().reverse().concat(element.nextSiblings());
 1719+ element = $(element);
 1720+ return element.previousSiblings().reverse().concat(element.nextSiblings());
17211721 },
17221722
17231723 match: function(element, selector) {
1724 - if (Object.isString(selector))
1725 - selector = new Selector(selector);
1726 - return selector.match($(element));
 1724+ if (Object.isString(selector))
 1725+ selector = new Selector(selector);
 1726+ return selector.match($(element));
17271727 },
17281728
17291729 up: function(element, expression, index) {
1730 - element = $(element);
1731 - if (arguments.length == 1) return $(element.parentNode);
1732 - var ancestors = element.ancestors();
1733 - return expression ? Selector.findElement(ancestors, expression, index) :
1734 - ancestors[index || 0];
 1730+ element = $(element);
 1731+ if (arguments.length == 1) return $(element.parentNode);
 1732+ var ancestors = element.ancestors();
 1733+ return expression ? Selector.findElement(ancestors, expression, index) :
 1734+ ancestors[index || 0];
17351735 },
17361736
17371737 down: function(element, expression, index) {
1738 - element = $(element);
1739 - if (arguments.length == 1) return element.firstDescendant();
1740 - var descendants = element.descendants();
1741 - return expression ? Selector.findElement(descendants, expression, index) :
1742 - descendants[index || 0];
 1738+ element = $(element);
 1739+ if (arguments.length == 1) return element.firstDescendant();
 1740+ var descendants = element.descendants();
 1741+ return expression ? Selector.findElement(descendants, expression, index) :
 1742+ descendants[index || 0];
17431743 },
17441744
17451745 previous: function(element, expression, index) {
1746 - element = $(element);
1747 - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
1748 - var previousSiblings = element.previousSiblings();
1749 - return expression ? Selector.findElement(previousSiblings, expression, index) :
1750 - previousSiblings[index || 0];
 1746+ element = $(element);
 1747+ if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
 1748+ var previousSiblings = element.previousSiblings();
 1749+ return expression ? Selector.findElement(previousSiblings, expression, index) :
 1750+ previousSiblings[index || 0];
17511751 },
17521752
17531753 next: function(element, expression, index) {
1754 - element = $(element);
1755 - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
1756 - var nextSiblings = element.nextSiblings();
1757 - return expression ? Selector.findElement(nextSiblings, expression, index) :
1758 - nextSiblings[index || 0];
 1754+ element = $(element);
 1755+ if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
 1756+ var nextSiblings = element.nextSiblings();
 1757+ return expression ? Selector.findElement(nextSiblings, expression, index) :
 1758+ nextSiblings[index || 0];
17591759 },
17601760
17611761 select: function() {
1762 - var args = $A(arguments), element = $(args.shift());
1763 - return Selector.findChildElements(element, args);
 1762+ var args = $A(arguments), element = $(args.shift());
 1763+ return Selector.findChildElements(element, args);
17641764 },
17651765
17661766 adjacent: function() {
1767 - var args = $A(arguments), element = $(args.shift());
1768 - return Selector.findChildElements(element.parentNode, args).without(element);
 1767+ var args = $A(arguments), element = $(args.shift());
 1768+ return Selector.findChildElements(element.parentNode, args).without(element);
17691769 },
17701770
17711771 identify: function(element) {
1772 - element = $(element);
1773 - var id = element.readAttribute('id'), self = arguments.callee;
1774 - if (id) return id;
1775 - do { id = 'anonymous_element_' + self.counter++ } while ($(id));
1776 - element.writeAttribute('id', id);
1777 - return id;
 1772+ element = $(element);
 1773+ var id = element.readAttribute('id'), self = arguments.callee;
 1774+ if (id) return id;
 1775+ do { id = 'anonymous_element_' + self.counter++ } while ($(id));
 1776+ element.writeAttribute('id', id);
 1777+ return id;
17781778 },
17791779
17801780 readAttribute: function(element, name) {
1781 - element = $(element);
1782 - if (Prototype.Browser.IE) {
1783 - var t = Element._attributeTranslations.read;
1784 - if (t.values[name]) return t.values[name](element, name);
1785 - if (t.names[name]) name = t.names[name];
1786 - if (name.include(':')) {
1787 - return (!element.attributes || !element.attributes[name]) ? null :
1788 - element.attributes[name].value;
1789 - }
1790 - }
1791 - return element.getAttribute(name);
 1781+ element = $(element);
 1782+ if (Prototype.Browser.IE) {
 1783+ var t = Element._attributeTranslations.read;
 1784+ if (t.values[name]) return t.values[name](element, name);
 1785+ if (t.names[name]) name = t.names[name];
 1786+ if (name.include(':')) {
 1787+ return (!element.attributes || !element.attributes[name]) ? null :
 1788+ element.attributes[name].value;
 1789+ }
 1790+ }
 1791+ return element.getAttribute(name);
17921792 },
17931793
17941794 writeAttribute: function(element, name, value) {
1795 - element = $(element);
1796 - var attributes = { }, t = Element._attributeTranslations.write;
 1795+ element = $(element);
 1796+ var attributes = { }, t = Element._attributeTranslations.write;
17971797
1798 - if (typeof name == 'object') attributes = name;
1799 - else attributes[name] = value === undefined ? true : value;
 1798+ if (typeof name == 'object') attributes = name;
 1799+ else attributes[name] = value === undefined ? true : value;
18001800
1801 - for (var attr in attributes) {
1802 - var name = t.names[attr] || attr, value = attributes[attr];
1803 - if (t.values[attr]) name = t.values[attr](element, value);
1804 - if (value === false || value === null)
1805 - element.removeAttribute(name);
1806 - else if (value === true)
1807 - element.setAttribute(name, name);
1808 - else element.setAttribute(name, value);
1809 - }
1810 - return element;
 1801+ for (var attr in attributes) {
 1802+ var name = t.names[attr] || attr, value = attributes[attr];
 1803+ if (t.values[attr]) name = t.values[attr](element, value);
 1804+ if (value === false || value === null)
 1805+ element.removeAttribute(name);
 1806+ else if (value === true)
 1807+ element.setAttribute(name, name);
 1808+ else element.setAttribute(name, value);
 1809+ }
 1810+ return element;
18111811 },
18121812
18131813 getHeight: function(element) {
1814 - return $(element).getDimensions().height;
 1814+ return $(element).getDimensions().height;
18151815 },
18161816
18171817 getWidth: function(element) {
1818 - return $(element).getDimensions().width;
 1818+ return $(element).getDimensions().width;
18191819 },
18201820
18211821 classNames: function(element) {
1822 - return new Element.ClassNames(element);
 1822+ return new Element.ClassNames(element);
18231823 },
18241824
18251825 hasClassName: function(element, className) {
1826 - if (!(element = $(element))) return;
1827 - var elementClassName = element.className;
1828 - return (elementClassName.length > 0 && (elementClassName == className ||
1829 - new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
 1826+ if (!(element = $(element))) return;
 1827+ var elementClassName = element.className;
 1828+ return (elementClassName.length > 0 && (elementClassName == className ||
 1829+ new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
18301830 },
18311831
18321832 addClassName: function(element, className) {
1833 - if (!(element = $(element))) return;
1834 - if (!element.hasClassName(className))
1835 - element.className += (element.className ? ' ' : '') + className;
1836 - return element;
 1833+ if (!(element = $(element))) return;
 1834+ if (!element.hasClassName(className))
 1835+ element.className += (element.className ? ' ' : '') + className;
 1836+ return element;
18371837 },
18381838
18391839 removeClassName: function(element, className) {
1840 - if (!(element = $(element))) return;
1841 - element.className = element.className.replace(
1842 - new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
1843 - return element;
 1840+ if (!(element = $(element))) return;
 1841+ element.className = element.className.replace(
 1842+ new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip();
 1843+ return element;
18441844 },
18451845
18461846 toggleClassName: function(element, className) {
1847 - if (!(element = $(element))) return;
1848 - return element[element.hasClassName(className) ?
1849 - 'removeClassName' : 'addClassName'](className);
 1847+ if (!(element = $(element))) return;
 1848+ return element[element.hasClassName(className) ?
 1849+ 'removeClassName' : 'addClassName'](className);
18501850 },
18511851
18521852 // removes whitespace-only text node children
18531853 cleanWhitespace: function(element) {
1854 - element = $(element);
1855 - var node = element.firstChild;
1856 - while (node) {
1857 - var nextNode = node.nextSibling;
1858 - if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
1859 - element.removeChild(node);
1860 - node = nextNode;
1861 - }
1862 - return element;
 1854+ element = $(element);
 1855+ var node = element.firstChild;
 1856+ while (node) {
 1857+ var nextNode = node.nextSibling;
 1858+ if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
 1859+ element.removeChild(node);
 1860+ node = nextNode;
 1861+ }
 1862+ return element;
18631863 },
18641864
18651865 empty: function(element) {
1866 - return $(element).innerHTML.blank();
 1866+ return $(element).innerHTML.blank();
18671867 },
18681868
18691869 descendantOf: function(element, ancestor) {
1870 - element = $(element), ancestor = $(ancestor);
 1870+ element = $(element), ancestor = $(ancestor);
18711871
1872 - if (element.compareDocumentPosition)
1873 - return (element.compareDocumentPosition(ancestor) & 8) === 8;
 1872+ if (element.compareDocumentPosition)
 1873+ return (element.compareDocumentPosition(ancestor) & 8) === 8;
18741874
1875 - if (element.sourceIndex && !Prototype.Browser.Opera) {
1876 - var e = element.sourceIndex, a = ancestor.sourceIndex,
1877 - nextAncestor = ancestor.nextSibling;
1878 - if (!nextAncestor) {
1879 - do { ancestor = ancestor.parentNode; }
1880 - while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
1881 - }
1882 - if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
1883 - }
 1875+ if (element.sourceIndex && !Prototype.Browser.Opera) {
 1876+ var e = element.sourceIndex, a = ancestor.sourceIndex,
 1877+ nextAncestor = ancestor.nextSibling;
 1878+ if (!nextAncestor) {
 1879+ do { ancestor = ancestor.parentNode; }
 1880+ while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
 1881+ }
 1882+ if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
 1883+ }
18841884
1885 - while (element = element.parentNode)
1886 - if (element == ancestor) return true;
1887 - return false;
 1885+ while (element = element.parentNode)
 1886+ if (element == ancestor) return true;
 1887+ return false;
18881888 },
18891889
18901890 scrollTo: function(element) {
1891 - element = $(element);
1892 - var pos = element.cumulativeOffset();
1893 - window.scrollTo(pos[0], pos[1]);
1894 - return element;
 1891+ element = $(element);
 1892+ var pos = element.cumulativeOffset();
 1893+ window.scrollTo(pos[0], pos[1]);
 1894+ return element;
18951895 },
18961896
18971897 getStyle: function(element, style) {
1898 - element = $(element);
1899 - style = style == 'float' ? 'cssFloat' : style.camelize();
1900 - var value = element.style[style];
1901 - if (!value) {
1902 - var css = document.defaultView.getComputedStyle(element, null);
1903 - value = css ? css[style] : null;
1904 - }
1905 - if (style == 'opacity') return value ? parseFloat(value) : 1.0;
1906 - return value == 'auto' ? null : value;
 1898+ element = $(element);
 1899+ style = style == 'float' ? 'cssFloat' : style.camelize();
 1900+ var value = element.style[style];
 1901+ if (!value) {
 1902+ var css = document.defaultView.getComputedStyle(element, null);
 1903+ value = css ? css[style] : null;
 1904+ }
 1905+ if (style == 'opacity') return value ? parseFloat(value) : 1.0;
 1906+ return value == 'auto' ? null : value;
19071907 },
19081908
19091909 getOpacity: function(element) {
1910 - return $(element).getStyle('opacity');
 1910+ return $(element).getStyle('opacity');
19111911 },
19121912
19131913 setStyle: function(element, styles) {
1914 - element = $(element);
1915 - var elementStyle = element.style, match;
1916 - if (Object.isString(styles)) {
1917 - element.style.cssText += ';' + styles;
1918 - return styles.include('opacity') ?
1919 - element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
1920 - }
1921 - for (var property in styles)
1922 - if (property == 'opacity') element.setOpacity(styles[property]);
1923 - else
1924 - elementStyle[(property == 'float' || property == 'cssFloat') ?
1925 - (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
1926 - property] = styles[property];
 1914+ element = $(element);
 1915+ var elementStyle = element.style, match;
 1916+ if (Object.isString(styles)) {
 1917+ element.style.cssText += ';' + styles;
 1918+ return styles.include('opacity') ?
 1919+ element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element;
 1920+ }
 1921+ for (var property in styles)
 1922+ if (property == 'opacity') element.setOpacity(styles[property]);
 1923+ else
 1924+ elementStyle[(property == 'float' || property == 'cssFloat') ?
 1925+ (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') :
 1926+ property] = styles[property];
19271927
1928 - return element;
 1928+ return element;
19291929 },
19301930
19311931 setOpacity: function(element, value) {
1932 - element = $(element);
1933 - element.style.opacity = (value == 1 || value === '') ? '' :
1934 - (value < 0.00001) ? 0 : value;
1935 - return element;
 1932+ element = $(element);
 1933+ element.style.opacity = (value == 1 || value === '') ? '' :
 1934+ (value < 0.00001) ? 0 : value;
 1935+ return element;
19361936 },
19371937
19381938 getDimensions: function(element) {
1939 - element = $(element);
1940 - var display = $(element).getStyle('display');
1941 - if (display != 'none' && display != null) // Safari bug
1942 - return {width: element.offsetWidth, height: element.offsetHeight};
 1939+ element = $(element);
 1940+ var display = $(element).getStyle('display');
 1941+ if (display != 'none' && display != null) // Safari bug
 1942+ return {width: element.offsetWidth, height: element.offsetHeight};
19431943
1944 - // All *Width and *Height properties give 0 on elements with display none,
1945 - // so enable the element temporarily
1946 - var els = element.style;
1947 - var originalVisibility = els.visibility;
1948 - var originalPosition = els.position;
1949 - var originalDisplay = els.display;
1950 - els.visibility = 'hidden';
1951 - els.position = 'absolute';
1952 - els.display = 'block';
1953 - var originalWidth = element.clientWidth;
1954 - var originalHeight = element.clientHeight;
1955 - els.display = originalDisplay;
1956 - els.position = originalPosition;
1957 - els.visibility = originalVisibility;
1958 - return {width: originalWidth, height: originalHeight};
 1944+ // All *Width and *Height properties give 0 on elements with display none,
 1945+ // so enable the element temporarily
 1946+ var els = element.style;
 1947+ var originalVisibility = els.visibility;
 1948+ var originalPosition = els.position;
 1949+ var originalDisplay = els.display;
 1950+ els.visibility = 'hidden';
 1951+ els.position = 'absolute';
 1952+ els.display = 'block';
 1953+ var originalWidth = element.clientWidth;
 1954+ var originalHeight = element.clientHeight;
 1955+ els.display = originalDisplay;
 1956+ els.position = originalPosition;
 1957+ els.visibility = originalVisibility;
 1958+ return {width: originalWidth, height: originalHeight};
19591959 },
19601960
19611961 makePositioned: function(element) {
1962 - element = $(element);
1963 - var pos = Element.getStyle(element, 'position');
1964 - if (pos == 'static' || !pos) {
1965 - element._madePositioned = true;
1966 - element.style.position = 'relative';
1967 - // Opera returns the offset relative to the positioning context, when an
1968 - // element is position relative but top and left have not been defined
1969 - if (window.opera) {
1970 - element.style.top = 0;
1971 - element.style.left = 0;
1972 - }
1973 - }
1974 - return element;
 1962+ element = $(element);
 1963+ var pos = Element.getStyle(element, 'position');
 1964+ if (pos == 'static' || !pos) {
 1965+ element._madePositioned = true;
 1966+ element.style.position = 'relative';
 1967+ // Opera returns the offset relative to the positioning context, when an
 1968+ // element is position relative but top and left have not been defined
 1969+ if (window.opera) {
 1970+ element.style.top = 0;
 1971+ element.style.left = 0;
 1972+ }
 1973+ }
 1974+ return element;
19751975 },
19761976
19771977 undoPositioned: function(element) {
1978 - element = $(element);
1979 - if (element._madePositioned) {
1980 - element._madePositioned = undefined;
1981 - element.style.position =
1982 - element.style.top =
1983 - element.style.left =
1984 - element.style.bottom =
1985 - element.style.right = '';
1986 - }
1987 - return element;
 1978+ element = $(element);
 1979+ if (element._madePositioned) {
 1980+ element._madePositioned = undefined;
 1981+ element.style.position =
 1982+ element.style.top =
 1983+ element.style.left =
 1984+ element.style.bottom =
 1985+ element.style.right = '';
 1986+ }
 1987+ return element;
19881988 },
19891989
19901990 makeClipping: function(element) {
1991 - element = $(element);
1992 - if (element._overflow) return element;
1993 - element._overflow = Element.getStyle(element, 'overflow') || 'auto';
1994 - if (element._overflow !== 'hidden')
1995 - element.style.overflow = 'hidden';
1996 - return element;
 1991+ element = $(element);
 1992+ if (element._overflow) return element;
 1993+ element._overflow = Element.getStyle(element, 'overflow') || 'auto';
 1994+ if (element._overflow !== 'hidden')
 1995+ element.style.overflow = 'hidden';
 1996+ return element;
19971997 },
19981998
19991999 undoClipping: function(element) {
2000 - element = $(element);
2001 - if (!element._overflow) return element;
2002 - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
2003 - element._overflow = null;
2004 - return element;
 2000+ element = $(element);
 2001+ if (!element._overflow) return element;
 2002+ element.style.overflow = element._overflow == 'auto' ? '' : element._overflow;
 2003+ element._overflow = null;
 2004+ return element;
20052005 },
20062006
20072007 cumulativeOffset: function(element) {
2008 - var valueT = 0, valueL = 0;
2009 - do {
2010 - valueT += element.offsetTop || 0;
2011 - valueL += element.offsetLeft || 0;
2012 - element = element.offsetParent;
2013 - } while (element);
2014 - return Element._returnOffset(valueL, valueT);
 2008+ var valueT = 0, valueL = 0;
 2009+ do {
 2010+ valueT += element.offsetTop || 0;
 2011+ valueL += element.offsetLeft || 0;
 2012+ element = element.offsetParent;
 2013+ } while (element);
 2014+ return Element._returnOffset(valueL, valueT);
20152015 },
20162016
20172017 positionedOffset: function(element) {
2018 - var valueT = 0, valueL = 0;
2019 - do {
2020 - valueT += element.offsetTop || 0;
2021 - valueL += element.offsetLeft || 0;
2022 - element = element.offsetParent;
2023 - if (element) {
2024 - if (element.tagName == 'BODY') break;
2025 - var p = Element.getStyle(element, 'position');
2026 - if (p == 'relative' || p == 'absolute') break;
2027 - }
2028 - } while (element);
2029 - return Element._returnOffset(valueL, valueT);
 2018+ var valueT = 0, valueL = 0;
 2019+ do {
 2020+ valueT += element.offsetTop || 0;
 2021+ valueL += element.offsetLeft || 0;
 2022+ element = element.offsetParent;
 2023+ if (element) {
 2024+ if (element.tagName == 'BODY') break;
 2025+ var p = Element.getStyle(element, 'position');
 2026+ if (p == 'relative' || p == 'absolute') break;
 2027+ }
 2028+ } while (element);
 2029+ return Element._returnOffset(valueL, valueT);
20302030 },
20312031
20322032 absolutize: function(element) {
2033 - element = $(element);
2034 - if (element.getStyle('position') == 'absolute') return;
2035 - // Position.prepare(); // To be done manually by Scripty when it needs it.
 2033+ element = $(element);
 2034+ if (element.getStyle('position') == 'absolute') return;
 2035+ // Position.prepare(); // To be done manually by Scripty when it needs it.
20362036
2037 - var offsets = element.positionedOffset();
2038 - var top = offsets[1];
2039 - var left = offsets[0];
2040 - var width = element.clientWidth;
2041 - var height = element.clientHeight;
 2037+ var offsets = element.positionedOffset();
 2038+ var top = offsets[1];
 2039+ var left = offsets[0];
 2040+ var width = element.clientWidth;
 2041+ var height = element.clientHeight;
20422042
2043 - element._originalLeft = left - parseFloat(element.style.left || 0);
2044 - element._originalTop = top - parseFloat(element.style.top || 0);
2045 - element._originalWidth = element.style.width;
2046 - element._originalHeight = element.style.height;
 2043+ element._originalLeft = left - parseFloat(element.style.left || 0);
 2044+ element._originalTop = top - parseFloat(element.style.top || 0);
 2045+ element._originalWidth = element.style.width;
 2046+ element._originalHeight = element.style.height;
20472047
2048 - element.style.position = 'absolute';
2049 - element.style.top = top + 'px';
2050 - element.style.left = left + 'px';
2051 - element.style.width = width + 'px';
2052 - element.style.height = height + 'px';
2053 - return element;
 2048+ element.style.position = 'absolute';
 2049+ element.style.top = top + 'px';
 2050+ element.style.left = left + 'px';
 2051+ element.style.width = width + 'px';
 2052+ element.style.height = height + 'px';
 2053+ return element;
20542054 },
20552055
20562056 relativize: function(element) {
2057 - element = $(element);
2058 - if (element.getStyle('position') == 'relative') return;
2059 - // Position.prepare(); // To be done manually by Scripty when it needs it.
 2057+ element = $(element);
 2058+ if (element.getStyle('position') == 'relative') return;
 2059+ // Position.prepare(); // To be done manually by Scripty when it needs it.
20602060
2061 - element.style.position = 'relative';
2062 - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
2063 - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
 2061+ element.style.position = 'relative';
 2062+ var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
 2063+ var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
20642064
2065 - element.style.top = top + 'px';
2066 - element.style.left = left + 'px';
2067 - element.style.height = element._originalHeight;
2068 - element.style.width = element._originalWidth;
2069 - return element;
 2065+ element.style.top = top + 'px';
 2066+ element.style.left = left + 'px';
 2067+ element.style.height = element._originalHeight;
 2068+ element.style.width = element._originalWidth;
 2069+ return element;
20702070 },
20712071
20722072 cumulativeScrollOffset: function(element) {
2073 - var valueT = 0, valueL = 0;
2074 - do {
2075 - valueT += element.scrollTop || 0;
2076 - valueL += element.scrollLeft || 0;
2077 - element = element.parentNode;
2078 - } while (element);
2079 - return Element._returnOffset(valueL, valueT);
 2073+ var valueT = 0, valueL = 0;
 2074+ do {
 2075+ valueT += element.scrollTop || 0;
 2076+ valueL += element.scrollLeft || 0;
 2077+ element = element.parentNode;
 2078+ } while (element);
 2079+ return Element._returnOffset(valueL, valueT);
20802080 },
20812081
20822082 getOffsetParent: function(element) {
2083 - if (element.offsetParent) return $(element.offsetParent);
2084 - if (element == document.body) return $(element);
 2083+ if (element.offsetParent) return $(element.offsetParent);
 2084+ if (element == document.body) return $(element);
20852085
2086 - while ((element = element.parentNode) && element != document.body)
2087 - if (Element.getStyle(element, 'position') != 'static')
2088 - return $(element);
 2086+ while ((element = element.parentNode) && element != document.body)
 2087+ if (Element.getStyle(element, 'position') != 'static')
 2088+ return $(element);
20892089
2090 - return $(document.body);
 2090+ return $(document.body);
20912091 },
20922092
20932093 viewportOffset: function(forElement) {
2094 - var valueT = 0, valueL = 0;
 2094+ var valueT = 0, valueL = 0;
20952095
2096 - var element = forElement;
2097 - do {
2098 - valueT += element.offsetTop || 0;
2099 - valueL += element.offsetLeft || 0;
 2096+ var element = forElement;
 2097+ do {
 2098+ valueT += element.offsetTop || 0;
 2099+ valueL += element.offsetLeft || 0;
21002100
2101 - // Safari fix
2102 - if (element.offsetParent == document.body &&
2103 - Element.getStyle(element, 'position') == 'absolute') break;
 2101+ // Safari fix
 2102+ if (element.offsetParent == document.body &&
 2103+ Element.getStyle(element, 'position') == 'absolute') break;
21042104
2105 - } while (element = element.offsetParent);
 2105+ } while (element = element.offsetParent);
21062106
2107 - element = forElement;
2108 - do {
2109 - if (!Prototype.Browser.Opera || element.tagName == 'BODY') {
2110 - valueT -= element.scrollTop || 0;
2111 - valueL -= element.scrollLeft || 0;
2112 - }
2113 - } while (element = element.parentNode);
 2107+ element = forElement;
 2108+ do {
 2109+ if (!Prototype.Browser.Opera || element.tagName == 'BODY') {
 2110+ valueT -= element.scrollTop || 0;
 2111+ valueL -= element.scrollLeft || 0;
 2112+ }
 2113+ } while (element = element.parentNode);
21142114
2115 - return Element._returnOffset(valueL, valueT);
 2115+ return Element._returnOffset(valueL, valueT);
21162116 },
21172117
21182118 clonePosition: function(element, source) {
2119 - var options = Object.extend({
2120 - setLeft: true,
2121 - setTop: true,
2122 - setWidth: true,
2123 - setHeight: true,
2124 - offsetTop: 0,
2125 - offsetLeft: 0
2126 - }, arguments[2] || { });
 2119+ var options = Object.extend({
 2120+ setLeft: true,
 2121+ setTop: true,
 2122+ setWidth: true,
 2123+ setHeight: true,
 2124+ offsetTop: 0,
 2125+ offsetLeft: 0
 2126+ }, arguments[2] || { });
21272127
2128 - // find page position of source
2129 - source = $(source);
2130 - var p = source.viewportOffset();
 2128+ // find page position of source
 2129+ source = $(source);
 2130+ var p = source.viewportOffset();
21312131
2132 - // find coordinate system to use
2133 - element = $(element);
2134 - var delta = [0, 0];
2135 - var parent = null;
2136 - // delta [0,0] will do fine with position: fixed elements,
2137 - // position:absolute needs offsetParent deltas
2138 - if (Element.getStyle(element, 'position') == 'absolute') {
2139 - parent = element.getOffsetParent();
2140 - delta = parent.viewportOffset();
2141 - }
 2132+ // find coordinate system to use
 2133+ element = $(element);
 2134+ var delta = [0, 0];
 2135+ var parent = null;
 2136+ // delta [0,0] will do fine with position: fixed elements,
 2137+ // position:absolute needs offsetParent deltas
 2138+ if (Element.getStyle(element, 'position') == 'absolute') {
 2139+ parent = element.getOffsetParent();
 2140+ delta = parent.viewportOffset();
 2141+ }
21422142
2143 - // correct by body offsets (fixes Safari)
2144 - if (parent == document.body) {
2145 - delta[0] -= document.body.offsetLeft;
2146 - delta[1] -= document.body.offsetTop;
2147 - }
 2143+ // correct by body offsets (fixes Safari)
 2144+ if (parent == document.body) {
 2145+ delta[0] -= document.body.offsetLeft;
 2146+ delta[1] -= document.body.offsetTop;
 2147+ }
21482148
2149 - // set position
2150 - if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
2151 - if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
2152 - if (options.setWidth) element.style.width = source.offsetWidth + 'px';
2153 - if (options.setHeight) element.style.height = source.offsetHeight + 'px';
2154 - return element;
 2149+ // set position
 2150+ if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
 2151+ if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
 2152+ if (options.setWidth) element.style.width = source.offsetWidth + 'px';
 2153+ if (options.setHeight) element.style.height = source.offsetHeight + 'px';
 2154+ return element;
21552155 }
21562156 };
21572157
@@ -2163,307 +2163,307 @@
21642164
21652165 Element._attributeTranslations = {
21662166 write: {
2167 - names: {
2168 - className: 'class',
2169 - htmlFor: 'for'
2170 - },
2171 - values: { }
 2167+ names: {
 2168+ className: 'class',
 2169+ htmlFor: 'for'
 2170+ },
 2171+ values: { }
21722172 }
21732173 };
21742174
21752175
21762176 if (!document.createRange || Prototype.Browser.Opera) {
21772177 Element.Methods.insert = function(element, insertions) {
2178 - element = $(element);
 2178+ element = $(element);
21792179
2180 - if (Object.isString(insertions) || Object.isNumber(insertions) ||
2181 - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
2182 - insertions = { bottom: insertions };
 2180+ if (Object.isString(insertions) || Object.isNumber(insertions) ||
 2181+ Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML)))
 2182+ insertions = { bottom: insertions };
21832183
2184 - var t = Element._insertionTranslations, content, position, pos, tagName;
 2184+ var t = Element._insertionTranslations, content, position, pos, tagName;
21852185
2186 - for (position in insertions) {
2187 - content = insertions[position];
2188 - position = position.toLowerCase();
2189 - pos = t[position];
 2186+ for (position in insertions) {
 2187+ content = insertions[position];
 2188+ position = position.toLowerCase();
 2189+ pos = t[position];
21902190
2191 - if (content && content.toElement) content = content.toElement();
2192 - if (Object.isElement(content)) {
2193 - pos.insert(element, content);
2194 - continue;
2195 - }
 2191+ if (content && content.toElement) content = content.toElement();
 2192+ if (Object.isElement(content)) {
 2193+ pos.insert(element, content);
 2194+ continue;
 2195+ }
21962196
2197 - content = Object.toHTML(content);
2198 - tagName = ((position == 'before' || position == 'after')
2199 - ? element.parentNode : element).tagName.toUpperCase();
 2197+ content = Object.toHTML(content);
 2198+ tagName = ((position == 'before' || position == 'after')
 2199+ ? element.parentNode : element).tagName.toUpperCase();
22002200
2201 - if (t.tags[tagName]) {
2202 - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
2203 - if (position == 'top' || position == 'after') fragments.reverse();
2204 - fragments.each(pos.insert.curry(element));
2205 - }
2206 - else element.insertAdjacentHTML(pos.adjacency, content.stripScripts());
 2201+ if (t.tags[tagName]) {
 2202+ var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
 2203+ if (position == 'top' || position == 'after') fragments.reverse();
 2204+ fragments.each(pos.insert.curry(element));
 2205+ }
 2206+ else element.insertAdjacentHTML(pos.adjacency, content.stripScripts());
22072207
2208 - content.evalScripts.bind(content).defer();
2209 - }
 2208+ content.evalScripts.bind(content).defer();
 2209+ }
22102210
2211 - return element;
 2211+ return element;
22122212 };
22132213 }
22142214
22152215 if (Prototype.Browser.Opera) {
22162216 Element.Methods._getStyle = Element.Methods.getStyle;
22172217 Element.Methods.getStyle = function(element, style) {
2218 - switch(style) {
2219 - case 'left':
2220 - case 'top':
2221 - case 'right':
2222 - case 'bottom':
2223 - if (Element._getStyle(element, 'position') == 'static') return null;
2224 - default: return Element._getStyle(element, style);
2225 - }
 2218+ switch(style) {
 2219+ case 'left':
 2220+ case 'top':
 2221+ case 'right':
 2222+ case 'bottom':
 2223+ if (Element._getStyle(element, 'position') == 'static') return null;
 2224+ default: return Element._getStyle(element, style);
 2225+ }
22262226 };
22272227 Element.Methods._readAttribute = Element.Methods.readAttribute;
22282228 Element.Methods.readAttribute = function(element, attribute) {
2229 - if (attribute == 'title') return element.title;
2230 - return Element._readAttribute(element, attribute);
 2229+ if (attribute == 'title') return element.title;
 2230+ return Element._readAttribute(element, attribute);
22312231 };
22322232 }
22332233
22342234 else if (Prototype.Browser.IE) {
22352235 $w('positionedOffset getOffsetParent viewportOffset').each(function(method) {
2236 - Element.Methods[method] = Element.Methods[method].wrap(
2237 - function(proceed, element) {
2238 - element = $(element);
2239 - var position = element.getStyle('position');
2240 - if (position != 'static') return proceed(element);
2241 - element.setStyle({ position: 'relative' });
2242 - var value = proceed(element);
2243 - element.setStyle({ position: position });
2244 - return value;
2245 - }
2246 - );
 2236+ Element.Methods[method] = Element.Methods[method].wrap(
 2237+ function(proceed, element) {
 2238+ element = $(element);
 2239+ var position = element.getStyle('position');
 2240+ if (position != 'static') return proceed(element);
 2241+ element.setStyle({ position: 'relative' });
 2242+ var value = proceed(element);
 2243+ element.setStyle({ position: position });
 2244+ return value;
 2245+ }
 2246+ );
22472247 });
22482248
22492249 Element.Methods.getStyle = function(element, style) {
2250 - element = $(element);
2251 - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
2252 - var value = element.style[style];
2253 - if (!value && element.currentStyle) value = element.currentStyle[style];
 2250+ element = $(element);
 2251+ style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize();
 2252+ var value = element.style[style];
 2253+ if (!value && element.currentStyle) value = element.currentStyle[style];
22542254
2255 - if (style == 'opacity') {
2256 - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
2257 - if (value[1]) return parseFloat(value[1]) / 100;
2258 - return 1.0;
2259 - }
 2255+ if (style == 'opacity') {
 2256+ if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
 2257+ if (value[1]) return parseFloat(value[1]) / 100;
 2258+ return 1.0;
 2259+ }
22602260
2261 - if (value == 'auto') {
2262 - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
2263 - return element['offset' + style.capitalize()] + 'px';
2264 - return null;
2265 - }
2266 - return value;
 2261+ if (value == 'auto') {
 2262+ if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none'))
 2263+ return element['offset' + style.capitalize()] + 'px';
 2264+ return null;
 2265+ }
 2266+ return value;
22672267 };
22682268
22692269 Element.Methods.setOpacity = function(element, value) {
2270 - function stripAlpha(filter){
2271 - return filter.replace(/alpha\([^\)]*\)/gi,'');
2272 - }
2273 - element = $(element);
2274 - var currentStyle = element.currentStyle;
2275 - if ((currentStyle && !currentStyle.hasLayout) ||
2276 - (!currentStyle && element.style.zoom == 'normal'))
2277 - element.style.zoom = 1;
 2270+ function stripAlpha(filter){
 2271+ return filter.replace(/alpha\([^\)]*\)/gi,'');
 2272+ }
 2273+ element = $(element);
 2274+ var currentStyle = element.currentStyle;
 2275+ if ((currentStyle && !currentStyle.hasLayout) ||
 2276+ (!currentStyle && element.style.zoom == 'normal'))
 2277+ element.style.zoom = 1;
22782278
2279 - var filter = element.getStyle('filter'), style = element.style;
2280 - if (value == 1 || value === '') {
2281 - (filter = stripAlpha(filter)) ?
2282 - style.filter = filter : style.removeAttribute('filter');
2283 - return element;
2284 - } else if (value < 0.00001) value = 0;
2285 - style.filter = stripAlpha(filter) +
2286 - 'alpha(opacity=' + (value * 100) + ')';
2287 - return element;
 2279+ var filter = element.getStyle('filter'), style = element.style;
 2280+ if (value == 1 || value === '') {
 2281+ (filter = stripAlpha(filter)) ?
 2282+ style.filter = filter : style.removeAttribute('filter');
 2283+ return element;
 2284+ } else if (value < 0.00001) value = 0;
 2285+ style.filter = stripAlpha(filter) +
 2286+ 'alpha(opacity=' + (value * 100) + ')';
 2287+ return element;
22882288 };
22892289
22902290 Element._attributeTranslations = {
2291 - read: {
2292 - names: {
2293 - 'class': 'className',
2294 - 'for': 'htmlFor'
2295 - },
2296 - values: {
2297 - _getAttr: function(element, attribute) {
2298 - return element.getAttribute(attribute, 2);
2299 - },
2300 - _getAttrNode: function(element, attribute) {
2301 - var node = element.getAttributeNode(attribute);
2302 - return node ? node.value : "";
2303 - },
2304 - _getEv: function(element, attribute) {
2305 - var attribute = element.getAttribute(attribute);
2306 - return attribute ? attribute.toString().slice(23, -2) : null;
2307 - },
2308 - _flag: function(element, attribute) {
2309 - return $(element).hasAttribute(attribute) ? attribute : null;
2310 - },
2311 - style: function(element) {
2312 - return element.style.cssText.toLowerCase();
2313 - },
2314 - title: function(element) {
2315 - return element.title;
2316 - }
2317 - }
2318 - }
 2291+ read: {
 2292+ names: {
 2293+ 'class': 'className',
 2294+ 'for': 'htmlFor'
 2295+ },
 2296+ values: {
 2297+ _getAttr: function(element, attribute) {
 2298+ return element.getAttribute(attribute, 2);
 2299+ },
 2300+ _getAttrNode: function(element, attribute) {
 2301+ var node = element.getAttributeNode(attribute);
 2302+ return node ? node.value : "";
 2303+ },
 2304+ _getEv: function(element, attribute) {
 2305+ var attribute = element.getAttribute(attribute);
 2306+ return attribute ? attribute.toString().slice(23, -2) : null;
 2307+ },
 2308+ _flag: function(element, attribute) {
 2309+ return $(element).hasAttribute(attribute) ? attribute : null;
 2310+ },
 2311+ style: function(element) {
 2312+ return element.style.cssText.toLowerCase();
 2313+ },
 2314+ title: function(element) {
 2315+ return element.title;
 2316+ }
 2317+ }
 2318+ }
23192319 };
23202320
23212321 Element._attributeTranslations.write = {
2322 - names: Object.clone(Element._attributeTranslations.read.names),
2323 - values: {
2324 - checked: function(element, value) {
2325 - element.checked = !!value;
2326 - },
 2322+ names: Object.clone(Element._attributeTranslations.read.names),
 2323+ values: {
 2324+ checked: function(element, value) {
 2325+ element.checked = !!value;
 2326+ },
23272327
2328 - style: function(element, value) {
2329 - element.style.cssText = value ? value : '';
2330 - }
2331 - }
 2328+ style: function(element, value) {
 2329+ element.style.cssText = value ? value : '';
 2330+ }
 2331+ }
23322332 };
23332333
23342334 Element._attributeTranslations.has = {};
23352335
23362336 $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' +
2337 - 'encType maxLength readOnly longDesc').each(function(attr) {
2338 - Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
2339 - Element._attributeTranslations.has[attr.toLowerCase()] = attr;
 2337+ 'encType maxLength readOnly longDesc').each(function(attr) {
 2338+ Element._attributeTranslations.write.names[attr.toLowerCase()] = attr;
 2339+ Element._attributeTranslations.has[attr.toLowerCase()] = attr;
23402340 });
23412341
23422342 (function(v) {
2343 - Object.extend(v, {
2344 - href: v._getAttr,
2345 - src: v._getAttr,
2346 - type: v._getAttr,
2347 - action: v._getAttrNode,
2348 - disabled: v._flag,
2349 - checked: v._flag,
2350 - readonly: v._flag,
2351 - multiple: v._flag,
2352 - onload: v._getEv,
2353 - onunload: v._getEv,
2354 - onclick: v._getEv,
2355 - ondblclick: v._getEv,
2356 - onmousedown: v._getEv,
2357 - onmouseup: v._getEv,
2358 - onmouseover: v._getEv,
2359 - onmousemove: v._getEv,
2360 - onmouseout: v._getEv,
2361 - onfocus: v._getEv,
2362 - onblur: v._getEv,
2363 - onkeypress: v._getEv,
2364 - onkeydown: v._getEv,
2365 - onkeyup: v._getEv,
2366 - onsubmit: v._getEv,
2367 - onreset: v._getEv,
2368 - onselect: v._getEv,
2369 - onchange: v._getEv
2370 - });
 2343+ Object.extend(v, {
 2344+ href: v._getAttr,
 2345+ src: v._getAttr,
 2346+ type: v._getAttr,
 2347+ action: v._getAttrNode,
 2348+ disabled: v._flag,
 2349+ checked: v._flag,
 2350+ readonly: v._flag,
 2351+ multiple: v._flag,
 2352+ onload: v._getEv,
 2353+ onunload: v._getEv,
 2354+ onclick: v._getEv,
 2355+ ondblclick: v._getEv,
 2356+ onmousedown: v._getEv,
 2357+ onmouseup: v._getEv,
 2358+ onmouseover: v._getEv,
 2359+ onmousemove: v._getEv,
 2360+ onmouseout: v._getEv,
 2361+ onfocus: v._getEv,
 2362+ onblur: v._getEv,
 2363+ onkeypress: v._getEv,
 2364+ onkeydown: v._getEv,
 2365+ onkeyup: v._getEv,
 2366+ onsubmit: v._getEv,
 2367+ onreset: v._getEv,
 2368+ onselect: v._getEv,
 2369+ onchange: v._getEv
 2370+ });
23712371 })(Element._attributeTranslations.read.values);
23722372 }
23732373
23742374 else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
23752375 Element.Methods.setOpacity = function(element, value) {
2376 - element = $(element);
2377 - element.style.opacity = (value == 1) ? 0.999999 :
2378 - (value === '') ? '' : (value < 0.00001) ? 0 : value;
2379 - return element;
 2376+ element = $(element);
 2377+ element.style.opacity = (value == 1) ? 0.999999 :
 2378+ (value === '') ? '' : (value < 0.00001) ? 0 : value;
 2379+ return element;
23802380 };
23812381 }
23822382
23832383 else if (Prototype.Browser.WebKit) {
23842384 Element.Methods.setOpacity = function(element, value) {
2385 - element = $(element);
2386 - element.style.opacity = (value == 1 || value === '') ? '' :
2387 - (value < 0.00001) ? 0 : value;
 2385+ element = $(element);
 2386+ element.style.opacity = (value == 1 || value === '') ? '' :
 2387+ (value < 0.00001) ? 0 : value;
23882388
2389 - if (value == 1)
2390 - if(element.tagName == 'IMG' && element.width) {
2391 - element.width++; element.width--;
2392 - } else try {
2393 - var n = document.createTextNode(' ');
2394 - element.appendChild(n);
2395 - element.removeChild(n);
2396 - } catch (e) { }
 2389+ if (value == 1)
 2390+ if(element.tagName == 'IMG' && element.width) {
 2391+ element.width++; element.width--;
 2392+ } else try {
 2393+ var n = document.createTextNode(' ');
 2394+ element.appendChild(n);
 2395+ element.removeChild(n);
 2396+ } catch (e) { }
23972397
2398 - return element;
 2398+ return element;
23992399 };
24002400
24012401 // Safari returns margins on body which is incorrect if the child is absolutely
24022402 // positioned. For performance reasons, redefine Position.cumulativeOffset for
24032403 // KHTML/WebKit only.
24042404 Element.Methods.cumulativeOffset = function(element) {
2405 - var valueT = 0, valueL = 0;
2406 - do {
2407 - valueT += element.offsetTop || 0;
2408 - valueL += element.offsetLeft || 0;
2409 - if (element.offsetParent == document.body)
2410 - if (Element.getStyle(element, 'position') == 'absolute') break;
 2405+ var valueT = 0, valueL = 0;
 2406+ do {
 2407+ valueT += element.offsetTop || 0;
 2408+ valueL += element.offsetLeft || 0;
 2409+ if (element.offsetParent == document.body)
 2410+ if (Element.getStyle(element, 'position') == 'absolute') break;
24112411
2412 - element = element.offsetParent;
2413 - } while (element);
 2412+ element = element.offsetParent;
 2413+ } while (element);
24142414
2415 - return Element._returnOffset(valueL, valueT);
 2415+ return Element._returnOffset(valueL, valueT);
24162416 };
24172417 }
24182418
24192419 if (Prototype.Browser.IE || Prototype.Browser.Opera) {
24202420 // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements
24212421 Element.Methods.update = function(element, content) {
2422 - element = $(element);
 2422+ element = $(element);
24232423
2424 - if (content && content.toElement) content = content.toElement();
2425 - if (Object.isElement(content)) return element.update().insert(content);
 2424+ if (content && content.toElement) content = content.toElement();
 2425+ if (Object.isElement(content)) return element.update().insert(content);
24262426
2427 - content = Object.toHTML(content);
2428 - var tagName = element.tagName.toUpperCase();
 2427+ content = Object.toHTML(content);
 2428+ var tagName = element.tagName.toUpperCase();
24292429
2430 - if (tagName in Element._insertionTranslations.tags) {
2431 - $A(element.childNodes).each(function(node) { element.removeChild(node) });
2432 - Element._getContentFromAnonymousElement(tagName, content.stripScripts())
2433 - .each(function(node) { element.appendChild(node) });
2434 - }
2435 - else element.innerHTML = content.stripScripts();
 2430+ if (tagName in Element._insertionTranslations.tags) {
 2431+ $A(element.childNodes).each(function(node) { element.removeChild(node) });
 2432+ Element._getContentFromAnonymousElement(tagName, content.stripScripts())
 2433+ .each(function(node) { element.appendChild(node) });
 2434+ }
 2435+ else element.innerHTML = content.stripScripts();
24362436
2437 - content.evalScripts.bind(content).defer();
2438 - return element;
 2437+ content.evalScripts.bind(content).defer();
 2438+ return element;
24392439 };
24402440 }
24412441
24422442 if (document.createElement('div').outerHTML) {
24432443 Element.Methods.replace = function(element, content) {
2444 - element = $(element);
 2444+ element = $(element);
24452445
2446 - if (content && content.toElement) content = content.toElement();
2447 - if (Object.isElement(content)) {
2448 - element.parentNode.replaceChild(content, element);
2449 - return element;
2450 - }
 2446+ if (content && content.toElement) content = content.toElement();
 2447+ if (Object.isElement(content)) {
 2448+ element.parentNode.replaceChild(content, element);
 2449+ return element;
 2450+ }
24512451
2452 - content = Object.toHTML(content);
2453 - var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
 2452+ content = Object.toHTML(content);
 2453+ var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
24542454
2455 - if (Element._insertionTranslations.tags[tagName]) {
2456 - var nextSibling = element.next();
2457 - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
2458 - parent.removeChild(element);
2459 - if (nextSibling)
2460 - fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
2461 - else
2462 - fragments.each(function(node) { parent.appendChild(node) });
2463 - }
2464 - else element.outerHTML = content.stripScripts();
 2455+ if (Element._insertionTranslations.tags[tagName]) {
 2456+ var nextSibling = element.next();
 2457+ var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
 2458+ parent.removeChild(element);
 2459+ if (nextSibling)
 2460+ fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
 2461+ else
 2462+ fragments.each(function(node) { parent.appendChild(node) });
 2463+ }
 2464+ else element.outerHTML = content.stripScripts();
24652465
2466 - content.evalScripts.bind(content).defer();
2467 - return element;
 2466+ content.evalScripts.bind(content).defer();
 2467+ return element;
24682468 };
24692469 }
24702470
@@ -2483,62 +2483,62 @@
24842484
24852485 Element._insertionTranslations = {
24862486 before: {
2487 - adjacency: 'beforeBegin',
2488 - insert: function(element, node) {
2489 - element.parentNode.insertBefore(node, element);
2490 - },
2491 - initializeRange: function(element, range) {
2492 - range.setStartBefore(element);
2493 - }
 2487+ adjacency: 'beforeBegin',
 2488+ insert: function(element, node) {
 2489+ element.parentNode.insertBefore(node, element);
 2490+ },
 2491+ initializeRange: function(element, range) {
 2492+ range.setStartBefore(element);
 2493+ }
24942494 },
24952495 top: {
2496 - adjacency: 'afterBegin',
2497 - insert: function(element, node) {
2498 - element.insertBefore(node, element.firstChild);
2499 - },
2500 - initializeRange: function(element, range) {
2501 - range.selectNodeContents(element);
2502 - range.collapse(true);
2503 - }
 2496+ adjacency: 'afterBegin',
 2497+ insert: function(element, node) {
 2498+ element.insertBefore(node, element.firstChild);
 2499+ },
 2500+ initializeRange: function(element, range) {
 2501+ range.selectNodeContents(element);
 2502+ range.collapse(true);
 2503+ }
25042504 },
25052505 bottom: {
2506 - adjacency: 'beforeEnd',
2507 - insert: function(element, node) {
2508 - element.appendChild(node);
2509 - }
 2506+ adjacency: 'beforeEnd',
 2507+ insert: function(element, node) {
 2508+ element.appendChild(node);
 2509+ }
25102510 },
25112511 after: {
2512 - adjacency: 'afterEnd',
2513 - insert: function(element, node) {
2514 - element.parentNode.insertBefore(node, element.nextSibling);
2515 - },
2516 - initializeRange: function(element, range) {
2517 - range.setStartAfter(element);
2518 - }
 2512+ adjacency: 'afterEnd',
 2513+ insert: function(element, node) {
 2514+ element.parentNode.insertBefore(node, element.nextSibling);
 2515+ },
 2516+ initializeRange: function(element, range) {
 2517+ range.setStartAfter(element);
 2518+ }
25192519 },
25202520 tags: {
2521 - TABLE: ['<table>', '</table>', 1],
2522 - TBODY: ['<table><tbody>', '</tbody></table>', 2],
2523 - TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3],
2524 - TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
2525 - SELECT: ['<select>', '</select>', 1]
 2521+ TABLE: ['<table>', '</table>', 1],
 2522+ TBODY: ['<table><tbody>', '</tbody></table>', 2],
 2523+ TR: ['<table><tbody><tr>', '</tr></tbody></table>', 3],
 2524+ TD: ['<table><tbody><tr><td>', '</td></tr></tbody></table>', 4],
 2525+ SELECT: ['<select>', '</select>', 1]
25262526 }
25272527 };
25282528
25292529 (function() {
25302530 this.bottom.initializeRange = this.top.initializeRange;
25312531 Object.extend(this.tags, {
2532 - THEAD: this.tags.TBODY,
2533 - TFOOT: this.tags.TBODY,
2534 - TH: this.tags.TD
 2532+ THEAD: this.tags.TBODY,
 2533+ TFOOT: this.tags.TBODY,
 2534+ TH: this.tags.TD
25352535 });
25362536 }).call(Element._insertionTranslations);
25372537
25382538 Element.Methods.Simulated = {
25392539 hasAttribute: function(element, attribute) {
2540 - attribute = Element._attributeTranslations.has[attribute] || attribute;
2541 - var node = $(element).getAttributeNode(attribute);
2542 - return node && node.specified;
 2540+ attribute = Element._attributeTranslations.has[attribute] || attribute;
 2541+ var node = $(element).getAttributeNode(attribute);
 2542+ return node && node.specified;
25432543 }
25442544 };
25452545
@@ -2547,7 +2547,7 @@
25482548 Object.extend(Element, Element.Methods);
25492549
25502550 if (!Prototype.BrowserFeatures.ElementExtensions &&
2551 - document.createElement('div').__proto__) {
 2551+ document.createElement('div').__proto__) {
25522552 window.HTMLElement = { };
25532553 window.HTMLElement.prototype = document.createElement('div').__proto__;
25542554 Prototype.BrowserFeatures.ElementExtensions = true;
@@ -2555,37 +2555,37 @@
25562556
25572557 Element.extend = (function() {
25582558 if (Prototype.BrowserFeatures.SpecificElementExtensions)
2559 - return Prototype.K;
 2559+ return Prototype.K;
25602560
25612561 var Methods = { }, ByTag = Element.Methods.ByTag;
25622562
25632563 var extend = Object.extend(function(element) {
2564 - if (!element || element._extendedByPrototype ||
2565 - element.nodeType != 1 || element == window) return element;
 2564+ if (!element || element._extendedByPrototype ||
 2565+ element.nodeType != 1 || element == window) return element;
25662566
2567 - var methods = Object.clone(Methods),
2568 - tagName = element.tagName, property, value;
 2567+ var methods = Object.clone(Methods),
 2568+ tagName = element.tagName, property, value;
25692569
2570 - // extend methods for specific tags
2571 - if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
 2570+ // extend methods for specific tags
 2571+ if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]);
25722572
2573 - for (property in methods) {
2574 - value = methods[property];
2575 - if (Object.isFunction(value) && !(property in element))
2576 - element[property] = value.methodize();
2577 - }
 2573+ for (property in methods) {
 2574+ value = methods[property];
 2575+ if (Object.isFunction(value) && !(property in element))
 2576+ element[property] = value.methodize();
 2577+ }
25782578
2579 - element._extendedByPrototype = Prototype.emptyFunction;
2580 - return element;
 2579+ element._extendedByPrototype = Prototype.emptyFunction;
 2580+ return element;
25812581
25822582 }, {
2583 - refresh: function() {
2584 - // extend methods for all tags (Safari doesn't need this)
2585 - if (!Prototype.BrowserFeatures.ElementExtensions) {
2586 - Object.extend(Methods, Element.Methods);
2587 - Object.extend(Methods, Element.Methods.Simulated);
2588 - }
2589 - }
 2583+ refresh: function() {
 2584+ // extend methods for all tags (Safari doesn't need this)
 2585+ if (!Prototype.BrowserFeatures.ElementExtensions) {
 2586+ Object.extend(Methods, Element.Methods);
 2587+ Object.extend(Methods, Element.Methods.Simulated);
 2588+ }
 2589+ }
25902590 });
25912591
25922592 extend.refresh();
@@ -2601,80 +2601,80 @@
26022602 var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
26032603
26042604 if (!methods) {
2605 - Object.extend(Form, Form.Methods);
2606 - Object.extend(Form.Element, Form.Element.Methods);
2607 - Object.extend(Element.Methods.ByTag, {
2608 - "FORM": Object.clone(Form.Methods),
2609 - "INPUT": Object.clone(Form.Element.Methods),
2610 - "SELECT": Object.clone(Form.Element.Methods),
2611 - "TEXTAREA": Object.clone(Form.Element.Methods)
2612 - });
 2605+ Object.extend(Form, Form.Methods);
 2606+ Object.extend(Form.Element, Form.Element.Methods);
 2607+ Object.extend(Element.Methods.ByTag, {
 2608+ "FORM": Object.clone(Form.Methods),
 2609+ "INPUT": Object.clone(Form.Element.Methods),
 2610+ "SELECT": Object.clone(Form.Element.Methods),
 2611+ "TEXTAREA": Object.clone(Form.Element.Methods)
 2612+ });
26132613 }
26142614
26152615 if (arguments.length == 2) {
2616 - var tagName = methods;
2617 - methods = arguments[1];
 2616+ var tagName = methods;
 2617+ methods = arguments[1];
26182618 }
26192619
26202620 if (!tagName) Object.extend(Element.Methods, methods || { });
26212621 else {
2622 - if (Object.isArray(tagName)) tagName.each(extend);
2623 - else extend(tagName);
 2622+ if (Object.isArray(tagName)) tagName.each(extend);
 2623+ else extend(tagName);
26242624 }
26252625
26262626 function extend(tagName) {
2627 - tagName = tagName.toUpperCase();
2628 - if (!Element.Methods.ByTag[tagName])
2629 - Element.Methods.ByTag[tagName] = { };
2630 - Object.extend(Element.Methods.ByTag[tagName], methods);
 2627+ tagName = tagName.toUpperCase();
 2628+ if (!Element.Methods.ByTag[tagName])
 2629+ Element.Methods.ByTag[tagName] = { };
 2630+ Object.extend(Element.Methods.ByTag[tagName], methods);
26312631 }
26322632
26332633 function copy(methods, destination, onlyIfAbsent) {
2634 - onlyIfAbsent = onlyIfAbsent || false;
2635 - for (var property in methods) {
2636 - var value = methods[property];
2637 - if (!Object.isFunction(value)) continue;
2638 - if (!onlyIfAbsent || !(property in destination))
2639 - destination[property] = value.methodize();
2640 - }
 2634+ onlyIfAbsent = onlyIfAbsent || false;
 2635+ for (var property in methods) {
 2636+ var value = methods[property];
 2637+ if (!Object.isFunction(value)) continue;
 2638+ if (!onlyIfAbsent || !(property in destination))
 2639+ destination[property] = value.methodize();
 2640+ }
26412641 }
26422642
26432643 function findDOMClass(tagName) {
2644 - var klass;
2645 - var trans = {
2646 - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
2647 - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
2648 - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
2649 - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
2650 - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
2651 - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
2652 - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
2653 - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
2654 - "FrameSet", "IFRAME": "IFrame"
2655 - };
2656 - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
2657 - if (window[klass]) return window[klass];
2658 - klass = 'HTML' + tagName + 'Element';
2659 - if (window[klass]) return window[klass];
2660 - klass = 'HTML' + tagName.capitalize() + 'Element';
2661 - if (window[klass]) return window[klass];
 2644+ var klass;
 2645+ var trans = {
 2646+ "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph",
 2647+ "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList",
 2648+ "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading",
 2649+ "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote",
 2650+ "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION":
 2651+ "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD":
 2652+ "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR":
 2653+ "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET":
 2654+ "FrameSet", "IFRAME": "IFrame"
 2655+ };
 2656+ if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element';
 2657+ if (window[klass]) return window[klass];
 2658+ klass = 'HTML' + tagName + 'Element';
 2659+ if (window[klass]) return window[klass];
 2660+ klass = 'HTML' + tagName.capitalize() + 'Element';
 2661+ if (window[klass]) return window[klass];
26622662
2663 - window[klass] = { };
2664 - window[klass].prototype = document.createElement(tagName).__proto__;
2665 - return window[klass];
 2663+ window[klass] = { };
 2664+ window[klass].prototype = document.createElement(tagName).__proto__;
 2665+ return window[klass];
26662666 }
26672667
26682668 if (F.ElementExtensions) {
2669 - copy(Element.Methods, HTMLElement.prototype);
2670 - copy(Element.Methods.Simulated, HTMLElement.prototype, true);
 2669+ copy(Element.Methods, HTMLElement.prototype);
 2670+ copy(Element.Methods.Simulated, HTMLElement.prototype, true);
26712671 }
26722672
26732673 if (F.SpecificElementExtensions) {
2674 - for (var tag in Element.Methods.ByTag) {
2675 - var klass = findDOMClass(tag);
2676 - if (Object.isUndefined(klass)) continue;
2677 - copy(T[tag], klass.prototype);
2678 - }
 2674+ for (var tag in Element.Methods.ByTag) {
 2675+ var klass = findDOMClass(tag);
 2676+ if (Object.isUndefined(klass)) continue;
 2677+ copy(T[tag], klass.prototype);
 2678+ }
26792679 }
26802680
26812681 Object.extend(Element, Element.Methods);
@@ -2686,27 +2686,27 @@
26872687
26882688 document.viewport = {
26892689 getDimensions: function() {
2690 - var dimensions = { };
2691 - $w('width height').each(function(d) {
2692 - var D = d.capitalize();
2693 - dimensions[d] = self['inner' + D] ||
2694 - (document.documentElement['client' + D] || document.body['client' + D]);
2695 - });
2696 - return dimensions;
 2690+ var dimensions = { };
 2691+ $w('width height').each(function(d) {
 2692+ var D = d.capitalize();
 2693+ dimensions[d] = self['inner' + D] ||
 2694+ (document.documentElement['client' + D] || document.body['client' + D]);
 2695+ });
 2696+ return dimensions;
26972697 },
26982698
26992699 getWidth: function() {
2700 - return this.getDimensions().width;
 2700+ return this.getDimensions().width;
27012701 },
27022702
27032703 getHeight: function() {
2704 - return this.getDimensions().height;
 2704+ return this.getDimensions().height;
27052705 },
27062706
27072707 getScrollOffsets: function() {
2708 - return Element._returnOffset(
2709 - window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
2710 - window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
 2708+ return Element._returnOffset(
 2709+ window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft,
 2710+ window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
27112711 }
27122712 };
27132713 /* Portions of the Selector class are derived from Jack Slocum’s DomQuery,
@@ -2715,117 +2715,117 @@
27162716
27172717 var Selector = Class.create({
27182718 initialize: function(expression) {
2719 - this.expression = expression.strip();
2720 - this.compileMatcher();
 2719+ this.expression = expression.strip();
 2720+ this.compileMatcher();
27212721 },
27222722
27232723 compileMatcher: function() {
2724 - // Selectors with namespaced attributes can't use the XPath version
2725 - if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression))
2726 - return this.compileXPathMatcher();
 2724+ // Selectors with namespaced attributes can't use the XPath version
 2725+ if (Prototype.BrowserFeatures.XPath && !(/(\[[\w-]*?:|:checked)/).test(this.expression))
 2726+ return this.compileXPathMatcher();
27272727
2728 - var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
2729 - c = Selector.criteria, le, p, m;
 2728+ var e = this.expression, ps = Selector.patterns, h = Selector.handlers,
 2729+ c = Selector.criteria, le, p, m;
27302730
2731 - if (Selector._cache[e]) {
2732 - this.matcher = Selector._cache[e];
2733 - return;
2734 - }
 2731+ if (Selector._cache[e]) {
 2732+ this.matcher = Selector._cache[e];
 2733+ return;
 2734+ }
27352735
2736 - this.matcher = ["this.matcher = function(root) {",
2737 - "var r = root, h = Selector.handlers, c = false, n;"];
 2736+ this.matcher = ["this.matcher = function(root) {",
 2737+ "var r = root, h = Selector.handlers, c = false, n;"];
27382738
2739 - while (e && le != e && (/\S/).test(e)) {
2740 - le = e;
2741 - for (var i in ps) {
2742 - p = ps[i];
2743 - if (m = e.match(p)) {
2744 - this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
2745 - new Template(c[i]).evaluate(m));
2746 - e = e.replace(m[0], '');
2747 - break;
2748 - }
2749 - }
2750 - }
 2739+ while (e && le != e && (/\S/).test(e)) {
 2740+ le = e;
 2741+ for (var i in ps) {
 2742+ p = ps[i];
 2743+ if (m = e.match(p)) {
 2744+ this.matcher.push(Object.isFunction(c[i]) ? c[i](m) :
 2745+ new Template(c[i]).evaluate(m));
 2746+ e = e.replace(m[0], '');
 2747+ break;
 2748+ }
 2749+ }
 2750+ }
27512751
2752 - this.matcher.push("return h.unique(n);\n}");
2753 - eval(this.matcher.join('\n'));
2754 - Selector._cache[this.expression] = this.matcher;
 2752+ this.matcher.push("return h.unique(n);\n}");
 2753+ eval(this.matcher.join('\n'));
 2754+ Selector._cache[this.expression] = this.matcher;
27552755 },
27562756
27572757 compileXPathMatcher: function() {
2758 - var e = this.expression, ps = Selector.patterns,
2759 - x = Selector.xpath, le, m;
 2758+ var e = this.expression, ps = Selector.patterns,
 2759+ x = Selector.xpath, le, m;
27602760
2761 - if (Selector._cache[e]) {
2762 - this.xpath = Selector._cache[e]; return;
2763 - }
 2761+ if (Selector._cache[e]) {
 2762+ this.xpath = Selector._cache[e]; return;
 2763+ }
27642764
2765 - this.matcher = ['.//*'];
2766 - while (e && le != e && (/\S/).test(e)) {
2767 - le = e;
2768 - for (var i in ps) {
2769 - if (m = e.match(ps[i])) {
2770 - this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
2771 - new Template(x[i]).evaluate(m));
2772 - e = e.replace(m[0], '');
2773 - break;
2774 - }
2775 - }
2776 - }
 2765+ this.matcher = ['.//*'];
 2766+ while (e && le != e && (/\S/).test(e)) {
 2767+ le = e;
 2768+ for (var i in ps) {
 2769+ if (m = e.match(ps[i])) {
 2770+ this.matcher.push(Object.isFunction(x[i]) ? x[i](m) :
 2771+ new Template(x[i]).evaluate(m));
 2772+ e = e.replace(m[0], '');
 2773+ break;
 2774+ }
 2775+ }
 2776+ }
27772777
2778 - this.xpath = this.matcher.join('');
2779 - Selector._cache[this.expression] = this.xpath;
 2778+ this.xpath = this.matcher.join('');
 2779+ Selector._cache[this.expression] = this.xpath;
27802780 },
27812781
27822782 findElements: function(root) {
2783 - root = root || document;
2784 - if (this.xpath) return document._getElementsByXPath(this.xpath, root);
2785 - return this.matcher(root);
 2783+ root = root || document;
 2784+ if (this.xpath) return document._getElementsByXPath(this.xpath, root);
 2785+ return this.matcher(root);
27862786 },
27872787
27882788 match: function(element) {
2789 - this.tokens = [];
 2789+ this.tokens = [];
27902790
2791 - var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
2792 - var le, p, m;
 2791+ var e = this.expression, ps = Selector.patterns, as = Selector.assertions;
 2792+ var le, p, m;
27932793
2794 - while (e && le !== e && (/\S/).test(e)) {
2795 - le = e;
2796 - for (var i in ps) {
2797 - p = ps[i];
2798 - if (m = e.match(p)) {
2799 - // use the Selector.assertions methods unless the selector
2800 - // is too complex.
2801 - if (as[i]) {
2802 - this.tokens.push([i, Object.clone(m)]);
2803 - e = e.replace(m[0], '');
2804 - } else {
2805 - // reluctantly do a document-wide search
2806 - // and look for a match in the array
2807 - return this.findElements(document).include(element);
2808 - }
2809 - }
2810 - }
2811 - }
 2794+ while (e && le !== e && (/\S/).test(e)) {
 2795+ le = e;
 2796+ for (var i in ps) {
 2797+ p = ps[i];
 2798+ if (m = e.match(p)) {
 2799+ // use the Selector.assertions methods unless the selector
 2800+ // is too complex.
 2801+ if (as[i]) {
 2802+ this.tokens.push([i, Object.clone(m)]);
 2803+ e = e.replace(m[0], '');
 2804+ } else {
 2805+ // reluctantly do a document-wide search
 2806+ // and look for a match in the array
 2807+ return this.findElements(document).include(element);
 2808+ }
 2809+ }
 2810+ }
 2811+ }
28122812
2813 - var match = true, name, matches;
2814 - for (var i = 0, token; token = this.tokens[i]; i++) {
2815 - name = token[0], matches = token[1];
2816 - if (!Selector.assertions[name](element, matches)) {
2817 - match = false; break;
2818 - }
2819 - }
 2813+ var match = true, name, matches;
 2814+ for (var i = 0, token; token = this.tokens[i]; i++) {
 2815+ name = token[0], matches = token[1];
 2816+ if (!Selector.assertions[name](element, matches)) {
 2817+ match = false; break;
 2818+ }
 2819+ }
28202820
2821 - return match;
 2821+ return match;
28222822 },
28232823
28242824 toString: function() {
2825 - return this.expression;
 2825+ return this.expression;
28262826 },
28272827
28282828 inspect: function() {
2829 - return "#<Selector:" + this.expression.inspect() + ">";
 2829+ return "#<Selector:" + this.expression.inspect() + ">";
28302830 }
28312831 });
28322832
@@ -2833,507 +2833,507 @@
28342834 _cache: { },
28352835
28362836 xpath: {
2837 - descendant: "//*",
2838 - child: "/*",
2839 - adjacent: "/following-sibling::*[1]",
2840 - laterSibling: '/following-sibling::*',
2841 - tagName: function(m) {
2842 - if (m[1] == '*') return '';
2843 - return "[local-name()='" + m[1].toLowerCase() +
2844 - "' or local-name()='" + m[1].toUpperCase() + "']";
2845 - },
2846 - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
2847 - id: "[@id='#{1}']",
2848 - attrPresence: "[@#{1}]",
2849 - attr: function(m) {
2850 - m[3] = m[5] || m[6];
2851 - return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
2852 - },
2853 - pseudo: function(m) {
2854 - var h = Selector.xpath.pseudos[m[1]];
2855 - if (!h) return '';
2856 - if (Object.isFunction(h)) return h(m);
2857 - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
2858 - },
2859 - operators: {
2860 - '=': "[@#{1}='#{3}']",
2861 - '!=': "[@#{1}!='#{3}']",
2862 - '^=': "[starts-with(@#{1}, '#{3}')]",
2863 - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
2864 - '*=': "[contains(@#{1}, '#{3}')]",
2865 - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
2866 - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
2867 - },
2868 - pseudos: {
2869 - 'first-child': '[not(preceding-sibling::*)]',
2870 - 'last-child': '[not(following-sibling::*)]',
2871 - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
2872 - 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
2873 - 'checked': "[@checked]",
2874 - 'disabled': "[@disabled]",
2875 - 'enabled': "[not(@disabled)]",
2876 - 'not': function(m) {
2877 - var e = m[6], p = Selector.patterns,
2878 - x = Selector.xpath, le, m, v;
 2837+ descendant: "//*",
 2838+ child: "/*",
 2839+ adjacent: "/following-sibling::*[1]",
 2840+ laterSibling: '/following-sibling::*',
 2841+ tagName: function(m) {
 2842+ if (m[1] == '*') return '';
 2843+ return "[local-name()='" + m[1].toLowerCase() +
 2844+ "' or local-name()='" + m[1].toUpperCase() + "']";
 2845+ },
 2846+ className: "[contains(concat(' ', @class, ' '), ' #{1} ')]",
 2847+ id: "[@id='#{1}']",
 2848+ attrPresence: "[@#{1}]",
 2849+ attr: function(m) {
 2850+ m[3] = m[5] || m[6];
 2851+ return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
 2852+ },
 2853+ pseudo: function(m) {
 2854+ var h = Selector.xpath.pseudos[m[1]];
 2855+ if (!h) return '';
 2856+ if (Object.isFunction(h)) return h(m);
 2857+ return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
 2858+ },
 2859+ operators: {
 2860+ '=': "[@#{1}='#{3}']",
 2861+ '!=': "[@#{1}!='#{3}']",
 2862+ '^=': "[starts-with(@#{1}, '#{3}')]",
 2863+ '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",
 2864+ '*=': "[contains(@#{1}, '#{3}')]",
 2865+ '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",
 2866+ '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]"
 2867+ },
 2868+ pseudos: {
 2869+ 'first-child': '[not(preceding-sibling::*)]',
 2870+ 'last-child': '[not(following-sibling::*)]',
 2871+ 'only-child': '[not(preceding-sibling::* or following-sibling::*)]',
 2872+ 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",
 2873+ 'checked': "[@checked]",
 2874+ 'disabled': "[@disabled]",
 2875+ 'enabled': "[not(@disabled)]",
 2876+ 'not': function(m) {
 2877+ var e = m[6], p = Selector.patterns,
 2878+ x = Selector.xpath, le, m, v;
28792879
2880 - var exclusion = [];
2881 - while (e && le != e && (/\S/).test(e)) {
2882 - le = e;
2883 - for (var i in p) {
2884 - if (m = e.match(p[i])) {
2885 - v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
2886 - exclusion.push("(" + v.substring(1, v.length - 1) + ")");
2887 - e = e.replace(m[0], '');
2888 - break;
2889 - }
2890 - }
2891 - }
2892 - return "[not(" + exclusion.join(" and ") + ")]";
2893 - },
2894 - 'nth-child': function(m) {
2895 - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
2896 - },
2897 - 'nth-last-child': function(m) {
2898 - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
2899 - },
2900 - 'nth-of-type': function(m) {
2901 - return Selector.xpath.pseudos.nth("position() ", m);
2902 - },
2903 - 'nth-last-of-type': function(m) {
2904 - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
2905 - },
2906 - 'first-of-type': function(m) {
2907 - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
2908 - },
2909 - 'last-of-type': function(m) {
2910 - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
2911 - },
2912 - 'only-of-type': function(m) {
2913 - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
2914 - },
2915 - nth: function(fragment, m) {
2916 - var mm, formula = m[6], predicate;
2917 - if (formula == 'even') formula = '2n+0';
2918 - if (formula == 'odd') formula = '2n+1';
2919 - if (mm = formula.match(/^(\d+)$/)) // digit only
2920 - return '[' + fragment + "= " + mm[1] + ']';
2921 - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
2922 - if (mm[1] == "-") mm[1] = -1;
2923 - var a = mm[1] ? Number(mm[1]) : 1;
2924 - var b = mm[2] ? Number(mm[2]) : 0;
2925 - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
2926 - "((#{fragment} - #{b}) div #{a} >= 0)]";
2927 - return new Template(predicate).evaluate({
2928 - fragment: fragment, a: a, b: b });
2929 - }
2930 - }
2931 - }
 2880+ var exclusion = [];
 2881+ while (e && le != e && (/\S/).test(e)) {
 2882+ le = e;
 2883+ for (var i in p) {
 2884+ if (m = e.match(p[i])) {
 2885+ v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m);
 2886+ exclusion.push("(" + v.substring(1, v.length - 1) + ")");
 2887+ e = e.replace(m[0], '');
 2888+ break;
 2889+ }
 2890+ }
 2891+ }
 2892+ return "[not(" + exclusion.join(" and ") + ")]";
 2893+ },
 2894+ 'nth-child': function(m) {
 2895+ return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m);
 2896+ },
 2897+ 'nth-last-child': function(m) {
 2898+ return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m);
 2899+ },
 2900+ 'nth-of-type': function(m) {
 2901+ return Selector.xpath.pseudos.nth("position() ", m);
 2902+ },
 2903+ 'nth-last-of-type': function(m) {
 2904+ return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m);
 2905+ },
 2906+ 'first-of-type': function(m) {
 2907+ m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m);
 2908+ },
 2909+ 'last-of-type': function(m) {
 2910+ m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m);
 2911+ },
 2912+ 'only-of-type': function(m) {
 2913+ var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m);
 2914+ },
 2915+ nth: function(fragment, m) {
 2916+ var mm, formula = m[6], predicate;
 2917+ if (formula == 'even') formula = '2n+0';
 2918+ if (formula == 'odd') formula = '2n+1';
 2919+ if (mm = formula.match(/^(\d+)$/)) // digit only
 2920+ return '[' + fragment + "= " + mm[1] + ']';
 2921+ if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
 2922+ if (mm[1] == "-") mm[1] = -1;
 2923+ var a = mm[1] ? Number(mm[1]) : 1;
 2924+ var b = mm[2] ? Number(mm[2]) : 0;
 2925+ predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " +
 2926+ "((#{fragment} - #{b}) div #{a} >= 0)]";
 2927+ return new Template(predicate).evaluate({
 2928+ fragment: fragment, a: a, b: b });
 2929+ }
 2930+ }
 2931+ }
29322932 },
29332933
29342934 criteria: {
2935 - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
2936 - className: 'n = h.className(n, r, "#{1}", c); c = false;',
2937 - id: 'n = h.id(n, r, "#{1}", c); c = false;',
2938 - attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
2939 - attr: function(m) {
2940 - m[3] = (m[5] || m[6]);
2941 - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
2942 - },
2943 - pseudo: function(m) {
2944 - if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
2945 - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
2946 - },
2947 - descendant: 'c = "descendant";',
2948 - child: 'c = "child";',
2949 - adjacent: 'c = "adjacent";',
2950 - laterSibling: 'c = "laterSibling";'
 2935+ tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
 2936+ className: 'n = h.className(n, r, "#{1}", c); c = false;',
 2937+ id: 'n = h.id(n, r, "#{1}", c); c = false;',
 2938+ attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
 2939+ attr: function(m) {
 2940+ m[3] = (m[5] || m[6]);
 2941+ return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
 2942+ },
 2943+ pseudo: function(m) {
 2944+ if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
 2945+ return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m);
 2946+ },
 2947+ descendant: 'c = "descendant";',
 2948+ child: 'c = "child";',
 2949+ adjacent: 'c = "adjacent";',
 2950+ laterSibling: 'c = "laterSibling";'
29512951 },
29522952
29532953 patterns: {
2954 - // combinators must be listed first
2955 - // (and descendant needs to be last combinator)
2956 - laterSibling: /^\s*~\s*/,
2957 - child: /^\s*>\s*/,
2958 - adjacent: /^\s*\+\s*/,
2959 - descendant: /^\s/,
 2954+ // combinators must be listed first
 2955+ // (and descendant needs to be last combinator)
 2956+ laterSibling: /^\s*~\s*/,
 2957+ child: /^\s*>\s*/,
 2958+ adjacent: /^\s*\+\s*/,
 2959+ descendant: /^\s/,
29602960
2961 - // selectors follow
2962 - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
2963 - id: /^#([\w\-\*]+)(\b|$)/,
2964 - className: /^\.([\w\-\*]+)(\b|$)/,
2965 - pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,
2966 - attrPresence: /^\[([\w]+)\]/,
2967 - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
 2961+ // selectors follow
 2962+ tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
 2963+ id: /^#([\w\-\*]+)(\b|$)/,
 2964+ className: /^\.([\w\-\*]+)(\b|$)/,
 2965+ pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,
 2966+ attrPresence: /^\[([\w]+)\]/,
 2967+ attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
29682968 },
29692969
29702970 // for Selector.match and Element#match
29712971 assertions: {
2972 - tagName: function(element, matches) {
2973 - return matches[1].toUpperCase() == element.tagName.toUpperCase();
2974 - },
 2972+ tagName: function(element, matches) {
 2973+ return matches[1].toUpperCase() == element.tagName.toUpperCase();
 2974+ },
29752975
2976 - className: function(element, matches) {
2977 - return Element.hasClassName(element, matches[1]);
2978 - },
 2976+ className: function(element, matches) {
 2977+ return Element.hasClassName(element, matches[1]);
 2978+ },
29792979
2980 - id: function(element, matches) {
2981 - return element.id === matches[1];
2982 - },
 2980+ id: function(element, matches) {
 2981+ return element.id === matches[1];
 2982+ },
29832983
2984 - attrPresence: function(element, matches) {
2985 - return Element.hasAttribute(element, matches[1]);
2986 - },
 2984+ attrPresence: function(element, matches) {
 2985+ return Element.hasAttribute(element, matches[1]);
 2986+ },
29872987
2988 - attr: function(element, matches) {
2989 - var nodeValue = Element.readAttribute(element, matches[1]);
2990 - return Selector.operators[matches[2]](nodeValue, matches[3]);
2991 - }
 2988+ attr: function(element, matches) {
 2989+ var nodeValue = Element.readAttribute(element, matches[1]);
 2990+ return Selector.operators[matches[2]](nodeValue, matches[3]);
 2991+ }
29922992 },
29932993
29942994 handlers: {
2995 - // UTILITY FUNCTIONS
2996 - // joins two collections
2997 - concat: function(a, b) {
2998 - for (var i = 0, node; node = b[i]; i++)
2999 - a.push(node);
3000 - return a;
3001 - },
 2995+ // UTILITY FUNCTIONS
 2996+ // joins two collections
 2997+ concat: function(a, b) {
 2998+ for (var i = 0, node; node = b[i]; i++)
 2999+ a.push(node);
 3000+ return a;
 3001+ },
30023002
3003 - // marks an array of nodes for counting
3004 - mark: function(nodes) {
3005 - for (var i = 0, node; node = nodes[i]; i++)
3006 - node._counted = true;
3007 - return nodes;
3008 - },
 3003+ // marks an array of nodes for counting
 3004+ mark: function(nodes) {
 3005+ for (var i = 0, node; node = nodes[i]; i++)
 3006+ node._counted = true;
 3007+ return nodes;
 3008+ },
30093009
3010 - unmark: function(nodes) {
3011 - for (var i = 0, node; node = nodes[i]; i++)
3012 - node._counted = undefined;
3013 - return nodes;
3014 - },
 3010+ unmark: function(nodes) {
 3011+ for (var i = 0, node; node = nodes[i]; i++)
 3012+ node._counted = undefined;
 3013+ return nodes;
 3014+ },
30153015
3016 - // mark each child node with its position (for nth calls)
3017 - // "ofType" flag indicates whether we're indexing for nth-of-type
3018 - // rather than nth-child
3019 - index: function(parentNode, reverse, ofType) {
3020 - parentNode._counted = true;
3021 - if (reverse) {
3022 - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
3023 - var node = nodes[i];
3024 - if (node.nodeType == 1 && (!ofType || (node._counted==true))) node.nodeIndex = j++;
3025 - }
3026 - } else {
3027 - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
3028 - if (node.nodeType == 1 && (!ofType || (node._counted==true))) node.nodeIndex = j++;
3029 - }
3030 - },
 3016+ // mark each child node with its position (for nth calls)
 3017+ // "ofType" flag indicates whether we're indexing for nth-of-type
 3018+ // rather than nth-child
 3019+ index: function(parentNode, reverse, ofType) {
 3020+ parentNode._counted = true;
 3021+ if (reverse) {
 3022+ for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
 3023+ var node = nodes[i];
 3024+ if (node.nodeType == 1 && (!ofType || (node._counted==true))) node.nodeIndex = j++;
 3025+ }
 3026+ } else {
 3027+ for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
 3028+ if (node.nodeType == 1 && (!ofType || (node._counted==true))) node.nodeIndex = j++;
 3029+ }
 3030+ },
30313031
3032 - // filters out duplicates and extends all nodes
3033 - unique: function(nodes) {
3034 - if (nodes.length == 0) return nodes;
3035 - var results = [], n;
3036 - for (var i = 0, l = nodes.length; i < l; i++)
3037 - if ((n = nodes[i])._counted != true) {
3038 - n._counted = true;
3039 - results.push(Element.extend(n));
3040 - }
3041 - return Selector.handlers.unmark(results);
3042 - },
 3032+ // filters out duplicates and extends all nodes
 3033+ unique: function(nodes) {
 3034+ if (nodes.length == 0) return nodes;
 3035+ var results = [], n;
 3036+ for (var i = 0, l = nodes.length; i < l; i++)
 3037+ if ((n = nodes[i])._counted != true) {
 3038+ n._counted = true;
 3039+ results.push(Element.extend(n));
 3040+ }
 3041+ return Selector.handlers.unmark(results);
 3042+ },
30433043
3044 - // COMBINATOR FUNCTIONS
3045 - descendant: function(nodes) {
3046 - var h = Selector.handlers;
3047 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3048 - h.concat(results, node.getElementsByTagName('*'));
3049 - return results;
3050 - },
 3044+ // COMBINATOR FUNCTIONS
 3045+ descendant: function(nodes) {
 3046+ var h = Selector.handlers;
 3047+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3048+ h.concat(results, node.getElementsByTagName('*'));
 3049+ return results;
 3050+ },
30513051
3052 - child: function(nodes) {
3053 - var h = Selector.handlers;
3054 - for (var i = 0, results = [], node; node = nodes[i]; i++) {
3055 - for (var j = 0, children = [], child; child = node.childNodes[j]; j++)
3056 - if (child.nodeType == 1 && child.tagName != '!') results.push(child);
3057 - }
3058 - return results;
3059 - },
 3052+ child: function(nodes) {
 3053+ var h = Selector.handlers;
 3054+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
 3055+ for (var j = 0, children = [], child; child = node.childNodes[j]; j++)
 3056+ if (child.nodeType == 1 && child.tagName != '!') results.push(child);
 3057+ }
 3058+ return results;
 3059+ },
30603060
3061 - adjacent: function(nodes) {
3062 - for (var i = 0, results = [], node; node = nodes[i]; i++) {
3063 - var next = this.nextElementSibling(node);
3064 - if (next) results.push(next);
3065 - }
3066 - return results;
3067 - },
 3061+ adjacent: function(nodes) {
 3062+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
 3063+ var next = this.nextElementSibling(node);
 3064+ if (next) results.push(next);
 3065+ }
 3066+ return results;
 3067+ },
30683068
3069 - laterSibling: function(nodes) {
3070 - var h = Selector.handlers;
3071 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3072 - h.concat(results, Element.nextSiblings(node));
3073 - return results;
3074 - },
 3069+ laterSibling: function(nodes) {
 3070+ var h = Selector.handlers;
 3071+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3072+ h.concat(results, Element.nextSiblings(node));
 3073+ return results;
 3074+ },
30753075
3076 - nextElementSibling: function(node) {
3077 - while (node = node.nextSibling)
3078 - if (node.nodeType == 1) return node;
3079 - return null;
3080 - },
 3076+ nextElementSibling: function(node) {
 3077+ while (node = node.nextSibling)
 3078+ if (node.nodeType == 1) return node;
 3079+ return null;
 3080+ },
30813081
3082 - previousElementSibling: function(node) {
3083 - while (node = node.previousSibling)
3084 - if (node.nodeType == 1) return node;
3085 - return null;
3086 - },
 3082+ previousElementSibling: function(node) {
 3083+ while (node = node.previousSibling)
 3084+ if (node.nodeType == 1) return node;
 3085+ return null;
 3086+ },
30873087
3088 - // TOKEN FUNCTIONS
3089 - tagName: function(nodes, root, tagName, combinator) {
3090 - tagName = tagName.toUpperCase();
3091 - var results = [], h = Selector.handlers;
3092 - if (nodes) {
3093 - if (combinator) {
3094 - // fastlane for ordinary descendant combinators
3095 - if (combinator == "descendant") {
3096 - for (var i = 0, node; node = nodes[i]; i++)
3097 - h.concat(results, node.getElementsByTagName(tagName));
3098 - return results;
3099 - } else nodes = this[combinator](nodes);
3100 - if (tagName == "*") return nodes;
3101 - }
3102 - for (var i = 0, node; node = nodes[i]; i++)
3103 - if (node.tagName.toUpperCase() == tagName) results.push(node);
3104 - return results;
3105 - } else return root.getElementsByTagName(tagName);
3106 - },
 3088+ // TOKEN FUNCTIONS
 3089+ tagName: function(nodes, root, tagName, combinator) {
 3090+ tagName = tagName.toUpperCase();
 3091+ var results = [], h = Selector.handlers;
 3092+ if (nodes) {
 3093+ if (combinator) {
 3094+ // fastlane for ordinary descendant combinators
 3095+ if (combinator == "descendant") {
 3096+ for (var i = 0, node; node = nodes[i]; i++)
 3097+ h.concat(results, node.getElementsByTagName(tagName));
 3098+ return results;
 3099+ } else nodes = this[combinator](nodes);
 3100+ if (tagName == "*") return nodes;
 3101+ }
 3102+ for (var i = 0, node; node = nodes[i]; i++)
 3103+ if (node.tagName.toUpperCase() == tagName) results.push(node);
 3104+ return results;
 3105+ } else return root.getElementsByTagName(tagName);
 3106+ },
31073107
3108 - id: function(nodes, root, id, combinator) {
3109 - var targetNode = $(id), h = Selector.handlers;
3110 - if (!targetNode) return [];
3111 - if (!nodes && root == document) return [targetNode];
3112 - if (nodes) {
3113 - if (combinator) {
3114 - if (combinator == 'child') {
3115 - for (var i = 0, node; node = nodes[i]; i++)
3116 - if (targetNode.parentNode == node) return [targetNode];
3117 - } else if (combinator == 'descendant') {
3118 - for (var i = 0, node; node = nodes[i]; i++)
3119 - if (Element.descendantOf(targetNode, node)) return [targetNode];
3120 - } else if (combinator == 'adjacent') {
3121 - for (var i = 0, node; node = nodes[i]; i++)
3122 - if (Selector.handlers.previousElementSibling(targetNode) == node)
3123 - return [targetNode];
3124 - } else nodes = h[combinator](nodes);
3125 - }
3126 - for (var i = 0, node; node = nodes[i]; i++)
3127 - if (node == targetNode) return [targetNode];
3128 - return [];
3129 - }
3130 - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
3131 - },
 3108+ id: function(nodes, root, id, combinator) {
 3109+ var targetNode = $(id), h = Selector.handlers;
 3110+ if (!targetNode) return [];
 3111+ if (!nodes && root == document) return [targetNode];
 3112+ if (nodes) {
 3113+ if (combinator) {
 3114+ if (combinator == 'child') {
 3115+ for (var i = 0, node; node = nodes[i]; i++)
 3116+ if (targetNode.parentNode == node) return [targetNode];
 3117+ } else if (combinator == 'descendant') {
 3118+ for (var i = 0, node; node = nodes[i]; i++)
 3119+ if (Element.descendantOf(targetNode, node)) return [targetNode];
 3120+ } else if (combinator == 'adjacent') {
 3121+ for (var i = 0, node; node = nodes[i]; i++)
 3122+ if (Selector.handlers.previousElementSibling(targetNode) == node)
 3123+ return [targetNode];
 3124+ } else nodes = h[combinator](nodes);
 3125+ }
 3126+ for (var i = 0, node; node = nodes[i]; i++)
 3127+ if (node == targetNode) return [targetNode];
 3128+ return [];
 3129+ }
 3130+ return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : [];
 3131+ },
31323132
3133 - className: function(nodes, root, className, combinator) {
3134 - if (nodes && combinator) nodes = this[combinator](nodes);
3135 - return Selector.handlers.byClassName(nodes, root, className);
3136 - },
 3133+ className: function(nodes, root, className, combinator) {
 3134+ if (nodes && combinator) nodes = this[combinator](nodes);
 3135+ return Selector.handlers.byClassName(nodes, root, className);
 3136+ },
31373137
3138 - byClassName: function(nodes, root, className) {
3139 - if (!nodes) nodes = Selector.handlers.descendant([root]);
3140 - var needle = ' ' + className + ' ';
3141 - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
3142 - nodeClassName = node.className;
3143 - if (nodeClassName.length == 0) continue;
3144 - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
3145 - results.push(node);
3146 - }
3147 - return results;
3148 - },
 3138+ byClassName: function(nodes, root, className) {
 3139+ if (!nodes) nodes = Selector.handlers.descendant([root]);
 3140+ var needle = ' ' + className + ' ';
 3141+ for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) {
 3142+ nodeClassName = node.className;
 3143+ if (nodeClassName.length == 0) continue;
 3144+ if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle))
 3145+ results.push(node);
 3146+ }
 3147+ return results;
 3148+ },
31493149
3150 - attrPresence: function(nodes, root, attr) {
3151 - if (!nodes) nodes = root.getElementsByTagName("*");
3152 - var results = [];
3153 - for (var i = 0, node; node = nodes[i]; i++)
3154 - if (Element.hasAttribute(node, attr)) results.push(node);
3155 - return results;
3156 - },
 3150+ attrPresence: function(nodes, root, attr) {
 3151+ if (!nodes) nodes = root.getElementsByTagName("*");
 3152+ var results = [];
 3153+ for (var i = 0, node; node = nodes[i]; i++)
 3154+ if (Element.hasAttribute(node, attr)) results.push(node);
 3155+ return results;
 3156+ },
31573157
3158 - attr: function(nodes, root, attr, value, operator) {
3159 - if (!nodes) nodes = root.getElementsByTagName("*");
3160 - var handler = Selector.operators[operator], results = [];
3161 - for (var i = 0, node; node = nodes[i]; i++) {
3162 - var nodeValue = Element.readAttribute(node, attr);
3163 - if (nodeValue === null) continue;
3164 - if (handler(nodeValue, value)) results.push(node);
3165 - }
3166 - return results;
3167 - },
 3158+ attr: function(nodes, root, attr, value, operator) {
 3159+ if (!nodes) nodes = root.getElementsByTagName("*");
 3160+ var handler = Selector.operators[operator], results = [];
 3161+ for (var i = 0, node; node = nodes[i]; i++) {
 3162+ var nodeValue = Element.readAttribute(node, attr);
 3163+ if (nodeValue === null) continue;
 3164+ if (handler(nodeValue, value)) results.push(node);
 3165+ }
 3166+ return results;
 3167+ },
31683168
3169 - pseudo: function(nodes, name, value, root, combinator) {
3170 - if (nodes && combinator) nodes = this[combinator](nodes);
3171 - if (!nodes) nodes = root.getElementsByTagName("*");
3172 - return Selector.pseudos[name](nodes, value, root);
3173 - }
 3169+ pseudo: function(nodes, name, value, root, combinator) {
 3170+ if (nodes && combinator) nodes = this[combinator](nodes);
 3171+ if (!nodes) nodes = root.getElementsByTagName("*");
 3172+ return Selector.pseudos[name](nodes, value, root);
 3173+ }
31743174 },
31753175
31763176 pseudos: {
3177 - 'first-child': function(nodes, value, root) {
3178 - for (var i = 0, results = [], node; node = nodes[i]; i++) {
3179 - if (Selector.handlers.previousElementSibling(node)) continue;
3180 - results.push(node);
3181 - }
3182 - return results;
3183 - },
3184 - 'last-child': function(nodes, value, root) {
3185 - for (var i = 0, results = [], node; node = nodes[i]; i++) {
3186 - if (Selector.handlers.nextElementSibling(node)) continue;
3187 - results.push(node);
3188 - }
3189 - return results;
3190 - },
3191 - 'only-child': function(nodes, value, root) {
3192 - var h = Selector.handlers;
3193 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3194 - if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
3195 - results.push(node);
3196 - return results;
3197 - },
3198 - 'nth-child': function(nodes, formula, root) {
3199 - return Selector.pseudos.nth(nodes, formula, root);
3200 - },
3201 - 'nth-last-child': function(nodes, formula, root) {
3202 - return Selector.pseudos.nth(nodes, formula, root, true);
3203 - },
3204 - 'nth-of-type': function(nodes, formula, root) {
3205 - return Selector.pseudos.nth(nodes, formula, root, false, true);
3206 - },
3207 - 'nth-last-of-type': function(nodes, formula, root) {
3208 - return Selector.pseudos.nth(nodes, formula, root, true, true);
3209 - },
3210 - 'first-of-type': function(nodes, formula, root) {
3211 - return Selector.pseudos.nth(nodes, "1", root, false, true);
3212 - },
3213 - 'last-of-type': function(nodes, formula, root) {
3214 - return Selector.pseudos.nth(nodes, "1", root, true, true);
3215 - },
3216 - 'only-of-type': function(nodes, formula, root) {
3217 - var p = Selector.pseudos;
3218 - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
3219 - },
 3177+ 'first-child': function(nodes, value, root) {
 3178+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
 3179+ if (Selector.handlers.previousElementSibling(node)) continue;
 3180+ results.push(node);
 3181+ }
 3182+ return results;
 3183+ },
 3184+ 'last-child': function(nodes, value, root) {
 3185+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
 3186+ if (Selector.handlers.nextElementSibling(node)) continue;
 3187+ results.push(node);
 3188+ }
 3189+ return results;
 3190+ },
 3191+ 'only-child': function(nodes, value, root) {
 3192+ var h = Selector.handlers;
 3193+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3194+ if (!h.previousElementSibling(node) && !h.nextElementSibling(node))
 3195+ results.push(node);
 3196+ return results;
 3197+ },
 3198+ 'nth-child': function(nodes, formula, root) {
 3199+ return Selector.pseudos.nth(nodes, formula, root);
 3200+ },
 3201+ 'nth-last-child': function(nodes, formula, root) {
 3202+ return Selector.pseudos.nth(nodes, formula, root, true);
 3203+ },
 3204+ 'nth-of-type': function(nodes, formula, root) {
 3205+ return Selector.pseudos.nth(nodes, formula, root, false, true);
 3206+ },
 3207+ 'nth-last-of-type': function(nodes, formula, root) {
 3208+ return Selector.pseudos.nth(nodes, formula, root, true, true);
 3209+ },
 3210+ 'first-of-type': function(nodes, formula, root) {
 3211+ return Selector.pseudos.nth(nodes, "1", root, false, true);
 3212+ },
 3213+ 'last-of-type': function(nodes, formula, root) {
 3214+ return Selector.pseudos.nth(nodes, "1", root, true, true);
 3215+ },
 3216+ 'only-of-type': function(nodes, formula, root) {
 3217+ var p = Selector.pseudos;
 3218+ return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root);
 3219+ },
32203220
3221 - // handles the an+b logic
3222 - getIndices: function(a, b, total) {
3223 - if (a == 0) return b > 0 ? [b] : [];
3224 - return $R(1, total).inject([], function(memo, i) {
3225 - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
3226 - return memo;
3227 - });
3228 - },
 3221+ // handles the an+b logic
 3222+ getIndices: function(a, b, total) {
 3223+ if (a == 0) return b > 0 ? [b] : [];
 3224+ return $R(1, total).inject([], function(memo, i) {
 3225+ if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i);
 3226+ return memo;
 3227+ });
 3228+ },
32293229
3230 - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
3231 - nth: function(nodes, formula, root, reverse, ofType) {
3232 - if (nodes.length == 0) return [];
3233 - if (formula == 'even') formula = '2n+0';
3234 - if (formula == 'odd') formula = '2n+1';
3235 - var h = Selector.handlers, results = [], indexed = [], m;
3236 - h.mark(nodes);
3237 - for (var i = 0, node; node = nodes[i]; i++) {
3238 - if (node.parentNode._counted != true) {
3239 - h.index(node.parentNode, reverse, ofType);
3240 - indexed.push(node.parentNode);
3241 - }
3242 - }
3243 - if (formula.match(/^\d+$/)) { // just a number
3244 - formula = Number(formula);
3245 - for (var i = 0, node; node = nodes[i]; i++)
3246 - if (node.nodeIndex == formula) results.push(node);
3247 - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
3248 - if (m[1] == "-") m[1] = -1;
3249 - var a = m[1] ? Number(m[1]) : 1;
3250 - var b = m[2] ? Number(m[2]) : 0;
3251 - var indices = Selector.pseudos.getIndices(a, b, nodes.length);
3252 - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
3253 - for (var j = 0; j < l; j++)
3254 - if (node.nodeIndex == indices[j]) results.push(node);
3255 - }
3256 - }
3257 - h.unmark(nodes);
3258 - h.unmark(indexed);
3259 - return results;
3260 - },
 3230+ // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type
 3231+ nth: function(nodes, formula, root, reverse, ofType) {
 3232+ if (nodes.length == 0) return [];
 3233+ if (formula == 'even') formula = '2n+0';
 3234+ if (formula == 'odd') formula = '2n+1';
 3235+ var h = Selector.handlers, results = [], indexed = [], m;
 3236+ h.mark(nodes);
 3237+ for (var i = 0, node; node = nodes[i]; i++) {
 3238+ if (node.parentNode._counted != true) {
 3239+ h.index(node.parentNode, reverse, ofType);
 3240+ indexed.push(node.parentNode);
 3241+ }
 3242+ }
 3243+ if (formula.match(/^\d+$/)) { // just a number
 3244+ formula = Number(formula);
 3245+ for (var i = 0, node; node = nodes[i]; i++)
 3246+ if (node.nodeIndex == formula) results.push(node);
 3247+ } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
 3248+ if (m[1] == "-") m[1] = -1;
 3249+ var a = m[1] ? Number(m[1]) : 1;
 3250+ var b = m[2] ? Number(m[2]) : 0;
 3251+ var indices = Selector.pseudos.getIndices(a, b, nodes.length);
 3252+ for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
 3253+ for (var j = 0; j < l; j++)
 3254+ if (node.nodeIndex == indices[j]) results.push(node);
 3255+ }
 3256+ }
 3257+ h.unmark(nodes);
 3258+ h.unmark(indexed);
 3259+ return results;
 3260+ },
32613261
3262 - 'empty': function(nodes, value, root) {
3263 - for (var i = 0, results = [], node; node = nodes[i]; i++) {
3264 - // IE treats comments as element nodes
3265 - if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
3266 - results.push(node);
3267 - }
3268 - return results;
3269 - },
 3262+ 'empty': function(nodes, value, root) {
 3263+ for (var i = 0, results = [], node; node = nodes[i]; i++) {
 3264+ // IE treats comments as element nodes
 3265+ if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue;
 3266+ results.push(node);
 3267+ }
 3268+ return results;
 3269+ },
32703270
3271 - 'not': function(nodes, selector, root) {
3272 - var h = Selector.handlers, selectorType, m;
3273 - var exclusions = new Selector(selector).findElements(root);
3274 - h.mark(exclusions);
3275 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3276 - if (node._counted!=true) results.push(node);
3277 - h.unmark(exclusions);
3278 - return results;
3279 - },
 3271+ 'not': function(nodes, selector, root) {
 3272+ var h = Selector.handlers, selectorType, m;
 3273+ var exclusions = new Selector(selector).findElements(root);
 3274+ h.mark(exclusions);
 3275+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3276+ if (node._counted!=true) results.push(node);
 3277+ h.unmark(exclusions);
 3278+ return results;
 3279+ },
32803280
3281 - 'enabled': function(nodes, value, root) {
3282 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3283 - if (!node.disabled) results.push(node);
3284 - return results;
3285 - },
 3281+ 'enabled': function(nodes, value, root) {
 3282+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3283+ if (!node.disabled) results.push(node);
 3284+ return results;
 3285+ },
32863286
3287 - 'disabled': function(nodes, value, root) {
3288 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3289 - if (node.disabled) results.push(node);
3290 - return results;
3291 - },
 3287+ 'disabled': function(nodes, value, root) {
 3288+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3289+ if (node.disabled) results.push(node);
 3290+ return results;
 3291+ },
32923292
3293 - 'checked': function(nodes, value, root) {
3294 - for (var i = 0, results = [], node; node = nodes[i]; i++)
3295 - if (node.checked) results.push(node);
3296 - return results;
3297 - }
 3293+ 'checked': function(nodes, value, root) {
 3294+ for (var i = 0, results = [], node; node = nodes[i]; i++)
 3295+ if (node.checked) results.push(node);
 3296+ return results;
 3297+ }
32983298 },
32993299
33003300 operators: {
3301 - '=': function(nv, v) { return nv == v; },
3302 - '!=': function(nv, v) { return nv != v; },
3303 - '^=': function(nv, v) { return nv.startsWith(v); },
3304 - '$=': function(nv, v) { return nv.endsWith(v); },
3305 - '*=': function(nv, v) { return nv.include(v); },
3306 - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
3307 - '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
 3301+ '=': function(nv, v) { return nv == v; },
 3302+ '!=': function(nv, v) { return nv != v; },
 3303+ '^=': function(nv, v) { return nv.startsWith(v); },
 3304+ '$=': function(nv, v) { return nv.endsWith(v); },
 3305+ '*=': function(nv, v) { return nv.include(v); },
 3306+ '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); },
 3307+ '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
33083308 },
33093309
33103310 matchElements: function(elements, expression) {
3311 - var matches = new Selector(expression).findElements(), h = Selector.handlers;
3312 - h.mark(matches);
3313 - for (var i = 0, results = [], element; element = elements[i]; i++)
3314 - //TS: does not work in IE: if (element._counted) results.push(element);
3315 - if (element._counted == true) results.push(element);
3316 - h.unmark(matches);
3317 - return results;
 3311+ var matches = new Selector(expression).findElements(), h = Selector.handlers;
 3312+ h.mark(matches);
 3313+ for (var i = 0, results = [], element; element = elements[i]; i++)
 3314+ //TS: does not work in IE: if (element._counted) results.push(element);
 3315+ if (element._counted == true) results.push(element);
 3316+ h.unmark(matches);
 3317+ return results;
33183318 },
33193319
33203320 findElement: function(elements, expression, index) {
3321 - if (Object.isNumber(expression)) {
3322 - index = expression; expression = false;
3323 - }
3324 - return Selector.matchElements(elements, expression || '*')[index || 0];
 3321+ if (Object.isNumber(expression)) {
 3322+ index = expression; expression = false;
 3323+ }
 3324+ return Selector.matchElements(elements, expression || '*')[index || 0];
33253325 },
33263326
33273327 findChildElements: function(element, expressions) {
3328 - var exprs = expressions.join(','), expressions = [];
3329 - exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
3330 - expressions.push(m[1].strip());
3331 - });
3332 - var results = [], h = Selector.handlers;
3333 - for (var i = 0, l = expressions.length, selector; i < l; i++) {
3334 - selector = new Selector(expressions[i].strip());
3335 - h.concat(results, selector.findElements(element));
3336 - }
3337 - return (l > 1) ? h.unique(results) : results;
 3328+ var exprs = expressions.join(','), expressions = [];
 3329+ exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
 3330+ expressions.push(m[1].strip());
 3331+ });
 3332+ var results = [], h = Selector.handlers;
 3333+ for (var i = 0, l = expressions.length, selector; i < l; i++) {
 3334+ selector = new Selector(expressions[i].strip());
 3335+ h.concat(results, selector.findElements(element));
 3336+ }
 3337+ return (l > 1) ? h.unique(results) : results;
33383338 }
33393339 });
33403340
@@ -3342,113 +3342,113 @@
33433343 }
33443344 var Form = {
33453345 reset: function(form) {
3346 - $(form).reset();
3347 - return form;
 3346+ $(form).reset();
 3347+ return form;
33483348 },
33493349
33503350 serializeElements: function(elements, options) {
3351 - if (typeof options != 'object') options = { hash: !!options };
3352 - else if (options.hash === undefined) options.hash = true;
3353 - var key, value, submitted = false, submit = options.submit;
 3351+ if (typeof options != 'object') options = { hash: !!options };
 3352+ else if (options.hash === undefined) options.hash = true;
 3353+ var key, value, submitted = false, submit = options.submit;
33543354
3355 - var data = elements.inject({ }, function(result, element) {
3356 - if (!element.disabled && element.name) {
3357 - key = element.name; value = $(element).getValue();
3358 - if (value != null && (element.type != 'submit' || (!submitted &&
3359 - submit !== false && (!submit || key == submit) && (submitted = true)))) {
3360 - if (key in result) {
3361 - // a key is already present; construct an array of values
3362 - if (!Object.isArray(result[key])) result[key] = [result[key]];
3363 - result[key].push(value);
3364 - }
3365 - else result[key] = value;
3366 - }
3367 - }
3368 - return result;
3369 - });
 3355+ var data = elements.inject({ }, function(result, element) {
 3356+ if (!element.disabled && element.name) {
 3357+ key = element.name; value = $(element).getValue();
 3358+ if (value != null && (element.type != 'submit' || (!submitted &&
 3359+ submit !== false && (!submit || key == submit) && (submitted = true)))) {
 3360+ if (key in result) {
 3361+ // a key is already present; construct an array of values
 3362+ if (!Object.isArray(result[key])) result[key] = [result[key]];
 3363+ result[key].push(value);
 3364+ }
 3365+ else result[key] = value;
 3366+ }
 3367+ }
 3368+ return result;
 3369+ });
33703370
3371 - return options.hash ? data : Object.toQueryString(data);
 3371+ return options.hash ? data : Object.toQueryString(data);
33723372 }
33733373 };
33743374
33753375 Form.Methods = {
33763376 serialize: function(form, options) {
3377 - return Form.serializeElements(Form.getElements(form), options);
 3377+ return Form.serializeElements(Form.getElements(form), options);
33783378 },
33793379
33803380 getElements: function(form) {
3381 - return $A($(form).getElementsByTagName('*')).inject([],
3382 - function(elements, child) {
3383 - if (Form.Element.Serializers[child.tagName.toLowerCase()])
3384 - elements.push(Element.extend(child));
3385 - return elements;
3386 - }
3387 - );
 3381+ return $A($(form).getElementsByTagName('*')).inject([],
 3382+ function(elements, child) {
 3383+ if (Form.Element.Serializers[child.tagName.toLowerCase()])
 3384+ elements.push(Element.extend(child));
 3385+ return elements;
 3386+ }
 3387+ );
33883388 },
33893389
33903390 getInputs: function(form, typeName, name) {
3391 - form = $(form);
3392 - var inputs = form.getElementsByTagName('input');
 3391+ form = $(form);
 3392+ var inputs = form.getElementsByTagName('input');
33933393
3394 - if (!typeName && !name) return $A(inputs).map(Element.extend);
 3394+ if (!typeName && !name) return $A(inputs).map(Element.extend);
33953395
3396 - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
3397 - var input = inputs[i];
3398 - if ((typeName && input.type != typeName) || (name && input.name != name))
3399 - continue;
3400 - matchingInputs.push(Element.extend(input));
3401 - }
 3396+ for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) {
 3397+ var input = inputs[i];
 3398+ if ((typeName && input.type != typeName) || (name && input.name != name))
 3399+ continue;
 3400+ matchingInputs.push(Element.extend(input));
 3401+ }
34023402
3403 - return matchingInputs;
 3403+ return matchingInputs;
34043404 },
34053405
34063406 disable: function(form) {
3407 - form = $(form);
3408 - Form.getElements(form).invoke('disable');
3409 - return form;
 3407+ form = $(form);
 3408+ Form.getElements(form).invoke('disable');
 3409+ return form;
34103410 },
34113411
34123412 enable: function(form) {
3413 - form = $(form);
3414 - Form.getElements(form).invoke('enable');
3415 - return form;
 3413+ form = $(form);
 3414+ Form.getElements(form).invoke('enable');
 3415+ return form;
34163416 },
34173417
34183418 findFirstElement: function(form) {
3419 - var elements = $(form).getElements().findAll(function(element) {
3420 - return 'hidden' != element.type && !element.disabled;
3421 - });
3422 - var firstByIndex = elements.findAll(function(element) {
3423 - return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
3424 - }).sortBy(function(element) { return element.tabIndex }).first();
 3419+ var elements = $(form).getElements().findAll(function(element) {
 3420+ return 'hidden' != element.type && !element.disabled;
 3421+ });
 3422+ var firstByIndex = elements.findAll(function(element) {
 3423+ return element.hasAttribute('tabIndex') && element.tabIndex >= 0;
 3424+ }).sortBy(function(element) { return element.tabIndex }).first();
34253425
3426 - return firstByIndex ? firstByIndex : elements.find(function(element) {
3427 - return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
3428 - });
 3426+ return firstByIndex ? firstByIndex : elements.find(function(element) {
 3427+ return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
 3428+ });
34293429 },
34303430
34313431 focusFirstElement: function(form) {
3432 - form = $(form);
3433 - form.findFirstElement().activate();
3434 - return form;
 3432+ form = $(form);
 3433+ form.findFirstElement().activate();
 3434+ return form;
34353435 },
34363436
34373437 request: function(form, options) {
3438 - form = $(form), options = Object.clone(options || { });
 3438+ form = $(form), options = Object.clone(options || { });
34393439
3440 - var params = options.parameters, action = form.readAttribute('action') || '';
3441 - if (action.blank()) action = window.location.href;
3442 - options.parameters = form.serialize(true);
 3440+ var params = options.parameters, action = form.readAttribute('action') || '';
 3441+ if (action.blank()) action = window.location.href;
 3442+ options.parameters = form.serialize(true);
34433443
3444 - if (params) {
3445 - if (Object.isString(params)) params = params.toQueryParams();
3446 - Object.extend(options.parameters, params);
3447 - }
 3444+ if (params) {
 3445+ if (Object.isString(params)) params = params.toQueryParams();
 3446+ Object.extend(options.parameters, params);
 3447+ }
34483448
3449 - if (form.hasAttribute('method') && !options.method)
3450 - options.method = form.method;
 3449+ if (form.hasAttribute('method') && !options.method)
 3450+ options.method = form.method;
34513451
3452 - return new Ajax.Request(action, options);
 3452+ return new Ajax.Request(action, options);
34533453 }
34543454 };
34553455
@@ -3456,74 +3456,74 @@
34573457
34583458 Form.Element = {
34593459 focus: function(element) {
3460 - $(element).focus();
3461 - return element;
 3460+ $(element).focus();
 3461+ return element;
34623462 },
34633463
34643464 select: function(element) {
3465 - $(element).select();
3466 - return element;
 3465+ $(element).select();
 3466+ return element;
34673467 }
34683468 };
34693469
34703470 Form.Element.Methods = {
34713471 serialize: function(element) {
3472 - element = $(element);
3473 - if (!element.disabled && element.name) {
3474 - var value = element.getValue();
3475 - if (value != undefined) {
3476 - var pair = { };
3477 - pair[element.name] = value;
3478 - return Object.toQueryString(pair);
3479 - }
3480 - }
3481 - return '';
 3472+ element = $(element);
 3473+ if (!element.disabled && element.name) {
 3474+ var value = element.getValue();
 3475+ if (value != undefined) {
 3476+ var pair = { };
 3477+ pair[element.name] = value;
 3478+ return Object.toQueryString(pair);
 3479+ }
 3480+ }
 3481+ return '';
34823482 },
34833483
34843484 getValue: function(element) {
3485 - element = $(element);
3486 - var method = element.tagName.toLowerCase();
3487 - return Form.Element.Serializers[method](element);
 3485+ element = $(element);
 3486+ var method = element.tagName.toLowerCase();
 3487+ return Form.Element.Serializers[method](element);
34883488 },
34893489
34903490 setValue: function(element, value) {
3491 - element = $(element);
3492 - var method = element.tagName.toLowerCase();
3493 - Form.Element.Serializers[method](element, value);
3494 - return element;
 3491+ element = $(element);
 3492+ var method = element.tagName.toLowerCase();
 3493+ Form.Element.Serializers[method](element, value);
 3494+ return element;
34953495 },
34963496
34973497 clear: function(element) {
3498 - $(element).value = '';
3499 - return element;
 3498+ $(element).value = '';
 3499+ return element;
35003500 },
35013501
35023502 present: function(element) {
3503 - return $(element).value != '';
 3503+ return $(element).value != '';
35043504 },
35053505
35063506 activate: function(element) {
3507 - element = $(element);
3508 - try {
3509 - element.focus();
3510 - if (element.select && (element.tagName.toLowerCase() != 'input' ||
3511 - !['button', 'reset', 'submit'].include(element.type)))
3512 - element.select();
3513 - } catch (e) { }
3514 - return element;
 3507+ element = $(element);
 3508+ try {
 3509+ element.focus();
 3510+ if (element.select && (element.tagName.toLowerCase() != 'input' ||
 3511+ !['button', 'reset', 'submit'].include(element.type)))
 3512+ element.select();
 3513+ } catch (e) { }
 3514+ return element;
35153515 },
35163516
35173517 disable: function(element) {
3518 - element = $(element);
3519 - element.blur();
3520 - element.disabled = true;
3521 - return element;
 3518+ element = $(element);
 3519+ element.blur();
 3520+ element.disabled = true;
 3521+ return element;
35223522 },
35233523
35243524 enable: function(element) {
3525 - element = $(element);
3526 - element.disabled = false;
3527 - return element;
 3525+ element = $(element);
 3526+ element.disabled = false;
 3527+ return element;
35283528 }
35293529 };
35303530
@@ -3536,64 +3536,64 @@
35373537
35383538 Form.Element.Serializers = {
35393539 input: function(element, value) {
3540 - switch (element.type.toLowerCase()) {
3541 - case 'checkbox':
3542 - case 'radio':
3543 - return Form.Element.Serializers.inputSelector(element, value);
3544 - default:
3545 - return Form.Element.Serializers.textarea(element, value);
3546 - }
 3540+ switch (element.type.toLowerCase()) {
 3541+ case 'checkbox':
 3542+ case 'radio':
 3543+ return Form.Element.Serializers.inputSelector(element, value);
 3544+ default:
 3545+ return Form.Element.Serializers.textarea(element, value);
 3546+ }
35473547 },
35483548
35493549 inputSelector: function(element, value) {
3550 - if (value === undefined) return element.checked ? element.value : null;
3551 - else element.checked = !!value;
 3550+ if (value === undefined) return element.checked ? element.value : null;
 3551+ else element.checked = !!value;
35523552 },
35533553
35543554 textarea: function(element, value) {
3555 - if (value === undefined) return element.value;
3556 - else element.value = value;
 3555+ if (value === undefined) return element.value;
 3556+ else element.value = value;
35573557 },
35583558
35593559 select: function(element, index) {
3560 - if (index === undefined)
3561 - return this[element.type == 'select-one' ?
3562 - 'selectOne' : 'selectMany'](element);
3563 - else {
3564 - var opt, value, single = !Object.isArray(index);
3565 - for (var i = 0, length = element.length; i < length; i++) {
3566 - opt = element.options[i];
3567 - value = this.optionValue(opt);
3568 - if (single) {
3569 - if (value == index) {
3570 - opt.selected = true;
3571 - return;
3572 - }
3573 - }
3574 - else opt.selected = index.include(value);
3575 - }
3576 - }
 3560+ if (index === undefined)
 3561+ return this[element.type == 'select-one' ?
 3562+ 'selectOne' : 'selectMany'](element);
 3563+ else {
 3564+ var opt, value, single = !Object.isArray(index);
 3565+ for (var i = 0, length = element.length; i < length; i++) {
 3566+ opt = element.options[i];
 3567+ value = this.optionValue(opt);
 3568+ if (single) {
 3569+ if (value == index) {
 3570+ opt.selected = true;
 3571+ return;
 3572+ }
 3573+ }
 3574+ else opt.selected = index.include(value);
 3575+ }
 3576+ }
35773577 },
35783578
35793579 selectOne: function(element) {
3580 - var index = element.selectedIndex;
3581 - return index >= 0 ? this.optionValue(element.options[index]) : null;
 3580+ var index = element.selectedIndex;
 3581+ return index >= 0 ? this.optionValue(element.options[index]) : null;
35823582 },
35833583
35843584 selectMany: function(element) {
3585 - var values, length = element.length;
3586 - if (!length) return null;
 3585+ var values, length = element.length;
 3586+ if (!length) return null;
35873587
3588 - for (var i = 0, values = []; i < length; i++) {
3589 - var opt = element.options[i];
3590 - if (opt.selected) values.push(this.optionValue(opt));
3591 - }
3592 - return values;
 3588+ for (var i = 0, values = []; i < length; i++) {
 3589+ var opt = element.options[i];
 3590+ if (opt.selected) values.push(this.optionValue(opt));
 3591+ }
 3592+ return values;
35933593 },
35943594
35953595 optionValue: function(opt) {
3596 - // extend element because hasAttribute may not be native
3597 - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
 3596+ // extend element because hasAttribute may not be native
 3597+ return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text;
35983598 }
35993599 };
36003600
@@ -3601,30 +3601,30 @@
36023602
36033603 Abstract.TimedObserver = Class.create(PeriodicalExecuter, {
36043604 initialize: function($super, element, frequency, callback) {
3605 - $super(callback, frequency);
3606 - this.element = $(element);
3607 - this.lastValue = this.getValue();
 3605+ $super(callback, frequency);
 3606+ this.element = $(element);
 3607+ this.lastValue = this.getValue();
36083608 },
36093609
36103610 execute: function() {
3611 - var value = this.getValue();
3612 - if (Object.isString(this.lastValue) && Object.isString(value) ?
3613 - this.lastValue != value : String(this.lastValue) != String(value)) {
3614 - this.callback(this.element, value);
3615 - this.lastValue = value;
3616 - }
 3611+ var value = this.getValue();
 3612+ if (Object.isString(this.lastValue) && Object.isString(value) ?
 3613+ this.lastValue != value : String(this.lastValue) != String(value)) {
 3614+ this.callback(this.element, value);
 3615+ this.lastValue = value;
 3616+ }
36173617 }
36183618 });
36193619
36203620 Form.Element.Observer = Class.create(Abstract.TimedObserver, {
36213621 getValue: function() {
3622 - return Form.Element.getValue(this.element);
 3622+ return Form.Element.getValue(this.element);
36233623 }
36243624 });
36253625
36263626 Form.Observer = Class.create(Abstract.TimedObserver, {
36273627 getValue: function() {
3628 - return Form.serialize(this.element);
 3628+ return Form.serialize(this.element);
36293629 }
36303630 });
36313631
@@ -3632,68 +3632,68 @@
36333633
36343634 Abstract.EventObserver = Class.create({
36353635 initialize: function(element, callback) {
3636 - this.element = $(element);
3637 - this.callback = callback;
 3636+ this.element = $(element);
 3637+ this.callback = callback;
36383638
3639 - this.lastValue = this.getValue();
3640 - if (this.element.tagName.toLowerCase() == 'form')
3641 - this.registerFormCallbacks();
3642 - else
3643 - this.registerCallback(this.element);
 3639+ this.lastValue = this.getValue();
 3640+ if (this.element.tagName.toLowerCase() == 'form')
 3641+ this.registerFormCallbacks();
 3642+ else
 3643+ this.registerCallback(this.element);
36443644 },
36453645
36463646 onElementEvent: function() {
3647 - var value = this.getValue();
3648 - if (this.lastValue != value) {
3649 - this.callback(this.element, value);
3650 - this.lastValue = value;
3651 - }
 3647+ var value = this.getValue();
 3648+ if (this.lastValue != value) {
 3649+ this.callback(this.element, value);
 3650+ this.lastValue = value;
 3651+ }
36523652 },
36533653
36543654 registerFormCallbacks: function() {
3655 - Form.getElements(this.element).each(this.registerCallback, this);
 3655+ Form.getElements(this.element).each(this.registerCallback, this);
36563656 },
36573657
36583658 registerCallback: function(element) {
3659 - if (element.type) {
3660 - switch (element.type.toLowerCase()) {
3661 - case 'checkbox':
3662 - case 'radio':
3663 - Event.observe(element, 'click', this.onElementEvent.bind(this));
3664 - break;
3665 - default:
3666 - Event.observe(element, 'change', this.onElementEvent.bind(this));
3667 - break;
3668 - }
3669 - }
 3659+ if (element.type) {
 3660+ switch (element.type.toLowerCase()) {
 3661+ case 'checkbox':
 3662+ case 'radio':
 3663+ Event.observe(element, 'click', this.onElementEvent.bind(this));
 3664+ break;
 3665+ default:
 3666+ Event.observe(element, 'change', this.onElementEvent.bind(this));
 3667+ break;
 3668+ }
 3669+ }
36703670 }
36713671 });
36723672
36733673 Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
36743674 getValue: function() {
3675 - return Form.Element.getValue(this.element);
 3675+ return Form.Element.getValue(this.element);
36763676 }
36773677 });
36783678
36793679 Form.EventObserver = Class.create(Abstract.EventObserver, {
36803680 getValue: function() {
3681 - return Form.serialize(this.element);
 3681+ return Form.serialize(this.element);
36823682 }
36833683 });
36843684 if (!window.Event) var Event = { };
36853685
36863686 Object.extend(Event, {
36873687 KEY_BACKSPACE: 8,
3688 - KEY_TAB: 9,
 3688+ KEY_TAB: 9,
36893689 KEY_RETURN: 13,
3690 - KEY_ESC: 27,
3691 - KEY_LEFT: 37,
3692 - KEY_UP: 38,
3693 - KEY_RIGHT: 39,
3694 - KEY_DOWN: 40,
 3690+ KEY_ESC: 27,
 3691+ KEY_LEFT: 37,
 3692+ KEY_UP: 38,
 3693+ KEY_RIGHT: 39,
 3694+ KEY_DOWN: 40,
36953695 KEY_DELETE: 46,
3696 - KEY_HOME: 36,
3697 - KEY_END: 35,
 3696+ KEY_HOME: 36,
 3697+ KEY_END: 35,
36983698 KEY_PAGEUP: 33,
36993699 KEY_PAGEDOWN: 34,
37003700 KEY_INSERT: 45,
@@ -3701,13 +3701,13 @@
37023702 cache: { },
37033703
37043704 relatedTarget: function(event) {
3705 - var element;
3706 - switch(event.type) {
3707 - case 'mouseover': element = event.fromElement; break;
3708 - case 'mouseout': element = event.toElement; break;
3709 - default: return null;
3710 - }
3711 - return Element.extend(element);
 3705+ var element;
 3706+ switch(event.type) {
 3707+ case 'mouseover': element = event.fromElement; break;
 3708+ case 'mouseout': element = event.toElement; break;
 3709+ default: return null;
 3710+ }
 3711+ return Element.extend(element);
37123712 }
37133713 });
37143714
@@ -3715,94 +3715,94 @@
37163716 var isButton;
37173717
37183718 if (Prototype.Browser.IE) {
3719 - var buttonMap = { 0: 1, 1: 4, 2: 2 };
3720 - isButton = function(event, code) {
3721 - return event.button == buttonMap[code];
3722 - };
 3719+ var buttonMap = { 0: 1, 1: 4, 2: 2 };
 3720+ isButton = function(event, code) {
 3721+ return event.button == buttonMap[code];
 3722+ };
37233723
37243724 } else if (Prototype.Browser.WebKit) {
3725 - isButton = function(event, code) {
3726 - switch (code) {
3727 - case 0: return event.which == 1 && !event.metaKey;
3728 - case 1: return event.which == 1 && event.metaKey;
3729 - default: return false;
3730 - }
3731 - };
 3725+ isButton = function(event, code) {
 3726+ switch (code) {
 3727+ case 0: return event.which == 1 && !event.metaKey;
 3728+ case 1: return event.which == 1 && event.metaKey;
 3729+ default: return false;
 3730+ }
 3731+ };
37323732
37333733 } else {
3734 - isButton = function(event, code) {
3735 - return event.which ? (event.which === code + 1) : (event.button === code);
3736 - };
 3734+ isButton = function(event, code) {
 3735+ return event.which ? (event.which === code + 1) : (event.button === code);
 3736+ };
37373737 }
37383738
37393739 return {
3740 - isLeftClick: function(event) { return isButton(event, 0) },
3741 - isMiddleClick: function(event) { return isButton(event, 1) },
3742 - isRightClick: function(event) { return isButton(event, 2) },
 3740+ isLeftClick: function(event) { return isButton(event, 0) },
 3741+ isMiddleClick: function(event) { return isButton(event, 1) },
 3742+ isRightClick: function(event) { return isButton(event, 2) },
37433743
3744 - element: function(event) {
3745 - var node = Event.extend(event).target;
3746 - return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
3747 - },
 3744+ element: function(event) {
 3745+ var node = Event.extend(event).target;
 3746+ return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node);
 3747+ },
37483748
3749 - findElement: function(event, expression) {
3750 - var element = Event.element(event);
3751 - return element.match(expression) ? element : element.up(expression);
3752 - },
 3749+ findElement: function(event, expression) {
 3750+ var element = Event.element(event);
 3751+ return element.match(expression) ? element : element.up(expression);
 3752+ },
37533753
3754 - pointer: function(event) {
3755 - return {
3756 - x: event.pageX || (event.clientX +
3757 - (document.documentElement.scrollLeft || document.body.scrollLeft)),
3758 - y: event.pageY || (event.clientY +
3759 - (document.documentElement.scrollTop || document.body.scrollTop))
3760 - };
3761 - },
 3754+ pointer: function(event) {
 3755+ return {
 3756+ x: event.pageX || (event.clientX +
 3757+ (document.documentElement.scrollLeft || document.body.scrollLeft)),
 3758+ y: event.pageY || (event.clientY +
 3759+ (document.documentElement.scrollTop || document.body.scrollTop))
 3760+ };
 3761+ },
37623762
3763 - pointerX: function(event) { return Event.pointer(event).x },
3764 - pointerY: function(event) { return Event.pointer(event).y },
 3763+ pointerX: function(event) { return Event.pointer(event).x },
 3764+ pointerY: function(event) { return Event.pointer(event).y },
37653765
3766 - stop: function(event) {
3767 - Event.extend(event);
3768 - event.preventDefault();
3769 - event.stopPropagation();
3770 - event.stopped = true;
3771 - }
 3766+ stop: function(event) {
 3767+ Event.extend(event);
 3768+ event.preventDefault();
 3769+ event.stopPropagation();
 3770+ event.stopped = true;
 3771+ }
37723772 };
37733773 })();
37743774
37753775 Event.extend = (function() {
37763776 var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
3777 - m[name] = Event.Methods[name].methodize();
3778 - return m;
 3777+ m[name] = Event.Methods[name].methodize();
 3778+ return m;
37793779 });
37803780
37813781 if (Prototype.Browser.IE) {
3782 - Object.extend(methods, {
3783 - stopPropagation: function() { this.cancelBubble = true },
3784 - preventDefault: function() { this.returnValue = false },
3785 - inspect: function() { return "[object Event]" }
3786 - });
 3782+ Object.extend(methods, {
 3783+ stopPropagation: function() { this.cancelBubble = true },
 3784+ preventDefault: function() { this.returnValue = false },
 3785+ inspect: function() { return "[object Event]" }
 3786+ });
37873787
3788 - return function(event) {
3789 - if (!event) return false;
3790 - if (event._extendedByPrototype) return event;
 3788+ return function(event) {
 3789+ if (!event) return false;
 3790+ if (event._extendedByPrototype) return event;
37913791
3792 - event._extendedByPrototype = Prototype.emptyFunction;
3793 - var pointer = Event.pointer(event);
3794 - Object.extend(event, {
3795 - target: event.srcElement,
3796 - relatedTarget: Event.relatedTarget(event),
3797 - pageX: pointer.x,
3798 - pageY: pointer.y
3799 - });
3800 - return Object.extend(event, methods);
3801 - };
 3792+ event._extendedByPrototype = Prototype.emptyFunction;
 3793+ var pointer = Event.pointer(event);
 3794+ Object.extend(event, {
 3795+ target: event.srcElement,
 3796+ relatedTarget: Event.relatedTarget(event),
 3797+ pageX: pointer.x,
 3798+ pageY: pointer.y
 3799+ });
 3800+ return Object.extend(event, methods);
 3801+ };
38023802
38033803 } else {
3804 - Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__;
3805 - Object.extend(Event.prototype, methods);
3806 - return Prototype.K;
 3804+ Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__;
 3805+ Object.extend(Event.prototype, methods);
 3806+ return Prototype.K;
38073807 }
38083808 })();
38093809
@@ -3810,189 +3810,189 @@
38113811 var cache = Event.cache;
38123812
38133813 function getEventID(element) {
3814 - if (element._eventID) return element._eventID;
3815 - arguments.callee.id = arguments.callee.id || 1;
3816 - return element._eventID = ++arguments.callee.id;
 3814+ if (element._eventID) return element._eventID;
 3815+ arguments.callee.id = arguments.callee.id || 1;
 3816+ return element._eventID = ++arguments.callee.id;
38173817 }
38183818
38193819 function getDOMEventName(eventName) {
3820 - if (eventName && eventName.include(':')) return "dataavailable";
3821 - return eventName;
 3820+ if (eventName && eventName.include(':')) return "dataavailable";
 3821+ return eventName;
38223822 }
38233823
38243824 function getCacheForID(id) {
3825 - return cache[id] = cache[id] || { };
 3825+ return cache[id] = cache[id] || { };
38263826 }
38273827
38283828 function getWrappersForEventName(id, eventName) {
3829 - var c = getCacheForID(id);
3830 - return c[eventName] = c[eventName] || [];
 3829+ var c = getCacheForID(id);
 3830+ return c[eventName] = c[eventName] || [];
38313831 }
38323832
38333833 function createWrapper(element, eventName, handler) {
3834 - var id = getEventID(element);
3835 - var c = getWrappersForEventName(id, eventName);
3836 - if (c.pluck("handler").include(handler)) return false;
 3834+ var id = getEventID(element);
 3835+ var c = getWrappersForEventName(id, eventName);
 3836+ if (c.pluck("handler").include(handler)) return false;
38373837
3838 - var wrapper = function(event) {
3839 - if (!Event || !Event.extend ||
3840 - (event.eventName && event.eventName != eventName))
3841 - return false;
 3838+ var wrapper = function(event) {
 3839+ if (!Event || !Event.extend ||
 3840+ (event.eventName && event.eventName != eventName))
 3841+ return false;
38423842
3843 - Event.extend(event);
3844 - handler.call(element, event)
3845 - };
 3843+ Event.extend(event);
 3844+ handler.call(element, event)
 3845+ };
38463846
3847 - wrapper.handler = handler;
3848 - c.push(wrapper);
3849 - return wrapper;
 3847+ wrapper.handler = handler;
 3848+ c.push(wrapper);
 3849+ return wrapper;
38503850 }
38513851
38523852 function findWrapper(id, eventName, handler) {
3853 - var c = getWrappersForEventName(id, eventName);
3854 - return c.find(function(wrapper) { return wrapper.handler == handler });
 3853+ var c = getWrappersForEventName(id, eventName);
 3854+ return c.find(function(wrapper) { return wrapper.handler == handler });
38553855 }
38563856
38573857 function destroyWrapper(id, eventName, handler) {
3858 - var c = getCacheForID(id);
3859 - if (!c[eventName]) return false;
3860 - c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
 3858+ var c = getCacheForID(id);
 3859+ if (!c[eventName]) return false;
 3860+ c[eventName] = c[eventName].without(findWrapper(id, eventName, handler));
38613861 }
38623862
38633863 function destroyCache() {
3864 - for (var id in cache)
3865 - for (var eventName in cache[id])
3866 - cache[id][eventName] = null;
 3864+ for (var id in cache)
 3865+ for (var eventName in cache[id])
 3866+ cache[id][eventName] = null;
38673867 }
38683868
38693869 if (window.attachEvent) {
3870 - window.attachEvent("onunload", destroyCache);
 3870+ window.attachEvent("onunload", destroyCache);
38713871 }
38723872
38733873 return {
3874 - observe: function(element, eventName, handler) {
3875 - element = $(element);
3876 - var name = getDOMEventName(eventName);
 3874+ observe: function(element, eventName, handler) {
 3875+ element = $(element);
 3876+ var name = getDOMEventName(eventName);
38773877
3878 - var wrapper = createWrapper(element, eventName, handler);
3879 - if (!wrapper) return element;
 3878+ var wrapper = createWrapper(element, eventName, handler);
 3879+ if (!wrapper) return element;
38803880
3881 - if (element.addEventListener) {
3882 - element.addEventListener(name, wrapper, false);
3883 - } else {
3884 - element.attachEvent("on" + name, wrapper);
3885 - }
 3881+ if (element.addEventListener) {
 3882+ element.addEventListener(name, wrapper, false);
 3883+ } else {
 3884+ element.attachEvent("on" + name, wrapper);
 3885+ }
38863886
3887 - return element;
3888 - },
 3887+ return element;
 3888+ },
38893889
3890 - stopObserving: function(element, eventName, handler) {
3891 - element = $(element);
3892 - var id = getEventID(element), name = getDOMEventName(eventName);
 3890+ stopObserving: function(element, eventName, handler) {
 3891+ element = $(element);
 3892+ var id = getEventID(element), name = getDOMEventName(eventName);
38933893
3894 - if (!handler && eventName) {
3895 - getWrappersForEventName(id, eventName).each(function(wrapper) {
3896 - element.stopObserving(eventName, wrapper.handler);
3897 - });
3898 - return element;
 3894+ if (!handler && eventName) {
 3895+ getWrappersForEventName(id, eventName).each(function(wrapper) {
 3896+ element.stopObserving(eventName, wrapper.handler);
 3897+ });
 3898+ return element;
38993899
3900 - } else if (!eventName) {
3901 - Object.keys(getCacheForID(id)).each(function(eventName) {
3902 - element.stopObserving(eventName);
3903 - });
3904 - return element;
3905 - }
 3900+ } else if (!eventName) {
 3901+ Object.keys(getCacheForID(id)).each(function(eventName) {
 3902+ element.stopObserving(eventName);
 3903+ });
 3904+ return element;
 3905+ }
39063906
3907 - var wrapper = findWrapper(id, eventName, handler);
3908 - if (!wrapper) return element;
 3907+ var wrapper = findWrapper(id, eventName, handler);
 3908+ if (!wrapper) return element;
39093909
3910 - if (element.removeEventListener) {
3911 - element.removeEventListener(name, wrapper, false);
3912 - } else {
3913 - element.detachEvent("on" + name, wrapper);
3914 - }
 3910+ if (element.removeEventListener) {
 3911+ element.removeEventListener(name, wrapper, false);
 3912+ } else {
 3913+ element.detachEvent("on" + name, wrapper);
 3914+ }
39153915
3916 - destroyWrapper(id, eventName, handler);
 3916+ destroyWrapper(id, eventName, handler);
39173917
3918 - return element;
3919 - },
 3918+ return element;
 3919+ },
39203920
3921 - fire: function(element, eventName, memo) {
3922 - element = $(element);
3923 - if (element == document && document.createEvent && !element.dispatchEvent)
3924 - element = document.documentElement;
 3921+ fire: function(element, eventName, memo) {
 3922+ element = $(element);
 3923+ if (element == document && document.createEvent && !element.dispatchEvent)
 3924+ element = document.documentElement;
39253925
3926 - if (document.createEvent) {
3927 - var event = document.createEvent("HTMLEvents");
3928 - event.initEvent("dataavailable", true, true);
3929 - } else {
3930 - var event = document.createEventObject();
3931 - event.eventType = "ondataavailable";
3932 - }
 3926+ if (document.createEvent) {
 3927+ var event = document.createEvent("HTMLEvents");
 3928+ event.initEvent("dataavailable", true, true);
 3929+ } else {
 3930+ var event = document.createEventObject();
 3931+ event.eventType = "ondataavailable";
 3932+ }
39333933
3934 - event.eventName = eventName;
3935 - event.memo = memo || { };
 3934+ event.eventName = eventName;
 3935+ event.memo = memo || { };
39363936
3937 - if (document.createEvent) {
3938 - element.dispatchEvent(event);
3939 - } else {
3940 - element.fireEvent(event.eventType, event);
3941 - }
 3937+ if (document.createEvent) {
 3938+ element.dispatchEvent(event);
 3939+ } else {
 3940+ element.fireEvent(event.eventType, event);
 3941+ }
39423942
3943 - return event;
3944 - }
 3943+ return event;
 3944+ }
39453945 };
39463946 })());
39473947
39483948 Object.extend(Event, Event.Methods);
39493949
39503950 Element.addMethods({
3951 - fire: Event.fire,
3952 - observe: Event.observe,
 3951+ fire: Event.fire,
 3952+ observe: Event.observe,
39533953 stopObserving: Event.stopObserving
39543954 });
39553955
39563956 Object.extend(document, {
3957 - fire: Element.Methods.fire.methodize(),
3958 - observe: Element.Methods.observe.methodize(),
 3957+ fire: Element.Methods.fire.methodize(),
 3958+ observe: Element.Methods.observe.methodize(),
39593959 stopObserving: Element.Methods.stopObserving.methodize()
39603960 });
39613961
39623962 (function() {
39633963 /* Support for the DOMContentLoaded event is based on work by Dan Webb,
3964 - Matthias Miller, Dean Edwards and John Resig. */
 3964+ Matthias Miller, Dean Edwards and John Resig. */
39653965
39663966 var timer, fired = false;
39673967
39683968 function fireContentLoadedEvent() {
3969 - if (fired) return;
3970 - if (timer) window.clearInterval(timer);
3971 - document.fire("dom:loaded");
3972 - fired = true;
 3969+ if (fired) return;
 3970+ if (timer) window.clearInterval(timer);
 3971+ document.fire("dom:loaded");
 3972+ fired = true;
39733973 }
39743974
39753975 if (document.addEventListener) {
3976 - if (Prototype.Browser.WebKit) {
3977 - timer = window.setInterval(function() {
3978 - if (/loaded|complete/.test(document.readyState))
3979 - fireContentLoadedEvent();
3980 - }, 0);
 3976+ if (Prototype.Browser.WebKit) {
 3977+ timer = window.setInterval(function() {
 3978+ if (/loaded|complete/.test(document.readyState))
 3979+ fireContentLoadedEvent();
 3980+ }, 0);
39813981
3982 - Event.observe(window, "load", fireContentLoadedEvent);
 3982+ Event.observe(window, "load", fireContentLoadedEvent);
39833983
3984 - } else {
3985 - document.addEventListener("DOMContentLoaded",
3986 - fireContentLoadedEvent, false);
3987 - }
 3984+ } else {
 3985+ document.addEventListener("DOMContentLoaded",
 3986+ fireContentLoadedEvent, false);
 3987+ }
39883988
39893989 } else {
3990 - document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
3991 - $("__onDOMContentLoaded").onreadystatechange = function() {
3992 - if (this.readyState == "complete") {
3993 - this.onreadystatechange = null;
3994 - fireContentLoadedEvent();
3995 - }
3996 - };
 3990+ document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");
 3991+ $("__onDOMContentLoaded").onreadystatechange = function() {
 3992+ if (this.readyState == "complete") {
 3993+ this.onreadystatechange = null;
 3994+ fireContentLoadedEvent();
 3995+ }
 3996+ };
39973997 }
39983998 })();
39993999 /*------------------------------- DEPRECATED -------------------------------*/
@@ -4005,19 +4005,19 @@
40064006
40074007 var Insertion = {
40084008 Before: function(element, content) {
4009 - return Element.insert(element, {before:content});
 4009+ return Element.insert(element, {before:content});
40104010 },
40114011
40124012 Top: function(element, content) {
4013 - return Element.insert(element, {top:content});
 4013+ return Element.insert(element, {top:content});
40144014 },
40154015
40164016 Bottom: function(element, content) {
4017 - return Element.insert(element, {bottom:content});
 4017+ return Element.insert(element, {bottom:content});
40184018 },
40194019
40204020 After: function(element, content) {
4021 - return Element.insert(element, {after:content});
 4021+ return Element.insert(element, {after:content});
40224022 }
40234023 };
40244024
@@ -4034,52 +4034,52 @@
40354035 // must be called before calling withinIncludingScrolloffset, every time the
40364036 // page is scrolled
40374037 prepare: function() {
4038 - this.deltaX = window.pageXOffset
4039 - || document.documentElement.scrollLeft
4040 - || document.body.scrollLeft
4041 - || 0;
4042 - this.deltaY = window.pageYOffset
4043 - || document.documentElement.scrollTop
4044 - || document.body.scrollTop
4045 - || 0;
 4038+ this.deltaX = window.pageXOffset
 4039+ || document.documentElement.scrollLeft
 4040+ || document.body.scrollLeft
 4041+ || 0;
 4042+ this.deltaY = window.pageYOffset
 4043+ || document.documentElement.scrollTop
 4044+ || document.body.scrollTop
 4045+ || 0;
40464046 },
40474047
40484048 // caches x/y coordinate pair to use with overlap
40494049 within: function(element, x, y) {
4050 - if (this.includeScrollOffsets)
4051 - return this.withinIncludingScrolloffsets(element, x, y);
4052 - this.xcomp = x;
4053 - this.ycomp = y;
4054 - this.offset = Element.cumulativeOffset(element);
 4050+ if (this.includeScrollOffsets)
 4051+ return this.withinIncludingScrolloffsets(element, x, y);
 4052+ this.xcomp = x;
 4053+ this.ycomp = y;
 4054+ this.offset = Element.cumulativeOffset(element);
40554055
4056 - return (y >= this.offset[1] &&
4057 - y < this.offset[1] + element.offsetHeight &&
4058 - x >= this.offset[0] &&
4059 - x < this.offset[0] + element.offsetWidth);
 4056+ return (y >= this.offset[1] &&
 4057+ y < this.offset[1] + element.offsetHeight &&
 4058+ x >= this.offset[0] &&
 4059+ x < this.offset[0] + element.offsetWidth);
40604060 },
40614061
40624062 withinIncludingScrolloffsets: function(element, x, y) {
4063 - var offsetcache = Element.cumulativeScrollOffset(element);
 4063+ var offsetcache = Element.cumulativeScrollOffset(element);
40644064
4065 - this.xcomp = x + offsetcache[0] - this.deltaX;
4066 - this.ycomp = y + offsetcache[1] - this.deltaY;
4067 - this.offset = Element.cumulativeOffset(element);
 4065+ this.xcomp = x + offsetcache[0] - this.deltaX;
 4066+ this.ycomp = y + offsetcache[1] - this.deltaY;
 4067+ this.offset = Element.cumulativeOffset(element);
40684068
4069 - return (this.ycomp >= this.offset[1] &&
4070 - this.ycomp < this.offset[1] + element.offsetHeight &&
4071 - this.xcomp >= this.offset[0] &&
4072 - this.xcomp < this.offset[0] + element.offsetWidth);
 4069+ return (this.ycomp >= this.offset[1] &&
 4070+ this.ycomp < this.offset[1] + element.offsetHeight &&
 4071+ this.xcomp >= this.offset[0] &&
 4072+ this.xcomp < this.offset[0] + element.offsetWidth);
40734073 },
40744074
40754075 // within must be called directly before
40764076 overlap: function(mode, element) {
4077 - if (!mode) return 0;
4078 - if (mode == 'vertical')
4079 - return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
4080 - element.offsetHeight;
4081 - if (mode == 'horizontal')
4082 - return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
4083 - element.offsetWidth;
 4077+ if (!mode) return 0;
 4078+ if (mode == 'vertical')
 4079+ return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
 4080+ element.offsetHeight;
 4081+ if (mode == 'horizontal')
 4082+ return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
 4083+ element.offsetWidth;
40844084 },
40854085
40864086 // Deprecation layer -- use newer Element methods now (1.5.2).
@@ -4089,13 +4089,13 @@
40904090 positionedOffset: Element.Methods.positionedOffset,
40914091
40924092 absolutize: function(element) {
4093 - Position.prepare();
4094 - return Element.absolutize(element);
 4093+ Position.prepare();
 4094+ return Element.absolutize(element);
40954095 },
40964096
40974097 relativize: function(element) {
4098 - Position.prepare();
4099 - return Element.relativize(element);
 4098+ Position.prepare();
 4099+ return Element.relativize(element);
41004100 },
41014101
41024102 realOffset: Element.Methods.cumulativeScrollOffset,
@@ -4105,8 +4105,8 @@
41064106 page: Element.Methods.viewportOffset,
41074107
41084108 clone: function(source, target, options) {
4109 - options = options || { };
4110 - return Element.clonePosition(target, source, options);
 4109+ options = options || { };
 4110+ return Element.clonePosition(target, source, options);
41114111 }
41124112 };
41134113
@@ -4114,34 +4114,34 @@
41154115
41164116 if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
41174117 function iter(name) {
4118 - return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
 4118+ return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
41194119 }
41204120
41214121 instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
41224122 function(element, className) {
4123 - className = className.toString().strip();
4124 - var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
4125 - return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
 4123+ className = className.toString().strip();
 4124+ var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
 4125+ return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
41264126 } : function(element, className) {
4127 - className = className.toString().strip();
4128 - var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
4129 - if (!classNames && !className) return elements;
 4127+ className = className.toString().strip();
 4128+ var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
 4129+ if (!classNames && !className) return elements;
41304130
4131 - var nodes = $(element).getElementsByTagName('*');
4132 - className = ' ' + className + ' ';
 4131+ var nodes = $(element).getElementsByTagName('*');
 4132+ className = ' ' + className + ' ';
41334133
4134 - for (var i = 0, child, cn; child = nodes[i]; i++) {
4135 - if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
4136 - (classNames && classNames.all(function(name) {
4137 - return !name.toString().blank() && cn.include(' ' + name + ' ');
4138 - }))))
4139 - elements.push(Element.extend(child));
4140 - }
4141 - return elements;
 4134+ for (var i = 0, child, cn; child = nodes[i]; i++) {
 4135+ if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
 4136+ (classNames && classNames.all(function(name) {
 4137+ return !name.toString().blank() && cn.include(' ' + name + ' ');
 4138+ }))))
 4139+ elements.push(Element.extend(child));
 4140+ }
 4141+ return elements;
41424142 };
41434143
41444144 return function(className, parentElement) {
4145 - return $(parentElement || document.body).getElementsByClassName(className);
 4145+ return $(parentElement || document.body).getElementsByClassName(className);
41464146 };
41474147 }(Element.Methods);
41484148
@@ -4150,31 +4150,31 @@
41514151 Element.ClassNames = Class.create();
41524152 Element.ClassNames.prototype = {
41534153 initialize: function(element) {
4154 - this.element = $(element);
 4154+ this.element = $(element);
41554155 },
41564156
41574157 _each: function(iterator) {
4158 - this.element.className.split(/\s+/).select(function(name) {
4159 - return name.length > 0;
4160 - })._each(iterator);
 4158+ this.element.className.split(/\s+/).select(function(name) {
 4159+ return name.length > 0;
 4160+ })._each(iterator);
41614161 },
41624162
41634163 set: function(className) {
4164 - this.element.className = className;
 4164+ this.element.className = className;
41654165 },
41664166
41674167 add: function(classNameToAdd) {
4168 - if (this.include(classNameToAdd)) return;
4169 - this.set($A(this).concat(classNameToAdd).join(' '));
 4168+ if (this.include(classNameToAdd)) return;
 4169+ this.set($A(this).concat(classNameToAdd).join(' '));
41704170 },
41714171
41724172 remove: function(classNameToRemove) {
4173 - if (!this.include(classNameToRemove)) return;
4174 - this.set($A(this).without(classNameToRemove).join(' '));
 4173+ if (!this.include(classNameToRemove)) return;
 4174+ this.set($A(this).without(classNameToRemove).join(' '));
41754175 },
41764176
41774177 toString: function() {
4178 - return $A(this).join(' ');
 4178+ return $A(this).join(' ');
41794179 }
41804180 };
41814181
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguage.js
@@ -1,8 +1,8 @@
22 /**
33 * SMW_NMLanguage.js
4 -*
 4+*
55 * A class that reads language strings from the server by an ajax call.
6 -*
 6+*
77 * @author dch
88 *
99 */
@@ -11,13 +11,13 @@
1212
1313 /**
1414 * This class provides language dependent strings for an identifier.
15 - *
 15+ *
1616 */
1717 NMLanguage.prototype = {
1818
1919 /**
2020 * @public
21 - *
 21+ *
2222 * Constructor.
2323 */
2424 initialize: function() {
@@ -25,14 +25,14 @@
2626
2727 /*
2828 * @public
29 - *
30 - * Returns a language dependent message for an ID, or the ID, if there is
 29+ *
 30+ * Returns a language dependent message for an ID, or the ID, if there is
3131 * no message for it.
32 - *
 32+ *
3333 * @param string id
34 - * ID of the message to be retrieved.
 34+ * ID of the message to be retrieved.
3535 * @return string
36 - * The language dependent message for the given ID.
 36+ * The language dependent message for the given ID.
3737 */
3838 getMessage: function(id, type) {
3939 switch (type) {
@@ -40,16 +40,16 @@
4141 var msg = wgNMUserLanguageStrings[id];
4242 if (!msg) {
4343 msg = id;
44 - }
 44+ }
4545 break;
46 -
 46+
4747 case "cont":
4848 var msg = wgNMContLanguageStrings[id];
4949 if (!msg) {
5050 msg = id;
51 - }
 51+ }
5252 break;
53 - default:
 53+ default:
5454 var msg = wgNMUserLanguageStrings[id];
5555 if (!msg) {
5656 var msg = wgNMContLanguageStrings[id];
@@ -57,17 +57,17 @@
5858 msg = id;
5959 }
6060 }
61 - }
62 -
 61+ }
 62+
6363 // Replace variables
64 - msg = msg.replace(/\$n/g,wgCanonicalNamespace);
 64+ msg = msg.replace(/\$n/g,wgCanonicalNamespace);
6565 msg = msg.replace(/\$p/g,wgPageName);
6666 msg = msg.replace(/\$t/g,wgTitle);
6767 msg = msg.replace(/\$u/g,wgUserName);
6868 msg = msg.replace(/\$s/g,wgServer);
6969 return msg;
7070 }
71 -
 71+
7272 }
7373
7474 // Singleton of this class
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageUserEn.js
@@ -1,4 +1,4 @@
22 var wgNMUserLanguageStrings = {
3 - 'NM_EMPTY_NOTIFYNAME' : 'Your Notify-name is empty.',
4 - 'NM_EMPTY_QUERY' : 'Your query is empty.',
 3+ 'NM_EMPTY_NOTIFYNAME' : 'Your Notify-name is empty.',
 4+ 'NM_EMPTY_QUERY' : 'Your query is empty.',
55 };
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageEn.js
@@ -1,3 +1,3 @@
22 var wgNMContLanguageStrings = {
3 - 'NOTIFYME_NS' : 'NotifyMe:' //namespace identifier with colon
 3+ 'NOTIFYME_NS' : 'NotifyMe:' //namespace identifier with colon
44 }
\ No newline at end of file
Index: trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/nm_tooltip.js
@@ -52,38 +52,38 @@
5353 // configuration. Order of commands is arbitrary.
5454 // Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)"
5555
56 -config. Above = false // false or true - tooltip above mousepointer?
57 -config. BgColor = '#E4E7FF' // Background color
 56+config. Above = false // false or true - tooltip above mousepointer?
 57+config. BgColor = '#E4E7FF' // Background color
5858 config. BgImg = '' // Path to background image, none if empty string ''
59 -config. BorderColor = '#002299'
60 -config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed'
61 -config. BorderWidth = 1
62 -config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer
63 -config. ClickClose = false // false or true - close tooltip if the user clicks somewhere
64 -config. CloseBtn = false // false or true - closebutton in titlebar
 59+config. BorderColor = '#002299'
 60+config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed'
 61+config. BorderWidth = 1
 62+config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer
 63+config. ClickClose = false // false or true - close tooltip if the user clicks somewhere
 64+config. CloseBtn = false // false or true - closebutton in titlebar
6565 config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colors
6666 config. CloseBtnText = '&nbsp;X&nbsp;' // Close button text (may also be an image tag)
6767 config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own
6868 config. Delay = 400 // Time span in ms until tooltip shows up
69 -config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration
70 -config. FadeIn = 0 // Fade-in duration in ms, e.g. 400; 0 for no animation
71 -config. FadeOut = 0
 69+config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration
 70+config. FadeIn = 0 // Fade-in duration in ms, e.g. 400; 0 for no animation
 71+config. FadeOut = 0
7272 config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load
73 -config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation
 73+config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation
7474 config. FollowMouse = true // false or true - tooltip follows the mouse
7575 config. FontColor = '#000044'
7676 config. FontFace = 'Verdana,Geneva,sans-serif'
77 -config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory
 77+config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory
7878 config. FontWeight = 'normal' // 'normal' or 'bold';
79 -config. Left = false // false or true - tooltip on the left of the mouse
80 -config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer
81 -config. OffsetY = 8 // Vertical offset
82 -config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent
83 -config. Padding = 3 // Spacing between border and content
84 -config. Shadow = false // false or true
85 -config. ShadowColor = '#C0C0C0'
86 -config. ShadowWidth = 5
87 -config. Sticky = false // Do NOT hide tooltip on mouseout? false or true
 79+config. Left = false // false or true - tooltip on the left of the mouse
 80+config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer
 81+config. OffsetY = 8 // Vertical offset
 82+config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent
 83+config. Padding = 3 // Spacing between border and content
 84+config. Shadow = false // false or true
 85+config. ShadowColor = '#C0C0C0'
 86+config. ShadowWidth = 5
 87+config. Sticky = false // Do NOT hide tooltip on mouseout? false or true
8888 config. TextAlign = 'left' // 'left', 'right' or 'justify'
8989 config. Title = '' // Default title text applied to all tips (no default title: empty string '')
9090 config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar
@@ -91,7 +91,7 @@
9292 config. TitleFontColor = '#ffffff' // Color of title text - if '', BgColor (of tooltip body) will be used
9393 config. TitleFontFace = '' // If '' use FontFace (boldified)
9494 config. TitleFontSize = '' // If '' use FontSize
95 -config. Width = 200 // Tooltip width; 0 for automatic adaption to tooltip content
 95+config. Width = 200 // Tooltip width; 0 for automatic adaption to tooltip content
9696 //======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============//
9797
9898
@@ -256,10 +256,10 @@
257257
258258 tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags
259259 tt_body,
260 -tt_flagOpa, // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C
 260+tt_flagOpa, // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C
261261 tt_maxPosX, tt_maxPosY,
262262 tt_iState = 0, // Tooltip active |= 1, shown |= 2, move with mouse |= 4
263 -tt_opa, // Currently applied opacity
 263+tt_opa, // Currently applied opacity
264264 tt_bJmpVert, // Tip above mouse (or ABOVE tip below mouse)
265265 tt_t2t, tt_t2tDad, // Tag converted to tip, and its parent element in the document
266266 tt_elDeHref, // The tag from which Opera has removed the href attribute
Index: trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/NotifyHelper.js
@@ -56,7 +56,7 @@
5757 doSaveToNotify:function(){
5858 /*STARTLOG*/
5959 if(window.smwhgLogger){
60 - smwhgLogger.log("Save Notify","NM","save_notify");
 60+ smwhgLogger.log("Save Notify","NM","save_notify");
6161 }
6262 /*ENDLOG*/
6363
@@ -70,7 +70,7 @@
7171 var request = Array();
7272 request.responseText = nmLanguage.getMessage('NM_EMPTY_NOTIFYNAME');
7373 this.saveNotify(request);
74 - }
 74+ }
7575 else if ($('nmquery').value){ //only do this if the query is not empty
7676 var params = $('nmquery').value.replace(/&/gm, "&amp;").replace(/,/gm, "&comma;") + ",";
7777 params += ($('nmqrall').checked ? 1 : 0) + ",";
@@ -112,7 +112,7 @@
113113 item.type = "checkbox";
114114 item.value = nid;
115115 item.name = "nmdel";
116 -
 116+
117117 td = document.createElement("td");
118118 ntr.appendChild(td);
119119 item = document.createElement("a");
@@ -169,14 +169,14 @@
170170 item.id = "nmdiv_" + nid;
171171 }
172172
173 - $('nmtoolbar').parentNode.insertBefore(ntr, $('nmtoolbar'));
 173+ $('nmtoolbar').parentNode.insertBefore(ntr, $('nmtoolbar'));
174174 attachAutocompleteToField("nmd_" + nid);
175175 },
176176
177177 doUpdateMail:function() {
178178 /*STARTLOG*/
179179 if(window.smwhgLogger){
180 - smwhgLogger.log("update Notify Me mail setting ","NM","update_mail");
 180+ smwhgLogger.log("update Notify Me mail setting ","NM","update_mail");
181181 }
182182 /*ENDLOG*/
183183
@@ -211,7 +211,7 @@
212212
213213 /*STARTLOG*/
214214 if(window.smwhgLogger){
215 - smwhgLogger.log("Preview Query","NM","query_preview");
 215+ smwhgLogger.log("Preview Query","NM","query_preview");
216216 }
217217 /*ENDLOG*/
218218 $('shade').toggle();
@@ -242,7 +242,7 @@
243243 updateStates:function(){
244244 /*STARTLOG*/
245245 if(window.smwhgLogger){
246 - smwhgLogger.log("Update States","NM","update_states");
 246+ smwhgLogger.log("Update States","NM","update_states");
247247 }
248248 /*ENDLOG*/
249249
@@ -283,7 +283,7 @@
284284 updateReportAll:function(){
285285 /*STARTLOG*/
286286 if(window.smwhgLogger){
287 - smwhgLogger.log("Update Notifications report all","NM","update_reportall");
 287+ smwhgLogger.log("Update Notifications report all","NM","update_reportall");
288288 }
289289 /*ENDLOG*/
290290
@@ -307,7 +307,7 @@
308308 updateShowAll:function(){
309309 /*STARTLOG*/
310310 if(window.smwhgLogger){
311 - smwhgLogger.log("Update Notifications show all","NM","update_showall");
 311+ smwhgLogger.log("Update Notifications show all","NM","update_showall");
312312 }
313313 /*ENDLOG*/
314314
@@ -339,7 +339,7 @@
340340 deleteNotify:function(){
341341 /*STARTLOG*/
342342 if(window.smwhgLogger){
343 - smwhgLogger.log("Delete Notifications","NM","delete_notify");
 343+ smwhgLogger.log("Delete Notifications","NM","delete_notify");
344344 }
345345 /*ENDLOG*/
346346
@@ -411,7 +411,7 @@
412412 updateDelegate:function(){
413413 /*STARTLOG*/
414414 if(window.smwhgLogger){
415 - smwhgLogger.log("Update delegates","NM","update_delegates");
 415+ smwhgLogger.log("Update delegates","NM","update_delegates");
416416 }
417417 /*ENDLOG*/
418418
@@ -434,17 +434,17 @@
435435 copyToClipboard:function(id){
436436 /*STARTLOG*/
437437 if(window.smwhgLogger){
438 - smwhgLogger.log("Copy nm rss to clipboard","NM","rss_copied");
 438+ smwhgLogger.log("Copy nm rss to clipboard","NM","rss_copied");
439439 }
440440 /*ENDLOG*/
441441 var text = $(id).value;
442442 var succ = 'The RSS feed url was successfully copied to your clipboard';
443443 var fail = 'Your browser does not allow clipboard access.\nThe RSS feed url could not be copied to your clipboard.\nPlease copy the RSS feed url manually.';
444 - if (window.clipboardData){ //IE
 444+ if (window.clipboardData){ //IE
445445 window.clipboardData.setData("Text", text);
446446 alert(succ);
447447 }
448 - else if (window.netscape) {
 448+ else if (window.netscape) {
449449 try {
450450 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
451451 var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
@@ -485,7 +485,7 @@
486486 if(!$('addnotifydialogue')) {
487487 var askdlg = $('showAsk');
488488 var nmdlg = document.createElement("div");
489 - askdlg.parentNode.insertBefore(nmdlg, askdlg);
 489+ askdlg.parentNode.insertBefore(nmdlg, askdlg);
490490 nmdlg.id = "addnotifydialogue";
491491 nmdlg.className = "topDialogue";
492492 nmdlg.style.display = "none";
@@ -501,7 +501,7 @@
502502 },
503503 doSaveToNotifyQI:function(){
504504 if(window.smwhgLogger){
505 - smwhgLogger.log("Save Notify","QI","save_notify");
 505+ smwhgLogger.log("Save Notify","QI","save_notify");
506506 }
507507 if(this.pendingElement)
508508 this.pendingElement.hide();
@@ -510,7 +510,7 @@
511511
512512 if($('nmqname').value=="") {
513513 alert(nmLanguage.getMessage('NM_EMPTY_NOTIFYNAME'));
514 - }
 514+ }
515515 else if (!qihelper.queries[0].isEmpty()){ //only do this if the query is not empty
516516 var ask = qihelper.recurseQuery(0, "parser"); // Get full ask syntax
517517 qihelper.queries[0].getDisplayStatements().each(function(s) { ask += "\n| ?" + s});
@@ -557,8 +557,8 @@
558558
559559 function initialize_notify(){
560560 notifyhelper = new NotifyHelper();
561 -
562 - // SMW / Halo extension contains wibbit which hooks all checkboxes,
 561+
 562+ // SMW / Halo extension contains wibbit which hooks all checkboxes,
563563 // have to load the event handler afterwards
564 - if($('nmemail')) $('nmemail').onclick = function() {notifyhelper.doUpdateMail();};
 564+ if($('nmemail')) $('nmemail').onclick = function() {notifyhelper.doUpdateMail();};
565565 }

Status & tagging log