From 599ad772ed5bfc4188f78c399d1895310b7a472b Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 14 Aug 2013 15:39:56 +0100 Subject: [PATCH] Allow inspectors to not show the delete button This functionality makes sense for annotations, but not for extensions. Change-Id: I64fea941f8e01d0464eb9a045257f4810d789d60 --- .../inspectors/ve.ui.MWExtensionInspector.js | 2 ++ modules/ve/ui/ve.ui.Inspector.js | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js index 8367a18264..563acd4981 100644 --- a/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js +++ b/modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js @@ -31,6 +31,8 @@ ve.ui.MWExtensionInspector.static.nodeView = null; ve.ui.MWExtensionInspector.static.nodeModel = null; +ve.ui.MWExtensionInspector.static.removeable = false; + /* Methods */ /** diff --git a/modules/ve/ui/ve.ui.Inspector.js b/modules/ve/ui/ve.ui.Inspector.js index e56dc06d40..93f208225a 100644 --- a/modules/ve/ui/ve.ui.Inspector.js +++ b/modules/ve/ui/ve.ui.Inspector.js @@ -35,6 +35,15 @@ ve.inheritClass( ve.ui.Inspector, ve.ui.Window ); ve.ui.Inspector.static.titleMessage = 've-ui-inspector-title'; +/** + * The inspector comes with a remove button + + * @static + * @inheritable + * @property {boolean} + */ +ve.ui.Inspector.static.removeable = true; + /* Methods */ /** @@ -52,9 +61,11 @@ ve.ui.Inspector.prototype.initialize = function () { this.closeButton = new ve.ui.IconButtonWidget( { '$$': this.$$, 'icon': 'previous', 'title': ve.msg( 'visualeditor-inspector-close-tooltip' ) } ); - this.removeButton = new ve.ui.IconButtonWidget( { - '$$': this.$$, 'icon': 'remove', 'title': ve.msg( 'visualeditor-inspector-remove-tooltip' ) - } ); + if ( this.constructor.static.removeable ) { + this.removeButton = new ve.ui.IconButtonWidget( { + '$$': this.$$, 'icon': 'remove', 'title': ve.msg( 'visualeditor-inspector-remove-tooltip' ) + } ); + } // Events this.$form.on( { @@ -62,12 +73,17 @@ ve.ui.Inspector.prototype.initialize = function () { 'keydown': ve.bind( this.onFormKeyDown, this ) } ); this.closeButton.connect( this, { 'click': 'onCloseButtonClick' } ); - this.removeButton.connect( this, { 'click': 'onRemoveButtonClick' } ); + if ( this.constructor.static.removeable ) { + this.removeButton.connect( this, { 'click': 'onRemoveButtonClick' } ); + } // Initialization this.closeButton.$.addClass( 've-ui-inspector-closeButton' ); - this.removeButton.$.addClass( 've-ui-inspector-removeButton' ); - this.$head.prepend( this.closeButton.$ ).append( this.removeButton.$ ); + this.$head.prepend( this.closeButton.$ ); + if ( this.constructor.static.removeable ) { + this.removeButton.$.addClass( 've-ui-inspector-removeButton' ); + this.$head.append( this.removeButton.$ ); + } this.$body.append( this.$form ); };