# MediaWiki:Gadget-VeSuperTool.js

From faraghaib
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.

    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 );

    })();

    });
    */

Retrieved from "https://en.faraghaib.ir/w/index.php?title=MediaWiki:Gadget-VeSuperTool.js&oldid=229"