From: Michael Dale Date: Tue, 13 Oct 2009 21:41:30 +0000 (+0000) Subject: * added add-media-wizard entry point which is compatible with wikiEditor style button... X-Git-Tag: 1.31.0-rc.0~39295 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=f559ace93bddb35bbc88c12fe5dfe7967a694b98;p=lhc%2Fweb%2Fwiklou.git * added add-media-wizard entry point which is compatible with wikiEditor style button callbacks --- diff --git a/js2/editPage.js b/js2/editPage.js index 290589d1a5..63958ff1d2 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -24,19 +24,28 @@ var defaultAddMediaConfig = { js2AddOnloadHook( function() { var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); // kind of tricky, it would be nice to use run on ready "loader" call here - if( typeof $j.wikiEditor != 'undefined' ) { - setTimeout( function() { - $j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz( + if( typeof $j.wikiEditor != 'undefined' ) { + $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', + function( e, section ) { + if ( typeof section.groups.insert.tools.file !== 'undefined' ) { + section.groups.insert.tools.file.action = { + 'type': 'callback', + 'execute': function() { + js_log('click add media wiz'); + $j.addMediaWiz( amwConf ); + } + }; + } + } + ); + }else{ + //add to the old-toolbar + if( $j('#btn-add-media-wiz').length == 0 ){ + $j( '#toolbar' ).append( '' ); + $j( '#btn-add-media-wiz' ).addMediaWiz( amwConf ); - }, 100 ); - } - //add to the old-toolbar all the time: - if( $j('#btn-add-media-wiz').length == 0 ){ - $j( '#toolbar' ).append( '' ); - $j( '#btn-add-media-wiz' ).addMediaWiz( - amwConf - ); + } } }); diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index a89b61dbca..74cb9569bd 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -387,7 +387,6 @@ remoteSearchDriver.prototype = { } } - //set up the target invocation: if( $j( this.target_invocation ).length==0 ){ js_log("RemoteSearchDriver:: no target invocation provided (will have to run your own doInitDisplay() )"); @@ -409,16 +408,23 @@ remoteSearchDriver.prototype = { this.add_interface_bindings(); //update the target binding to just un-hide the dialog: - $j(this.target_invocation).unbind().click(function(){ - js_log("re-open"); - //update the base text: - if( _this.target_textbox ) - _this.getTexboxSelection(); - //$j(_this.target_container).dialog("open"); - $j(_this.target_container).parents('.ui-dialog').fadeIn('slow'); - //re-center the dialog: - $j(_this.target_container).dialog('option', 'position','center'); - }); + if( this.target_invocation ){ + $j(this.target_invocation).unbind().click(function(){ + js_log("doInitDisplay:target_invocation: click doReDisp"); + _this.doReDisplay(); + }); + } + }, + doReDisplay: function(){ + var _this = this; + js_log("doReDisplay::"); + //update the base text: + if( _this.target_textbox ) + _this.getTexboxSelection(); + //$j(_this.target_container).dialog("open"); + $j(_this.target_container).parents('.ui-dialog').fadeIn('slow'); + //re-center the dialog: + $j(_this.target_container).dialog('option', 'position','center'); }, //gets the in and out points for insert position or grabs the selected text for search getTexboxSelection:function(){ @@ -475,7 +481,7 @@ remoteSearchDriver.prototype = { js_log( 'width: ' + $j(window).width() + ' height: ' + $j(window).height()); var cConf = {}; cConf['cancel'] = function(){ - _this.cancelClipEditCB() + _this.cancelClipEditCB(); } function doResize(){ js_log('do resize:: ' + _this.target_container); @@ -492,9 +498,10 @@ remoteSearchDriver.prototype = { resizable:false, buttons:cConf, close: function() { - //if we are 'editing' a item close that - _this.cancelClipEditCB(); - js_log('closed modal'); + //if we are 'editing' a item close that + //@@todo maybe prompt the user? + _this.cancelClipEditCB(); + //$j(this).dialog('close'); $j(this).parents('.ui-dialog').fadeOut('slow'); } }); diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 41242e42eb..bc73c1781f 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -617,7 +617,8 @@ $mw.lang.loadGM({ "mwe-size-megabytes" : "$1 MB", "mwe-size-kilobytes" : "$1 K", "mwe-size-bytes" : "$1 B", - "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2" + "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2", + "mwe-loading-add-media-wiz": "Loading add media wizard" }); @@ -1180,18 +1181,43 @@ function mv_remove_modal( speed ) { function mv_jqueryBindings() { js_log( 'mv_jqueryBindings' ); (function( $ ) { - $.fn.addMediaWiz = function( iObj, callback ) { - // First set the cursor for the button to "loading" - $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_title' ) ); - - iObj['target_invocation'] = this.selector; + //non selector based add-media-wizard direct invocation with loader + $.addMediaWiz = function( iObj, callback ){ + js_log(".addMediaWiz call"); + //check if already loaded: + if( _global['rsdMVRS'] ){ + _global['rsdMVRS'].doReDisplay(); + if( callback ) + callback( _global['rsdMVRS'] ); + return ; + } + //display a loader: + $.addLoaderDialog( gM('mwe-loading-add-media-wiz') ); + //load the addMedia wizard without a target: + $.fn.addMediaWiz ( iObj, function( amwObj ){ + //close the dialog + $.closeLoaderDialog(); + //do the add-media-wizard display + amwObj.doInitDisplay(); + //call the parent callback: + if( callback ) + callback( _global['rsdMVRS'] ); + }); + } + $.fn.addMediaWiz = function( iObj, callback ) { + if( this.selector ){ + // First set the cursor for the button to "loading" + $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_title' ) ); + //set the target: + iObj['target_invocation'] = this.selector; + } // Load the mv_embed_base skin: loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); loadExternalCss( mv_embed_path + 'skins/' + mwConfig['skin_name']+'/styles.css' ); // Load all the required libs: mvJsLoader.jQueryCheck( function() { - // Load with staged dependencies (for IE and Safari that don't execute in order) + // Load with staged dependencies (for IE that does not execute in order) mvJsLoader.doLoadDepMode([ [ 'remoteSearchDriver', '$j.cookie', @@ -1398,12 +1424,13 @@ function mv_jqueryBindings() { $.addLoaderDialog = function( msg_txt ){ if( $('#mwe_tmp_loader').length != 0 ) $('#mwe_tmp_loader').remove(); - + + //append the style free loader ontop: $('body').append('
' + - gM('mwe-checking-resource') + '
' + + msg_txt + '
' + mv_get_loading_img() + '
'); - + //turn the loader into a real dialog loader: mvJsLoader.doLoadDepMode([ [ '$j.ui' diff --git a/js2/mwEmbed/php/languages/mwEmbed.i18n.php b/js2/mwEmbed/php/languages/mwEmbed.i18n.php index c2f95ac3dc..a5f46c5efb 100644 --- a/js2/mwEmbed/php/languages/mwEmbed.i18n.php +++ b/js2/mwEmbed/php/languages/mwEmbed.i18n.php @@ -103,6 +103,7 @@ $messages['en'] = array( 'mwe-size-kilobytes' => '$1 K', 'mwe-size-bytes' => '$1 B', 'mwe-error_load_lib' => 'Error: JavaScript $1 was not retrievable or does not define $2', + 'mwe-loading-add-media-wiz' => "Loading add media wizard", /* * js file: /libAddMedia/mvFirefogg.js