2011-08-07 18:59:20 -03:00
|
|
|
/*
|
2012-10-04 20:48:01 -03:00
|
|
|
* Copyright [2012] [wisemapping]
|
2011-08-07 18:59:20 -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.
|
|
|
|
*/
|
|
|
|
|
2011-08-10 23:13:13 -03:00
|
|
|
mindplot.widget.ListToolbarPanel = new Class({
|
2011-10-04 01:16:29 -03:00
|
|
|
Extends: mindplot.widget.ToolbarPaneItem,
|
2014-03-05 00:14:28 -03:00
|
|
|
initialize: function (buttonId, model) {
|
2011-08-08 20:48:59 -03:00
|
|
|
this.parent(buttonId, model);
|
2011-08-10 23:13:13 -03:00
|
|
|
this._initPanel();
|
2011-08-07 18:59:20 -03:00
|
|
|
},
|
|
|
|
|
2011-08-10 23:13:13 -03:00
|
|
|
_initPanel: function () {
|
2011-08-07 18:59:20 -03:00
|
|
|
// Register on toolbar elements ...
|
2014-05-02 01:15:12 -03:00
|
|
|
var me = this;
|
2014-03-05 00:14:28 -03:00
|
|
|
this.getPanelElem().children('div').bind('click', function (event) {
|
|
|
|
event.stopPropagation();
|
2014-05-02 01:15:12 -03:00
|
|
|
me.hide();
|
|
|
|
var value = $defined($(this).attr('model')) ? $(this).attr('model') : $(this).attr('id');
|
|
|
|
me.getModel().setValue(value);
|
2014-03-05 00:14:28 -03:00
|
|
|
});
|
2011-08-07 18:59:20 -03:00
|
|
|
},
|
|
|
|
|
2014-03-05 00:14:28 -03:00
|
|
|
_updateSelectedItem: function () {
|
2011-10-14 22:56:20 -03:00
|
|
|
var panelElem = this.getPanelElem();
|
2014-04-27 23:59:45 -03:00
|
|
|
var menuElems = panelElem.find('div');
|
2011-10-14 22:56:20 -03:00
|
|
|
var value = this.getModel().getValue();
|
2014-03-17 00:36:29 -03:00
|
|
|
_.each(menuElems, function (elem) {
|
2014-05-02 01:15:12 -03:00
|
|
|
var elemValue = $defined($(elem).attr('model')) ? $(elem).attr('model') : $(elem).attr('id');
|
2014-03-05 00:14:28 -03:00
|
|
|
$assert(elemValue, "elemValue can not be null");
|
2011-10-14 22:56:20 -03:00
|
|
|
if (elemValue == value)
|
2014-05-02 01:15:12 -03:00
|
|
|
$(elem).attr('class', "toolbarPanelLinkSelectedLink");
|
2011-10-14 22:56:20 -03:00
|
|
|
else
|
2014-05-02 01:15:12 -03:00
|
|
|
$(elem).attr('class', "toolbarPanelLink");
|
2011-10-14 22:56:20 -03:00
|
|
|
});
|
|
|
|
return panelElem;
|
2011-08-07 18:59:20 -03:00
|
|
|
}
|
|
|
|
});
|