Autocomplete further stabilized. Made Special:PasswordReset and Special:Register prevent use if logged in.
--- a/includes/clientside/static/autofill.js Thu Aug 21 08:24:37 2008 -0400
+++ b/includes/clientside/static/autofill.js Thu Aug 21 11:24:56 2008 -0400
@@ -4,7 +4,7 @@
* can be created describing how to draw each row.
*/
-var autofill_schemas = {};
+var autofill_schemas = window.autofill_schemas || {};
/**
* SCHEMA - GENERIC
@@ -19,18 +19,43 @@
}
}
+/**
+ * SCHEMA - USERNAME
+ */
+
autofill_schemas.username = {
init: function(element, fillclass, params)
{
+ params = params || {};
+ var allow_anon = params.allow_anon ? '1' : '0';
+ $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass + '&allow_anon=' + allow_anon) + '&userinput=', {
+ minChars: 3,
+ formatItem: function(row, _, __)
+ {
+ var html = row.name_highlight + ' – ';
+ html += '<span style="' + row.rank_style + '">' + row.rank_title + '</span>';
+ return html;
+ },
+ tableHeader: '<tr><th>' + $lang.get('user_autofill_heading_suggestions') + '</th></tr>',
+ showWhenNoResults: true,
+ noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + $lang.get('user_autofill_msg_no_suggestions') + '</td></tr>',
+ });
+ }
+}
+
+autofill_schemas.page = {
+ init: function(element, fillclass, params)
+ {
$(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=' + fillclass) + '&userinput=', {
minChars: 3,
formatItem: function(row, _, __)
{
- var html = row.name_highlight + '<br />';
- html += '<span style="' + row.rank_style + '">' + row.rank_title + '</span>';
+ var html = '<u>' + row.name_highlight + '</u>';
+ html += ' – ' + row.pid_highlight;
return html;
},
- tableHeader: '<tr><th>' + $lang.get('user_autofill_heading_suggestions') + '</th></tr>',
+ showWhenNoResults: true,
+ noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + $lang.get('user_autofill_msg_no_suggestions') + '</td></tr>',
});
}
}
@@ -48,7 +73,7 @@
{
// we have at least one input that needs to be made an autofill element.
// is spry data loaded?
- load_component('template-compiler');
+ load_component('l10n');
}
this.loaded = true;
@@ -59,8 +84,11 @@
}
}
-function autofill_init_element(element, params)
+window.autofill_init_element = function(element, params)
{
+ if ( element.af_initted )
+ return false;
+
params = params || {};
// assign an ID if it doesn't have one yet
if ( !element.id )
@@ -84,14 +112,14 @@
element.af_initted = true;
}
-function AutofillUsername(el, allow_anon)
+window.AutofillUsername = function(el, allow_anon)
{
el.onkeyup = null;
el.className = 'autofill username';
autofill_init_element(el, { allow_anon: allow_anon });
}
-function AutofillPage(el)
+window.AutofillPage = function(el)
{
el.onkeyup = null;
el.className = 'autofill page';
@@ -100,6 +128,7 @@
addOnloadHook(function()
{
+ load_component('l10n');
load_component('jquery');
load_component('jquery-ui');
@@ -130,10 +159,6 @@
if( options.width > 0 ) {
$results.css("width", options.width);
}
- else
- {
- $results.css("width", "200px");
- }
// Add to body element
$("body").append(results);
@@ -145,7 +170,9 @@
var active = -1;
var cache = {};
var keyb = false;
- var hasFocus = false;
+ // hasFocus was false by default, see if making it true helps
+ var hasFocus = true;
+ var hasNoResults = false;
var lastKeyPressCode = null;
var mouseDownOnSelect = false;
var hidingResults = false;
@@ -186,11 +213,14 @@
}
// add the data items to the cache
- for( var k in stMatchSets ) {
- // increase the cache size
- options.cacheLength++;
- // add to the cache
- addToCache(k, stMatchSets[k]);
+ if ( options.cacheLength )
+ {
+ for( var k in stMatchSets ) {
+ // increase the cache size
+ options.cacheLength++;
+ // add to the cache
+ addToCache(k, stMatchSets[k]);
+ }
}
}
@@ -254,7 +284,7 @@
function moveSelect(step) {
var lis = $("td", results);
- if (!lis) return;
+ if (!lis || hasNoResults) return;
active += step;
@@ -355,7 +385,11 @@
});
if ( !$results.is(":visible") )
{
- $results.show("blind", {}, 350);
+ $results.show("blind", {}, 200);
+ }
+ else
+ {
+ $results.show();
}
};
@@ -395,7 +429,15 @@
results.innerHTML = "";
// if the field no longer has focus or if there are no matches, do not display the drop down
- if( !hasFocus || data.length == 0 ) return hideResultsNow();
+ if( !hasFocus )
+ {
+ return hideResultsNow();
+ }
+ if ( data.length == 0 && !options.showWhenNoResults )
+ {
+ return hideResultsNow();
+ }
+ hasNoResults = false;
if ($.browser.msie) {
// we put a styled iframe behind the calendar so HTML SELECT elements don't show through
@@ -425,20 +467,44 @@
{
ul.innerHTML = options.tableHeader;
}
-
+
+ if ( num == 0 )
+ {
+ // not showing any results
+ if ( options.noResultsHTML )
+ ul.innerHTML += options.noResultsHTML;
+
+ hasNoResults = true;
+ return ul;
+ }
+
// limited results to a max number
if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
-
+
for (var i=0; i < num; i++) {
var row = data[i];
if (!row) continue;
+ console.debug('row good ', row);
+
+ if ( typeof(row[0]) != 'string' )
+ {
+ // last ditch resort if it's a 1.1.4 autocomplete plugin that doesn't provide an automatic result.
+ // hopefully this doesn't slow it down a lot.
+ for ( var i in row )
+ {
+ if ( i == "0" || i == 0 )
+ break;
+ row[0] = row[i];
+ break;
+ }
+ }
+
var li = document.createElement("tr");
var td = document.createElement("td");
td.selectValue = row[0];
$(td).addClass('row1');
$(td).css("font-size", "smaller");
- console.debug(ul, li, td);
if ( options.formatItem )
{
@@ -449,14 +515,6 @@
td.innerHTML = row[0];
}
li.appendChild(td);
- var extra = null;
- if (row.length > 1) {
- extra = [];
- for (var j=1; j < row.length; j++) {
- extra[extra.length] = row[j];
- }
- }
- td.extra = extra;
ul.appendChild(li);
$(td).hover(
@@ -467,37 +525,8 @@
e.stopPropagation();
selectItem(this)
});
-
- /*
- var li = document.createElement("li");
- if (options.formatItem) {
- li.innerHTML = options.formatItem(row, i, num);
- li.selectValue = row[0];
- } else {
- li.innerHTML = row[0];
- li.selectValue = row[0];
- }
- var extra = null;
- if (row.length > 1) {
- extra = [];
- for (var j=1; j < row.length; j++) {
- extra[extra.length] = row[j];
- }
- }
- li.extra = extra;
- ul.appendChild(li);
-
- $(li).hover(
- function() { $("li", ul).removeClass("ac_over"); $(this).addClass("ac_over"); active = $("li", ul).indexOf($(this).get(0)); },
- function() { $(this).removeClass("ac_over"); }
- ).click(function(e) {
- e.preventDefault();
- e.stopPropagation();
- selectItem(this)
- });
- */
-
}
+
$(ul).mousedown(function() {
mouseDownOnSelect = true;
}).mouseup(function() {
@@ -664,7 +693,7 @@
matchCase: 0,
matchSubset: 1,
matchContains: 0,
- cacheLength: 1,
+ cacheLength: false,
mustMatch: 0,
extraParams: {},
loadingClass: "ac_loading",
@@ -672,6 +701,7 @@
selectOnly: false,
maxItemsToShow: -1,
autoFill: false,
+ showWhenNoResults: false,
width: 0
}, options);
options.width = parseInt(options.width, 10);
--- a/includes/clientside/static/editor.js Thu Aug 21 08:24:37 2008 -0400
+++ b/includes/clientside/static/editor.js Thu Aug 21 11:24:56 2008 -0400
@@ -4,6 +4,7 @@
var AUTOSAVE_TIMEOUT = 15;
var AutosaveTimeoutObj = null;
var editor_img_path = cdnPath + '/images/editor';
+var editor_save_lock = false;
window.ajaxEditor = function(revid)
{
@@ -521,6 +522,11 @@
{
if ( !is_draft )
ajaxSetEditorLoading();
+ if ( is_draft && editor_save_lock )
+ return false;
+ else
+ editor_save_lock = true;
+
var ta_content = ( text_override ) ? text_override : $dynano('ajaxEditArea').getContent();
if ( !is_draft && ( ta_content == '' || ta_content == '<p></p>' || ta_content == '<p> </p>' ) )
@@ -659,6 +665,7 @@
// The save was successful; reset flags and make another request for the new page content
setAjaxLoading();
editor_open = false;
+ editor_save_lock = false;
enableUnload();
changeOpac(0, 'ajaxEditContainer');
ajaxGet(stdAjaxPrefix + '&_mode=getpage&noheaders', function()
--- a/includes/clientside/static/enano-lib-basic.js Thu Aug 21 08:24:37 2008 -0400
+++ b/includes/clientside/static/enano-lib-basic.js Thu Aug 21 11:24:56 2008 -0400
@@ -377,17 +377,6 @@
return;
}
}
- else if ( typeof(inputs[i].onkeyup) == 'function' )
- {
- var f = new String(inputs[i].onkeyup);
- if ( f.match(/AutofillUsername/) )
- {
- delete(f.onkeyup);
- f.className = 'autofill username';
- autofill_check();
- return;
- }
- }
}
}
@@ -495,6 +484,7 @@
ajaxSetPassword: 'ajax.js',
ajaxChangeStyle: 'ajax.js',
ajaxCatToTag: 'ajax.js',
+ ajaxCatEdit: 'ajax.js',
ajaxOpenACLManager: 'acl.js',
ajaxOpenDirectACLRule: 'acl.js',
ajaxAdminPage: 'login.js',
@@ -519,9 +509,27 @@
ajaxToggleSystemThemes: 'theme-manager.js',
ajaxInstallTheme: 'theme-manager.js',
ajaxInitRankEdit: 'rank-manager.js',
- ajaxInitRankCreate: 'rank-manager.js'
+ ajaxInitRankCreate: 'rank-manager.js',
+ autofill_init_element: 'autofill.js',
+ autofill_onload: 'autofill.js'
};
+function AutofillUsername(el, p)
+{
+ p = p || {};
+ el.className = 'autofill username';
+ el.onkeyup = null;
+ autofill_init_element(el, p);
+}
+
+function AutofillPage(el, p)
+{
+ p = p || {};
+ el.className = 'autofill page';
+ el.onkeyup = null;
+ autofill_init_element(el, p);
+}
+
var placeholder_instances = {};
for ( var i in placeholder_list )
--- a/includes/template.php Thu Aug 21 08:24:37 2008 -0400
+++ b/includes/template.php Thu Aug 21 11:24:56 2008 -0400
@@ -1947,7 +1947,7 @@
function username_field($name, $value = false)
{
$randomid = md5( time() . microtime() . mt_rand() );
- $text = '<input name="'.$name.'" onkeyup="new AutofillUsername(this);" type="text" size="30" id="userfield_'.$randomid.'" autocomplete="off"';
+ $text = '<input name="'.$name.'" class="autofill username" type="text" size="30" id="userfield_'.$randomid.'" autocomplete="off"';
if($value) $text .= ' value="'.$value.'"';
$text .= ' />';
return $text;
@@ -1962,7 +1962,7 @@
function pagename_field($name, $value = false)
{
$randomid = md5( time() . microtime() . mt_rand() );
- $text = '<input name="'.$name.'" onkeyup="new AutofillPage(this);" type="text" size="30" id="pagefield_'.$randomid.'" autocomplete="off"';
+ $text = '<input name="'.$name.'" class="autofill page" type="text" size="30" id="pagefield_'.$randomid.'" autocomplete="off"';
if($value) $text .= ' value="'.$value.'"';
$text .= ' />';
return $text;
--- a/plugins/SpecialPageFuncs.php Thu Aug 21 08:24:37 2008 -0400
+++ b/plugins/SpecialPageFuncs.php Thu Aug 21 11:24:56 2008 -0400
@@ -863,7 +863,8 @@
if ( isset($_GET['userinput']) && strlen($_GET['userinput']) >= 3 )
{
$search = '%' . escape_string_like($_GET['userinput']) . '%';
- $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE " . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$search' AND user_id > 1");
+ $min_id = ( isset($_GET['allow_anon']) && $_GET['allow_anon'] == '1' ) ? '1' : '2';
+ $q = $db->sql_query('SELECT username FROM ' . table_prefix . "users WHERE " . ENANO_SQLFUNC_LOWERCASE . "(username) LIKE '$search' AND user_id >= $min_id");
if ( !$q )
$db->die_json();
@@ -898,6 +899,7 @@
while ( $row = $db->fetchrow() )
{
$pathskey = ( isset($paths->nslist[$row['namespace']]) ? $paths->nslist[$row['namespace']] : $row['namespace'] . substr($paths->nslist['Special'], -1) ) . $row['urlname'];
+
$key = array(
0 => $pathskey,
'pid_highlight' => highlight_term($_GET['userinput'], dirtify_page_id($pathskey), '<b>', '</b>'),
--- a/plugins/SpecialUserFuncs.php Thu Aug 21 08:24:37 2008 -0400
+++ b/plugins/SpecialUserFuncs.php Thu Aug 21 11:24:56 2008 -0400
@@ -699,6 +699,11 @@
global $db, $session, $paths, $template, $plugins; // Common objects
global $lang;
+ if ( $session->user_logged_in )
+ {
+ $paths->main_page();
+ }
+
// form field trackers
$username = '';
$email = '';
@@ -1772,6 +1777,11 @@
$template->footer();
return true;
}
+ if ( $session->user_logged_in )
+ {
+ $paths->main_page();
+ }
+
if(isset($_POST['do_reset']))
{
if($session->mail_password_reset($_POST['username']))
--- a/themes/oxygen/css/bleu.css Thu Aug 21 08:24:37 2008 -0400
+++ b/themes/oxygen/css/bleu.css Thu Aug 21 11:24:56 2008 -0400
@@ -524,6 +524,12 @@
padding: 3px;
}
+input.ac_loading {
+ background-image: url(../../../images/loading.gif);
+ background-position: right center;
+ background-repeat: no-repeat;
+}
+
label {
padding: 3px;
cursor: pointer;