"सदस्य:Lupo/vector.js": अवतरणों में अंतर

Content deleted Content added
छोNo edit summary
छोNo edit summary
पंक्ति 210:
 
(function () { // Local scope to avoid polluting the global namespace with declarations
 
function log(text) { // Debugging only.
var user = (window.mediaWiki && mediaWiki.config) ? mediaWiki.config.get('wgUserName') : window.wgUserName;
if (user != 'Lupo') return;
var logPane = document.getElementById('hotcat-log');
if (!logPane) {
logPane = document.createElement('div');
logPane.id = 'hotcat-log';
logPane.style.background = '#F8CCB0';
logPane.style.position = 'absolute';
logPane.style.top = logPane.style.right = '0px';
logPane.style.height = '500px';
logPane.style.width = '200px';
logPane.style.maxHeight = '500px';
logPane.style.overflowY = 'auto';
logPane.style.zIndex = 100;
var content = document.getElementById('mw-content-text');
content.insertBefore(logPane, content.firstChild);
}
if (!text) {
logPane.style.display = 'none';
} else {
if (logPane.firstChild) logPane.appendChild(document.createElement('br'));
logPane.appendChild(document.createTextNode(text));
logPane.style.display = 'block';
logPane.scrollTop = logPane.scrollHeight;
}
}
 
// Backwards compatibility stuff. We want HotCat to work with either wg* globals, or with mw.config.get().
Line 1,478 ⟶ 1,450:
evt = evt || window.event || window.Event; // W3C, IE, Netscape
var key = evt.keyCode || 0;
log('Keyup ' + key + ' ' + self.lastKey + ' ' + (self.ime ? 'I' : 'i') + ' ' + (self.usesComposition ? 'C' : 'c'));
if (self.ime && self.lastKey === IME && !self.usesComposition && (key === TAB || key === RET || key == ESC || key === SPACE)) self.ime = false;
log('-- ' + (self.ime ? 'I' : 'i'));
if (self.ime) return true;
if (key === UP || key === DOWN || key === PGUP || key === PGDOWN) {
Line 1,503 ⟶ 1,473:
evt = evt || window.event || window.Event; // W3C, IE, Netscape
var key = evt.keyCode || 0;
log('Keydown ' + key + ' ' + (self.ime ? 'I' : 'i') + ' ' + (self.usesComposition ? 'C' : 'c'));
self.lastKey = key;
self.keyCount = 0;
Line 1,534 ⟶ 1,503:
// DOM Level 3 IME handling
try {
// Webkit does send the textInput after compositionend, but then sends a spurious keydown IME. We ignore
addEvent(text, 'compositionstart', function (evt) { log('cStart'); self.lastKey = IME; self.usesComposition = true; self.ime = true; });
// that in onkeydown above. Gecko, OTOH, doesn't send textInput but a keyUp with the key that terminated
addEvent(text, 'compositionend', function (evt) { log('cEnd'); self.lastKey = IME; self.usesComposition = true; self.ime = false; });
// the composition, so that will trigger suggestions. Except if that key was ESC (cancel composition),
addEvent(text, 'textInput', function (evt) { log('textInput ' + (typeof evt.data != 'undefined' ? evt.data : 'UNDEF')); self.ime = false; self.invokeSuggestions(false); });
// which we'd get with a non-IME keydown from before compositionstart. Therefore, pretend the last
// keydown had been IME if we see either composition event, which allows us to handle this ESC properly.
addEvent(text, 'compositionstart', function (evt) { log('cStart'); self.lastKey = IME; self.usesComposition = true; self.ime = true; });
addEvent(text, 'compositionend', function (evt) { log('cEnd'); self.lastKey = IME; self.usesComposition = true; self.ime = false; });
addEvent(text, 'textInput', function (evt) { log('textInput ' + (typeof evt.data != 'undefined' ? evt.data : 'UNDEF')); self.ime = false; self.invokeSuggestions(false); });
} catch (any) {
// Just in case some browsers might produce exceptions with these DOM Level 3 events
}
addEvent(text, 'blur', function (evt) { log('blur'); self.usesComposition = false; self.ime = false; });
}
this.text = text;
Line 2,370 ⟶ 2,344:
autoComplete : function (newVal, actVal, normalizedActVal, key, dontModify) {
if (newVal == actVal) return true;
log('autoComplete ' + dontModify + ' ' + this.ime + ' ' + (!this.canSelect()));
if (dontModify || this.ime || !this.canSelect()) return false;
// If we can't select properly or an IME composition is ongoing, autocompletion would be a major annoyance to the user.