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
|
|
|
/**
|
|
|
|
* Window.js
|
|
|
|
*
|
|
|
|
* Created by Maxim Kadushkin on 24 January 2014
|
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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Usage
|
|
|
|
*
|
|
|
|
* Configuration
|
|
|
|
*
|
|
|
|
* @cfg {Boolean} closable
|
|
|
|
* Doesn't allow user to close window neither ESC nor the 'close' button.
|
|
|
|
*
|
|
|
|
* @cfg {Boolean} header
|
|
|
|
* Prevents window to create header. Default value is 'true'
|
|
|
|
|
|
|
|
* @cfg {Boolean} modal
|
|
|
|
* False if window will not allowed to take over keyboard and mouse input.
|
|
|
|
*
|
|
|
|
* @cfg {String} title
|
|
|
|
*
|
|
|
|
* @cfg {String} tpl
|
|
|
|
* Describes template of window's body
|
|
|
|
*
|
|
|
|
* @cfg {String} cls
|
|
|
|
* Extra class for the root dom-element
|
|
|
|
*
|
|
|
|
* @cfg {Boolean} animate
|
|
|
|
* Makes the window to animate while showing or hiding
|
|
|
|
*
|
2019-09-11 08:38:08 +00:00
|
|
|
* @cfg {Object} buttons
|
|
|
|
* Use an array for predefined buttons (ok, cancel, yes, no): @example ['yes', 'no']
|
|
|
|
* Use a named array for the custom buttons: {value: caption, ...}
|
|
|
|
* @param {String} value will be returned in callback function
|
|
|
|
* @param {String} caption
|
|
|
|
*
|
2016-03-11 00:48:53 +00:00
|
|
|
* Methods
|
|
|
|
*
|
|
|
|
* @method show
|
|
|
|
* Fires event 'afterender'
|
|
|
|
*
|
|
|
|
* @method close
|
|
|
|
* Fires event 'close'
|
|
|
|
*
|
|
|
|
* @method setSize
|
|
|
|
* Sets new size of the window
|
|
|
|
* @params {Integer} width
|
|
|
|
* @params {Integer} height
|
|
|
|
|
|
|
|
* @method getSize
|
|
|
|
* Returns current size of the window
|
|
|
|
* @returns {Array} [width, height]
|
|
|
|
*
|
|
|
|
* @method getChild
|
|
|
|
* @params {String} selector
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Events
|
|
|
|
*
|
|
|
|
* @event close
|
|
|
|
*
|
|
|
|
* @event afterender
|
|
|
|
*
|
|
|
|
* Examples
|
|
|
|
* var win = new Common.UI.Window({
|
|
|
|
* title: options.title,
|
|
|
|
* tpl: template
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
* win.on('close', onClose);
|
|
|
|
* win.show()
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* ****************************************
|
|
|
|
* Extends
|
|
|
|
*
|
|
|
|
* @window Common.UI.warning
|
|
|
|
* Shows warning message.
|
|
|
|
* @cfg {String} msg
|
|
|
|
* @cfg {Function} callback
|
|
|
|
* @param {String} button
|
|
|
|
* If the window is closed via shortcut or header's close tool, the 'button' will be 'close'
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* Common.UI.warning({
|
|
|
|
* msg: 'Unknown error.',
|
|
|
|
* buttons: ['ok'],
|
|
|
|
* callback: function(btn) {
|
|
|
|
* console.log('button was pressed: ' + btn);
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @window Common.UI.error
|
|
|
|
* @window Common.UI.info
|
|
|
|
* @window Common.UI.confirm
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (Common === undefined)
|
|
|
|
var Common = {};
|
|
|
|
|
|
|
|
define([
|
2020-05-21 16:30:57 +00:00
|
|
|
'common/main/lib/component/BaseView',
|
2020-09-25 11:44:15 +00:00
|
|
|
'common/main/lib/component/CheckBox',
|
2021-11-08 15:55:38 +00:00
|
|
|
'common/main/lib/controller/FocusManager'
|
2016-03-11 00:48:53 +00:00
|
|
|
], function () {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Common.UI.Window = Common.UI.BaseView.extend(_.extend((function(){
|
|
|
|
var config = {
|
|
|
|
closable: true,
|
|
|
|
header: true,
|
|
|
|
modal: true,
|
|
|
|
width: 'auto',
|
|
|
|
height: 'auto',
|
|
|
|
title: 'Title',
|
|
|
|
alias: 'Window',
|
|
|
|
cls: '',
|
2016-08-04 11:41:16 +00:00
|
|
|
toolclose: 'close',
|
2020-07-21 12:32:58 +00:00
|
|
|
help: false,
|
2016-08-04 11:41:16 +00:00
|
|
|
maxwidth: undefined,
|
|
|
|
maxheight: undefined,
|
|
|
|
minwidth: 0,
|
2016-08-23 14:27:32 +00:00
|
|
|
minheight: 0,
|
|
|
|
enableKeyEvents: true
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var template = '<div class="asc-window<%= modal?" modal":"" %><%= cls?" "+cls:"" %>" id="<%= id %>" style="width:<%= width %>px;">' +
|
|
|
|
'<% if (header==true) { %>' +
|
|
|
|
'<div class="header">' +
|
2020-07-21 12:32:58 +00:00
|
|
|
'<div class="tools">' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'<% if (closable!==false) %>' +
|
2020-12-30 10:37:44 +00:00
|
|
|
'<div class="tool close"></div>' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'<% %>' +
|
2020-07-21 12:32:58 +00:00
|
|
|
'<% if (help===true) %>' +
|
|
|
|
'<div class="tool help">?</div>' +
|
|
|
|
'<% %>' +
|
|
|
|
'</div>' +
|
2019-07-31 08:16:58 +00:00
|
|
|
'<div class="title"><%= title %></div> ' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'</div>' +
|
|
|
|
'<% } %>' +
|
2019-09-11 08:38:08 +00:00
|
|
|
'<div class="body"><%= tpl %>' +
|
|
|
|
'<% if (typeof (buttons) !== "undefined" && _.size(buttons) > 0) { %>' +
|
|
|
|
'<div class="footer">' +
|
|
|
|
'<% for(var bt in buttons) { %>' +
|
|
|
|
'<button class="btn normal dlg-btn <%= buttons[bt].cls %>" result="<%= bt %>"><%= buttons[bt].text %></button>'+
|
|
|
|
'<% } %>' +
|
|
|
|
'</div>' +
|
|
|
|
'<% } %>' +
|
|
|
|
'</div>' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'</div>';
|
|
|
|
|
|
|
|
function _getMask() {
|
|
|
|
var mask = $('.modals-mask');
|
|
|
|
|
|
|
|
if( mask.length == 0) {
|
|
|
|
mask = $("<div class='modals-mask'>")
|
|
|
|
.appendTo(document.body).hide();
|
|
|
|
mask.attr('counter', 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _keydown(event) {
|
2017-05-01 11:30:44 +00:00
|
|
|
if (!this.isLocked() && this.isVisible()
|
|
|
|
&& this.initConfig.enableKeyEvents && this.pauseKeyEvents !== false) {
|
2016-03-11 00:48:53 +00:00
|
|
|
switch (event.keyCode) {
|
|
|
|
case Common.UI.Keys.ESC:
|
|
|
|
if ( $('.asc-loadmask').length<1 ) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
if (this.initConfig.closable !== false) {
|
2018-02-06 10:54:40 +00:00
|
|
|
if (this.initConfig.toolcallback)
|
|
|
|
this.initConfig.toolcallback.call(this);
|
|
|
|
else
|
|
|
|
(this.initConfig.toolclose=='hide') ? this.hide() : this.close();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Common.UI.Keys.RETURN:
|
|
|
|
if (this.$window.find('.btn.primary').length && $('.asc-loadmask').length<1) {
|
|
|
|
if ((this.initConfig.onprimary || this.onPrimary).call(this)===false) {
|
|
|
|
event.preventDefault();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 14:03:04 +00:00
|
|
|
function _readDocumetGeometry() {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (window.innerHeight == undefined) {
|
2020-04-21 14:03:04 +00:00
|
|
|
var width = document.documentElement.offsetWidth,
|
|
|
|
height = document.documentElement.offsetHeight;
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
2020-04-21 14:03:04 +00:00
|
|
|
width = Common.Utils.innerWidth();
|
|
|
|
height = Common.Utils.innerHeight();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
2020-04-21 14:03:04 +00:00
|
|
|
height -= Common.Utils.InternalSettings.get('window-inactive-area-top');
|
|
|
|
return {width: width, height: height, top: Common.Utils.InternalSettings.get('window-inactive-area-top')};
|
|
|
|
}
|
|
|
|
|
2020-10-15 11:09:23 +00:00
|
|
|
function _autoSize() {
|
|
|
|
if (this.initConfig.height == 'auto') {
|
|
|
|
var height = parseInt(this.$window.find('> .body').css('height'));
|
|
|
|
this.initConfig.header && (height += parseInt(this.$window.find('> .header').css('height')));
|
|
|
|
this.$window.height(height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 14:03:04 +00:00
|
|
|
function _centre() {
|
|
|
|
var main_geometry = _readDocumetGeometry(),
|
|
|
|
main_width = main_geometry.width,
|
|
|
|
main_height = main_geometry.height;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (this.initConfig.height == 'auto') {
|
|
|
|
var win_height = parseInt(this.$window.find('.body').css('height'));
|
|
|
|
this.initConfig.header && (win_height += parseInt(this.$window.find('.header').css('height')));
|
2020-04-23 07:27:13 +00:00
|
|
|
} else {
|
2016-03-11 00:48:53 +00:00
|
|
|
win_height = this.initConfig.height;
|
2020-04-23 07:27:13 +00:00
|
|
|
win_height > main_height && (win_height = main_height);
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
var win_width = (this.initConfig.width=='auto') ? parseInt(this.$window.find('.body').css('width')) : this.initConfig.width;
|
|
|
|
|
2020-04-23 07:27:13 +00:00
|
|
|
var top = main_geometry.top + Math.floor((parseInt(main_height) - parseInt(win_height)) / 2);
|
2016-03-11 00:48:53 +00:00
|
|
|
var left = Math.floor((parseInt(main_width) - parseInt(win_width)) / 2);
|
|
|
|
|
|
|
|
this.$window.css('left',left);
|
|
|
|
this.$window.css('top',top);
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:27:20 +00:00
|
|
|
function _setVisible() {
|
2020-04-21 14:03:04 +00:00
|
|
|
var main_geometry = _readDocumetGeometry(),
|
|
|
|
main_width = main_geometry.width,
|
|
|
|
main_height = main_geometry.height;
|
2018-11-23 12:27:20 +00:00
|
|
|
|
|
|
|
if (this.getLeft() + this.getWidth() > main_width)
|
|
|
|
this.$window.css('left', main_width - this.getWidth());
|
2020-04-23 07:27:13 +00:00
|
|
|
|
|
|
|
if (this.getTop() < main_geometry.top )
|
|
|
|
this.$window.css('top', main_geometry.top);
|
|
|
|
else
|
|
|
|
if (this.getTop() + this.getHeight() > main_height) {
|
|
|
|
if (main_height - this.getHeight() < 0)
|
|
|
|
this.$window.css('top', main_geometry.top);
|
|
|
|
else this.$window.css('top', main_geometry.top + main_height - this.getHeight());
|
|
|
|
}
|
2018-11-23 12:27:20 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
function _getTransformation(end) {
|
|
|
|
return {
|
|
|
|
'-webkit-transition': '0.3s opacity',
|
|
|
|
'-moz-transition': '0.3s opacity',
|
|
|
|
'-ms-transition': '0.3s opacity',
|
|
|
|
'-o-transition': '0.3s opacity',
|
|
|
|
'opacity': end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* window drag's functions */
|
|
|
|
function _dragstart(event) {
|
2020-07-21 12:32:58 +00:00
|
|
|
if ( $(event.target).hasClass('close') || $(event.target).hasClass('help') ) return;
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.UI.Menu.Manager.hideAll();
|
2016-08-19 13:41:48 +00:00
|
|
|
var zoom = (event instanceof jQuery.Event) ? Common.Utils.zoom() : 1;
|
2016-03-11 00:48:53 +00:00
|
|
|
this.dragging.enabled = true;
|
2017-06-26 11:21:26 +00:00
|
|
|
this.dragging.initx = event.pageX*zoom - this.getLeft();
|
|
|
|
this.dragging.inity = event.pageY*zoom - this.getTop();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2020-04-21 14:03:04 +00:00
|
|
|
var main_geometry = _readDocumetGeometry(),
|
|
|
|
main_width = main_geometry.width,
|
|
|
|
main_height = main_geometry.height;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2017-06-26 11:21:26 +00:00
|
|
|
this.dragging.maxx = main_width - this.getWidth();
|
2020-04-23 07:27:13 +00:00
|
|
|
this.dragging.maxy = main_height - this.getHeight();
|
|
|
|
if (this.dragging.maxy < 0)
|
|
|
|
this.dragging.maxy = 0;
|
|
|
|
this.dragging.maxy += main_geometry.top;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
$(document).on('mousemove', this.binding.drag);
|
|
|
|
$(document).on('mouseup', this.binding.dragStop);
|
|
|
|
|
|
|
|
this.fireEvent('drag', [this, 'start']);
|
|
|
|
|
|
|
|
// event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true);
|
|
|
|
// event.preventDefault && event.preventDefault();
|
|
|
|
|
|
|
|
// return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _mouseup() {
|
|
|
|
$(document).off('mousemove', this.binding.drag);
|
|
|
|
$(document).off('mouseup', this.binding.dragStop);
|
|
|
|
|
|
|
|
this.dragging.enabled = false;
|
|
|
|
this.fireEvent('drag', [this, 'end']);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _mousemove(event) {
|
|
|
|
if (this.dragging.enabled) {
|
2016-08-19 13:41:48 +00:00
|
|
|
var zoom = (event instanceof jQuery.Event) ? Common.Utils.zoom() : 1,
|
|
|
|
left = event.pageX*zoom - this.dragging.initx,
|
2020-03-15 15:13:29 +00:00
|
|
|
top = event.pageY*zoom - this.dragging.inity,
|
|
|
|
topedge = Common.Utils.InternalSettings.get('window-inactive-area-top');
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
left < 0 ? (left = 0) : left > this.dragging.maxx && (left = this.dragging.maxx);
|
2020-03-15 15:13:29 +00:00
|
|
|
top < topedge ? (top = topedge) : top > this.dragging.maxy && (top = this.dragging.maxy);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
this.$window.css({left: left, top: top});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-07 14:10:25 +00:00
|
|
|
function _onProcessMouse(data) {
|
|
|
|
if (data.type == 'mouseup' && this.dragging.enabled) {
|
|
|
|
_mouseup.call(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-04 11:41:16 +00:00
|
|
|
/* window resize functions */
|
|
|
|
function _resizestart(event) {
|
|
|
|
Common.UI.Menu.Manager.hideAll();
|
|
|
|
var el = $(event.target),
|
2017-06-26 11:21:26 +00:00
|
|
|
left = this.getLeft(),
|
|
|
|
top = this.getTop();
|
2016-08-04 11:41:16 +00:00
|
|
|
|
|
|
|
this.resizing.enabled = true;
|
2016-08-19 13:41:48 +00:00
|
|
|
this.resizing.initpage_x = event.pageX*Common.Utils.zoom();
|
|
|
|
this.resizing.initpage_y = event.pageY*Common.Utils.zoom();
|
|
|
|
this.resizing.initx = this.resizing.initpage_x - left;
|
|
|
|
this.resizing.inity = this.resizing.initpage_y - top;
|
2017-06-26 11:21:26 +00:00
|
|
|
this.resizing.initw = this.getWidth();
|
|
|
|
this.resizing.inith = this.getHeight();
|
2016-08-04 11:41:16 +00:00
|
|
|
this.resizing.type = [el.hasClass('left') ? -1 : (el.hasClass('right') ? 1 : 0), el.hasClass('top') ? -1 : (el.hasClass('bottom') ? 1 : 0)];
|
|
|
|
|
2020-04-21 14:03:04 +00:00
|
|
|
var main_geometry = _readDocumetGeometry(),
|
|
|
|
main_width = main_geometry.width,
|
|
|
|
main_height = main_geometry.height;
|
|
|
|
var maxwidth = (this.initConfig.maxwidth) ? this.initConfig.maxwidth : main_width,
|
2016-08-04 13:02:39 +00:00
|
|
|
maxheight = (this.initConfig.maxheight) ? this.initConfig.maxheight : main_height;
|
2016-08-04 11:41:16 +00:00
|
|
|
|
2019-11-14 07:51:53 +00:00
|
|
|
this.resizing.minw = this.initConfig.minwidth;
|
|
|
|
this.resizing.maxw = (this.resizing.type[0]>0) ? Math.min(main_width-left, maxwidth) : Math.min(left+this.resizing.initw, maxwidth);
|
|
|
|
|
|
|
|
this.resizing.minh = this.initConfig.minheight;
|
|
|
|
this.resizing.maxh = (this.resizing.type[1]>0) ? Math.min(main_height-top, maxheight) : Math.min(top+this.resizing.inith, maxheight);
|
2016-08-04 11:41:16 +00:00
|
|
|
|
|
|
|
$(document.body).css('cursor', el.css('cursor'));
|
|
|
|
this.$window.find('.resize-border').addClass('resizing');
|
|
|
|
this.$window.find('.header').addClass('resizing');
|
|
|
|
|
|
|
|
$(document).on('mousemove', this.binding.resize);
|
|
|
|
$(document).on('mouseup', this.binding.resizeStop);
|
|
|
|
this.fireEvent('resize', [this, 'start']);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _resize(event) {
|
|
|
|
if (this.resizing.enabled) {
|
2016-08-19 13:41:48 +00:00
|
|
|
var resized = false,
|
|
|
|
zoom = (event instanceof jQuery.Event) ? Common.Utils.zoom() : 1,
|
|
|
|
pageX = event.pageX*zoom,
|
|
|
|
pageY = event.pageY*zoom;
|
2019-11-14 07:51:53 +00:00
|
|
|
if (this.resizing.type[0]) {
|
|
|
|
var new_width = this.resizing.initw + (pageX - this.resizing.initpage_x) * this.resizing.type[0];
|
|
|
|
if (new_width>this.resizing.maxw) {
|
|
|
|
pageX = pageX - (new_width-this.resizing.maxw) * this.resizing.type[0];
|
|
|
|
new_width = this.resizing.maxw;
|
|
|
|
} else if (new_width<this.resizing.minw) {
|
|
|
|
pageX = pageX - (new_width-this.resizing.minw) * this.resizing.type[0];
|
|
|
|
new_width = this.resizing.minw;
|
|
|
|
}
|
|
|
|
|
2016-08-04 11:41:16 +00:00
|
|
|
if (this.resizing.type[0]<0)
|
2016-08-19 13:41:48 +00:00
|
|
|
this.$window.css({left: pageX - this.resizing.initx});
|
2019-11-14 07:51:53 +00:00
|
|
|
this.setWidth(new_width);
|
2016-08-04 11:41:16 +00:00
|
|
|
resized = true;
|
|
|
|
}
|
2019-11-14 07:51:53 +00:00
|
|
|
if (this.resizing.type[1]) {
|
|
|
|
var new_height = this.resizing.inith + (pageY - this.resizing.initpage_y) * this.resizing.type[1];
|
|
|
|
if (new_height>this.resizing.maxh) {
|
|
|
|
pageY = pageY - (new_height-this.resizing.maxh) * this.resizing.type[1];
|
|
|
|
new_height = this.resizing.maxh;
|
|
|
|
} else if (new_height<this.resizing.minh) {
|
|
|
|
pageY = pageY - (new_height-this.resizing.minh) * this.resizing.type[1];
|
|
|
|
new_height = this.resizing.minh;
|
|
|
|
}
|
|
|
|
|
2016-08-04 11:41:16 +00:00
|
|
|
if (this.resizing.type[1]<0)
|
2016-08-19 13:41:48 +00:00
|
|
|
this.$window.css({top: pageY - this.resizing.inity});
|
2019-11-14 07:51:53 +00:00
|
|
|
this.setHeight(new_height);
|
2016-08-04 11:41:16 +00:00
|
|
|
resized = true;
|
|
|
|
}
|
|
|
|
if (resized) this.fireEvent('resizing');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _resizestop() {
|
|
|
|
$(document).off('mousemove', this.binding.resize);
|
|
|
|
$(document).off('mouseup', this.binding.resizeStop);
|
|
|
|
$(document.body).css('cursor', 'auto');
|
|
|
|
this.$window.find('.resize-border').removeClass('resizing');
|
|
|
|
this.$window.find('.header').removeClass('resizing');
|
|
|
|
|
|
|
|
this.resizing.enabled = false;
|
|
|
|
this.fireEvent('resize', [this, 'end']);
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.UI.alert = function(options) {
|
|
|
|
var me = this.Window.prototype;
|
|
|
|
|
|
|
|
if (!options.buttons) {
|
2019-09-11 08:38:08 +00:00
|
|
|
options.buttons = ['ok'];
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
options.dontshow = options.dontshow || false;
|
2016-08-29 11:45:09 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (!options.width) options.width = 'auto';
|
|
|
|
|
|
|
|
var template = '<div class="info-box">' +
|
2021-07-29 01:25:33 +00:00
|
|
|
'<% if (typeof iconCls !== "undefined") { %><div class="icon <%= iconCls %>"></div><% } %>' +
|
2017-02-07 08:55:24 +00:00
|
|
|
'<div class="text" <% if (typeof iconCls == "undefined") { %> style="padding-left:10px;" <% } %>><span><%= msg %></span>' +
|
2016-03-11 00:48:53 +00:00
|
|
|
'<% if (dontshow) { %><div class="dont-show-checkbox"></div><% } %>' +
|
|
|
|
'</div>' +
|
|
|
|
'</div>' +
|
2020-06-05 13:10:48 +00:00
|
|
|
'<% if (dontshow) { %><div class="separator horizontal" style="width: 100%;"></div><% } %>';
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-08-29 11:45:09 +00:00
|
|
|
_.extend(options, {
|
2016-03-11 00:48:53 +00:00
|
|
|
cls: 'alert',
|
|
|
|
onprimary: onKeyDown,
|
2017-04-21 08:10:07 +00:00
|
|
|
tpl: _.template(template)(options)
|
2016-08-29 11:45:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var win = new Common.UI.Window(options),
|
|
|
|
chDontShow = null;
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
function autoSize(window) {
|
|
|
|
var text_cnt = window.getChild('.info-box');
|
2021-04-02 17:03:13 +00:00
|
|
|
var text = window.getChild('.info-box .text > span');
|
2016-03-11 00:48:53 +00:00
|
|
|
var footer = window.getChild('.footer');
|
|
|
|
var header = window.getChild('.header');
|
|
|
|
var body = window.getChild('.body');
|
2017-04-17 12:06:39 +00:00
|
|
|
var icon = window.getChild('.icon'),
|
|
|
|
icon_height = (icon.length>0) ? icon.height() : 0;
|
2016-03-11 00:48:53 +00:00
|
|
|
var check = window.getChild('.info-box .dont-show-checkbox');
|
|
|
|
|
|
|
|
if (!options.dontshow) body.css('padding-bottom', '10px');
|
|
|
|
|
2016-08-09 09:25:34 +00:00
|
|
|
if (options.maxwidth && options.width=='auto') {
|
|
|
|
if ((text.position().left + text.width() + parseInt(text_cnt.css('padding-right'))) > options.maxwidth)
|
|
|
|
options.width = options.maxwidth;
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
if (options.width=='auto') {
|
2021-04-02 17:03:13 +00:00
|
|
|
text_cnt.height(Math.max(text.height(), icon_height) + ((check.length>0) ? (check.height() + parseInt(check.css('margin-top'))) : 0));
|
2016-03-11 00:48:53 +00:00
|
|
|
body.height(parseInt(text_cnt.css('height')) + parseInt(footer.css('height')));
|
|
|
|
window.setSize(text.position().left + text.width() + parseInt(text_cnt.css('padding-right')),
|
|
|
|
parseInt(body.css('height')) + parseInt(header.css('height')));
|
|
|
|
} else {
|
|
|
|
text.css('white-space', 'normal');
|
|
|
|
window.setWidth(options.width);
|
2021-04-02 17:03:13 +00:00
|
|
|
text_cnt.height(Math.max(text.height(), icon_height) + ((check.length>0) ? (check.height() + parseInt(check.css('margin-top'))) : 0));
|
2016-03-11 00:48:53 +00:00
|
|
|
body.height(parseInt(text_cnt.css('height')) + parseInt(footer.css('height')));
|
|
|
|
window.setHeight(parseInt(body.css('height')) + parseInt(header.css('height')));
|
|
|
|
}
|
2017-04-17 12:06:39 +00:00
|
|
|
if (text.height() < icon_height-10)
|
|
|
|
text.css({'vertical-align': 'baseline', 'line-height': icon_height+'px'});
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onBtnClick(event) {
|
|
|
|
if (options.callback) {
|
|
|
|
options.callback.call(win, event.currentTarget.attributes['result'].value, (chDontShow) ? (chDontShow.getValue() == 'checked') : false);
|
|
|
|
}
|
|
|
|
|
|
|
|
win.close(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onKeyDown(event) {
|
|
|
|
onBtnClick({currentTarget: win.getChild('.footer .dlg-btn')[0]});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
win.on({
|
|
|
|
'render:after': function(obj){
|
2019-09-11 08:38:08 +00:00
|
|
|
var footer = obj.getChild('.footer');
|
|
|
|
options.dontshow && footer.addClass('dontshow');
|
|
|
|
footer.find('.dlg-btn').on('click', onBtnClick);
|
2016-03-11 00:48:53 +00:00
|
|
|
chDontShow = new Common.UI.CheckBox({
|
|
|
|
el: win.$window.find('.dont-show-checkbox'),
|
2020-03-25 13:07:23 +00:00
|
|
|
labelText: options.textDontShow || win.textDontShow
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
autoSize(obj);
|
|
|
|
},
|
|
|
|
show: function(obj) {
|
|
|
|
obj.getChild('.footer .dlg-btn').focus();
|
|
|
|
},
|
|
|
|
close: function() {
|
|
|
|
options.callback && options.callback.call(win, 'close');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
win.show();
|
2020-03-25 13:07:23 +00:00
|
|
|
return win;
|
2016-03-11 00:48:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Common.UI.error = function(options) {
|
|
|
|
options = options || {};
|
|
|
|
!options.title && (options.title = this.Window.prototype.textError);
|
|
|
|
|
2020-03-25 13:07:23 +00:00
|
|
|
return Common.UI.alert(
|
2016-03-11 00:48:53 +00:00
|
|
|
_.extend(options, {
|
|
|
|
iconCls: 'error'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Common.UI.confirm = function(options) {
|
|
|
|
options = options || {};
|
|
|
|
!options.title && (options.title = this.Window.prototype.textConfirmation);
|
|
|
|
|
2020-03-25 13:07:23 +00:00
|
|
|
return Common.UI.alert(
|
2016-03-11 00:48:53 +00:00
|
|
|
_.extend(options, {
|
|
|
|
iconCls: 'confirm'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Common.UI.info = function(options) {
|
|
|
|
options = options || {};
|
|
|
|
!options.title && (options.title = this.Window.prototype.textInformation);
|
|
|
|
|
2020-03-25 13:07:23 +00:00
|
|
|
return Common.UI.alert(
|
2016-03-11 00:48:53 +00:00
|
|
|
_.extend(options, {
|
|
|
|
iconCls: 'info'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Common.UI.warning = function(options) {
|
|
|
|
options = options || {};
|
|
|
|
!options.title && (options.title = this.Window.prototype.textWarning);
|
|
|
|
|
2020-03-25 13:07:23 +00:00
|
|
|
return Common.UI.alert(
|
2016-03-11 00:48:53 +00:00
|
|
|
_.extend(options, {
|
|
|
|
iconCls: 'warn'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
$window : undefined,
|
|
|
|
$lastmodal : undefined,
|
|
|
|
dragging : {enabled: false},
|
2016-08-04 11:41:16 +00:00
|
|
|
resizing : {enabled: false},
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
initialize : function(options) {
|
|
|
|
this.initConfig = {};
|
|
|
|
this.binding = {};
|
|
|
|
|
2019-09-11 08:38:08 +00:00
|
|
|
var arrBtns = {ok: this.okButtonText, cancel: this.cancelButtonText,
|
|
|
|
yes: this.yesButtonText, no: this.noButtonText,
|
|
|
|
close: this.closeButtonText};
|
|
|
|
|
|
|
|
if (options.buttons && _.isArray(options.buttons)) {
|
|
|
|
if (options.primary==undefined)
|
|
|
|
options.primary = 'ok';
|
|
|
|
var newBtns = {};
|
|
|
|
_.each(options.buttons, function(b){
|
|
|
|
if (typeof(b) == 'object') {
|
|
|
|
if (b.value !== undefined)
|
|
|
|
newBtns[b.value] = {text: b.caption, cls: 'custom' + ((b.primary || options.primary==b.value) ? ' primary' : '')};
|
|
|
|
} else {
|
2020-11-11 20:55:11 +00:00
|
|
|
newBtns[b] = {text: (b=='custom') ? options.customButtonText : arrBtns[b], cls: (options.primary==b || _.indexOf(options.primary, b)>-1) ? 'primary' : ''};
|
2019-09-11 08:38:08 +00:00
|
|
|
if (b=='custom')
|
|
|
|
newBtns[b].cls += ' custom';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
options.buttons = newBtns;
|
|
|
|
options.footerCls = options.footerCls || 'center';
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
_.extend(this.initConfig, config, options || {});
|
|
|
|
|
|
|
|
!this.initConfig.id && (this.initConfig.id = 'window-' + this.cid);
|
|
|
|
!this.initConfig.tpl && (this.initConfig.tpl = '');
|
|
|
|
|
|
|
|
Common.UI.BaseView.prototype.initialize.call(this, this.initConfig);
|
|
|
|
},
|
|
|
|
|
2020-04-09 14:14:42 +00:00
|
|
|
render: function() {
|
2016-03-11 00:48:53 +00:00
|
|
|
var renderto = this.initConfig.renderTo || document.body;
|
|
|
|
$(renderto).append(
|
2017-04-21 08:10:07 +00:00
|
|
|
_.template(template)(this.initConfig)
|
2016-03-11 00:48:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
this.$window = $('#' + this.initConfig.id);
|
|
|
|
|
2021-05-12 09:33:10 +00:00
|
|
|
if (Common.Locale.getCurrentLanguage() && Common.Locale.getCurrentLanguage() !== 'en')
|
2019-12-10 14:22:28 +00:00
|
|
|
this.$window.attr('applang', Common.Locale.getCurrentLanguage());
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.binding.keydown = _.bind(_keydown,this);
|
|
|
|
// $(document).on('keydown', this.binding.keydown);
|
|
|
|
|
|
|
|
if ( this.initConfig.header ) {
|
|
|
|
this.binding.drag = _.bind(_mousemove, this);
|
|
|
|
this.binding.dragStop = _.bind(_mouseup, this);
|
|
|
|
this.binding.dragStart = _.bind(_dragstart, this);
|
|
|
|
|
|
|
|
var doclose = function() {
|
|
|
|
if ( this.$window.find('.tool.close').hasClass('disabled') ) return;
|
|
|
|
if (this.initConfig.toolcallback)
|
|
|
|
this.initConfig.toolcallback.call(this);
|
|
|
|
else
|
|
|
|
(this.initConfig.toolclose=='hide') ? this.hide() : this.close();
|
|
|
|
};
|
2020-07-21 12:32:58 +00:00
|
|
|
var dohelp = function() {
|
|
|
|
if ( this.$window.find('.tool.help').hasClass('disabled') ) return;
|
|
|
|
this.fireEvent('help',this);
|
|
|
|
};
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$window.find('.header').on('mousedown', this.binding.dragStart);
|
|
|
|
this.$window.find('.tool.close').on('click', _.bind(doclose, this));
|
2020-07-21 12:32:58 +00:00
|
|
|
this.$window.find('.tool.help').on('click', _.bind(dohelp, this));
|
2017-11-07 14:10:25 +00:00
|
|
|
|
|
|
|
if (!this.initConfig.modal)
|
|
|
|
Common.Gateway.on('processmouse', _.bind(_onProcessMouse, this));
|
2016-03-11 00:48:53 +00:00
|
|
|
} else {
|
|
|
|
this.$window.find('.body').css({
|
|
|
|
top:0,
|
|
|
|
'border-radius': '5px'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-15 11:09:23 +00:00
|
|
|
if (this.initConfig.height !== 'auto') {
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$window.css('height',this.initConfig.height);
|
|
|
|
}
|
|
|
|
|
2016-08-04 11:41:16 +00:00
|
|
|
if (this.initConfig.resizable)
|
|
|
|
this.setResizable(this.initConfig.resizable);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
var me = this;
|
2018-09-27 13:59:46 +00:00
|
|
|
this.binding.winclose = function(obj) {
|
|
|
|
if (me.$window && me.isVisible() && me.$window == obj.$window) me.close();
|
|
|
|
};
|
|
|
|
Common.NotificationCenter.on('window:close', this.binding.winclose);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2019-09-11 08:38:08 +00:00
|
|
|
this.initConfig.footerCls && this.$window.find('.footer').addClass(this.initConfig.footerCls);
|
|
|
|
|
2020-04-09 14:14:42 +00:00
|
|
|
this.menuAddAlign = function(menuRoot, left, top) {
|
|
|
|
var self = this;
|
|
|
|
if (!me.$window.hasClass('notransform')) {
|
|
|
|
me.$window.addClass('notransform');
|
|
|
|
menuRoot.addClass('hidden');
|
|
|
|
setTimeout(function() {
|
|
|
|
menuRoot.removeClass('hidden');
|
|
|
|
menuRoot.css({left: left, top: top});
|
|
|
|
self.options.additionalAlign = null;
|
|
|
|
}, 300);
|
|
|
|
} else {
|
|
|
|
menuRoot.css({left: left, top: top});
|
|
|
|
self.options.additionalAlign = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
this.fireEvent('render:after',this);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function(x,y) {
|
|
|
|
if (this.initConfig.modal) {
|
|
|
|
var mask = _getMask();
|
2019-05-28 13:08:51 +00:00
|
|
|
if (this.options.animate === false || this.options.animate && this.options.animate.mask === false) { // animate.mask = false -> don't animate mask
|
|
|
|
mask.attr('counter', parseInt(mask.attr('counter'))+1);
|
|
|
|
mask.show();
|
|
|
|
} else {
|
2020-12-30 10:37:44 +00:00
|
|
|
var maskOpacity = $(':root').css('--modal-window-mask-opacity');
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
mask.css('opacity', 0);
|
|
|
|
mask.attr('counter', parseInt(mask.attr('counter'))+1);
|
|
|
|
mask.show();
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2020-12-30 10:37:44 +00:00
|
|
|
mask.css(_getTransformation(maskOpacity));
|
2016-03-11 00:48:53 +00:00
|
|
|
}, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common.NotificationCenter.trigger('modal:show', this);
|
|
|
|
this.$lastmodal = $('.asc-window.modal:not(.dethrone):visible').first().addClass('dethrone');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.$window) {
|
|
|
|
this.render();
|
2020-10-15 11:09:23 +00:00
|
|
|
_autoSize.call(this);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (_.isNumber(x) && _.isNumber(y)) {
|
|
|
|
this.$window.css('left',Math.floor(x));
|
|
|
|
this.$window.css('top',Math.floor(y));
|
|
|
|
} else
|
|
|
|
_centre.call(this);
|
|
|
|
} else
|
|
|
|
if (!this.$window.is(':visible')) {
|
|
|
|
this.$window.css({opacity: 0});
|
2018-11-23 12:27:20 +00:00
|
|
|
_setVisible.call(this);
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$window.show()
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('keydown.' + this.cid, this.binding.keydown);
|
|
|
|
|
|
|
|
var me = this;
|
2016-11-07 08:45:15 +00:00
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
me.fireEvent('animate:before', me);
|
|
|
|
}, 10);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
if (this.options.animate !== false) {
|
|
|
|
this.$window.css({
|
|
|
|
'-webkit-transform': 'scale(0.8)',
|
|
|
|
'-moz-transform': 'scale(0.8)',
|
|
|
|
'-ms-transform': 'scale(0.8)',
|
|
|
|
'-o-transform': 'scale(0.8)',
|
|
|
|
opacity: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
me.$window.css({
|
|
|
|
'-webkit-transition': '0.2s opacity, 0.2s -webkit-transform',
|
|
|
|
'-webkit-transform': 'scale(1)',
|
|
|
|
'-moz-transition': '0.2s opacity, 0.2s -moz-transform',
|
|
|
|
'-moz-transform': 'scale(1)',
|
|
|
|
'-ms-transition': '0.2s opacity, 0.2s -ms-transform',
|
|
|
|
'-ms-transform': 'scale(1)',
|
|
|
|
'-o-transition': '0.2s opacity, 0.2s -o-transform',
|
|
|
|
'-o-transform': 'scale(1)',
|
|
|
|
'opacity': '1'
|
|
|
|
});
|
2021-04-29 12:41:04 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
me.fireEvent('animate:after', me);
|
|
|
|
}, 210);
|
2016-03-11 00:48:53 +00:00
|
|
|
}, 1);
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
me.$window.addClass('notransform');
|
|
|
|
me.fireEvent('show', me);
|
|
|
|
}, (this.initConfig.modal) ? 1000 : 350);
|
|
|
|
} else {
|
|
|
|
this.$window.css({opacity: 1});
|
|
|
|
this.$window.addClass('notransform');
|
|
|
|
this.fireEvent('show', this);
|
2021-04-29 12:41:04 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
me.fireEvent('animate:after', me);
|
|
|
|
}, 10);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 08:59:57 +00:00
|
|
|
Common.NotificationCenter.trigger('window:show', this);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
close: function(suppressevent) {
|
|
|
|
$(document).off('keydown.' + this.cid);
|
|
|
|
if ( this.initConfig.header ) {
|
|
|
|
this.$window.find('.header').off('mousedown', this.binding.dragStart);
|
|
|
|
}
|
2018-09-27 13:59:46 +00:00
|
|
|
Common.NotificationCenter.off({'window:close': this.binding.winclose});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (this.initConfig.modal) {
|
|
|
|
var mask = _getMask(),
|
|
|
|
hide_mask = true;
|
|
|
|
mask.attr('counter', parseInt(mask.attr('counter'))-1);
|
|
|
|
|
2017-04-21 08:20:40 +00:00
|
|
|
if (this.$lastmodal.length > 0) {
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$lastmodal.removeClass('dethrone');
|
|
|
|
hide_mask = !(this.$lastmodal.hasClass('modal') && this.$lastmodal.is(':visible'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( hide_mask ) {
|
|
|
|
if (this.options.animate !== false) {
|
2020-12-30 10:37:44 +00:00
|
|
|
var maskOpacity = $(':root').css('--modal-window-mask-opacity');
|
2016-03-11 00:48:53 +00:00
|
|
|
mask.css(_getTransformation(0));
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
if (parseInt(mask.attr('counter'))<1) {
|
2020-12-30 10:37:44 +00:00
|
|
|
mask.css('opacity', maskOpacity);
|
2016-03-11 00:48:53 +00:00
|
|
|
mask.hide();
|
|
|
|
mask.attr('counter', 0);
|
|
|
|
}
|
|
|
|
}, 300);
|
|
|
|
} else {
|
|
|
|
if (parseInt(mask.attr('counter'))<1) {
|
|
|
|
mask.hide();
|
|
|
|
mask.attr('counter', 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 14:13:07 +00:00
|
|
|
Common.NotificationCenter.trigger('modal:close', this, hide_mask && (parseInt(mask.attr('counter'))<1));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.$window.remove();
|
|
|
|
|
|
|
|
suppressevent!==true && this.fireEvent('close', this);
|
|
|
|
},
|
|
|
|
|
|
|
|
hide: function() {
|
|
|
|
$(document).off('keydown.' + this.cid);
|
|
|
|
if (this.$window) {
|
|
|
|
if (this.initConfig.modal) {
|
|
|
|
var mask = _getMask(),
|
|
|
|
hide_mask = true;
|
|
|
|
mask.attr('counter', parseInt(mask.attr('counter'))-1);
|
|
|
|
|
2017-04-21 08:20:40 +00:00
|
|
|
if (this.$lastmodal.length > 0) {
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$lastmodal.removeClass('dethrone');
|
|
|
|
hide_mask = !(this.$lastmodal.hasClass('modal') && this.$lastmodal.is(':visible'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( hide_mask ) {
|
|
|
|
if (this.options.animate !== false) {
|
2020-12-30 10:37:44 +00:00
|
|
|
var maskOpacity = $(':root').css('--modal-window-mask-opacity');
|
2016-03-11 00:48:53 +00:00
|
|
|
mask.css(_getTransformation(0));
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
if (parseInt(mask.attr('counter'))<1) {
|
2020-12-30 10:37:44 +00:00
|
|
|
mask.css('opacity', maskOpacity);
|
2016-03-11 00:48:53 +00:00
|
|
|
mask.hide();
|
|
|
|
mask.attr('counter', 0);
|
|
|
|
}
|
|
|
|
}, 300);
|
|
|
|
} else {
|
|
|
|
if (parseInt(mask.attr('counter'))<1) {
|
|
|
|
mask.hide();
|
|
|
|
mask.attr('counter', 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-31 14:13:07 +00:00
|
|
|
Common.NotificationCenter.trigger('modal:hide', this, hide_mask && (parseInt(mask.attr('counter'))<1));
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
this.$window.hide();
|
|
|
|
this.$window.removeClass('notransform');
|
|
|
|
this.fireEvent('hide', this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isLocked: function() {
|
|
|
|
return this.$window.hasClass('dethrone') ||
|
2018-02-28 14:45:00 +00:00
|
|
|
(!this.initConfig.modal && this.$window.parent().find('.asc-window.modal:visible').length);
|
2016-03-11 00:48:53 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getChild: function(selector) {
|
|
|
|
return selector ? this.$window.find(selector) : this.$window;
|
|
|
|
},
|
|
|
|
|
|
|
|
setWidth: function(width) {
|
|
|
|
if (width >= 0) {
|
|
|
|
var min = parseInt(this.$window.css('min-width'));
|
|
|
|
width < min && (width = min);
|
2016-08-04 11:41:16 +00:00
|
|
|
width -= (parseInt(this.$window.css('border-left-width')) + parseInt(this.$window.css('border-right-width')));
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$window.width(width);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getWidth: function() {
|
|
|
|
return parseInt(this.$window.css('width'));
|
|
|
|
},
|
|
|
|
|
|
|
|
setHeight: function(height) {
|
|
|
|
if (height >= 0) {
|
|
|
|
var min = parseInt(this.$window.css('min-height'));
|
|
|
|
height < min && (height = min);
|
2016-08-04 11:41:16 +00:00
|
|
|
height -= (parseInt(this.$window.css('border-bottom-width')) + parseInt(this.$window.css('border-top-width')));
|
2016-03-11 00:48:53 +00:00
|
|
|
this.$window.height(height);
|
|
|
|
|
|
|
|
if (this.initConfig.header)
|
|
|
|
height -= parseInt(this.$window.find('> .header').css('height'));
|
|
|
|
|
|
|
|
this.$window.find('> .body').css('height', height);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getHeight: function() {
|
|
|
|
return parseInt(this.$window.css('height'));
|
|
|
|
},
|
|
|
|
|
|
|
|
setSize: function(w, h) {
|
|
|
|
this.setWidth(w);
|
|
|
|
this.setHeight(h);
|
|
|
|
},
|
|
|
|
|
|
|
|
getSize: function() {
|
|
|
|
return [this.getWidth(), this.getHeight()];
|
|
|
|
},
|
|
|
|
|
|
|
|
setTitle: function(title) {
|
|
|
|
this.$window.find('> .header > .title').text(title);
|
|
|
|
},
|
|
|
|
|
|
|
|
getTitle: function() {
|
|
|
|
return this.$window.find('> .header > .title').text();
|
|
|
|
},
|
|
|
|
|
2017-06-26 11:21:26 +00:00
|
|
|
getLeft: function() {
|
|
|
|
return parseInt(this.$window.css('left'));
|
|
|
|
},
|
|
|
|
|
|
|
|
getTop: function() {
|
|
|
|
return parseInt(this.$window.css('top'));
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
isVisible: function() {
|
|
|
|
return this.$window && this.$window.is(':visible');
|
|
|
|
},
|
|
|
|
|
2016-08-04 13:02:39 +00:00
|
|
|
setResizable: function(resizable, minSize, maxSize) {
|
2016-08-04 11:41:16 +00:00
|
|
|
if (resizable !== this.resizable) {
|
|
|
|
if (resizable) {
|
2017-10-19 10:47:04 +00:00
|
|
|
var bordersTemplate = '<div class="resize-border left" style="top:' + ((this.initConfig.header) ? '33' : '5') + 'px; bottom: 5px; height: auto; border-right-style: solid; cursor: w-resize;"></div>' +
|
2016-08-04 11:41:16 +00:00
|
|
|
'<div class="resize-border left bottom" style="border-bottom-left-radius: 5px; cursor: sw-resize;"></div>' +
|
|
|
|
'<div class="resize-border bottom" style="left: 4px; right: 4px; width: auto; z-index: 2; border-top-style: solid; cursor: s-resize;"></div>' +
|
|
|
|
'<div class="resize-border right bottom" style="border-bottom-right-radius: 5px; cursor: se-resize;"></div>' +
|
2017-10-19 10:47:04 +00:00
|
|
|
'<div class="resize-border right" style="top:' + ((this.initConfig.header) ? '33' : '5') + 'px; bottom: 5px; height: auto; border-left-style: solid; cursor: e-resize;"></div>' +
|
2017-08-18 09:09:28 +00:00
|
|
|
'<div class="resize-border left top" style="border-top-left-radius: 5px; cursor: nw-resize;"></div>' +
|
2017-10-19 10:47:04 +00:00
|
|
|
'<div class="resize-border top" style="left: 4px; right: 4px; width: auto; z-index: 2; border-bottom-style:' + ((this.initConfig.header) ? "none" : "solid") + '; cursor: n-resize;"></div>' +
|
2017-08-18 09:09:28 +00:00
|
|
|
'<div class="resize-border right top" style="border-top-right-radius: 5px; cursor: ne-resize;"></div>';
|
2016-08-04 11:41:16 +00:00
|
|
|
if (this.initConfig.header)
|
2017-10-19 10:58:16 +00:00
|
|
|
bordersTemplate += '<div class="resize-border left" style="top: 5px; height: 28px; cursor: w-resize;"></div>' +
|
|
|
|
'<div class="resize-border right" style="top: 5px; height: 28px; cursor: e-resize;"></div>';
|
2016-08-04 11:41:16 +00:00
|
|
|
|
|
|
|
this.$window.append(_.template(bordersTemplate));
|
|
|
|
|
|
|
|
this.binding.resize = _.bind(_resize, this);
|
|
|
|
this.binding.resizeStop = _.bind(_resizestop, this);
|
|
|
|
this.binding.resizeStart = _.bind(_resizestart, this);
|
|
|
|
|
2016-08-04 13:02:39 +00:00
|
|
|
(minSize && minSize.length>1) && (this.initConfig.minwidth = minSize[0]);
|
|
|
|
(minSize && minSize.length>1) && (this.initConfig.minheight = minSize[1]);
|
|
|
|
(maxSize && maxSize.length>1) && (this.initConfig.maxwidth = maxSize[0]);
|
|
|
|
(maxSize && maxSize.length>1) && (this.initConfig.maxheight = maxSize[1]);
|
2016-08-04 11:41:16 +00:00
|
|
|
|
|
|
|
this.$window.find('.resize-border').on('mousedown', this.binding.resizeStart);
|
|
|
|
} else {
|
|
|
|
this.$window.find('.resize-border').remove();
|
|
|
|
}
|
|
|
|
this.resizable = resizable;
|
2020-06-08 17:09:33 +00:00
|
|
|
} else {
|
|
|
|
if (resizable) {
|
|
|
|
(minSize && minSize.length>1) && (this.initConfig.minwidth = minSize[0]);
|
|
|
|
(minSize && minSize.length>1) && (this.initConfig.minheight = minSize[1]);
|
|
|
|
(maxSize && maxSize.length>1) && (this.initConfig.maxwidth = maxSize[0]);
|
|
|
|
(maxSize && maxSize.length>1) && (this.initConfig.maxheight = maxSize[1]);
|
|
|
|
}
|
2016-08-04 11:41:16 +00:00
|
|
|
}
|
|
|
|
},
|
2017-05-01 11:30:44 +00:00
|
|
|
|
|
|
|
suspendKeyEvents: function () {
|
|
|
|
this.pauseKeyEvents = false;
|
|
|
|
},
|
2016-08-04 11:41:16 +00:00
|
|
|
|
2017-05-01 11:30:44 +00:00
|
|
|
resumeKeyEvents: function () {
|
|
|
|
this.initConfig.enableKeyEvents && (this.pauseKeyEvents = true);
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
onPrimary: function() {},
|
|
|
|
|
2020-10-09 08:59:57 +00:00
|
|
|
getFocusedComponents: function() {
|
|
|
|
return [];
|
|
|
|
},
|
|
|
|
|
2020-10-21 08:10:11 +00:00
|
|
|
getDefaultFocusableComponent: function() {
|
|
|
|
},
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
cancelButtonText: 'Cancel',
|
|
|
|
okButtonText: 'OK',
|
|
|
|
yesButtonText: 'Yes',
|
|
|
|
noButtonText: 'No',
|
|
|
|
closeButtonText: 'Close',
|
|
|
|
textWarning: 'Warning',
|
|
|
|
textError: 'Error',
|
|
|
|
textConfirmation: 'Confirmation',
|
|
|
|
textInformation: 'Information',
|
|
|
|
textDontShow: 'Don\'t show this message again'
|
|
|
|
};
|
|
|
|
|
|
|
|
})(), Common.UI.Window || {}));
|
|
|
|
});
|