مدیاویکی:Gadget-VeSuperTool.js: تفاوت میان نسخهها
ظاهر
imported>Ebrahim ro:Utilizator:Strainu/ve.js و توسعه |
imported>Dalba خنثیسازی ویژه:تفاوت/29674063/29682191 https://fa.wikipedia.org/w/index.php?title=%D8%A8%D8%AD%D8%AB_%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Gadget-Extra-Editbuttons.js&oldid=29684517#banned_from_using_AbarAbzar |
||
| (۱۷ نسخهٔ میانی ویرایش شده توسط ۵ کاربر نشان داده نشد) | |||
| خط ۱: | خط ۱: | ||
function processText(text) { | |||
text = persianTools.toStandardPersianCharacters(text); | |||
mw.hook('ve. | text = persianTools.applyZwnj(text); | ||
text = persianTools.applyOrthography(text); | |||
text = persianTools.toPersianDigits(text); | |||
text = persianTools.punctuation(text); | |||
text = persianWikiTools.dictation(text); | |||
return text; | |||
} | |||
mw.hook('ve.activate').add(function () { | |||
$('#ca-abar-abzar').remove(); | |||
$(mw.util.addPortletLink('p-cactions', '#', 'ابرابزار ویرایشگر دیداری', 'ca-abar-abzar-ve')).click(function (e) { | |||
var surfaceModel = ve.init.target.getSurface().getModel(); | |||
var documentModel = surfaceModel.getDocument(); | |||
var fragments = []; | |||
var ranges = documentModel.findText(new RegExp('.*'), true, true); | |||
var i, l; | |||
for (i = 0, l = ranges.length; i < l; i++) { | |||
fragments.push(surfaceModel.getLinearFragment(ranges[i], true, true)); | |||
} | |||
for (i = 0, l = fragments.length; i < l; i++) { | |||
var fragment = fragments[i]; | |||
fragment.insertContent(processText(fragment.getText()), true); | |||
} | |||
e.preventDefault(); | |||
mw.hook( 've.saveDialog.stateChanged' ).add(function(){ | |||
//.ve-init-mw-viewPageTarget-saveDialog-checkboxes | |||
var target = ve.init.target; | |||
var $insertBeforeThis = target.saveDialog.$body.find('.ve-ui-mwSaveDialog-options'); | |||
$summaryBox = target.saveDialog.$body.find('.ve-ui-mwSaveDialog-summary textarea'); | |||
$summaryBox.val("ابرابزار ویرایشیگر دیداری، " + $summaryBox.val()); | |||
}); | |||
}); | |||
$('#ca-abar-abzar-ve').css('font-weight', 'bold'); | |||
}); | }); | ||
function | /* | ||
mw.libs.ve.addPlugin(function(){ | |||
(function () { | |||
function SuperTool( toolGroup, config ) { | |||
OO.ui.Tool.call( this, toolGroup, config ); | |||
} | } | ||
OO.inheritClass( SuperTools, OO.ui.Tool ); | |||
SuperTool.static.name = 'SuperTool'; | |||
SuperTool.static.title = mw.msg('SuperTool-toolname'); | |||
SuperTool.prototype.onSelect = function () { | |||
aa(); | |||
/* | |||
this.toolbar.getSurface().getModel().getFragment().collapseRangeToEnd().insertContent([{ | |||
'type': 'mwTransclusionInline', | |||
'attributes': { | |||
'mw': { | |||
parts: [ { | |||
template: { | |||
target: { | |||
href: mw.config.get('wgFormattedNamespaces')[10]+ ':'+ mw.config.get(''), | |||
wt: mw.config.get('rlmTemplateName') | |||
}, | |||
params: {} | |||
} | |||
}] | |||
} | |||
} | |||
}]); | |||
}; | |||
SuperTool.prototype.onUpdateState = function () { | |||
this.setActive( false ); | |||
}; | |||
ve.ui.toolFactory.register( SuperTool ); | |||
})(); | |||
}); | |||
*/ | |||
نسخهٔ کنونی تا ۶ اوت ۲۰۲۰، ساعت ۰۷:۱۷
function processText(text) {
text = persianTools.toStandardPersianCharacters(text);
text = persianTools.applyZwnj(text);
text = persianTools.applyOrthography(text);
text = persianTools.toPersianDigits(text);
text = persianTools.punctuation(text);
text = persianWikiTools.dictation(text);
return text;
}
mw.hook('ve.activate').add(function () {
$('#ca-abar-abzar').remove();
$(mw.util.addPortletLink('p-cactions', '#', 'ابرابزار ویرایشگر دیداری', 'ca-abar-abzar-ve')).click(function (e) {
var surfaceModel = ve.init.target.getSurface().getModel();
var documentModel = surfaceModel.getDocument();
var fragments = [];
var ranges = documentModel.findText(new RegExp('.*'), true, true);
var i, l;
for (i = 0, l = ranges.length; i < l; i++) {
fragments.push(surfaceModel.getLinearFragment(ranges[i], true, true));
}
for (i = 0, l = fragments.length; i < l; i++) {
var fragment = fragments[i];
fragment.insertContent(processText(fragment.getText()), true);
}
e.preventDefault();
mw.hook( 've.saveDialog.stateChanged' ).add(function(){
//.ve-init-mw-viewPageTarget-saveDialog-checkboxes
var target = ve.init.target;
var $insertBeforeThis = target.saveDialog.$body.find('.ve-ui-mwSaveDialog-options');
$summaryBox = target.saveDialog.$body.find('.ve-ui-mwSaveDialog-summary textarea');
$summaryBox.val("ابرابزار ویرایشیگر دیداری، " + $summaryBox.val());
});
});
$('#ca-abar-abzar-ve').css('font-weight', 'bold');
});
/*
mw.libs.ve.addPlugin(function(){
(function () {
function SuperTool( toolGroup, config ) {
OO.ui.Tool.call( this, toolGroup, config );
}
OO.inheritClass( SuperTools, OO.ui.Tool );
SuperTool.static.name = 'SuperTool';
SuperTool.static.title = mw.msg('SuperTool-toolname');
SuperTool.prototype.onSelect = function () {
aa();
/*
this.toolbar.getSurface().getModel().getFragment().collapseRangeToEnd().insertContent([{
'type': 'mwTransclusionInline',
'attributes': {
'mw': {
parts: [ {
template: {
target: {
href: mw.config.get('wgFormattedNamespaces')[10]+ ':'+ mw.config.get(''),
wt: mw.config.get('rlmTemplateName')
},
params: {}
}
}]
}
}
}]);
};
SuperTool.prototype.onUpdateState = function () {
this.setActive( false );
};
ve.ui.toolFactory.register( SuperTool );
})();
});
*/