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
|
|
|
|
*
|
|
|
|
*/
|
2019-05-14 11:11:42 +00:00
|
|
|
DE.ApplicationController = new(function(){
|
2016-03-11 00:48:53 +00:00
|
|
|
var me,
|
|
|
|
api,
|
|
|
|
config = {},
|
|
|
|
docConfig = {},
|
|
|
|
embedConfig = {},
|
|
|
|
permissions = {},
|
|
|
|
maxPages = 0,
|
|
|
|
created = false,
|
2016-11-02 09:34:10 +00:00
|
|
|
ttOffset = [0, -10];
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
// Initialize analytics
|
|
|
|
// -------------------------
|
|
|
|
|
2019-02-22 12:28:39 +00:00
|
|
|
// Common.Analytics.initialize('UA-12442749-13', 'Embedded Document Editor');
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Check browser
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){
|
2019-05-14 11:11:42 +00:00
|
|
|
Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText);
|
2016-03-11 00:48:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handlers
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
function loadConfig(data) {
|
|
|
|
config = $.extend(config, data.config);
|
|
|
|
embedConfig = $.extend(embedConfig, data.config.embedded);
|
|
|
|
|
2016-11-02 10:28:44 +00:00
|
|
|
common.controller.modals.init(embedConfig);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
// Docked toolbar
|
2017-04-11 11:05:56 +00:00
|
|
|
if (embedConfig.toolbarDocked === 'bottom') {
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#toolbar').addClass('bottom');
|
|
|
|
$('#editor_sdk').addClass('bottom');
|
2016-11-02 10:35:55 +00:00
|
|
|
$('#box-tools').removeClass('dropdown').addClass('dropup');
|
|
|
|
ttOffset[1] = -40;
|
2017-04-11 11:05:56 +00:00
|
|
|
} else {
|
|
|
|
$('#toolbar').addClass('top');
|
|
|
|
$('#editor_sdk').addClass('top');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 10:32:43 +00:00
|
|
|
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && config.customization.goback.url)) {
|
|
|
|
$('#id-btn-close').hide();
|
|
|
|
|
|
|
|
// Hide last separator
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#toolbar .right .separator').hide();
|
|
|
|
$('#pages').css('margin-right', '12px');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadDocument(data) {
|
|
|
|
docConfig = data.doc;
|
|
|
|
|
|
|
|
if (docConfig) {
|
|
|
|
permissions = $.extend(permissions, docConfig.permissions);
|
|
|
|
|
2017-10-23 12:19:07 +00:00
|
|
|
var _permissions = $.extend({}, docConfig.permissions),
|
|
|
|
docInfo = new Asc.asc_CDocInfo();
|
2016-03-11 00:48:53 +00:00
|
|
|
docInfo.put_Id(docConfig.key);
|
|
|
|
docInfo.put_Url(docConfig.url);
|
|
|
|
docInfo.put_Title(docConfig.title);
|
|
|
|
docInfo.put_Format(docConfig.fileType);
|
|
|
|
docInfo.put_VKey(docConfig.vkey);
|
2016-11-24 13:44:54 +00:00
|
|
|
docInfo.put_Token(docConfig.token);
|
2017-10-23 12:19:07 +00:00
|
|
|
docInfo.put_Permissions(_permissions);
|
|
|
|
|
|
|
|
var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType);
|
|
|
|
if (type && typeof type[1] === 'string') {
|
|
|
|
permissions.edit = permissions.review = false;
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (api) {
|
|
|
|
api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions);
|
|
|
|
api.asc_setDocInfo(docInfo);
|
|
|
|
api.asc_getEditorPermissions(config.licenseUrl, config.customerId);
|
|
|
|
api.asc_enableKeyEvents(true);
|
|
|
|
|
|
|
|
Common.Analytics.trackEvent('Load', 'Start');
|
|
|
|
}
|
|
|
|
|
2016-11-18 15:00:46 +00:00
|
|
|
embedConfig.docTitle = docConfig.title;
|
2016-10-31 14:49:53 +00:00
|
|
|
if ( !embedConfig.saveUrl && permissions.print === false)
|
|
|
|
$('#idt-copy').hide();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCountPages(count) {
|
|
|
|
maxPages = count;
|
2019-05-14 11:11:42 +00:00
|
|
|
$('#pages').text(me.textOf + " " + count);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCurrentPage(number) {
|
|
|
|
$('#page-number').val(number + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLongActionBegin(type, id) {
|
|
|
|
var text = '';
|
|
|
|
switch (id)
|
|
|
|
{
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscAsyncAction['Print']:
|
2019-05-14 11:11:42 +00:00
|
|
|
text = me.downloadTextText;
|
2016-03-11 00:48:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
2019-05-14 11:11:42 +00:00
|
|
|
text = me.waitText;
|
2016-03-11 00:48:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-05 11:52:34 +00:00
|
|
|
if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) {
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#id-loadmask .cmd-loader-title').html(text);
|
|
|
|
showMask();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLongActionEnd(){
|
|
|
|
hideMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDocMouseMoveStart() {
|
|
|
|
me.isHideBodyTip = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDocMouseMoveEnd() {
|
|
|
|
if (me.isHideBodyTip) {
|
2016-10-31 14:49:53 +00:00
|
|
|
if ( $tooltip ) {
|
|
|
|
$tooltip.tooltip('hide');
|
|
|
|
$tooltip = false;
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
var $ttEl, $tooltip;
|
2016-03-11 00:48:53 +00:00
|
|
|
function onDocMouseMove(data) {
|
|
|
|
if (data) {
|
|
|
|
if (data.get_Type() == 1) { // hyperlink
|
|
|
|
me.isHideBodyTip = false;
|
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
if ( !$ttEl ) {
|
|
|
|
$ttEl = $('.hyperlink-tooltip');
|
|
|
|
$ttEl.tooltip({'container':'body', 'trigger':'manual'});
|
|
|
|
$ttEl.on('shown.bs.tooltip', function(e) {
|
|
|
|
$tooltip = $ttEl.data('bs.tooltip').tip();
|
|
|
|
|
|
|
|
$tooltip.css({
|
2016-11-02 10:32:43 +00:00
|
|
|
left: $ttEl.ttpos[0] + ttOffset[0],
|
|
|
|
top: $ttEl.ttpos[1] + ttOffset[1]
|
2016-10-31 14:49:53 +00:00
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
$tooltip.find('.tooltip-arrow').css({left: 10});
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
if ( !$tooltip ) {
|
|
|
|
$ttEl.ttpos = [data.get_X(), data.get_Y()];
|
|
|
|
$ttEl.tooltip('show');
|
|
|
|
} else {
|
|
|
|
$tooltip.css({
|
2016-11-02 10:32:43 +00:00
|
|
|
left:data.get_X() + ttOffset[0],
|
|
|
|
top:data.get_Y() + ttOffset[1]
|
2016-10-31 14:49:53 +00:00
|
|
|
});
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDownloadUrl(url) {
|
|
|
|
Common.Gateway.downloadAs(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrint() {
|
2016-11-02 10:32:43 +00:00
|
|
|
if ( permissions.print!==false )
|
2016-03-11 00:48:53 +00:00
|
|
|
api.asc_Print($.browser.chrome || $.browser.safari || $.browser.opera);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrintUrl(url) {
|
2016-11-02 09:34:10 +00:00
|
|
|
common.utils.dialogPrint(url);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hidePreloader() {
|
|
|
|
$('#loading-mask').fadeOut('slow');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDocumentContentReady() {
|
|
|
|
hidePreloader();
|
|
|
|
|
2018-04-04 09:19:20 +00:00
|
|
|
var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -2);
|
|
|
|
(zf == -1) ? api.zoomFitToPage() : ((zf == -2) ? api.zoomFitToWidth() : api.zoom(zf>0 ? zf : 100));
|
|
|
|
|
2016-11-02 10:32:43 +00:00
|
|
|
if ( !embedConfig.shareUrl )
|
|
|
|
$('#idt-share').hide();
|
|
|
|
|
|
|
|
if ( !embedConfig.embedUrl )
|
|
|
|
$('#idt-embed').hide();
|
|
|
|
|
|
|
|
if ( !embedConfig.fullscreenUrl )
|
2016-11-17 13:01:54 +00:00
|
|
|
$('#idt-fullscreen').hide();
|
2016-11-02 10:32:43 +00:00
|
|
|
|
2016-11-02 10:28:44 +00:00
|
|
|
common.controller.modals.attach({
|
|
|
|
share: '#idt-share',
|
|
|
|
embed: '#idt-embed'
|
|
|
|
});
|
2016-10-31 14:49:53 +00:00
|
|
|
|
|
|
|
api.asc_registerCallback('asc_onStartAction', onLongActionBegin);
|
|
|
|
api.asc_registerCallback('asc_onEndAction', onLongActionEnd);
|
|
|
|
api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart);
|
|
|
|
api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd);
|
|
|
|
api.asc_registerCallback('asc_onMouseMove', onDocMouseMove);
|
2016-11-02 09:34:10 +00:00
|
|
|
api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink);
|
2016-10-31 14:49:53 +00:00
|
|
|
api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl);
|
|
|
|
api.asc_registerCallback('asc_onPrint', onPrint);
|
2016-11-02 10:32:43 +00:00
|
|
|
api.asc_registerCallback('asc_onPrintUrl', onPrintUrl);
|
2016-10-31 14:49:53 +00:00
|
|
|
|
|
|
|
Common.Gateway.on('processmouse', onProcessMouse);
|
|
|
|
Common.Gateway.on('downloadas', onDownloadAs);
|
|
|
|
|
2019-05-14 11:11:42 +00:00
|
|
|
DE.ApplicationView.tools.get('#idt-fullscreen')
|
2016-10-31 14:49:53 +00:00
|
|
|
.on('click', function(){
|
2016-11-02 09:34:10 +00:00
|
|
|
common.utils.openLink(embedConfig.fullscreenUrl);
|
2016-10-31 14:49:53 +00:00
|
|
|
});
|
|
|
|
|
2019-05-14 11:11:42 +00:00
|
|
|
DE.ApplicationView.tools.get('#idt-download')
|
2016-10-31 14:49:53 +00:00
|
|
|
.on('click', function(){
|
|
|
|
if ( !!embedConfig.saveUrl ){
|
2016-11-02 09:34:10 +00:00
|
|
|
common.utils.openLink(embedConfig.saveUrl);
|
2016-10-31 14:49:53 +00:00
|
|
|
} else
|
|
|
|
if (api && permissions.print!==false){
|
|
|
|
api.asc_Print($.browser.chrome || $.browser.safari || $.browser.opera);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common.Analytics.trackEvent('Save');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id-btn-close').on('click', function(){
|
|
|
|
if (config.customization && config.customization.goback && config.customization.goback.url)
|
|
|
|
window.parent.location.href = config.customization.goback.url;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id-btn-zoom-in').on('click', api.zoomIn.bind(this));
|
|
|
|
$('#id-btn-zoom-out').on('click', api.zoomOut.bind(this));
|
|
|
|
|
|
|
|
var $pagenum = $('#page-number');
|
|
|
|
$pagenum.on({
|
|
|
|
'keyup': function(e){
|
|
|
|
if ( e.keyCode == 13 ){
|
|
|
|
var newPage = parseInt($('#page-number').val());
|
|
|
|
|
|
|
|
if ( newPage > maxPages ) newPage = maxPages;
|
|
|
|
if (newPage < 2 || isNaN(newPage)) newPage = 1;
|
|
|
|
|
|
|
|
api.goToPage(newPage-1);
|
|
|
|
$pagenum.blur();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
, 'focusin' : function(e) {
|
|
|
|
$pagenum.removeClass('masked');
|
|
|
|
}
|
|
|
|
, 'focusout': function(e){
|
|
|
|
!$pagenum.hasClass('masked') && $pagenum.addClass('masked');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#pages').on('click', function(e) {
|
|
|
|
$pagenum.focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
var documentMoveTimer;
|
|
|
|
var ismoved = false;
|
|
|
|
$(document).mousemove(function(event){
|
|
|
|
$('#id-btn-zoom-in').fadeIn();
|
|
|
|
$('#id-btn-zoom-out').fadeIn();
|
|
|
|
|
|
|
|
ismoved = true;
|
|
|
|
if ( !documentMoveTimer ) {
|
|
|
|
documentMoveTimer = setInterval(function(){
|
|
|
|
if ( !ismoved ) {
|
|
|
|
$('#id-btn-zoom-in').fadeOut();
|
|
|
|
$('#id-btn-zoom-out').fadeOut();
|
|
|
|
clearInterval(documentMoveTimer);
|
|
|
|
documentMoveTimer = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
ismoved = false;
|
|
|
|
}, 2000);
|
|
|
|
}
|
|
|
|
});
|
2019-01-10 08:20:53 +00:00
|
|
|
Common.Gateway.documentReady();
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.Analytics.trackEvent('Load', 'Complete');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onEditorPermissions(params) {
|
2017-06-16 07:52:31 +00:00
|
|
|
if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') &&
|
2016-03-11 00:48:53 +00:00
|
|
|
config.customization && config.customization.logo ) {
|
|
|
|
|
|
|
|
var logo = $('#header-logo');
|
|
|
|
if (config.customization.logo.imageEmbedded) {
|
|
|
|
logo.html('<img src="'+config.customization.logo.imageEmbedded+'" style="max-width:124px; max-height:20px;"/>');
|
|
|
|
logo.css({'background-image': 'none', width: 'auto', height: 'auto'});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.customization.logo.url) {
|
|
|
|
logo.attr('href', config.customization.logo.url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
api.asc_setViewMode(true);
|
|
|
|
api.asc_LoadDocument();
|
|
|
|
api.Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showMask() {
|
|
|
|
$('#id-loadmask').modal({
|
|
|
|
backdrop: 'static',
|
|
|
|
keyboard: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideMask() {
|
|
|
|
$('#id-loadmask').modal('hide');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onOpenDocument(progress) {
|
|
|
|
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
|
2019-05-14 12:18:18 +00:00
|
|
|
$('#loadmask-text').html(me.textLoadingDocument + ': ' + Math.min(Math.round(proc * 100), 100) + '%');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onError(id, level, errData) {
|
2018-10-08 11:21:05 +00:00
|
|
|
if (id == Asc.c_oAscError.ID.LoadingScriptError) {
|
|
|
|
$('#id-critical-error-title').text(me.criticalErrorTitle);
|
|
|
|
$('#id-critical-error-message').text(me.scriptLoadError);
|
2019-05-14 11:11:42 +00:00
|
|
|
$('#id-critical-error-close').text(me.txtClose).off().on('click', function(){
|
2018-10-08 11:21:05 +00:00
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
$('#id-critical-error-dialog').css('z-index', 20002).modal('show');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
hidePreloader();
|
|
|
|
|
|
|
|
var message;
|
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscError.ID.Unknown:
|
2016-03-11 00:48:53 +00:00
|
|
|
message = me.unknownErrorText;
|
|
|
|
break;
|
|
|
|
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscError.ID.ConvertationTimeout:
|
2016-03-11 00:48:53 +00:00
|
|
|
message = me.convertationTimeoutText;
|
|
|
|
break;
|
|
|
|
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscError.ID.ConvertationError:
|
2016-03-11 00:48:53 +00:00
|
|
|
message = me.convertationErrorText;
|
|
|
|
break;
|
|
|
|
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscError.ID.DownloadError:
|
2016-03-11 00:48:53 +00:00
|
|
|
message = me.downloadErrorText;
|
|
|
|
break;
|
|
|
|
|
2018-10-09 11:32:18 +00:00
|
|
|
case Asc.c_oAscError.ID.ConvertationPassword:
|
|
|
|
message = me.errorFilePassProtect;
|
|
|
|
break;
|
|
|
|
|
2019-03-29 09:21:43 +00:00
|
|
|
case Asc.c_oAscError.ID.UserDrop:
|
|
|
|
message = me.errorUserDrop;
|
|
|
|
break;
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
default:
|
|
|
|
message = me.errorDefaultMessage.replace('%1', id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-05 11:52:34 +00:00
|
|
|
if (level == Asc.c_oAscError.Level.Critical) {
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
// report only critical errors
|
|
|
|
Common.Gateway.reportError(id, message);
|
|
|
|
|
|
|
|
$('#id-critical-error-title').text(me.criticalErrorTitle);
|
|
|
|
$('#id-critical-error-message').text(message);
|
2019-05-14 11:11:42 +00:00
|
|
|
$('#id-critical-error-close').text(me.txtClose).off().on('click', function(){
|
2016-03-11 00:48:53 +00:00
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2017-10-07 09:20:39 +00:00
|
|
|
Common.Gateway.reportWarning(id, message);
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#id-critical-error-title').text(me.notcriticalErrorTitle);
|
|
|
|
$('#id-critical-error-message').text(message);
|
2019-05-14 11:11:42 +00:00
|
|
|
$('#id-critical-error-close').text(me.txtClose).off().on('click', function(){
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#id-critical-error-dialog').modal('hide');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#id-critical-error-dialog').modal('show');
|
|
|
|
|
|
|
|
Common.Analytics.trackEvent('Internal Error', id.toString());
|
|
|
|
}
|
|
|
|
|
2017-05-16 07:46:04 +00:00
|
|
|
function onExternalMessage(error) {
|
2016-03-11 00:48:53 +00:00
|
|
|
if (error) {
|
|
|
|
hidePreloader();
|
2019-05-14 11:11:42 +00:00
|
|
|
$('#id-error-mask-title').text(me.criticalErrorTitle);
|
2016-03-11 00:48:53 +00:00
|
|
|
$('#id-error-mask-text').text(error.msg);
|
|
|
|
$('#id-error-mask').css('display', 'block');
|
|
|
|
|
2017-05-16 07:46:04 +00:00
|
|
|
Common.Analytics.trackEvent('External Error');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onProcessMouse(data) {
|
|
|
|
if (data.type == 'mouseup') {
|
|
|
|
var e = document.getElementById('editor_sdk');
|
|
|
|
if (e) {
|
|
|
|
var r = e.getBoundingClientRect();
|
|
|
|
api.OnMouseUp(
|
|
|
|
data.x - r.left,
|
|
|
|
data.y - r.top
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDownloadAs() {
|
2019-01-10 14:20:59 +00:00
|
|
|
if ( permissions.download === false) {
|
|
|
|
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny);
|
|
|
|
return;
|
|
|
|
}
|
2016-04-05 11:52:34 +00:00
|
|
|
if (api) api.asc_DownloadAs(Asc.c_oAscFileType.DOCX, true);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
function onDocumentResize() {
|
2016-10-31 14:49:53 +00:00
|
|
|
api && api.Resize();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function createController(){
|
|
|
|
if (created)
|
|
|
|
return me;
|
|
|
|
|
|
|
|
me = this;
|
|
|
|
created = true;
|
|
|
|
|
|
|
|
$(window).resize(function(){
|
|
|
|
onDocumentResize();
|
|
|
|
});
|
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
var ismodalshown = false;
|
|
|
|
$(document.body).on('show.bs.modal', '.modal',
|
|
|
|
function(e) {
|
|
|
|
ismodalshown = true;
|
|
|
|
api.asc_enableKeyEvents(false);
|
|
|
|
}
|
|
|
|
).on('hidden.bs.modal', '.modal',
|
|
|
|
function(e) {
|
|
|
|
ismodalshown = false;
|
|
|
|
api.asc_enableKeyEvents(true);
|
|
|
|
}
|
|
|
|
).on('hidden.bs.dropdown', '.dropdown',
|
|
|
|
function(e) {
|
|
|
|
if ( !ismodalshown )
|
|
|
|
api.asc_enableKeyEvents(true);
|
|
|
|
}
|
|
|
|
).on('blur', 'input, textarea',
|
|
|
|
function(e) {
|
|
|
|
if ( !ismodalshown ) {
|
|
|
|
if (!/area_id/.test(e.target.id) ) {
|
|
|
|
api.asc_enableKeyEvents(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-10-31 14:49:53 +00:00
|
|
|
$('#editor_sdk').on('click', function(e) {
|
|
|
|
if ( e.target.localName == 'canvas' ) {
|
|
|
|
e.currentTarget.focus();
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
window["flat_desine"] = true;
|
2016-05-13 08:37:54 +00:00
|
|
|
api = new Asc.asc_docs_api({
|
|
|
|
'id-view' : 'editor_sdk'
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (api){
|
|
|
|
api.asc_registerCallback('asc_onError', onError);
|
|
|
|
api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady);
|
|
|
|
api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument);
|
2016-10-31 14:49:53 +00:00
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
api.asc_registerCallback('asc_onCountPages', onCountPages);
|
|
|
|
// api.asc_registerCallback('OnCurrentVisiblePage', onCurrentPage);
|
|
|
|
api.asc_registerCallback('asc_onCurrentPage', onCurrentPage);
|
|
|
|
|
|
|
|
// Initialize api gateway
|
|
|
|
Common.Gateway.on('init', loadConfig);
|
|
|
|
Common.Gateway.on('opendocument', loadDocument);
|
2017-05-16 07:46:04 +00:00
|
|
|
Common.Gateway.on('showmessage', onExternalMessage);
|
2017-09-20 11:32:18 +00:00
|
|
|
Common.Gateway.appReady();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
create : createController,
|
|
|
|
errorDefaultMessage : 'Error code: %1',
|
|
|
|
unknownErrorText : 'Unknown error.',
|
2019-05-14 13:55:52 +00:00
|
|
|
convertationTimeoutText : 'Conversion timeout exceeded.',
|
|
|
|
convertationErrorText : 'Conversion failed.',
|
2016-03-11 00:48:53 +00:00
|
|
|
downloadErrorText : 'Download failed.',
|
|
|
|
criticalErrorTitle : 'Error',
|
2018-10-08 11:21:05 +00:00
|
|
|
notcriticalErrorTitle : 'Warning',
|
2018-10-09 11:32:18 +00:00
|
|
|
scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.',
|
2019-01-10 14:20:59 +00:00
|
|
|
errorFilePassProtect: 'The file is password protected and cannot be opened.',
|
2019-03-29 09:21:43 +00:00
|
|
|
errorAccessDeny: 'You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.',
|
2019-05-14 11:11:42 +00:00
|
|
|
errorUserDrop: 'The file cannot be accessed right now.',
|
|
|
|
unsupportedBrowserErrorText: 'Your browser is not supported.',
|
|
|
|
textOf: 'of',
|
|
|
|
downloadTextText: 'Downloading document...',
|
|
|
|
waitText: 'Please, wait...',
|
|
|
|
textLoadingDocument: 'Loading document',
|
|
|
|
txtClose: 'Close'
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
})();
|