Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NotAjaxAccess.php |
— | — | @@ -32,31 +32,31 @@ |
33 | 33 | | format=table |
34 | 34 | | link=all'; |
35 | 35 | |
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 ); |
38 | 38 | |
39 | | - $result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI ); |
| 39 | + $result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI ); |
40 | 40 | 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 | + } |
58 | 58 | global $wgParser; |
59 | 59 | |
60 | | - if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) { |
| 60 | + if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) { |
61 | 61 | $result = $wgParser->recursiveTagParse( $result ); |
62 | 62 | } else { |
63 | 63 | global $wgTitle; |
Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/libs/NM_yui_autocompletion.js |
— | — | @@ -7,77 +7,77 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | 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 | + } |
16 | 16 | |
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 | + }); |
53 | 32 | |
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 | + } |
61 | 53 | |
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 | + }; |
67 | 61 | |
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]; |
72 | 67 | |
73 | | - var itemSelectHandler = function (oAutoComp, listItem, dataArray) { |
74 | | - } |
| 68 | + if(aResults.length == 0) { |
| 69 | + oAutoComp.setBody("<div>No matching results</div>"); |
| 70 | + } |
| 71 | + }; |
75 | 72 | |
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 | + } |
79 | 75 | |
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(""); |
82 | 82 | }; |
83 | 83 | |
84 | 84 | /* |
— | — | @@ -85,47 +85,47 @@ |
86 | 86 | * string, an array of values that match it |
87 | 87 | */ |
88 | 88 | 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 | + } |
130 | 130 | } |
131 | 131 | |
132 | 132 | function nmAttachAutocompleteToAllFields() |
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php |
— | — | @@ -38,18 +38,18 @@ |
39 | 39 | global $smwgQDefaultNamespaces; |
40 | 40 | |
41 | 41 | 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; |
45 | 45 | $printoutArticles[] = array( |
46 | 46 | 'namespace' => SMW_NS_PROPERTY, |
47 | 47 | 'title' => Title::makeTitle( SMW_NS_PROPERTY, $po->getText() )->getDBkey() ); |
48 | | - } |
49 | | - if ( !$sorted && isset( $params['sort'] ) ) { |
| 48 | + } |
| 49 | + if ( !$sorted && isset( $params['sort'] ) ) { |
50 | 50 | $printoutArticles[] = array( |
51 | 51 | 'namespace' => SMW_NS_PROPERTY, |
52 | 52 | 'title' => Title::makeTitle( SMW_NS_PROPERTY, $params['sort'] )->getDBkey() ); |
53 | | - } |
| 53 | + } |
54 | 54 | |
55 | 55 | $qp = new SMWNotifyParser( $notify_id, $printoutArticles ); |
56 | 56 | $qp->setDefaultNamespaces( $smwgQDefaultNamespaces ); |
— | — | @@ -482,11 +482,11 @@ |
483 | 483 | protected function getSubqueryDescription( &$setNS, &$label ) { |
484 | 484 | global $smwgQPrintoutLimit; |
485 | 485 | 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 |
488 | 488 | $printrequests = array(); // the printrequests found for this query level |
489 | 489 | $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) |
491 | 491 | |
492 | 492 | // added by dch |
493 | 493 | $subquery = $this->m_subquery; |
— | — | @@ -1021,7 +1021,7 @@ |
1022 | 1022 | protected function readChunk( $stoppattern = '', $consume = true, $trim = true ) { |
1023 | 1023 | if ( $stoppattern == '' ) { |
1024 | 1024 | $stoppattern = '\[\[|\]\]|::|:=|<q>|<\/q>|^' . $this->m_categoryprefix . |
1025 | | - '|^' . $this->m_conceptprefix . '|\|\||\|'; |
| 1025 | + '|^' . $this->m_conceptprefix . '|\|\||\|'; |
1026 | 1026 | } |
1027 | 1027 | $chunks = preg_split( '/[\s]*(' . $stoppattern . ')/u', $this->m_curstring, 2, PREG_SPLIT_DELIM_CAPTURE ); |
1028 | 1028 | if ( count( $chunks ) == 1 ) { // no matches anymore, strip spaces and finish |
— | — | @@ -1608,36 +1608,36 @@ |
1609 | 1609 | } else { |
1610 | 1610 | global $phpInterpreter; |
1611 | 1611 | 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(); |
1621 | 1621 | // Get Systemstring |
1622 | | - preg_match( '!\nSystem(.*?)\n!is', strip_tags( $info ), $ma ); |
| 1622 | + preg_match( '!\nSystem(.*?)\n!is', strip_tags( $info ), $ma ); |
1623 | 1623 | // 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 ) { |
1627 | 1627 | |
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" ); |
1638 | 1638 | $runCommand = "cmd /C " . $runCommand; |
1639 | 1639 | |
1640 | | - $oExec = $wshShell->Run( $runCommand, 7, false ); |
1641 | | - } |
| 1640 | + $oExec = $wshShell->Run( $runCommand, 7, false ); |
| 1641 | + } |
1642 | 1642 | } |
1643 | 1643 | } |
1644 | 1644 | // copy from user class |
Index: trunk/extensions/SemanticNotifyMe/includes/SNM_Initialize.php |
— | — | @@ -221,22 +221,22 @@ |
222 | 222 | $jsm->addCSSIf( $smwgNMScriptPath . '/skins/nm.css', "all", - 1, NS_SPECIAL . ":NotifyMe" ); |
223 | 223 | } else { |
224 | 224 | global $wgRequest; |
225 | | - $scripts = array(); |
226 | | - $$css = array(); |
| 225 | + $scripts = array(); |
| 226 | + $$css = array(); |
227 | 227 | |
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(); |
235 | 235 | |
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 | + } |
241 | 241 | if ( ( $namespace == NS_SPECIAL || $namespace == - 1 ) && ( $page == NS_SPECIAL . ":NotifyMe" ) ) { |
242 | 242 | $out->addScript( '<script type="text/javascript" src="' . $smwgNMScriptPath . '/scripts/prototype.js"></script>' ); |
243 | 243 | $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 @@ |
79 | 79 | // Update database: |
80 | 80 | $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' ); |
81 | 81 | $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' ); |
86 | 86 | $this->m_dbs->update( 'smw_conc2', array( 'cache_date' => strtotime( "now" ), 'cache_count' => $this->m_dbs->affectedRows() ), array( 's_id' => $cid ), 'SMW::refreshConceptCache' ); |
87 | 87 | } else { // just delete old data if there is any |
88 | 88 | $this->m_dbs->delete( 'smw_conccache', array( 'o_id' => $cid ), 'SMW::refreshConceptCache' ); |
— | — | @@ -157,8 +157,8 @@ |
158 | 158 | $qobj = $this->m_queries[$rootid]; |
159 | 159 | if ( $qobj->joinfield !== '' ) { |
160 | 160 | $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; |
163 | 163 | } else { // empty result, no query needed |
164 | 164 | wfProfileOut( 'SMWSQLStore2Queries::getNMQueryResult (SMW)' ); |
165 | 165 | return false; |
— | — | @@ -254,8 +254,8 @@ |
255 | 255 | } elseif ( $description instanceof SMWConceptDescription ) { // fetch concept definition and insert it here |
256 | 256 | $cid = $this->m_store->getSMWPageID( $description->getConcept()->getDBKey(), SMW_NS_CONCEPT, '' ); |
257 | 257 | $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' ); |
260 | 260 | if ( $row === false ) { // no description found, concept does not exist |
261 | 261 | // keep the above query object, it yields an empty result |
262 | 262 | // /TODO: announce an error here? (maybe not, since the query processor can check for |
— | — | @@ -263,11 +263,11 @@ |
264 | 264 | } else { |
265 | 265 | global $smwgQConceptCaching, $smwgQMaxSize, $smwgQMaxDepth, $smwgQFeatures, $smwgQConceptCacheLifetime; |
266 | 266 | $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 ) ); |
269 | 269 | 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 |
272 | 272 | $query->jointable = 'smw_conccache'; |
273 | 273 | $query->joinfield = "$query->alias.s_id"; |
274 | 274 | $query->where = "$query->alias.o_id=" . $this->m_dbs->addQuotes( $cid ); |
— | — | @@ -511,7 +511,7 @@ |
512 | 512 | // modified by dch, disable TEMPORARY tables |
513 | 513 | // if ($this->m_qmode !== SMWQuery::MODE_DEBUG) { |
514 | 514 | // $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' ); |
516 | 516 | // } |
517 | 517 | // $this->m_querylog[$query->alias] = array(); |
518 | 518 | foreach ( $query->components as $qid => $joinfield ) { |
— | — | @@ -698,11 +698,11 @@ |
699 | 699 | } else { |
700 | 700 | $result['ORDER BY'] .= ', '; |
701 | 701 | } |
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 | + } |
707 | 707 | |
708 | 708 | } |
709 | 709 | } |
Index: trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php |
— | — | @@ -27,38 +27,38 @@ |
28 | 28 | |
29 | 29 | // page_id, monitored page id |
30 | 30 | 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 ); |
33 | 33 | SNMDBHelper::setupIndex( $smw_nm_monitor, array( 'page_id' ), $db ); |
34 | 34 | SNMDBHelper::setupTable( $smw_nm_query, |
35 | 35 | 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', |
37 | 37 | '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', |
43 | 43 | 'nm_hierarchy' => 'BLOB', |
44 | | - 'enable' => 'TINYINT(1) NOT NULL default \'0\'' ), $db, $verbose ); |
| 44 | + 'enable' => 'TINYINT(1) NOT NULL default \'0\'' ), $db, $verbose ); |
45 | 45 | SNMDBHelper::setupIndex( $smw_nm_query, array( 'user_id' ), $db ); |
46 | 46 | // page_id, related page / property id in notify query |
47 | 47 | 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', |
50 | 50 | // 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 ); |
53 | 53 | SNMDBHelper::setupIndex( $smw_nm_relations, array( 'smw_id', 'notify_id' ), $db ); |
54 | 54 | 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 ); |
63 | 63 | SNMDBHelper::setupIndex( $smw_nm_rss, array( 'user_id' ), $db ); |
64 | 64 | |
65 | 65 | SNMDBHelper::reportProgress( "... done!\n", $verbose ); |
— | — | @@ -152,9 +152,9 @@ |
153 | 153 | $new_rel = true; |
154 | 154 | $relations[] = array( |
155 | 155 | 'notify_id' => $notify_id, |
156 | | - 'smw_id' => $rel_smw_id, |
| 156 | + 'smw_id' => $rel_smw_id, |
157 | 157 | // $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 ) ), |
159 | 159 | 'subquery' => $subquery ); |
160 | 160 | } |
161 | 161 | } |
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NMStorage.php |
— | — | @@ -34,20 +34,20 @@ |
35 | 35 | * |
36 | 36 | */ |
37 | 37 | 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 | + } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
— | — | @@ -57,26 +57,26 @@ |
58 | 58 | * Returns the single instance of this class. |
59 | 59 | * |
60 | 60 | * @return NMStorage |
61 | | - * The single instance of this class. |
| 61 | + * The single instance of this class. |
62 | 62 | */ |
63 | 63 | 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 | + } |
68 | 68 | |
69 | | - return self::$mInstance; |
| 69 | + return self::$mInstance; |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Returns the actual database. |
74 | 74 | * |
75 | 75 | * @return object |
76 | | - * The object to access the database. |
| 76 | + * The object to access the database. |
77 | 77 | */ |
78 | 78 | 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; |
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NMDBHelper.php |
— | — | @@ -6,53 +6,53 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | 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 ); |
57 | 57 | if ( substr( $type, 0, 8 ) == 'VARCHAR(' ) { |
58 | 58 | $type .= ' binary'; // just assume this to be the case for VARCHAR, avoid collation checks |
59 | 59 | } |
— | — | @@ -70,230 +70,230 @@ |
71 | 71 | } |
72 | 72 | |
73 | 73 | $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 | + } |
106 | 106 | |
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 |
129 | 129 | if ( $key != 'PRIMARY' ) { |
130 | 130 | $db->query( 'DROP INDEX ' . $key . ' ON ' . $table, 'SMW::SetupIndex' ); |
131 | 131 | } |
132 | | - } |
133 | | - } |
| 132 | + } |
| 133 | + } |
134 | 134 | |
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 | + } |
142 | 142 | |
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 | + } |
158 | 158 | |
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 | + } |
183 | 183 | |
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 | + } |
191 | 191 | |
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 |
223 | 223 | |
224 | | - $sql_conds .= ' AND ( '; |
| 224 | + $sql_conds .= ' AND ( '; |
225 | 225 | |
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 | + } |
250 | 250 | |
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 | + } |
300 | 300 | } |
Index: trunk/extensions/SemanticNotifyMe/includes/jobs/SMW_NMSendMailJob.php |
— | — | @@ -20,23 +20,23 @@ |
21 | 21 | * |
22 | 22 | * @param Title $title |
23 | 23 | */ |
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 ); |
28 | 28 | |
29 | | - wfProfileOut( __METHOD__ ); |
30 | | - } |
| 29 | + wfProfileOut( __METHOD__ ); |
| 30 | + } |
31 | 31 | |
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__ ); |
39 | 39 | |
40 | | - UserMailer::send( // userMailer( |
| 40 | + UserMailer::send( // userMailer( |
41 | 41 | $this->params['to'], |
42 | 42 | $this->params['from'], |
43 | 43 | $this->params['subj'], |
— | — | @@ -45,6 +45,6 @@ |
46 | 46 | ); |
47 | 47 | |
48 | 48 | wfProfileOut( __METHOD__ ); |
49 | | - return true; |
50 | | - } |
| 49 | + return true; |
| 50 | + } |
51 | 51 | } |
Index: trunk/extensions/SemanticNotifyMe/languages/SMW_NMLanguage.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | /** |
55 | 55 | * Returns the label of the special property with the ID $propID. |
56 | 56 | * @param int propID |
57 | | - * ID of the special property |
| 57 | + * ID of the special property |
58 | 58 | * @return String Label of the special property |
59 | 59 | */ |
60 | 60 | function getSpecialPropertyLabel( $propID ) { |
— | — | @@ -100,9 +100,9 @@ |
101 | 101 | * Returns the name of the namespace with the ID <$namespaceID>. |
102 | 102 | * |
103 | 103 | * @param int $namespaceID |
104 | | - * ID of the namespace whose name is requested |
| 104 | + * ID of the namespace whose name is requested |
105 | 105 | * @return string |
106 | | - * Name of the namespace or <null>. |
| 106 | + * Name of the namespace or <null>. |
107 | 107 | * |
108 | 108 | */ |
109 | 109 | public function getNamespace( $namespaceID ) { |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | * Returns the array with all namespaces of the NM extension. |
115 | 115 | * |
116 | 116 | * @return string |
117 | | - * Array of additional namespaces. |
| 117 | + * Array of additional namespaces. |
118 | 118 | * |
119 | 119 | */ |
120 | 120 | public function getNamespaces() { |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | * Returns the array with all namespace aliases of the NM extension. |
126 | 126 | * |
127 | 127 | * @return string |
128 | | - * Array of additional namespace aliases. |
| 128 | + * Array of additional namespace aliases. |
129 | 129 | * |
130 | 130 | */ |
131 | 131 | public function getNamespaceAliases() { |
Index: trunk/extensions/SemanticNotifyMe/scripts/prototype.js |
— | — | @@ -10,20 +10,20 @@ |
11 | 11 | Version: '1.6.0', |
12 | 12 | |
13 | 13 | 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/) |
19 | 19 | }, |
20 | 20 | |
21 | 21 | 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__ |
28 | 28 | }, |
29 | 29 | |
30 | 30 | ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', |
— | — | @@ -42,60 +42,60 @@ |
43 | 43 | /* Based on Alex Arnell's inheritance implementation. */ |
44 | 44 | var Class = { |
45 | 45 | 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(); |
49 | 49 | |
50 | | - function klass() { |
51 | | - this.initialize.apply(this, arguments); |
52 | | - } |
| 50 | + function klass() { |
| 51 | + this.initialize.apply(this, arguments); |
| 52 | + } |
53 | 53 | |
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 = []; |
57 | 57 | |
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 | + } |
64 | 64 | |
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]); |
67 | 67 | |
68 | | - if (!klass.prototype.initialize) |
69 | | - klass.prototype.initialize = Prototype.emptyFunction; |
| 68 | + if (!klass.prototype.initialize) |
| 69 | + klass.prototype.initialize = Prototype.emptyFunction; |
70 | 70 | |
71 | | - klass.prototype.constructor = klass; |
| 71 | + klass.prototype.constructor = klass; |
72 | 72 | |
73 | | - return klass; |
| 73 | + return klass; |
74 | 74 | } |
75 | 75 | }; |
76 | 76 | |
77 | 77 | Class.Methods = { |
78 | 78 | 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); |
81 | 81 | |
82 | | - if (!Object.keys({ toString: true }).length) |
83 | | - properties.push("toString", "valueOf"); |
| 82 | + if (!Object.keys({ toString: true }).length) |
| 83 | + properties.push("toString", "valueOf"); |
84 | 84 | |
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 | + } |
98 | 98 | |
99 | | - return this; |
| 99 | + return this; |
100 | 100 | } |
101 | 101 | }; |
102 | 102 | |
— | — | @@ -103,149 +103,149 @@ |
104 | 104 | |
105 | 105 | Object.extend = function(destination, source) { |
106 | 106 | for (var property in source) |
107 | | - destination[property] = source[property]; |
| 107 | + destination[property] = source[property]; |
108 | 108 | return destination; |
109 | 109 | }; |
110 | 110 | |
111 | 111 | Object.extend(Object, { |
112 | 112 | 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 | + } |
121 | 121 | }, |
122 | 122 | |
123 | 123 | 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 | + } |
131 | 131 | |
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; |
135 | 135 | |
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 | + } |
142 | 142 | |
143 | | - return '{' + results.join(', ') + '}'; |
| 143 | + return '{' + results.join(', ') + '}'; |
144 | 144 | }, |
145 | 145 | |
146 | 146 | toQueryString: function(object) { |
147 | | - return $H(object).toQueryString(); |
| 147 | + return $H(object).toQueryString(); |
148 | 148 | }, |
149 | 149 | |
150 | 150 | toHTML: function(object) { |
151 | | - return object && object.toHTML ? object.toHTML() : String.interpret(object); |
| 151 | + return object && object.toHTML ? object.toHTML() : String.interpret(object); |
152 | 152 | }, |
153 | 153 | |
154 | 154 | 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; |
159 | 159 | }, |
160 | 160 | |
161 | 161 | 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; |
166 | 166 | }, |
167 | 167 | |
168 | 168 | clone: function(object) { |
169 | | - return Object.extend({ }, object); |
| 169 | + return Object.extend({ }, object); |
170 | 170 | }, |
171 | 171 | |
172 | 172 | isElement: function(object) { |
173 | | - return object && object.nodeType == 1; |
| 173 | + return object && object.nodeType == 1; |
174 | 174 | }, |
175 | 175 | |
176 | 176 | isArray: function(object) { |
177 | | - return object && object.constructor === Array; |
| 177 | + return object && object.constructor === Array; |
178 | 178 | }, |
179 | 179 | |
180 | 180 | isHash: function(object) { |
181 | | - return object instanceof Hash; |
| 181 | + return object instanceof Hash; |
182 | 182 | }, |
183 | 183 | |
184 | 184 | isFunction: function(object) { |
185 | | - return typeof object == "function"; |
| 185 | + return typeof object == "function"; |
186 | 186 | }, |
187 | 187 | |
188 | 188 | isString: function(object) { |
189 | | - return typeof object == "string"; |
| 189 | + return typeof object == "string"; |
190 | 190 | }, |
191 | 191 | |
192 | 192 | isNumber: function(object) { |
193 | | - return typeof object == "number"; |
| 193 | + return typeof object == "number"; |
194 | 194 | }, |
195 | 195 | |
196 | 196 | isUndefined: function(object) { |
197 | | - return typeof object == "undefined"; |
| 197 | + return typeof object == "undefined"; |
198 | 198 | } |
199 | 199 | }); |
200 | 200 | |
201 | 201 | Object.extend(Function.prototype, { |
202 | 202 | 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; |
205 | 205 | }, |
206 | 206 | |
207 | 207 | 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 | + } |
213 | 213 | }, |
214 | 214 | |
215 | 215 | 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 | + } |
220 | 220 | }, |
221 | 221 | |
222 | 222 | 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 | + } |
228 | 228 | }, |
229 | 229 | |
230 | 230 | 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); |
235 | 235 | }, |
236 | 236 | |
237 | 237 | 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 | + } |
242 | 242 | }, |
243 | 243 | |
244 | 244 | 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 | + }; |
250 | 250 | } |
251 | 251 | }); |
252 | 252 | |
— | — | @@ -253,26 +253,26 @@ |
254 | 254 | |
255 | 255 | Date.prototype.toJSON = function() { |
256 | 256 | 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"'; |
262 | 262 | }; |
263 | 263 | |
264 | 264 | var Try = { |
265 | 265 | these: function() { |
266 | | - var returnValue; |
| 266 | + var returnValue; |
267 | 267 | |
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 | + } |
275 | 275 | |
276 | | - return returnValue; |
| 276 | + return returnValue; |
277 | 277 | } |
278 | 278 | }; |
279 | 279 | |
— | — | @@ -286,250 +286,250 @@ |
287 | 287 | |
288 | 288 | var PeriodicalExecuter = Class.create({ |
289 | 289 | 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; |
293 | 293 | |
294 | | - this.registerCallback(); |
| 294 | + this.registerCallback(); |
295 | 295 | }, |
296 | 296 | |
297 | 297 | registerCallback: function() { |
298 | | - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); |
| 298 | + this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); |
299 | 299 | }, |
300 | 300 | |
301 | 301 | execute: function() { |
302 | | - this.callback(this); |
| 302 | + this.callback(this); |
303 | 303 | }, |
304 | 304 | |
305 | 305 | 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; |
309 | 309 | }, |
310 | 310 | |
311 | 311 | 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 | + } |
320 | 320 | } |
321 | 321 | }); |
322 | 322 | Object.extend(String, { |
323 | 323 | interpret: function(value) { |
324 | | - return value == null ? '' : String(value); |
| 324 | + return value == null ? '' : String(value); |
325 | 325 | }, |
326 | 326 | 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 | + '\\': '\\\\' |
333 | 333 | } |
334 | 334 | }); |
335 | 335 | |
336 | 336 | Object.extend(String.prototype, { |
337 | 337 | 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); |
340 | 340 | |
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; |
351 | 351 | }, |
352 | 352 | |
353 | 353 | 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; |
356 | 356 | |
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 | + }); |
361 | 361 | }, |
362 | 362 | |
363 | 363 | scan: function(pattern, iterator) { |
364 | | - this.gsub(pattern, iterator); |
365 | | - return String(this); |
| 364 | + this.gsub(pattern, iterator); |
| 365 | + return String(this); |
366 | 366 | }, |
367 | 367 | |
368 | 368 | 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); |
373 | 373 | }, |
374 | 374 | |
375 | 375 | strip: function() { |
376 | | - return this.replace(/^\s+/, '').replace(/\s+$/, ''); |
| 376 | + return this.replace(/^\s+/, '').replace(/\s+$/, ''); |
377 | 377 | }, |
378 | 378 | |
379 | 379 | stripTags: function() { |
380 | | - return this.replace(/<\/?[^>]+>/gi, ''); |
| 380 | + return this.replace(/<\/?[^>]+>/gi, ''); |
381 | 381 | }, |
382 | 382 | |
383 | 383 | stripScripts: function() { |
384 | | - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); |
| 384 | + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); |
385 | 385 | }, |
386 | 386 | |
387 | 387 | 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 | + }); |
393 | 393 | }, |
394 | 394 | |
395 | 395 | evalScripts: function() { |
396 | | - return this.extractScripts().map(function(script) { return eval(script) }); |
| 396 | + return this.extractScripts().map(function(script) { return eval(script) }); |
397 | 397 | }, |
398 | 398 | |
399 | 399 | 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; |
403 | 403 | }, |
404 | 404 | |
405 | 405 | 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) : ''; |
411 | 411 | }, |
412 | 412 | |
413 | 413 | toQueryParams: function(separator) { |
414 | | - var match = this.strip().match(/([^?#]*)(#.*)?$/); |
415 | | - if (!match) return { }; |
| 414 | + var match = this.strip().match(/([^?#]*)(#.*)?$/); |
| 415 | + if (!match) return { }; |
416 | 416 | |
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); |
422 | 422 | |
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 | + }); |
431 | 431 | }, |
432 | 432 | |
433 | 433 | toArray: function() { |
434 | | - return this.split(''); |
| 434 | + return this.split(''); |
435 | 435 | }, |
436 | 436 | |
437 | 437 | 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); |
440 | 440 | }, |
441 | 441 | |
442 | 442 | times: function(count) { |
443 | | - return count < 1 ? '' : new Array(count + 1).join(this); |
| 443 | + return count < 1 ? '' : new Array(count + 1).join(this); |
444 | 444 | }, |
445 | 445 | |
446 | 446 | 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]; |
449 | 449 | |
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]; |
453 | 453 | |
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); |
456 | 456 | |
457 | | - return camelized; |
| 457 | + return camelized; |
458 | 458 | }, |
459 | 459 | |
460 | 460 | capitalize: function() { |
461 | | - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); |
| 461 | + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); |
462 | 462 | }, |
463 | 463 | |
464 | 464 | 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(); |
466 | 466 | }, |
467 | 467 | |
468 | 468 | dasherize: function() { |
469 | | - return this.gsub(/_/,'-'); |
| 469 | + return this.gsub(/_/,'-'); |
470 | 470 | }, |
471 | 471 | |
472 | 472 | 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, '\\\'') + "'"; |
479 | 479 | }, |
480 | 480 | |
481 | 481 | toJSON: function() { |
482 | | - return this.inspect(true); |
| 482 | + return this.inspect(true); |
483 | 483 | }, |
484 | 484 | |
485 | 485 | unfilterJSON: function(filter) { |
486 | | - return this.sub(filter || Prototype.JSONFilter, '#{1}'); |
| 486 | + return this.sub(filter || Prototype.JSONFilter, '#{1}'); |
487 | 487 | }, |
488 | 488 | |
489 | 489 | 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); |
492 | 492 | }, |
493 | 493 | |
494 | 494 | 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()); |
500 | 500 | }, |
501 | 501 | |
502 | 502 | include: function(pattern) { |
503 | | - return this.indexOf(pattern) > -1; |
| 503 | + return this.indexOf(pattern) > -1; |
504 | 504 | }, |
505 | 505 | |
506 | 506 | startsWith: function(pattern) { |
507 | | - return this.indexOf(pattern) === 0; |
| 507 | + return this.indexOf(pattern) === 0; |
508 | 508 | }, |
509 | 509 | |
510 | 510 | 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; |
513 | 513 | }, |
514 | 514 | |
515 | 515 | empty: function() { |
516 | | - return this == ''; |
| 516 | + return this == ''; |
517 | 517 | }, |
518 | 518 | |
519 | 519 | blank: function() { |
520 | | - return /^\s*$/.test(this); |
| 520 | + return /^\s*$/.test(this); |
521 | 521 | }, |
522 | 522 | |
523 | 523 | interpolate: function(object, pattern) { |
524 | | - return new Template(this, pattern).evaluate(object); |
| 524 | + return new Template(this, pattern).evaluate(object); |
525 | 525 | } |
526 | 526 | }); |
527 | 527 | |
528 | 528 | if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { |
529 | 529 | escapeHTML: function() { |
530 | | - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
| 530 | + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
531 | 531 | }, |
532 | 532 | unescapeHTML: function() { |
533 | | - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
| 533 | + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
534 | 534 | } |
535 | 535 | }); |
536 | 536 | |
— | — | @@ -550,34 +550,34 @@ |
551 | 551 | |
552 | 552 | var Template = Class.create({ |
553 | 553 | 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; |
556 | 556 | }, |
557 | 557 | |
558 | 558 | evaluate: function(object) { |
559 | | - if (Object.isFunction(object.toTemplateReplacements)) |
560 | | - object = object.toTemplateReplacements(); |
| 559 | + if (Object.isFunction(object.toTemplateReplacements)) |
| 560 | + object = object.toTemplateReplacements(); |
561 | 561 | |
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 ''; |
564 | 564 | |
565 | | - var before = match[1] || ''; |
566 | | - if (before == '\\') return match[2]; |
| 565 | + var before = match[1] || ''; |
| 566 | + if (before == '\\') return match[2]; |
567 | 567 | |
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; |
571 | 571 | |
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 | + } |
579 | 579 | |
580 | | - return before + String.interpret(ctx); |
581 | | - }.bind(this)); |
| 580 | + return before + String.interpret(ctx); |
| 581 | + }.bind(this)); |
582 | 582 | } |
583 | 583 | }); |
584 | 584 | Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; |
— | — | @@ -586,221 +586,221 @@ |
587 | 587 | |
588 | 588 | var Enumerable = { |
589 | 589 | 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; |
600 | 600 | }, |
601 | 601 | |
602 | 602 | 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); |
608 | 608 | }, |
609 | 609 | |
610 | 610 | 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; |
618 | 618 | }, |
619 | 619 | |
620 | 620 | 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; |
628 | 628 | }, |
629 | 629 | |
630 | 630 | 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; |
637 | 637 | }, |
638 | 638 | |
639 | 639 | 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; |
649 | 649 | }, |
650 | 650 | |
651 | 651 | 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; |
659 | 659 | }, |
660 | 660 | |
661 | 661 | 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 = []; |
664 | 664 | |
665 | | - if (Object.isString(filter)) |
666 | | - filter = new RegExp(filter); |
| 665 | + if (Object.isString(filter)) |
| 666 | + filter = new RegExp(filter); |
667 | 667 | |
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; |
673 | 673 | }, |
674 | 674 | |
675 | 675 | 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; |
678 | 678 | |
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; |
687 | 687 | }, |
688 | 688 | |
689 | 689 | 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 | + }); |
695 | 695 | }, |
696 | 696 | |
697 | 697 | 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; |
703 | 703 | }, |
704 | 704 | |
705 | 705 | 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 | + }); |
710 | 710 | }, |
711 | 711 | |
712 | 712 | 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; |
721 | 721 | }, |
722 | 722 | |
723 | 723 | 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; |
732 | 732 | }, |
733 | 733 | |
734 | 734 | 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]; |
742 | 742 | }, |
743 | 743 | |
744 | 744 | 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; |
750 | 750 | }, |
751 | 751 | |
752 | 752 | 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; |
760 | 760 | }, |
761 | 761 | |
762 | 762 | 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'); |
770 | 770 | }, |
771 | 771 | |
772 | 772 | toArray: function() { |
773 | | - return this.map(); |
| 773 | + return this.map(); |
774 | 774 | }, |
775 | 775 | |
776 | 776 | 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(); |
780 | 780 | |
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 | + }); |
785 | 785 | }, |
786 | 786 | |
787 | 787 | size: function() { |
788 | | - return this.toArray().length; |
| 788 | + return this.toArray().length; |
789 | 789 | }, |
790 | 790 | |
791 | 791 | inspect: function() { |
792 | | - return '#<Enumerable:' + this.toArray().inspect() + '>'; |
| 792 | + return '#<Enumerable:' + this.toArray().inspect() + '>'; |
793 | 793 | } |
794 | 794 | }; |
795 | 795 | |
796 | 796 | Object.extend(Enumerable, { |
797 | | - map: Enumerable.collect, |
798 | | - find: Enumerable.detect, |
| 797 | + map: Enumerable.collect, |
| 798 | + find: Enumerable.detect, |
799 | 799 | select: Enumerable.findAll, |
800 | 800 | filter: Enumerable.findAll, |
801 | 801 | member: Enumerable.include, |
802 | 802 | entries: Enumerable.toArray, |
803 | 803 | every: Enumerable.all, |
804 | | - some: Enumerable.any |
| 804 | + some: Enumerable.any |
805 | 805 | }); |
806 | 806 | function $A(iterable) { |
807 | 807 | if (!iterable) return []; |
— | — | @@ -812,12 +812,12 @@ |
813 | 813 | |
814 | 814 | if (Prototype.Browser.WebKit) { |
815 | 815 | 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; |
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
— | — | @@ -829,84 +829,84 @@ |
830 | 830 | |
831 | 831 | Object.extend(Array.prototype, { |
832 | 832 | _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]); |
835 | 835 | }, |
836 | 836 | |
837 | 837 | clear: function() { |
838 | | - this.length = 0; |
839 | | - return this; |
| 838 | + this.length = 0; |
| 839 | + return this; |
840 | 840 | }, |
841 | 841 | |
842 | 842 | first: function() { |
843 | | - return this[0]; |
| 843 | + return this[0]; |
844 | 844 | }, |
845 | 845 | |
846 | 846 | last: function() { |
847 | | - return this[this.length - 1]; |
| 847 | + return this[this.length - 1]; |
848 | 848 | }, |
849 | 849 | |
850 | 850 | compact: function() { |
851 | | - return this.select(function(value) { |
852 | | - return value != null; |
853 | | - }); |
| 851 | + return this.select(function(value) { |
| 852 | + return value != null; |
| 853 | + }); |
854 | 854 | }, |
855 | 855 | |
856 | 856 | 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 | + }); |
861 | 861 | }, |
862 | 862 | |
863 | 863 | 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 | + }); |
868 | 868 | }, |
869 | 869 | |
870 | 870 | reverse: function(inline) { |
871 | | - return (inline !== false ? this : this.toArray())._reverse(); |
| 871 | + return (inline !== false ? this : this.toArray())._reverse(); |
872 | 872 | }, |
873 | 873 | |
874 | 874 | reduce: function() { |
875 | | - return this.length > 1 ? this : this[0]; |
| 875 | + return this.length > 1 ? this : this[0]; |
876 | 876 | }, |
877 | 877 | |
878 | 878 | 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 | + }); |
884 | 884 | }, |
885 | 885 | |
886 | 886 | 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 | + }); |
890 | 890 | }, |
891 | 891 | |
892 | 892 | clone: function() { |
893 | | - return [].concat(this); |
| 893 | + return [].concat(this); |
894 | 894 | }, |
895 | 895 | |
896 | 896 | size: function() { |
897 | | - return this.length; |
| 897 | + return this.length; |
898 | 898 | }, |
899 | 899 | |
900 | 900 | inspect: function() { |
901 | | - return '[' + this.map(Object.inspect).join(', ') + ']'; |
| 901 | + return '[' + this.map(Object.inspect).join(', ') + ']'; |
902 | 902 | }, |
903 | 903 | |
904 | 904 | 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(', ') + ']'; |
911 | 911 | } |
912 | 912 | }); |
913 | 913 | |
— | — | @@ -919,7 +919,7 @@ |
920 | 920 | var length = this.length; |
921 | 921 | if (i < 0) i = length + i; |
922 | 922 | for (; i < length; i++) |
923 | | - if (this[i] === item) return i; |
| 923 | + if (this[i] === item) return i; |
924 | 924 | return -1; |
925 | 925 | }; |
926 | 926 | |
— | — | @@ -939,40 +939,40 @@ |
940 | 940 | |
941 | 941 | if (Prototype.Browser.Opera){ |
942 | 942 | 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; |
954 | 954 | }; |
955 | 955 | } |
956 | 956 | Object.extend(Number.prototype, { |
957 | 957 | toColorPart: function() { |
958 | | - return this.toPaddedString(2, 16); |
| 958 | + return this.toPaddedString(2, 16); |
959 | 959 | }, |
960 | 960 | |
961 | 961 | succ: function() { |
962 | | - return this + 1; |
| 962 | + return this + 1; |
963 | 963 | }, |
964 | 964 | |
965 | 965 | times: function(iterator) { |
966 | | - $R(0, this, true).each(iterator); |
967 | | - return this; |
| 966 | + $R(0, this, true).each(iterator); |
| 967 | + return this; |
968 | 968 | }, |
969 | 969 | |
970 | 970 | 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; |
973 | 973 | }, |
974 | 974 | |
975 | 975 | toJSON: function() { |
976 | | - return isFinite(this) ? this.toString() : 'null'; |
| 976 | + return isFinite(this) ? this.toString() : 'null'; |
977 | 977 | } |
978 | 978 | }); |
979 | 979 | |
— | — | @@ -985,115 +985,115 @@ |
986 | 986 | |
987 | 987 | var Hash = Class.create(Enumerable, (function() { |
988 | 988 | 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; |
993 | 993 | }()) { |
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 | + } |
1006 | 1006 | } 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 | + } |
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | 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)); |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | 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 | + }, |
1026 | 1026 | |
1027 | | - _each: each, |
| 1027 | + _each: each, |
1028 | 1028 | |
1029 | | - set: function(key, value) { |
1030 | | - return this._object[key] = value; |
1031 | | - }, |
| 1029 | + set: function(key, value) { |
| 1030 | + return this._object[key] = value; |
| 1031 | + }, |
1032 | 1032 | |
1033 | | - get: function(key) { |
1034 | | - return this._object[key]; |
1035 | | - }, |
| 1033 | + get: function(key) { |
| 1034 | + return this._object[key]; |
| 1035 | + }, |
1036 | 1036 | |
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 | + }, |
1042 | 1042 | |
1043 | | - toObject: function() { |
1044 | | - return Object.clone(this._object); |
1045 | | - }, |
| 1043 | + toObject: function() { |
| 1044 | + return Object.clone(this._object); |
| 1045 | + }, |
1046 | 1046 | |
1047 | | - keys: function() { |
1048 | | - return this.pluck('key'); |
1049 | | - }, |
| 1047 | + keys: function() { |
| 1048 | + return this.pluck('key'); |
| 1049 | + }, |
1050 | 1050 | |
1051 | | - values: function() { |
1052 | | - return this.pluck('value'); |
1053 | | - }, |
| 1051 | + values: function() { |
| 1052 | + return this.pluck('value'); |
| 1053 | + }, |
1054 | 1054 | |
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 | + }, |
1061 | 1061 | |
1062 | | - merge: function(object) { |
1063 | | - return this.clone().update(object); |
1064 | | - }, |
| 1062 | + merge: function(object) { |
| 1063 | + return this.clone().update(object); |
| 1064 | + }, |
1065 | 1065 | |
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 | + }, |
1072 | 1072 | |
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; |
1076 | 1076 | |
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 | + }, |
1084 | 1084 | |
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 | + }, |
1090 | 1090 | |
1091 | | - toJSON: function() { |
1092 | | - return Object.toJSON(this.toObject()); |
1093 | | - }, |
| 1091 | + toJSON: function() { |
| 1092 | + return Object.toJSON(this.toObject()); |
| 1093 | + }, |
1094 | 1094 | |
1095 | | - clone: function() { |
1096 | | - return new Hash(this); |
1097 | | - } |
| 1095 | + clone: function() { |
| 1096 | + return new Hash(this); |
| 1097 | + } |
1098 | 1098 | } |
1099 | 1099 | })()); |
1100 | 1100 | |
— | — | @@ -1101,25 +1101,25 @@ |
1102 | 1102 | Hash.from = $H; |
1103 | 1103 | var ObjectRange = Class.create(Enumerable, { |
1104 | 1104 | 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; |
1108 | 1108 | }, |
1109 | 1109 | |
1110 | 1110 | _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 | + } |
1116 | 1116 | }, |
1117 | 1117 | |
1118 | 1118 | 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; |
1124 | 1124 | } |
1125 | 1125 | }); |
1126 | 1126 | |
— | — | @@ -1129,11 +1129,11 @@ |
1130 | 1130 | |
1131 | 1131 | var Ajax = { |
1132 | 1132 | 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; |
1138 | 1138 | }, |
1139 | 1139 | |
1140 | 1140 | activeRequestCount: 0 |
— | — | @@ -1143,26 +1143,26 @@ |
1144 | 1144 | responders: [], |
1145 | 1145 | |
1146 | 1146 | _each: function(iterator) { |
1147 | | - this.responders._each(iterator); |
| 1147 | + this.responders._each(iterator); |
1148 | 1148 | }, |
1149 | 1149 | |
1150 | 1150 | register: function(responder) { |
1151 | | - if (!this.include(responder)) |
1152 | | - this.responders.push(responder); |
| 1151 | + if (!this.include(responder)) |
| 1152 | + this.responders.push(responder); |
1153 | 1153 | }, |
1154 | 1154 | |
1155 | 1155 | unregister: function(responder) { |
1156 | | - this.responders = this.responders.without(responder); |
| 1156 | + this.responders = this.responders.without(responder); |
1157 | 1157 | }, |
1158 | 1158 | |
1159 | 1159 | 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 | + }); |
1167 | 1167 | } |
1168 | 1168 | }; |
1169 | 1169 | |
— | — | @@ -1175,20 +1175,20 @@ |
1176 | 1176 | |
1177 | 1177 | Ajax.Base = Class.create({ |
1178 | 1178 | 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 || { }); |
1189 | 1189 | |
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(); |
1193 | 1193 | } |
1194 | 1194 | }); |
1195 | 1195 | |
— | — | @@ -1196,160 +1196,160 @@ |
1197 | 1197 | _complete: false, |
1198 | 1198 | |
1199 | 1199 | 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); |
1203 | 1203 | }, |
1204 | 1204 | |
1205 | 1205 | 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); |
1209 | 1209 | |
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 | + } |
1215 | 1215 | |
1216 | | - this.parameters = params; |
| 1216 | + this.parameters = params; |
1217 | 1217 | |
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 | + } |
1225 | 1225 | |
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); |
1230 | 1230 | |
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); |
1233 | 1233 | |
1234 | | - if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); |
| 1234 | + if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); |
1235 | 1235 | |
1236 | | - this.transport.onreadystatechange = this.onStateChange.bind(this); |
1237 | | - this.setRequestHeaders(); |
| 1236 | + this.transport.onreadystatechange = this.onStateChange.bind(this); |
| 1237 | + this.setRequestHeaders(); |
1238 | 1238 | |
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); |
1241 | 1241 | |
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(); |
1245 | 1245 | |
1246 | | - } |
1247 | | - catch (e) { |
1248 | | - this.dispatchException(e); |
1249 | | - } |
| 1246 | + } |
| 1247 | + catch (e) { |
| 1248 | + this.dispatchException(e); |
| 1249 | + } |
1250 | 1250 | }, |
1251 | 1251 | |
1252 | 1252 | 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); |
1256 | 1256 | }, |
1257 | 1257 | |
1258 | 1258 | 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 | + }; |
1264 | 1264 | |
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 : ''); |
1268 | 1268 | |
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 | + } |
1277 | 1277 | |
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; |
1281 | 1281 | |
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 | + } |
1288 | 1288 | |
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]); |
1291 | 1291 | }, |
1292 | 1292 | |
1293 | 1293 | 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); |
1296 | 1296 | }, |
1297 | 1297 | |
1298 | 1298 | 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 } |
1302 | 1302 | }, |
1303 | 1303 | |
1304 | 1304 | 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); |
1306 | 1306 | |
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 | + } |
1316 | 1316 | |
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 | + } |
1323 | 1323 | |
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 | + } |
1330 | 1330 | |
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 | + } |
1335 | 1335 | }, |
1336 | 1336 | |
1337 | 1337 | 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 } |
1341 | 1341 | }, |
1342 | 1342 | |
1343 | 1343 | 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 | + } |
1349 | 1349 | }, |
1350 | 1350 | |
1351 | 1351 | 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); |
1354 | 1354 | } |
1355 | 1355 | }); |
1356 | 1356 | |
— | — | @@ -1358,174 +1358,174 @@ |
1359 | 1359 | |
1360 | 1360 | Ajax.Response = Class.create({ |
1361 | 1361 | 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; |
1365 | 1365 | |
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 | + } |
1372 | 1372 | |
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 | + } |
1378 | 1378 | }, |
1379 | 1379 | |
1380 | | - status: 0, |
| 1380 | + status: 0, |
1381 | 1381 | statusText: '', |
1382 | 1382 | |
1383 | 1383 | getStatus: Ajax.Request.prototype.getStatus, |
1384 | 1384 | |
1385 | 1385 | getStatusText: function() { |
1386 | | - try { |
1387 | | - return this.transport.statusText || ''; |
1388 | | - } catch (e) { return '' } |
| 1386 | + try { |
| 1387 | + return this.transport.statusText || ''; |
| 1388 | + } catch (e) { return '' } |
1389 | 1389 | }, |
1390 | 1390 | |
1391 | 1391 | getHeader: Ajax.Request.prototype.getHeader, |
1392 | 1392 | |
1393 | 1393 | getAllHeaders: function() { |
1394 | | - try { |
1395 | | - return this.getAllResponseHeaders(); |
1396 | | - } catch (e) { return null } |
| 1394 | + try { |
| 1395 | + return this.getAllResponseHeaders(); |
| 1396 | + } catch (e) { return null } |
1397 | 1397 | }, |
1398 | 1398 | |
1399 | 1399 | getResponseHeader: function(name) { |
1400 | | - return this.transport.getResponseHeader(name); |
| 1400 | + return this.transport.getResponseHeader(name); |
1401 | 1401 | }, |
1402 | 1402 | |
1403 | 1403 | getAllResponseHeaders: function() { |
1404 | | - return this.transport.getAllResponseHeaders(); |
| 1404 | + return this.transport.getAllResponseHeaders(); |
1405 | 1405 | }, |
1406 | 1406 | |
1407 | 1407 | _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 | + } |
1416 | 1416 | }, |
1417 | 1417 | |
1418 | 1418 | _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 | + } |
1428 | 1428 | } |
1429 | 1429 | }); |
1430 | 1430 | |
1431 | 1431 | Ajax.Updater = Class.create(Ajax.Request, { |
1432 | 1432 | 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 | + }; |
1437 | 1437 | |
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); |
1444 | 1444 | |
1445 | | - $super(url, options); |
| 1445 | + $super(url, options); |
1446 | 1446 | }, |
1447 | 1447 | |
1448 | 1448 | 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; |
1451 | 1451 | |
1452 | | - if (!options.evalScripts) responseText = responseText.stripScripts(); |
| 1452 | + if (!options.evalScripts) responseText = responseText.stripScripts(); |
1453 | 1453 | |
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 | + } |
1464 | 1464 | |
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 | + } |
1468 | 1468 | } |
1469 | 1469 | }); |
1470 | 1470 | |
1471 | 1471 | Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { |
1472 | 1472 | initialize: function($super, container, url, options) { |
1473 | | - $super(options); |
1474 | | - this.onComplete = this.options.onComplete; |
| 1473 | + $super(options); |
| 1474 | + this.onComplete = this.options.onComplete; |
1475 | 1475 | |
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); |
1478 | 1478 | |
1479 | | - this.updater = { }; |
1480 | | - this.container = container; |
1481 | | - this.url = url; |
| 1479 | + this.updater = { }; |
| 1480 | + this.container = container; |
| 1481 | + this.url = url; |
1482 | 1482 | |
1483 | | - this.start(); |
| 1483 | + this.start(); |
1484 | 1484 | }, |
1485 | 1485 | |
1486 | 1486 | start: function() { |
1487 | | - this.options.onComplete = this.updateComplete.bind(this); |
1488 | | - this.onTimerEvent(); |
| 1487 | + this.options.onComplete = this.updateComplete.bind(this); |
| 1488 | + this.onTimerEvent(); |
1489 | 1489 | }, |
1490 | 1490 | |
1491 | 1491 | 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); |
1495 | 1495 | }, |
1496 | 1496 | |
1497 | 1497 | 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); |
1501 | 1501 | |
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); |
1505 | 1505 | }, |
1506 | 1506 | |
1507 | 1507 | 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); |
1509 | 1509 | } |
1510 | 1510 | }); |
1511 | 1511 | function $(element) { |
1512 | 1512 | 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; |
1516 | 1516 | } |
1517 | 1517 | if (Object.isString(element)) |
1518 | | - element = document.getElementById(element); |
| 1518 | + element = document.getElementById(element); |
1519 | 1519 | return Element.extend(element); |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | if (Prototype.BrowserFeatures.XPath) { |
1523 | 1523 | 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; |
1530 | 1530 | }; |
1531 | 1531 | } |
1532 | 1532 | |
— | — | @@ -1536,34 +1536,34 @@ |
1537 | 1537 | if (!Node.ELEMENT_NODE) { |
1538 | 1538 | // DOM level 2 ECMAScript Language Binding |
1539 | 1539 | 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 |
1552 | 1552 | }); |
1553 | 1553 | } |
1554 | 1554 | |
1555 | 1555 | (function() { |
1556 | 1556 | var element = this.Element; |
1557 | 1557 | 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); |
1568 | 1568 | }; |
1569 | 1569 | Object.extend(this.Element, element || { }); |
1570 | 1570 | }).call(window); |
— | — | @@ -1572,585 +1572,585 @@ |
1573 | 1573 | |
1574 | 1574 | Element.Methods = { |
1575 | 1575 | visible: function(element) { |
1576 | | - return $(element).style.display != 'none'; |
| 1576 | + return $(element).style.display != 'none'; |
1577 | 1577 | }, |
1578 | 1578 | |
1579 | 1579 | 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; |
1583 | 1583 | }, |
1584 | 1584 | |
1585 | 1585 | hide: function(element) { |
1586 | | - $(element).style.display = 'none'; |
1587 | | - return element; |
| 1586 | + $(element).style.display = 'none'; |
| 1587 | + return element; |
1588 | 1588 | }, |
1589 | 1589 | |
1590 | 1590 | show: function(element) { |
1591 | | - $(element).style.display = ''; |
1592 | | - return element; |
| 1591 | + $(element).style.display = ''; |
| 1592 | + return element; |
1593 | 1593 | }, |
1594 | 1594 | |
1595 | 1595 | 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; |
1599 | 1599 | }, |
1600 | 1600 | |
1601 | 1601 | 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; |
1609 | 1609 | }, |
1610 | 1610 | |
1611 | 1611 | 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; |
1623 | 1623 | }, |
1624 | 1624 | |
1625 | 1625 | insert: function(element, insertions) { |
1626 | | - element = $(element); |
| 1626 | + element = $(element); |
1627 | 1627 | |
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}; |
1631 | 1631 | |
1632 | | - var content, t, range; |
| 1632 | + var content, t, range; |
1633 | 1633 | |
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]; |
1638 | 1638 | |
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 | + } |
1644 | 1644 | |
1645 | | - content = Object.toHTML(content); |
| 1645 | + content = Object.toHTML(content); |
1646 | 1646 | |
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())); |
1650 | 1650 | |
1651 | | - content.evalScripts.bind(content).defer(); |
1652 | | - } |
| 1651 | + content.evalScripts.bind(content).defer(); |
| 1652 | + } |
1653 | 1653 | |
1654 | | - return element; |
| 1654 | + return element; |
1655 | 1655 | }, |
1656 | 1656 | |
1657 | 1657 | 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; |
1667 | 1667 | }, |
1668 | 1668 | |
1669 | 1669 | 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 + '>'; |
1678 | 1678 | }, |
1679 | 1679 | |
1680 | 1680 | 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; |
1687 | 1687 | }, |
1688 | 1688 | |
1689 | 1689 | ancestors: function(element) { |
1690 | | - return $(element).recursivelyCollect('parentNode'); |
| 1690 | + return $(element).recursivelyCollect('parentNode'); |
1691 | 1691 | }, |
1692 | 1692 | |
1693 | 1693 | descendants: function(element) { |
1694 | | - return $A($(element).getElementsByTagName('*')).each(Element.extend); |
| 1694 | + return $A($(element).getElementsByTagName('*')).each(Element.extend); |
1695 | 1695 | }, |
1696 | 1696 | |
1697 | 1697 | 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); |
1701 | 1701 | }, |
1702 | 1702 | |
1703 | 1703 | 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 []; |
1708 | 1708 | }, |
1709 | 1709 | |
1710 | 1710 | previousSiblings: function(element) { |
1711 | | - return $(element).recursivelyCollect('previousSibling'); |
| 1711 | + return $(element).recursivelyCollect('previousSibling'); |
1712 | 1712 | }, |
1713 | 1713 | |
1714 | 1714 | nextSiblings: function(element) { |
1715 | | - return $(element).recursivelyCollect('nextSibling'); |
| 1715 | + return $(element).recursivelyCollect('nextSibling'); |
1716 | 1716 | }, |
1717 | 1717 | |
1718 | 1718 | 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()); |
1721 | 1721 | }, |
1722 | 1722 | |
1723 | 1723 | 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)); |
1727 | 1727 | }, |
1728 | 1728 | |
1729 | 1729 | 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]; |
1735 | 1735 | }, |
1736 | 1736 | |
1737 | 1737 | 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]; |
1743 | 1743 | }, |
1744 | 1744 | |
1745 | 1745 | 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]; |
1751 | 1751 | }, |
1752 | 1752 | |
1753 | 1753 | 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]; |
1759 | 1759 | }, |
1760 | 1760 | |
1761 | 1761 | 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); |
1764 | 1764 | }, |
1765 | 1765 | |
1766 | 1766 | 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); |
1769 | 1769 | }, |
1770 | 1770 | |
1771 | 1771 | 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; |
1778 | 1778 | }, |
1779 | 1779 | |
1780 | 1780 | 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); |
1792 | 1792 | }, |
1793 | 1793 | |
1794 | 1794 | 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; |
1797 | 1797 | |
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; |
1800 | 1800 | |
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; |
1811 | 1811 | }, |
1812 | 1812 | |
1813 | 1813 | getHeight: function(element) { |
1814 | | - return $(element).getDimensions().height; |
| 1814 | + return $(element).getDimensions().height; |
1815 | 1815 | }, |
1816 | 1816 | |
1817 | 1817 | getWidth: function(element) { |
1818 | | - return $(element).getDimensions().width; |
| 1818 | + return $(element).getDimensions().width; |
1819 | 1819 | }, |
1820 | 1820 | |
1821 | 1821 | classNames: function(element) { |
1822 | | - return new Element.ClassNames(element); |
| 1822 | + return new Element.ClassNames(element); |
1823 | 1823 | }, |
1824 | 1824 | |
1825 | 1825 | 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))); |
1830 | 1830 | }, |
1831 | 1831 | |
1832 | 1832 | 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; |
1837 | 1837 | }, |
1838 | 1838 | |
1839 | 1839 | 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; |
1844 | 1844 | }, |
1845 | 1845 | |
1846 | 1846 | 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); |
1850 | 1850 | }, |
1851 | 1851 | |
1852 | 1852 | // removes whitespace-only text node children |
1853 | 1853 | 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; |
1863 | 1863 | }, |
1864 | 1864 | |
1865 | 1865 | empty: function(element) { |
1866 | | - return $(element).innerHTML.blank(); |
| 1866 | + return $(element).innerHTML.blank(); |
1867 | 1867 | }, |
1868 | 1868 | |
1869 | 1869 | descendantOf: function(element, ancestor) { |
1870 | | - element = $(element), ancestor = $(ancestor); |
| 1870 | + element = $(element), ancestor = $(ancestor); |
1871 | 1871 | |
1872 | | - if (element.compareDocumentPosition) |
1873 | | - return (element.compareDocumentPosition(ancestor) & 8) === 8; |
| 1872 | + if (element.compareDocumentPosition) |
| 1873 | + return (element.compareDocumentPosition(ancestor) & 8) === 8; |
1874 | 1874 | |
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 | + } |
1884 | 1884 | |
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; |
1888 | 1888 | }, |
1889 | 1889 | |
1890 | 1890 | 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; |
1895 | 1895 | }, |
1896 | 1896 | |
1897 | 1897 | 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; |
1907 | 1907 | }, |
1908 | 1908 | |
1909 | 1909 | getOpacity: function(element) { |
1910 | | - return $(element).getStyle('opacity'); |
| 1910 | + return $(element).getStyle('opacity'); |
1911 | 1911 | }, |
1912 | 1912 | |
1913 | 1913 | 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]; |
1927 | 1927 | |
1928 | | - return element; |
| 1928 | + return element; |
1929 | 1929 | }, |
1930 | 1930 | |
1931 | 1931 | 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; |
1936 | 1936 | }, |
1937 | 1937 | |
1938 | 1938 | 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}; |
1943 | 1943 | |
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}; |
1959 | 1959 | }, |
1960 | 1960 | |
1961 | 1961 | 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; |
1975 | 1975 | }, |
1976 | 1976 | |
1977 | 1977 | 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; |
1988 | 1988 | }, |
1989 | 1989 | |
1990 | 1990 | 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; |
1997 | 1997 | }, |
1998 | 1998 | |
1999 | 1999 | 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; |
2005 | 2005 | }, |
2006 | 2006 | |
2007 | 2007 | 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); |
2015 | 2015 | }, |
2016 | 2016 | |
2017 | 2017 | 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); |
2030 | 2030 | }, |
2031 | 2031 | |
2032 | 2032 | 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. |
2036 | 2036 | |
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; |
2042 | 2042 | |
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; |
2047 | 2047 | |
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; |
2054 | 2054 | }, |
2055 | 2055 | |
2056 | 2056 | 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. |
2060 | 2060 | |
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); |
2064 | 2064 | |
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; |
2070 | 2070 | }, |
2071 | 2071 | |
2072 | 2072 | 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); |
2080 | 2080 | }, |
2081 | 2081 | |
2082 | 2082 | 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); |
2085 | 2085 | |
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); |
2089 | 2089 | |
2090 | | - return $(document.body); |
| 2090 | + return $(document.body); |
2091 | 2091 | }, |
2092 | 2092 | |
2093 | 2093 | viewportOffset: function(forElement) { |
2094 | | - var valueT = 0, valueL = 0; |
| 2094 | + var valueT = 0, valueL = 0; |
2095 | 2095 | |
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; |
2100 | 2100 | |
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; |
2104 | 2104 | |
2105 | | - } while (element = element.offsetParent); |
| 2105 | + } while (element = element.offsetParent); |
2106 | 2106 | |
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); |
2114 | 2114 | |
2115 | | - return Element._returnOffset(valueL, valueT); |
| 2115 | + return Element._returnOffset(valueL, valueT); |
2116 | 2116 | }, |
2117 | 2117 | |
2118 | 2118 | 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] || { }); |
2127 | 2127 | |
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(); |
2131 | 2131 | |
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 | + } |
2142 | 2142 | |
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 | + } |
2148 | 2148 | |
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; |
2155 | 2155 | } |
2156 | 2156 | }; |
2157 | 2157 | |
— | — | @@ -2163,307 +2163,307 @@ |
2164 | 2164 | |
2165 | 2165 | Element._attributeTranslations = { |
2166 | 2166 | write: { |
2167 | | - names: { |
2168 | | - className: 'class', |
2169 | | - htmlFor: 'for' |
2170 | | - }, |
2171 | | - values: { } |
| 2167 | + names: { |
| 2168 | + className: 'class', |
| 2169 | + htmlFor: 'for' |
| 2170 | + }, |
| 2171 | + values: { } |
2172 | 2172 | } |
2173 | 2173 | }; |
2174 | 2174 | |
2175 | 2175 | |
2176 | 2176 | if (!document.createRange || Prototype.Browser.Opera) { |
2177 | 2177 | Element.Methods.insert = function(element, insertions) { |
2178 | | - element = $(element); |
| 2178 | + element = $(element); |
2179 | 2179 | |
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 }; |
2183 | 2183 | |
2184 | | - var t = Element._insertionTranslations, content, position, pos, tagName; |
| 2184 | + var t = Element._insertionTranslations, content, position, pos, tagName; |
2185 | 2185 | |
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]; |
2190 | 2190 | |
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 | + } |
2196 | 2196 | |
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(); |
2200 | 2200 | |
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()); |
2207 | 2207 | |
2208 | | - content.evalScripts.bind(content).defer(); |
2209 | | - } |
| 2208 | + content.evalScripts.bind(content).defer(); |
| 2209 | + } |
2210 | 2210 | |
2211 | | - return element; |
| 2211 | + return element; |
2212 | 2212 | }; |
2213 | 2213 | } |
2214 | 2214 | |
2215 | 2215 | if (Prototype.Browser.Opera) { |
2216 | 2216 | Element.Methods._getStyle = Element.Methods.getStyle; |
2217 | 2217 | 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 | + } |
2226 | 2226 | }; |
2227 | 2227 | Element.Methods._readAttribute = Element.Methods.readAttribute; |
2228 | 2228 | 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); |
2231 | 2231 | }; |
2232 | 2232 | } |
2233 | 2233 | |
2234 | 2234 | else if (Prototype.Browser.IE) { |
2235 | 2235 | $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 | + ); |
2247 | 2247 | }); |
2248 | 2248 | |
2249 | 2249 | 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]; |
2254 | 2254 | |
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 | + } |
2260 | 2260 | |
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; |
2267 | 2267 | }; |
2268 | 2268 | |
2269 | 2269 | 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; |
2278 | 2278 | |
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; |
2288 | 2288 | }; |
2289 | 2289 | |
2290 | 2290 | 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 | + } |
2319 | 2319 | }; |
2320 | 2320 | |
2321 | 2321 | 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 | + }, |
2327 | 2327 | |
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 | + } |
2332 | 2332 | }; |
2333 | 2333 | |
2334 | 2334 | Element._attributeTranslations.has = {}; |
2335 | 2335 | |
2336 | 2336 | $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; |
2340 | 2340 | }); |
2341 | 2341 | |
2342 | 2342 | (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 | + }); |
2371 | 2371 | })(Element._attributeTranslations.read.values); |
2372 | 2372 | } |
2373 | 2373 | |
2374 | 2374 | else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { |
2375 | 2375 | 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; |
2380 | 2380 | }; |
2381 | 2381 | } |
2382 | 2382 | |
2383 | 2383 | else if (Prototype.Browser.WebKit) { |
2384 | 2384 | 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; |
2388 | 2388 | |
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) { } |
2397 | 2397 | |
2398 | | - return element; |
| 2398 | + return element; |
2399 | 2399 | }; |
2400 | 2400 | |
2401 | 2401 | // Safari returns margins on body which is incorrect if the child is absolutely |
2402 | 2402 | // positioned. For performance reasons, redefine Position.cumulativeOffset for |
2403 | 2403 | // KHTML/WebKit only. |
2404 | 2404 | 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; |
2411 | 2411 | |
2412 | | - element = element.offsetParent; |
2413 | | - } while (element); |
| 2412 | + element = element.offsetParent; |
| 2413 | + } while (element); |
2414 | 2414 | |
2415 | | - return Element._returnOffset(valueL, valueT); |
| 2415 | + return Element._returnOffset(valueL, valueT); |
2416 | 2416 | }; |
2417 | 2417 | } |
2418 | 2418 | |
2419 | 2419 | if (Prototype.Browser.IE || Prototype.Browser.Opera) { |
2420 | 2420 | // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements |
2421 | 2421 | Element.Methods.update = function(element, content) { |
2422 | | - element = $(element); |
| 2422 | + element = $(element); |
2423 | 2423 | |
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); |
2426 | 2426 | |
2427 | | - content = Object.toHTML(content); |
2428 | | - var tagName = element.tagName.toUpperCase(); |
| 2427 | + content = Object.toHTML(content); |
| 2428 | + var tagName = element.tagName.toUpperCase(); |
2429 | 2429 | |
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(); |
2436 | 2436 | |
2437 | | - content.evalScripts.bind(content).defer(); |
2438 | | - return element; |
| 2437 | + content.evalScripts.bind(content).defer(); |
| 2438 | + return element; |
2439 | 2439 | }; |
2440 | 2440 | } |
2441 | 2441 | |
2442 | 2442 | if (document.createElement('div').outerHTML) { |
2443 | 2443 | Element.Methods.replace = function(element, content) { |
2444 | | - element = $(element); |
| 2444 | + element = $(element); |
2445 | 2445 | |
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 | + } |
2451 | 2451 | |
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(); |
2454 | 2454 | |
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(); |
2465 | 2465 | |
2466 | | - content.evalScripts.bind(content).defer(); |
2467 | | - return element; |
| 2466 | + content.evalScripts.bind(content).defer(); |
| 2467 | + return element; |
2468 | 2468 | }; |
2469 | 2469 | } |
2470 | 2470 | |
— | — | @@ -2483,62 +2483,62 @@ |
2484 | 2484 | |
2485 | 2485 | Element._insertionTranslations = { |
2486 | 2486 | 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 | + } |
2494 | 2494 | }, |
2495 | 2495 | 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 | + } |
2504 | 2504 | }, |
2505 | 2505 | 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 | + } |
2510 | 2510 | }, |
2511 | 2511 | 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 | + } |
2519 | 2519 | }, |
2520 | 2520 | 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] |
2526 | 2526 | } |
2527 | 2527 | }; |
2528 | 2528 | |
2529 | 2529 | (function() { |
2530 | 2530 | this.bottom.initializeRange = this.top.initializeRange; |
2531 | 2531 | 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 |
2535 | 2535 | }); |
2536 | 2536 | }).call(Element._insertionTranslations); |
2537 | 2537 | |
2538 | 2538 | Element.Methods.Simulated = { |
2539 | 2539 | 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; |
2543 | 2543 | } |
2544 | 2544 | }; |
2545 | 2545 | |
— | — | @@ -2547,7 +2547,7 @@ |
2548 | 2548 | Object.extend(Element, Element.Methods); |
2549 | 2549 | |
2550 | 2550 | if (!Prototype.BrowserFeatures.ElementExtensions && |
2551 | | - document.createElement('div').__proto__) { |
| 2551 | + document.createElement('div').__proto__) { |
2552 | 2552 | window.HTMLElement = { }; |
2553 | 2553 | window.HTMLElement.prototype = document.createElement('div').__proto__; |
2554 | 2554 | Prototype.BrowserFeatures.ElementExtensions = true; |
— | — | @@ -2555,37 +2555,37 @@ |
2556 | 2556 | |
2557 | 2557 | Element.extend = (function() { |
2558 | 2558 | if (Prototype.BrowserFeatures.SpecificElementExtensions) |
2559 | | - return Prototype.K; |
| 2559 | + return Prototype.K; |
2560 | 2560 | |
2561 | 2561 | var Methods = { }, ByTag = Element.Methods.ByTag; |
2562 | 2562 | |
2563 | 2563 | 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; |
2566 | 2566 | |
2567 | | - var methods = Object.clone(Methods), |
2568 | | - tagName = element.tagName, property, value; |
| 2567 | + var methods = Object.clone(Methods), |
| 2568 | + tagName = element.tagName, property, value; |
2569 | 2569 | |
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]); |
2572 | 2572 | |
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 | + } |
2578 | 2578 | |
2579 | | - element._extendedByPrototype = Prototype.emptyFunction; |
2580 | | - return element; |
| 2579 | + element._extendedByPrototype = Prototype.emptyFunction; |
| 2580 | + return element; |
2581 | 2581 | |
2582 | 2582 | }, { |
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 | + } |
2590 | 2590 | }); |
2591 | 2591 | |
2592 | 2592 | extend.refresh(); |
— | — | @@ -2601,80 +2601,80 @@ |
2602 | 2602 | var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; |
2603 | 2603 | |
2604 | 2604 | 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 | + }); |
2613 | 2613 | } |
2614 | 2614 | |
2615 | 2615 | if (arguments.length == 2) { |
2616 | | - var tagName = methods; |
2617 | | - methods = arguments[1]; |
| 2616 | + var tagName = methods; |
| 2617 | + methods = arguments[1]; |
2618 | 2618 | } |
2619 | 2619 | |
2620 | 2620 | if (!tagName) Object.extend(Element.Methods, methods || { }); |
2621 | 2621 | 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); |
2624 | 2624 | } |
2625 | 2625 | |
2626 | 2626 | 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); |
2631 | 2631 | } |
2632 | 2632 | |
2633 | 2633 | 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 | + } |
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | 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]; |
2662 | 2662 | |
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]; |
2666 | 2666 | } |
2667 | 2667 | |
2668 | 2668 | 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); |
2671 | 2671 | } |
2672 | 2672 | |
2673 | 2673 | 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 | + } |
2679 | 2679 | } |
2680 | 2680 | |
2681 | 2681 | Object.extend(Element, Element.Methods); |
— | — | @@ -2686,27 +2686,27 @@ |
2687 | 2687 | |
2688 | 2688 | document.viewport = { |
2689 | 2689 | 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; |
2697 | 2697 | }, |
2698 | 2698 | |
2699 | 2699 | getWidth: function() { |
2700 | | - return this.getDimensions().width; |
| 2700 | + return this.getDimensions().width; |
2701 | 2701 | }, |
2702 | 2702 | |
2703 | 2703 | getHeight: function() { |
2704 | | - return this.getDimensions().height; |
| 2704 | + return this.getDimensions().height; |
2705 | 2705 | }, |
2706 | 2706 | |
2707 | 2707 | 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); |
2711 | 2711 | } |
2712 | 2712 | }; |
2713 | 2713 | /* Portions of the Selector class are derived from Jack Slocum’s DomQuery, |
— | — | @@ -2715,117 +2715,117 @@ |
2716 | 2716 | |
2717 | 2717 | var Selector = Class.create({ |
2718 | 2718 | initialize: function(expression) { |
2719 | | - this.expression = expression.strip(); |
2720 | | - this.compileMatcher(); |
| 2719 | + this.expression = expression.strip(); |
| 2720 | + this.compileMatcher(); |
2721 | 2721 | }, |
2722 | 2722 | |
2723 | 2723 | 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(); |
2727 | 2727 | |
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; |
2730 | 2730 | |
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 | + } |
2735 | 2735 | |
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;"]; |
2738 | 2738 | |
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 | + } |
2751 | 2751 | |
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; |
2755 | 2755 | }, |
2756 | 2756 | |
2757 | 2757 | 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; |
2760 | 2760 | |
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 | + } |
2764 | 2764 | |
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 | + } |
2777 | 2777 | |
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; |
2780 | 2780 | }, |
2781 | 2781 | |
2782 | 2782 | 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); |
2786 | 2786 | }, |
2787 | 2787 | |
2788 | 2788 | match: function(element) { |
2789 | | - this.tokens = []; |
| 2789 | + this.tokens = []; |
2790 | 2790 | |
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; |
2793 | 2793 | |
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 | + } |
2812 | 2812 | |
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 | + } |
2820 | 2820 | |
2821 | | - return match; |
| 2821 | + return match; |
2822 | 2822 | }, |
2823 | 2823 | |
2824 | 2824 | toString: function() { |
2825 | | - return this.expression; |
| 2825 | + return this.expression; |
2826 | 2826 | }, |
2827 | 2827 | |
2828 | 2828 | inspect: function() { |
2829 | | - return "#<Selector:" + this.expression.inspect() + ">"; |
| 2829 | + return "#<Selector:" + this.expression.inspect() + ">"; |
2830 | 2830 | } |
2831 | 2831 | }); |
2832 | 2832 | |
— | — | @@ -2833,507 +2833,507 @@ |
2834 | 2834 | _cache: { }, |
2835 | 2835 | |
2836 | 2836 | 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; |
2879 | 2879 | |
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 | + } |
2932 | 2932 | }, |
2933 | 2933 | |
2934 | 2934 | 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";' |
2951 | 2951 | }, |
2952 | 2952 | |
2953 | 2953 | 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/, |
2960 | 2960 | |
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|([^'"][^\]]*?)))?\]/ |
2968 | 2968 | }, |
2969 | 2969 | |
2970 | 2970 | // for Selector.match and Element#match |
2971 | 2971 | 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 | + }, |
2975 | 2975 | |
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 | + }, |
2979 | 2979 | |
2980 | | - id: function(element, matches) { |
2981 | | - return element.id === matches[1]; |
2982 | | - }, |
| 2980 | + id: function(element, matches) { |
| 2981 | + return element.id === matches[1]; |
| 2982 | + }, |
2983 | 2983 | |
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 | + }, |
2987 | 2987 | |
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 | + } |
2992 | 2992 | }, |
2993 | 2993 | |
2994 | 2994 | 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 | + }, |
3002 | 3002 | |
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 | + }, |
3009 | 3009 | |
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 | + }, |
3015 | 3015 | |
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 | + }, |
3031 | 3031 | |
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 | + }, |
3043 | 3043 | |
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 | + }, |
3051 | 3051 | |
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 | + }, |
3060 | 3060 | |
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 | + }, |
3068 | 3068 | |
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 | + }, |
3075 | 3075 | |
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 | + }, |
3081 | 3081 | |
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 | + }, |
3087 | 3087 | |
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 | + }, |
3107 | 3107 | |
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 | + }, |
3132 | 3132 | |
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 | + }, |
3137 | 3137 | |
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 | + }, |
3149 | 3149 | |
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 | + }, |
3157 | 3157 | |
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 | + }, |
3168 | 3168 | |
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 | + } |
3174 | 3174 | }, |
3175 | 3175 | |
3176 | 3176 | 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 | + }, |
3220 | 3220 | |
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 | + }, |
3229 | 3229 | |
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 | + }, |
3261 | 3261 | |
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 | + }, |
3270 | 3270 | |
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 | + }, |
3280 | 3280 | |
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 | + }, |
3286 | 3286 | |
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 | + }, |
3292 | 3292 | |
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 | + } |
3298 | 3298 | }, |
3299 | 3299 | |
3300 | 3300 | 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() + '-'); } |
3308 | 3308 | }, |
3309 | 3309 | |
3310 | 3310 | 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; |
3318 | 3318 | }, |
3319 | 3319 | |
3320 | 3320 | 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]; |
3325 | 3325 | }, |
3326 | 3326 | |
3327 | 3327 | 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; |
3338 | 3338 | } |
3339 | 3339 | }); |
3340 | 3340 | |
— | — | @@ -3342,113 +3342,113 @@ |
3343 | 3343 | } |
3344 | 3344 | var Form = { |
3345 | 3345 | reset: function(form) { |
3346 | | - $(form).reset(); |
3347 | | - return form; |
| 3346 | + $(form).reset(); |
| 3347 | + return form; |
3348 | 3348 | }, |
3349 | 3349 | |
3350 | 3350 | 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; |
3354 | 3354 | |
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 | + }); |
3370 | 3370 | |
3371 | | - return options.hash ? data : Object.toQueryString(data); |
| 3371 | + return options.hash ? data : Object.toQueryString(data); |
3372 | 3372 | } |
3373 | 3373 | }; |
3374 | 3374 | |
3375 | 3375 | Form.Methods = { |
3376 | 3376 | serialize: function(form, options) { |
3377 | | - return Form.serializeElements(Form.getElements(form), options); |
| 3377 | + return Form.serializeElements(Form.getElements(form), options); |
3378 | 3378 | }, |
3379 | 3379 | |
3380 | 3380 | 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 | + ); |
3388 | 3388 | }, |
3389 | 3389 | |
3390 | 3390 | getInputs: function(form, typeName, name) { |
3391 | | - form = $(form); |
3392 | | - var inputs = form.getElementsByTagName('input'); |
| 3391 | + form = $(form); |
| 3392 | + var inputs = form.getElementsByTagName('input'); |
3393 | 3393 | |
3394 | | - if (!typeName && !name) return $A(inputs).map(Element.extend); |
| 3394 | + if (!typeName && !name) return $A(inputs).map(Element.extend); |
3395 | 3395 | |
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 | + } |
3402 | 3402 | |
3403 | | - return matchingInputs; |
| 3403 | + return matchingInputs; |
3404 | 3404 | }, |
3405 | 3405 | |
3406 | 3406 | 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; |
3410 | 3410 | }, |
3411 | 3411 | |
3412 | 3412 | 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; |
3416 | 3416 | }, |
3417 | 3417 | |
3418 | 3418 | 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(); |
3425 | 3425 | |
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 | + }); |
3429 | 3429 | }, |
3430 | 3430 | |
3431 | 3431 | focusFirstElement: function(form) { |
3432 | | - form = $(form); |
3433 | | - form.findFirstElement().activate(); |
3434 | | - return form; |
| 3432 | + form = $(form); |
| 3433 | + form.findFirstElement().activate(); |
| 3434 | + return form; |
3435 | 3435 | }, |
3436 | 3436 | |
3437 | 3437 | request: function(form, options) { |
3438 | | - form = $(form), options = Object.clone(options || { }); |
| 3438 | + form = $(form), options = Object.clone(options || { }); |
3439 | 3439 | |
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); |
3443 | 3443 | |
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 | + } |
3448 | 3448 | |
3449 | | - if (form.hasAttribute('method') && !options.method) |
3450 | | - options.method = form.method; |
| 3449 | + if (form.hasAttribute('method') && !options.method) |
| 3450 | + options.method = form.method; |
3451 | 3451 | |
3452 | | - return new Ajax.Request(action, options); |
| 3452 | + return new Ajax.Request(action, options); |
3453 | 3453 | } |
3454 | 3454 | }; |
3455 | 3455 | |
— | — | @@ -3456,74 +3456,74 @@ |
3457 | 3457 | |
3458 | 3458 | Form.Element = { |
3459 | 3459 | focus: function(element) { |
3460 | | - $(element).focus(); |
3461 | | - return element; |
| 3460 | + $(element).focus(); |
| 3461 | + return element; |
3462 | 3462 | }, |
3463 | 3463 | |
3464 | 3464 | select: function(element) { |
3465 | | - $(element).select(); |
3466 | | - return element; |
| 3465 | + $(element).select(); |
| 3466 | + return element; |
3467 | 3467 | } |
3468 | 3468 | }; |
3469 | 3469 | |
3470 | 3470 | Form.Element.Methods = { |
3471 | 3471 | 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 ''; |
3482 | 3482 | }, |
3483 | 3483 | |
3484 | 3484 | 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); |
3488 | 3488 | }, |
3489 | 3489 | |
3490 | 3490 | 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; |
3495 | 3495 | }, |
3496 | 3496 | |
3497 | 3497 | clear: function(element) { |
3498 | | - $(element).value = ''; |
3499 | | - return element; |
| 3498 | + $(element).value = ''; |
| 3499 | + return element; |
3500 | 3500 | }, |
3501 | 3501 | |
3502 | 3502 | present: function(element) { |
3503 | | - return $(element).value != ''; |
| 3503 | + return $(element).value != ''; |
3504 | 3504 | }, |
3505 | 3505 | |
3506 | 3506 | 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; |
3515 | 3515 | }, |
3516 | 3516 | |
3517 | 3517 | 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; |
3522 | 3522 | }, |
3523 | 3523 | |
3524 | 3524 | enable: function(element) { |
3525 | | - element = $(element); |
3526 | | - element.disabled = false; |
3527 | | - return element; |
| 3525 | + element = $(element); |
| 3526 | + element.disabled = false; |
| 3527 | + return element; |
3528 | 3528 | } |
3529 | 3529 | }; |
3530 | 3530 | |
— | — | @@ -3536,64 +3536,64 @@ |
3537 | 3537 | |
3538 | 3538 | Form.Element.Serializers = { |
3539 | 3539 | 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 | + } |
3547 | 3547 | }, |
3548 | 3548 | |
3549 | 3549 | 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; |
3552 | 3552 | }, |
3553 | 3553 | |
3554 | 3554 | 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; |
3557 | 3557 | }, |
3558 | 3558 | |
3559 | 3559 | 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 | + } |
3577 | 3577 | }, |
3578 | 3578 | |
3579 | 3579 | 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; |
3582 | 3582 | }, |
3583 | 3583 | |
3584 | 3584 | 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; |
3587 | 3587 | |
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; |
3593 | 3593 | }, |
3594 | 3594 | |
3595 | 3595 | 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; |
3598 | 3598 | } |
3599 | 3599 | }; |
3600 | 3600 | |
— | — | @@ -3601,30 +3601,30 @@ |
3602 | 3602 | |
3603 | 3603 | Abstract.TimedObserver = Class.create(PeriodicalExecuter, { |
3604 | 3604 | 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(); |
3608 | 3608 | }, |
3609 | 3609 | |
3610 | 3610 | 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 | + } |
3617 | 3617 | } |
3618 | 3618 | }); |
3619 | 3619 | |
3620 | 3620 | Form.Element.Observer = Class.create(Abstract.TimedObserver, { |
3621 | 3621 | getValue: function() { |
3622 | | - return Form.Element.getValue(this.element); |
| 3622 | + return Form.Element.getValue(this.element); |
3623 | 3623 | } |
3624 | 3624 | }); |
3625 | 3625 | |
3626 | 3626 | Form.Observer = Class.create(Abstract.TimedObserver, { |
3627 | 3627 | getValue: function() { |
3628 | | - return Form.serialize(this.element); |
| 3628 | + return Form.serialize(this.element); |
3629 | 3629 | } |
3630 | 3630 | }); |
3631 | 3631 | |
— | — | @@ -3632,68 +3632,68 @@ |
3633 | 3633 | |
3634 | 3634 | Abstract.EventObserver = Class.create({ |
3635 | 3635 | initialize: function(element, callback) { |
3636 | | - this.element = $(element); |
3637 | | - this.callback = callback; |
| 3636 | + this.element = $(element); |
| 3637 | + this.callback = callback; |
3638 | 3638 | |
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); |
3644 | 3644 | }, |
3645 | 3645 | |
3646 | 3646 | 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 | + } |
3652 | 3652 | }, |
3653 | 3653 | |
3654 | 3654 | registerFormCallbacks: function() { |
3655 | | - Form.getElements(this.element).each(this.registerCallback, this); |
| 3655 | + Form.getElements(this.element).each(this.registerCallback, this); |
3656 | 3656 | }, |
3657 | 3657 | |
3658 | 3658 | 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 | + } |
3670 | 3670 | } |
3671 | 3671 | }); |
3672 | 3672 | |
3673 | 3673 | Form.Element.EventObserver = Class.create(Abstract.EventObserver, { |
3674 | 3674 | getValue: function() { |
3675 | | - return Form.Element.getValue(this.element); |
| 3675 | + return Form.Element.getValue(this.element); |
3676 | 3676 | } |
3677 | 3677 | }); |
3678 | 3678 | |
3679 | 3679 | Form.EventObserver = Class.create(Abstract.EventObserver, { |
3680 | 3680 | getValue: function() { |
3681 | | - return Form.serialize(this.element); |
| 3681 | + return Form.serialize(this.element); |
3682 | 3682 | } |
3683 | 3683 | }); |
3684 | 3684 | if (!window.Event) var Event = { }; |
3685 | 3685 | |
3686 | 3686 | Object.extend(Event, { |
3687 | 3687 | KEY_BACKSPACE: 8, |
3688 | | - KEY_TAB: 9, |
| 3688 | + KEY_TAB: 9, |
3689 | 3689 | 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, |
3695 | 3695 | KEY_DELETE: 46, |
3696 | | - KEY_HOME: 36, |
3697 | | - KEY_END: 35, |
| 3696 | + KEY_HOME: 36, |
| 3697 | + KEY_END: 35, |
3698 | 3698 | KEY_PAGEUP: 33, |
3699 | 3699 | KEY_PAGEDOWN: 34, |
3700 | 3700 | KEY_INSERT: 45, |
— | — | @@ -3701,13 +3701,13 @@ |
3702 | 3702 | cache: { }, |
3703 | 3703 | |
3704 | 3704 | 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); |
3712 | 3712 | } |
3713 | 3713 | }); |
3714 | 3714 | |
— | — | @@ -3715,94 +3715,94 @@ |
3716 | 3716 | var isButton; |
3717 | 3717 | |
3718 | 3718 | 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 | + }; |
3723 | 3723 | |
3724 | 3724 | } 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 | + }; |
3732 | 3732 | |
3733 | 3733 | } 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 | + }; |
3737 | 3737 | } |
3738 | 3738 | |
3739 | 3739 | 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) }, |
3743 | 3743 | |
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 | + }, |
3748 | 3748 | |
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 | + }, |
3753 | 3753 | |
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 | + }, |
3762 | 3762 | |
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 }, |
3765 | 3765 | |
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 | + } |
3772 | 3772 | }; |
3773 | 3773 | })(); |
3774 | 3774 | |
3775 | 3775 | Event.extend = (function() { |
3776 | 3776 | 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; |
3779 | 3779 | }); |
3780 | 3780 | |
3781 | 3781 | 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 | + }); |
3787 | 3787 | |
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; |
3791 | 3791 | |
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 | + }; |
3802 | 3802 | |
3803 | 3803 | } 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; |
3807 | 3807 | } |
3808 | 3808 | })(); |
3809 | 3809 | |
— | — | @@ -3810,189 +3810,189 @@ |
3811 | 3811 | var cache = Event.cache; |
3812 | 3812 | |
3813 | 3813 | 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; |
3817 | 3817 | } |
3818 | 3818 | |
3819 | 3819 | function getDOMEventName(eventName) { |
3820 | | - if (eventName && eventName.include(':')) return "dataavailable"; |
3821 | | - return eventName; |
| 3820 | + if (eventName && eventName.include(':')) return "dataavailable"; |
| 3821 | + return eventName; |
3822 | 3822 | } |
3823 | 3823 | |
3824 | 3824 | function getCacheForID(id) { |
3825 | | - return cache[id] = cache[id] || { }; |
| 3825 | + return cache[id] = cache[id] || { }; |
3826 | 3826 | } |
3827 | 3827 | |
3828 | 3828 | 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] || []; |
3831 | 3831 | } |
3832 | 3832 | |
3833 | 3833 | 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; |
3837 | 3837 | |
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; |
3842 | 3842 | |
3843 | | - Event.extend(event); |
3844 | | - handler.call(element, event) |
3845 | | - }; |
| 3843 | + Event.extend(event); |
| 3844 | + handler.call(element, event) |
| 3845 | + }; |
3846 | 3846 | |
3847 | | - wrapper.handler = handler; |
3848 | | - c.push(wrapper); |
3849 | | - return wrapper; |
| 3847 | + wrapper.handler = handler; |
| 3848 | + c.push(wrapper); |
| 3849 | + return wrapper; |
3850 | 3850 | } |
3851 | 3851 | |
3852 | 3852 | 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 }); |
3855 | 3855 | } |
3856 | 3856 | |
3857 | 3857 | 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)); |
3861 | 3861 | } |
3862 | 3862 | |
3863 | 3863 | 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; |
3867 | 3867 | } |
3868 | 3868 | |
3869 | 3869 | if (window.attachEvent) { |
3870 | | - window.attachEvent("onunload", destroyCache); |
| 3870 | + window.attachEvent("onunload", destroyCache); |
3871 | 3871 | } |
3872 | 3872 | |
3873 | 3873 | 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); |
3877 | 3877 | |
3878 | | - var wrapper = createWrapper(element, eventName, handler); |
3879 | | - if (!wrapper) return element; |
| 3878 | + var wrapper = createWrapper(element, eventName, handler); |
| 3879 | + if (!wrapper) return element; |
3880 | 3880 | |
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 | + } |
3886 | 3886 | |
3887 | | - return element; |
3888 | | - }, |
| 3887 | + return element; |
| 3888 | + }, |
3889 | 3889 | |
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); |
3893 | 3893 | |
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; |
3899 | 3899 | |
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 | + } |
3906 | 3906 | |
3907 | | - var wrapper = findWrapper(id, eventName, handler); |
3908 | | - if (!wrapper) return element; |
| 3907 | + var wrapper = findWrapper(id, eventName, handler); |
| 3908 | + if (!wrapper) return element; |
3909 | 3909 | |
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 | + } |
3915 | 3915 | |
3916 | | - destroyWrapper(id, eventName, handler); |
| 3916 | + destroyWrapper(id, eventName, handler); |
3917 | 3917 | |
3918 | | - return element; |
3919 | | - }, |
| 3918 | + return element; |
| 3919 | + }, |
3920 | 3920 | |
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; |
3925 | 3925 | |
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 | + } |
3933 | 3933 | |
3934 | | - event.eventName = eventName; |
3935 | | - event.memo = memo || { }; |
| 3934 | + event.eventName = eventName; |
| 3935 | + event.memo = memo || { }; |
3936 | 3936 | |
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 | + } |
3942 | 3942 | |
3943 | | - return event; |
3944 | | - } |
| 3943 | + return event; |
| 3944 | + } |
3945 | 3945 | }; |
3946 | 3946 | })()); |
3947 | 3947 | |
3948 | 3948 | Object.extend(Event, Event.Methods); |
3949 | 3949 | |
3950 | 3950 | Element.addMethods({ |
3951 | | - fire: Event.fire, |
3952 | | - observe: Event.observe, |
| 3951 | + fire: Event.fire, |
| 3952 | + observe: Event.observe, |
3953 | 3953 | stopObserving: Event.stopObserving |
3954 | 3954 | }); |
3955 | 3955 | |
3956 | 3956 | 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(), |
3959 | 3959 | stopObserving: Element.Methods.stopObserving.methodize() |
3960 | 3960 | }); |
3961 | 3961 | |
3962 | 3962 | (function() { |
3963 | 3963 | /* 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. */ |
3965 | 3965 | |
3966 | 3966 | var timer, fired = false; |
3967 | 3967 | |
3968 | 3968 | 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; |
3973 | 3973 | } |
3974 | 3974 | |
3975 | 3975 | 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); |
3981 | 3981 | |
3982 | | - Event.observe(window, "load", fireContentLoadedEvent); |
| 3982 | + Event.observe(window, "load", fireContentLoadedEvent); |
3983 | 3983 | |
3984 | | - } else { |
3985 | | - document.addEventListener("DOMContentLoaded", |
3986 | | - fireContentLoadedEvent, false); |
3987 | | - } |
| 3984 | + } else { |
| 3985 | + document.addEventListener("DOMContentLoaded", |
| 3986 | + fireContentLoadedEvent, false); |
| 3987 | + } |
3988 | 3988 | |
3989 | 3989 | } 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 | + }; |
3997 | 3997 | } |
3998 | 3998 | })(); |
3999 | 3999 | /*------------------------------- DEPRECATED -------------------------------*/ |
— | — | @@ -4005,19 +4005,19 @@ |
4006 | 4006 | |
4007 | 4007 | var Insertion = { |
4008 | 4008 | Before: function(element, content) { |
4009 | | - return Element.insert(element, {before:content}); |
| 4009 | + return Element.insert(element, {before:content}); |
4010 | 4010 | }, |
4011 | 4011 | |
4012 | 4012 | Top: function(element, content) { |
4013 | | - return Element.insert(element, {top:content}); |
| 4013 | + return Element.insert(element, {top:content}); |
4014 | 4014 | }, |
4015 | 4015 | |
4016 | 4016 | Bottom: function(element, content) { |
4017 | | - return Element.insert(element, {bottom:content}); |
| 4017 | + return Element.insert(element, {bottom:content}); |
4018 | 4018 | }, |
4019 | 4019 | |
4020 | 4020 | After: function(element, content) { |
4021 | | - return Element.insert(element, {after:content}); |
| 4021 | + return Element.insert(element, {after:content}); |
4022 | 4022 | } |
4023 | 4023 | }; |
4024 | 4024 | |
— | — | @@ -4034,52 +4034,52 @@ |
4035 | 4035 | // must be called before calling withinIncludingScrolloffset, every time the |
4036 | 4036 | // page is scrolled |
4037 | 4037 | 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; |
4046 | 4046 | }, |
4047 | 4047 | |
4048 | 4048 | // caches x/y coordinate pair to use with overlap |
4049 | 4049 | 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); |
4055 | 4055 | |
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); |
4060 | 4060 | }, |
4061 | 4061 | |
4062 | 4062 | withinIncludingScrolloffsets: function(element, x, y) { |
4063 | | - var offsetcache = Element.cumulativeScrollOffset(element); |
| 4063 | + var offsetcache = Element.cumulativeScrollOffset(element); |
4064 | 4064 | |
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); |
4068 | 4068 | |
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); |
4073 | 4073 | }, |
4074 | 4074 | |
4075 | 4075 | // within must be called directly before |
4076 | 4076 | 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; |
4084 | 4084 | }, |
4085 | 4085 | |
4086 | 4086 | // Deprecation layer -- use newer Element methods now (1.5.2). |
— | — | @@ -4089,13 +4089,13 @@ |
4090 | 4090 | positionedOffset: Element.Methods.positionedOffset, |
4091 | 4091 | |
4092 | 4092 | absolutize: function(element) { |
4093 | | - Position.prepare(); |
4094 | | - return Element.absolutize(element); |
| 4093 | + Position.prepare(); |
| 4094 | + return Element.absolutize(element); |
4095 | 4095 | }, |
4096 | 4096 | |
4097 | 4097 | relativize: function(element) { |
4098 | | - Position.prepare(); |
4099 | | - return Element.relativize(element); |
| 4098 | + Position.prepare(); |
| 4099 | + return Element.relativize(element); |
4100 | 4100 | }, |
4101 | 4101 | |
4102 | 4102 | realOffset: Element.Methods.cumulativeScrollOffset, |
— | — | @@ -4105,8 +4105,8 @@ |
4106 | 4106 | page: Element.Methods.viewportOffset, |
4107 | 4107 | |
4108 | 4108 | 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); |
4111 | 4111 | } |
4112 | 4112 | }; |
4113 | 4113 | |
— | — | @@ -4114,34 +4114,34 @@ |
4115 | 4115 | |
4116 | 4116 | if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){ |
4117 | 4117 | function iter(name) { |
4118 | | - return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; |
| 4118 | + return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]"; |
4119 | 4119 | } |
4120 | 4120 | |
4121 | 4121 | instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? |
4122 | 4122 | 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) : []; |
4126 | 4126 | } : 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; |
4130 | 4130 | |
4131 | | - var nodes = $(element).getElementsByTagName('*'); |
4132 | | - className = ' ' + className + ' '; |
| 4131 | + var nodes = $(element).getElementsByTagName('*'); |
| 4132 | + className = ' ' + className + ' '; |
4133 | 4133 | |
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; |
4142 | 4142 | }; |
4143 | 4143 | |
4144 | 4144 | return function(className, parentElement) { |
4145 | | - return $(parentElement || document.body).getElementsByClassName(className); |
| 4145 | + return $(parentElement || document.body).getElementsByClassName(className); |
4146 | 4146 | }; |
4147 | 4147 | }(Element.Methods); |
4148 | 4148 | |
— | — | @@ -4150,31 +4150,31 @@ |
4151 | 4151 | Element.ClassNames = Class.create(); |
4152 | 4152 | Element.ClassNames.prototype = { |
4153 | 4153 | initialize: function(element) { |
4154 | | - this.element = $(element); |
| 4154 | + this.element = $(element); |
4155 | 4155 | }, |
4156 | 4156 | |
4157 | 4157 | _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); |
4161 | 4161 | }, |
4162 | 4162 | |
4163 | 4163 | set: function(className) { |
4164 | | - this.element.className = className; |
| 4164 | + this.element.className = className; |
4165 | 4165 | }, |
4166 | 4166 | |
4167 | 4167 | 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(' ')); |
4170 | 4170 | }, |
4171 | 4171 | |
4172 | 4172 | 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(' ')); |
4175 | 4175 | }, |
4176 | 4176 | |
4177 | 4177 | toString: function() { |
4178 | | - return $A(this).join(' '); |
| 4178 | + return $A(this).join(' '); |
4179 | 4179 | } |
4180 | 4180 | }; |
4181 | 4181 | |
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguage.js |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | /** |
3 | 3 | * SMW_NMLanguage.js |
4 | | -* |
| 4 | +* |
5 | 5 | * A class that reads language strings from the server by an ajax call. |
6 | | -* |
| 6 | +* |
7 | 7 | * @author dch |
8 | 8 | * |
9 | 9 | */ |
— | — | @@ -11,13 +11,13 @@ |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * This class provides language dependent strings for an identifier. |
15 | | - * |
| 15 | + * |
16 | 16 | */ |
17 | 17 | NMLanguage.prototype = { |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @public |
21 | | - * |
| 21 | + * |
22 | 22 | * Constructor. |
23 | 23 | */ |
24 | 24 | initialize: function() { |
— | — | @@ -25,14 +25,14 @@ |
26 | 26 | |
27 | 27 | /* |
28 | 28 | * @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 |
31 | 31 | * no message for it. |
32 | | - * |
| 32 | + * |
33 | 33 | * @param string id |
34 | | - * ID of the message to be retrieved. |
| 34 | + * ID of the message to be retrieved. |
35 | 35 | * @return string |
36 | | - * The language dependent message for the given ID. |
| 36 | + * The language dependent message for the given ID. |
37 | 37 | */ |
38 | 38 | getMessage: function(id, type) { |
39 | 39 | switch (type) { |
— | — | @@ -40,16 +40,16 @@ |
41 | 41 | var msg = wgNMUserLanguageStrings[id]; |
42 | 42 | if (!msg) { |
43 | 43 | msg = id; |
44 | | - } |
| 44 | + } |
45 | 45 | break; |
46 | | - |
| 46 | + |
47 | 47 | case "cont": |
48 | 48 | var msg = wgNMContLanguageStrings[id]; |
49 | 49 | if (!msg) { |
50 | 50 | msg = id; |
51 | | - } |
| 51 | + } |
52 | 52 | break; |
53 | | - default: |
| 53 | + default: |
54 | 54 | var msg = wgNMUserLanguageStrings[id]; |
55 | 55 | if (!msg) { |
56 | 56 | var msg = wgNMContLanguageStrings[id]; |
— | — | @@ -57,17 +57,17 @@ |
58 | 58 | msg = id; |
59 | 59 | } |
60 | 60 | } |
61 | | - } |
62 | | - |
| 61 | + } |
| 62 | + |
63 | 63 | // Replace variables |
64 | | - msg = msg.replace(/\$n/g,wgCanonicalNamespace); |
| 64 | + msg = msg.replace(/\$n/g,wgCanonicalNamespace); |
65 | 65 | msg = msg.replace(/\$p/g,wgPageName); |
66 | 66 | msg = msg.replace(/\$t/g,wgTitle); |
67 | 67 | msg = msg.replace(/\$u/g,wgUserName); |
68 | 68 | msg = msg.replace(/\$s/g,wgServer); |
69 | 69 | return msg; |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Singleton of this class |
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageUserEn.js |
— | — | @@ -1,4 +1,4 @@ |
2 | 2 | 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.', |
5 | 5 | }; |
Index: trunk/extensions/SemanticNotifyMe/scripts/Language/SMW_NMLanguageEn.js |
— | — | @@ -1,3 +1,3 @@ |
2 | 2 | var wgNMContLanguageStrings = { |
3 | | - 'NOTIFYME_NS' : 'NotifyMe:' //namespace identifier with colon |
| 3 | + 'NOTIFYME_NS' : 'NotifyMe:' //namespace identifier with colon |
4 | 4 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/nm_tooltip.js |
— | — | @@ -52,38 +52,38 @@ |
53 | 53 | // configuration. Order of commands is arbitrary. |
54 | 54 | // Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)" |
55 | 55 | |
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 |
58 | 58 | 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 |
65 | 65 | config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colors |
66 | 66 | config. CloseBtnText = ' X ' // Close button text (may also be an image tag) |
67 | 67 | 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 |
68 | 68 | 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 |
72 | 72 | 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 |
74 | 74 | config. FollowMouse = true // false or true - tooltip follows the mouse |
75 | 75 | config. FontColor = '#000044' |
76 | 76 | 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 |
78 | 78 | 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 |
88 | 88 | config. TextAlign = 'left' // 'left', 'right' or 'justify' |
89 | 89 | config. Title = '' // Default title text applied to all tips (no default title: empty string '') |
90 | 90 | config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | config. TitleFontColor = '#ffffff' // Color of title text - if '', BgColor (of tooltip body) will be used |
93 | 93 | config. TitleFontFace = '' // If '' use FontFace (boldified) |
94 | 94 | 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 |
96 | 96 | //======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// |
97 | 97 | |
98 | 98 | |
— | — | @@ -256,10 +256,10 @@ |
257 | 257 | |
258 | 258 | tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags |
259 | 259 | 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 |
261 | 261 | tt_maxPosX, tt_maxPosY, |
262 | 262 | tt_iState = 0, // Tooltip active |= 1, shown |= 2, move with mouse |= 4 |
263 | | -tt_opa, // Currently applied opacity |
| 263 | +tt_opa, // Currently applied opacity |
264 | 264 | tt_bJmpVert, // Tip above mouse (or ABOVE tip below mouse) |
265 | 265 | tt_t2t, tt_t2tDad, // Tag converted to tip, and its parent element in the document |
266 | 266 | tt_elDeHref, // The tag from which Opera has removed the href attribute |
Index: trunk/extensions/SemanticNotifyMe/scripts/NotifyMe/NotifyHelper.js |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | doSaveToNotify:function(){ |
58 | 58 | /*STARTLOG*/ |
59 | 59 | if(window.smwhgLogger){ |
60 | | - smwhgLogger.log("Save Notify","NM","save_notify"); |
| 60 | + smwhgLogger.log("Save Notify","NM","save_notify"); |
61 | 61 | } |
62 | 62 | /*ENDLOG*/ |
63 | 63 | |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | var request = Array(); |
72 | 72 | request.responseText = nmLanguage.getMessage('NM_EMPTY_NOTIFYNAME'); |
73 | 73 | this.saveNotify(request); |
74 | | - } |
| 74 | + } |
75 | 75 | else if ($('nmquery').value){ //only do this if the query is not empty |
76 | 76 | var params = $('nmquery').value.replace(/&/gm, "&").replace(/,/gm, ",") + ","; |
77 | 77 | params += ($('nmqrall').checked ? 1 : 0) + ","; |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | item.type = "checkbox"; |
114 | 114 | item.value = nid; |
115 | 115 | item.name = "nmdel"; |
116 | | - |
| 116 | + |
117 | 117 | td = document.createElement("td"); |
118 | 118 | ntr.appendChild(td); |
119 | 119 | item = document.createElement("a"); |
— | — | @@ -169,14 +169,14 @@ |
170 | 170 | item.id = "nmdiv_" + nid; |
171 | 171 | } |
172 | 172 | |
173 | | - $('nmtoolbar').parentNode.insertBefore(ntr, $('nmtoolbar')); |
| 173 | + $('nmtoolbar').parentNode.insertBefore(ntr, $('nmtoolbar')); |
174 | 174 | attachAutocompleteToField("nmd_" + nid); |
175 | 175 | }, |
176 | 176 | |
177 | 177 | doUpdateMail:function() { |
178 | 178 | /*STARTLOG*/ |
179 | 179 | 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"); |
181 | 181 | } |
182 | 182 | /*ENDLOG*/ |
183 | 183 | |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | |
213 | 213 | /*STARTLOG*/ |
214 | 214 | if(window.smwhgLogger){ |
215 | | - smwhgLogger.log("Preview Query","NM","query_preview"); |
| 215 | + smwhgLogger.log("Preview Query","NM","query_preview"); |
216 | 216 | } |
217 | 217 | /*ENDLOG*/ |
218 | 218 | $('shade').toggle(); |
— | — | @@ -242,7 +242,7 @@ |
243 | 243 | updateStates:function(){ |
244 | 244 | /*STARTLOG*/ |
245 | 245 | if(window.smwhgLogger){ |
246 | | - smwhgLogger.log("Update States","NM","update_states"); |
| 246 | + smwhgLogger.log("Update States","NM","update_states"); |
247 | 247 | } |
248 | 248 | /*ENDLOG*/ |
249 | 249 | |
— | — | @@ -283,7 +283,7 @@ |
284 | 284 | updateReportAll:function(){ |
285 | 285 | /*STARTLOG*/ |
286 | 286 | if(window.smwhgLogger){ |
287 | | - smwhgLogger.log("Update Notifications report all","NM","update_reportall"); |
| 287 | + smwhgLogger.log("Update Notifications report all","NM","update_reportall"); |
288 | 288 | } |
289 | 289 | /*ENDLOG*/ |
290 | 290 | |
— | — | @@ -307,7 +307,7 @@ |
308 | 308 | updateShowAll:function(){ |
309 | 309 | /*STARTLOG*/ |
310 | 310 | if(window.smwhgLogger){ |
311 | | - smwhgLogger.log("Update Notifications show all","NM","update_showall"); |
| 311 | + smwhgLogger.log("Update Notifications show all","NM","update_showall"); |
312 | 312 | } |
313 | 313 | /*ENDLOG*/ |
314 | 314 | |
— | — | @@ -339,7 +339,7 @@ |
340 | 340 | deleteNotify:function(){ |
341 | 341 | /*STARTLOG*/ |
342 | 342 | if(window.smwhgLogger){ |
343 | | - smwhgLogger.log("Delete Notifications","NM","delete_notify"); |
| 343 | + smwhgLogger.log("Delete Notifications","NM","delete_notify"); |
344 | 344 | } |
345 | 345 | /*ENDLOG*/ |
346 | 346 | |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | updateDelegate:function(){ |
413 | 413 | /*STARTLOG*/ |
414 | 414 | if(window.smwhgLogger){ |
415 | | - smwhgLogger.log("Update delegates","NM","update_delegates"); |
| 415 | + smwhgLogger.log("Update delegates","NM","update_delegates"); |
416 | 416 | } |
417 | 417 | /*ENDLOG*/ |
418 | 418 | |
— | — | @@ -434,17 +434,17 @@ |
435 | 435 | copyToClipboard:function(id){ |
436 | 436 | /*STARTLOG*/ |
437 | 437 | 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"); |
439 | 439 | } |
440 | 440 | /*ENDLOG*/ |
441 | 441 | var text = $(id).value; |
442 | 442 | var succ = 'The RSS feed url was successfully copied to your clipboard'; |
443 | 443 | 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 |
445 | 445 | window.clipboardData.setData("Text", text); |
446 | 446 | alert(succ); |
447 | 447 | } |
448 | | - else if (window.netscape) { |
| 448 | + else if (window.netscape) { |
449 | 449 | try { |
450 | 450 | netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); |
451 | 451 | var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); |
— | — | @@ -485,7 +485,7 @@ |
486 | 486 | if(!$('addnotifydialogue')) { |
487 | 487 | var askdlg = $('showAsk'); |
488 | 488 | var nmdlg = document.createElement("div"); |
489 | | - askdlg.parentNode.insertBefore(nmdlg, askdlg); |
| 489 | + askdlg.parentNode.insertBefore(nmdlg, askdlg); |
490 | 490 | nmdlg.id = "addnotifydialogue"; |
491 | 491 | nmdlg.className = "topDialogue"; |
492 | 492 | nmdlg.style.display = "none"; |
— | — | @@ -501,7 +501,7 @@ |
502 | 502 | }, |
503 | 503 | doSaveToNotifyQI:function(){ |
504 | 504 | if(window.smwhgLogger){ |
505 | | - smwhgLogger.log("Save Notify","QI","save_notify"); |
| 505 | + smwhgLogger.log("Save Notify","QI","save_notify"); |
506 | 506 | } |
507 | 507 | if(this.pendingElement) |
508 | 508 | this.pendingElement.hide(); |
— | — | @@ -510,7 +510,7 @@ |
511 | 511 | |
512 | 512 | if($('nmqname').value=="") { |
513 | 513 | alert(nmLanguage.getMessage('NM_EMPTY_NOTIFYNAME')); |
514 | | - } |
| 514 | + } |
515 | 515 | else if (!qihelper.queries[0].isEmpty()){ //only do this if the query is not empty |
516 | 516 | var ask = qihelper.recurseQuery(0, "parser"); // Get full ask syntax |
517 | 517 | qihelper.queries[0].getDisplayStatements().each(function(s) { ask += "\n| ?" + s}); |
— | — | @@ -557,8 +557,8 @@ |
558 | 558 | |
559 | 559 | function initialize_notify(){ |
560 | 560 | 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, |
563 | 563 | // have to load the event handler afterwards |
564 | | - if($('nmemail')) $('nmemail').onclick = function() {notifyhelper.doUpdateMail();}; |
| 564 | + if($('nmemail')) $('nmemail').onclick = function() {notifyhelper.doUpdateMail();}; |
565 | 565 | } |