/*
*
* (c) Copyright Ascensio System Limited 2010-2017
*
* 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
*
*/
/**
* FileMenuPanels.js
*
* Contains views for menu 'File'
*
* Created by Maxim Kadushkin on 20 February 2014
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/view/DocumentAccessDialog',
'common/main/lib/component/CheckBox'
], function () {
'use strict';
!PE.Views.FileMenuPanels && (PE.Views.FileMenuPanels = {});
PE.Views.FileMenuPanels.ViewSaveAs = Common.UI.BaseView.extend({
el: '#panel-saveas',
menu: undefined,
formats: [[
{name: 'PPTX', imgCls: 'pptx', type: Asc.c_oAscFileType.PPTX},
{name: 'PDF', imgCls: 'pdf', type: Asc.c_oAscFileType.PDF},
{name: 'ODP', imgCls: 'odp', type: Asc.c_oAscFileType.ODP}
]],
template: _.template([
'
',
'<% _.each(rows, function(row) { %>',
'
',
'<% _.each(row, function(item) { %>',
'
',
'<% }) %>',
'
',
'<% }) %>',
'
'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template({rows:this.formats}));
$('.btn-doc-format',this.el).on('click', _.bind(this.onFormatClick,this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
this.flatFormats = _.flatten(this.formats);
return this;
},
onFormatClick: function(e) {
var format = /\s(\w+)/.exec(e.currentTarget.className);
if (format) {
format = format[1];
var item = _.findWhere(this.flatFormats, {imgCls: format});
if (item && this.menu) {
this.menu.fireEvent('saveas:format', [this.menu, item.type]);
}
}
}
});
PE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: '#panel-settings',
menu: undefined,
template: _.template([
'
',
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
','
',
/** coauthoring begin **/
'
',
'
',
'
',
'
',
'
',
'
','
',
/** coauthoring end **/
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
','
',
'
',
'
',
'
',
'
',
'
'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template({scope: this}));
this.chSpell = new Common.UI.CheckBox({
el: $('#fms-chb-spell-check'),
labelText: this.strSpellCheckMode
});
this.chInputMode = new Common.UI.CheckBox({
el: $('#fms-chb-input-mode'),
labelText: this.strInputMode
});
this.cmbZoom = new Common.UI.ComboBox({
el : $('#fms-cmb-zoom'),
style : 'width: 160px;',
editable : false,
cls : 'input-group-nr',
menuStyle : 'max-height: 210px;',
data : [
{ value: -1, displayValue: this.txtFitSlide },
{ value: -2, displayValue: this.txtFitWidth },
{ value: 50, displayValue: "50%" },
{ value: 60, displayValue: "60%" },
{ value: 70, displayValue: "70%" },
{ value: 80, displayValue: "80%" },
{ value: 90, displayValue: "90%" },
{ value: 100, displayValue: "100%" },
{ value: 110, displayValue: "110%" },
{ value: 120, displayValue: "120%" },
{ value: 150, displayValue: "150%" },
{ value: 175, displayValue: "175%" },
{ value: 200, displayValue: "200%" }
]
});
/** coauthoring begin **/
this.cmbCoAuthMode = new Common.UI.ComboBox({
el : $('#fms-cmb-coauth-mode'),
style : 'width: 160px;',
editable : false,
cls : 'input-group-nr',
data : [
{ value: 1, displayValue: this.strFast, descValue: this.strCoAuthModeDescFast},
{ value: 0, displayValue: this.strStrict, descValue: this.strCoAuthModeDescStrict }
]
}).on('selected', _.bind(function(combo, record) {
if (record.value == 1 && (this.chAutosave.getValue()!=='checked'))
this.chAutosave.setValue(1);
this.lblCoAuthMode.text(record.descValue);
}, this));
this.lblCoAuthMode = $('#fms-lbl-coauth-mode');
/** coauthoring end **/
this.chAutosave = new Common.UI.CheckBox({
el: $('#fms-chb-autosave'),
labelText: this.strAutosave
}).on('change', _.bind(function(field, newValue, oldValue, eOpts){
if (field.getValue()!=='checked' && this.cmbCoAuthMode.getValue()) {
this.cmbCoAuthMode.setValue(0);
this.lblCoAuthMode.text(this.strCoAuthModeDescStrict);
}
}, this));
this.lblAutosave = $('#fms-lbl-autosave');
this.chForcesave = new Common.UI.CheckBox({
el: $('#fms-chb-forcesave'),
labelText: this.strForcesave
});
this.chAlignGuides = new Common.UI.CheckBox({
el: $('#fms-chb-align-guides'),
labelText: this.strAlignGuides
});
this.cmbUnit = new Common.UI.ComboBox({
el : $('#fms-cmb-unit'),
style : 'width: 160px;',
editable : false,
cls : 'input-group-nr',
data : [
{ value: Common.Utils.Metric.c_MetricUnits['cm'], displayValue: this.txtCm },
{ value: Common.Utils.Metric.c_MetricUnits['pt'], displayValue: this.txtPt },
{ value: Common.Utils.Metric.c_MetricUnits['inch'], displayValue: this.txtInch }
]
});
this.btnApply = new Common.UI.Button({
el: '#fms-btn-apply'
});
this.btnApply.on('click', _.bind(this.applySettings, this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.updateSettings();
},
setMode: function(mode) {
this.mode = mode;
$('tr.edit', this.el)[mode.isEdit?'show':'hide']();
$('tr.autosave', this.el)[mode.isEdit ? 'show' : 'hide']();
if (this.mode.isDesktopApp && this.mode.isOffline) {
this.chAutosave.setCaption(this.strAutoRecover);
this.lblAutosave.text(this.textAutoRecover);
}
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
/** coauthoring begin **/
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
/** coauthoring end **/
},
updateSettings: function() {
this.chSpell.setValue(Common.Utils.InternalSettings.get("pe-settings-spellcheck"));
this.chInputMode.setValue(Common.Utils.InternalSettings.get("pe-settings-inputmode"));
var value = Common.Utils.InternalSettings.get("pe-settings-zoom");
value = (value!==null) ? parseInt(value) : (this.mode.customization && this.mode.customization.zoom ? parseInt(this.mode.customization.zoom) : -1);
var item = this.cmbZoom.store.findWhere({value: value});
this.cmbZoom.setValue(item ? parseInt(item.get('value')) : (value>0 ? value+'%' : 100));
/** coauthoring begin **/
var fast_coauth = Common.Utils.InternalSettings.get("pe-settings-coauthmode");
item = this.cmbCoAuthMode.store.findWhere({value: fast_coauth ? 1 : 0});
this.cmbCoAuthMode.setValue(item ? item.get('value') : 1);
this.lblCoAuthMode.text(item ? item.get('descValue') : this.strCoAuthModeDescFast);
/** coauthoring end **/
value = Common.Utils.InternalSettings.get("pe-settings-unit");
item = this.cmbUnit.store.findWhere({value: value});
this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric());
this._oldUnits = this.cmbUnit.getValue();
value = Common.Utils.InternalSettings.get("pe-settings-autosave");
this.chAutosave.setValue(value == 1);
if (this.mode.canForcesave) {
this.chForcesave.setValue(Common.Utils.InternalSettings.get("pe-settings-forcesave"));
}
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("pe-settings-showsnaplines"));
},
applySettings: function() {
Common.localStorage.setItem("pe-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-zoom", this.cmbZoom.getValue());
Common.Utils.InternalSettings.set("pe-settings-zoom", Common.localStorage.getItem("pe-settings-zoom"));
/** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
Common.localStorage.setItem("pe-settings-coauthmode", this.cmbCoAuthMode.getValue());
}
/** coauthoring end **/
Common.localStorage.setItem("pe-settings-unit", this.cmbUnit.getValue());
Common.localStorage.setItem("pe-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.mode.canForcesave)
Common.localStorage.setItem("pe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
Common.Utils.InternalSettings.set("pe-settings-showsnaplines", this.chAlignGuides.isChecked());
Common.localStorage.save();
if (this.menu) {
this.menu.fireEvent('settings:apply', [this.menu]);
if (this._oldUnits !== this.cmbUnit.getValue())
Common.NotificationCenter.trigger('settings:unitschanged', this);
}
},
strInputMode: 'Turn on hieroglyphs',
strZoom: 'Default Zoom Value',
okButtonText: 'Apply',
txtFitSlide: 'Fit to Slide',
txtInput: 'Alternate Input',
strUnit: 'Unit of Measurement',
txtCm: 'Centimeter',
txtPt: 'Point',
textAutoSave: 'Autosave',
strAutosave: 'Turn on autosave',
/** coauthoring begin **/
strShowChanges: 'Realtime Collaboration Changes',
/** coauthoring end **/
txtAll: 'View All',
txtLast: 'View Last',
textAlignGuides: 'Alignment Guides',
strAlignGuides: 'Turn on alignment guides',
strCoAuthMode: 'Co-editing mode',
strCoAuthModeDescFast: 'Other users will see your changes at once',
strCoAuthModeDescStrict: 'You will need to accept changes before you can see them',
strFast: 'Fast',
strStrict: 'Strict',
textAutoRecover: 'Autorecover',
strAutoRecover: 'Turn on autorecover',
txtInch: 'Inch',
txtFitWidth: 'Fit to Width',
textForceSave: 'Save to Server',
strForcesave: 'Always save to server (otherwise save to server on document close)',
txtSpellCheck: 'Spell Checking',
strSpellCheckMode: 'Turn on spell checking option'
}, PE.Views.FileMenuPanels.Settings || {}));
PE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
el: '#panel-recentfiles',
menu: undefined,
template: _.template([
''
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.recent = options.recent;
},
render: function() {
$(this.el).html(this.template());
this.viewRecentPicker = new Common.UI.DataView({
el: $('#id-recent-view'),
store: new Common.UI.DataViewStore(this.recent),
itemTemplate: _.template([
'
'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template({
scope: this,
docs: this.options[0].docs
}));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
_onBlankDocument: function() {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, 'blank']);
},
_onDocumentTemplate: function(e) {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, e.currentTarget.attributes['template'].value]);
},
fromBlankText : 'From Blank',
newDocumentText : 'New Presentation',
newDescriptionText : 'Create a new blank presentation which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a document of a certain type or purpose where some styles have already been pre-applied.',
fromTemplateText : 'From Template',
noTemplatesText : 'There are no templates'
}, PE.Views.FileMenuPanels.CreateNew || {}));
PE.Views.FileMenuPanels.DocumentInfo = Common.UI.BaseView.extend(_.extend({
el: '#panel-info',
menu: undefined,
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.rendered = false;
this.template = _.template([
'