MediaWiki Javascript phase 2
-Documentaiton to follow:
\ No newline at end of file
+Documentation to follow:.
\ No newline at end of file
*/
// Setup configuration vars
-if( !mwAddMediaConfig )
+if( !mwAddMediaConfig ) {
var mwAddMediaConfig = {
- 'profile': 'mediawiki_edit',
- 'target_textbox': '#wpTextbox1',
- // Note: selections in the textbox will take over the default query
- 'default_query': wgTitle,
- 'target_title': wgPageName,
- // Here we can setup the content provider overrides
- 'enabled_cps':['wiki_commons'],
- // The local wiki API URL:
- 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
- };
-
+ 'profile': 'mediawiki_edit',
+ 'target_textbox': '#wpTextbox1',
+ // Note: selections in the textbox will take over the default query
+ 'default_query': wgTitle,
+ 'target_title': wgPageName,
+ // Here we can setup the content provider overrides
+ 'enabled_cps':['wiki_commons'],
+ // The local wiki API URL:
+ 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
+ };
+}
js2AddOnloadHook( function() {
mwEditPageHelper.init();
if( typeof $j.wikiEditor != 'undefined' ) {
setTimeout( function() {
$j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz(
- mwAddMediaConfig
+ mwAddMediaConfig
);
- }, 100 );
+ },
+ 100 );
} else {
// Add the add-media-wizard button for old toolbar:
$j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
- mv_skin_img_path + 'Button_add_media.png">' );
+ mv_skin_img_path + 'Button_add_media.png">' );
$j( '#btn-add-media-wiz' ).addMediaWiz(
mwAddMediaConfig
);
// Add to new toolbar (need to use api)
/*$j( '[rel=insert] tool-file' ).addMediaWiz(
- mwAddMediaConfig
+ mwAddMediaConfig
);*/
}
}
* that are not yet running the new-upload branch
*/
-
var urlparts = getRemoteEmbedPath();
var mwEmbedHostPath = urlparts[0];
var reqAguments = urlparts[1];
if( wgAction == 'edit' || wgAction == 'submit' ) {
load_mv_embed( function() {
importScriptURI( mwEmbedHostPath + '/editPage.js' + reqAguments );
- });
+ } );
}
// Firefogg integration
if( wgPageName == "Special:Upload" ){
load_mv_embed( function() {
importScriptURI( mwEmbedHostPath + '/uploadPage.js' + reqAguments );
- });
+ } );
}
// OggHandler rewrite
var vidIdList = [];
var divs = document.getElementsByTagName( 'div' );
for( var i = 0; i < divs.length; i++ ) {
- if( divs[i].id && divs[i].id.substring( 0, 11 ) == 'ogg_player_' ) {
- vidIdList.push( divs[i].getAttribute( "id" ) );
- }
+ if( divs[i].id && divs[i].id.substring( 0, 11 ) == 'ogg_player_' ) {
+ vidIdList.push( divs[i].getAttribute( "id" ) );
+ }
}
if( vidIdList.length > 0 ) {
- load_mv_embed( function() {
- mvJsLoader.embedVideoCheck( function() {
- // Do utilty rewrite of OggHandler content:
- rewrite_for_OggHandler( vidIdList );
- });
- });
+ load_mv_embed( function() {
+ mvJsLoader.embedVideoCheck( function() {
+ // Do utilty rewrite of OggHandler content:
+ rewrite_for_OggHandler( vidIdList );
+ } );
+ } );
}
}
+
function getRemoteEmbedPath() {
- for( var i = 0; i < document.getElementsByTagName( 'script' ).length; i++ ) {
- var s = document.getElementsByTagName( 'script' )[i];
- if( s.src.indexOf( 'remoteMwEmbed.js' ) != -1 ) {
- var reqStr = '';
- var scriptPath = '';
- if( s.src.indexOf( '?' ) != -1) {
- reqStr = s.src.substr( s.src.indexOf( '?' ) );
- scriptPath = s.src.substr( 0, s.src.indexOf( '?' ) ).replace( 'remoteMwEmbed.js', '' );
- } else {
- scriptPath = s.src.replace( 'remoteMwEmbed.js', '' )
- }
- // Use the external_media_wizard path:
- return [scriptPath, reqStr];
- }
- }
+ for( var i = 0; i < document.getElementsByTagName( 'script' ).length; i++ ) {
+ var s = document.getElementsByTagName( 'script' )[i];
+ if( s.src.indexOf( 'remoteMwEmbed.js' ) != -1 ) {
+ var reqStr = '';
+ var scriptPath = '';
+ if( s.src.indexOf( '?' ) != -1) {
+ reqStr = s.src.substr( s.src.indexOf( '?' ) );
+ scriptPath = s.src.substr( 0, s.src.indexOf( '?' ) ).replace( 'remoteMwEmbed.js', '' );
+ } else {
+ scriptPath = s.src.replace( 'remoteMwEmbed.js', '' )
+ }
+ // Use the external_media_wizard path:
+ return [scriptPath, reqStr];
+ }
+ }
}
function load_mv_embed( callback ) {
- // Inject mv_embed if needed
- if( typeof mvEmbed == 'undefined' ) {
+ // Inject mv_embed if needed
+ if( typeof mvEmbed == 'undefined' ) {
importScriptURI( mwEmbedHostPath + '/mwEmbed/mv_embed.js' + reqAguments );
- check_for_mv_embed( callback );
- } else {
- check_for_mv_embed( callback );
- }
+ check_for_mv_embed( callback );
+ } else {
+ check_for_mv_embed( callback );
+ }
}
+
function check_for_mv_embed( callback ) {
- if( typeof MV_EMBED_VERSION == 'undefined' ) {
- setTimeout( 'check_for_mv_embed( ' + callback + ');', 25 );
- } else {
- callback();
- }
+ if( typeof MV_EMBED_VERSION == 'undefined' ) {
+ setTimeout( 'check_for_mv_embed( ' + callback + ');', 25 );
+ } else {
+ callback();
+ }
}
-
*/
js2AddOnloadHook( function() {
mwUploadHelper.init();
-});
+} );
var mwUploadFormTarget = '#mw-upload-form';
// Set up the upload form bindings once all DOM manipulation is done
var mwUploadHelper = {
var _this = this;
// If wgEnableFirefogg is not boolean false, set to true
if( typeof wgEnableFirefogg == 'undefined' )
- wgEnableFirefogg = true;
+ wgEnableFirefogg = true;
if( wgEnableFirefogg ) {
// Set up the upload handler to Firefogg. Should work with the HTTP uploads too.
'form_rewrite': true,
'target_edit_from': mwUploadFormTarget,
'new_source_cb': function( orgFilename, oggName ) {
- if( $j( '#wpDestFile' ).val() == "" )
- $j( '#wpDestFile' ).val( oggName );
+ if( $j( '#wpDestFile' ).val() == "" )
+ $j( '#wpDestFile' ).val( oggName );
$j( '#wpDestFile' ).doDestCheck({
'warn_target': '#wpDestFile-warning'
- });
+ } );
}
- });
+ } );
} else {
// Add basic upload profile support ( http status monitoring, progress box for
// browsers that support it, etc.)
$j( '#wpUploadFileURL' ).baseUploadInterface( {
'api_url': wgServer + wgScriptPath + '/api.php',
'target_edit_from': mwUploadFormTarget
- });
+ } );
}
}
$j( '#wpDestFile' ).change( function() {
$j( '#wpDestFile' ).doDestCheck({
'warn_target':'#wpDestFile-warning'
- });
- });
+ } );
+ } );
}
// Check if we have HTTP enabled & setup enable/disable toggle:
$j( "input[name='wpSourceType']" ).click( function() {
_this.toggleUpType( this.id == 'wpSourceTypeFile' );
- });
+ } );
}
$j( '#wpUploadFile,#wpUploadFileURL' )
- .focus( function() {
- _this.toggleUpType( this.id == 'wpUploadFile' );
- })
- // Also setup the onChange event binding:
- .change( function() {
- if ( wgUploadAutoFill ) {
- mwUploadHelper.doDestinationFill( this );
- }
- });
+ .focus( function() {
+ _this.toggleUpType( this.id == 'wpUploadFile' );
+ })
+ // Also setup the onChange event binding:
+ .change( function() {
+ if ( wgUploadAutoFill ) {
+ mwUploadHelper.doDestinationFill( this );
+ }
+ } );
},
/**
- * Set the upload radio buttons
- *
- * boolean set
- */
+ * Set the upload radio buttons
+ *
+ * boolean set
+ */
toggleUpType: function( set ) {
$j( '#wpSourceTypeFile' ).attr( 'checked', set );
$j( '#wpUploadFile' ).attr( 'disabled', !set );
if( wgEnableFirefogg ) {
$j( '#wpUploadFile' ).firefogg({
'firefogg_form_action': $j( '#wpSourceTypeFile' ).attr( 'checked' )
- });
+ } );
}
},
/**
- * Fill in a destination file-name based on a source asset name.
- */
+ * Fill in a destination file-name based on a source asset name.
+ */
doDestinationFill: function( targetElm ) {
js_log( "doDestinationFill" )
// Remove any previously flagged errors
var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
for( var i = 0; i < wgFileExtensions.length; i++ ) {
if( wgFileExtensions[i].toLowerCase() == ext.toLowerCase() )
- found = true;
+ found = true;
}
}
if( !found ) {
// Do a destination check
$j( '#wpDestFile' ).doDestCheck({
'warn_target': '#wpDestFile-warning'
- });
+ } );
}
}
-