User:Ravid ziv/test.js

/** * Adds direction mark tool to VE (for adding RLM) */ (function {	ve.ui.VeUiMWCiteDialog = function VeUiMWCiteDialog( surface, config ) {	// Configuration initialization	config = ve.extendObject( { 'size': 'medium' }, config ); //MWReferenceDialog	// Parent constructor	ve.ui.MWReferenceDialog.call( this, surface, config );	this.followTransactions  = false;

};

/* Inheritance */

OO.inheritClass( ve.ui.VeUiMWCiteDialog, ve.ui.MWReferenceDialog );

/* Static Properties */

ve.ui.VeUiMWCiteDialog.static.name = 'Cite';

ve.ui.VeUiMWCiteDialog.static.title = OO.ui.deferMsg( 'visualeditor-dialog-reference-title' ); ve.ui.VeUiMWCiteDialog.prototype.useReference = function ( ref ) { window.xyz= this; var self=this; var dialog = $(' '), webButton = $(' web ').button.click(function{			self.citeWeb;		}); dialog.append(webButton); dialog.dialog; this.$element.hide; this.followTransactions = false; ve.ui.MWReferenceDialog.prototype.useReference.call(this, ref); }

ve.ui.VeUiMwCiteDialog.prototype.citeWeb = function{ this.referenceSurface.getSurface.getModel.getFragment.collapseRangeToEnd.insertContent([{'type': 'mwTransclusionInline','attributes': {'mw': 	{		parts: [		{ template: {			target: {				href: 'Template:cite web',				wt: 'cite web'			},			params: {				'first': {wt: 'first name'},				'last': {wt: 'last name'},				'title': {wt: 'title'},				'url': {wt: ''},			}		}	}]	}}}]); this.followTransactions = true; this.referenceSurface.getSurface.execute('dialog', 'open', 'transclusion', null); var self = this; window.xyz = this.referenceSurface.getSurface.getDialogs; this.referenceSurface.getSurface.getDialogs.getWindow('transclusion').on(		'close',function (data){			if (data.action=='cancel')			{				self.close({ 'action': 'cancel' });			}		}); }

ve.ui.VeUiMWCiteDialog.prototype.onDocumentTransact = function { console.log("FIRST - "+this.followTransactions); if (!this.followTransactions) return; var data = this.referenceSurface.getSurface.getModel.getDocument.getFullData; for (var j=0;j0) {				this.close( { 'action': 'insert' } ); return; }		}	}	console.log("END!!")

};

/* Registration */

ve.ui.dialogFactory.register( ve.ui.VeUiMWCiteDialog );

function DirectionTool( toolGroup, config ) { OO.ui.Tool.call( this, toolGroup, config );

} OO.inheritClass( DirectionTool, OO.ui.Tool ); DirectionTool.static.name = 'DirectionTool'; DirectionTool.static.title = 'רפרנס' DirectionTool.prototype.onSelect = function { this.toolbar.getSurface.execute('dialog', 'open', 'Cite', null); /*	this.toolbar.getSurface.getModel.getFragment.collapseRangeToEnd.insertContent([		{			'type':			'mwReference',			'attributes':			{				'listGroup': "mwReference/",				'listIndex': '75',				'listKey': "auto/0",				'refGroup': "",			}		},		{			'type': '/mwReference'	}]).collapseRangeToEnd.select; */ }; DirectionTool.prototype.onUpdateState = function { this.setActive( false ); }; ve.ui.toolFactory.register( DirectionTool ); });