2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2019-01-17 13:05:03 +00:00
|
|
|
* (c) Copyright Ascensio System SIA 2010-2019
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* This program is a free software product. You can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
|
|
|
* version 3 as published by the Free Software Foundation. In accordance with
|
|
|
|
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
|
|
|
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
|
|
|
* of any third-party rights.
|
|
|
|
*
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
|
|
|
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
*
|
2019-01-17 13:00:34 +00:00
|
|
|
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
|
|
|
* street, Riga, Latvia, EU, LV-1050.
|
2016-04-01 13:17:09 +00:00
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions
|
|
|
|
* of the Program must display Appropriate Legal Notices, as required under
|
|
|
|
* Section 5 of the GNU AGPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7(b) of the License you must retain the original Product
|
|
|
|
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
|
|
|
* grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
* All the Product's GUI elements, including illustrations and icon sets, as
|
|
|
|
* well as technical writing content are licensed under the terms of the
|
|
|
|
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
|
|
|
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
|
|
|
*
|
|
|
|
*/
|
2016-03-11 00:48:53 +00:00
|
|
|
/**
|
|
|
|
* Button.js
|
|
|
|
*
|
|
|
|
* Created by Alexander Yuzhin on 1/20/14
|
2018-03-01 12:16:38 +00:00
|
|
|
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
|
2016-03-11 00:48:53 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Using template
|
|
|
|
*
|
|
|
|
* A simple button with text:
|
|
|
|
* <button type="button" class="btn" id="id-button">Caption</button>
|
|
|
|
*
|
|
|
|
* A simple button with icon:
|
2017-03-13 16:14:26 +00:00
|
|
|
* <button type="button" class="btn" id="id-button"><span class="icon"> </span></button>
|
2016-03-11 00:48:53 +00:00
|
|
|
*
|
|
|
|
* A button with menu:
|
|
|
|
* <div class="btn-group" id="id-button">
|
|
|
|
* <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
|
2017-03-13 16:14:26 +00:00
|
|
|
* <span class="icon"> </span>
|
2016-03-11 00:48:53 +00:00
|
|
|
* <span class="caret"></span>
|
|
|
|
* </button>
|
|
|
|
* <ul class="dropdown-menu" role="menu">
|
|
|
|
* </ul>
|
|
|
|
* </div>
|
|
|
|
*
|
|
|
|
* A split button:
|
|
|
|
* <div class="btn-group split" id="id-button">
|
2017-03-13 16:14:26 +00:00
|
|
|
* <button type="button" class="btn"><span class="icon"> </span></button>
|
2016-03-11 00:48:53 +00:00
|
|
|
* <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
|
|
|
|
* <span class="caret"></span>
|
|
|
|
* <span class="sr-only"></span>
|
|
|
|
* </button>
|
|
|
|
* <ul class="dropdown-menu" role="menu">
|
|
|
|
* </ul>
|
|
|
|
* </div>
|
|
|
|
*
|
|
|
|
* A useful classes of button size
|
|
|
|
*
|
|
|
|
* - `'small'`
|
|
|
|
* - `'normal'`
|
|
|
|
* - `'large'`
|
|
|
|
* - `'huge'`
|
|
|
|
*
|
|
|
|
* A useful classes of button type
|
|
|
|
*
|
|
|
|
* - `'default'`
|
|
|
|
* - `'active'`
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Buttons can also be toggled. To enable this, you simple set the {@link #enableToggle} property to `true`.
|
|
|
|
*
|
|
|
|
* Example usage:
|
|
|
|
* new Common.UI.Button({
|
|
|
|
* el: $('#id'),
|
|
|
|
* enableToggle: true
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @property {Boolean} disabled
|
|
|
|
* True if this button is disabled. Read-only.
|
|
|
|
*
|
|
|
|
* disabled: false,
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @property {Boolean} pressed
|
|
|
|
* True if this button is pressed (only if enableToggle = true). Read-only.
|
|
|
|
*
|
|
|
|
* pressed: false,
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @cfg {Boolean} [allowDepress=true]
|
|
|
|
* False to not allow a pressed Button to be depressed. Only valid when {@link #enableToggle} is true.
|
|
|
|
*
|
|
|
|
* @cfg {String/Object} hint
|
|
|
|
* The tooltip for the button - can be a string to be used as bootstrap tooltip
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (Common === undefined)
|
|
|
|
var Common = {};
|
|
|
|
|
|
|
|
define([
|
|
|
|
'common/main/lib/component/BaseView',
|
|
|
|
'common/main/lib/component/ToggleManager'
|
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
2018-02-13 14:37:22 +00:00
|
|
|
window.createButtonSet = function() {
|
|
|
|
function ButtonsArray(args) {};
|
|
|
|
ButtonsArray.prototype = new Array;
|
|
|
|
ButtonsArray.prototype.constructor = ButtonsArray;
|
|
|
|
|
|
|
|
var _disabled = false;
|
|
|
|
|
|
|
|
ButtonsArray.prototype.add = function(button) {
|
|
|
|
button.setDisabled(_disabled);
|
|
|
|
this.push(button);
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonsArray.prototype.setDisabled = function(disable) {
|
2018-11-20 09:54:31 +00:00
|
|
|
// if ( _disabled != disable ) //bug when disable buttons outside the group
|
|
|
|
{
|
2018-02-13 14:37:22 +00:00
|
|
|
_disabled = disable;
|
|
|
|
|
|
|
|
this.forEach( function(button) {
|
|
|
|
button.setDisabled(disable);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonsArray.prototype.toggle = function(state, suppress) {
|
|
|
|
this.forEach(function(button) {
|
|
|
|
button.toggle(state, suppress);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonsArray.prototype.pressed = function() {
|
|
|
|
return this.some(function(button) {
|
|
|
|
return button.pressed;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonsArray.prototype.contains = function(id) {
|
|
|
|
return this.some(function(button) {
|
|
|
|
return button.id == id;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonsArray.prototype.concat = function () {
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
var result = Array.prototype.slice.call(this);
|
|
|
|
|
|
|
|
args.forEach(function(sub){
|
2018-04-23 11:16:37 +00:00
|
|
|
if (sub instanceof Array )
|
|
|
|
Array.prototype.push.apply(result, sub);
|
2018-04-24 10:46:07 +00:00
|
|
|
else if (sub)
|
2018-04-23 11:16:37 +00:00
|
|
|
result.push(sub);
|
2018-02-13 14:37:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return result;
|
2018-04-23 11:16:37 +00:00
|
|
|
};
|
2018-02-13 14:37:22 +00:00
|
|
|
|
|
|
|
var _out_array = Object.create(ButtonsArray.prototype);
|
|
|
|
for ( var i in arguments ) {
|
|
|
|
_out_array.add(arguments[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _out_array;
|
|
|
|
};
|
|
|
|
|
2017-06-26 09:19:08 +00:00
|
|
|
var templateBtnIcon =
|
|
|
|
'<% if ( iconImg ) { %>' +
|
|
|
|
'<img src="<%= iconImg %>">' +
|
|
|
|
'<% } else { %>' +
|
|
|
|
'<% if (/svgicon/.test(iconCls)) {' +
|
2019-10-15 13:11:19 +00:00
|
|
|
'print(\'<svg class=\"icon\"><use class=\"zoom-int\" xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'\"></use>' +
|
|
|
|
'<use class=\"zoom-grit\" xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'-150\"></use></svg>\');' +
|
|
|
|
'} else ' +
|
2017-06-26 09:19:08 +00:00
|
|
|
'print(\'<i class=\"icon \' + iconCls + \'\"> </i>\'); %>' +
|
|
|
|
'<% } %>';
|
|
|
|
|
2017-03-09 08:58:19 +00:00
|
|
|
var templateHugeCaption =
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn <%= cls %>" id="<%= id %>" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>> ' +
|
2017-03-23 12:52:49 +00:00
|
|
|
'<div class="inner-box-icon">' +
|
2017-06-26 09:19:08 +00:00
|
|
|
templateBtnIcon +
|
2017-03-23 12:52:49 +00:00
|
|
|
'</div>' +
|
2017-07-11 08:26:42 +00:00
|
|
|
'<div class="inner-box-caption">' +
|
|
|
|
'<span class="caption"><%= caption %></span>' +
|
|
|
|
'</div>' +
|
2017-03-29 08:49:42 +00:00
|
|
|
'</button>';
|
2017-03-23 12:52:49 +00:00
|
|
|
|
|
|
|
var templateHugeMenuCaption =
|
2017-03-13 16:14:26 +00:00
|
|
|
'<div class="btn-group icon-top" id="<%= id %>" style="<%= style %>">' +
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn dropdown-toggle <%= cls %>" data-toggle="dropdown" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>>' +
|
2017-03-29 08:49:42 +00:00
|
|
|
'<div class="inner-box-icon">' +
|
2017-06-26 09:19:08 +00:00
|
|
|
templateBtnIcon +
|
2017-03-29 08:49:42 +00:00
|
|
|
'</div>' +
|
2017-03-09 08:58:19 +00:00
|
|
|
'<div class="inner-box-caption">' +
|
2021-12-22 16:25:25 +00:00
|
|
|
'<span class="caption"><%= caption %>' +
|
|
|
|
'<i class="caret"></i>' +
|
|
|
|
'</span>' +
|
2021-12-28 15:18:18 +00:00
|
|
|
'<i class="caret compact-caret"></i>' +
|
2017-03-09 08:58:19 +00:00
|
|
|
'</div>' +
|
|
|
|
'</button>' +
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
var templateHugeSplitCaption =
|
|
|
|
'<div class="btn-group x-huge split icon-top" id="<%= id %>" style="<%= style %>">' +
|
|
|
|
'<button type="button" class="btn <%= cls %> inner-box-icon">' +
|
2017-08-15 11:26:40 +00:00
|
|
|
'<span class="btn-fixflex-hcenter">' +
|
|
|
|
templateBtnIcon +
|
|
|
|
'</span>' +
|
2017-03-09 08:58:19 +00:00
|
|
|
'</button>' +
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn <%= cls %> inner-box-caption dropdown-toggle" data-toggle="dropdown" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>>' +
|
2017-08-15 11:26:40 +00:00
|
|
|
'<span class="btn-fixflex-vcenter">' +
|
2021-12-24 12:16:21 +00:00
|
|
|
'<span class="caption"><%= caption %>' +
|
|
|
|
'<i class="caret"></i>' +
|
|
|
|
'</span>' +
|
2021-12-28 15:18:18 +00:00
|
|
|
'<i class="caret compact-caret"></i>' +
|
2017-08-15 11:26:40 +00:00
|
|
|
'</span>' +
|
2017-03-09 08:58:19 +00:00
|
|
|
'</button>' +
|
|
|
|
'</div>';
|
|
|
|
|
2021-12-27 18:18:15 +00:00
|
|
|
var getWidthOfCaption = function (txt) {
|
|
|
|
var el = document.createElement('span');
|
|
|
|
el.style.fontSize = '11px';
|
|
|
|
el.style.fontFamily = 'Arial, Helvetica, "Helvetica Neue", sans-serif';
|
|
|
|
el.style.position = "absolute";
|
|
|
|
el.style.top = '-1000px';
|
|
|
|
el.style.left = '-1000px';
|
|
|
|
el.innerHTML = txt;
|
|
|
|
document.body.appendChild(el);
|
|
|
|
var result = el.offsetWidth;
|
|
|
|
document.body.removeChild(el);
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
|
|
|
|
var getShortText = function (txt, max) {
|
|
|
|
var lastIndex = txt.length - 1,
|
|
|
|
word = txt;
|
|
|
|
while (getWidthOfCaption(word) > max) {
|
|
|
|
word = txt.slice(0, lastIndex).trim() + '...';
|
|
|
|
lastIndex--;
|
|
|
|
}
|
|
|
|
return word;
|
|
|
|
};
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.UI.Button = Common.UI.BaseView.extend({
|
|
|
|
options : {
|
|
|
|
id : null,
|
|
|
|
hint : false,
|
|
|
|
enableToggle : false,
|
|
|
|
allowDepress : true,
|
|
|
|
toggleGroup : null,
|
|
|
|
cls : '',
|
|
|
|
iconCls : '',
|
|
|
|
caption : '',
|
|
|
|
menu : null,
|
|
|
|
disabled : false,
|
|
|
|
pressed : false,
|
2017-11-16 09:37:41 +00:00
|
|
|
split : false,
|
2021-05-20 17:02:11 +00:00
|
|
|
visible : true,
|
|
|
|
dataHint : '',
|
2021-05-26 15:30:18 +00:00
|
|
|
dataHintDirection: '',
|
|
|
|
dataHintOffset: '0, 0'
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
template: _.template([
|
2017-03-16 09:55:11 +00:00
|
|
|
'<% var applyicon = function() { %>',
|
2017-03-16 11:38:12 +00:00
|
|
|
'<% if (iconImg) { print(\'<img src=\"\' + iconImg + \'\">\'); } else { %>',
|
2017-04-20 13:36:15 +00:00
|
|
|
// '<% if (iconCls != "") { print(\'<i class=\"icon \' + iconCls + \'\"> </i>\'); }} %>',
|
|
|
|
'<% if (iconCls != "") { ' +
|
|
|
|
' if (/svgicon/.test(iconCls)) {' +
|
2018-02-01 14:15:56 +00:00
|
|
|
'print(\'<svg class=\"icon\"><use class=\"zoom-int\" xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'\"></use>' +
|
|
|
|
'<use class=\"zoom-grit\" xlink:href=\"#\' + /svgicon\\s(\\S+)/.exec(iconCls)[1] + \'-150\"></use></svg>\');' +
|
2017-04-20 13:36:15 +00:00
|
|
|
'} else ' +
|
|
|
|
'print(\'<i class=\"icon \' + iconCls + \'\"> </i>\'); ' +
|
|
|
|
'}} %>',
|
2017-03-16 09:55:11 +00:00
|
|
|
'<% } %>',
|
2017-03-13 16:14:26 +00:00
|
|
|
'<% if ( !menu ) { %>',
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn <%= cls %>" id="<%= id %>" style="<%= style %>" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>>',
|
2017-03-16 09:55:11 +00:00
|
|
|
'<% applyicon() %>',
|
2017-03-06 09:02:32 +00:00
|
|
|
'<span class="caption"><%= caption %></span>',
|
2016-03-11 00:48:53 +00:00
|
|
|
'</button>',
|
|
|
|
'<% } else if (split == false) {%>',
|
|
|
|
'<div class="btn-group" id="<%= id %>" style="<%= style %>">',
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn dropdown-toggle <%= cls %>" data-toggle="dropdown" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>>',
|
2017-03-16 09:55:11 +00:00
|
|
|
'<% applyicon() %>',
|
2017-03-06 09:02:32 +00:00
|
|
|
'<span class="caption"><%= caption %></span>',
|
2017-07-11 08:26:42 +00:00
|
|
|
'<span class="inner-box-caret">' +
|
2021-01-03 21:58:06 +00:00
|
|
|
'<i class="caret"></i>' +
|
2017-07-11 08:26:42 +00:00
|
|
|
'</span>',
|
2016-03-11 00:48:53 +00:00
|
|
|
'</button>',
|
|
|
|
'</div>',
|
|
|
|
'<% } else { %>',
|
|
|
|
'<div class="btn-group split" id="<%= id %>" style="<%= style %>">',
|
2021-05-26 15:30:18 +00:00
|
|
|
'<button type="button" class="btn <%= cls %>">',
|
2017-03-16 09:55:11 +00:00
|
|
|
'<% applyicon() %>',
|
2017-03-06 09:02:32 +00:00
|
|
|
'<span class="caption"><%= caption %></span>',
|
2016-03-11 00:48:53 +00:00
|
|
|
'</button>',
|
2021-06-23 15:41:38 +00:00
|
|
|
'<button type="button" class="btn <%= cls %> dropdown-toggle" data-toggle="dropdown" data-hint="<%= dataHint %>" data-hint-direction="<%= dataHintDirection %>" data-hint-offset="<%= dataHintOffset %>" <% if (dataHintTitle) { %> data-hint-title="<%= dataHintTitle %>" <% } %>>',
|
2021-01-03 21:58:06 +00:00
|
|
|
'<i class="caret"></i>',
|
2016-03-11 00:48:53 +00:00
|
|
|
'<span class="sr-only"></span>',
|
|
|
|
'</button>',
|
|
|
|
'</div>',
|
|
|
|
'<% } %>'
|
|
|
|
].join('')),
|
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
Common.UI.BaseView.prototype.initialize.call(this, options);
|
|
|
|
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
me.id = me.options.id || Common.UI.getId();
|
|
|
|
me.hint = me.options.hint;
|
|
|
|
me.enableToggle = me.options.enableToggle;
|
|
|
|
me.allowDepress = me.options.allowDepress;
|
|
|
|
me.cls = me.options.cls;
|
|
|
|
me.iconCls = me.options.iconCls;
|
|
|
|
me.menu = me.options.menu;
|
|
|
|
me.split = me.options.split;
|
|
|
|
me.toggleGroup = me.options.toggleGroup;
|
|
|
|
me.disabled = me.options.disabled;
|
2017-11-16 09:37:41 +00:00
|
|
|
me.visible = me.options.visible;
|
2016-03-11 00:48:53 +00:00
|
|
|
me.pressed = me.options.pressed;
|
|
|
|
me.caption = me.options.caption;
|
|
|
|
me.template = me.options.template || me.template;
|
|
|
|
me.style = me.options.style;
|
|
|
|
me.rendered = false;
|
|
|
|
|
|
|
|
if (me.options.el) {
|
|
|
|
me.render();
|
2020-04-29 07:36:53 +00:00
|
|
|
} else if (me.options.parentEl)
|
|
|
|
me.render(me.options.parentEl);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2021-12-29 12:47:52 +00:00
|
|
|
getCaptionWithBreaks: function (caption) {
|
|
|
|
var words = caption.split(' '),
|
|
|
|
newCaption = null,
|
2022-01-11 14:52:59 +00:00
|
|
|
maxWidth = 85 - 4;
|
2021-12-29 12:47:52 +00:00
|
|
|
if (words.length > 1) {
|
2022-01-11 14:52:59 +00:00
|
|
|
maxWidth = !!this.menu || this.split === true ? maxWidth - 10 : maxWidth;
|
2021-12-29 12:47:52 +00:00
|
|
|
if (words.length < 3) {
|
|
|
|
words[1] = getShortText(words[1], maxWidth);
|
|
|
|
newCaption = words[0] + '<br>' + words[1];
|
|
|
|
} else {
|
|
|
|
if (getWidthOfCaption(words[0] + ' ' + words[1]) < maxWidth) { // first and second words in first line
|
|
|
|
words[2] = getShortText(words[2], maxWidth);
|
|
|
|
newCaption = words[0] + ' ' + words[1] + '<br>' + words[2];
|
|
|
|
} else if (getWidthOfCaption(words[1] + ' ' + words[2]) < maxWidth) { // second and third words in second line
|
|
|
|
words[2] = getShortText(words[2], maxWidth);
|
|
|
|
newCaption = words[0] + '<br>' + words[1] + ' ' + words[2];
|
|
|
|
} else {
|
|
|
|
words[1] = getShortText(words[1] + ' ' + words[2], maxWidth);
|
|
|
|
newCaption = words[0] + '<br>' + words[1];
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 14:52:59 +00:00
|
|
|
} else {
|
2021-12-29 12:47:52 +00:00
|
|
|
var width = getWidthOfCaption(caption);
|
2022-01-11 14:52:59 +00:00
|
|
|
newCaption = width < maxWidth ? caption : getShortText(caption, maxWidth);
|
|
|
|
if (!!this.menu || this.split === true) {
|
|
|
|
newCaption += '<br>';
|
2021-12-29 12:47:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return newCaption;
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
render: function(parentEl) {
|
|
|
|
var me = this;
|
|
|
|
|
|
|
|
me.trigger('render:before', me);
|
|
|
|
|
2019-07-29 11:24:20 +00:00
|
|
|
me.cmpEl = me.$el || $(me.el);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (parentEl) {
|
|
|
|
me.setElement(parentEl, false);
|
|
|
|
|
|
|
|
if (!me.rendered) {
|
2017-03-09 08:58:19 +00:00
|
|
|
if ( /icon-top/.test(me.cls) && !!me.caption && /huge/.test(me.cls) ) {
|
|
|
|
if ( me.split === true ) {
|
|
|
|
!!me.cls && (me.cls = me.cls.replace(/\s?(?:x-huge|icon-top)/g, ''));
|
|
|
|
this.template = _.template(templateHugeSplitCaption);
|
|
|
|
} else
|
|
|
|
if ( !!me.menu ) {
|
2017-03-23 12:52:49 +00:00
|
|
|
this.template = _.template(templateHugeMenuCaption);
|
|
|
|
} else {
|
2017-03-09 08:58:19 +00:00
|
|
|
this.template = _.template(templateHugeCaption);
|
|
|
|
}
|
2021-12-29 12:47:52 +00:00
|
|
|
var newCaption = this.getCaptionWithBreaks(this.caption);
|
2021-12-24 12:16:21 +00:00
|
|
|
if (newCaption) {
|
|
|
|
me.caption = newCaption;
|
|
|
|
}
|
2017-03-09 08:58:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
me.cmpEl = $(this.template({
|
|
|
|
id : me.id,
|
|
|
|
cls : me.cls,
|
|
|
|
iconCls : me.iconCls,
|
2017-03-16 09:55:11 +00:00
|
|
|
iconImg : me.options.iconImg,
|
2016-03-11 00:48:53 +00:00
|
|
|
menu : me.menu,
|
|
|
|
split : me.split,
|
|
|
|
disabled : me.disabled,
|
|
|
|
pressed : me.pressed,
|
|
|
|
caption : me.caption,
|
2021-05-20 17:02:11 +00:00
|
|
|
style : me.style,
|
|
|
|
dataHint : me.options.dataHint,
|
2021-05-26 15:30:18 +00:00
|
|
|
dataHintDirection: me.options.dataHintDirection,
|
2021-06-23 15:41:38 +00:00
|
|
|
dataHintOffset: me.options.dataHintOffset,
|
|
|
|
dataHintTitle: me.options.dataHintTitle
|
2016-03-11 00:48:53 +00:00
|
|
|
}));
|
|
|
|
|
2016-08-04 17:02:57 +00:00
|
|
|
if (me.menu && _.isObject(me.menu) && _.isFunction(me.menu.render))
|
2016-03-11 00:48:53 +00:00
|
|
|
me.menu.render(me.cmpEl);
|
|
|
|
|
|
|
|
parentEl.html(me.cmpEl);
|
2018-02-26 13:23:07 +00:00
|
|
|
me.$icon = me.$el.find('.icon');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!me.rendered) {
|
|
|
|
var el = me.cmpEl,
|
|
|
|
isGroup = el.hasClass('btn-group'),
|
|
|
|
isSplit = el.hasClass('split');
|
|
|
|
|
|
|
|
if (me.options.hint) {
|
|
|
|
var modalParents = me.cmpEl.closest('.asc-window');
|
|
|
|
|
2017-08-03 13:38:52 +00:00
|
|
|
if (typeof me.options.hint == 'object' && me.options.hint.length>1 && $('button', el).length>0) {
|
|
|
|
var btnEl = $('button', el);
|
|
|
|
me.btnEl = $(btnEl[0]);
|
|
|
|
me.btnMenuEl = $(btnEl[1]);
|
|
|
|
} else {
|
|
|
|
me.btnEl = me.cmpEl;
|
|
|
|
me.btnEl.attr('data-toggle', 'tooltip');
|
|
|
|
}
|
|
|
|
me.btnEl.tooltip({
|
|
|
|
title : (typeof me.options.hint == 'string') ? me.options.hint : me.options.hint[0],
|
|
|
|
placement : me.options.hintAnchor||'cursor'
|
|
|
|
});
|
|
|
|
me.btnMenuEl && me.btnMenuEl.tooltip({
|
|
|
|
title : me.options.hint[1],
|
2016-03-11 00:48:53 +00:00
|
|
|
placement : me.options.hintAnchor||'cursor'
|
|
|
|
});
|
|
|
|
|
|
|
|
if (modalParents.length > 0) {
|
2017-08-03 13:38:52 +00:00
|
|
|
me.btnEl.data('bs.tooltip').tip().css('z-index', parseInt(modalParents.css('z-index')) + 10);
|
|
|
|
me.btnMenuEl && me.btnMenuEl.data('bs.tooltip').tip().css('z-index', parseInt(modalParents.css('z-index')) + 10);
|
2019-09-02 11:01:42 +00:00
|
|
|
var onModalClose = function(dlg) {
|
|
|
|
if (modalParents[0] !== dlg.$window[0]) return;
|
|
|
|
var tip = me.btnEl.data('bs.tooltip');
|
|
|
|
if (tip) {
|
|
|
|
if (tip.dontShow===undefined)
|
|
|
|
tip.dontShow = true;
|
|
|
|
|
|
|
|
tip.hide();
|
|
|
|
}
|
|
|
|
Common.NotificationCenter.off({'modal:close': onModalClose});
|
|
|
|
};
|
|
|
|
Common.NotificationCenter.on({'modal:close': onModalClose});
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_.isString(me.toggleGroup)) {
|
|
|
|
me.enableToggle = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var buttonHandler = function(e) {
|
|
|
|
if (!me.disabled && e.which == 1) {
|
|
|
|
me.doToggle();
|
|
|
|
if (me.options.hint) {
|
2017-08-03 13:38:52 +00:00
|
|
|
var tip = me.btnEl.data('bs.tooltip');
|
2016-03-11 00:48:53 +00:00
|
|
|
if (tip) {
|
|
|
|
if (tip.dontShow===undefined)
|
|
|
|
tip.dontShow = true;
|
|
|
|
|
|
|
|
tip.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
me.trigger('click', me, e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-23 13:00:24 +00:00
|
|
|
var doSplitSelect = function(select, element, e) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!select) {
|
|
|
|
// Is mouse under button
|
|
|
|
var isUnderMouse = false;
|
|
|
|
|
2017-03-23 13:00:24 +00:00
|
|
|
$('button', el).each(function(index, button){
|
|
|
|
if ($(button).is(':hover')) {
|
2016-03-11 00:48:53 +00:00
|
|
|
isUnderMouse = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!isUnderMouse) {
|
|
|
|
el.removeClass('over');
|
|
|
|
$('button', el).removeClass('over');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-23 13:00:24 +00:00
|
|
|
if ( element == 'button') {
|
|
|
|
if (!select && (me.enableToggle && me.allowDepress && me.pressed))
|
|
|
|
return;
|
|
|
|
if (select && !isSplit && (me.enableToggle && me.allowDepress && !me.pressed)) { // to depress button with menu
|
|
|
|
e.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$('button:first', el).toggleClass('active', select);
|
|
|
|
} else
|
|
|
|
$('[data-toggle^=dropdown]', el).toggleClass('active', select);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
el.toggleClass('active', select);
|
|
|
|
};
|
|
|
|
|
|
|
|
var menuHandler = function(e) {
|
|
|
|
if (!me.disabled && e.which == 1) {
|
|
|
|
if (isSplit) {
|
|
|
|
if (me.options.hint) {
|
2017-08-03 13:38:52 +00:00
|
|
|
var tip = (me.btnMenuEl ? me.btnMenuEl : me.btnEl).data('bs.tooltip');
|
2016-03-11 00:48:53 +00:00
|
|
|
if (tip) {
|
|
|
|
if (tip.dontShow===undefined)
|
|
|
|
tip.dontShow = true;
|
|
|
|
|
|
|
|
tip.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var isOpen = el.hasClass('open');
|
2017-03-23 13:00:24 +00:00
|
|
|
doSplitSelect(!isOpen, 'arrow', e);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var doSetActiveState = function(e, state) {
|
|
|
|
if (isSplit) {
|
2017-03-23 13:00:24 +00:00
|
|
|
doSplitSelect(state, 'button', e);
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
|
|
|
el.toggleClass('active', state);
|
|
|
|
$('button', el).toggleClass('active', state);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-23 13:00:24 +00:00
|
|
|
var splitElement;
|
2016-03-11 00:48:53 +00:00
|
|
|
var onMouseDown = function (e) {
|
2017-03-23 13:00:24 +00:00
|
|
|
splitElement = e.currentTarget.className.match(/dropdown/) ? 'arrow' : 'button';
|
|
|
|
doSplitSelect(true, splitElement, e);
|
2016-03-11 00:48:53 +00:00
|
|
|
$(document).on('mouseup', onMouseUp);
|
|
|
|
};
|
|
|
|
|
|
|
|
var onMouseUp = function (e) {
|
2017-03-23 13:00:24 +00:00
|
|
|
doSplitSelect(false, splitElement, e);
|
2016-03-11 00:48:53 +00:00
|
|
|
$(document).off('mouseup', onMouseUp);
|
|
|
|
};
|
|
|
|
|
2017-04-12 09:45:16 +00:00
|
|
|
var onAfterHideMenu = function(e, isFromInputControl) {
|
2016-03-11 00:48:53 +00:00
|
|
|
me.cmpEl.find('.dropdown-toggle').blur();
|
|
|
|
if (me.cmpEl.hasClass('active') !== me.pressed)
|
|
|
|
me.cmpEl.trigger('button.internal.active', [me.pressed]);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (isGroup) {
|
|
|
|
if (isSplit) {
|
|
|
|
$('[data-toggle^=dropdown]', el).on('mousedown', _.bind(menuHandler, this));
|
|
|
|
$('button', el).on('mousedown', _.bind(onMouseDown, this));
|
2019-04-05 14:36:15 +00:00
|
|
|
(me.options.width>0) && $('button:first', el).css('width', me.options.width - $('[data-toggle^=dropdown]', el).outerWidth());
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-23 13:00:24 +00:00
|
|
|
el.on('hide.bs.dropdown', _.bind(doSplitSelect, me, false, 'arrow'));
|
|
|
|
el.on('show.bs.dropdown', _.bind(doSplitSelect, me, true, 'arrow'));
|
2016-03-11 00:48:53 +00:00
|
|
|
el.on('hidden.bs.dropdown', _.bind(onAfterHideMenu, me));
|
|
|
|
|
|
|
|
$('button:first', el).on('click', buttonHandler);
|
|
|
|
} else {
|
|
|
|
el.on('click', buttonHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
el.on('button.internal.active', _.bind(doSetActiveState, me));
|
|
|
|
|
|
|
|
el.on('mouseover', function(e) {
|
|
|
|
if (!me.disabled) {
|
|
|
|
me.cmpEl.addClass('over');
|
|
|
|
me.trigger('mouseover', me, e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
el.on('mouseout', function(e) {
|
2019-05-24 09:58:06 +00:00
|
|
|
me.cmpEl.removeClass('over');
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!me.disabled) {
|
|
|
|
me.trigger('mouseout', me, e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Register the button in the toggle manager
|
|
|
|
Common.UI.ToggleManager.register(me);
|
|
|
|
}
|
|
|
|
|
|
|
|
me.rendered = true;
|
|
|
|
|
|
|
|
if (me.pressed) {
|
|
|
|
me.toggle(me.pressed, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (me.disabled) {
|
2016-08-05 09:58:30 +00:00
|
|
|
me.setDisabled(!(me.disabled=false));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2017-11-16 09:37:41 +00:00
|
|
|
if (!me.visible) {
|
|
|
|
me.setVisible(me.visible);
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
me.trigger('render:after', me);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
doToggle: function(){
|
|
|
|
var me = this;
|
|
|
|
if (me.enableToggle && (me.allowDepress !== false || !me.pressed)) {
|
|
|
|
me.toggle();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
toggle: function(toggle, suppressEvent) {
|
|
|
|
var state = toggle === undefined ? !this.pressed : !!toggle;
|
|
|
|
|
|
|
|
this.pressed = state;
|
|
|
|
|
|
|
|
if (this.cmpEl)
|
|
|
|
this.cmpEl.trigger('button.internal.active', [state]);
|
|
|
|
|
|
|
|
if (!suppressEvent)
|
|
|
|
this.trigger('toggle', this, state);
|
|
|
|
},
|
|
|
|
|
2019-11-05 12:17:48 +00:00
|
|
|
click: function(opts) {
|
|
|
|
if ( !this.disabled ) {
|
|
|
|
this.doToggle();
|
|
|
|
this.trigger('click', this, opts);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
isActive: function() {
|
|
|
|
if (this.enableToggle)
|
|
|
|
return this.pressed;
|
|
|
|
|
|
|
|
return this.cmpEl.hasClass('active')
|
|
|
|
},
|
|
|
|
|
|
|
|
setDisabled: function(disabled) {
|
2016-08-12 12:04:12 +00:00
|
|
|
if (this.rendered && this.disabled != disabled) {
|
2016-03-11 00:48:53 +00:00
|
|
|
var el = this.cmpEl,
|
2017-04-11 14:07:46 +00:00
|
|
|
isGroup = el.hasClass('btn-group'),
|
|
|
|
me = this;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
disabled = (disabled===true);
|
|
|
|
|
|
|
|
if (disabled !== el.hasClass('disabled')) {
|
|
|
|
var decorateBtn = function(button) {
|
|
|
|
button.toggleClass('disabled', disabled);
|
2017-04-11 14:07:46 +00:00
|
|
|
if (!me.options.allowMouseEventsOnDisabled)
|
|
|
|
(disabled) ? button.attr({disabled: disabled}) : button.removeAttr('disabled');
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
decorateBtn(el);
|
|
|
|
isGroup && decorateBtn(el.children('button'));
|
|
|
|
}
|
|
|
|
|
2017-08-03 13:38:52 +00:00
|
|
|
if ((disabled || !Common.Utils.isGecko) && this.options.hint) {
|
|
|
|
var tip = this.btnEl.data('bs.tooltip');
|
2016-03-11 00:48:53 +00:00
|
|
|
if (tip) {
|
2016-12-16 13:26:37 +00:00
|
|
|
disabled && tip.hide();
|
|
|
|
!Common.Utils.isGecko && (tip.enabled = !disabled);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2017-08-03 13:38:52 +00:00
|
|
|
if (this.btnMenuEl) {
|
|
|
|
tip = this.btnMenuEl.data('bs.tooltip');
|
|
|
|
if (tip) {
|
|
|
|
disabled && tip.hide();
|
|
|
|
!Common.Utils.isGecko && (tip.enabled = !disabled);
|
|
|
|
}
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2018-02-15 23:56:17 +00:00
|
|
|
|
2018-07-19 13:41:52 +00:00
|
|
|
if (disabled && this.menu && _.isObject(this.menu) && this.menu.rendered && this.menu.isVisible())
|
2018-07-20 10:28:54 +00:00
|
|
|
setTimeout(function(){ me.menu.hide()}, 1);
|
2018-07-19 13:41:52 +00:00
|
|
|
|
2018-02-15 23:56:17 +00:00
|
|
|
if ( !!me.options.signals ) {
|
|
|
|
var opts = me.options.signals;
|
|
|
|
if ( !(opts.indexOf('disabled') < 0) ) {
|
|
|
|
me.trigger('disabled', me, disabled);
|
|
|
|
}
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.disabled = disabled;
|
|
|
|
},
|
|
|
|
|
|
|
|
isDisabled: function() {
|
|
|
|
return this.disabled;
|
|
|
|
},
|
|
|
|
|
|
|
|
setIconCls: function(cls) {
|
2017-03-09 08:41:47 +00:00
|
|
|
var btnIconEl = $(this.el).find('.icon'),
|
2016-03-11 00:48:53 +00:00
|
|
|
oldCls = this.iconCls;
|
|
|
|
|
|
|
|
this.iconCls = cls;
|
2020-05-06 14:17:03 +00:00
|
|
|
if (/svgicon/.test(this.iconCls)) {
|
|
|
|
var icon = /svgicon\s(\S+)/.exec(this.iconCls);
|
|
|
|
btnIconEl.find('use.zoom-int').attr('xlink:href', icon && icon.length>1 ? '#' + icon[1]: '');
|
|
|
|
btnIconEl.find('use.zoom-grit').attr('xlink:href', icon && icon.length>1 ? '#' + icon[1] + '-150' : '');
|
|
|
|
} else {
|
|
|
|
btnIconEl.removeClass(oldCls);
|
|
|
|
btnIconEl.addClass(cls || '');
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
2019-11-05 12:28:33 +00:00
|
|
|
changeIcon: function(opts) {
|
|
|
|
var me = this;
|
2020-12-14 19:45:30 +00:00
|
|
|
if ( opts && (opts.curr || opts.next) && me.$icon) {
|
2019-11-06 13:50:12 +00:00
|
|
|
!!opts.curr && (me.$icon.removeClass(opts.curr));
|
2019-11-05 12:28:33 +00:00
|
|
|
!!opts.next && !me.$icon.hasClass(opts.next) && (me.$icon.addClass(opts.next));
|
|
|
|
|
|
|
|
if ( !!me.options.signals ) {
|
|
|
|
if ( !(me.options.signals.indexOf('icon:changed') < 0) ) {
|
|
|
|
me.trigger('icon:changed', me, opts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hasIcon: function(iconcls) {
|
|
|
|
return this.$icon.hasClass(iconcls);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
setVisible: function(visible) {
|
|
|
|
if (this.cmpEl) this.cmpEl.toggleClass('hidden', !visible);
|
2017-11-16 09:37:41 +00:00
|
|
|
this.visible = visible;
|
|
|
|
},
|
|
|
|
|
|
|
|
isVisible: function() {
|
|
|
|
return (this.cmpEl) ? this.cmpEl.is(":visible") : $(this.el).is(":visible");
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updateHint: function(hint) {
|
|
|
|
this.options.hint = hint;
|
|
|
|
|
2016-08-23 08:25:57 +00:00
|
|
|
if (!this.rendered) return;
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
var cmpEl = this.cmpEl,
|
|
|
|
modalParents = cmpEl.closest('.asc-window');
|
|
|
|
|
2017-08-03 13:38:52 +00:00
|
|
|
|
|
|
|
if (!this.btnEl) {
|
|
|
|
if (typeof this.options.hint == 'object' && this.options.hint.length>1 && $('button', cmpEl).length>0) {
|
|
|
|
var btnEl = $('button', cmpEl);
|
|
|
|
this.btnEl = $(btnEl[0]);
|
|
|
|
this.btnMenuEl = $(btnEl[1]);
|
|
|
|
} else {
|
|
|
|
this.btnEl = cmpEl;
|
|
|
|
this.btnEl.attr('data-toggle', 'tooltip');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.btnEl.data('bs.tooltip'))
|
|
|
|
this.btnEl.removeData('bs.tooltip');
|
|
|
|
if (this.btnMenuEl && this.btnMenuEl.data('bs.tooltip'))
|
|
|
|
this.btnMenuEl.removeData('bs.tooltip');
|
|
|
|
|
|
|
|
this.btnEl.tooltip({
|
|
|
|
title : (typeof hint == 'string') ? hint : hint[0],
|
|
|
|
placement : this.options.hintAnchor||'cursor'
|
|
|
|
});
|
|
|
|
this.btnMenuEl && this.btnMenuEl.tooltip({
|
|
|
|
title : hint[1],
|
|
|
|
placement : this.options.hintAnchor||'cursor'
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (modalParents.length > 0) {
|
2017-08-03 13:38:52 +00:00
|
|
|
this.btnEl.data('bs.tooltip').tip().css('z-index', parseInt(modalParents.css('z-index')) + 10);
|
|
|
|
this.btnMenuEl && this.btnMenuEl.data('bs.tooltip').tip().css('z-index', parseInt(modalParents.css('z-index')) + 10);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2017-04-24 12:46:46 +00:00
|
|
|
|
|
|
|
if (this.disabled || !Common.Utils.isGecko) {
|
2017-08-03 13:38:52 +00:00
|
|
|
var tip = this.btnEl.data('bs.tooltip');
|
2017-04-24 12:46:46 +00:00
|
|
|
if (tip) {
|
|
|
|
this.disabled && tip.hide();
|
|
|
|
!Common.Utils.isGecko && (tip.enabled = !this.disabled);
|
|
|
|
}
|
2017-08-03 13:38:52 +00:00
|
|
|
if (this.btnMenuEl) {
|
|
|
|
tip = this.btnMenuEl.data('bs.tooltip');
|
|
|
|
if (tip) {
|
|
|
|
this.disabled && tip.hide();
|
|
|
|
!Common.Utils.isGecko && (tip.enabled = !this.disabled);
|
|
|
|
}
|
|
|
|
}
|
2017-04-24 12:46:46 +00:00
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setCaption: function(caption) {
|
|
|
|
if (this.caption != caption) {
|
2021-12-29 12:47:52 +00:00
|
|
|
if ( /icon-top/.test(this.cls) && !!this.caption && /huge/.test(this.cls) ) {
|
|
|
|
var newCaption = this.getCaptionWithBreaks(caption);
|
|
|
|
this.caption = newCaption || caption;
|
|
|
|
} else
|
|
|
|
this.caption = caption;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (this.rendered) {
|
2019-11-06 14:19:43 +00:00
|
|
|
var captionNode = this.cmpEl.find('.caption');
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (captionNode.length > 0) {
|
2021-12-29 12:47:52 +00:00
|
|
|
captionNode.html(this.caption);
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
2021-12-29 12:47:52 +00:00
|
|
|
this.cmpEl.find('button:first').addBack().filter('button').html(this.caption);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-12 12:04:12 +00:00
|
|
|
},
|
2016-08-04 17:02:57 +00:00
|
|
|
|
2016-08-12 12:04:12 +00:00
|
|
|
setMenu: function (m) {
|
2016-10-20 08:52:14 +00:00
|
|
|
if (m && _.isObject(m) && _.isFunction(m.render)){
|
2016-08-04 17:02:57 +00:00
|
|
|
this.menu = m;
|
2016-10-20 08:52:14 +00:00
|
|
|
if (this.rendered)
|
|
|
|
this.menu.render(this.cmpEl);
|
2016-08-04 17:02:57 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|