2016-04-01 13:17:09 +00:00
|
|
|
/*
|
|
|
|
*
|
2017-01-17 14:58:08 +00:00
|
|
|
* (c) Copyright Ascensio System Limited 2010-2017
|
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
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
|
|
|
* EU, LV-1021.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
var ApplicationController = new(function(){
|
|
|
|
var me,
|
|
|
|
api,
|
|
|
|
config = {},
|
|
|
|
docConfig = {},
|
|
|
|
embedConfig = {},
|
|
|
|
permissions = {},
|
|
|
|
maxPages = 0,
|
|
|
|
created = false,
|
|
|
|
iframePrint = null;
|
2016-11-02 10:44:35 +00:00
|
|
|
var $ttEl,
|
|
|
|
$tooltip,
|
|
|
|
ttOffset = [6, -15];
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
// Initialize analytics
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
// Common.Analytics.initialize('UA-12442749-13', 'Embedded ONLYOFFICE Spreadsheet');
|
|
|
|
|
|
|
|
|
|
|
|
// Check browser
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){
|
|
|
|
Common.Gateway.reportError(undefined, 'Your browser is not supported.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Handlers
|
|
|
|
// -------------------------
|
|
|
|
|
|
|
|
function loadConfig(data) {
|
|
|
|
config = $.extend(config, data.config);
|
|
|
|
embedConfig = $.extend(embedConfig, data.config.embedded);
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
common.controller.modals.init(embedConfig);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (config.canBackToFolder === false || !(config.customization && config.customization.goback && config.customization.goback.url))
|
|
|
|
$('#id-btn-close').hide();
|
|
|
|
|
|
|
|
// 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');
|
|
|
|
$('.viewer').addClass('bottom');
|
2016-11-02 10:44:35 +00:00
|
|
|
$('#box-tools').removeClass('dropdown').addClass('dropup');
|
|
|
|
ttOffset[1] = -40;
|
2017-04-11 11:05:56 +00:00
|
|
|
} else {
|
|
|
|
$('#toolbar').addClass('top');
|
|
|
|
$('.viewer').addClass('top');
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadDocument(data) {
|
|
|
|
docConfig = data.doc;
|
|
|
|
|
|
|
|
if (docConfig) {
|
|
|
|
permissions = $.extend(permissions, docConfig.permissions);
|
|
|
|
|
2016-04-18 12:21:15 +00:00
|
|
|
var 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);
|
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-11-02 10:44:35 +00:00
|
|
|
if ( !embedConfig.saveUrl && permissions.print === false)
|
|
|
|
$('#idt-copy').hide();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
function setActiveWorkSheet(index) {
|
|
|
|
var $box = $('#worksheets');
|
|
|
|
$box.find('> li').removeClass('active');
|
|
|
|
$box.find('#worksheet' + index).addClass('active');
|
|
|
|
|
|
|
|
api.asc_showWorksheet(index);
|
|
|
|
}
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
function onSheetsChanged(){
|
2016-11-02 10:44:35 +00:00
|
|
|
maxPages = api.asc_getWorksheetsCount();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
var handleWorksheet = function(e){
|
|
|
|
var $worksheet = $(this);
|
2016-11-02 10:44:35 +00:00
|
|
|
var index = $worksheet.attr('id').match(/\d+$/);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (index.length > 0) {
|
|
|
|
index = parseInt(index[0]);
|
|
|
|
|
|
|
|
if (index > -1 && index < maxPages)
|
|
|
|
setActiveWorkSheet(index);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
var $box = $('#worksheets');
|
|
|
|
$box.find('li').off();
|
|
|
|
$box.empty();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
var tpl = '<li id="worksheet{index}">{title}</li>';
|
|
|
|
for (var i = 0; i < maxPages; i++) {
|
|
|
|
var item = tpl.replace(/\{index}/, i).replace(/\{title}/,api.asc_getWorksheetName(i).replace(/\s/g,' '));
|
|
|
|
$(item).appendTo($box).on('click', handleWorksheet);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
setActiveWorkSheet(api.asc_getActiveWorksheetIndex());
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onDownloadUrl(url) {
|
|
|
|
Common.Gateway.downloadAs(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrint() {
|
2016-11-02 10:44:35 +00:00
|
|
|
if ( permissions.print!==false )
|
2016-03-11 00:48:53 +00:00
|
|
|
api.asc_Print(undefined, $.browser.chrome || $.browser.safari || $.browser.opera);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPrintUrl(url) {
|
2016-11-02 10:44:35 +00:00
|
|
|
common.utils.dialogPrint(url);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hidePreloader() {
|
|
|
|
$('#loading-mask').fadeOut('slow');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDocumentContentReady() {
|
|
|
|
hidePreloader();
|
|
|
|
|
2016-11-02 10:44:35 +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:44:35 +00:00
|
|
|
|
|
|
|
common.controller.modals.attach({
|
|
|
|
share: '#idt-share',
|
|
|
|
embed: '#idt-embed'
|
|
|
|
});
|
|
|
|
|
|
|
|
api.asc_registerCallback('asc_onMouseMove', onApiMouseMove);
|
|
|
|
api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink);
|
|
|
|
api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl);
|
|
|
|
api.asc_registerCallback('asc_onPrint', onPrint);
|
|
|
|
api.asc_registerCallback('asc_onPrintUrl', onPrintUrl);
|
|
|
|
|
|
|
|
Common.Gateway.on('processmouse', onProcessMouse);
|
|
|
|
Common.Gateway.on('downloadas', onDownloadAs);
|
|
|
|
|
|
|
|
ApplicationView.tools.get('#idt-fullscreen')
|
|
|
|
.on('click', function(){
|
|
|
|
common.utils.openLink(embedConfig.fullscreenUrl);
|
|
|
|
});
|
|
|
|
|
|
|
|
ApplicationView.tools.get('#idt-download')
|
|
|
|
.on('click', function(){
|
|
|
|
if ( !!embedConfig.saveUrl ){
|
|
|
|
common.utils.openLink(embedConfig.saveUrl);
|
|
|
|
} else
|
|
|
|
if (permissions.print!==false){
|
|
|
|
api.asc_Print(undefined, $.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', function () {
|
|
|
|
if (api){
|
|
|
|
var f = Math.floor(api.asc_getZoom() * 10)/10;
|
|
|
|
f += .1;
|
|
|
|
f > 0 && !(f > 2.) && api.asc_setZoom(f);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#id-btn-zoom-out').on('click', function () {
|
|
|
|
if (api){
|
|
|
|
var f = Math.ceil(api.asc_getZoom() * 10)/10;
|
|
|
|
f -= .1;
|
|
|
|
!(f < .5) && api.asc_setZoom(f);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$('#editor_sdk').on('click', function(e) {
|
|
|
|
if ( e.target.localName == 'canvas' ) {
|
|
|
|
e.currentTarget.focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-11-22 12:27:23 +00:00
|
|
|
$(document).on('mousewheel', function (e) {
|
|
|
|
if ((e.ctrlKey || e.metaKey) && !e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.Analytics.trackEvent('Load', 'Complete');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onEditorPermissions(params) {
|
|
|
|
if ( params.asc_getCanBranding() && (typeof config.customization == 'object') &&
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
$('#loadmask-text').html('Loading document: ' + Math.min(Math.round(proc * 100), 100) + '%');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLongActionBegin(type, id){
|
|
|
|
var text = '';
|
|
|
|
switch (id)
|
|
|
|
{
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscAsyncAction['Print']:
|
2016-03-11 00:48:53 +00:00
|
|
|
text = 'Downloading document...';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
text = 'Please wait...';
|
|
|
|
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(type, id){
|
2016-04-05 11:52:34 +00:00
|
|
|
if (type === Asc.c_oAscAsyncActionType.BlockInteraction) {
|
2016-03-11 00:48:53 +00:00
|
|
|
switch (id) {
|
2016-04-05 11:52:34 +00:00
|
|
|
case Asc.c_oAscAsyncAction.Open:
|
2016-03-11 00:48:53 +00:00
|
|
|
if (api) {
|
|
|
|
api.asc_Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
onDocumentContentReady();
|
|
|
|
onSheetsChanged();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hideMask();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onError(id, level, errData) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
$('#id-critical-error-close').off();
|
|
|
|
$('#id-critical-error-close').on('click', function(){
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#id-critical-error-title').text(me.notcriticalErrorTitle);
|
|
|
|
$('#id-critical-error-message').text(message);
|
|
|
|
$('#id-critical-error-close').off();
|
|
|
|
$('#id-critical-error-close').on('click', function(){
|
|
|
|
$('#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();
|
2017-05-16 07:46:04 +00:00
|
|
|
$('#id-error-mask-title').text('Error');
|
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 editor = document.getElementById('editor_sdk');
|
|
|
|
if (editor) {
|
|
|
|
var rect = editor.getBoundingClientRect();
|
|
|
|
var event = window.event || arguments.callee.caller.arguments[0];
|
|
|
|
api.asc_onMouseUp(event, data.x - rect.left, data.y - rect.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDownloadAs() {
|
2016-11-02 10:44:35 +00:00
|
|
|
api.asc_DownloadAs(Asc.c_oAscFileType.XLSX, true);
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
function onApiMouseMove(array) {
|
|
|
|
if ( array.length ) {
|
|
|
|
var ttdata;
|
|
|
|
for (var i = array.length; i > 0; i--) {
|
|
|
|
if (array[i-1].asc_getType() == Asc.c_oAscMouseMoveType.Hyperlink) {
|
|
|
|
ttdata = array[i - 1];
|
|
|
|
break;
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
if ( ttdata ) {
|
|
|
|
if (!$ttEl) {
|
|
|
|
$ttEl = $('.hyperlink-tooltip');
|
|
|
|
$ttEl.tooltip({'container': 'body', 'trigger': 'manual'});
|
|
|
|
$ttEl.on('shown.bs.tooltip', function(e) {
|
|
|
|
$tooltip = $ttEl.data('bs.tooltip').tip();
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
$tooltip.css({
|
|
|
|
left: $ttEl.ttpos[0] + ttOffset[0],
|
|
|
|
top: $ttEl.ttpos[1] + ttOffset[1]
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
$tooltip.find('.tooltip-arrow').css({left: 10});
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
if (!$tooltip) {
|
|
|
|
$ttEl.ttpos = [ttdata.asc_getX(), ttdata.asc_getY()];
|
|
|
|
$ttEl.tooltip('show');
|
|
|
|
} else {
|
|
|
|
$tooltip.css({
|
|
|
|
left: ttdata.asc_getX() + ttOffset[0],
|
|
|
|
top: ttdata.asc_getY() + ttOffset[1]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( $tooltip ) {
|
|
|
|
$tooltip.tooltip('hide');
|
|
|
|
$tooltip = false;
|
|
|
|
}
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
// Helpers
|
|
|
|
// -------------------------
|
2016-03-11 00:48:53 +00:00
|
|
|
|
2016-11-02 10:44:35 +00:00
|
|
|
function onDocumentResize() {
|
|
|
|
if (api) api.asc_Resize();
|
2016-03-11 00:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function createController(){
|
|
|
|
if (created)
|
|
|
|
return me;
|
|
|
|
|
|
|
|
me = this;
|
|
|
|
created = true;
|
|
|
|
|
|
|
|
// popover ui handlers
|
|
|
|
|
|
|
|
$(window).resize(function(){
|
|
|
|
onDocumentResize();
|
|
|
|
});
|
|
|
|
|
2016-05-13 08:37:54 +00:00
|
|
|
api = new Asc.spreadsheet_api({
|
|
|
|
'id-view': 'editor_sdk'
|
|
|
|
});
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
if (api){
|
|
|
|
api.asc_registerCallback('asc_onStartAction', onLongActionBegin);
|
|
|
|
api.asc_registerCallback('asc_onEndAction', onLongActionEnd);
|
|
|
|
api.asc_registerCallback('asc_onError', onError);
|
|
|
|
api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument);
|
|
|
|
api.asc_registerCallback('asc_onSheetsChanged', onSheetsChanged);
|
2016-11-02 10:44:35 +00:00
|
|
|
api.asc_registerCallback('asc_onActiveSheetChanged', setActiveWorkSheet);
|
2016-03-11 00:48:53 +00:00
|
|
|
|
|
|
|
// 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);
|
2016-03-11 00:48:53 +00:00
|
|
|
Common.Gateway.ready();
|
|
|
|
}
|
|
|
|
|
|
|
|
return me;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
create : createController,
|
|
|
|
errorDefaultMessage : 'Error code: %1',
|
|
|
|
unknownErrorText : 'Unknown error.',
|
|
|
|
convertationTimeoutText : 'Convertation timeout exceeded.',
|
|
|
|
convertationErrorText : 'Convertation failed.',
|
|
|
|
downloadErrorText : 'Download failed.',
|
|
|
|
criticalErrorTitle : 'Error',
|
|
|
|
notcriticalErrorTitle : 'Warning'
|
|
|
|
}
|
|
|
|
})();
|