Last modified: 2009-11-02 10:05:52 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 21363 - Can't add dialogs with a user script
Can't add dialogs with a user script
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
UsabilityInitiative (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Trevor Parscal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-31 02:04 UTC by Alex Z.
Modified: 2009-11-02 10:05 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch (619 bytes, patch)
2009-10-31 02:04 UTC, Alex Z.
Details

Description Alex Z. 2009-10-31 02:04:35 UTC
Created attachment 6744 [details]
patch

To add a new dialog to the toolbar, one needs to do something like this:

...
var mydialog = {
  modules: {
    mydialog: {
      titleMsg: 'mydialog-title',
      id: 'mydialog-id',
      init: mydialoginit,
      html: mydialoghtml,
      dialog: {
        width:400,
        buttons: {
         ...
        }
      }
    }
  }
}
$j('#wpTextbox1').wikiEditor('addDialog', mydialog);
...

However, this doesn't seem to work (nor do other slight variations) and gives a JS error (in Firefox) like:

Error: configuration is undefined
Source File: http://wiki.com/w/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js?7
Line: 53

The attached patch should fix this.
Comment 1 Roan Kattouw 2009-10-31 11:09:45 UTC
Have you tested that this patch doesn't break the toolbar itself? Also, the change suggests that the following JS would work:

var mydialog = {
//  modules: { // remove this line
    mydialog: {
      titleMsg: 'mydialog-title',
      id: 'mydialog-id',
      init: mydialoginit,
      html: mydialoghtml,
      dialog: {
        width:400,
        buttons: {
         ...
        }
      }
    }
//  }  // remove this line
}
$j('#wpTextbox1').wikiEditor('addDialog', mydialog);
Comment 2 Alex Z. 2009-10-31 19:34:33 UTC
That change gives the same error as before.

The problem is that the current addDialog function is creating something like this:

finalobject = {
  'modules': {
    userSuppliedObject
  }
}

So when the create function iterates over that, it adds the 'modules' object to the dialogs list.

Technically this works:
var mydialog = {
//  modules: { // remove this line
//    mydialog: {
      titleMsg: 'mydialog-title',
      id: 'mydialog-id',
      init: mydialoginit,
      html: mydialoghtml,
      dialog: {
        width:400,
        buttons: {
         ...
        }
      }
//    }
//  }  // remove this line
$j('#wpTextbox1').wikiEditor('addDialog', mydialog);

But it only allows you to create one dialog called 'modules.'

The change doesn't seem to have any effect on the rest of the toolbar, though my test wasn't exhaustive.
Comment 3 Roan Kattouw 2009-11-02 10:05:52 UTC
Fixed in r58423. Note that this revision also changed the calling convention for open/closeDialog from openDialog( { 'dialog': 'myDialogID' } ); to openDialog( 'myDialogID' );

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links