Allowing for config data when instantiating dialogs

Currently, WindowSet open method uses the Window factory to call up
the instantiation of a new dialog or inspector class. This commit will
also allow sending further config options to these classes if needed.

Specifically, this will also allow the use of ve.ui.Context.js for
block inspectors that are not dependent on current selection or current
location of the cursor.

It will also let us generalize the dialog/inspector window instantiations
by adding in any needed config settings on call.

Change-Id: If14384d74ab91ef01b1c7641ff84f327f2a12112
This commit is contained in:
Moriel Schottlender 2013-09-11 08:30:56 -07:00
parent 22d9067095
commit 63056eaa6d
2 changed files with 6 additions and 4 deletions

View file

@ -386,11 +386,12 @@ ve.ui.Context.prototype.hide = function () {
*
* @method
* @param {string} name Symbolic name of inspector
* @param {Object} [config] Config options to be sent to the inspector class constructor
* @chainable
*/
ve.ui.Context.prototype.openInspector = function ( name ) {
ve.ui.Context.prototype.openInspector = function ( name, config ) {
if ( !this.inspectors.currentWindow ) {
this.inspectors.open( name );
this.inspectors.open( name, config );
}
return this;
};

View file

@ -113,9 +113,10 @@ ve.ui.WindowSet.prototype.getCurrent = function () {
*
* @method
* @param {string} name Symbolic name of window
* @param {Object} [config] Config options to be sent to the window class constructor
* @chainable
*/
ve.ui.WindowSet.prototype.open = function ( name ) {
ve.ui.WindowSet.prototype.open = function ( name, config ) {
var win;
if ( !this.factory.lookup( name ) ) {
@ -125,7 +126,7 @@ ve.ui.WindowSet.prototype.open = function ( name ) {
throw new Error( 'Cannot open another window while another one is active' );
}
if ( !( name in this.windows ) ) {
win = this.windows[name] = this.factory.create( name, this.surface );
win = this.windows[name] = this.factory.create( name, this.surface, config );
win.connect( this, {
'setup': ['onWindowSetup', win],
'open': ['onWindowOpen', win],