| Index: trunk/phase3/skins/common/ajaxsearch.js |
| — | — | @@ -0,0 +1,101 @@ |
| | 2 | +// remote scripting library |
| | 3 | +// (c) copyright 2005 modernmethod, inc |
| | 4 | + |
| | 5 | +var started; |
| | 6 | +var typing; |
| | 7 | +var memory=null; |
| | 8 | +var body=null; |
| | 9 | +var oldbody=null; |
| | 10 | + |
| | 11 | +// Remove the typing barrier to allow call() to complete |
| | 12 | +function Search_doneTyping() |
| | 13 | +{ |
| | 14 | + typing=false; |
| | 15 | +} |
| | 16 | + |
| | 17 | +// Wait 500ms to run call() |
| | 18 | +function Searching_Go() |
| | 19 | +{ |
| | 20 | + setTimeout("Searching_Call()", 500); |
| | 21 | +} |
| | 22 | + |
| | 23 | +// If the user is typing wait until they are done. |
| | 24 | +function Search_Typing() { |
| | 25 | + started=true; |
| | 26 | + typing=true; |
| | 27 | + window.status = "Waiting until you're done typing..."; |
| | 28 | + setTimeout("Search_doneTyping()", 500); |
| | 29 | + |
| | 30 | + // I believe these are needed by IE for when the users press return? |
| | 31 | + if (window.event) |
| | 32 | + { |
| | 33 | + if (event.keyCode == 13) |
| | 34 | + { |
| | 35 | + event.cancelBubble = true; |
| | 36 | + event.returnValue = false; |
| | 37 | + } |
| | 38 | + } |
| | 39 | +} |
| | 40 | + |
| | 41 | +// Set the body div to the results |
| | 42 | +function Searching_SetResult(result) |
| | 43 | +{ |
| | 44 | + //body.innerHTML = result; |
| | 45 | + t = document.getElementById("searchTarget"); |
| | 46 | + if ( t == null ) { |
| | 47 | + oldbody=body.innerHTML; |
| | 48 | + body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ; |
| | 49 | + t = document.getElementById("searchTarget"); |
| | 50 | + } |
| | 51 | + t.innerHTML = result; |
| | 52 | + t.style.display='block'; |
| | 53 | +} |
| | 54 | + |
| | 55 | +function Searching_Hide_Results() |
| | 56 | +{ |
| | 57 | + t = document.getElementById("searchTarget"); |
| | 58 | + t.style.display='none'; |
| | 59 | + body.innerHTML = oldbody; |
| | 60 | +} |
| | 61 | + |
| | 62 | + |
| | 63 | +// This will call the php function that will eventually |
| | 64 | +// return a results table |
| | 65 | +function Searching_Call() |
| | 66 | +{ |
| | 67 | + var x; |
| | 68 | + Searching_Go(); |
| | 69 | + |
| | 70 | + //Don't proceed if user is typing |
| | 71 | + if (typing) |
| | 72 | + return; |
| | 73 | + |
| | 74 | + x = document.getElementById("searchInput").value; |
| | 75 | + |
| | 76 | + // Don't search again if the query is the same |
| | 77 | + if (x==memory) |
| | 78 | + return; |
| | 79 | + |
| | 80 | + memory=x; |
| | 81 | + if (started) { |
| | 82 | + // Don't search for blank or < 3 chars. |
| | 83 | + if ((x=="") || (x.length < 3)) |
| | 84 | + { |
| | 85 | + return; |
| | 86 | + } |
| | 87 | + x_wfSajaxSearch(x, Searching_SetResult); |
| | 88 | + } |
| | 89 | +} |
| | 90 | + |
| | 91 | +function x_wfSajaxSearch() { |
| | 92 | + sajax_do_call( "wfSajaxSearch", x_wfSajaxSearch.arguments ); |
| | 93 | +} |
| | 94 | + |
| | 95 | + |
| | 96 | +//Initialize |
| | 97 | +function sajax_onload() { |
| | 98 | + x = document.getElementById( 'searchInput' ); |
| | 99 | + x.onkeypress= function() { Search_Typing(); }; |
| | 100 | + Searching_Go(); |
| | 101 | + body = document.getElementById("content"); |
| | 102 | +} |
| Property changes on: trunk/phase3/skins/common/ajaxsearch.js |
| ___________________________________________________________________ |
| Name: svn:eol-style |
| 1 | 103 | + native |
| Name: svn:keywords |
| 2 | 104 | + Author Date Id Revision |
| Index: trunk/phase3/skins/common/ajax.js |
| — | — | @@ -3,18 +3,11 @@ |
| 4 | 4 | var sajax_debug_mode = false; |
| 5 | 5 | var sajax_request_type = "GET"; |
| 6 | 6 | |
| 7 | | -var started; |
| 8 | | -var typing; |
| 9 | | -var memory=null; |
| 10 | | -var body=null; |
| 11 | | -var oldbody=null; |
| 12 | | - |
| 13 | 7 | function sajax_debug(text) { |
| 14 | 8 | if (sajax_debug_mode) |
| 15 | 9 | alert("RSD: " + text) |
| 16 | 10 | } |
| 17 | 11 | |
| 18 | | - |
| 19 | 12 | function sajax_init_object() { |
| 20 | 13 | sajax_debug("sajax_init_object() called..") |
| 21 | 14 | var A; |
| — | — | @@ -80,98 +73,3 @@ |
| 81 | 74 | sajax_debug(func_name + " waiting.."); |
| 82 | 75 | delete x; |
| 83 | 76 | } |
| 84 | | - |
| 85 | | -// Remove the typing barrier to allow call() to complete |
| 86 | | -function Search_doneTyping() |
| 87 | | -{ |
| 88 | | - typing=false; |
| 89 | | -} |
| 90 | | - |
| 91 | | -// Wait 500ms to run call() |
| 92 | | -function Searching_Go() |
| 93 | | -{ |
| 94 | | - setTimeout("Searching_Call()", 500); |
| 95 | | -} |
| 96 | | - |
| 97 | | -// If the user is typing wait until they are done. |
| 98 | | -function Search_Typing() { |
| 99 | | - started=true; |
| 100 | | - typing=true; |
| 101 | | - window.status = "Waiting until you're done typing..."; |
| 102 | | - setTimeout("Search_doneTyping()", 500); |
| 103 | | - |
| 104 | | - // I believe these are needed by IE for when the users press return? |
| 105 | | - if (window.event) |
| 106 | | - { |
| 107 | | - if (event.keyCode == 13) |
| 108 | | - { |
| 109 | | - event.cancelBubble = true; |
| 110 | | - event.returnValue = false; |
| 111 | | - } |
| 112 | | - } |
| 113 | | -} |
| 114 | | - |
| 115 | | -// Set the body div to the results |
| 116 | | -function Searching_SetResult(result) |
| 117 | | -{ |
| 118 | | - //body.innerHTML = result; |
| 119 | | - t = document.getElementById("searchTarget"); |
| 120 | | - if ( t == null ) { |
| 121 | | - oldbody=body.innerHTML; |
| 122 | | - body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ; |
| 123 | | - t = document.getElementById("searchTarget"); |
| 124 | | - } |
| 125 | | - t.innerHTML = result; |
| 126 | | - t.style.display='block'; |
| 127 | | -} |
| 128 | | - |
| 129 | | -function Searching_Hide_Results() |
| 130 | | -{ |
| 131 | | - t = document.getElementById("searchTarget"); |
| 132 | | - t.style.display='none'; |
| 133 | | - body.innerHTML = oldbody; |
| 134 | | -} |
| 135 | | - |
| 136 | | - |
| 137 | | -// This will call the php function that will eventually |
| 138 | | -// return a results table |
| 139 | | -function Searching_Call() |
| 140 | | -{ |
| 141 | | - var x; |
| 142 | | - Searching_Go(); |
| 143 | | - |
| 144 | | - //Don't proceed if user is typing |
| 145 | | - if (typing) |
| 146 | | - return; |
| 147 | | - |
| 148 | | - x = document.getElementById("searchInput").value; |
| 149 | | - |
| 150 | | - // Don't search again if the query is the same |
| 151 | | - if (x==memory) |
| 152 | | - return; |
| 153 | | - |
| 154 | | - memory=x; |
| 155 | | - if (started) { |
| 156 | | - // Don't search for blank or < 3 chars. |
| 157 | | - if ((x=="") || (x.length < 3)) |
| 158 | | - { |
| 159 | | - return; |
| 160 | | - } |
| 161 | | - x_wfSajaxSearch(x, Searching_SetResult); |
| 162 | | - } |
| 163 | | -} |
| 164 | | - |
| 165 | | -function x_wfSajaxSearch() { |
| 166 | | - sajax_do_call( "wfSajaxSearch", x_wfSajaxSearch.arguments ); |
| 167 | | -} |
| 168 | | - |
| 169 | | - |
| 170 | | -//Initialize |
| 171 | | -function sajax_onload() { |
| 172 | | - x = document.getElementById( 'searchInput' ); |
| 173 | | - x.onkeypress= function() { Search_Typing(); }; |
| 174 | | - Searching_Go(); |
| 175 | | - body = document.getElementById("content"); |
| 176 | | -} |
| 177 | | - |
| 178 | | -hookEvent("load", sajax_onload); |
| Index: trunk/phase3/includes/Setup.php |
| — | — | @@ -168,6 +168,8 @@ |
| 169 | 169 | $wgDeferredUpdateList = array(); |
| 170 | 170 | $wgPostCommitUpdateList = array(); |
| 171 | 171 | |
| | 172 | +if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch'; |
| | 173 | + |
| 172 | 174 | wfSeedRandom(); |
| 173 | 175 | |
| 174 | 176 | # Placeholders in case of DB error |
| Index: trunk/phase3/includes/OutputPage.php |
| — | — | @@ -484,7 +484,7 @@ |
| 485 | 485 | function output() { |
| 486 | 486 | global $wgUser, $wgOutputEncoding; |
| 487 | 487 | global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType; |
| 488 | | - global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgScriptPath, $wgServer; |
| | 488 | + global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgScriptPath, $wgServer; |
| 489 | 489 | |
| 490 | 490 | if( $this->mDoNothing ){ |
| 491 | 491 | return; |
| — | — | @@ -494,13 +494,14 @@ |
| 495 | 495 | $sk = $wgUser->getSkin(); |
| 496 | 496 | |
| 497 | 497 | if ( $wgUseAjax ) { |
| 498 | | - $this->addScript( "<script type=\"{$wgJsMimeType}\"> |
| 499 | | - var wgScriptPath=\"{$wgScriptPath}\"; |
| 500 | | - var wgServer=\"{$wgServer}\"; |
| 501 | | - </script>" ); |
| 502 | 498 | $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js\"></script>\n" ); |
| 503 | 499 | } |
| 504 | 500 | |
| | 501 | + if ( $wgUseAjax && $wgAjaxSearch ) { |
| | 502 | + $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js\"></script>\n" ); |
| | 503 | + $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" ); |
| | 504 | + } |
| | 505 | + |
| 505 | 506 | if ( '' != $this->mRedirect ) { |
| 506 | 507 | if( substr( $this->mRedirect, 0, 4 ) != 'http' ) { |
| 507 | 508 | # Standards require redirect URLs to be absolute |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -2136,16 +2136,24 @@ |
| 2137 | 2137 | $wgUpdateRowsPerQuery = 10; |
| 2138 | 2138 | |
| 2139 | 2139 | /** |
| 2140 | | - * Enable use of AJAX features, currently auto suggestion for the search bar |
| | 2140 | + * Enable AJAX framework |
| 2141 | 2141 | */ |
| 2142 | 2142 | $wgUseAjax = false; |
| 2143 | 2143 | |
| 2144 | 2144 | /** |
| 2145 | | - * List of Ajax-callable functions |
| | 2145 | + * Enable auto suggestion for the search bar |
| | 2146 | + * Requires $wgUseAjax to be true too. |
| | 2147 | + * Causes wfSajaxSearch to be added to $wgAjaxExportList |
| 2146 | 2148 | */ |
| 2147 | | -$wgAjaxExportList = array( 'wfSajaxSearch' ); |
| | 2149 | +$wgAjaxSearch = false; |
| 2148 | 2150 | |
| 2149 | 2151 | /** |
| | 2152 | + * List of Ajax-callable functions. |
| | 2153 | + * Extensions acting as Ajax callbacks must register here |
| | 2154 | + */ |
| | 2155 | +$wgAjaxExportList = array( ); |
| | 2156 | + |
| | 2157 | +/** |
| 2150 | 2158 | * Allow DISPLAYTITLE to change title display |
| 2151 | 2159 | */ |
| 2152 | 2160 | $wgAllowDisplayTitle = false ; |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -105,8 +105,9 @@ |
| 106 | 106 | page title, etc. |
| 107 | 107 | * hooks registered with addOnloadHook are now called at the one of the html body |
| 108 | 108 | by all skins. |
| | 109 | +* Split ajax aided search from core ajax framework. Use wgUseAjax to enable the |
| | 110 | + framework and wgAjaxSearch to enable the suggest feature for the search box. |
| 109 | 111 | |
| 110 | | - |
| 111 | 112 | == Languages updated == |
| 112 | 113 | |
| 113 | 114 | * Albanian (sq) |