use wgPageName
[lhc/web/wiklou.git] / js2 / editPage.js
index 63958ff..8e41461 100644 (file)
@@ -20,13 +20,19 @@ var defaultAddMediaConfig = {
                'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
 };
 
-
 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' ) {             
+       var didWikiEditorBind = false;
+       
+       //setup the drag drop binding (will only work for html5 upload browsers) 
+       //$j( 'textarea#wpTextbox1' ).dragFileUpload();
+       
+       //set up the add-media-wizard binding: 
+       if( typeof $j.wikiEditor != 'undefined' ) {
                        $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main',
                    function( e, section ) {
+                       didWikiEditorBind = true;
                        if ( typeof section.groups.insert.tools.file !== 'undefined' ) {
                            section.groups.insert.tools.file.action = {
                                'type': 'callback',
@@ -38,14 +44,21 @@ js2AddOnloadHook( function() {
                        }
                    }
                );
-       }else{
-               //add to the old-toolbar
-               if( $j('#btn-add-media-wiz').length == 0 ){
+       }               
+       //add to old toolbar if wikiEditor did not remove '#toolbar' from the page:    
+       setTimeout(function(){                                  
+               if( $j('#btn-add-media-wiz').length == 0 && $j( '#toolbar' ).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
                        );
+               }else{
+                       //make sure the wikieditor got binded: 
+                       if( !didWikiEditorBind )
+                               $j(".tool [rel='file']").addMediaWiz( amwConf );
                }
-       }
+       }, 120)
+       //drag drop for editbar: 
+       //$j('textarea#wpTextbox1').dragFileUpload();
 });