[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 /* Publish module for wikiEditor */ 2 /*jshint onevar:false */ 3 ( function ( $ ) { 4 5 $.wikiEditor.modules.publish = { 6 7 /** 8 * Compatability map 9 */ 10 browsers: { 11 // Left-to-right languages 12 ltr: { 13 msie: [['>=', 7]], 14 firefox: [['>=', 3]], 15 opera: [['>=', 9.6]], 16 safari: [['>=', 4]] 17 }, 18 // Right-to-left languages 19 rtl: { 20 msie: [['>=', 8]], 21 firefox: [['>=', 3]], 22 opera: [['>=', 9.6]], 23 safari: [['>=', 4]] 24 } 25 }, 26 /** 27 * Internally used functions 28 */ 29 fn: { 30 /** 31 * Creates a publish module within a wikiEditor 32 * @param context Context object of editor to create module in 33 * @param config Configuration object to create module from 34 */ 35 create: function ( context ) { 36 // Build the dialog behind the Publish button 37 var dialogID = 'wikiEditor-' + context.instance + '-dialog'; 38 $.wikiEditor.modules.dialogs.fn.create( 39 context, 40 { 41 previewsave: { 42 id: dialogID, 43 titleMsg: 'wikieditor-publish-dialog-title', 44 html: '\ 45 <div class="wikiEditor-publish-dialog-copywarn"></div>\ 46 <div class="wikiEditor-publish-dialog-editoptions">\ 47 <form id="wikieditor-' + context.instance + '-publish-dialog-form">\ 48 <div class="wikiEditor-publish-dialog-summary">\ 49 <label for="wikiEditor-' + context.instance + '-dialog-summary"\ 50 rel="wikieditor-publish-dialog-summary"></label>\ 51 <br />\ 52 <input type="text" id="wikiEditor-' + context.instance + '-dialog-summary"\ 53 style="width: 100%;" />\ 54 </div>\ 55 <div class="wikiEditor-publish-dialog-options">\ 56 <input type="checkbox"\ 57 id="wikiEditor-' + context.instance + '-dialog-minor" />\ 58 <label for="wikiEditor-' + context.instance + '-dialog-minor"\ 59 rel="wikieditor-publish-dialog-minor"></label>\ 60 <input type="checkbox"\ 61 id="wikiEditor-' + context.instance + '-dialog-watch" />\ 62 <label for="wikiEditor-' + context.instance + '-dialog-watch"\ 63 rel="wikieditor-publish-dialog-watch"></label>\ 64 </div>\ 65 </form>\ 66 </div>', 67 init: function () { 68 var i; 69 70 $( this ).find( '[rel]' ).each( function () { 71 $( this ).text( mediaWiki.msg( $( this ).attr( 'rel' ) ) ); 72 } ); 73 74 /* REALLY DIRTY HACK! */ 75 // Reformat the copyright warning stuff 76 var copyWarnHTML = $( '#editpage-copywarn p' ).html(); 77 // TODO: internationalize by splitting on other characters that end statements 78 var copyWarnStatements = copyWarnHTML.split( '. ' ); 79 var newCopyWarnHTML = '<ul>'; 80 for ( i = 0; i < copyWarnStatements.length; i++ ) { 81 if ( copyWarnStatements[i] !== '' ) { 82 var copyWarnStatement = $.trim( copyWarnStatements[i] ).replace( /\.*$/, '' ); 83 newCopyWarnHTML += '<li>' + copyWarnStatement + '.</li>'; 84 } 85 } 86 newCopyWarnHTML += '</ul>'; 87 // No list if there's only one element 88 $( this ).find( '.wikiEditor-publish-dialog-copywarn' ).html( 89 copyWarnStatements.length > 1 ? newCopyWarnHTML : copyWarnHTML 90 ); 91 /* END OF REALLY DIRTY HACK */ 92 93 if ( $( '#wpMinoredit' ).length === 0 ) { 94 $( '#wikiEditor-' + context.instance + '-dialog-minor' ).hide(); 95 } else if ( $( '#wpMinoredit' ).prop( 'checked' ) ) { 96 $( '#wikiEditor-' + context.instance + '-dialog-minor' ) 97 .prop( 'checked', true ); 98 } 99 if ( $( '#wpWatchthis' ).length === 0 ) { 100 $( '#wikiEditor-' + context.instance + '-dialog-watch' ).hide(); 101 } else if ( $( '#wpWatchthis' ).prop( 'checked' ) ) { 102 $( '#wikiEditor-' + context.instance + '-dialog-watch' ) 103 .prop( 'checked', true ); 104 } 105 106 $( this ).find( 'form' ).submit( function ( e ) { 107 $( this ).closest( '.ui-dialog' ).find( 'button:first' ).click(); 108 e.preventDefault(); 109 } ); 110 }, 111 immediateCreate: true, 112 dialog: { 113 buttons: { 114 'wikieditor-publish-dialog-publish': function () { 115 var minorChecked = $( '#wikiEditor-' + context.instance + 116 '-dialog-minor' ).is( ':checked' ) ? 117 'checked' : ''; 118 var watchChecked = $( '#wikiEditor-' + context.instance + 119 '-dialog-watch' ).is( ':checked' ) ? 120 'checked' : ''; 121 $( '#wpMinoredit' ).prop( 'checked', minorChecked ); 122 $( '#wpWatchthis' ).prop( 'checked', watchChecked ); 123 $( '#wpSummary' ).val( $( '#wikiEditor-' + context.instance + 124 '-dialog-summary' ).val() ); 125 $( '#editform' ).submit(); 126 }, 127 'wikieditor-publish-dialog-goback': function () { 128 $( this ).dialog( 'close' ); 129 } 130 }, 131 open: function () { 132 $( '#wikiEditor-' + context.instance + '-dialog-summary' ).focus(); 133 }, 134 width: 500 135 }, 136 resizeme: false 137 } 138 } 139 ); 140 141 context.fn.addButton( { 142 'captionMsg': 'wikieditor-publish-button-publish', 143 'action': function () { 144 $( '#' + dialogID ).dialog( 'open' ); 145 return false; 146 } 147 } ); 148 149 context.fn.addButton( { 150 'captionMsg': 'wikieditor-publish-button-cancel', 151 'action': function () { 152 window.location.href = $( '#mw-editform-cancel' ).attr( 'href' ); 153 return false; 154 } 155 } ); 156 } 157 } 158 159 }; 160 161 }( jQuery ) );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |