מדיה ויקי:Ref2template.js

מתוך ויקימסע

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) + 1 ) {
	$(document).on('dialogopen','.ui-dialog[aria-labelledby=ui-dialog-title-wikieditor-toolbar-reference-dialog]',function() {
		var
			dialog = $( this ),
			addButton,
			clone,
			refnameId = 'wikieditor-toolbar-reference-name',
			onAdd = function() {
							var $this = $( '#wikieditor-toolbar-reference-dialog' ),
								refContent = $( '#wikieditor-toolbar-reference-text' ).val(),
								refName  = $( '#' + refnameId ).val(),
								whitespace = $this.data( 'whitespace' ),
								attributes = $this.data( 'attributes' ),
								refPrefix = whitespace[0]
									+ '{{הערה|'
									+ ( $.trim( refName ) ? 'שם=' + refName + '|' : '' )
									+ (/=/.test( refContent ) ? '1=' : '');
							// Close the dialog
							$this.dialog( 'close' );
							$.wikiEditor.modules.toolbar.fn.doAction(
								$this.data( 'context' ),
								{
									type: 'replace',
									options: {
										pre: refPrefix,
										peri: refContent,
										post: '}}' + whitespace[1]
		 							}
								},
								$this
							);
							// Restore form state
							$( '#wikieditor-toolbar-reference-text' ).val( '' );
							$( '#' + refnameId ).val( '' );
						};
		if ( !window.refDialogbeenThere ) {
			$( 'label[for=wikieditor-toolbar-reference-text]' ).before( $( '<input>', { id: refnameId } ) ).before( $( '<p>' ) );
			$( '#' + refnameId ).before( $( '<label>', { 'for': refnameId, rel: refnameId, text: 'שם ההערה (אופציונלי) :' } ) );
			dialog.dialog( 'option', { height: 'auto' } );
			window.refDialogbeenThere = true;
			addButton = dialog.find( 'button:contains(הוספה)' ),
			clone = addButton.clone().click( onAdd ).insertAfter( addButton );
			addButton.toggle( false );
		}
	} );

	$(function() {
		var action = $('[rel=reference]').data('action'),
			options = (action || {}).options;
		if (options) {
			options.pre = '{{הערה|1=';
			options.post = '}}';
		}
		action = $('[rel=newline]').data('action');
		options = (action || {}).options;
		if (options) 
			options.pre = '{{ש}}\n';
		else
			$('#wpTextbox1').on('wikiEditor-toolbar-buildSection-advanced', function( e, d ){
				d.groups.format.tools.newline.action.options.pre = '{{ש}}\n'; 
			});
	})
}