unlock edit-function

This commit is contained in:
OVSharova 2021-09-02 02:26:43 +03:00
parent a0280ed55b
commit 8c72339612
4 changed files with 18 additions and 278 deletions

View file

@ -129,8 +129,6 @@
<script type="text/javascript" src="../../unit-tests/common/main/lib/util/utils.js"></script>
<script type="text/javascript" src="../../unit-tests/common/main/lib/view/LoadMask.js"></script>
<script type="text/javascript" src="../../unit-tests/common/main/lib/view/modals.js"></script>
<script type="text/javascript" src="../../unit-tests/common/main/lib/controller/modals.js"></script>
<script type="text/javascript" src="js/ApplicationView.js"></script>
<script type="text/javascript" src="js/ApplicationController.js"></script>
<script type="text/javascript" src="js/application.js"></script>

View file

@ -42,7 +42,7 @@ DE.ApplicationController = new(function(){
ttOffset = [0, -10],
appOptions = {},
btnSubmit,
_submitFail, $submitedTooltip, $requiredTooltip,
_submitFail, $submitedTooltip,
$listControlMenu, listControlItems = [], listObj,
bodyWidth = 0;
@ -67,19 +67,11 @@ DE.ApplicationController = new(function(){
function loadConfig(data) {
config = $.extend(config, data.config);
embedConfig = $.extend(embedConfig, data.config.embedded);
common.controller.modals.init(embedConfig);
// Docked toolbar
if (embedConfig.toolbarDocked === 'bottom') {
$('#editor_sdk').addClass('bottom');
} else {
$('#editor_sdk').addClass('top');
}
config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback &&
(config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);
/*config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback &&
(config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);*/
}
function loadDocument(data) {
@ -115,10 +107,11 @@ DE.ApplicationController = new(function(){
docInfo.put_Permissions(_permissions);
docInfo.put_EncryptedInfo(config.encryptionKeys);
var enable = !config.customization || (config.customization.macros!==false);
/*var enable = !config.customization || (config.customization.macros!==false);
docInfo.asc_putIsEnabledMacroses(!!enable);
enable = !config.customization || (config.customization.plugins!==false);
docInfo.asc_putIsEnabledPlugins(!!enable);
docInfo.asc_putIsEnabledPlugins(!!enable);*/
var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType);
if (type && typeof type[1] === 'string') {
@ -137,11 +130,6 @@ DE.ApplicationController = new(function(){
function onCountPages(count) {
maxPages = count;
$('#pages').text(me.textOf + " " + count);
}
function onCurrentPage(number) {
//$('#page-number').val(number + 1);
}
function onLongActionBegin(type, id) {
@ -388,11 +376,11 @@ DE.ApplicationController = new(function(){
api.asc_registerCallback('asc_onPrint', onPrint);
api.asc_registerCallback('asc_onPrintUrl', onPrintUrl);
api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields);
if (appOptions.canFillForms) {
/*if (appOptions.canFillForms) {
api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions);
api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions);
api.asc_SetHighlightRequiredFields(true);
}
}*/
Common.Gateway.on('processmouse', onProcessMouse);
Common.Gateway.on('downloadas', onDownloadAs);
@ -439,17 +427,17 @@ DE.ApplicationController = new(function(){
var licType = params.asc_getLicenseType();
appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view');
//appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view');
appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm;
api.asc_setViewMode(!appOptions.canFillForms);
//api.asc_setViewMode(!appOptions.canFillForms);
//api.asc_setViewMode(false);
/*if (appOptions.canFillForms) {*/
if (appOptions.canFillForms) {
api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms);
api.asc_SetFastCollaborative(true);
//api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms);
//api.asc_SetFastCollaborative(true);
api.asc_setAutoSaveGap(1);
}
/*}*/
onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
api.asc_LoadDocument();
@ -468,7 +456,7 @@ DE.ApplicationController = new(function(){
$('#id-critical-error-close').text(me.txtClose).off().on('click', function(){
window.location.reload();
});
$('#id-critical-error-dialog').css('z-index', 20002).modal('show');
//$('#id-critical-error-dialog').css('z-index', 20002).modal('show');
return;
}
@ -660,7 +648,7 @@ DE.ApplicationController = new(function(){
window["flat_desine"] = true;
api = new Asc.asc_docs_api({
'id-view' : 'editor_sdk',
'embedded' : true
'embedded' : true/**/
});
if (api){
@ -669,8 +657,7 @@ DE.ApplicationController = new(function(){
api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument);
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);

View file

@ -1,143 +0,0 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
+function () {
!window.common && (window.common = {});
!common.controller && (common.controller = {});
common.controller.modals = new(function() {
var $dlgShare, $dlgEmbed;
var appConfig;
var embedCode = '<iframe allowtransparency="true" frameborder="0" scrolling="no" src="{embed-url}" width="{width}" height="{height}"></iframe>',
minEmbedWidth = 400,
minEmbedHeight = 600;
function copytext(el, event) {
el.select();
if ( !document.execCommand('copy') ) {
window.alert('Browser\'s error! Use keyboard shortcut [Ctrl] + [C]');
}
}
var createDlgShare = function () {
$dlgShare = common.view.modals.create('share');
var _encoded = encodeURIComponent(appConfig.shareUrl);
var _mailto = 'mailto:?subject=I have shared a document with you: ' + appConfig.docTitle + '&body=I have shared a document with you: ' + _encoded;
$dlgShare.find('#btn-copyshort').on('click', copytext.bind(this, $dlgShare.find('#id-short-url')));
$dlgShare.find('.share-buttons > span').on('click', function(e){
var _url;
switch ($(e.target).attr('data-name')) {
case 'facebook':
_url = 'https://www.facebook.com/sharer/sharer.php?u=' + appConfig.shareUrl + '&t=' + encodeURI(appConfig.docTitle);
window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
break;
case 'twitter':
_url = 'https://twitter.com/share?url='+ _encoded;
!!appConfig.docTitle && (_url += encodeURIComponent('&text=' + appConfig.docTitle));
window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
break;
case 'email':
window.open(_mailto, '_self');
break;
}
});
$dlgShare.find('#id-short-url').val(appConfig.shareUrl);
$dlgShare.find('.share-buttons > #email.autotest').attr('data-test', _mailto);
};
var createDlgEmbed =function () {
$dlgEmbed = common.view.modals.create('embed');
var txtembed = $dlgEmbed.find('#txt-embed-url');
txtembed.text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', minEmbedWidth).replace('{height}', minEmbedHeight));
$dlgEmbed.find('#btn-copyembed').on('click', copytext.bind(this, txtembed));
$dlgEmbed.find('#txt-embed-width, #txt-embed-height').on({
'keypress': function(e){
if (e.keyCode == 13)
updateEmbedCode();
}
, 'focusout': function(e){
updateEmbedCode();
}
});
};
function updateEmbedCode(){
var $txtwidth = $dlgEmbed.find('#txt-embed-width');
var $txtheight = $dlgEmbed.find('#txt-embed-height');
var newWidth = parseInt($txtwidth.val()),
newHeight = parseInt($txtheight.val());
if (newWidth < minEmbedWidth)
newWidth = minEmbedWidth;
if (newHeight < minEmbedHeight)
newHeight = minEmbedHeight;
$dlgEmbed.find('#txt-embed-url').text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', newWidth).replace('{height}', newHeight));
$txtwidth.val(newWidth + 'px');
$txtheight.val(newHeight + 'px');
}
var attachToView = function(config) {
if ( config.share && !!appConfig.shareUrl ) {
if ( !$dlgShare ) {
createDlgShare();
}
$(config.share).on('click', function(e){
$dlgShare.modal('show');
});
}
if ( config.embed && !!appConfig.embedUrl ) {
if ( !$dlgEmbed ) {
createDlgEmbed();
}
$(config.embed).on('click', function(e) {
$dlgEmbed.modal('show');
})
}
};
return {
init: function(config) { appConfig = config; }
, attach: attachToView
};
});
}();

View file

@ -1,102 +0,0 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
!window.common && (window.common = {});
!common.view && (common.view = {});
common.view.modals = new(function() {
var tplDialog = '<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="idm-title" aria-hidden="true">' +
'<div class="modal-dialog" role="document">' +
'<div class="modal-content">' +
'<div class="modal-header">' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
'<span aria-hidden="true">&times;</span>' +
'</button>' +
'<h4 id="idm-title" class="modal-title">{title}</h4>'+
'</div>'+
'<div class="modal-body">{body}</div>'+
'<div class="modal-footer">{footer}</div>'+
'</div>' +
'</div>' +
'</div>';
var _tplbody_share = '<div class="share-link">' +
'<input id="id-short-url" class="form-control" type="text" readonly/>' +
'</div>' +
'<div class="share-buttons">' +
'<span class="svg big-facebook" data-name="facebook"></span>' +
'<span class="svg big-twitter" data-name="twitter"></span>' +
'<span class="svg big-email" data-name="email"></span>' +
'<div class="autotest" id="email" style="display: none"></div>' +
'</div>';
var _tplbody_embed = '<div class="size-manual">' +
'<span class="caption">{width}:</span>' +
'<input id="txt-embed-width" class="form-control input-xs" type="text" value="400px">' +
'<input id="txt-embed-height" class="form-control input-xs right" type="text" value="600px">' +
'<span class="right caption">{height}:</span>' +
'</div>' +
'<textarea id="txt-embed-url" rows="4" class="form-control" readonly></textarea>';
return {
create: function(name, parent) {
!parent && (parent = 'body');
var _$dlg;
if (name == 'share') {
_$dlg = $(tplDialog
.replace(/\{title}/, this.txtShare)
.replace(/\{body}/, _tplbody_share)
.replace(/\{footer}/, '<button id="btn-copyshort" type="button" class="btn">' + this.txtCopy + '</button>'))
.appendTo(parent)
.attr('id', 'dlg-share');
} else
if (name == 'embed') {
_$dlg = $(tplDialog
.replace(/\{title}/, this.txtEmbed)
.replace(/\{body}/, _tplbody_embed)
.replace(/\{width}/, this.txtWidth)
.replace(/\{height}/, this.txtHeight)
.replace(/\{footer}/, '<button id="btn-copyembed" type="button" class="btn">' + this.txtCopy + '</button>'))
.appendTo(parent)
.attr('id', 'dlg-embed');
}
return _$dlg;
},
txtWidth: 'Width',
txtHeight: 'Height',
txtShare: 'Share Link',
txtCopy: 'Copy to clipboard',
txtEmbed: 'Embed'
};
})();