MediaWiki:Gadget-Ae-to-Aelig.js: различия между версиями

Содержимое удалено Содержимое добавлено
Bouron (ныхас | бавæрд)
Нет описания правки
Bouron (ныхас | бавæрд)
Нет описания правки
Рæнхъ 6:
wgAe.init = function() {
wgAe.APressed = false;
wgAejQuery.setCaretfn.setCursorPosition = function(posposition) {
if(this.lengh == 0) return this;
if (document.selection) {
return $(this).setSelection(position, position);
} else if ($('#wpTextbox1')[0].selectionStart) {
});
$('#wpTextbox1')[0].selectionStart = pos;
jQuery.fn.getCursorPosition = function(){
$('#wpTextbox1')[0].selectionEnd = pos;
} else if ($('#wpTextbox1')[0]this.selectionStartlengh == '0') {return -1;
return $(this).getSelectionStart();
};
jQuery.fn.getSelectionStart = function(){
if(this.lengh == 0) return -1;
input = this[0];
 
var pos = input.value.length;
 
if (input.createTextRange) {
var r = document.selection.createRange().duplicate();
r.moveEnd('character', input.value.length);
if (r.text == '')
pos = input.value.length;
pos = input.value.lastIndexOf(r.text);
} else if(typeof(input.selectionStart)!="undefined")
pos = input.selectionStart;
 
return pos;
};
jQuery.fn.setSelection = function(selectionStart, selectionEnd) {
if(this.lengh == 0) return this;
input = this[0];
 
if (input.createTextRange) {
}
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
} else if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
 
return this;
};
wgAe.timeFlag = 0;
$('#wpTextbox1'"input:text, textarea").keydown(
function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
Строка 25 ⟶ 57 :
} else if (wgAe.APressed && $.now() - wgAe.timeFlag < 500) {
if (code == 84) {
var $target=$(e.target);
var caps = false;
var caretPosition = $target.getSelectionStart('#wpTextbox1').data(;
var val = $('#wpTextbox1')target.val();
'wikiEditor-context').$textarea.textSelection(
var enteredKey = val.slice(caretPosition[0] - 1,
'getCaretPosition', {
startAndEnd : truecaretPosition);
});
var val = $('#wpTextbox1').val();
var enteredKey = val.slice(caretPosition[0] - 1,
caretPosition[0]);
enteredKey.toUpperCase() === enteredKey ? caps = true
: caps = false;
var pre = val.slice(0, caretPosition[0] - 1);
var ins = caps ? 'Ӕ' : 'ӕ';
val = pre + ins
+ val.slice(caretPosition[0], val.length);
$('#wpTextbox1')target.val(val);
wgAe$target.setCaretsetSelection(caretPosition[0],caretPosition);
wgAe.APressed = false;
e.stopPropagation();
Строка 50 ⟶ 79 :
});
};
$(document).ready(wgAe.init);
if ($.inArray(mw.config.get('wgAction'), [ 'edit', 'submit' ]) !== -1) {
mw.loader.using('user.options', function() {
if (mw.user.options.get('usebetatoolbar')) {
mw.loader.using('ext.wikiEditor.toolbar', function() {
$(document).ready(wgAe.init);
});
}
});
}