page title, etc.
* hooks registered with addOnloadHook are now called at the one of the html body
by all skins.
-
+* Split ajax aided search from core ajax framework. Use wgUseAjax to enable the
+ framework and wgAjaxSearch to enable the suggest feature for the search box.
== Languages updated ==
$wgUpdateRowsPerQuery = 10;
/**
- * Enable use of AJAX features, currently auto suggestion for the search bar
+ * Enable AJAX framework
*/
$wgUseAjax = false;
/**
- * List of Ajax-callable functions
+ * Enable auto suggestion for the search bar
+ * Requires $wgUseAjax to be true too.
+ * Causes wfSajaxSearch to be added to $wgAjaxExportList
*/
-$wgAjaxExportList = array( 'wfSajaxSearch' );
+$wgAjaxSearch = false;
+
+/**
+ * List of Ajax-callable functions.
+ * Extensions acting as Ajax callbacks must register here
+ */
+$wgAjaxExportList = array( );
/**
* Allow DISPLAYTITLE to change title display
function output() {
global $wgUser, $wgOutputEncoding;
global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
- global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgScriptPath, $wgServer;
+ global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgScriptPath, $wgServer;
if( $this->mDoNothing ){
return;
$sk = $wgUser->getSkin();
if ( $wgUseAjax ) {
- $this->addScript( "<script type=\"{$wgJsMimeType}\">
- var wgScriptPath=\"{$wgScriptPath}\";
- var wgServer=\"{$wgServer}\";
- </script>" );
$this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js\"></script>\n" );
}
+ if ( $wgUseAjax && $wgAjaxSearch ) {
+ $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js\"></script>\n" );
+ $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
+ }
+
if ( '' != $this->mRedirect ) {
if( substr( $this->mRedirect, 0, 4 ) != 'http' ) {
# Standards require redirect URLs to be absolute
$wgDeferredUpdateList = array();
$wgPostCommitUpdateList = array();
+if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
+
wfSeedRandom();
# Placeholders in case of DB error
var sajax_debug_mode = false;
var sajax_request_type = "GET";
-var started;
-var typing;
-var memory=null;
-var body=null;
-var oldbody=null;
-
function sajax_debug(text) {
if (sajax_debug_mode)
alert("RSD: " + text)
}
-
function sajax_init_object() {
sajax_debug("sajax_init_object() called..")
var A;
sajax_debug(func_name + " waiting..");
delete x;
}
-
-// Remove the typing barrier to allow call() to complete
-function Search_doneTyping()
-{
- typing=false;
-}
-
-// Wait 500ms to run call()
-function Searching_Go()
-{
- setTimeout("Searching_Call()", 500);
-}
-
-// If the user is typing wait until they are done.
-function Search_Typing() {
- started=true;
- typing=true;
- window.status = "Waiting until you're done typing...";
- setTimeout("Search_doneTyping()", 500);
-
- // I believe these are needed by IE for when the users press return?
- if (window.event)
- {
- if (event.keyCode == 13)
- {
- event.cancelBubble = true;
- event.returnValue = false;
- }
- }
-}
-
-// Set the body div to the results
-function Searching_SetResult(result)
-{
- //body.innerHTML = result;
- t = document.getElementById("searchTarget");
- if ( t == null ) {
- oldbody=body.innerHTML;
- body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ;
- t = document.getElementById("searchTarget");
- }
- t.innerHTML = result;
- t.style.display='block';
-}
-
-function Searching_Hide_Results()
-{
- t = document.getElementById("searchTarget");
- t.style.display='none';
- body.innerHTML = oldbody;
-}
-
-
-// This will call the php function that will eventually
-// return a results table
-function Searching_Call()
-{
- var x;
- Searching_Go();
-
- //Don't proceed if user is typing
- if (typing)
- return;
-
- x = document.getElementById("searchInput").value;
-
- // Don't search again if the query is the same
- if (x==memory)
- return;
-
- memory=x;
- if (started) {
- // Don't search for blank or < 3 chars.
- if ((x=="") || (x.length < 3))
- {
- return;
- }
- x_wfSajaxSearch(x, Searching_SetResult);
- }
-}
-
-function x_wfSajaxSearch() {
- sajax_do_call( "wfSajaxSearch", x_wfSajaxSearch.arguments );
-}
-
-
-//Initialize
-function sajax_onload() {
- x = document.getElementById( 'searchInput' );
- x.onkeypress= function() { Search_Typing(); };
- Searching_Go();
- body = document.getElementById("content");
-}
-
-hookEvent("load", sajax_onload);
--- /dev/null
+// remote scripting library
+// (c) copyright 2005 modernmethod, inc
+
+var started;
+var typing;
+var memory=null;
+var body=null;
+var oldbody=null;
+
+// Remove the typing barrier to allow call() to complete
+function Search_doneTyping()
+{
+ typing=false;
+}
+
+// Wait 500ms to run call()
+function Searching_Go()
+{
+ setTimeout("Searching_Call()", 500);
+}
+
+// If the user is typing wait until they are done.
+function Search_Typing() {
+ started=true;
+ typing=true;
+ window.status = "Waiting until you're done typing...";
+ setTimeout("Search_doneTyping()", 500);
+
+ // I believe these are needed by IE for when the users press return?
+ if (window.event)
+ {
+ if (event.keyCode == 13)
+ {
+ event.cancelBubble = true;
+ event.returnValue = false;
+ }
+ }
+}
+
+// Set the body div to the results
+function Searching_SetResult(result)
+{
+ //body.innerHTML = result;
+ t = document.getElementById("searchTarget");
+ if ( t == null ) {
+ oldbody=body.innerHTML;
+ body.innerHTML= '<div id="searchTargetContainer"><div id="searchTarget" ></div></div>' ;
+ t = document.getElementById("searchTarget");
+ }
+ t.innerHTML = result;
+ t.style.display='block';
+}
+
+function Searching_Hide_Results()
+{
+ t = document.getElementById("searchTarget");
+ t.style.display='none';
+ body.innerHTML = oldbody;
+}
+
+
+// This will call the php function that will eventually
+// return a results table
+function Searching_Call()
+{
+ var x;
+ Searching_Go();
+
+ //Don't proceed if user is typing
+ if (typing)
+ return;
+
+ x = document.getElementById("searchInput").value;
+
+ // Don't search again if the query is the same
+ if (x==memory)
+ return;
+
+ memory=x;
+ if (started) {
+ // Don't search for blank or < 3 chars.
+ if ((x=="") || (x.length < 3))
+ {
+ return;
+ }
+ x_wfSajaxSearch(x, Searching_SetResult);
+ }
+}
+
+function x_wfSajaxSearch() {
+ sajax_do_call( "wfSajaxSearch", x_wfSajaxSearch.arguments );
+}
+
+
+//Initialize
+function sajax_onload() {
+ x = document.getElementById( 'searchInput' );
+ x.onkeypress= function() { Search_Typing(); };
+ Searching_Go();
+ body = document.getElementById("content");
+}