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( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
+ mv_skin_img_path + 'Button_add_media.png">' );
+ $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( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
- mv_skin_img_path + 'Button_add_media.png">' );
- $j( '#btn-add-media-wiz' ).addMediaWiz(
- amwConf
- );
+ }
}
});
}
}
-
//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() )");
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(){
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);
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');
}
});
"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"
});
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',
$.addLoaderDialog = function( msg_txt ){
if( $('#mwe_tmp_loader').length != 0 )
$('#mwe_tmp_loader').remove();
-
+
+ //append the style free loader ontop:
$('body').append('<div id="mwe_tmp_loader" title="' + msg_txt + '" >' +
- gM('mwe-checking-resource') + '<br>' +
+ msg_txt + '<br>' +
mv_get_loading_img() +
'</div>');
-
+ //turn the loader into a real dialog loader:
mvJsLoader.doLoadDepMode([
[
'$j.ui'
'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