123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- define(['underscore', '../lib/@waca/dashboard-common/dist/ui/AuthoringToolbar', 'jquery'], function (_, Toolbar, $) {
- var ToolbarHelper = function () {
-
- function ToolbarHelper(attributes) {
- _classCallCheck(this, ToolbarHelper);
- attributes = attributes || {};
- this._cbOnRemove = attributes.cbOnRemove || this._cbOnRemove;
- }
- ToolbarHelper.prototype.getToolbar = function getToolbar() {
- return this._actionMenuToolbar;
- };
-
- ToolbarHelper.prototype.buildActionToolbar = function buildActionToolbar(aActions, parentNode, sLabel, userOptions) {
- var toolbarOptions = _.clone(userOptions);
- toolbarOptions.textOnly = true;
- toolbarOptions.container = $('body');
- toolbarOptions.notCentered = true;
- toolbarOptions.popoverClass = 'popover actionToolbarPopover text';
-
- parentNode = $(parentNode).find(userOptions.attachPoint || '.toolbarRoot');
- var toolbar = new Toolbar(toolbarOptions);
- toolbar.setName(sLabel);
- toolbar.addItems(aActions);
- toolbar.setSelectionContext([parentNode]);
- toolbar.show(toolbarOptions.placement);
- parentNode.addClass('selected');
- var hideToolbar = function hideToolbar() {
- this._clearToolbar();
- setTimeout(this._cbOnRemove.bind(this), 100);
- };
-
-
-
- toolbar.on('flyout:hide', hideToolbar, this);
- toolbar.on('toolbar:remove', this._cbOnRemove.bind(this));
- this._actionMenuToolbar = toolbar;
- };
-
-
- ToolbarHelper.prototype._cbOnRemove = function _cbOnRemove() {};
- ToolbarHelper.prototype._clearToolbar = function _clearToolbar() {
- if (this._actionMenuToolbar) {
- _.each(this._actionMenuToolbar.selectionNodes, function (node) {
- $(node).removeClass('selected');
- });
- this._actionMenuToolbar.hide();
- this._actionMenuToolbar.remove();
- this._actionMenuToolbar = null;
- }
- };
- return ToolbarHelper;
- }();
- return ToolbarHelper;
- });
|