2011-10-04 01:16:29 -03:00
|
|
|
/*
|
2012-10-04 20:48:01 -03:00
|
|
|
* Copyright [2012] [wisemapping]
|
2011-10-04 01:16:29 -03:00
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
mindplot.widget.ToolbarPaneItem = new Class({
|
|
|
|
Extends:mindplot.widget.ToolbarItem,
|
|
|
|
initialize : function(buttonId, model) {
|
|
|
|
$assert(buttonId, "buttonId can not be null");
|
|
|
|
$assert(model, "model can not be null");
|
2011-10-14 22:56:20 -03:00
|
|
|
this._model = model;
|
2014-07-06 01:15:34 -03:00
|
|
|
var me = this;
|
2011-10-04 01:16:29 -03:00
|
|
|
var fn = function() {
|
|
|
|
// Is the panel being displayed ?
|
2014-07-06 01:15:34 -03:00
|
|
|
me.isVisible() ? me.hide() : me.show();
|
|
|
|
};
|
2011-10-04 23:59:21 -03:00
|
|
|
this.parent(buttonId, fn, {topicAction:true,relAction:false});
|
2011-10-14 22:56:20 -03:00
|
|
|
this._panelElem = this._init();
|
|
|
|
this._visible = false;
|
2011-10-04 01:16:29 -03:00
|
|
|
},
|
|
|
|
|
|
|
|
_init:function () {
|
|
|
|
// Load the context of the panel ...
|
|
|
|
var panelElem = this.buildPanel();
|
2014-03-04 23:09:39 -03:00
|
|
|
panelElem.css('cursor', 'default');
|
2011-10-04 01:16:29 -03:00
|
|
|
var buttonElem = this.getButtonElem();
|
|
|
|
|
2014-04-27 23:59:35 -03:00
|
|
|
var me = this;
|
2011-10-14 22:56:20 -03:00
|
|
|
this._tip = new mindplot.widget.FloatingTip(buttonElem, {
|
|
|
|
html: true,
|
2014-04-27 23:59:35 -03:00
|
|
|
placement: 'bottom',
|
2011-10-14 22:56:20 -03:00
|
|
|
content: function() {
|
2014-04-27 23:59:35 -03:00
|
|
|
return me._updateSelectedItem();
|
|
|
|
},
|
2011-10-14 22:56:20 -03:00
|
|
|
className: 'toolbarPaneTip',
|
2014-04-27 23:59:35 -03:00
|
|
|
trigger: 'manual'
|
2011-10-14 22:56:20 -03:00
|
|
|
});
|
|
|
|
|
2014-03-05 00:14:28 -03:00
|
|
|
this._tip.addEvent('hide', function() {
|
2014-04-27 23:59:35 -03:00
|
|
|
me._visible = false
|
|
|
|
});
|
2011-10-14 22:56:20 -03:00
|
|
|
|
2014-03-05 00:14:28 -03:00
|
|
|
this._tip.addEvent('show', function() {
|
2014-04-27 23:59:35 -03:00
|
|
|
me._visible = true
|
|
|
|
});
|
2011-10-04 01:16:29 -03:00
|
|
|
|
|
|
|
return panelElem;
|
|
|
|
},
|
|
|
|
|
|
|
|
getModel : function() {
|
|
|
|
return this._model;
|
|
|
|
},
|
|
|
|
|
|
|
|
getPanelElem : function() {
|
2011-10-14 22:56:20 -03:00
|
|
|
return this._panelElem;
|
2011-10-04 01:16:29 -03:00
|
|
|
}.protect(),
|
|
|
|
|
|
|
|
show : function() {
|
|
|
|
if (!this.isVisible()) {
|
|
|
|
this.parent();
|
2014-04-27 23:59:35 -03:00
|
|
|
this._tip.show();
|
2011-10-14 22:56:20 -03:00
|
|
|
this.getButtonElem().className = 'buttonExtActive';
|
2011-10-04 01:16:29 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hide : function() {
|
|
|
|
if (this.isVisible()) {
|
|
|
|
this.parent();
|
2014-04-27 23:59:35 -03:00
|
|
|
this._tip.hide();
|
2011-10-14 22:56:20 -03:00
|
|
|
this.getButtonElem().className = 'buttonExtOn';
|
2011-10-04 01:16:29 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isVisible : function() {
|
2011-10-14 22:56:20 -03:00
|
|
|
return this._visible;
|
2011-10-04 01:16:29 -03:00
|
|
|
},
|
|
|
|
|
2011-10-14 22:56:20 -03:00
|
|
|
disable : function() {
|
2011-10-04 01:16:29 -03:00
|
|
|
this.hide();
|
2011-10-14 22:56:20 -03:00
|
|
|
var elem = this.getButtonElem();
|
|
|
|
if (this._enable) {
|
2014-03-04 23:09:39 -03:00
|
|
|
elem.unbind('click', this._fn);
|
2011-10-14 22:56:20 -03:00
|
|
|
elem.removeClass('buttonExtOn');
|
|
|
|
|
|
|
|
// Todo: Hack...
|
|
|
|
elem.removeClass('buttonOn');
|
|
|
|
|
|
|
|
elem.addClass('buttonExtOff');
|
|
|
|
this._enable = false;
|
|
|
|
}
|
2011-10-04 01:16:29 -03:00
|
|
|
},
|
|
|
|
|
2011-10-14 22:56:20 -03:00
|
|
|
enable : function() {
|
|
|
|
var elem = this.getButtonElem();
|
|
|
|
if (!this._enable) {
|
2014-03-04 23:09:39 -03:00
|
|
|
elem.bind('click', this._fn);
|
2011-10-14 22:56:20 -03:00
|
|
|
elem.removeClass('buttonExtOff');
|
|
|
|
elem.addClass('buttonExtOn');
|
|
|
|
this._enable = true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-10-04 01:16:29 -03:00
|
|
|
buildPanel : function() {
|
|
|
|
throw "Method must be implemented";
|
|
|
|
}.protect()
|
|
|
|
|
|
|
|
});
|