Localisation updates for core and extension messages from translatewiki.net (2009...
[lhc/web/wiklou.git] / js2 / editPage.js
1 /*
2 * JS2-style replacement for MediaWiki edit.js
3 * (right now it just supports the toolbar)
4 */
5
6 // Setup configuration vars (if not set already)
7 if( !mwAddMediaConfig )
8 var mwAddMediaConfig = {};
9
10 //The default editPage AMW config
11 var defaultAddMediaConfig = {
12 'profile': 'mediawiki_edit',
13 'target_textbox': '#wpTextbox1',
14 // Note: selections in the textbox will take over the default query
15 'default_query': wgTitle,
16 'target_title': wgPageName,
17 // Here we can setup the content provider overrides
18 'enabled_cps':['wiki_commons'],
19 // The local wiki API URL:
20 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php'
21 };
22
23 js2AddOnloadHook( function() {
24 js_log("edit page js2AddOnloadHook::");
25 var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig );
26 // kind of tricky, it would be nice to use run on ready "loader" call here
27 var didWikiEditorBind = false;
28
29 //Set-up the drag drop binding (will only work for html5 upload browsers)
30 //$j('textarea#wpTextbox1').dragFileUpload();
31
32 //set up the add-media-wizard binding:
33 if( typeof $j.wikiEditor != 'undefined' ) {
34 //the below seems to be broken :(
35 $j( 'textarea#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main',
36 function( e, section ) {
37 didWikiEditorBind = true;
38 if ( typeof section.groups.insert.tools.file !== 'undefined' ) {
39 section.groups.insert.tools.file.action = {
40 'type': 'callback',
41 'execute': function() {
42 js_log('click add media wiz');
43 $j.addMediaWiz( amwConf );
44 }
45 };
46 }
47 }
48 );
49 }
50 //Add to old toolbar if wikiEditor did not remove '#toolbar' from the page:
51 setTimeout(function(){
52 if( $j('#btn-add-media-wiz').length == 0 && $j( '#toolbar' ).length != 0 ){
53 js_log( 'Do old toolbar bind:' );
54 didWikiEditorBind = true;
55 $j( '#toolbar' ).append( '<img style="cursor:pointer" id="btn-add-media-wiz" src="' +
56 mv_skin_img_path + 'Button_add_media.png">' );
57 $j( '#btn-add-media-wiz' ).addMediaWiz(
58 amwConf
59 );
60 }else{
61 //Make sure the wikieditor got binded:
62 if( !didWikiEditorBind ){
63 js_log( 'Failed to bind via build section bind via target:' );
64 $j(".tool[rel='file']").unbind().addMediaWiz( amwConf );
65 }
66 }
67 }, 120)
68
69 });