3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -1,331 +1,643 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.AutoFilterDialog", {
extend: "Ext.window.Window",
alias: "widget.sseautofilterdialog",
requires: ["Ext.window.Window", "Common.plugin.GridScrollPane", "Common.component.SearchField"],
modal: true,
closable: true,
resizable: false,
height: 350,
width: 270,
constrain: true,
padding: "20px 20px 0 20px",
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var me = this;
this.addEvents("onmodalresult");
this.btnSortDesc = Ext.create("Ext.Button", {
iconCls: "asc-toolbar-btn btn-sort-up",
width: 28,
enableToggle: true,
toggleGroup: "autoFilterSort",
allowDepress: false,
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 3, "descending");
me.close();
}
}
});
this.btnSortAsc = Ext.create("Ext.Button", {
iconCls: "asc-toolbar-btn btn-sort-down",
width: 28,
enableToggle: true,
style: "margin: 0 6px 0 0",
toggleGroup: "autoFilterSort",
allowDepress: false,
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 3, "ascending");
me.close();
}
}
});
this.chCustomFilter = Ext.widget("checkbox", {
style: "margin: 0 6px 0 0",
disabled: true,
boxLabel: ""
});
var btnCustomFilter = Ext.create("Ext.Button", {
width: 120,
text: me.btnCustomFilter,
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 2);
me.close();
}
}
});
var range, full_range;
var txtSearch = Ext.create("Common.component.SearchField", {
style: "margin: 10px 0",
emptyText: me.txtEmpty,
listeners: {
change: function (obj, newval, oldval, opts) {
me.cellsStore.clearFilter(true);
if (oldval && newval.length < oldval.length) {
selectionModel.selected.clear();
full_range = me.cellsStore.getAt(0).ischecked;
range = me.cellsStore.getRange(full_range ? 0 : 1);
range.forEach(function (record) {
(full_range || record.ischecked) && selectionModel.selected.add(record);
});
}
if (newval.length) {
me.cellsStore.filter([{
property: "cellvalue",
value: new RegExp(newval, "i")
},
{
property: "rowvisible",
value: /^((?!ever|hidden).)*$/
}]);
} else {
me.cellsStore.filter("rowvisible", /^((?!hidden).)*$/);
}
},
searchstart: function (obj, text) {
me.cellsStore.filter([{
property: "cellvalue",
value: new RegExp(text, "i")
},
{
property: "rowvisible",
value: /^((?!ever|hidden).)*$/
}]);
this.stopSearch(true);
},
searchclear: function () {}
}
});
this.cellsStore = Ext.create("Ext.data.Store", {
fields: ["cellvalue", "rowvisible", "groupid", "intval", "strval"]
});
var selectionModel = Ext.create("Ext.selection.CheckboxModel", {
mode: "SIMPLE",
listeners: {
deselect: function (obj, record, index) {
me.chCustomFilter.getValue() && me.chCustomFilter.setValue(false);
record.ischecked = false;
if (record.data.rowvisible == "ever") {
obj.deselectAll();
me.cellsStore.getRange(1).forEach(function (rec) {
rec.ischecked = false;
});
} else {
var srecord = me.cellList.getStore().getAt(0);
if (srecord.data.rowvisible == "ever" && obj.isSelected(srecord)) {
srecord.ischecked = false;
obj.deselect(srecord, true);
}
}
},
select: function (obj, record, index) {
me.chCustomFilter.getValue() && me.chCustomFilter.setValue(false);
record.ischecked = true;
if (record.data.rowvisible == "ever") {
obj.select(me.cellList.getStore().getRange(1), false, true);
obj.select(me.cellList.getStore().getAt(0), true, true);
me.cellsStore.getRange(1).forEach(function (rec) {
rec.ischecked = true;
});
}
}
}
});
this.cellList = Ext.create("Ext.grid.Panel", {
activeItem: 0,
selModel: selectionModel,
store: this.cellsStore,
stateful: true,
stateId: "stateGrid",
scroll: false,
columns: [{
flex: 1,
sortable: false,
dataIndex: "cellvalue"
}],
height: 160,
hideHeaders: true,
style: "margin: 0 0 14px 0",
viewConfig: {
stripeRows: false
},
plugins: [{
ptype: "gridscrollpane"
}]
});
var btnOk = Ext.create("Ext.Button", {
text: Ext.Msg.buttonText.ok,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
if (!selectionModel.getCount()) {
Ext.Msg.show({
title: me.textWarning,
msg: me.warnNoSelected,
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OK
});
} else {
me.fireEvent("onmodalresult", me, me.chCustomFilter.getValue() ? 0 : 1);
me.close();
}
}
}
});
var btnCancel = Ext.create("Ext.Button", {
text: me.cancelButtonText,
width: 80,
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 0);
me.close();
}
}
});
this.items = [{
xtype: "container",
height: 30,
layout: {
type: "hbox"
},
items: [this.btnSortAsc, this.btnSortDesc, {
xtype: "tbspacer",
flex: 1
},
this.chCustomFilter, btnCustomFilter]
},
txtSearch, this.cellList, {
xtype: "container",
width: 250,
layout: "hbox",
layoutConfig: {
align: "stretch"
},
items: [{
xtype: "tbspacer",
flex: 1
},
btnOk, {
xtype: "tbspacer",
width: 5
},
btnCancel]
}];
this.callParent(arguments);
this.setTitle(this.txtTitle);
},
afterRender: function () {
this.callParent(arguments);
this._setDefaults();
},
setSettings: function (config) {
var arr = [{
cellvalue: this.textSelectAll,
rowvisible: "ever",
groupid: "0"
}];
var isnumber, value;
config.asc_getResult().forEach(function (item) {
value = item.asc_getVal();
isnumber = Ext.isNumeric(value);
arr.push({
cellvalue: value,
rowvisible: item.asc_getVisible(),
groupid: "1",
intval: isnumber ? parseFloat(value) : undefined,
strval: !isnumber ? value : ""
});
});
this.cellsStore.loadData(arr);
this.cellsStore.group("groupid");
this._defaults = [];
this._defaults.properties = config;
},
getSettings: function () {
var ret_out = new Asc.AutoFiltersOptions();
ret_out.asc_setCellId(this._defaults.properties.asc_getCellId());
var result_arr = [],
visibility,
me = this;
this.cellsStore.clearFilter(true);
var records = this.cellsStore.getRange(1);
records.forEach(function (item) {
if ((visibility = item.get("rowvisible")) != "hidden") {
visibility = me.cellList.getSelectionModel().isSelected(item);
}
result_arr.push(new Asc.AutoFiltersOptionsElements(item.get("cellvalue"), visibility));
});
ret_out.asc_setResult(result_arr);
ret_out.sortState = this._defaults.properties.asc_getSortState();
return ret_out;
},
_setDefaults: function () {
var sort = this._defaults.properties.asc_getSortState();
if (sort) {
this[sort == "ascending" ? "btnSortAsc" : "btnSortDesc"].toggle(true, true);
}
var store = this.cellList.getStore(),
selectionModel = this.cellList.getSelectionModel();
store.filter("rowvisible", /^((?!hidden).)*$/);
var count = store.getCount(),
item,
isSelectAll = true;
while (count > 1) {
item = store.getAt(--count);
if (item.data.rowvisible === true) {
selectionModel.select(item, true, true);
item.ischecked = true;
} else {
isSelectAll = false;
}
}
if (isSelectAll) {
store.getAt(0).ischecked = true;
selectionModel.select(0, true, true);
}
this.chCustomFilter.setValue(this._defaults.properties.asc_getIsCustomFilter() === true);
},
btnCustomFilter: "Custom Filter",
textSelectAll: "Select All",
txtTitle: "Filter",
warnNoSelected: "You must choose at least one value",
textWarning: "Warning",
cancelButtonText: "Cancel",
txtEmpty: "Enter cell's filter"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["common/main/lib/component/Window"], function () {
SSE.Views = SSE.Views || {};
SSE.Views.DigitalFilterDialog = Common.UI.Window.extend(_.extend({
initialize: function (options) {
var t = this,
_options = {};
_.extend(_options, {
width: 500,
height: 230,
contentWidth: 180,
header: true,
cls: "filter-dlg",
contentTemplate: "",
title: t.txtTitle,
items: []
},
options);
this.template = options.template || ['<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="content-panel" >', '<label class="header">', t.textShowRows, "</label>", '<div style="margin-top:15px;">', '<div id="id-search-begin-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>', '<div id="id-sd-cell-search-begin" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>', "</div>", "<div>", '<div id="id-and-radio" class="padding-small" style="display: inline-block; margin-top:10px;"></div>', '<div id="id-or-radio" class="padding-small" style="display: inline-block; margin-left:25px;"></div>', "</div>", '<div style="margin-top:10px;">', '<div id="id-search-end-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>', '<div id="id-sd-cell-search-end" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>', "</div>", "</div>", "</div>", '<div class="separator horizontal" style="width:100%"></div>', '<div class="footer right" style="margin-left:-15px;">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">', t.okButtonText, "</button>", '<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, "</button>", "</div>"].join("");
this.api = options.api;
this.handler = options.handler;
_options.tpl = _.template(this.template, _options);
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var conditions = [{
value: c_oAscCustomAutoFilter.equals,
displayValue: this.capCondition1
},
{
value: c_oAscCustomAutoFilter.doesNotEqual,
displayValue: this.capCondition2
},
{
value: c_oAscCustomAutoFilter.isGreaterThan,
displayValue: this.capCondition3
},
{
value: c_oAscCustomAutoFilter.isGreaterThanOrEqualTo,
displayValue: this.capCondition4
},
{
value: c_oAscCustomAutoFilter.isLessThan,
displayValue: this.capCondition5
},
{
value: c_oAscCustomAutoFilter.isLessThanOrEqualTo,
displayValue: this.capCondition6
},
{
value: c_oAscCustomAutoFilter.beginsWith,
displayValue: this.capCondition7
},
{
value: c_oAscCustomAutoFilter.doesNotBeginWith,
displayValue: this.capCondition8
},
{
value: c_oAscCustomAutoFilter.endsWith,
displayValue: this.capCondition9
},
{
value: c_oAscCustomAutoFilter.doesNotEndWith,
displayValue: this.capCondition10
},
{
value: c_oAscCustomAutoFilter.contains,
displayValue: this.capCondition11
},
{
value: c_oAscCustomAutoFilter.doesNotContain,
displayValue: this.capCondition12
}];
this.cmbCondition1 = new Common.UI.ComboBox({
el: $("#id-search-begin-digital-combo", this.$window),
menuStyle: "min-width: 225px;",
cls: "input-group-nr",
data: conditions,
editable: false
});
this.cmbCondition1.setValue(c_oAscCustomAutoFilter.equals);
conditions.splice(0, 0, {
value: 0,
displayValue: this.textNoFilter
});
this.cmbCondition2 = new Common.UI.ComboBox({
el: $("#id-search-end-digital-combo", this.$window),
menuStyle: "min-width: 225px;",
cls: "input-group-nr",
data: conditions,
editable: false
});
this.cmbCondition2.setValue(0);
this.rbAnd = new Common.UI.RadioBox({
el: $("#id-and-radio", this.$window),
labelText: this.capAnd,
name: "asc-radio-filter-tab",
checked: true
});
this.rbOr = new Common.UI.RadioBox({
el: $("#id-or-radio", this.$window),
labelText: this.capOr,
name: "asc-radio-filter-tab"
});
this.txtValue1 = new Common.UI.InputField({
el: $("#id-sd-cell-search-begin", this.$window),
template: _.template(['<div class="input-field" style="<%= style %>">', "<input ", 'type="<%= type %>" ', 'name="<%= name %>" ', 'class="form-control <%= cls %>" style="float:none" ', 'placeholder="<%= placeHolder %>" ', 'value="<%= value %>"', ">", "</div>"].join("")),
allowBlank: true,
validation: function () {
return true;
}
});
this.txtValue2 = new Common.UI.InputField({
el: $("#id-sd-cell-search-end", this.$window),
template: _.template(['<div class="input-field" style="<%= style %>">', "<input ", 'type="<%= type %>" ', 'name="<%= name %>" ', 'class="form-control <%= cls %>" style="float:none" ', 'placeholder="<%= placeHolder %>" ', 'value="<%= value %>"', ">", "</div>"].join("")),
allowBlank: true,
validation: function () {
return true;
}
});
this.$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
this.loadDefaults();
},
show: function () {
Common.UI.Window.prototype.show.call(this);
var me = this;
_.defer(function () {
if (me.txtValue1) {
me.txtValue1.focus();
}
},
500);
},
close: function () {
if (this.api) {
this.api.asc_enableKeyEvents(true);
}
Common.UI.Window.prototype.close.call(this);
},
onBtnClick: function (event) {
if (event.currentTarget.attributes && event.currentTarget.attributes.result) {
if ("ok" === event.currentTarget.attributes.result.value) {
this.save();
}
this.close();
}
},
setSettings: function (properties) {
this.properties = properties;
},
loadDefaults: function () {
if (this.properties && this.rbOr && this.rbAnd && this.cmbCondition1 && this.cmbCondition2 && this.txtValue1 && this.txtValue2) {
(this.properties.asc_getIsChecked()) ? this.rbOr.setValue(true) : this.rbAnd.setValue(true);
this.cmbCondition1.setValue(this.properties.asc_getFilter1() || c_oAscCustomAutoFilter.equals);
this.cmbCondition2.setValue(this.properties.asc_getFilter2() || 0);
this.txtValue1.setValue(null === this.properties.asc_getValFilter1() ? "" : this.properties.asc_getValFilter1());
this.txtValue2.setValue(null === this.properties.asc_getValFilter2() ? "" : this.properties.asc_getValFilter2());
}
},
save: function () {
if (this.api && this.properties && this.rbOr && this.rbAnd && this.cmbCondition1 && this.cmbCondition2 && this.txtValue1 && this.txtValue2) {
var options = new Asc.AutoFiltersOptions();
if (options) {
options.asc_setCellId(this.properties.asc_getCellId());
options.asc_setIsChecked(this.rbOr.getValue());
options.asc_setFilter1(this.cmbCondition1.getValue());
options.asc_setFilter2(this.cmbCondition2.getValue() || undefined);
options.asc_setValFilter1(this.txtValue1.getValue());
options.asc_setValFilter2(this.txtValue2.getValue());
this.api.asc_applyAutoFilter("digitalFilter", options);
}
}
},
onPrimary: function () {
this.save();
this.close();
return false;
},
cancelButtonText: "Cancel",
capAnd: "And",
capCondition1: "equals",
capCondition10: "does not end with",
capCondition11: "contains",
capCondition12: "does not contain",
capCondition2: "does not equal",
capCondition3: "is greater than",
capCondition4: "is greater than or equal to",
capCondition5: "is less than",
capCondition6: "is less than or equal to",
capCondition7: "begins with",
capCondition8: "does not begin with",
capCondition9: "ends with",
capOr: "Or",
textNoFilter: "no filter",
textShowRows: "Show rows where",
textUse1: "Use ? to present any single character",
textUse2 : "Use * to present any series of character",
txtTitle: "Custom Filter"
},
SSE.Views.DigitalFilterDialog || {}));
SSE.Views.AutoFilterDialog = Common.UI.Window.extend(_.extend({
initialize: function (options) {
var t = this,
_options = {};
_.extend(_options, {
width: 270,
height: 450,
contentWidth: 400,
header: true,
cls: "filter-dlg",
contentTemplate: "",
title: t.txtTitle,
items: []
},
options);
this.template = options.template || ['<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="content-panel">', '<div class="">', '<div id="id-btn-sort-down" class="btn-placeholder border"></div>', '<div id="id-btn-sort-up" class="btn-placeholder border"></div>', '<div id="id-checkbox-custom-filter" style="max-width:50px;margin-left:50px;display:inline-block;"></div>', '<button class="btn normal dlg-btn primary" result="custom" id="id-btn-custom-filter" style="min-width:120px;">', t.btnCustomFilter, "</button>", '<div id="id-sd-cell-search" class="input-row" style="margin-bottom:10px;"></div>', '<div class="border-values" style="margin-top:45px;">', '<div id="id-dlg-filter-values" class="combo-values"/>', "</div>", "</div>", "</div>", "</div>", '<div class="separator horizontal"></div>', '<div class="footer center">', '<div id="id-apply-filter" style="display: inline-block;"></div>', '<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, "</button>", "</div>"].join("");
this.api = options.api;
this.handler = options.handler;
this.throughIndexes = [];
_options.tpl = _.template(this.template, _options);
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
var me = this;
Common.UI.Window.prototype.render.call(this);
this.$window.find(".btn").on("click", _.bind(this.onBtnClick, this));
this.btnOk = new Common.UI.Button({
cls: "btn normal dlg-btn primary",
caption: this.okButtonText,
style: "margin-right:10px;",
enableToggle: false,
allowDepress: false
});
if (this.btnOk) {
this.btnOk.render($("#id-apply-filter", this.$window));
this.btnOk.on("click", _.bind(this.onApplyFilter, this));
}
this.btnSortDown = new Common.UI.Button({
cls: "btn-toolbar btn-toolbar-default border",
iconCls: "btn-icon btn-sort-down",
pressed: true,
enableToggle: true,
allowDepress: false
});
if (this.btnSortDown) {
this.btnSortDown.render($("#id-btn-sort-down", this.$window));
this.btnSortDown.on("click", _.bind(this.onSortType, this, "ascending"));
}
this.btnSortUp = new Common.UI.Button({
cls: "btn-toolbar btn-toolbar-default border",
iconCls: "btn-icon btn-sort-up",
pressed: true,
enableToggle: true,
allowDepress: false
});
if (this.btnSortUp) {
this.btnSortUp.render($("#id-btn-sort-up", this.$window));
this.btnSortUp.on("click", _.bind(this.onSortType, this, "descending"));
}
this.chCustomFilter = new Common.UI.CheckBox({
el: $("#id-checkbox-custom-filter", this.$window)
});
this.chCustomFilter.setDisabled(true);
this.btnCustomFilter = new Common.UI.Button({
el: $("#id-btn-custom-filter", this.$window)
}).on("click", _.bind(this.onShowCustomFilterDialog, this));
this.input = new Common.UI.InputField({
el: $("#id-sd-cell-search", this.$window),
allowBlank: true,
placeHolder: this.txtEmpty,
style: "margin-top: 10px;",
validateOnChange: true,
validation: function () {
return true;
}
}).on("changing", function (input, value) {
if (value.length) {
value = value.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
me.filter = new RegExp(value, "ig");
} else {
me.filter = undefined;
}
me.setupDataCells();
});
this.cells = new Common.UI.DataViewStore();
this.filterExcludeCells = new Common.UI.DataViewStore();
if (this.cells) {
this.cellsList = new Common.UI.ListView({
el: $("#id-dlg-filter-values", this.$window),
store: this.cells,
template: _.template(['<div class="listview inner" style="border:none;"></div>'].join("")),
itemTemplate: _.template(["<div>", '<label class="checkbox-indeterminate" style="position:absolute;">', "<% if (!check) { %>", '<input type="button"/>', "<% } else { %>", '<input type="button" class="checked"/>', "<% } %>", "</label>", '<div id="<%= id %>" class="list-item" style="pointer-events:none;margin-left:20px;display:inline-block;"><%= value %></div>', "</div>"].join(""))
});
this.cellsList.on("item:select", _.bind(this.onCellCheck, this));
this.cellsList.onKeyDown = _.bind(this.onListKeyDown, this);
}
this.setupListCells();
},
show: function () {
Common.UI.Window.prototype.show.call(this);
var me = this;
if (this.input) {
_.delay(function () {
me.input.$el.find("input").focus();
},
500, this);
}
},
onBtnClick: function (event) {
if (event.currentTarget.attributes && event.currentTarget.attributes.result) {
if ("cancel" === event.currentTarget.attributes.result.value) {
this.close();
}
}
},
onApplyFilter: function () {
if (this.testFilter()) {
this.save();
this.close();
}
},
onSortType: function (type) {
if (this.api && this.configTo) {
this.api.asc_sortColFilter(type, this.configTo.asc_getCellId());
}
this.close();
},
onShowCustomFilterDialog: function () {
var me = this,
dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({
api: this.api
}).on({
"close": function () {
me.close();
}
});
dlgDigitalFilter.setSettings(this.configTo);
dlgDigitalFilter.show();
this.close();
},
onCellCheck: function (listView, itemView, record) {
if (this.checkCellTrigerBlock) {
return;
}
var target = "",
type = "",
isLabel = false,
bound = null;
var event = window.event ? window.event : window._event;
if (event) {
type = event.target.type;
target = $(event.currentTarget).find(".list-item");
if (target.length) {
bound = target.get(0).getBoundingClientRect();
if (bound.left < event.clientX && event.clientX < bound.right && bound.top < event.clientY && event.clientY < bound.bottom) {
isLabel = true;
}
}
if (type === "button" || isLabel) {
this.updateCellCheck(listView, record);
_.delay(function () {
listView.$el.find(".listview").focus();
},
100, this);
}
}
},
onListKeyDown: function (e, data) {
var record = null,
listView = this.cellsList;
if (listView.disabled) {
return;
}
if (_.isUndefined(undefined)) {
data = e;
}
if (data.keyCode == Common.UI.Keys.SPACE) {
data.preventDefault();
data.stopPropagation();
this.updateCellCheck(listView, listView.getSelectedRec()[0]);
} else {
Common.UI.DataView.prototype.onKeyDown.call(this.cellsList, e, data);
}
},
updateCellCheck: function (listView, record) {
if (record && listView) {
listView.isSuspendEvents = true;
if ("1" !== record.get("groupid")) {
var check = !record.get("check");
this.cells.each(function (cell) {
cell.set("check", check);
});
} else {
record.set("check", !record.get("check"));
}
this.chCustomFilter.setValue(false);
this.btnOk.setDisabled(false);
listView.isSuspendEvents = false;
listView.scroller.update({
minScrollbarLength: 40,
alwaysVisibleY: true
});
}
},
setSettings: function (config) {
this.config = config;
this.configTo = config;
},
setupListCells: function () {
function isNumeric(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
var me = this,
isnumber, value, index = 0,
haveUnselectedCell = false,
throughIndex = 1,
isCustomFilter = (this.configTo.asc_getIsCustomFilter() === true);
if (_.isUndefined(this.config)) {
return;
}
this.cells.reset();
this.filterExcludeCells.reset();
me.cells.push(new Common.UI.DataViewModel({
id: ++index,
selected: false,
allowSelected: true,
value: this.textSelectAll,
groupid: "0",
check: true,
throughIndex: 0
}));
this.throughIndexes.push(true);
this.config.asc_getResult().forEach(function (item) {
value = item.asc_getVal();
isnumber = isNumeric(value);
if ("hidden" !== item.asc_getVisible()) {
me.cells.push(new Common.UI.DataViewModel({
id: ++index,
selected: false,
allowSelected: true,
cellvalue: value,
value: isnumber ? value : (value.length > 0 ? value : me.textEmptyItem),
rowvisible: item.asc_getVisible(),
intval: isnumber ? parseFloat(value) : undefined,
strval: !isnumber ? value : "",
groupid: "1",
check: item.asc_getVisible(),
throughIndex: throughIndex
}));
if (!item.asc_getVisible()) {
haveUnselectedCell = true;
}
me.throughIndexes.push(item.asc_getVisible());
++throughIndex;
}
});
this.checkCellTrigerBlock = true;
this.cells.at(0).set("check", !haveUnselectedCell);
this.checkCellTrigerBlock = undefined;
this.btnSortDown.toggle(false, false);
this.btnSortUp.toggle(false, false);
var sort = this.config.asc_getSortState();
if (sort) {
if ("ascending" === sort) {
this.btnSortDown.toggle(true, false);
} else {
this.btnSortUp.toggle(true, false);
}
}
this.chCustomFilter.setValue(isCustomFilter);
this.btnOk.setDisabled(isCustomFilter);
this.cellsList.scroller.update({
minScrollbarLength: 40,
alwaysVisibleY: true
});
this.config = undefined;
},
setupDataCells: function () {
function isNumeric(value) {
return !isNaN(parseFloat(value)) && isFinite(value);
}
var me = this,
isnumber, value, index = 0,
applyfilter = true,
throughIndex = 1;
this.cells.forEach(function (item) {
value = item.get("check");
if (_.isUndefined(value)) {
value = false;
}
me.throughIndexes[parseInt(item.get("throughIndex"))] = item.get("check");
});
this.cells.reset();
this.filterExcludeCells.reset();
if (!me.filter) {
me.cells.push(new Common.UI.DataViewModel({
id: ++index,
selected: false,
allowSelected: true,
value: this.textSelectAll,
groupid: "0",
check: me.throughIndexes[0],
throughIndex: 0
}));
}
this.configTo.asc_getResult().forEach(function (item) {
value = item.asc_getVal();
isnumber = isNumeric(value);
applyfilter = true;
if (me.filter) {
if (null === value.match(me.filter)) {
applyfilter = false;
}
}
if ("hidden" !== item.asc_getVisible()) {
if (applyfilter) {
me.cells.push(new Common.UI.DataViewModel({
id: ++index,
selected: false,
allowSelected: true,
cellvalue: value,
value: isnumber ? value : (value.length > 0 ? value : me.textEmptyItem),
rowvisible: item.asc_getVisible(),
intval: isnumber ? parseFloat(value) : undefined,
strval: !isnumber ? value : "",
groupid: "1",
check: me.throughIndexes[throughIndex],
throughIndex: throughIndex
}));
} else {
me.filterExcludeCells.push(new Common.UI.DataViewModel({
cellvalue: value
}));
}++throughIndex;
}
});
if (this.cells.length) {
this.chCustomFilter.setValue(this.configTo.asc_getIsCustomFilter() === true);
}
this.cellsList.scroller.update({
minScrollbarLength: 40,
alwaysVisibleY: true
});
},
testFilter: function () {
var me = this,
isValid = false;
if (this.cells) {
this.cells.forEach(function (item) {
if ("1" === item.get("groupid")) {
if (item.get("check")) {
isValid = true;
}
}
});
}
if (!isValid) {
Common.UI.warning({
title: this.textWarning,
msg: this.warnNoSelected,
callback: function () {
_.delay(function () {
me.input.$el.find("input").focus();
},
100, this);
}
});
}
return isValid;
},
save: function () {
if (this.api && this.configTo && this.cells && this.filterExcludeCells) {
var options = new Asc.AutoFiltersOptions();
if (options) {
options.asc_setCellId(this.configTo.asc_getCellId());
var me = this,
result_arr = [],
visibility;
this.cells.forEach(function (item) {
if ("1" === item.get("groupid")) {
if ((visibility = item.get("rowvisible")) !== "hidden") {
visibility = item.get("check");
result_arr.push(new Asc.AutoFiltersOptionsElements(item.get("cellvalue"), visibility));
}
}
});
this.filterExcludeCells.forEach(function (item) {
result_arr.push(new Asc.AutoFiltersOptionsElements(item.get("cellvalue"), false));
});
options.asc_setResult(result_arr);
options.sortState = this.configTo.asc_getSortState();
this.api.asc_applyAutoFilter("mainFilter", options);
}
}
},
onPrimary: function () {
this.save();
this.close();
return false;
},
okButtonText: "Ok",
btnCustomFilter: "Custom Filter",
textSelectAll: "Select All",
txtTitle: "Filter",
warnNoSelected: "You must choose at least one value",
textWarning: "Warning",
cancelButtonText: "Cancel",
textEmptyItem: "{Blanks}",
txtEmpty: "Enter cell's filter"
},
SSE.Views.AutoFilterDialog || {}));
});

View File

@@ -0,0 +1,58 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/CellEditor.template", "common/main/lib/component/BaseView"], function (template) {
SSE.Views.CellEditor = Common.UI.BaseView.extend({
template: _.template(template),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
},
render: function () {
$(this.el).html(this.template());
this.$cellname = $("#ce-cell-name", this.el);
this.$btnexpand = $("#ce-btn-expand", this.el);
this.$btnfunc = $("#ce-func-label", this.el);
this.$btnfunc.addClass("disabled");
this.$btnfunc.tooltip({
title: this.tipFormula,
placement: "cursor"
});
return this;
},
updateCellInfo: function (info) {
if (info) {
this.$cellname.val(typeof(info) == "string" ? info : info.asc_getName());
}
},
tipFormula: "Insert Function"
},
SSE.Views.CellEditor || {});
});

View File

@@ -1,141 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.CellInfo", {
extend: "Ext.container.Container",
alias: "widget.ssecellinfo",
cls: "sse-cellinfo",
uses: ["SSE.view.FormulaDialog"],
height: 23,
initComponent: function () {
var me = this;
this.addEvents("editcomplete");
this.txtName = Ext.widget("textfield", {
id: "infobox-cell-name",
width: 70,
height: this.height,
cls: "asc-input-aslabel",
fieldStyle: "border-radius:0;"
});
this._cellInput = Ext.widget("textarea", {
id: "infobox-cell-edit",
inputId: "infobox-cell-input",
flex: 1,
style: "margin:0;opacity:1;",
fieldStyle: "border-radius:0;font-size:14px;padding:0 3px;line-height:21px;",
enableKeyEvents: true,
enterIsSpecial: true
});
var style = "padding:4px 0 0 4px;border-bottom:solid 1px #AFAFAF; background:#E9E9E9 url(resources/img/toolbar-menu.png) no-repeat 0 -1416px;";
style += 'background-image: -webkit-image-set(url("resources/img/toolbar-menu.png") 1x, url("resources/img/toolbar-menu@2x.png") 2x);';
this._lblFunct = Ext.widget("box", {
width: 20,
height: this.height,
id: "func-label-box",
style: style,
listeners: {
afterrender: function (c) {
$("#func-label-box").hover(function () {
this.style.backgroundPosition = this.mdown ? "-40px -1416px" : "-20px -1416px";
},
function () {
this.style.backgroundPosition = "0 -1416px";
});
$("#func-label-box").mousedown(function () {
this.style.backgroundPosition = "-40px -1416px";
var hdown = this;
hdown.mdown = true;
var upHandler = function () {
hdown.mdown = false;
$(document).unbind("mouseup", upHandler);
};
$(document).mouseup(upHandler);
});
$("#func-label-box").click(function (e) {
if (me.permissions.isEdit) {
dlgFormulas.addListener("onmodalresult", function (o, mr, s) {
me.fireEvent("editcomplete", me);
},
me, {
single: true
});
dlgFormulas.show();
}
});
}
}
});
this.keep_height = 180;
var btnExpand = Ext.widget("button", {
width: 16,
height: this.height,
id: "infobox-cell-multiline-button",
style: "border-radius: 0;",
iconCls: "infobox-cell-multiline-button"
});
Ext.apply(me, {
style: "overflow:visible;",
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "container",
cls: "infobox-container-border",
id: "infobox-container-cell-name",
width: 90,
layout: {
type: "hbox"
},
items: [this.txtName, this._lblFunct]
},
this._cellInput, {
xtype: "container",
items: [btnExpand]
}]
},
me.initialConfig);
me.callParent(arguments);
},
updateCellInfo: function (info) {
if (info) {
this.txtName.setValue(typeof(info) == "string" ? info : info.asc_getName());
}
},
setMode: function (m) {
if (m.isDisconnected) {
this.permissions.isEdit = false;
} else {
this.permissions = m;
}
$("#" + this._lblFunct.id).css("cursor", m.isEdit ? "pointer" : "default");
}
});

View File

@@ -0,0 +1,126 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/InputField", "common/main/lib/component/Window"], function () {
SSE.Views.CellRangeDialog = Common.UI.Window.extend(_.extend({
options: {
width: 350,
cls: "modal-dlg",
modal: false
},
initialize: function (options) {
_.extend(this.options, {
title: this.txtTitle
},
options);
this.template = ['<div class="box">', '<div id="id-dlg-cell-range" class="input-row" style="margin-bottom: 5px;"></div>', "</div>", '<div class="footer right">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + "</button>", "</div>"].join("");
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild(),
me = this;
me.inputRange = new Common.UI.InputField({
el: $("#id-dlg-cell-range"),
name: "range",
style: "width: 100%;",
allowBlank: false,
blankError: this.txtEmpty,
validateOnChange: true
});
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
me.inputRange.cmpEl.find("input").on("keypress", _.bind(this.onKeyPress, this));
this.on("close", _.bind(this.onClose, this));
},
onPrimary: function () {
this._handleInput("ok");
return false;
},
setSettings: function (settings) {
var me = this;
this.inputRange.setValue(settings.range ? settings.range : "");
if (settings.api) {
me.api = settings.api;
me.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.Chart, settings.range ? settings.range : "");
me.api.asc_registerCallback("asc_onSelectionRangeChanged", _.bind(me.onApiRangeChanged, me));
Common.NotificationCenter.trigger("cells:range", c_oAscSelectionDialogType.Chart);
}
me.inputRange.validation = function (value) {
var isvalid = me.api.asc_checkDataRange(c_oAscSelectionDialogType.Chart, value, false);
return (isvalid == c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true;
};
},
getSettings: function () {
return this.inputRange.getValue();
},
onApiRangeChanged: function (info) {
this.inputRange.setValue(info);
if (this.inputRange.cmpEl.hasClass("error")) {
this.inputRange.cmpEl.removeClass("error");
}
},
onBtnClick: function (event) {
this._handleInput(event.currentTarget.attributes["result"].value);
},
onClose: function (event) {
if (this.api) {
this.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.None);
}
Common.NotificationCenter.trigger("cells:range", c_oAscSelectionDialogType.None);
},
onKeyPress: function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput("ok");
}
},
_handleInput: function (state) {
if (this.options.handler) {
if (state == "ok") {
if (this.inputRange.checkValidate() !== true) {
return;
}
}
this.options.handler.call(this, this, state);
}
this.close();
},
txtTitle: "Select Data Range",
textCancel: "Cancel",
txtEmpty: "This field is required",
txtInvalidRange: "ERROR! Invalid cells range",
errorMaxRows: "ERROR! The maximum number of data series per chart is 255."
},
SSE.Views.CellRangeDialog || {}));
});

View File

@@ -0,0 +1,538 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/ChartSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/component/MetricSpinner", "spreadsheeteditor/main/app/view/ChartSettingsDlg"], function (menuTemplate, $, _, Backbone) {
SSE.Views.ChartSettings = Backbone.View.extend(_.extend({
el: "#id-chart-settings",
template: _.template(menuTemplate),
events: {},
options: {
alias: "ChartSettings"
},
initialize: function () {
var me = this;
this._initSettings = true;
this._state = {
Width: 0,
Height: 0,
ChartStyle: 1,
ChartType: -1,
SeveralCharts: false,
DisabledControls: false
};
this._nRatio = 1;
this.spinners = [];
this.lockedControls = [];
this._locked = false;
this._noApply = false;
this._originalProps = null;
this.render();
this.btnChartType = new Common.UI.Button({
cls: "btn-large-dataview",
iconCls: "item-chartlist bar-normal",
menu: new Common.UI.Menu({
style: "width: 330px;",
items: [{
template: _.template('<div id="id-chart-menu-type" class="menu-insertchart" style="margin: 5px 5px 5px 10px;"></div>')
}]
})
});
this.btnChartType.on("render:after", function (btn) {
me.mnuChartTypePicker = new Common.UI.DataView({
el: $("#id-chart-menu-type"),
parentMenu: btn.menu,
restoreHeight: 411,
groups: new Common.UI.DataViewGroupStore([{
id: "menu-chart-group-bar",
caption: me.textColumn
},
{
id: "menu-chart-group-line",
caption: me.textLine
},
{
id: "menu-chart-group-pie",
caption: me.textPie
},
{
id: "menu-chart-group-hbar",
caption: me.textBar
},
{
id: "menu-chart-group-area",
caption: me.textArea
},
{
id: "menu-chart-group-scatter",
caption: me.textPoint
},
{
id: "menu-chart-group-stock",
caption: me.textStock
}]),
store: new Common.UI.DataViewStore([{
group: "menu-chart-group-bar",
type: c_oAscChartTypeSettings.barNormal,
iconCls: "column-normal",
selected: true
},
{
group: "menu-chart-group-bar",
type: c_oAscChartTypeSettings.barStacked,
iconCls: "column-stack"
},
{
group: "menu-chart-group-bar",
type: c_oAscChartTypeSettings.barStackedPer,
iconCls: "column-pstack"
},
{
group: "menu-chart-group-line",
type: c_oAscChartTypeSettings.lineNormal,
iconCls: "line-normal"
},
{
group: "menu-chart-group-line",
type: c_oAscChartTypeSettings.lineStacked,
iconCls: "line-stack"
},
{
group: "menu-chart-group-line",
type: c_oAscChartTypeSettings.lineStackedPer,
iconCls: "line-pstack"
},
{
group: "menu-chart-group-pie",
type: c_oAscChartTypeSettings.pie,
iconCls: "pie-normal"
},
{
group: "menu-chart-group-pie",
type: c_oAscChartTypeSettings.doughnut,
iconCls: "pie-doughnut"
},
{
group: "menu-chart-group-hbar",
type: c_oAscChartTypeSettings.hBarNormal,
iconCls: "bar-normal"
},
{
group: "menu-chart-group-hbar",
type: c_oAscChartTypeSettings.hBarStacked,
iconCls: "bar-stack"
},
{
group: "menu-chart-group-hbar",
type: c_oAscChartTypeSettings.hBarStackedPer,
iconCls: "bar-pstack"
},
{
group: "menu-chart-group-area",
type: c_oAscChartTypeSettings.areaNormal,
iconCls: "area-normal"
},
{
group: "menu-chart-group-area",
type: c_oAscChartTypeSettings.areaStacked,
iconCls: "area-stack"
},
{
group: "menu-chart-group-area",
type: c_oAscChartTypeSettings.areaStackedPer,
iconCls: "area-pstack"
},
{
group: "menu-chart-group-scatter",
type: c_oAscChartTypeSettings.scatter,
iconCls: "point-normal"
},
{
group: "menu-chart-group-stock",
type: c_oAscChartTypeSettings.stock,
iconCls: "stock-normal"
}]),
itemTemplate: _.template('<div id="<%= id %>" class="item-chartlist <%= iconCls %>"></div>')
});
});
this.btnChartType.render($("#chart-button-type"));
this.mnuChartTypePicker.on("item:click", _.bind(this.onSelectType, this, this.btnChartType));
this.lockedControls.push(this.btnChartType);
this.btnChartStyle = new Common.UI.Button({
cls: "btn-large-dataview",
iconCls: "item-wrap",
menu: new Common.UI.Menu({
menuAlign: "tr-br",
items: [{
template: _.template('<div id="id-chart-menu-style" style="width: 245px; margin: 0 5px;"></div>')
}]
})
});
this.btnChartStyle.on("render:after", function (btn) {
me.mnuChartStylePicker = new Common.UI.DataView({
el: $("#id-chart-menu-style"),
style: "max-height: 411px;",
parentMenu: btn.menu,
store: new Common.UI.DataViewStore(),
itemTemplate: _.template('<div id="<%= id %>" class="item-wrap" style="background-image: url(<%= imageUrl %>); background-position: 0 0;"></div>')
});
if (me.btnChartStyle.menu) {
me.btnChartStyle.menu.on("show:after", function () {
me.mnuChartStylePicker.scroller.update({
alwaysVisibleY: true
});
});
}
});
this.btnChartStyle.render($("#chart-button-style"));
this.mnuChartStylePicker.on("item:click", _.bind(this.onSelectStyle, this, this.btnChartStyle));
this.lockedControls.push(this.btnChartStyle);
this.spnWidth = new Common.UI.MetricSpinner({
el: $("#chart-spin-width"),
step: 0.1,
width: 78,
defaultUnit: "cm",
value: "3 cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.spnWidth);
this.lockedControls.push(this.spnWidth);
this.spnHeight = new Common.UI.MetricSpinner({
el: $("#chart-spin-height"),
step: 0.1,
width: 78,
defaultUnit: "cm",
value: "3 cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.spnHeight);
this.lockedControls.push(this.spnHeight);
this.spnWidth.on("change", _.bind(this.onWidthChange, this));
this.spnHeight.on("change", _.bind(this.onHeightChange, this));
this.btnRatio = new Common.UI.Button({
cls: "btn-toolbar btn-toolbar-default",
iconCls: "advanced-btn-ratio",
style: "margin-bottom: 1px;",
enableToggle: true,
hint: this.textKeepRatio
});
this.btnRatio.render($("#chart-button-ratio"));
this.lockedControls.push(this.btnRatio);
var value = window.localStorage.getItem("sse-settings-chartratio");
if (value !== null && parseInt(value) == 1) {
this.btnRatio.toggle(true);
}
this.btnRatio.on("click", _.bind(function (btn, e) {
if (btn.pressed && this.spnHeight.getNumberValue() > 0) {
this._nRatio = this.spnWidth.getNumberValue() / this.spnHeight.getNumberValue();
}
window.localStorage.setItem("sse-settings-chartratio", (btn.pressed) ? 1 : 0);
},
this));
$(this.el).on("click", "#chart-advanced-link", _.bind(this.openAdvancedSettings, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
this.linkAdvanced = $("#chart-advanced-link");
},
setApi: function (api) {
this.api = api;
if (this.api) {
this.api.asc_registerCallback("asc_onUpdateChartStyles", _.bind(this._onUpdateChartStyles, this));
}
return this;
},
ChangeSettings: function (props) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
this.disableControls(this._locked);
if (this.api && props && props.asc_getChartProperties()) {
this._originalProps = new Asc.asc_CImgProperty(props);
this._noApply = true;
this.chartProps = props.asc_getChartProperties();
var value = props.asc_getSeveralCharts() || this._locked;
if (this._state.SeveralCharts !== value) {
this.linkAdvanced.toggleClass("disabled", value);
this._state.SeveralCharts = value;
}
value = props.asc_getSeveralChartTypes();
if (this._state.SeveralCharts && value) {
this.btnChartType.setIconCls("");
this._state.ChartType = null;
} else {
var type = this.chartProps.getType();
if (this._state.ChartType !== type) {
var record = this.mnuChartTypePicker.store.findWhere({
type: type
});
this.mnuChartTypePicker.selectRecord(record, true);
if (record) {
this.btnChartType.setIconCls("item-chartlist " + record.get("iconCls"));
}
this.updateChartStyles(this.api.asc_getChartPreviews(type));
this._state.ChartType = type;
}
}
value = props.asc_getSeveralChartStyles();
if (this._state.SeveralCharts && value) {
var btnIconEl = this.btnChartStyle.cmpEl.find("span.btn-icon");
btnIconEl.css("background-image", "none");
this.mnuChartStylePicker.selectRecord(null, true);
this._state.ChartStyle = null;
} else {
value = this.chartProps.getStyle();
if (this._state.ChartStyle !== value) {
var record = this.mnuChartStylePicker.store.findWhere({
data: value
});
this.mnuChartStylePicker.selectRecord(record, true);
if (record) {
var btnIconEl = this.btnChartStyle.cmpEl.find("span.btn-icon");
btnIconEl.css("background-image", "url(" + record.get("imageUrl") + ")");
}
this._state.ChartStyle = value;
}
}
this._noApply = false;
value = props.asc_getWidth();
if (Math.abs(this._state.Width - value) > 0.001 || (this._state.Width === null || value === null) && (this._state.Width !== value)) {
this.spnWidth.setValue((value !== null) ? Common.Utils.Metric.fnRecalcFromMM(value) : "", true);
this._state.Width = value;
}
value = props.asc_getHeight();
if (Math.abs(this._state.Height - value) > 0.001 || (this._state.Height === null || value === null) && (this._state.Height !== value)) {
this.spnHeight.setValue((value !== null) ? Common.Utils.Metric.fnRecalcFromMM(value) : "", true);
this._state.Height = value;
}
if (props.asc_getHeight() > 0) {
this._nRatio = props.asc_getWidth() / props.asc_getHeight();
}
}
},
updateMetricUnit: function () {
if (this.spinners) {
for (var i = 0; i < this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]);
spinner.setStep(Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
onWidthChange: function (field, newValue, oldValue, eOpts) {
var w = field.getNumberValue();
var h = this.spnHeight.getNumberValue();
if (this.btnRatio.pressed) {
h = w / this._nRatio;
if (h > this.spnHeight.options.maxValue) {
h = this.spnHeight.options.maxValue;
w = h * this._nRatio;
this.spnWidth.setValue(w, true);
}
this.spnHeight.setValue(h, true);
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onHeightChange: function (field, newValue, oldValue, eOpts) {
var h = field.getNumberValue(),
w = this.spnWidth.getNumberValue();
if (this.btnRatio.pressed) {
w = h * this._nRatio;
if (w > this.spnWidth.options.maxValue) {
w = this.spnWidth.options.maxValue;
h = w / this._nRatio;
this.spnHeight.setValue(h, true);
}
this.spnWidth.setValue(w, true);
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
openAdvancedSettings: function () {
if (this.linkAdvanced.hasClass("disabled")) {
return;
}
var me = this;
var win, props;
if (me.api) {
props = me.api.asc_getChartObject();
if (props) {
(new SSE.Views.ChartSettingsDlg({
chartSettings: props,
api: me.api,
handler: function (result, value) {
if (result == "ok") {
if (me.api) {
me.api.asc_editChartDrawingObject(value.chartSettings);
}
}
Common.NotificationCenter.trigger("edit:complete", me);
}
})).show();
}
}
},
onSelectType: function (btn, picker, itemView, record) {
if (this._noApply) {
return;
}
var rawData = {},
isPickerSelect = _.isFunction(record.toJSON);
if (isPickerSelect) {
if (record.get("selected")) {
rawData = record.toJSON();
} else {
return;
}
} else {
rawData = record;
}
this.btnChartType.setIconCls("item-chartlist " + rawData.iconCls);
this._state.ChartType = -1;
if (this.api && !this._noApply && this.chartProps) {
var props = new Asc.asc_CImgProperty();
this.chartProps.changeType(rawData.type);
props.asc_putChartProperties(this.chartProps);
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onSelectStyle: function (btn, picker, itemView, record) {
if (this._noApply) {
return;
}
var rawData = {},
isPickerSelect = _.isFunction(record.toJSON);
if (isPickerSelect) {
if (record.get("selected")) {
rawData = record.toJSON();
} else {
return;
}
} else {
rawData = record;
}
var style = "url(" + rawData.imageUrl + ")";
var btnIconEl = this.btnChartStyle.cmpEl.find("span.btn-icon");
btnIconEl.css("background-image", style);
if (this.api && !this._noApply && this.chartProps) {
var props = new Asc.asc_CImgProperty();
this.chartProps.putStyle(rawData.data);
props.asc_putChartProperties(this.chartProps);
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
_onUpdateChartStyles: function () {
if (this.api && this._state.ChartType !== null && this._state.ChartType > -1) {
this.updateChartStyles(this.api.asc_getChartPreviews(this._state.ChartType));
}
},
updateChartStyles: function (styles) {
var me = this;
if (styles && styles.length > 0) {
var stylesStore = this.mnuChartStylePicker.store;
if (stylesStore) {
var stylearray = [],
selectedIdx = -1,
selectedUrl;
_.each(styles, function (item, index) {
stylearray.push({
imageUrl: item.asc_getImageUrl(),
data: item.asc_getStyle(),
tip: me.textStyle + " " + item.asc_getStyle()
});
if (me._state.ChartStyle == item.asc_getStyle()) {
selectedIdx = index;
selectedUrl = item.asc_getImageUrl();
}
});
stylesStore.reset(stylearray, {
silent: false
});
}
}
this.mnuChartStylePicker.selectByIndex(selectedIdx, true);
if (selectedIdx >= 0 && this.btnChartStyle.cmpEl) {
var style = "url(" + selectedUrl + ")";
var btnIconEl = this.btnChartStyle.cmpEl.find("span.btn-icon");
btnIconEl.css("background-image", style);
}
},
setLocked: function (locked) {
this._locked = locked;
},
disableControls: function (disable) {
if (this._state.DisabledControls !== disable) {
this._state.DisabledControls = disable;
_.each(this.lockedControls, function (item) {
item.setDisabled(disable);
});
this.linkAdvanced.toggleClass("disabled", disable);
}
},
textKeepRatio: "Constant Proportions",
textSize: "Size",
textWidth: "Width",
textHeight: "Height",
textEditData: "Edit Data",
textChartType: "Change Chart Type",
textLine: "Line Chart",
textColumn: "Column Chart",
textBar: "Bar Chart",
textArea: "Area Chart",
textPie: "Pie Chart",
textPoint: "Point Chart",
textStock: "Stock Chart",
textStyle: "Style",
textAdvanced: "Show advanced settings"
},
SSE.Views.ChartSettings || {}));
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,87 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.CreateFile", {
extend: "Ext.panel.Panel",
alias: "widget.ssecreatenew",
cls: "sse-file-createnew",
layout: {
type: "vbox",
align: "stretch"
},
requires: ["Ext.container.Container", "Ext.data.Model", "Ext.data.Store", "Ext.view.View", "Ext.XTemplate", "Common.plugin.DataViewScrollPane"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.callParent(arguments);
var me = this;
me.add({
xtype: "container",
html: "<h3>" + me.fromBlankText + "</h3>" + "<hr noshade>" + '<div class="blank-document">' + '<div id="id-create-blank-document" class="btn-blank-document"></div>' + '<div class="blank-document-info">' + "<h3>" + me.newDocumentText + "</h3>" + me.newDescriptionText + "</div>" + "</div>" + '<div style="clear: both;"></div>' + "<h3>" + me.fromTemplateText + "</h3>" + "<hr noshade>"
},
{
xtype: "container",
flex: 1,
layout: "fit",
cls: "container-template-list",
items: [{
xtype: "dataview",
store: "FileTemplates",
tpl: Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap">', '<tpl if="this.isEmptyIcon(icon)">', '<div class="thumb"></div>', "</tpl>", '<tpl if="this.isEmptyIcon(icon) == false">', '<div class="thumb" style="background-image: url(' + "'{icon}'" + ');"></div>', "</tpl>", '<div class="title">{name:htmlEncode}</div>', "</div>", "</tpl>", {
isEmptyIcon: function (icon) {
return icon == "";
}
}),
singleSelect: true,
trackOver: true,
autoScroll: true,
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
cls: "x-view-context",
plugins: [{
ptype: "dataviewscrollpane",
pluginId: "scrollpane",
areaSelector: ".x-view-context",
settings: {
enableKeyboardNavigation: true
}
}]
}]
});
},
fromBlankText: "From Blank",
newDocumentText: "New Text Document",
newDescriptionText: "Create a new blank text document 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"
});

View File

@@ -1,276 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.DigitalFilterDialog", {
extend: "Ext.window.Window",
alias: "widget.ssedigitalfilterdialog",
requires: ["Ext.window.Window"],
modal: true,
closable: true,
resizable: false,
height: 226,
width: 500,
constrain: true,
padding: "20px 20px 0 20px",
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var me = this;
var storeCondition = Ext.create("Ext.data.Store", {
fields: ["condition", "caption"],
data: [{
condition: c_oAscCustomAutoFilter.equals,
caption: me.capCondition1
},
{
condition: c_oAscCustomAutoFilter.doesNotEqual,
caption: me.capCondition2
},
{
condition: c_oAscCustomAutoFilter.isGreaterThan,
caption: me.capCondition3
},
{
condition: c_oAscCustomAutoFilter.isGreaterThanOrEqualTo,
caption: me.capCondition4
},
{
condition: c_oAscCustomAutoFilter.isLessThan,
caption: me.capCondition5
},
{
condition: c_oAscCustomAutoFilter.isLessThanOrEqualTo,
caption: me.capCondition6
},
{
condition: c_oAscCustomAutoFilter.beginsWith,
caption: me.capCondition7
},
{
condition: c_oAscCustomAutoFilter.doesNotBeginWith,
caption: me.capCondition8
},
{
condition: c_oAscCustomAutoFilter.endsWith,
caption: me.capCondition9
},
{
condition: c_oAscCustomAutoFilter.doesNotEndWith,
caption: me.capCondition10
},
{
condition: c_oAscCustomAutoFilter.contains,
caption: me.capCondition11
},
{
condition: c_oAscCustomAutoFilter.doesNotContain,
caption: me.capCondition12
}]
});
this.cmbCondition1 = Ext.create("Ext.form.field.ComboBox", {
store: storeCondition,
displayField: "caption",
valueField: "condition",
queryMode: "local",
typeAhead: false,
style: "margin-right: 10px",
width: 200,
editable: false
});
this.txtValue1 = Ext.create("Ext.form.Text", {
flex: 1,
value: ""
});
this.txtValue2 = Ext.create("Ext.form.Text", {
flex: 1,
value: ""
});
var storeCondition2 = Ext.create("Ext.data.Store", {
fields: ["condition", "caption"],
data: [{
condition: 0,
caption: me.textNoFilter
}]
});
storeCondition2.loadRecords(storeCondition.data.getRange(), {
addRecords: true
});
this.cmbCondition2 = Ext.create("Ext.form.field.ComboBox", {
store: storeCondition2,
displayField: "caption",
valueField: "condition",
queryMode: "local",
typeAhead: false,
style: "margin-right: 10px",
width: 200,
editable: false
});
this.rbMixer = Ext.widget("radiogroup", {
columns: 2,
width: 120,
items: [{
boxLabel: me.capAnd,
name: "mix",
inputValue: "and",
checked: true
},
{
boxLabel: me.capOr,
name: "mix",
inputValue: "or"
}]
});
var btnOk = Ext.create("Ext.Button", {
text: Ext.Msg.buttonText.ok,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 1);
me.close();
}
}
});
var btnCancel = Ext.create("Ext.Button", {
text: me.cancelButtonText,
width: 80,
listeners: {
click: function () {
me.fireEvent("onmodalresult", me, 0);
me.close();
}
}
});
this.items = [{
xtype: "label",
style: "font-weight: bold;margin:0 0 4px 0;",
text: me.textShowRows
},
{
xtype: "container",
style: "margin:10px 0 0 0;",
layout: {
type: "hbox",
align: "middle"
},
items: [this.cmbCondition1, this.txtValue1]
},
{
xtype: "container",
layout: {
type: "hbox",
align: "middle"
},
items: [this.rbMixer]
},
{
xtype: "container",
layout: {
type: "hbox",
align: "middle"
},
items: [this.cmbCondition2, this.txtValue2]
},
{
xtype: "tbspacer",
height: 3
},
{
xtype: "container",
width: 400,
style: "margin:10px 0 0 0;",
layout: {
type: "hbox",
align: "middle"
},
items: [{
xtype: "tbspacer",
flex: 1
},
btnOk, {
xtype: "tbspacer",
width: 5
},
btnCancel]
}];
this.callParent(arguments);
this.setTitle(this.txtTitle);
},
afterRender: function () {
this.callParent(arguments);
this._setDefaults();
},
setSettings: function (config) {
this._defaults = [];
this._defaults.properties = config;
},
getSettings: function () {
var ret_out = new Asc.AutoFiltersOptions();
ret_out.asc_setCellId(this._defaults.properties.asc_getCellId());
ret_out.asc_setIsChecked(this.rbMixer.getValue().mix == "or");
ret_out.asc_setFilter1(this.cmbCondition1.getValue());
ret_out.asc_setFilter2(this.cmbCondition2.getValue() || undefined);
ret_out.asc_setValFilter1(this.txtValue1.getValue());
ret_out.asc_setValFilter2(this.txtValue2.getValue());
return ret_out;
},
_setDefaults: function () {
this.rbMixer.setValue({
mix: this._defaults.properties.asc_getIsChecked() ? "or" : "and"
});
this.cmbCondition1.setValue(this._defaults.properties.asc_getFilter1() || c_oAscCustomAutoFilter.equals);
this.cmbCondition2.setValue(this._defaults.properties.asc_getFilter2() || 0);
this.txtValue1.setValue(this._defaults.properties.asc_getValFilter1());
this.txtValue2.setValue(this._defaults.properties.asc_getValFilter2());
},
txtTitle: "Custom Filter",
capCondition1: "equals",
capCondition2: "does not equal",
capCondition3: "is greater than",
capCondition4: "is greater than or equal to",
capCondition5: "is less than",
capCondition6: "is less than or equal to",
capCondition7: "begins with",
capCondition8: "does not begin with",
capCondition9: "ends with",
capCondition10: "does not end with",
capCondition11: "contains",
capCondition12: "does not contain",
capAnd: "And",
capOr: "Or",
textShowRows: "Show rows where",
textUse1: "Use ? to present any single character",
textUse2 : "Use * to present any series of character",
textNoFilter: "no filter",
cancelButtonText: "Cancel"
});

View File

@@ -1,267 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.model.ModelHelpMenu", {
extend: "Ext.data.Model",
fields: [{
type: "string",
name: "name"
},
{
type: "string",
name: "src"
},
{
type: "string",
name: "headername"
}]
});
Ext.define("SSE.view.DocumentHelp", {
extend: "Ext.container.Container",
alias: "widget.ssedocumenthelp",
cls: "sse-documenthelp-body",
autoScroll: true,
requires: ["Ext.container.Container", "Ext.XTemplate", "Ext.view.View", "Ext.data.Model", "Ext.data.Store", "Common.plugin.DataViewScrollPane"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this;
this.urlPref = "resources/help/en/";
var en_data = [{
src: "UsageInstructions/OpenCreateNew.htm",
name: "Create a new spreadsheet or open an existing one",
headername: "Usage Instructions"
},
{
src: "UsageInstructions/ManageSheets.htm",
name: "Manage sheets"
},
{
src: "UsageInstructions/InsertDeleteCells.htm",
name: "Insert or delete cells, rows, and columns"
},
{
src: "UsageInstructions/CopyPasteData.htm",
name: "Copy and paste data"
},
{
src: "UsageInstructions/FontTypeSizeStyle.htm",
name: "Set font type, size, style, and colors"
},
{
src: "UsageInstructions/AlignText.htm",
name: "Align data in cells"
},
{
src: "UsageInstructions/AddBorders.htm",
name: "Add borders"
},
{
src: "UsageInstructions/MergeCells.htm",
name: "Merge cells"
},
{
src: "UsageInstructions/ClearFormatting.htm",
name: "Clear text, format in a cell"
},
{
src: "UsageInstructions/SortData.htm",
name: "Sort data"
},
{
src: "UsageInstructions/InsertFunction.htm",
name: "Insert function"
},
{
src: "UsageInstructions/ChangeNumberFormat.htm",
name: "Change number format"
},
{
src: "UsageInstructions/UndoRedo.htm",
name: "Undo/redo your actions"
},
{
src: "UsageInstructions/ViewDocInfo.htm",
name: "View file information"
},
{
src: "UsageInstructions/SavePrintDownload.htm",
name: "Save/print/download your spreadsheet"
},
{
src: "HelpfulHints/About.htm",
name: "About ONLYOFFICE Spreadsheet Editor",
headername: "Helpful Hints"
},
{
src: "HelpfulHints/SupportedFormats.htm",
name: "Supported Formats of Spreadsheets"
},
{
src: "HelpfulHints/Navigation.htm",
name: "Navigation through Your Spreadsheet"
},
{
src: "HelpfulHints/Search.htm",
name: "Search Function"
},
{
src: "HelpfulHints/KeyboardShortcuts.htm",
name: "Keyboard Shortcuts"
}];
this.menuStore = Ext.create("Ext.data.Store", {
model: "SSE.model.ModelHelpMenu",
proxy: {
type: "ajax",
url: "help/Contents.json",
noCache: false
},
listeners: {
load: function (store, records, successful) {
if (!successful) {
if (me.urlPref.indexOf("resources/help/en/") < 0) {
me.urlPref = "resources/help/en/";
store.getProxy().url = "resources/help/en/Contents.json";
store.load();
} else {
me.urlPref = "resources/help/en/";
store.loadData(en_data);
}
}
}
}
});
var menuTpl = new Ext.XTemplate('<tpl for=".">', '<tpl if="headername">', '<div class="header-wrap">', '<span class="header">{headername}</span>', "</div>", "</tpl>", '<div class="thumb-wrap">', '<span class="caption">{name}</span>', "</div>", "</tpl>", '<div class="x-clear"></div>');
this.cntMenu = Ext.create("Ext.container.Container", {
layout: "fit",
cls: "help-menu-container",
width: 200,
items: [this.menuView = Ext.create("Ext.view.View", {
store: this.menuStore,
tpl: menuTpl,
singleSelect: true,
trackOver: true,
style: "overflow:visible;",
width: "100%",
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
cls: "help-menu-view",
listeners: {
afterrender: function (view) {
view.getSelectionModel().deselectOnContainerClick = false;
if (view.getStore().getCount()) {
view.select(0);
me.iFrame.src = me.urlPref + view.getStore().getAt(0).data.src;
}
},
selectionchange: function (model, selections) {
var record = model.getLastSelected();
if (record) {
me.iFrame.src = me.urlPref + record.data.src;
}
}
},
plugins: [{
ptype: "dataviewscrollpane",
areaSelector: ".help-menu-view",
pluginId: "docHelpPluginId",
settings: {
enableKeyboardNavigation: true,
keyboardSpeed: 0.001
}
}]
})]
});
this.iFrame = document.createElement("iframe");
this.iFrame.src = "";
this.iFrame.align = "top";
this.iFrame.frameBorder = "0";
this.iFrame.width = "100%";
this.iFrame.height = "100%";
this.iFrame.onload = Ext.bind(function () {
var src = arguments[0].currentTarget.contentDocument.URL;
Ext.each(this.menuStore.data.items, function (item, index) {
var res = src.indexOf(item.data.src);
if (res > 0) {
this.menuView.select(index);
var node = this.menuView.getNode(index),
plugin = this.menuView.getPlugin("docHelpPluginId");
if (plugin) {
plugin.scrollToElement(node);
}
return false;
}
},
this);
},
this);
this.items = [{
xtype: "container",
layout: {
type: "hbox",
align: "stretch"
},
height: "100%",
items: [this.cntMenu, {
xtype: "tbspacer",
width: 2,
style: "border-left: 1px solid #C7C7C7"
},
{
xtype: "container",
flex: 1,
layout: "fit",
listeners: {
afterrender: function (cmp) {
cmp.getEl().appendChild(me.iFrame);
}
}
}]
}];
this.callParent(arguments);
},
setApi: function (o) {
if (o) {
this.api = o;
}
},
setLangConfig: function (lang) {
if (lang) {
lang = lang.split("-")[0];
this.menuStore.getProxy().url = "resources/help/" + lang + "/Contents.json";
this.menuStore.load();
this.urlPref = "resources/help/" + lang + "/";
}
}
});

View File

@@ -1,399 +1,416 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.DocumentHolder", {
extend: "Ext.container.Container",
alias: "widget.ssedocumentholder",
cls: "sse-documentholder",
uses: ["Ext.menu.Menu", "Ext.menu.Manager", "SSE.view.FormulaDialog", "Common.plugin.MenuExpand"],
config: {},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
layout: "fit",
initComponent: function () {
var me = this;
this.setApi = function (o) {
me.api = o;
return me;
};
var value = window.localStorage.getItem("sse-settings-livecomment");
me.isLiveCommenting = !(value !== null && parseInt(value) == 0);
me.addEvents("editcomplete");
me.callParent(arguments);
},
createDelayedElements: function () {
var me = this;
function fixSubmenuPosition(submenu) {
if (!submenu.getPosition()[0]) {
if (submenu.floatParent) {
var xy = submenu.el.getAlignToXY(submenu.parentItem.getEl(), "tl-tr?"),
region = submenu.floatParent.getTargetEl().getViewRegion();
submenu.setPosition([xy[0] - region.x, xy[1] - region.y]);
}
}
}
this.pmiInsertEntire = Ext.widget("menuitem", {
action: "insert-entire",
text: me.txtInsert
});
this.pmiInsertCells = Ext.widget("menuitem", {
text: me.txtInsert,
hideOnClick: false,
menu: {
action: "insert-cells",
showSeparator: false,
bodyCls: "no-icons",
items: [{
text: me.txtShiftRight,
kind: c_oAscInsertOptions.InsertCellsAndShiftRight
},
{
text: me.txtShiftDown,
kind: c_oAscInsertOptions.InsertCellsAndShiftDown
},
{
text: me.txtRow,
kind: c_oAscInsertOptions.InsertRows
},
{
text: me.txtColumn,
kind: c_oAscInsertOptions.InsertColumns
}],
plugins: [{
ptype: "menuexpand"
}],
listeners: {
show: fixSubmenuPosition
}
}
});
this.pmiDeleteEntire = Ext.widget("menuitem", {
action: "delete-entire",
text: me.txtDelete
});
this.pmiDeleteCells = Ext.widget("menuitem", {
text: me.txtDelete,
hideOnClick: false,
menu: {
action: "delete-cells",
showSeparator: false,
bodyCls: "no-icons",
items: [{
text: me.txtShiftLeft,
kind: c_oAscDeleteOptions.DeleteCellsAndShiftLeft
},
{
text: me.txtShiftUp,
kind: c_oAscDeleteOptions.DeleteCellsAndShiftTop
},
{
text: me.txtRow,
kind: c_oAscDeleteOptions.DeleteRows
},
{
text: me.txtColumn,
kind: c_oAscDeleteOptions.DeleteColumns
}],
plugins: [{
ptype: "menuexpand"
}],
listeners: {
show: fixSubmenuPosition
}
}
});
this.pmiSortCells = Ext.widget("menuitem", {
text: me.txtSort,
hideOnClick: false,
menu: {
id: "cmi-sort-cells",
bodyCls: "no-icons",
showSeparator: false,
items: [{
text: me.txtAscending,
direction: "descending"
},
{
text: me.txtDescending,
direction: "ascending"
}],
plugins: [{
ptype: "menuexpand"
}],
listeners: {
show: fixSubmenuPosition
}
}
});
this.pmiInsFunction = Ext.widget("menuitem", {
text: me.txtFormula,
listeners: {
click: function (item) {
dlgFormulas.addListener("onmodalresult", function (o, mr, s) {
me.fireEvent("editcomplete", me);
},
me, {
single: true
});
dlgFormulas.show();
}
}
});
this.pmiInsHyperlink = Ext.widget("menuitem", {
action: "insert-hyperlink",
text: me.txtInsHyperlink
});
this.pmiDelHyperlink = Ext.widget("menuitem", {
action: "remove-hyperlink",
text: me.removeHyperlinkText
});
this.pmiRowHeight = Ext.widget("menuitem", {
action: "row-height",
text: this.txtRowHeight
});
this.pmiColumnWidth = Ext.widget("menuitem", {
action: "column-width",
text: this.txtColumnWidth
});
this.pmiEntireHide = Ext.widget("menuitem", {
text: this.txtHide,
handler: function (item, event) {
me.api[item.isrowmenu ? "asc_hideRows" : "asc_hideColumns"]();
}
});
this.pmiEntireShow = Ext.widget("menuitem", {
text: this.txtShow,
handler: function (item, event) {
me.api[item.isrowmenu ? "asc_showRows" : "asc_showColumns"]();
}
});
this.pmiAddComment = Ext.widget("menuitem", {
id: "cmi-add-comment",
text: this.txtAddComment
});
this.pmiCellMenuSeparator = Ext.widget("menuseparator");
this.ssMenu = Ext.widget("menu", {
id: "context-menu-cell",
showSeparator: false,
bodyCls: "no-icons",
group: "menu-document",
items: [{
text: this.txtCut,
group: "copy-paste",
action: "cut"
},
{
text: this.txtCopy,
group: "copy-paste",
action: "copy"
},
{
text: this.txtPaste,
group: "copy-paste",
action: "paste"
},
{
xtype: "menuseparator"
},
this.pmiInsertEntire, this.pmiInsertCells, this.pmiDeleteEntire, this.pmiDeleteCells, {
action: "clear-all",
text: me.txtClear
},
this.pmiSortCells, {
xtype: "menuseparator"
},
this.pmiAddComment, this.pmiCellMenuSeparator, this.pmiInsFunction, this.pmiInsHyperlink, this.pmiDelHyperlink, this.pmiRowHeight, this.pmiColumnWidth, this.pmiEntireHide, this.pmiEntireShow],
plugins: [{
ptype: "menuexpand"
}]
});
this.mnuGroupImg = Ext.create("Ext.menu.Item", {
iconCls: "mnu-icon-item mnu-group",
text: this.txtGroup,
action: "image-grouping",
grouping: true
});
this.mnuUnGroupImg = Ext.create("Ext.menu.Item", {
iconCls: "mnu-icon-item mnu-ungroup",
text: this.txtUngroup,
action: "image-grouping",
grouping: false
});
this.imgMenu = Ext.widget("menu", {
showSeparator: false,
group: "menu-document",
listeners: {
click: function (menu, item) {
if (item) {
me.api.asc_setSelectedDrawingObjectLayer(item.arrange);
}
me.fireEvent("editcomplete", me);
}
},
items: [{
iconCls: "mnu-icon-item mnu-arrange-front",
text: this.textArrangeFront,
arrange: c_oAscDrawingLayerType.BringToFront
},
{
iconCls: "mnu-icon-item mnu-arrange-back",
text: this.textArrangeBack,
arrange: c_oAscDrawingLayerType.SendToBack
},
{
iconCls: "mnu-icon-item mnu-arrange-forward",
text: this.textArrangeForward,
arrange: c_oAscDrawingLayerType.BringForward
},
{
iconCls: "mnu-icon-item mnu-arrange-backward",
text: this.textArrangeBackward,
arrange: c_oAscDrawingLayerType.SendBackward
},
{
xtype: "menuseparator"
},
this.mnuGroupImg, this.mnuUnGroupImg]
});
this.menuParagraphVAlign = Ext.widget("menuitem", {
text: this.vertAlignText,
hideOnClick: false,
menu: {
showSeparator: false,
bodyCls: "no-icons",
items: [this.menuParagraphTop = Ext.widget("menucheckitem", {
text: this.topCellText,
checked: false,
group: "popupparagraphvalign",
valign: c_oAscVerticalTextAlign.TEXT_ALIGN_TOP
}), this.menuParagraphCenter = Ext.widget("menucheckitem", {
text: this.centerCellText,
checked: false,
group: "popupparagraphvalign",
valign: c_oAscVerticalTextAlign.TEXT_ALIGN_CTR
}), this.menuParagraphBottom = Ext.widget("menucheckitem", {
text: this.bottomCellText,
checked: false,
group: "popupparagraphvalign",
valign: c_oAscVerticalTextAlign.TEXT_ALIGN_BOTTOM
})],
plugins: [{
ptype: "menuexpand"
}]
}
});
this.pmiInsHyperlinkShape = Ext.widget("menuitem", {
text: me.txtInsHyperlink,
action: "add-hyperlink-shape"
});
this.pmiRemoveHyperlinkShape = Ext.widget("menuitem", {
text: me.removeHyperlinkText,
action: "remove-hyperlink-shape"
});
this.pmiTextAdvanced = Ext.widget("menuitem", {
text: me.txtTextAdvanced,
action: "text-advanced"
});
this.textInShapeMenu = Ext.widget("menu", {
showSeparator: false,
bodyCls: "no-icons",
group: "menu-document",
items: [this.menuParagraphVAlign, this.pmiInsHyperlinkShape, this.pmiRemoveHyperlinkShape, {
xtype: "menuseparator"
},
this.pmiTextAdvanced]
});
this.funcMenu = Ext.widget("menu", {
showSeparator: false,
bodyCls: "no-icons",
group: "menu-document",
items: [{
text: "item 1"
},
{
text: "item 2"
},
{
text: "item 3"
},
{
text: "item 4"
},
{
text: "item 5"
}]
});
},
setLiveCommenting: function (value) {
this.isLiveCommenting = value;
},
txtSort: "Sort",
txtAscending: "Ascending",
txtDescending: "Descending",
txtFormula: "Insert Function",
txtInsHyperlink: "Add Hyperlink",
txtCut: "Cut",
txtCopy: "Copy",
txtPaste: "Paste",
txtInsert: "Insert",
txtDelete: "Delete",
txtFilter: "Filter",
txtClear: "Clear All",
txtShiftRight: "Shift cells right",
txtShiftLeft: "Shift cells left",
txtShiftUp: "Shift cells up",
txtShiftDown: "Shift cells down",
txtRow: "Entire Row",
txtColumn: "Entire Column",
txtColumnWidth: "Column Width",
txtRowHeight: "Row Height",
txtWidth: "Width",
txtHide: "Hide",
txtShow: "Show",
textArrangeFront: "Bring To Front",
textArrangeBack: "Send To Back",
textArrangeForward: "Bring Forward",
textArrangeBackward: "Send Backward",
txtArrange: "Arrange",
txtAddComment: "Add Comment",
txtUngroup: "Ungroup",
txtGroup: "Group",
topCellText: "Align Top",
centerCellText: "Align Center",
bottomCellText: "Align Bottom",
vertAlignText: "Vertical Alignment",
txtTextAdvanced: "Text Advanced Settings",
editHyperlinkText: "Edit Hyperlink",
removeHyperlinkText: "Remove Hyperlink"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["jquery", "underscore", "backbone", "gateway", "common/main/lib/component/Menu"], function ($, _, Backbone, gateway) {
SSE.Views.DocumentHolder = Backbone.View.extend(_.extend({
el: "#editor_sdk",
template: null,
events: {},
initialize: function () {
var me = this;
this.setApi = function (api) {
me.api = api;
return me;
};
var value = window.localStorage.getItem("sse-settings-livecomment");
me.isLiveCommenting = !(value !== null && parseInt(value) == 0);
},
render: function () {
this.fireEvent("render:before", this);
this.cmpEl = $(this.el);
this.fireEvent("render:after", this);
return this;
},
focus: function () {
var me = this;
_.defer(function () {
me.cmpEl.focus();
},
50);
},
createDelayedElements: function () {
var me = this;
me.pmiCut = new Common.UI.MenuItem({
caption: me.txtCut,
value: "cut"
});
me.pmiCopy = new Common.UI.MenuItem({
caption: me.txtCopy,
value: "copy"
});
me.pmiPaste = new Common.UI.MenuItem({
caption: me.txtPaste,
value: "paste"
});
me.pmiInsertEntire = new Common.UI.MenuItem({
caption: me.txtInsert
});
me.pmiInsertCells = new Common.UI.MenuItem({
caption: me.txtInsert,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [{
caption: me.txtShiftRight,
value: c_oAscInsertOptions.InsertCellsAndShiftRight
},
{
caption: me.txtShiftDown,
value: c_oAscInsertOptions.InsertCellsAndShiftDown
},
{
caption: me.txtRow,
value: c_oAscInsertOptions.InsertRows
},
{
caption: me.txtColumn,
value: c_oAscInsertOptions.InsertColumns
}]
})
});
me.pmiDeleteEntire = new Common.UI.MenuItem({
caption: me.txtDelete
});
me.pmiDeleteCells = new Common.UI.MenuItem({
caption: me.txtDelete,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [{
caption: me.txtShiftLeft,
value: c_oAscDeleteOptions.DeleteCellsAndShiftLeft
},
{
caption: me.txtShiftUp,
value: c_oAscDeleteOptions.DeleteCellsAndShiftTop
},
{
caption: me.txtRow,
value: c_oAscDeleteOptions.DeleteRows
},
{
caption: me.txtColumn,
value: c_oAscDeleteOptions.DeleteColumns
}]
})
});
me.pmiClear = new Common.UI.MenuItem({
caption: me.txtClear,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [{
caption: me.txtClearAll,
value: c_oAscCleanOptions.All
},
{
caption: me.txtClearText,
value: c_oAscCleanOptions.Text
},
{
caption: me.txtClearFormat,
value: c_oAscCleanOptions.Format
},
{
caption: me.txtClearComments,
value: c_oAscCleanOptions.Comments
},
{
caption: me.txtClearHyper,
value: c_oAscCleanOptions.Hyperlinks
}]
})
});
me.pmiSortCells = new Common.UI.MenuItem({
caption: me.txtSort,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [{
caption: me.txtAscending,
value: "ascending"
},
{
caption: me.txtDescending,
value: "descending"
}]
})
});
me.pmiInsFunction = new Common.UI.MenuItem({
caption: me.txtFormula
});
me.menuAddHyperlink = new Common.UI.MenuItem({
caption: me.txtInsHyperlink,
inCell: true
});
me.menuEditHyperlink = new Common.UI.MenuItem({
caption: me.editHyperlinkText,
inCell: true
});
me.menuRemoveHyperlink = new Common.UI.MenuItem({
caption: me.removeHyperlinkText
});
me.menuHyperlink = new Common.UI.MenuItem({
caption: me.txtInsHyperlink,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [me.menuEditHyperlink, me.menuRemoveHyperlink]
})
});
me.pmiRowHeight = new Common.UI.MenuItem({
caption: me.txtRowHeight,
action: "row-height"
});
me.pmiColumnWidth = new Common.UI.MenuItem({
caption: me.txtColumnWidth,
action: "column-width"
});
me.pmiEntireHide = new Common.UI.MenuItem({
caption: me.txtHide
});
me.pmiEntireShow = new Common.UI.MenuItem({
caption: me.txtShow
});
me.pmiAddComment = new Common.UI.MenuItem({
id: "id-context-menu-item-add-comment",
caption: me.txtAddComment
});
me.pmiCellMenuSeparator = new Common.UI.MenuItem({
caption: "--"
});
me.ssMenu = new Common.UI.Menu({
id: "id-context-menu-cell",
items: [me.pmiCut, me.pmiCopy, me.pmiPaste, {
caption: "--"
},
me.pmiInsertEntire, me.pmiInsertCells, me.pmiDeleteEntire, me.pmiDeleteCells, me.pmiClear, me.pmiSortCells, {
caption: "--"
},
me.pmiAddComment, me.pmiCellMenuSeparator, me.pmiInsFunction, me.menuAddHyperlink, me.menuHyperlink, me.pmiRowHeight, me.pmiColumnWidth, me.pmiEntireHide, me.pmiEntireShow]
});
me.mnuGroupImg = new Common.UI.MenuItem({
caption: this.txtGroup,
iconCls: "mnu-group",
type: "group",
value: "grouping"
});
me.mnuUnGroupImg = new Common.UI.MenuItem({
caption: this.txtUngroup,
iconCls: "mnu-ungroup",
type: "group",
value: "ungrouping"
});
me.mnuShapeSeparator = new Common.UI.MenuItem({
caption: "--"
});
me.mnuShapeAdvanced = new Common.UI.MenuItem({
caption: me.advancedShapeText
});
me.mnuChartEdit = new Common.UI.MenuItem({
caption: me.chartText
});
me.pmiImgCut = new Common.UI.MenuItem({
caption: me.txtCut,
value: "cut"
});
me.pmiImgCopy = new Common.UI.MenuItem({
caption: me.txtCopy,
value: "copy"
});
me.pmiImgPaste = new Common.UI.MenuItem({
caption: me.txtPaste,
value: "paste"
});
this.imgMenu = new Common.UI.Menu({
items: [me.pmiImgCut, me.pmiImgCopy, me.pmiImgPaste, {
caption: "--"
},
{
caption: this.textArrangeFront,
iconCls: "mnu-arrange-front",
type: "arrange",
value: c_oAscDrawingLayerType.BringToFront
},
{
caption: this.textArrangeBack,
iconCls: "mnu-arrange-back",
type: "arrange",
value: c_oAscDrawingLayerType.SendToBack
},
{
caption: this.textArrangeForward,
iconCls: "mnu-arrange-forward",
type: "arrange",
value: c_oAscDrawingLayerType.BringForward
},
{
caption: this.textArrangeBackward,
iconCls: "mnu-arrange-backward",
type: "arrange",
value: c_oAscDrawingLayerType.SendBackward
},
{
caption: "--"
},
me.mnuGroupImg, me.mnuUnGroupImg, me.mnuShapeSeparator, me.mnuChartEdit, me.mnuShapeAdvanced]
});
this.menuParagraphVAlign = new Common.UI.MenuItem({
caption: this.vertAlignText,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [me.menuParagraphTop = new Common.UI.MenuItem({
caption: me.topCellText,
checkable: true,
toggleGroup: "popupparagraphvalign",
value: c_oAscVerticalTextAlign.TEXT_ALIGN_TOP
}), me.menuParagraphCenter = new Common.UI.MenuItem({
caption: me.centerCellText,
checkable: true,
toggleGroup: "popupparagraphvalign",
value: c_oAscVerticalTextAlign.TEXT_ALIGN_CTR
}), this.menuParagraphBottom = new Common.UI.MenuItem({
caption: me.bottomCellText,
checkable: true,
toggleGroup: "popupparagraphvalign",
value: c_oAscVerticalTextAlign.TEXT_ALIGN_BOTTOM
})]
})
});
me.menuAddHyperlinkShape = new Common.UI.MenuItem({
caption: me.txtInsHyperlink
});
me.menuEditHyperlinkShape = new Common.UI.MenuItem({
caption: me.editHyperlinkText
});
me.menuRemoveHyperlinkShape = new Common.UI.MenuItem({
caption: me.removeHyperlinkText
});
me.menuHyperlinkShape = new Common.UI.MenuItem({
caption: me.txtInsHyperlink,
menu: new Common.UI.Menu({
menuAlign: "tl-tr",
items: [me.menuEditHyperlinkShape, me.menuRemoveHyperlinkShape]
})
});
this.pmiTextAdvanced = new Common.UI.MenuItem({
caption: me.txtTextAdvanced
});
me.pmiTextCut = new Common.UI.MenuItem({
caption: me.txtCut,
value: "cut"
});
me.pmiTextCopy = new Common.UI.MenuItem({
caption: me.txtCopy,
value: "copy"
});
me.pmiTextPaste = new Common.UI.MenuItem({
caption: me.txtPaste,
value: "paste"
});
this.textInShapeMenu = new Common.UI.Menu({
items: [me.pmiTextCut, me.pmiTextCopy, me.pmiTextPaste, {
caption: "--"
},
me.menuParagraphVAlign, me.menuAddHyperlinkShape, me.menuHyperlinkShape, {
caption: "--"
},
me.pmiTextAdvanced]
});
this.funcMenu = new Common.UI.Menu({
items: [{
caption: "item 1"
},
{
caption: "item 2"
},
{
caption: "item 3"
},
{
caption: "item 4"
},
{
caption: "item 5"
}]
});
me.fireEvent("createdelayedelements", [me]);
},
setMenuItemCommentCaptionMode: function (edit) {
edit ? this.pmiAddComment.setCaption(this.txtEditComment) : this.pmiAddComment.setCaption(this.txtAddComment);
},
setLiveCommenting: function (value) {
this.isLiveCommenting = value;
},
txtSort: "Sort",
txtAscending: "Ascending",
txtDescending: "Descending",
txtFormula: "Insert Function",
txtInsHyperlink: "Hyperlink",
txtCut: "Cut",
txtCopy: "Copy",
txtPaste: "Paste",
txtInsert: "Insert",
txtDelete: "Delete",
txtClear: "Clear",
txtClearAll: "All",
txtClearText: "Text",
txtClearFormat: "Format",
txtClearHyper: "Hyperlink",
txtClearComments: "Comments",
txtShiftRight: "Shift cells right",
txtShiftLeft: "Shift cells left",
txtShiftUp: "Shift cells up",
txtShiftDown: "Shift cells down",
txtRow: "Entire Row",
txtColumn: "Entire Column",
txtColumnWidth: "Column Width",
txtRowHeight: "Row Height",
txtWidth: "Width",
txtHide: "Hide",
txtShow: "Show",
textArrangeFront: "Bring To Front",
textArrangeBack: "Send To Back",
textArrangeForward: "Bring Forward",
textArrangeBackward: "Send Backward",
txtArrange: "Arrange",
txtAddComment: "Add Comment",
txtEditComment: "Edit Comment",
txtUngroup: "Ungroup",
txtGroup: "Group",
topCellText: "Align Top",
centerCellText: "Align Center",
bottomCellText: "Align Bottom",
vertAlignText: "Vertical Alignment",
txtTextAdvanced: "Text Advanced Settings",
editHyperlinkText: "Edit Hyperlink",
removeHyperlinkText: "Remove Hyperlink",
editChartText: "Edit Data",
advancedShapeText: "Shape Advanced Settings",
chartText: "Chart Advanced Settings"
},
SSE.Views.DocumentHolder || {}));
});

View File

@@ -1,250 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.DocumentInfo", {
extend: "Ext.container.Container",
alias: "widget.ssedocumentinfo",
cls: "sse-documentinfo-body",
autoScroll: true,
requires: ["Ext.button.Button", "Ext.container.Container", "Common.plugin.ScrollPane", "Ext.form.Label", "Ext.XTemplate", "Ext.Date"],
uses: ["Common.view.DocumentAccessDialog"],
listeners: {
afterrender: function (cmp, eOpts) {
cmp.updateInfo(cmp.doc);
}
},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.infoObj = {
PageCount: 0,
WordsCount: 0,
ParagraphCount: 0,
SymbolsCount: 0,
SymbolsWSCount: 0
};
this.inProgress = false;
this.lblTitle = Ext.create("Ext.form.Label", {
text: "-",
height: 14
});
this.lblPlacement = Ext.create("Ext.form.Label", {
text: "-",
width: 150,
height: 14,
style: "text-align:left",
hideId: "element-to-hide"
});
this.lblDate = Ext.create("Ext.form.Label", {
text: "-",
width: 150,
height: 14,
style: "text-align:left",
hideId: "element-to-hide"
});
var userTpl = Ext.create("Ext.XTemplate", '<span class="userLink">{text:htmlEncode}</span>');
this.cntAuthor = Ext.create("Ext.container.Container", {
tpl: userTpl,
data: {
text: "-"
},
hideId: "element-to-hide"
});
var rightsTpl = Ext.create("Ext.XTemplate", "<table>", '<tpl for=".">', "<tr>", '<td style="padding: 0 20px 5px 0;"><span class="userLink">{user:htmlEncode}</span></td>', '<td style="padding: 0 20px 5px 0;">{permissions:htmlEncode}</td>', "</tr>", "</tpl>", "</table>");
this.cntRights = Ext.create("Ext.container.Container", {
tpl: rightsTpl,
hideId: "element-to-hide"
});
this.items = [{
xtype: "tbspacer",
height: 30
},
{
xtype: "container",
layout: {
type: "table",
columns: 2,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
style: "padding: 5px 10px;vertical-align: top;"
}
},
items: [{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtTitle,
style: "display: block;text-align: right;",
width: "100%"
},
this.lblTitle, {
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtAuthor,
style: "display: block;text-align: right;",
width: "100%"
},
this.cntAuthor, {
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtPlacement,
style: "display: block;text-align: right;",
width: "100%"
},
this.lblPlacement, {
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtDate,
style: "display: block;text-align: right;",
width: "100%"
},
this.lblDate, {
xtype: "tbspacer",
colspan: 2,
height: 5
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtRights,
style: "display: block;text-align: right;",
width: "100%"
},
this.cntRights, this.tbsRights = Ext.create("Ext.toolbar.Spacer", {
colspan: 2,
height: 5,
hideId: "element-to-hide"
}), {
xtype: "box"
},
this.btnEditRights = Ext.widget("button", {
id: "doc-info-set-rights",
cls: "asc-blue-button",
text: this.txtBtnAccessRights,
hideId: "element-to-hide",
listeners: {
click: Ext.bind(this._changeAccessRights, this)
}
})]
}];
Ext.apply(this, {
plugins: [{
ptype: "scrollpane",
areaSelector: ".x-container",
pluginId: "docInfoPluginId",
settings: {
enableKeyboardNavigation: true
}
}]
});
this.callParent(arguments);
},
updateInfo: function (doc) {
this.doc = doc;
if (!this.rendered) {
return;
}
doc = doc || {};
this.lblTitle.setText((doc.title) ? doc.title : "-");
if (doc.info) {
if (doc.info.author) {
this.cntAuthor.update({
text: doc.info.author
});
}
this._ShowHideInfoItem(this.cntAuthor, doc.info.author !== undefined && doc.info.author !== null);
if (doc.info.created) {
this.lblDate.setText(doc.info.created);
}
this._ShowHideInfoItem(this.lblDate, doc.info.created !== undefined && doc.info.created !== null);
if (doc.info.folder) {
this.lblPlacement.setText(doc.info.folder);
}
this._ShowHideInfoItem(this.lblPlacement, doc.info.folder !== undefined && doc.info.folder !== null);
if (doc.info.sharingSettings) {
this.cntRights.update(doc.info.sharingSettings);
}
this._ShowHideInfoItem(this.cntRights, doc.info.sharingSettings !== undefined && doc.info.sharingSettings !== null && this._readonlyRights !== true);
this._ShowHideInfoItem(this.tbsRights, doc.info.sharingSettings !== undefined && doc.info.sharingSettings !== null && this._readonlyRights !== true);
this._ShowHideInfoItem(this.btnEditRights, !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && this._readonlyRights !== true);
} else {
this._ShowHideDocInfo(false);
}
},
_ShowHideInfoItem: function (cmp, visible) {
var tr = cmp.getEl().up("tr");
if (tr) {
tr.setDisplayed(visible);
}
},
_ShowHideDocInfo: function (visible) {
var components = Ext.ComponentQuery.query('[hideId="element-to-hide"]', this);
for (var i = 0; i < components.length; i++) {
this._ShowHideInfoItem(components[i], visible);
}
},
stopUpdatingStatisticInfo: function () {},
setApi: function (o) {},
loadConfig: function (data) {
this.sharingSettingsUrl = data.config.sharingSettingsUrl;
return this;
},
_changeAccessRights: function (btn, event, opts) {
var win = Ext.widget("commondocumentaccessdialog", {
settingsurl: this.sharingSettingsUrl
});
var me = this;
win.on("accessrights", function (obj, rights) {
me.doc.info.sharingSettings = rights;
me.cntRights.update(rights);
});
win.show();
},
onLostEditRights: function () {
this._readonlyRights = true;
if (!this.rendered) {
return;
}
this._ShowHideInfoItem(this.cntRights, false);
this._ShowHideInfoItem(this.tbsRights, false);
this._ShowHideInfoItem(this.btnEditRights, false);
},
txtTitle: "Document Title",
txtAuthor: "Author",
txtPlacement: "Placement",
txtDate: "Creation Date",
txtRights: "Persons who have rights",
txtBtnAccessRights: "Change access rights"
});

View File

@@ -1,161 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.DocumentSettings", {
extend: "Ext.container.Container",
alias: "widget.ssedocumentsettings",
cls: "sse-documentsettings-panel",
autoScroll: true,
requires: ["Ext.container.Container", "Ext.XTemplate", "Ext.view.View", "Ext.data.Model", "Ext.data.Store", "Common.plugin.DataViewScrollPane", "SSE.view.MainSettingsGeneral", "SSE.view.MainSettingsPrint"],
listeners: {
show: function (cmp, eOpts) {
cmp.updateSettings();
}
},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this;
me.addEvents("savedocsettings");
this.addEvents("changemeasureunit");
me.generalSettings = Ext.widget("ssemainsettingsgeneral");
me.printSettings = Ext.widget("ssemainsettingsprint");
me.printSettings.updateMetricUnit();
var settingsPanels = [me.generalSettings, me.printSettings, 1];
me.generalSettings.addListener("savedocsettings", function () {
me.fireEvent("savedocsettings", me);
});
me.generalSettings.addListener("changemeasureunit", function () {
var value = window.localStorage.getItem("sse-settings-unit");
Common.MetricSettings.setCurrentMetric((value !== null) ? parseInt(value) : Common.MetricSettings.c_MetricUnits.cm);
me.printSettings.updateMetricUnit();
me.fireEvent("changemeasureunit", me);
});
this.menuStore = Ext.create("Ext.data.Store", {
fields: ["name", {
type: "int",
name: "panelindex"
},
"iconCls"],
data: [{
name: me.txtGeneral,
panelindex: 0,
iconCls: "mnu-settings-general"
},
{
name: me.txtPrint,
panelindex: 1,
iconCls: "mnu-print"
}]
});
var menuTpl = new Ext.XTemplate('<tpl for=".">', '<div class="thumb-wrap">', '<img class="icon {iconCls}" src="' + Ext.BLANK_IMAGE_URL + '" />', '<span class="caption">{name}</span>', "</div>", "</tpl>", '<div class="x-clear"></div>');
this.cntMenu = Ext.create("Ext.container.Container", {
layout: "fit",
cls: "help-menu-container",
width: 200,
items: [this.menuView = Ext.create("Ext.view.View", {
store: this.menuStore,
tpl: menuTpl,
singleSelect: true,
trackOver: true,
style: "overflow:visible;",
width: "100%",
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
cls: "help-menu-view",
listeners: {
afterrender: function (view) {
view.getSelectionModel().deselectOnContainerClick = false;
view.select(0);
},
selectionchange: function (model, selections) {
var record = model.getLastSelected();
if (record) {
if (settingsPanels[record.data.panelindex].updateSettings) {
settingsPanels[record.data.panelindex].updateSettings();
}
settingsPanels[record.data.panelindex].setVisible(true);
settingsPanels[settingsPanels[settingsPanels.length - 1]].setVisible(false);
settingsPanels[settingsPanels.length - 1] = record.data.panelindex;
}
}
},
plugins: [{
ptype: "dataviewscrollpane",
areaSelector: ".help-menu-view",
pluginId: "docHelpPluginId",
settings: {
enableKeyboardNavigation: true,
keyboardSpeed: 0.001
}
}]
})]
});
this.items = [{
xtype: "container",
layout: {
type: "hbox",
align: "stretch"
},
height: "100%",
items: [this.cntMenu, {
xtype: "tbspacer",
width: 2,
style: "border-left: 1px solid #C7C7C7"
},
{
xtype: "container",
flex: 1,
layout: "fit",
items: [me.generalSettings, me.printSettings],
listeners: {}
}]
}];
this.callParent(arguments);
},
setApi: function (o) {
if (o) {
this.api = o;
}
},
updateSettings: function () {
this.generalSettings && this.generalSettings.updateSettings();
},
setMode: function (mode) {
this.mode = mode;
this.generalSettings && this.generalSettings.setMode(this.mode);
},
txtGeneral: "General",
txtPrint: "Print"
});

View File

@@ -1,711 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var ACTIVE_TAB_NEXT = -255;
var ACTIVE_TAB_PREV = -254;
Ext.define("SSE.view.DocumentStatusInfo", {
extend: "Ext.container.Container",
alias: "widget.documentstatusinfo",
requires: ["Ext.form.field.Number", "Ext.button.Button", "Ext.form.Label", "Ext.toolbar.Spacer", "SSE.plugin.TabBarScroller", "SSE.plugin.TabReorderer"],
uses: ["Ext.tip.ToolTip", "Ext.menu.Menu", "SSE.view.SheetRenameDialog", "SSE.view.SheetCopyDialog", "Common.view.Participants"],
cls: "sse-documentstatusinfo",
height: 27,
layout: {
type: "hbox",
align: "middle"
},
style: "padding-left:5px;padding-right:40px;",
initComponent: function () {
var me = this;
this.permissions = {};
this.txtZoom = Ext.widget("label", {
id: "status-label-zoom",
text: Ext.String.format(me.zoomText, 0),
cls: "statusinfo-pages",
style: "cursor: pointer; white-space:nowrap; text-align: center;",
listeners: {
afterrender: function (ct) {
ct.getEl().on("mousedown", onShowZoomMenu, me);
ct.getEl().set({
"data-qtip": me.tipZoomFactor,
"data-qalign": "bl-tl?"
});
ct.setWidth(Ext.util.TextMetrics.measure(ct.getEl(), Ext.String.format(me.zoomText, 999)).width);
}
}
});
this.btnZoomIn = Ext.widget("button", {
id: "status-button-zoom-in",
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-zoomin",
style: "margin-left:5px;"
});
this.btnZoomOut = Ext.widget("button", {
id: "status-button-zoom-out",
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-zoomout",
style: "margin:0 5px 0 40px;"
});
this.userPanel = Ext.widget("statusinfoparticipants", {
pack: "end",
userIconCls: "sse-icon-statusinfo-users"
});
var onShowZoomMenu = function (event, elem) {
if (!elem.disabled) {
this.menuZoomTo.show();
this.menuZoomTo.showBy(me.txtZoom, "b-t", [0, -10]);
}
};
this.setApi = function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onZoomChanged", Ext.bind(me.onZoomChange, me));
this.api.asc_registerCallback("asc_onSheetsChanged", Ext.bind(me.updateInfo, me));
this.api.asc_registerCallback("asc_onEditCell", Ext.bind(me._onStartEditCell, me));
this.api.asc_registerCallback("asc_onActiveSheetChanged", Ext.bind(me._onActiveSheetChanged, me));
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(me.onCoAuthoringDisconnect, me));
this.api.asc_registerCallback("asc_onWorkbookLocked", Ext.bind(me.onWorkbookLocked, me));
this.api.asc_registerCallback("asc_onWorksheetLocked", Ext.bind(me.onWorksheetLocked, me));
this.userPanel.setApi(this.api);
return this;
};
var btnPageFirst = Ext.widget("button", {
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-page-scroller-btn btn-scroll-first"
});
var btnPageLast = Ext.widget("button", {
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-page-scroller-btn btn-scroll-last"
});
var btnPagePrev = Ext.widget("button", {
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-page-scroller-btn btn-scroll-prev"
});
var btnPageNext = Ext.widget("button", {
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-page-scroller-btn btn-scroll-next"
});
this.barWorksheets = Ext.widget("tabbar", {
dock: "bottom",
plain: true,
width: "100%",
style: "margin:-2px 0 0 5px;",
plugins: [{
ptype: "tabbarscroller",
pluginId: "tabbarscroller",
firstButton: btnPageFirst,
lastButton: btnPageLast,
prevButton: btnPagePrev,
nextButton: btnPageNext
},
{
ptype: "tabreorderer",
pluginId: "scheetreorderer"
}]
});
me.items = [btnPageFirst, btnPagePrev, btnPageNext, btnPageLast, {
xtype: "container",
flex: 1,
height: "100%",
items: [this.barWorksheets]
},
this.userPanel, this.btnZoomOut, this.txtZoom, this.btnZoomIn];
me.callParent(arguments);
},
onZoomChange: function (zf, type) {
switch (type) {
case 1:
case 2:
case 0:
default:
this.txtZoom.setText(Ext.String.format(this.zoomText, Math.floor((zf + 0.005) * 100)));
}
this.doLayout();
},
updateInfo: function () {
this.fireEvent("updatesheetsinfo", this);
this.barWorksheets.removeAll();
this.ssMenu.items.items[6].menu.removeAll();
this.ssMenu.items.items[6].setVisible(false);
if (this.api) {
var me = this;
var wc = this.api.asc_getWorksheetsCount(),
i = -1;
var hidentems = [],
items = [],
tab,
locked;
var sindex = this.api.asc_getActiveWorksheetIndex();
while (++i < wc) {
locked = me.api.asc_isWorksheetLockedOrDeleted(i);
tab = {
sheetindex: i,
text: me.api.asc_getWorksheetName(i).replace(/\s/g, "&nbsp;"),
reorderable: !locked,
closable: false,
cls: locked ? "coauth-locked" : undefined
};
this.api.asc_isWorksheetHidden(i) ? hidentems.push(tab) : items.push(tab);
if (sindex == i) {
sindex = items.length - 1;
}
}
var checkcount = items.length;
if (this.permissions.isEdit) {
items.push({
iconCls: "asc-add-page-icon",
width: 36,
closable: false,
reorderable: false,
disabled: me.api.asc_isWorkbookLocked(),
listeners: {
afterrender: function (cmp) {
cmp.getEl().on("click", me._onAddTabClick, me, {
preventDefault: true,
tabid: "tab-add-new"
});
}
}
});
}
if (hidentems.length) {
this.ssMenu.items.items[6].setVisible(true);
this.ssMenu.items.items[6].menu.add(hidentems);
}
if (checkcount) {
this.barWorksheets.add(items);
if (! (sindex < 0) && sindex < checkcount) {
this.barWorksheets.suspendEvents();
this.barWorksheets.setActiveTab(this.barWorksheets.items.items[sindex]);
this.barWorksheets.resumeEvents();
}
this.barWorksheets.getPlugin("tabbarscroller").scrollToLast();
this.barWorksheets.getPlugin("scheetreorderer").dd.unlock();
}
this.barWorksheets.enable(true);
this.txtZoom.setText(Ext.String.format(this.zoomText, this.api.asc_getZoom() * 100));
}
},
setMode: function (m) {
this.permissions = m;
this.userPanel.setMode(m);
var plugin = this.barWorksheets.getPlugin("scheetreorderer");
if (plugin) {
plugin.setDisabled(!this.permissions.isEdit);
}
},
setActiveWorksheet: function (index, opt) {
if (!index) {
var new_index = this.barWorksheets.activeTab ? this.barWorksheets.items.items.indexOf(this.barWorksheets.activeTab) : 0;
if (opt == ACTIVE_TAB_NEXT) {
if (! (++new_index < this.barWorksheets.items.items.length - 1)) {
new_index = 0;
}
} else {
if (opt == ACTIVE_TAB_PREV) {
if (--new_index < 0) {
new_index = this.barWorksheets.items.items.length - 2;
}
}
}
this.barWorksheets.setActiveTab(this.barWorksheets.items.items[new_index]);
}
},
_onTabClick: function (tabBar, tab, card, eOpts) {
if (! (tab.sheetindex < 0)) {
this.api.asc_showWorksheet(tab.sheetindex);
if (tab.newindex != undefined) {
var new_index = tab.newindex + 1;
new_index < this.barWorksheets.items.length - 1 ? new_index = this.barWorksheets.items.getAt(new_index).sheetindex : new_index = this.api.asc_getWorksheetsCount();
this.api.asc_moveWorksheet(new_index);
tab.newindex = undefined;
}
}
this.fireEvent("editcomplete", this);
},
_onAddTabClick: function (e, el, opt) {
e.stopEvent();
if (!e.target.parentNode.disabled && this.permissions.isEdit) {
this.api.asc_addWorksheet();
}
},
_onTabContextMenu: function (event, docElement, eOpts) {
if (this.api && this.permissions.isEdit) {
var tab = Ext.getCmp(eOpts.tabid);
if (tab && tab.sheetindex >= 0) {
if (!this.barWorksheets.activeTab || tab.id != this.barWorksheets.activeTab.id) {
this.barWorksheets.setActiveTab(tab);
}
var issheetlocked = this.api.asc_isWorksheetLockedOrDeleted(tab.sheetindex),
isdoclocked = this.api.asc_isWorkbookLocked();
this.ssMenu.items.items[0].setDisabled(isdoclocked);
this.ssMenu.items.items[1].setDisabled(issheetlocked);
this.ssMenu.items.items[2].setDisabled(issheetlocked);
this.ssMenu.items.items[3].setDisabled(issheetlocked);
this.ssMenu.items.items[4].setDisabled(issheetlocked);
this.ssMenu.items.items[5].setDisabled(issheetlocked);
this.ssMenu.items.items[6].setDisabled(isdoclocked);
this.api.asc_closeCellEditor();
this._showPopupMenu(this.ssMenu, {},
event, tab.getEl(), eOpts);
}
}
},
_onTabDblClick: function (event, docElement, eOpts) {
if (this.api && this.permissions.isEdit) {
var tab = Ext.getCmp(eOpts.tabid);
if (tab && tab.sheetindex >= 0) {
if (!this.api.asc_isWorksheetLockedOrDeleted(tab.sheetindex) && this.api.asc_getActiveWorksheetIndex() == tab.sheetindex) {
this._renameWorksheet();
}
}
}
},
_showPopupMenu: function (menu, value, event, docElement, eOpts) {
if (Ext.isDefined(menu)) {
Ext.menu.Manager.hideAll();
var showPoint = event.getXY();
showPoint[1] += 10;
if (Ext.isFunction(menu.initMenu)) {
menu.initMenu(value);
}
menu.show();
menu.showBy(docElement, "bl-tl");
}
},
_getNewSheetName: function (n) {
var nameindex = 1;
var firstname = this.strSheet;
var wc = this.api.asc_getWorksheetsCount(),
i = -1;
var items = [];
while (++i < wc) {
items.push(this.api.asc_getWorksheetName(i));
}
while (true) {
if (Ext.Array.contains(items, firstname + nameindex)) {
nameindex++;
if (nameindex > 100) {
return "";
}
} else {
break;
}
}
return firstname + nameindex;
},
_insertWorksheet: function () {
var name = this._getNewSheetName();
this.api.asc_insertWorksheet(name);
},
_deleteWorksheet: function () {
var me = this;
if (this.barWorksheets.items.items.length == 2) {
Ext.Msg.show({
title: this.textWarning,
msg: this.errorLastSheet,
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OK
});
} else {
Ext.create("Ext.window.MessageBox", {
buttonText: {
ok: "OK",
yes: "Yes",
no: "No",
cancel: me.textCancel
}
}).show({
title: this.textWarning,
msg: this.warnDeleteSheet,
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OKCANCEL,
fn: function (bid) {
if (bid == "ok") {
var index = me.api.asc_getActiveWorksheetIndex();
var uid = me.api.asc_getActiveWorksheetId();
if (!me.api.asc_deleteWorksheet()) {
Ext.Msg.show({
title: me.textError,
msg: me.msgDelSheetError,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
} else {
me.fireEvent("removeworksheet", index, uid);
}
}
}
});
}
},
_renameWorksheet: function () {
var me = this;
var wc = me.api.asc_getWorksheetsCount(),
items = [],
i = -1;
while (++i < wc) {
items.push(me.api.asc_getWorksheetName(i));
}
var win = Ext.create("SSE.view.SheetRenameDialog", {
title: "Rename",
renameindex: me.api.asc_getActiveWorksheetIndex(),
names: items
});
win.addListener("onmodalresult", function (o, mr, s) {
if (mr) {
me.api.asc_renameWorksheet(s);
me.barWorksheets.activeTab.setText(s.replace(/\s/g, "&nbsp;"));
}
me.fireEvent("editcomplete", me);
},
false);
win.show();
var xy = win.getEl().getAlignToXY(me.barWorksheets.activeTab.getEl(), "bl-tl");
win.showAt(xy[0], xy[1] - 4);
},
_getSheetCopyName: function (n) {
var result = /^(.*)\((\d)\)$/.exec(n);
var nameindex = 2;
var firstname = result ? result[1] : n + " ";
var tn = firstname + "(" + nameindex + ")";
var wc = this.api.asc_getWorksheetsCount(),
i = -1;
var items = [];
while (++i < wc) {
items.push(this.api.asc_getWorksheetName(i));
}
while (true) {
if (Ext.Array.contains(items, tn)) {
nameindex++;
if (nameindex > 100) {
return "";
}
tn = firstname + "(" + nameindex + ")";
} else {
break;
}
}
return tn;
},
_copyWorksheet: function (cut) {
var me = this;
var wc = me.api.asc_getWorksheetsCount(),
i = -1;
var items = [];
while (++i < wc) {
if (!this.api.asc_isWorksheetHidden(i)) {
items.push({
name: me.api.asc_getWorksheetName(i).replace(/\s/g, "&nbsp;"),
sheetindex: i
});
}
}
if (items.length) {
items.push({
name: cut ? me.itemMoveToEnd : me.itemCopyToEnd,
sheetindex: -255
});
}
var win = Ext.create("SSE.view.SheetCopyDialog", {
title: cut ? me.itemMoveWS : me.itemCopyWS,
listtitle: cut ? this.textMoveBefore : undefined,
names: items
});
win.addListener("onmodalresult", function (o, mr, i) {
if (mr && me.api) {
if (cut) {
me.api.asc_moveWorksheet(i == -255 ? wc : i);
} else {
var new_text = me._getSheetCopyName(me.api.asc_getWorksheetName(me.api.asc_getActiveWorksheetIndex()));
me.api.asc_copyWorksheet(i == -255 ? wc : i, new_text);
}
}
me.fireEvent("editcomplete", me);
},
false);
win.show();
},
_showWorksheet: function (show, index) {
Ext.menu.Manager.hideAll();
if (!show && this.barWorksheets.items.items.length == 2) {
Ext.Msg.show({
title: this.textWarning,
msg: this.errorLastSheet,
icon: Ext.Msg.WARNING,
buttons: Ext.Msg.OK
});
return;
}
this.api[show ? "asc_showWorksheet" : "asc_hideWorksheet"](index);
},
_onStartEditCell: function (isstart) {
this.txtZoom.setDisabled(isstart);
this.btnZoomIn.setDisabled(isstart);
this.btnZoomOut.setDisabled(isstart);
},
_onActiveSheetChanged: function (index) {
var seltab, item, ic = this.barWorksheets.items.items.length;
while (! (--ic < 0)) {
item = this.barWorksheets.items.items[ic];
if (item.sheetindex == index) {
seltab = item;
break;
}
}
if (seltab) {
this.barWorksheets.setActiveTab(seltab);
}
},
createDelayedElements: function () {
var me = this;
this.btnZoomIn.getEl().set({
"data-qtip": me.tipZoomIn,
"data-qalign": "bl-tl?"
});
this.btnZoomOut.getEl().set({
"data-qtip": me.tipZoomOut,
"data-qalign": "bl-tl?"
});
this.btnZoomIn.on("click", function () {
var f = me.api.asc_getZoom() + 0.1;
if (f > 0 && !(f > 2)) {
me.api.asc_setZoom(f);
}
});
this.btnZoomOut.on("click", function () {
var f = me.api.asc_getZoom() - 0.1;
if (! (f < 0.5)) {
me.api.asc_setZoom(f);
}
});
this.barWorksheets.on("change", this._onTabClick, this);
this.barWorksheets.getEl().on({
contextmenu: {
fn: function (event, docElement, eOpts) {
var tab = /x-tab(?!\S)/.test(docElement.className) ? docElement : Ext.fly(docElement).up(".x-tab");
tab && me._onTabContextMenu(event, docElement, {
tabid: tab.id
});
},
preventDefault: true
},
dblclick: {
fn: function (event, docElement, eOpts) {
var tab = /x-tab(?!\S)/.test(docElement.className) ? docElement : Ext.fly(docElement).up(".x-tab");
tab && me._onTabDblClick(event, docElement, {
tabid: tab.id
});
},
preventDefault: true
}
});
this.barWorksheets.getPlugin("scheetreorderer").on({
drop: function (obj, tabbar, tab, idx, nidx, opts) {
if (nidx != idx) {
obj.lock();
tab.newindex = nidx;
tab.reorderable = false;
}
}
});
this.menuZoomTo = Ext.widget("menu", {
plain: true,
bodyCls: "status-zoom-menu",
minWidth: 100,
listeners: {
click: function (menu, item) {
if (me.api) {
me.api.asc_setZoom(item.fz);
}
me.onZoomChange(item.fz);
me.fireEvent("editcomplete", me);
}
},
items: [{
text: "50%",
fz: 0.5
},
{
text: "75%",
fz: 0.75
},
{
text: "100%",
fz: 1
},
{
text: "125%",
fz: 1.25
},
{
text: "150%",
fz: 1.5
},
{
text: "175%",
fz: 1.75
},
{
text: "200%",
fz: 2
}]
});
this.ssMenu = Ext.widget("menu", {
showSeparator: false,
bodyCls: "no-icons",
listeners: {
hide: function (cnt, eOpt) {
me.fireEvent("editcomplete", me);
},
click: function (menu, item) {
if (!item.isDisabled()) {
if (item.action == "ins") {
me._insertWorksheet();
} else {
if (item.action == "del") {
me._deleteWorksheet();
} else {
if (item.action == "ren") {
me._renameWorksheet();
} else {
if (item.action == "copy") {
me._copyWorksheet(false);
} else {
if (item.action == "move") {
me._copyWorksheet(true);
} else {
if (item.action == "hide") {
me._showWorksheet(false);
}
}
}
}
}
}
}
}
},
items: [{
text: this.itemInsertWS,
action: "ins"
},
{
text: this.itemDeleteWS,
action: "del"
},
{
text: this.itemRenameWS,
action: "ren"
},
{
text: this.itemCopyWS,
action: "copy"
},
{
text: this.itemMoveWS,
action: "move"
},
{
text: this.itemHideWS,
action: "hide"
},
{
text: this.itemHidenWS,
hideOnClick: false,
menu: {
showSeparator: false,
items: [],
listeners: {
click: function (menu, item) {
me._showWorksheet(true, item.sheetindex);
}
}
}
}]
});
},
onCoAuthoringDisconnect: function () {
this.permissions.isEdit = false;
this.barWorksheets.getPlugin("scheetreorderer").setDisabled(true);
this.updateInfo();
},
onWorkbookLocked: function (locked) {
this.barWorksheets[locked ? "addCls" : "removeCls"]("coauth-locked");
var item, ic = this.barWorksheets.items.items.length;
while (! (--ic < 0)) {
item = this.barWorksheets.items.items[ic];
if (item.sheetindex >= 0) {
if (locked) {
item.reorderable = false;
} else {
item.reorderable = !this.api.asc_isWorksheetLockedOrDeleted(item.sheetindex);
}
} else {
item.setDisabled(locked);
}
}
},
onWorksheetLocked: function (index, locked) {
var tabs = this.barWorksheets.items.items;
for (var i = 0; i < tabs.length; i++) {
if (index == tabs[i].sheetindex) {
tabs[i][locked ? "addCls" : "removeCls"]("coauth-locked");
tabs[i].reorderable = !locked;
break;
}
}
},
zoomText: "Zoom {0}%",
tipZoomIn: "Zoom In",
tipZoomOut: "Zoom Out",
tipZoomFactor: "Magnification",
txtFirst: "First Sheet",
txtLast: "Last Sheet",
txtPrev: "Previous Sheet",
txtNext: "Next Sheet",
itemInsertWS: "Insert",
itemDeleteWS: "Delete",
itemRenameWS: "Rename",
itemCopyWS: "Copy",
itemMoveWS: "Move",
itemHideWS: "Hide",
itemHidenWS: "Hiden",
itemCopyToEnd: "(Copy to end)",
itemMoveToEnd: "(Move to end)",
msgDelSheetError: "Can't delete the worksheet.",
textMoveBefore: "Move before sheet",
warnDeleteSheet: "The worksheet maybe has data. Proceed operation?",
errorLastSheet : "Workbook must have at least one visible worksheet.",
strSheet: "Sheet",
textError: "Error",
textWarning: "Warning",
textCancel: "Cancel"
});

View File

@@ -1,391 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.File", {
extend: "Ext.panel.Panel",
alias: "widget.ssefile",
cls: "sse-file-body",
layout: "card",
btnSaveCaption: "Save",
btnDownloadCaption: "Download as...",
btnInfoCaption: "Document Info...",
btnCreateNewCaption: "Create New...",
btnRecentFilesCaption: "Open Recent...",
btnPrintCaption: "Print",
btnHelpCaption: "Help...",
btnReturnCaption: "Back to Document",
btnToEditCaption: "Edit Document",
btnBackCaption: "Go to Documents",
btnSettingsCaption: "Advanced Settings...",
toolbarWidth: 260,
activeBtn: undefined,
uses: ["Ext.container.Container", "Ext.toolbar.Toolbar", "Ext.button.Button", "SSE.view.DocumentInfo", "SSE.view.RecentFiles", "SSE.view.CreateFile", "SSE.view.DocumentHelp", "SSE.view.DocumentSettings"],
listeners: {
afterrender: function (Component, eOpts) {
var cnt = this.ownerCt;
if (Ext.isDefined(cnt)) {
cnt.addListener("show", Ext.Function.bind(this._onShow, this));
}
}
},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this;
this.addEvents("editdocument", "downloadas");
this.callParent(arguments);
},
loadConfig: function (data) {
this.editorConfig = data.config;
},
_onShow: function () {
if (this.activeBtn === undefined) {
this.activeBtn = this.btnDownloadAs.isVisible() ? this.btnCreateNew : this.btnDocumentInfo;
}
if (this.activeBtn == this.btnDocumentInfo) {
this.getLayout().setActiveItem(this.cardDocumentInfo);
} else {
if (this.activeBtn == this.btnDocumentSettings) {
this.getLayout().setActiveItem(this.cardDocumentSettings);
this.cardDocumentSettings.updateSettings();
} else {
if (this.activeBtn == this.btnCreateNew) {
if (this.btnDownloadAs.isVisible()) {
this.getLayout().setActiveItem(this.cardDownloadAs);
this.activeBtn = this.btnDownloadAs;
} else {
this.getLayout().setActiveItem(this.cardDocumentInfo);
this.activeBtn = this.btnDocumentInfo;
}
}
}
}
this.redrawButton(this.activeBtn);
},
buildDockedItems: function () {
this.btnSave = Ext.create("Ext.button.Button", {
id: "file-button-save",
text: this.btnSaveCaption,
textAlign: "left",
enableToggle: true,
cls: "asc-filemenu-btn",
padding: "0 27px",
height: 27,
listeners: {
click: Ext.bind(function (btnCall) {
if (btnCall.pressed) {
this.api = this.ownerCt.getApi();
if (this.api) {
this.redrawButton(btnCall);
this.api.asc_Save();
this.closeMenu();
}
Common.component.Analytics.trackEvent("Save");
Common.component.Analytics.trackEvent("File Menu", "Save");
}
},
this)
}
});
this.btnPrint = this.btnSave.cloneConfig({
id: "file-button-print",
text: this.btnPrintCaption,
listeners: {
click: Ext.bind(function (btnCall) {
if (btnCall.pressed) {
this.api = this.ownerCt.getApi();
if (this.api) {
this.api.asc_Print();
this.closeMenu();
}
Common.component.Analytics.trackEvent("Print");
Common.component.Analytics.trackEvent("File Menu", "Print");
}
},
this)
}
});
this.btnToEdit = this.btnSave.cloneConfig({
id: "file-button-edit",
text: this.btnToEditCaption,
listeners: {
click: Ext.bind(function (btnCall) {
this.redrawButton(btnCall);
if (btnCall.pressed) {
this.closeMenu();
this.fireEvent("editdocument");
Common.component.Analytics.trackEvent("Edit");
Common.component.Analytics.trackEvent("File Menu", "Edit");
}
},
this)
}
});
this.btnDownloadAs = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnDownloadCaption, this.cardDownloadAs), {
id: "file-button-download"
}));
this.btnDocumentInfo = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnInfoCaption, this.cardDocumentInfo), {
id: "file-button-info"
}));
this.btnDocumentSettings = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnSettingsCaption, this.cardDocumentSettings), {
id: "file-button-settings"
}));
this.btnBack = this.btnPrint.cloneConfig({
id: "file-button-back",
text: this.btnBackCaption,
listeners: {
click: Ext.bind(function (btnCall) {
this.redrawButton(btnCall);
if (btnCall.pressed) {
Common.Gateway.goBack();
this.closeMenu();
}
},
this)
}
});
this.btnHelp = Ext.create("Ext.button.Button", this.getFileMenuButton(this.btnHelpCaption, this.cardHelp));
this.btnReturn = Ext.create("Ext.button.Button", {
id: "file-button-return",
text: this.btnReturnCaption,
textAlign: "left",
enableToggle: true,
cls: "asc-filemenu-btn",
padding: "0 27px",
height: 27,
listeners: {
click: Ext.bind(function (btnCall) {
if (btnCall.pressed) {
this.closeMenu();
Common.component.Analytics.trackEvent("File Menu", "Return");
}
},
this)
}
});
this.btnCreateNew = Ext.create("Ext.button.Button", Ext.apply(this.getFileMenuButton(this.btnCreateNewCaption, this.cardCreateNew), {
id: "file-button-createnew",
label: "Create",
listeners: {},
enableToggle: false
}));
this.btnOpenRecent = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnRecentFilesCaption, this.cardRecentFiles), {
id: "file-button-recentfiles",
label: "Recent"
}));
this.tbFileMenu = Ext.create("Ext.toolbar.Toolbar", {
dock: "left",
layout: {
type: "vbox",
align: "stretch"
},
cls: "sse-file-toolbar",
vertical: true,
width: this.toolbarWidth,
defaults: {
height: 22,
width: "100%"
},
items: [{
xtype: "container",
height: 15
},
this.btnReturn, this.getSeparator(), this.btnSave, this.btnToEdit, this.btnDownloadAs, this.btnPrint, this.getSeparator(), this.btnOpenRecent, this.btnCreateNew, this.getSeparator(), this.btnDocumentInfo, this.getSeparator(), this.btnDocumentSettings, this.getSeparator(), this.btnHelp, this.getSeparator(), this.btnBack]
});
return this.tbFileMenu;
},
setApi: function (api) {
this.api = api;
},
getSeparator: function () {
return {
xtype: "container",
html: '<hr class="sse-file-separator" />'
};
},
getFileMenuButton: function (caption, card) {
return {
text: caption,
textAlign: "left",
enableToggle: true,
cls: "asc-filemenu-btn",
padding: "0 27px",
height: 27,
listeners: {
click: Ext.Function.bind(this._itemClick, this, [card], true),
toggle: Ext.Function.bind(this._itemTogglge, this)
}
};
},
redrawButton: function (btnCall) {
var tb = this.tbFileMenu;
for (var i = 0; i < tb.items.length; i++) {
var btn = tb.items.items[i];
if (btn.componentCls === "x-btn") {
if (btn.id != btnCall.id && btn.pressed) {
btn.toggle(false, true);
}
}
}
btnCall.toggle(true, true);
},
closeMenu: function () {
this.ownerCt.closeMenu();
},
_itemClick: function (btnCall, event, opt, card) {
if (btnCall.pressed) {
if (this.activeBtn != btnCall) {
this.getLayout().setActiveItem(card);
this.activeBtn = btnCall;
}
Common.component.Analytics.trackEvent("File Menu", btnCall.label);
}
},
_itemTogglge: function (btnCall) {
this.redrawButton(btnCall);
},
applyMode: function () {
this.btnDownloadAs.setVisible(this.mode.canDownload);
this.hkSaveAs[this.mode.canDownload ? "enable" : "disable"]();
this.hkSave[this.mode.isEdit ? "enable" : "disable"]();
this.hkHelp.enable();
this.btnSave.setVisible(this.mode.isEdit);
this.btnToEdit.setVisible(this.mode.canEdit && this.mode.isEdit === false);
this.btnDocumentSettings.setVisible(this.mode.isEdit);
this.tbFileMenu.items.items[14].setVisible(this.mode.isEdit);
this.btnBack.setVisible(this.mode.canBack);
this.tbFileMenu.items.items[16].setVisible(this.mode.canBack);
this.btnOpenRecent.setVisible(this.mode.canOpenRecent);
this.btnCreateNew.setVisible(this.mode.canCreateNew);
this.tbFileMenu.items.items[10].setVisible(this.mode.canCreateNew || this.mode.canOpenRecent);
this.cardDocumentSettings.setMode(this.mode);
},
setMode: function (mode, delay) {
if (mode.isDisconnected) {
this.mode.canEdit = this.mode.isEdit = false;
this.mode.canOpenRecent = this.mode.canCreateNew = false;
} else {
this.mode = mode;
}
if (!delay) {
this.applyMode();
}
},
createDelayedElements: function () {
var me = this;
this.hkSaveAs = new Ext.util.KeyMap(document, [{
key: "s",
ctrl: true,
shift: true,
defaultEventAction: "stopEvent",
fn: function () {
if (me.ownerCt && me.ownerCt.isVisible()) {
me.btnDownloadAs.toggle(true);
me.btnDownloadAs.fireEvent("click", me.btnDownloadAs);
}
}
}]);
this.hkSave = new Ext.util.KeyMap(document, [{
key: "s",
ctrl: true,
shift: false,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
var api = me.ownerCt.getApi();
if (api) {
api.asc_Save();
}
}
}
}]);
this.hkHelp = new Ext.util.KeyMap(document, {
key: Ext.EventObject.F1,
ctrl: false,
shift: false,
defaultEventAction: "stopEvent",
fn: function () {
if (me.ownerCt && me.ownerCt.isVisible()) {
me.btnHelp.toggle(true);
me.btnHelp.fireEvent("click", me.btnHelp, [me.cardHelp]);
}
}
});
var docInfo = [{
name: "XLSX",
imgCls: "tabular-format btn-xlsx",
type: c_oAscFileType.XLSX
}];
this.cardDownloadAs = Ext.widget("container", {
cls: "sse-file-table",
layout: {
type: "table",
columns: 2
}
});
Ext.each(docInfo, function (item) {
this.cardDownloadAs.add({
xtype: "container",
items: [{
xtype: "button",
id: "file-format-" + item.name,
cls: item.imgCls + " download-button-style",
docType: item.type,
width: 102,
height: 129,
margin: "65px 25px 0 25px"
}]
});
},
this);
this.cardDocumentInfo = Ext.widget("ssedocumentinfo");
this.cardCreateNew = Ext.widget("ssecreatenew");
this.cardRecentFiles = Ext.widget("sserecentfiles");
this.cardHelp = Ext.widget("ssedocumenthelp");
this.cardDocumentSettings = Ext.widget("ssedocumentsettings");
this.cardDocumentSettings.addListener("savedocsettings", Ext.bind(this.closeMenu, this));
this.add([this.cardDownloadAs, this.cardHelp, this.cardDocumentInfo, this.cardRecentFiles, this.cardDocumentSettings]);
this.addDocked(this.buildDockedItems());
this.setConfig();
this.applyMode();
},
setConfig: function () {
this.cardHelp.setLangConfig(this.editorConfig.lang);
if (this.editorConfig.templates && this.editorConfig.templates.length > 0) {
this.btnCreateNew.enableToggle = true;
this.btnCreateNew.on("click", Ext.bind(this._itemClick, this, [this.cardCreateNew], true));
this.btnCreateNew.on("toggle", Ext.bind(this._itemTogglge, this));
}
}
});

View File

@@ -0,0 +1,243 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/FileMenu.template", "underscore", "common/main/lib/component/BaseView"], function (tpl, _) {
SSE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({
el: "#file-menu-panel",
template: _.template(tpl),
events: function () {
return {
"click .fm-btn": _.bind(function (event) {
var $item = $(event.currentTarget);
if (!$item.hasClass("active")) {
$(".fm-btn", this.el).removeClass("active");
$item.addClass("active");
}
var item = _.findWhere(this.items, {
el: event.currentTarget
});
if (item) {
var panel = this.panels[item.options.action];
this.fireEvent("item:click", [this, item.options.action, !!panel]);
if (panel) {
this.$el.find(".content-box:visible").hide();
this.active = item.options.action;
panel.show();
}
}
},
this)
};
},
initialize: function () {},
render: function () {
this.$el = $(this.el);
this.$el.html(this.template());
this.items = [];
this.items.push(new Common.UI.MenuItem({
el: $("#fm-btn-return", this.el),
action: "back",
caption: this.btnReturnCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-save", this.el),
action: "save",
caption: this.btnSaveCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-edit", this.el),
action: "edit",
caption: this.btnToEditCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-download", this.el),
action: "saveas",
caption: this.btnDownloadCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-print", this.el),
action: "print",
caption: this.btnPrintCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-recent", this.el),
action: "recent",
caption: this.btnRecentFilesCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-create", this.el),
action: "new",
caption: this.btnCreateNewCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-info", this.el),
action: "info",
caption: this.btnInfoCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-settings", this.el),
action: "opts",
caption: this.btnSettingsCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-help", this.el),
action: "help",
caption: this.btnHelpCaption,
canFocused: false
}), new Common.UI.MenuItem({
el: $("#fm-btn-back", this.el),
action: "exit",
caption: this.btnBackCaption,
canFocused: false
}));
var me = this;
this.panels = {};
require(["spreadsheeteditor/main/app/view/FileMenuPanels"], function () {
me.panels = {
"saveas": (new SSE.Views.FileMenuPanels.ViewSaveAs({
menu: me
})).render(),
"opts": (new SSE.Views.FileMenuPanels.Settings({
menu: me
})).render(),
"info": (new SSE.Views.FileMenuPanels.DocumentInfo({
menu: me
})).render(),
"help": (new SSE.Views.FileMenuPanels.Help({
menu: me
})).render()
};
me.$el.find(".content-box").hide();
});
return this;
},
show: function (panel) {
if (this.isVisible() && panel === undefined) {
return;
}
if (!panel) {
panel = this.active || (this.mode.canDownload ? "saveas" : "info");
}
this.$el.show();
this.selectMenu(panel);
if (this.mode.isEdit) {
SSE.getController("Toolbar").DisableToolbar(true);
}
this.api.asc_enableKeyEvents(false);
},
hide: function () {
this.$el.hide();
if (this.mode.isEdit) {
SSE.getController("Toolbar").DisableToolbar(false);
}
this.api.asc_enableKeyEvents(true);
},
applyMode: function () {
this.items[0][this.mode.canBack ? "show" : "hide"]();
this.items[0].$el.find("+.devider")[this.mode.canBack ? "show" : "hide"]();
this.items[5][this.mode.canOpenRecent ? "show" : "hide"]();
this.items[6][this.mode.canCreateNew ? "show" : "hide"]();
this.items[6].$el.find("+.devider")[this.mode.canCreateNew ? "show" : "hide"]();
this.items[3][this.mode.canDownload ? "show" : "hide"]();
this.items[1][this.mode.isEdit ? "show" : "hide"]();
this.items[2][!this.mode.isEdit && this.mode.canEdit ? "show" : "hide"]();
this.items[8][this.mode.isEdit ? "show" : "hide"]();
this.items[8].$el.find("+.devider")[this.mode.isEdit ? "show" : "hide"]();
this.panels["opts"].setMode(this.mode);
this.panels["info"].setMode(this.mode).updateInfo(this.document);
if (this.mode.canCreateNew) {
if (this.mode.templates && this.mode.templates.length) {
$("a", this.items[6].$el).text(this.btnCreateNewCaption + "...");
this.panels["new"] = ((new SSE.Views.FileMenuPanels.CreateNew({
menu: this,
docs: this.mode.templates
})).render());
}
}
if (this.mode.canOpenRecent) {
if (this.mode.recent) {
this.panels["recent"] = (new SSE.Views.FileMenuPanels.RecentFiles({
menu: this,
recent: this.mode.recent
})).render();
}
}
this.panels["help"].setLangConfig(this.mode.lang);
},
setMode: function (mode, delay) {
if (mode.isDisconnected) {
this.mode.canEdit = this.mode.isEdit = false;
this.mode.canOpenRecent = this.mode.canCreateNew = false;
} else {
this.mode = mode;
}
if (!delay) {
this.applyMode();
}
},
setApi: function (api) {
this.api = api;
},
loadDocument: function (data) {
this.document = data.doc;
},
selectMenu: function (menu) {
if (menu) {
var item = this._getMenuItem(menu),
panel = this.panels[menu];
if (item && panel) {
$(".fm-btn", this.el).removeClass("active");
item.$el.addClass("active");
this.$el.find(".content-box:visible").hide();
panel.show();
this.active = menu;
}
}
},
_getMenuItem: function (action) {
return _.find(this.items, function (item) {
return item.options.action == action;
});
},
btnSaveCaption: "Save",
btnDownloadCaption: "Download as...",
btnInfoCaption: "Document Info...",
btnCreateNewCaption: "Create New",
btnRecentFilesCaption: "Open Recent...",
btnPrintCaption: "Print",
btnHelpCaption: "Help...",
btnReturnCaption: "Back to Document",
btnToEditCaption: "Edit Document",
btnBackCaption: "Go to Documents",
btnSettingsCaption: "Advanced Settings..."
},
SSE.Views.FileMenu || {}));
});

View File

@@ -0,0 +1,878 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["common/main/lib/view/DocumentAccessDialog"], function () { ! SSE.Views.FileMenuPanels && (SSE.Views.FileMenuPanels = {});
SSE.Views.FileMenuPanels.ViewSaveAs = Common.UI.BaseView.extend({
el: "#panel-saveas",
menu: undefined,
formats: [[{
name: "XLSX",
imgCls: "xlsx",
type: c_oAscFileType.XLSX
},
{
name: "ODS",
imgCls: "ods",
type: c_oAscFileType.ODS
}], [{
name: "CSV",
imgCls: "csv",
type: c_oAscFileType.CSV
},
{
name: "HTML",
imgCls: "html",
type: c_oAscFileType.HTML
}]],
template: _.template(["<table><tbody>", "<% _.each(rows, function(row) { %>", "<tr>", "<% _.each(row, function(item) { %>", '<td><span class="btn-doc-format <%= item.imgCls %>" /></td>', "<% }) %>", "</tr>", "<% }) %>", "</tbody></table>"].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]);
}
}
}
});
SSE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: "#panel-settings",
menu: undefined,
template: _.template(['<div style="width:100%; height:100%; position: relative;">', '<div id="id-settings-menu" style="position: absolute; width:200px; top: 0; bottom: 0;" class="no-padding"></div>', '<div id="id-settings-content" style="position: absolute; left: 200px; top: 0; right: 0; bottom: 0;" class="no-padding">', '<div id="panel-settings-general" style="width:100%; height:100%;" class="no-padding main-settings-panel active"></div>', '<div id="panel-settings-print" style="width:100%; height:100%;" class="no-padding main-settings-panel"></div>', "</div>", "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.menu = options.menu;
},
render: function () {
$(this.el).html(this.template());
this.generalSettings = new SSE.Views.FileMenuPanels.MainSettingsGeneral({
menu: this.menu
});
this.generalSettings.options = {
alias: "MainSettingsGeneral"
};
this.generalSettings.render();
this.printSettings = SSE.getController("Print").getView("MainSettingsPrint");
this.printSettings.menu = this.menu;
this.printSettings.render($("#panel-settings-print"));
this.viewSettingsPicker = new Common.UI.DataView({
el: $("#id-settings-menu"),
store: new Common.UI.DataViewStore([{
name: this.txtGeneral,
panel: this.generalSettings,
iconCls: "mnu-settings-general",
selected: true
},
{
name: this.txtPrint,
panel: this.printSettings,
iconCls: "mnu-print"
}]),
itemTemplate: _.template(['<div id="<%= id %>" class="settings-item-wrap">', '<div><span class="settings-icon <%= iconCls %>"/><span class="caption"><%= name %></span></div>', "</div>"].join(""))
});
this.viewSettingsPicker.on("item:select", _.bind(function (dataview, itemview, record) {
var panel = record.get("panel");
$("#id-settings-content > div").removeClass("active");
panel.$el.addClass("active");
panel.show();
},
this));
return this;
},
show: function () {
Common.UI.BaseView.prototype.show.call(this, arguments);
var item = this.viewSettingsPicker.getSelectedRec();
if (item[0]) {
item[0].get("panel").show();
}
},
setMode: function (mode) {
this.mode = mode;
this.generalSettings && this.generalSettings.setMode(this.mode);
},
txtGeneral: "General",
txtPrint: "Print"
},
SSE.Views.FileMenuPanels.Settings || {}));
SSE.Views.MainSettingsPrint = Common.UI.BaseView.extend(_.extend({
menu: undefined,
template: _.template(['<table class="main"><tbody>', "<tr>", '<td class="left"><label><%= scope.textSettings %></label></td>', '<td class="right"><div id="advsettings-print-combo-sheets" class="input-group-nr" /></td>', "</tr>", '<tr class="divider"></tr>', '<tr class="divider"></tr>', "<tr>", '<td class="left"><label><%= scope.textPageSize %></label></td>', '<td class="right"><div id="advsettings-print-combo-pages" class="input-group-nr" /></td>', "</tr>", '<tr class="divider"></tr>', "<tr>", '<td class="left"><label><%= scope.textPageOrientation %></label></td>', '<td class="right"><span id="advsettings-print-combo-orient" /></td>', "</tr>", '<tr class="divider"></tr>', "<tr>", '<td class="left" style="vertical-align: top;"><label><%= scope.strMargins %></label></td>', '<td class="right" style="vertical-align: top;"><div id="advsettings-margins">', '<table cols="2" class="no-padding">', "<tr>", "<td><label><%= scope.strTop %></label></td>", "<td><label><%= scope.strBottom %></label></td>", "</tr>", "<tr>", '<td><div id="advsettings-spin-margin-top"></div></td>', '<td><div id="advsettings-spin-margin-bottom"></div></td>', "</tr>", "<tr>", "<td><label><%= scope.strLeft %></label></td>", "<td><label><%= scope.strRight %></label></td>", "</tr>", "<tr>", '<td><div id="advsettings-spin-margin-left"></div></td>', '<td><div id="advsettings-spin-margin-right"></div></td>', "</tr>", "</table>", "</div></td>", "</tr>", '<tr class="divider"></tr>', "<tr>", '<td class="left" style="vertical-align: top;"><label><%= scope.strPrint %></label></td>', '<td class="right" style="vertical-align: top;"><div id="advsettings-print">', '<div id="advsettings-print-chb-grid" style="margin-bottom: 10px;"/>', '<div id="advsettings-print-chb-rows"/>', "</div></td>", "</tr>", '<tr class="divider"></tr>', '<tr class="divider"></tr>', "<tr>", '<td class="left"></td>', '<td class="right"><button id="advsettings-print-button-save" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>', "</tr>", "</tbody></table>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.menu = options.menu;
this.spinners = [];
this._initSettings = true;
},
render: function (parentEl) {
if (parentEl) {
this.setElement(parentEl, false);
}
$(this.el).html(this.template({
scope: this
}));
this.cmbSheet = new Common.UI.ComboBox({
el: $("#advsettings-print-combo-sheets"),
style: "width: 260px;",
menuStyle: "min-width: 260px;max-height: 280px;",
editable: false,
cls: "input-group-nr",
data: [{
value: -255,
displayValue: this.strAllSheets
}]
});
this.cmbPaperSize = new Common.UI.ComboBox({
el: $("#advsettings-print-combo-pages"),
style: "width: 260px;",
menuStyle: "max-height: 280px; min-width: 260px;",
editable: false,
cls: "input-group-nr",
data: [{
value: "215.9|279.4",
displayValue: "US Letter (21,59cm x 27,94cm)"
},
{
value: "215.9|355.6",
displayValue: "US Legal (21,59cm x 35,56cm)"
},
{
value: "210|297",
displayValue: "A4 (21cm x 29,7cm)"
},
{
value: "148.1|209.9",
displayValue: "A5 (14,81cm x 20,99cm)"
},
{
value: "176|250.1",
displayValue: "B5 (17,6cm x 25,01cm)"
},
{
value: "104.8|241.3",
displayValue: "Envelope #10 (10,48cm x 24,13cm)"
},
{
value: "110.1|220.1",
displayValue: "Envelope DL (11,01cm x 22,01cm)"
},
{
value: "279.4|431.7",
displayValue: "Tabloid (27,94cm x 43,17cm)"
},
{
value: "297|420.1",
displayValue: "A3 (29,7cm x 42,01cm)"
},
{
value: "304.8|457.1",
displayValue: "Tabloid Oversize (30,48cm x 45,71cm)"
},
{
value: "196.8|273",
displayValue: "ROC 16K (19,68cm x 27,3cm)"
},
{
value: "119.9|234.9",
displayValue: "Envelope Choukei 3 (11,99cm x 23,49cm)"
},
{
value: "330.2|482.5",
displayValue: "Super B/A3 (33,02cm x 48,25cm)"
}]
});
this.cmbPaperOrientation = new Common.UI.ComboBox({
el: $("#advsettings-print-combo-orient"),
style: "width: 200px;",
menuStyle: "min-width: 200px;",
editable: false,
cls: "input-group-nr",
data: [{
value: c_oAscPageOrientation.PagePortrait,
displayValue: this.strPortrait
},
{
value: c_oAscPageOrientation.PageLandscape,
displayValue: this.strLandscape
}]
});
this.chPrintGrid = new Common.UI.CheckBox({
el: $("#advsettings-print-chb-grid"),
labelText: this.textPrintGrid
});
this.chPrintRows = new Common.UI.CheckBox({
el: $("#advsettings-print-chb-rows"),
labelText: this.textPrintHeadings
});
this.spnMarginTop = new Common.UI.MetricSpinner({
el: $("#advsettings-spin-margin-top"),
step: 0.1,
width: 90,
defaultUnit: "cm",
value: "0 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginTop);
this.spnMarginBottom = new Common.UI.MetricSpinner({
el: $("#advsettings-spin-margin-bottom"),
step: 0.1,
width: 90,
defaultUnit: "cm",
value: "0 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginBottom);
this.spnMarginLeft = new Common.UI.MetricSpinner({
el: $("#advsettings-spin-margin-left"),
step: 0.1,
width: 90,
defaultUnit: "cm",
value: "0.19 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginLeft);
this.spnMarginRight = new Common.UI.MetricSpinner({
el: $("#advsettings-spin-margin-right"),
step: 0.1,
width: 90,
defaultUnit: "cm",
value: "0.19 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginRight);
this.btnOk = new Common.UI.Button({
el: "#advsettings-print-button-save"
});
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
this.fireEvent("render:after", this);
return this;
},
updateMetricUnit: function () {
if (this.spinners) {
for (var i = 0; i < this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]);
spinner.setStep(Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
applySettings: function () {
if (this.menu) {
this.menu.fireEvent("settings:apply", [this.menu]);
}
},
show: function () {
Common.UI.BaseView.prototype.show.call(this, arguments);
if (this._initSettings) {
this.updateMetricUnit();
this._initSettings = false;
}
this.fireEvent("show", this);
},
okButtonText: "Save",
strPortrait: "Portrait",
strLandscape: "Landscape",
textPrintGrid: "Print Gridlines",
textPrintHeadings: "Print Rows and Columns Headings",
strLeft: "Left",
strRight: "Right",
strTop: "Top",
strBottom: "Bottom",
strMargins: "Margins",
textPageSize: "Page Size",
textPageOrientation: "Page Orientation",
strPrint: "Print",
textSettings: "Settings for"
},
SSE.Views.MainSettingsPrint || {}));
SSE.Views.FileMenuPanels.MainSettingsGeneral = Common.UI.BaseView.extend(_.extend({
el: "#panel-settings-general",
menu: undefined,
template: _.template(['<table class="main"><tbody>', '<tr class="coauth">', '<td class="left"><label><%= scope.txtLiveComment %></label></td>', '<td class="right"><div id="fms-chb-live-comment"/></td>', "</tr>", '<tr class="divider coauth"></tr>', '<tr class="autosave">', '<td class="left"><label><%= scope.textAutoSave %></label></td>', '<td class="right"><span id="fms-chb-autosave" /></td>', "</tr>", '<tr class="divider autosave"></tr>', "<tr>", '<td class="left"><label><%= scope.strZoom %></label></td>', '<td class="right"><div id="fms-cmb-zoom" class="input-group-nr" /></td>', "</tr>", '<tr class="divider"></tr>', "<tr>", '<td class="left"><label><%= scope.strFontRender %></label></td>', '<td class="right"><span id="fms-cmb-font-render" /></td>', "</tr>", '<tr class="divider"></tr>', '<tr class="edit">', '<td class="left"><label><%= scope.strUnit %></label></td>', '<td class="right"><span id="fms-cmb-unit" /></td>', "</tr>", '<tr class="divider edit"></tr>', "<tr>", '<td class="left"></td>', '<td class="right"><button id="fms-btn-apply" class="btn normal dlg-btn primary"><%= scope.okButtonText %></button></td>', "</tr>", "</tbody></table>"].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.chLiveComment = new Common.UI.CheckBox({
el: $("#fms-chb-live-comment"),
labelText: this.strLiveComment
});
this.cmbZoom = new Common.UI.ComboBox({
el: $("#fms-cmb-zoom"),
style: "width: 160px;",
editable: false,
cls: "input-group-nr",
data: [{
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%"
}]
});
this.cmbFontRender = new Common.UI.ComboBox({
el: $("#fms-cmb-font-render"),
style: "width: 160px;",
editable: false,
cls: "input-group-nr",
data: [{
value: c_oAscFontRenderingModeType.hintingAndSubpixeling,
displayValue: this.txtWin
},
{
value: c_oAscFontRenderingModeType.noHinting,
displayValue: this.txtMac
},
{
value: c_oAscFontRenderingModeType.hinting,
displayValue: this.txtNative
}]
});
this.chAutosave = new Common.UI.CheckBox({
el: $("#fms-chb-autosave"),
labelText: this.strAutosave
});
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
}]
});
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) {
$("tr.autosave", this.el)[mode.isEdit && mode.canAutosave ? "show" : "hide"]();
$("tr.coauth", this.el)[mode.canCoAuthoring && mode.isEdit ? "show" : "hide"]();
},
updateSettings: function () {
var value = window.localStorage.getItem("sse-settings-zoom");
var item = this.cmbZoom.store.findWhere({
value: parseInt(value)
});
this.cmbZoom.setValue(item ? parseInt(item.get("value")) : 100);
value = window.localStorage.getItem("sse-settings-livecomment");
this.chLiveComment.setValue(!(value !== null && parseInt(value) == 0));
value = window.localStorage.getItem("sse-settings-fontrender");
item = this.cmbFontRender.store.findWhere({
value: parseInt(value)
});
this.cmbFontRender.setValue(item ? item.get("value") : (window.devicePixelRatio > 1 ? c_oAscFontRenderingModeType.noHinting : c_oAscFontRenderingModeType.hintingAndSubpixeling));
value = window.localStorage.getItem("sse-settings-unit");
item = this.cmbUnit.store.findWhere({
value: parseInt(value)
});
this.cmbUnit.setValue(item ? parseInt(item.get("value")) : 0);
this._oldUnits = this.cmbUnit.getValue();
value = window.localStorage.getItem("sse-settings-autosave");
this.chAutosave.setValue(value === null || parseInt(value) == 1);
},
applySettings: function () {
window.localStorage.setItem("sse-settings-zoom", this.cmbZoom.getValue());
window.localStorage.setItem("sse-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0);
window.localStorage.setItem("sse-settings-fontrender", this.cmbFontRender.getValue());
window.localStorage.setItem("sse-settings-unit", this.cmbUnit.getValue());
window.localStorage.setItem("sse-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
if (this.menu) {
this.menu.fireEvent("settings:apply", [this.menu]);
if (this._oldUnits !== this.cmbUnit.getValue()) {
Common.NotificationCenter.trigger("settings:unitschanged", this);
}
}
},
strLiveComment: "Turn on option",
strZoom: "Default Zoom Value",
okButtonText: "Apply",
txtLiveComment: "Live Commenting",
txtWin: "as Windows",
txtMac: "as OS X",
txtNative: "Native",
strFontRender: "Font Hinting",
strUnit: "Unit of Measurement",
txtCm: "Centimeter",
txtPt: "Point",
strAutosave: "Turn on autosave",
textAutoSave: "Autosave"
},
SSE.Views.FileMenuPanels.MainSettingsGeneral || {}));
SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
el: "#panel-recentfiles",
menu: undefined,
template: _.template(['<div id="id-recent-view" style="margin: 20px 0;"></div>'].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(['<div class="recent-wrap">', '<div class="recent-icon"></div>', '<div class="file-name"><%= Common.Utils.String.htmlEncode(title) %></div>', '<div class="file-info"><%= Common.Utils.String.htmlEncode(folder) %></div>', "</div>"].join(""))
});
this.viewRecentPicker.on("item:click", _.bind(this.onRecentFileClick, this));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
onRecentFileClick: function (view, itemview, record) {
if (this.menu) {
this.menu.fireEvent("recent:open", [this.menu, record.get("url")]);
}
}
});
SSE.Views.FileMenuPanels.CreateNew = Common.UI.BaseView.extend(_.extend({
el: "#panel-createnew",
menu: undefined,
events: function () {
return {
"click .blank-document-btn": _.bind(this._onBlankDocument, this),
"click .thumb-list .thumb-wrap": _.bind(this._onDocumentTemplate, this)
};
},
template: _.template(['<h3 style="margin-top: 20px;"><%= scope.fromBlankText %></h3><hr noshade />', '<div class="blank-document">', '<div class="blank-document-btn"></div>', '<div class="blank-document-info">', "<h3><%= scope.newDocumentText %></h3>", "<%= scope.newDescriptionText %>", "</div>", "</div>", "<h3><%= scope.fromTemplateText %></h3><hr noshade />", '<div class="thumb-list">', "<% _.each(docs, function(item) { %>", '<div class="thumb-wrap" template="<%= item.name %>">', '<div class="thumb"<% if (!_.isEmpty(item.icon)) { %> style="background-image: url(<%= item.icon %>);" <% } %> />', '<div class="title"><%= item.name %></div>', "</div>", "<% }) %>", "</div>"].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 Spreadsheet",
newDescriptionText: "Create a new blank text document 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"
},
SSE.Views.FileMenuPanels.CreateNew || {}));
SSE.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(['<table class="main">', "<tr>", '<td class="left"><label>' + this.txtTitle + "</label></td>", '<td class="right"><label id="id-info-title">-</label></td>', "</tr>", '<tr class="author">', '<td class="left"><label>' + this.txtAuthor + "</label></td>", '<td class="right"><span class="userLink" id="id-info-author">-</span></td>', "</tr>", '<tr class="placement">', '<td class="left"><label>' + this.txtPlacement + "</label></td>", '<td class="right"><label id="id-info-placement">-</label></td>', "</tr>", '<tr class="date">', '<td class="left"><label>' + this.txtDate + "</label></td>", '<td class="right"><label id="id-info-date">-</label></td>', "</tr>", '<tr class="divider date"></tr>', '<tr class="rights">', '<td class="left" style="vertical-align: top;"><label>' + this.txtRights + "</label></td>", '<td class="right"><div id="id-info-rights"></div></td>', "</tr>", '<tr class="edit-rights">', '<td class="left"></td><td class="right"><button id="id-info-btn-edit" class="btn normal dlg-btn primary" style="margin-right: 10px;width: auto;">' + this.txtBtnAccessRights + "</button></td>", "</tr>", "</table>"].join(""));
this.templateRights = _.template(["<table>", "<% _.each(users, function(item) { %>", "<tr>", '<td><span class="userLink"><%= Common.Utils.String.htmlEncode(item.user) %></span></td>', "<td><%= Common.Utils.String.htmlEncode(item.permissions) %></td>", "</tr>", "<% }); %>", "</table>"].join(""));
this.menu = options.menu;
},
render: function () {
$(this.el).html(this.template());
this.lblTitle = $("#id-info-title");
this.lblPlacement = $("#id-info-placement");
this.lblDate = $("#id-info-date");
this.lblAuthor = $("#id-info-author");
this.cntRights = $("#id-info-rights");
this.btnEditRights = new Common.UI.Button({
el: "#id-info-btn-edit"
});
this.btnEditRights.on("click", _.bind(this.changeAccessRights, this));
this.rendered = true;
this.updateInfo(this.doc);
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);
},
hide: function () {
Common.UI.BaseView.prototype.hide.call(this, arguments);
},
updateInfo: function (doc) {
this.doc = doc;
if (!this.rendered) {
return;
}
doc = doc || {};
this.lblTitle.text((doc.title) ? doc.title : "-");
if (doc.info) {
if (doc.info.author) {
this.lblAuthor.text(doc.info.author);
}
this._ShowHideInfoItem("author", doc.info.author !== undefined && doc.info.author !== null);
if (doc.info.created) {
this.lblDate.text(doc.info.created);
}
this._ShowHideInfoItem("date", doc.info.created !== undefined && doc.info.created !== null);
if (doc.info.folder) {
this.lblPlacement.text(doc.info.folder);
}
this._ShowHideInfoItem("placement", doc.info.folder !== undefined && doc.info.folder !== null);
if (doc.info.sharingSettings) {
this.cntRights.html(this.templateRights({
users: doc.info.sharingSettings
}));
}
this._ShowHideInfoItem("rights", doc.info.sharingSettings !== undefined && doc.info.sharingSettings !== null && this._readonlyRights !== true);
this._ShowHideInfoItem("edit-rights", !!this.sharingSettingsUrl && this.sharingSettingsUrl.length && this._readonlyRights !== true);
} else {
this._ShowHideDocInfo(false);
}
},
_ShowHideInfoItem: function (cls, visible) {
$("tr." + cls, this.el)[visible ? "show" : "hide"]();
},
_ShowHideDocInfo: function (visible) {
this._ShowHideInfoItem("date", visible);
this._ShowHideInfoItem("placement", visible);
this._ShowHideInfoItem("author", visible);
this._ShowHideInfoItem("rights", visible);
this._ShowHideInfoItem("edit-rights", visible);
},
setMode: function (mode) {
this.sharingSettingsUrl = mode.sharingSettingsUrl;
return this;
},
changeAccessRights: function (btn, event, opts) {
var me = this;
var win = new Common.Views.DocumentAccessDialog({
settingsurl: this.sharingSettingsUrl
});
win.on("accessrights", function (obj, rights) {
me.doc.info.sharingSettings = rights;
me.cntRights.html(me.templateRights({
users: me.doc.info.sharingSettings
}));
});
win.show();
},
onLostEditRights: function () {
this._readonlyRights = true;
if (!this.rendered) {
return;
}
this._ShowHideInfoItem("rights", false);
this._ShowHideInfoItem("edit-rights", false);
},
txtTitle: "Document Title",
txtAuthor: "Author",
txtPlacement: "Placement",
txtDate: "Creation Date",
txtRights: "Persons who have rights",
txtBtnAccessRights: "Change access rights"
},
SSE.Views.FileMenuPanels.DocumentInfo || {}));
SSE.Views.FileMenuPanels.Help = Common.UI.BaseView.extend({
el: "#panel-help",
menu: undefined,
template: _.template(['<div style="width:100%; height:100%; position: relative;">', '<div id="id-help-contents" style="position: absolute; width:200px; top: 0; bottom: 0;" class="no-padding"></div>', '<div id="id-help-frame" style="position: absolute; left: 200px; top: 0; right: 0; bottom: 0;" class="no-padding"></div>', "</div>"].join("")),
initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, arguments);
this.menu = options.menu;
this.urlPref = "resources/help/en/";
this.itemclicked = false;
this.en_data = [{
src: "UsageInstructions/OpenCreateNew.htm",
name: "Create a new spreadsheet or open an existing one",
headername: "Usage Instructions",
selected: true
},
{
src: "UsageInstructions/ManageSheets.htm",
name: "Manage sheets"
},
{
src: "UsageInstructions/InsertDeleteCells.htm",
name: "Insert or delete cells, rows, and columns"
},
{
src: "UsageInstructions/CopyPasteData.htm",
name: "Copy and paste data"
},
{
src: "UsageInstructions/FontTypeSizeStyle.htm",
name: "Set font type, size, style, and colors"
},
{
src: "UsageInstructions/AlignText.htm",
name: "Align data in cells"
},
{
src: "UsageInstructions/AddBorders.htm",
name: "Add borders"
},
{
src: "UsageInstructions/MergeCells.htm",
name: "Merge cells"
},
{
src: "UsageInstructions/ClearFormatting.htm",
name: "Clear text, format in a cell"
},
{
src: "UsageInstructions/SortData.htm",
name: "Sort data"
},
{
src: "UsageInstructions/InsertFunction.htm",
name: "Insert function"
},
{
src: "UsageInstructions/ChangeNumberFormat.htm",
name: "Change number format"
},
{
src: "UsageInstructions/UndoRedo.htm",
name: "Undo/redo your actions"
},
{
src: "UsageInstructions/ViewDocInfo.htm",
name: "View file information"
},
{
src: "UsageInstructions/SavePrintDownload.htm",
name: "Save/print/download your spreadsheet"
},
{
src: "HelpfulHints/About.htm",
name: "About ONLYOFFICE Spreadsheet Editor",
headername: "Helpful Hints"
},
{
src: "HelpfulHints/SupportedFormats.htm",
name: "Supported Formats of Spreadsheets"
},
{
src: "HelpfulHints/Navigation.htm",
name: "Navigation through Your Spreadsheet"
},
{
src: "HelpfulHints/Search.htm",
name: "Search Function"
},
{
src: "HelpfulHints/KeyboardShortcuts.htm",
name: "Keyboard Shortcuts"
}];
if (Common.Utils.isIE) {
window.onhelp = function () {
return false;
};
}
},
render: function () {
$(this.el).html(this.template());
this.viewHelpPicker = new Common.UI.DataView({
el: $("#id-help-contents"),
store: new Common.UI.DataViewStore([]),
keyMoveDirection: "vertical",
itemTemplate: _.template(['<div id="<%= id %>" class="help-item-wrap">', '<div class="caption"><%= name %></div>', "</div>"].join(""))
});
this.viewHelpPicker.on("item:add", _.bind(function (dataview, itemview, record) {
if (record.has("headername")) {
$(itemview.el).before('<div class="header-name">' + record.get("headername") + "</div>");
}
},
this));
this.viewHelpPicker.on("item:select", _.bind(function (dataview, itemview, record) {
this.itemclicked = true;
this.iFrame.src = this.urlPref + record.get("src");
},
this));
this.iFrame = document.createElement("iframe");
this.iFrame.src = "";
this.iFrame.align = "top";
this.iFrame.frameBorder = "0";
this.iFrame.width = "100%";
this.iFrame.height = "100%";
this.iFrame.onload = _.bind(function () {
if (!this.itemclicked) {
var src = arguments[0].currentTarget.contentDocument.URL;
var rec = this.viewHelpPicker.store.find(function (record) {
return (src.indexOf(record.get("src")) > 0);
});
if (rec) {
this.viewHelpPicker.selectRecord(rec, true);
this.viewHelpPicker.scrollToRecord(rec);
}
}
this.itemclicked = false;
},
this);
$("#id-help-frame").append(this.iFrame);
return this;
},
setLangConfig: function (lang) {
var me = this;
var store = this.viewHelpPicker.store;
if (lang) {
lang = lang.split("-")[0];
var config = {
dataType: "json",
error: function () {
if (me.urlPref.indexOf("resources/help/en/") < 0) {
me.urlPref = "resources/help/en/";
store.url = "resources/help/en/Contents.json";
store.fetch(config);
} else {
me.urlPref = "resources/help/en/";
store.reset(me.en_data);
}
},
success: function () {
var rec = store.at(0);
me.viewHelpPicker.selectRecord(rec);
me.iFrame.src = me.urlPref + rec.get("src");
}
};
store.url = "resources/help/" + lang + "/Contents.json";
store.fetch(config);
this.urlPref = "resources/help/" + lang + "/";
}
},
show: function () {
Common.UI.BaseView.prototype.show.call(this);
if (!this._scrollerInited) {
this.viewHelpPicker.scroller.update();
this._scrollerInited = true;
}
}
});
});

View File

@@ -1,247 +1,334 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.FormulaDialog", {
extend: "Ext.window.Window",
alias: "widget.sseformuladialog",
requires: ["Ext.window.Window", "Common.plugin.GridScrollPane"],
modal: true,
closable: true,
resizable: false,
height: 490,
width: 300,
constrain: true,
padding: "10px 20px 0 20px",
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var gp_store = Ext.create("SSE.store.FormulaGroups");
this.cmbGroup = Ext.create("Ext.form.field.ComboBox", {
id: "formulas-group-combo",
store: gp_store,
displayField: "groupname",
queryMode: "local",
queryDelay: 1000,
typeAhead: false,
editable: false,
listeners: {
select: function (combo, records, eOpts) {},
specialkey: function (obj, event) {
if (!obj.isExpanded && event.getKey() == Ext.EventObject.ESC) {
this.fireEvent("onmodalresult", this, 0);
this.hide();
}
},
scope: this
}
});
Ext.create("SSE.store.Formulas", {
storeId: "appFormulasStore"
});
var funcList = Ext.create("Ext.grid.Panel", {
activeItem: 0,
id: "formulas-list",
store: Ext.data.StoreManager.lookup("appFormulasStore"),
stateful: true,
stateId: "stateGrid",
scroll: false,
columns: [{
flex: 1,
sortable: false,
dataIndex: "func"
}],
height: 250,
hideHeaders: true,
viewConfig: {
stripeRows: false
},
plugins: [{
pluginId: "scrollpane",
ptype: "gridscrollpane"
}],
listeners: {
itemdblclick: function (o, record, item, index, e, eOpts) {
this.btnOk.fireEvent("click", this.btnOk);
},
select: function (o, record, index, eOpts) {
lblSyntax.setText("Syntax: " + record.data.func + record.data.args);
},
viewready: function (cmp) {
cmp.getView().on("cellkeydown", function (obj, cell, cellIndex, record, row, rowIndex, e) {
if (e.getKey() == Ext.EventObject.ESC) {
this.fireEvent("onmodalresult", this, 0);
this.hide();
return false;
}
},
this);
},
scope: this
}
});
var lblSyntax = Ext.widget("label", {});
this.items = [{
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
height: 57,
width: 260,
items: [{
xtype: "label",
text: this.textGroupDescription,
style: "font-weight: bold;margin:0 0 4px 0;"
},
this.cmbGroup]
},
{
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
height: 277,
width: 260,
items: [{
xtype: "label",
text: this.textListDescription,
style: "font-weight:bold;margin:0 0 4px 0;"
},
funcList]
},
{
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
height: 56,
items: [lblSyntax]
},
{
xtype: "tbspacer",
height: 8,
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
},
{
xtype: "container",
height: 40,
layout: {
type: "vbox",
align: "center",
pack: "center"
},
items: [{
xtype: "container",
width: 182,
height: 24,
layout: {
type: "hbox",
align: "middle"
},
items: [this.btnOk = Ext.widget("button", {
id: "formulas-button-ok",
cls: "asc-blue-button",
width: 86,
height: 22,
margin: "0 5px 0 0",
text: this.okButtonText,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 1, funcList.getSelectionModel().selected.items[0].data.func);
},
scope: this
}
}), this.btnCancel = Ext.widget("button", {
cls: "asc-darkgray-button",
width: 86,
height: 22,
text: this.cancelButtonText,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 0);
this.hide();
},
scope: this
}
})]
}]
}];
this.listeners = {
show: function () {}
};
this.callParent(arguments);
this.setTitle(this.txtTitle);
},
setGroups: function (arr) {
var groupDesc = {
"Cube": this.sCategoryCube,
"Database": this.sCategoryDatabase,
"DateAndTime": this.sCategoryDateTime,
"Engineering": this.sCategoryEngineering,
"Financial": this.sCategoryFinancial,
"Information": this.sCategoryInformation,
"Logical": this.sCategoryLogical,
"LookupAndReference": this.sCategoryLookupAndReference,
"Mathematic": this.sCategoryMathematics,
"Statistical": this.sCategoryStatistical,
"TextAndData": this.sCategoryTextData
};
var garr = [[this.sCategoryAll, "all"]];
Ext.each(arr, function (item) {
garr.push([groupDesc[item], item]);
});
this.cmbGroup.getStore().removeAll(true);
this.cmbGroup.getStore().loadData(garr);
this.cmbGroup.select(this.cmbGroup.getStore().getAt(0));
},
cancelButtonText: "Cancel",
okButtonText: "Ok",
sCategoryAll: "All",
sCategoryLogical: "Logical",
sCategoryCube: "Cube",
sCategoryDatabase: "Database",
sCategoryDateTime: "Date and time",
sCategoryEngineering: "Engineering",
sCategoryFinancial: "Financial",
sCategoryInformation: "Information",
sCategoryLookupAndReference: "LookupAndReference",
sCategoryMathematics: "Math and trigonometry",
sCategoryStatistical: "Statistical",
sCategoryTextData: "Text and data",
textGroupDescription: "Select Function Group",
textListDescription: "Select Function",
sDescription: "Description",
txtTitle: "Insert Function"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["common/main/lib/component/Window", "spreadsheeteditor/main/app/collection/FormulaGroups"], function () {
SSE.Views = SSE.Views || {};
SSE.Views.FormulaDialog = Common.UI.Window.extend(_.extend({
applyFunction: undefined,
initialize: function (options) {
var t = this,
_options = {};
_.extend(_options, {
width: 300,
height: 490,
contentWidth: 390,
header: true,
cls: "formula-dlg",
contentTemplate: "",
title: t.txtTitle,
items: []
},
options);
this.template = options.template || ['<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="content-panel" >', '<label class="header">' + t.textGroupDescription + "</label>", '<div id="formula-dlg-combo-group" class="input-group-nr" style="margin-top: 10px"/>', '<label class="header" style="margin-top:10px">' + t.textListDescription + "</label>", '<div id="formula-dlg-combo-functions" class="combo-functions"/>', '<label id="formula-dlg-args" style="margin-top: 10px">' + "</label>", "</div>", "</div>", '<div class="separator horizontal"/>', '<div class="footer center">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + t.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + t.cancelButtonText + "</button>", "</div>"].join("");
this.api = options.api;
this.formulasGroups = options.formulasGroups;
this.handler = options.handler;
_options.tpl = _.template(this.template, _options);
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
this.$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
this.syntaxLabel = $("#formula-dlg-args");
this.fillFormulasGroups();
this.fillFunctions("All");
},
show: function () {
if (this.$window) {
var main_width, main_height, top, left, win_height = this.initConfig.height;
if (window.innerHeight === undefined) {
main_width = document.documentElement.offsetWidth;
main_height = document.documentElement.offsetHeight;
} else {
main_width = window.innerWidth;
main_height = window.innerHeight;
}
top = ((parseInt(main_height, 10) - parseInt(win_height, 10)) / 2) * 0.9;
left = (parseInt(main_width, 10) - parseInt(this.initConfig.width, 10)) / 2;
this.$window.css("left", Math.floor(left));
this.$window.css("top", Math.floor(top));
}
Common.UI.Window.prototype.show.call(this);
this.mask = $(".modals-mask");
this.mask.on("mousedown", _.bind(this.onUpdateFocus, this));
this.$window.on("mousedown", _.bind(this.onUpdateFocus, this));
if (this.cmbListFunctions) {
_.delay(function (me) {
me.cmbListFunctions.$el.find(".listview").focus();
},
100, this);
}
},
hide: function () {
this.mask.off("mousedown", _.bind(this.onUpdateFocus, this));
this.$window.off("mousedown", _.bind(this.onUpdateFocus, this));
Common.UI.Window.prototype.hide.call(this);
},
onBtnClick: function (event) {
if ("ok" === event.currentTarget.attributes["result"].value) {
if (this.handler) {
this.handler.call(this, this.applyFunction);
}
}
this.hide();
},
onDblClickFunction: function () {
if (this.handler) {
this.handler.call(this, this.applyFunction);
}
this.hide();
},
onSelectGroup: function (combo, record) {
if (!_.isUndefined(record) && !_.isUndefined(record.value)) {
if (record.value < this.formulasGroups.length) {
this.fillFunctions(this.formulasGroups.at(record.value).get("name"));
}
}
this.onUpdateFocus();
},
onSelectFunction: function (listView, itemView, record) {
var funcId, functions, func;
if (this.formulasGroups) {
funcId = record.get("id");
if (!_.isUndefined(funcId)) {
functions = this.formulasGroups.at(0).get("functions");
if (functions) {
func = _.find(functions, function (f) {
if (f.get("index") === funcId) {
return f;
}
return null;
});
if (func) {
this.applyFunction = func.get("name");
this.syntaxLabel.text(this.syntaxText + ": " + this.applyFunction + func.get("args"));
}
}
}
}
},
onPrimary: function (list, record, event) {
if (this.handler) {
this.handler.call(this, this.applyFunction);
}
this.hide();
},
onUpdateFocus: function () {
_.delay(function (me) {
me.cmbListFunctions.$el.find(".listview").focus();
},
100, this);
},
fillFormulasGroups: function () {
if (this.formulasGroups) {
var descriptions = {
"All": this.sCategoryAll,
"Cube": this.sCategoryCube,
"Database": this.sCategoryDatabase,
"DateAndTime": this.sCategoryDateTime,
"Engineering": this.sCategoryEngineering,
"Financial": this.sCategoryFinancial,
"Information": this.sCategoryInformation,
"Logical": this.sCategoryLogical,
"LookupAndReference": this.sCategoryLookupAndReference,
"Mathematic": this.sCategoryMathematics,
"Statistical": this.sCategoryStatistical,
"TextAndData": this.sCategoryTextData
};
var i, groupsListItems = [],
length = this.formulasGroups.length;
for (i = 0; i < length; ++i) {
if (this.formulasGroups.at(i).get("functions").length) {
groupsListItems.push({
value: this.formulasGroups.at(i).get("index"),
displayValue: descriptions[this.formulasGroups.at(i).get("name")]
});
}
}
if (!this.cmbFuncGroup) {
this.cmbFuncGroup = new Common.UI.ComboBox({
el: $("#formula-dlg-combo-group"),
menuStyle: "min-width: 268px;",
cls: "input-group-nr",
data: groupsListItems,
editable: false
});
this.cmbFuncGroup.setValue(0);
this.cmbFuncGroup.on("selected", _.bind(this.onSelectGroup, this));
} else {
this.cmbFuncGroup.setData(groupsListItems);
}
}
},
fillFunctions: function (name) {
if (this.formulasGroups) {
if (!this.cmbListFunctions && !this.functions) {
this.functions = new Common.UI.DataViewStore();
this.cmbListFunctions = new Common.UI.ListView({
el: $("#formula-dlg-combo-functions"),
store: this.functions,
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="pointer-events:none;"><%= value %></div>')
});
this.cmbListFunctions.on("item:select", _.bind(this.onSelectFunction, this));
this.cmbListFunctions.on("item:dblclick", _.bind(this.onDblClickFunction, this));
this.cmbListFunctions.on("entervalue", _.bind(this.onPrimary, this));
this.cmbListFunctions.onKeyDown = _.bind(this.onKeyDown, this.cmbListFunctions);
this.cmbListFunctions.$el.find(".listview").focus();
this.cmbListFunctions.scrollToRecord = _.bind(this.onScrollToRecordCustom, this.cmbListFunctions);
}
if (this.functions) {
this.functions.reset();
var i = 0,
length = 0,
functions = null,
group = this.formulasGroups.findWhere({
name: name
});
if (group) {
functions = group.get("functions");
if (functions && functions.length) {
length = functions.length;
for (i = 0; i < length; ++i) {
this.functions.push(new Common.UI.DataViewModel({
id: functions[i].get("index"),
selected: i < 1,
allowSelected: true,
value: functions[i].get("name")
}));
}
this.applyFunction = functions[0].get("name");
this.syntaxLabel.text(this.syntaxText + ": " + this.applyFunction + functions[0].get("args"));
this.cmbListFunctions.scroller.update({
minScrollbarLength: 40,
alwaysVisibleY: true
});
}
}
}
}
},
onKeyDown: function (e, event) {
var i = 0,
record = null,
me = this,
charVal = "",
value = "",
firstRecord = null,
recSelect = false,
innerEl = null,
isEqualSelectRecord = false,
selectRecord = null,
needNextRecord = false;
if (this.disabled) {
return;
}
if (_.isUndefined(undefined)) {
event = e;
}
function selectItem(item) {
me.selectRecord(item);
me.scrollToRecord(item);
innerEl = $(me.el).find(".inner");
me.scroller.scrollTop(innerEl.scrollTop(), 0);
event.preventDefault();
event.stopPropagation();
}
charVal = String.fromCharCode(e.keyCode);
if (e.keyCode > 64 && e.keyCode < 91 && charVal && charVal.length) {
selectRecord = this.store.findWhere({
selected: true
});
if (selectRecord) {
value = selectRecord.get("value");
isEqualSelectRecord = (value && value.length && value[0] === charVal);
}
for (i = 0; i < this.store.length; ++i) {
record = this.store.at(i);
value = record.get("value");
if (value[0] === charVal) {
if (null === firstRecord) {
firstRecord = record;
}
if (isEqualSelectRecord) {
if (selectRecord === record) {
isEqualSelectRecord = false;
}
continue;
}
if (record.get("selected")) {
continue;
}
selectItem(record);
return;
}
}
if (firstRecord) {
selectItem(firstRecord);
return;
}
}
Common.UI.DataView.prototype.onKeyDown.call(this, e, event);
},
onScrollToRecordCustom: function (record) {
var innerEl = $(this.el).find(".inner");
var inner_top = innerEl.offset().top;
var div = innerEl.find("#" + record.get("id")).parent();
var div_top = div.offset().top;
if (div_top < inner_top || div_top + div.height() > inner_top + innerEl.height()) {
if (this.scroller) {
this.scroller.scrollTop(innerEl.scrollTop() + div_top - inner_top, 0);
} else {
innerEl.scrollTop(innerEl.scrollTop() + div_top - inner_top);
}
}
},
cancelButtonText: "Cancel",
okButtonText: "Ok",
sCategoryAll: "All",
sCategoryLogical: "Logical",
sCategoryCube: "Cube",
sCategoryDatabase: "Database",
sCategoryDateTime: "Date and time",
sCategoryEngineering: "Engineering",
sCategoryFinancial: "Financial",
sCategoryInformation: "Information",
sCategoryLookupAndReference: "LookupAndReference",
sCategoryMathematics: "Math and trigonometry",
sCategoryStatistical: "Statistical",
sCategoryTextData: "Text and data",
textGroupDescription: "Select Function Group",
textListDescription: "Select Function",
sDescription: "Description",
txtTitle: "Insert Function",
syntaxText: "Syntax"
},
SSE.Views.FormulaDialog || {}));
});

View File

@@ -1,339 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.HyperlinkSettings", {
extend: "Ext.window.Window",
alias: "widget.ssehyperlinksettings",
requires: ["Ext.window.Window", "Ext.form.field.ComboBox", "Ext.form.field.Text", "Ext.Array"],
cls: "asc-advanced-settings-window",
modal: true,
resizable: false,
plain: true,
constrain: true,
height: 348,
width: 366,
layout: {
type: "vbox",
align: "stretch"
},
listeners: {
show: function () {
if (this.contExtLink.isVisible()) {
this.txtLink.focus(false, 500);
} else {
this.txtLinkText.focus(false, 500);
}
}
},
initComponent: function () {
var me = this;
this.addEvents("onmodalresult");
this._spacer = Ext.create("Ext.toolbar.Spacer", {
width: "100%",
height: 10,
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
});
this.cmbLinkType = Ext.widget("combo", {
store: Ext.create("Ext.data.Store", {
fields: ["description", "type"],
data: [{
type: c_oAscHyperlinkType.RangeLink,
description: me.textInternalLink
},
{
type: c_oAscHyperlinkType.WebLink,
description: me.textExternalLink
}]
}),
displayField: "description",
valueField: "type",
queryMode: "local",
editable: false,
listeners: {
change: function (o, nV, oV) {
var isinter = nV == c_oAscHyperlinkType.RangeLink;
me.contIntLink.setVisible(isinter);
me.contExtLink.setVisible(!isinter);
}
}
});
this.cmbSheets = Ext.widget("combo", {
store: Ext.create("Ext.data.ArrayStore", {
fields: ["name"],
data: this.sheets
}),
displayField: "name",
queryMode: "local",
editable: false
});
this.txtDataRange = Ext.widget("textfield", {
allowBlank: false,
check: false,
blankText: me.txtEmpty,
msgTarget: "side",
validator: function (value) {
if (!this.check) {
return true;
}
var isvalid = /^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(value); ! isvalid && (isvalid = /^[A-Z]+[1-9]\d*$/.test(value));
if (isvalid) {
$("#" + this.id + " input").css("color", "black");
return true;
} else {
$("#" + this.id + " input").css("color", "red");
return me.textInvalidRange;
}
},
listeners: {
blur: function (o) {
this.check = true;
this.check = !this.validate();
}
}
});
this.txtLink = Ext.widget("textfield", {
allowBlank: false,
blankText: me.txtEmpty,
emptyText: me.textEmptyLink,
validateOnChange: false,
msgTarget: "side",
regex: /(([\-\wа-яё]+\.)+[\wа-яё]{2,3}(\/[%\-\wа-яё]+(\.[\wа-яё]{2,})?)*(([\wа-яё\-\.\?\\\/+@&#;`~=%!]*)(\.[\wа-яё]{2,})?)*\/?)/i,
regexText: me.txtNotUrl
});
this.txtLinkText = Ext.widget("textfield", {
allowBlank: false,
blankText: me.txtEmpty,
msgTarget: "side",
emptyText: me.textEmptyDesc
});
this.txtLinkTip = Ext.widget("textfield", {
emptyText: me.textEmptyTooltip
});
this.label = Ext.widget("label", {
width: "100%",
margin: "0 0 3 0"
});
this.contExtLink = Ext.widget("container", {
height: 44,
layout: {
type: "vbox",
align: "stretch"
},
items: [this.label.cloneConfig({
text: me.strLinkTo
}), this.txtLink]
});
this.contIntLink = Ext.widget("container", {
height: 44,
hidden: true,
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "container",
flex: 1,
layout: {
type: "vbox",
align: "stretch"
},
items: [this.label.cloneConfig({
text: me.strSheet
}), this.cmbSheets]
},
{
xtype: "tbspacer",
width: 18
},
{
xtype: "container",
flex: 1,
layout: {
type: "vbox",
align: "stretch"
},
items: [this.label.cloneConfig({
text: me.strRange
}), this.txtDataRange]
}]
});
this.items = [{
xtype: "container",
height: 254,
padding: "18",
layout: {
type: "vbox",
align: "stretch"
},
items: [this.label.cloneConfig({
text: me.textLinkType
}), this.cmbLinkType, {
xtype: "tbspacer",
height: 10
},
this.contExtLink, this.contIntLink, {
xtype: "tbspacer",
height: 10
},
this.labelDisplay = this.label.cloneConfig({
text: me.strDisplay
}), this.txtLinkText, {
xtype: "tbspacer",
height: 10
},
this.label.cloneConfig({
text: me.textTipText
}), this.txtLinkTip]
},
this._spacer.cloneConfig({
style: "margin: 0 18px"
}), {
xtype: "container",
height: 40,
layout: {
type: "vbox",
align: "center",
pack: "center"
},
items: [{
xtype: "container",
width: 182,
height: 24,
layout: {
type: "hbox",
align: "middle"
},
items: [this.btnOk = Ext.widget("button", {
cls: "asc-blue-button",
width: 86,
height: 22,
margin: "0 5px 0 0",
text: Ext.Msg.buttonText.ok,
listeners: {
click: function (btn) {
if (me.cmbLinkType.getValue() == c_oAscHyperlinkType.RangeLink) {
me.txtDataRange.check = true;
if (!me.txtDataRange.validate()) {
me.txtDataRange.focus(true, 500);
return;
}
} else {
if (!me.txtLink.isValid()) {
me.txtLink.focus(true, 500);
return;
}
}
if (!me.txtLinkText.isValid()) {
me.txtLinkText.focus(true, 500);
return;
}
this.fireEvent("onmodalresult", this, 1);
this.close();
},
scope: this
}
}), this.btnCancel = Ext.widget("button", {
cls: "asc-darkgray-button",
width: 86,
height: 22,
text: me.cancelButtonText,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 0);
this.close();
},
scope: this
}
})]
}]
}];
this.callParent(arguments);
this.setTitle(this.textTitle);
},
afterRender: function () {
this.callParent(arguments);
},
setSettings: function (props, text, islock) {
if (!props) {
this.cmbLinkType.select(this.cmbLinkType.getStore().getAt(1));
this.txtLinkText.setValue(text);
} else {
var index = this.cmbLinkType.getStore().find("type", props.asc_getType());
this.cmbLinkType.select(this.cmbLinkType.getStore().getAt(index));
if (props.asc_getType() == c_oAscHyperlinkType.RangeLink) {
index = this.cmbSheets.getStore().find("name", props.asc_getSheet());
if (! (index < 0)) {
this.cmbSheets.select(this.cmbSheets.getStore().getAt(index));
}
this.txtDataRange.setValue(props.asc_getRange());
} else {
this.txtLink.setValue(props.asc_getHyperlinkUrl());
}
this.txtLinkText.setValue(props.asc_getText());
this.txtLinkTip.setValue(props.asc_getTooltip());
}
this.txtLinkText.setDisabled(islock);
this.labelDisplay.setDisabled(islock);
},
getSettings: function () {
var props = new Asc.asc_CHyperlink();
props.asc_setType(this.cmbLinkType.getValue());
if (this.cmbLinkType.getValue() == c_oAscHyperlinkType.RangeLink) {
props.asc_setSheet(this.cmbSheets.getValue());
props.asc_setRange(this.txtDataRange.getValue());
} else {
var url = this.txtLink.getValue().replace(/^\s+|\s+$/g, "");
if (!/(((^https?)|(^ftp)):\/\/)/i.test(url)) {
url = "http://" + url;
}
props.asc_setHyperlinkUrl(url);
}
props.asc_setText(this.txtLinkText.isDisabled() ? null : this.txtLinkText.getValue());
props.asc_setTooltip(this.txtLinkTip.getValue());
return props;
},
textTitle: "Hyperlink Settings",
textInternalLink: "Internal Data Range",
textExternalLink: "Web Link",
textEmptyLink: "Enter link here",
textEmptyDesc: "Enter caption here",
textEmptyTooltip: "Enter tooltip here",
strSheet: "Sheet",
strRange: "Range",
textLinkType: "Link Type",
strDisplay: "Display",
textTipText: "Screen Tip Text",
strLinkTo: "Link To",
txtEmpty: "This field is required",
textInvalidRange: "ERROR! Invalid cells range",
txtNotUrl: 'This field should be a URL in the format "http://www.example.com"',
cancelButtonText: "Cancel"
});

View File

@@ -0,0 +1,245 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/util/utils", "common/main/lib/component/ComboBox", "common/main/lib/component/InputField", "common/main/lib/component/Window"], function () {
SSE.Views.HyperlinkSettingsDialog = Common.UI.Window.extend(_.extend({
options: {
width: 350,
style: "min-width: 230px;",
cls: "modal-dlg"
},
initialize: function (options) {
_.extend(this.options, {
title: this.textTitle
},
options || {});
this.template = ['<div class="box">', '<div class="input-row">', "<label>" + this.textLinkType + "</label>", "</div>", '<div class="input-row" id="id-dlg-hyperlink-type" style="margin-bottom: 5px;">', "</div>", '<div id="id-dlg-hyperlink-external">', '<div class="input-row">', "<label>" + this.strLinkTo + " *</label>", "</div>", '<div id="id-dlg-hyperlink-url" class="input-row" style="margin-bottom: 5px;"></div>', "</div>", '<div id="id-dlg-hyperlink-internal" style="display: none;">', '<div class="input-row">', '<label style="width: 50%;">' + this.strSheet + "</label>", '<label style="width: 50%;">' + this.strRange + " *</label>", "</div>", '<div class="input-row" style="margin-bottom: 5px;">', '<div id="id-dlg-hyperlink-sheet" style="display: inline-block; width: 50%; padding-right: 10px; float: left;"></div>', '<div id="id-dlg-hyperlink-range" style="display: inline-block; width: 50%;"></div>', "</div>", "</div>", '<div class="input-row">', "<label>" + this.strDisplay + "</label>", "</div>", '<div id="id-dlg-hyperlink-display" class="input-row" style="margin-bottom: 5px;"></div>', '<div class="input-row">', "<label>" + this.textTipText + "</label>", "</div>", '<div id="id-dlg-hyperlink-tip" class="input-row" style="margin-bottom: 5px;"></div>', "</div>", '<div class="footer right">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + "</button>", "</div>"].join("");
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild(),
me = this;
me.cmbLinkType = new Common.UI.ComboBox({
el: $("#id-dlg-hyperlink-type"),
cls: "input-group-nr",
editable: false,
menuStyle: "min-width: 100%;",
data: [{
displayValue: this.textInternalLink,
value: c_oAscHyperlinkType.RangeLink
},
{
displayValue: this.textExternalLink,
value: c_oAscHyperlinkType.WebLink
}]
}).on("selected", function (combo, record) {
$("#id-dlg-hyperlink-external")[record.value == c_oAscHyperlinkType.WebLink ? "show" : "hide"]();
$("#id-dlg-hyperlink-internal")[record.value != c_oAscHyperlinkType.WebLink ? "show" : "hide"]();
});
me.cmbLinkType.setValue(c_oAscHyperlinkType.WebLink);
me.cmbSheets = new Common.UI.ComboBox({
el: $("#id-dlg-hyperlink-sheet"),
cls: "input-group-nr",
editable: false,
menuStyle: "min-width: 100%;max-height: 150px;"
});
me.inputUrl = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-url"),
allowBlank: false,
blankError: me.txtEmpty,
validateOnBlur: false,
style: "width: 100%;",
validation: function (value) {
me.isEmail = false;
var isvalid = value.strongMatch(Common.Utils.hostnameRe); ! isvalid && (me.isEmail = isvalid = value.strongMatch(Common.Utils.emailRe)); ! isvalid && (isvalid = value.strongMatch(Common.Utils.ipRe)); ! isvalid && (isvalid = value.strongMatch(Common.Utils.localRe));
if (isvalid) {
return true;
} else {
return me.txtNotUrl;
}
}
});
me.inputRange = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-range"),
allowBlank: false,
blankError: me.txtEmpty,
style: "width: 100%;",
validateOnChange: true,
validateOnBlur: false,
validation: function (value) {
var isvalid = /^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(value);
if (!isvalid) {
isvalid = /^[A-Z]+[1-9]\d*$/.test(value);
}
if (isvalid) {
return true;
} else {
return me.textInvalidRange;
}
}
});
me.inputDisplay = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-display"),
allowBlank: true,
validateOnBlur: false,
style: "width: 100%;"
});
me.inputTip = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-tip"),
style: "width: 100%;"
});
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
$window.find("input").on("keypress", _.bind(this.onKeyPress, this));
},
show: function () {
Common.UI.Window.prototype.show.apply(this, arguments);
var me = this;
_.delay(function () {
if (me.focusedInput) {
me.focusedInput.focus();
}
},
500);
},
setSettings: function (settings) {
if (settings) {
var me = this;
this.cmbSheets.setData(settings.sheets);
if (!settings.props) {
this.cmbLinkType.setValue(c_oAscHyperlinkType.WebLink);
this.cmbLinkType.setDisabled(!settings.allowInternal);
this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.text);
this.focusedInput = this.inputUrl.cmpEl.find("input");
this.cmbSheets.setValue(settings.currentSheet);
} else {
this.cmbLinkType.setValue(settings.props.asc_getType());
this.cmbLinkType.setDisabled(!settings.allowInternal);
if (settings.props.asc_getType() == c_oAscHyperlinkType.RangeLink) {
$("#id-dlg-hyperlink-external").hide();
$("#id-dlg-hyperlink-internal").show();
this.cmbSheets.setValue(settings.props.asc_getSheet());
this.inputRange.setValue(settings.props.asc_getRange());
this.focusedInput = this.inputRange.cmpEl.find("input");
} else {
this.inputUrl.setValue(settings.props.asc_getHyperlinkUrl());
this.focusedInput = this.inputUrl.cmpEl.find("input");
this.cmbSheets.setValue(settings.currentSheet);
}
this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.props.asc_getText());
this.inputTip.setValue(settings.props.asc_getTooltip());
}
this.inputDisplay.setDisabled(settings.isLock);
}
},
getSettings: function () {
var props = new Asc.asc_CHyperlink(),
def_display = "";
props.asc_setType(this.cmbLinkType.getValue());
if (this.cmbLinkType.getValue() == c_oAscHyperlinkType.RangeLink) {
props.asc_setSheet(this.cmbSheets.getValue());
props.asc_setRange(this.inputRange.getValue());
def_display = this.cmbSheets.getValue() + "!" + this.inputRange.getValue();
} else {
var url = this.inputUrl.getValue().replace(/^\s+|\s+$/g, "");
if (!/(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url)) {
url = ((this.isEmail) ? "mailto:": "http://") + url;
}
props.asc_setHyperlinkUrl(url);
def_display = url;
}
if (this.inputDisplay.isDisabled()) {
props.asc_setText(null);
} else {
if (_.isEmpty(this.inputDisplay.getValue())) {
this.inputDisplay.setValue(def_display);
}
props.asc_setText(this.inputDisplay.getValue());
}
props.asc_setTooltip(this.inputTip.getValue());
return props;
},
onBtnClick: function (event) {
this._handleInput(event.currentTarget.attributes["result"].value);
},
onKeyPress: function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput("ok");
return false;
}
},
_handleInput: function (state) {
if (this.options.handler) {
if (state == "ok") {
var checkurl = (this.cmbLinkType.getValue() === c_oAscHyperlinkType.WebLink) ? this.inputUrl.checkValidate() : true,
checkrange = (this.cmbLinkType.getValue() === c_oAscHyperlinkType.RangeLink) ? this.inputRange.checkValidate() : true,
checkdisp = this.inputDisplay.checkValidate();
if (checkurl !== true) {
this.inputUrl.cmpEl.find("input").focus();
return;
}
if (checkrange !== true) {
this.inputRange.cmpEl.find("input").focus();
return;
}
if (checkdisp !== true) {
this.inputDisplay.cmpEl.find("input").focus();
return;
}
}
this.options.handler.call(this, this, state);
}
this.close();
},
textTitle: "Hyperlink Settings",
textInternalLink: "Internal Data Range",
textExternalLink: "Web Link",
textEmptyLink: "Enter link here",
textEmptyDesc: "Enter caption here",
textEmptyTooltip: "Enter tooltip here",
strSheet: "Sheet",
strRange: "Range",
textLinkType: "Link Type",
strDisplay: "Display",
textTipText: "Screen Tip Text",
strLinkTo: "Link To",
txtEmpty: "This field is required",
textInvalidRange: "ERROR! Invalid cells range",
txtNotUrl: 'This field should be a URL in the format "http://www.example.com"',
cancelButtonText: "Cancel",
textDefault: "Selected range"
},
SSE.Views.HyperlinkSettingsDialog || {}));
});

View File

@@ -1,389 +1,259 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.ImageSettings", {
extend: "Common.view.AbstractSettingsPanel",
alias: "widget.sseimagesettings",
height: 192,
requires: ["Ext.ComponentQuery", "Ext.container.Container", "Ext.button.Button", "Ext.form.Label", "Ext.toolbar.Spacer", "Common.view.ImageFromUrlDialog", "Ext.util.Cookies"],
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
this.title = this.txtTitle;
this._initSettings = true;
this._nRatio = 1;
this._state = {
Width: 0,
Height: 0
};
this._spnWidth = Ext.create("Common.component.MetricSpinner", {
id: "image-spin-width",
readOnly: false,
maxValue: 55.88,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "3 cm",
width: 78,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
var w = field.getNumberValue();
var h = this._spnHeight.getNumberValue();
if (this._btnRatio.pressed) {
h = w / this._nRatio;
if (h > this._spnHeight.maxValue) {
h = this._spnHeight.maxValue;
w = h * this._nRatio;
this._spnWidth.suspendEvents(false);
this._spnWidth.setValue(w);
this._spnWidth.resumeEvents();
}
this._spnHeight.suspendEvents(false);
this._spnHeight.setValue(h);
this._spnHeight.resumeEvents();
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.MetricSettings.fnRecalcToMM(w));
props.asc_putHeight(Common.MetricSettings.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this._spnWidth);
this._spnHeight = Ext.create("Common.component.MetricSpinner", {
id: "image-span-height",
readOnly: false,
maxValue: 55.88,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "3 cm",
width: 78,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
var h = field.getNumberValue(),
w = this._spnWidth.getNumberValue();
if (this._btnRatio.pressed) {
w = h * this._nRatio;
if (w > this._spnWidth.maxValue) {
w = this._spnWidth.maxValue;
h = w / this._nRatio;
this._spnHeight.suspendEvents(false);
this._spnHeight.setValue(h);
this._spnHeight.resumeEvents();
}
this._spnWidth.suspendEvents(false);
this._spnWidth.setValue(w);
this._spnWidth.resumeEvents();
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.MetricSettings.fnRecalcToMM(w));
props.asc_putHeight(Common.MetricSettings.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this._spnHeight);
var value = window.localStorage.getItem("sse-settings-imageratio");
this._btnRatio = Ext.create("Ext.Button", {
id: "image-button-ratio",
iconCls: "advanced-btn-ratio",
enableToggle: true,
width: 22,
height: 22,
pressed: (value === null || parseInt(value) == 1),
style: "margin: 0 0 0 4px;",
tooltip: this.textKeepRatio,
toggleHandler: Ext.bind(function (btn) {
if (btn.pressed && this._spnHeight.getNumberValue() > 0) {
this._nRatio = this._spnWidth.getNumberValue() / this._spnHeight.getNumberValue();
}
window.localStorage.setItem("sse-settings-imageratio", (btn.pressed) ? 1 : 0);
},
this)
});
this._btnOriginalSize = Ext.create("Ext.Button", {
id: "image-button-original-size",
text: this.textOriginalSize,
width: 106,
listeners: {
click: this.setOriginalSize,
scope: this
}
});
this._btnInsertFromFile = Ext.create("Ext.Button", {
id: "image-button-from-file",
text: this.textFromFile,
width: 85,
listeners: {
click: function (btn) {
if (this.api) {
this.api.asc_changeImageFromFile();
}
this.fireEvent("editcomplete", this);
},
scope: this
}
});
this._btnInsertFromUrl = Ext.create("Ext.Button", {
id: "image-button-from-url",
text: this.textFromUrl,
width: 85,
listeners: {
click: function (btn) {
var w = Ext.create("Common.view.ImageFromUrlDialog");
w.addListener("onmodalresult", Ext.bind(this._onOpenImageFromURL, [this, w]), false);
w.addListener("close", Ext.bind(function (cnt, eOpts) {
this.fireEvent("editcomplete", this);
},
this));
w.show();
},
scope: this
}
});
this._SizePanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 88,
width: 195,
items: [{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
layout: {
type: "table",
columns: 2
},
defaults: {
xtype: "container",
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 43,
style: "float:left;"
},
items: [{
items: [{
xtype: "label",
text: this.textWidth,
width: 78
},
{
xtype: "tbspacer",
height: 3
},
{
xtype: "container",
width: 108,
layout: {
type: "hbox"
},
items: [this._spnWidth, this._btnRatio, {
xtype: "tbspacer",
width: 4
}]
}]
},
{
items: [{
xtype: "label",
text: this.textHeight,
width: 78
},
{
xtype: "tbspacer",
height: 3
},
this._spnHeight]
}]
},
{
xtype: "tbspacer",
height: 7
},
this._btnOriginalSize, {
xtype: "tbspacer",
height: 3
}]
});
this._UrlPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 36,
width: 195,
items: [{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 8px;"
}
},
items: [this._btnInsertFromFile, this._btnInsertFromUrl]
},
{
xtype: "tbspacer",
height: 2
}]
});
this.items = [{
xtype: "tbspacer",
height: 9
},
{
xtype: "label",
style: "font-weight: bold;margin-top: 1px;",
text: this.textSize
},
this._SizePanel, {
xtype: "tbspacer",
height: 5
},
{
xtype: "tbspacer",
width: "100%",
height: 10,
style: "padding-right: 10px;",
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
},
{
xtype: "label",
style: "font-weight: bold;margin-top: 1px;",
text: this.textInsert
},
this._UrlPanel];
this.addEvents("editcomplete");
this.callParent(arguments);
},
setOriginalSize: function () {
if (this.api) {
var imgsize = this.api.asc_getOriginalImageSize();
if (imgsize) {
var w = imgsize.asc_getImageWidth();
var h = imgsize.asc_getImageHeight();
var properties = new Asc.asc_CImgProperty();
properties.asc_putWidth(w);
properties.asc_putHeight(h);
this.api.asc_setGraphicObjectProps(properties);
}
this.fireEvent("editcomplete", this);
}
},
setApi: function (api) {
if (api == undefined) {
return;
}
this.api = api;
},
ChangeSettings: function (props) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
if (props) {
this.SuspendEvents();
var value = props.asc_getWidth();
if (Math.abs(this._state.Width - value) > 0.001 || (this._state.Width === null || value === null) && (this._state.Width !== value)) {
this._spnWidth.setValue((value !== null) ? Common.MetricSettings.fnRecalcFromMM(value) : "");
this._state.Width = value;
}
value = props.asc_getHeight();
if (Math.abs(this._state.Height - value) > 0.001 || (this._state.Height === null || value === null) && (this._state.Height !== value)) {
this._spnHeight.setValue((value !== null) ? Common.MetricSettings.fnRecalcFromMM(value) : "");
this._state.Height = value;
}
this.ResumeEvents();
if (props.asc_getHeight() > 0) {
this._nRatio = props.asc_getWidth() / props.asc_getHeight();
}
this._btnOriginalSize.setDisabled(props.asc_getImageUrl() === null || props.asc_getImageUrl() === undefined);
}
},
_onOpenImageFromURL: function (mr) {
var self = this[0];
var url = this[1].txtUrl;
if (mr == 1 && self.api) {
var checkurl = url.value.replace(/ /g, "");
if (checkurl != "") {
var props = new Asc.asc_CImgProperty();
props.asc_putImageUrl(url.value);
self.api.asc_setGraphicObjectProps(props);
}
}
},
updateMetricUnit: function () {
var spinners = this.query("commonmetricspinner");
if (spinners) {
for (var i = 0; i < spinners.length; i++) {
var spinner = spinners[i];
spinner.setDefaultUnit(Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
spinner.setStep(Common.MetricSettings.getCurrentMetric() == Common.MetricSettings.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
textKeepRatio: "Constant Proportions",
textSize: "Size",
textWidth: "Width",
textHeight: "Height",
textOriginalSize: "Default Size",
textUrl: "Image URL",
textInsert: "Change Image",
textFromUrl: "From URL",
textFromFile: "From File",
txtTitle: "Picture"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/ImageSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/component/MetricSpinner", "common/main/lib/view/ImageFromUrlDialog"], function (menuTemplate, $, _, Backbone) {
SSE.Views.ImageSettings = Backbone.View.extend(_.extend({
el: "#id-image-settings",
template: _.template(menuTemplate),
events: {},
options: {
alias: "ImageSettings"
},
initialize: function () {
var me = this;
this._initSettings = true;
this._nRatio = 1;
this._state = {
Width: 0,
Height: 0,
DisabledControls: false
};
this.spinners = [];
this.lockedControls = [];
this._locked = false;
this._noApply = false;
this.render();
this.spnWidth = new Common.UI.MetricSpinner({
el: $("#image-spin-width"),
step: 0.1,
width: 78,
defaultUnit: "cm",
value: "3 cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.spnWidth);
this.lockedControls.push(this.spnWidth);
this.spnHeight = new Common.UI.MetricSpinner({
el: $("#image-spin-height"),
step: 0.1,
width: 78,
defaultUnit: "cm",
value: "3 cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.spnHeight);
this.lockedControls.push(this.spnHeight);
this.btnRatio = new Common.UI.Button({
cls: "btn-toolbar btn-toolbar-default",
iconCls: "advanced-btn-ratio",
style: "margin-bottom: 1px;",
enableToggle: true,
hint: this.textKeepRatio
});
this.btnRatio.render($("#image-button-ratio"));
this.lockedControls.push(this.btnRatio);
var value = window.localStorage.getItem("sse-settings-imageratio");
if (value === null || parseInt(value) == 1) {
this.btnRatio.toggle(true);
}
this.btnRatio.on("click", _.bind(function (btn, e) {
if (btn.pressed && this.spnHeight.getNumberValue() > 0) {
this._nRatio = this.spnWidth.getNumberValue() / this.spnHeight.getNumberValue();
}
window.localStorage.setItem("sse-settings-imageratio", (btn.pressed) ? 1 : 0);
},
this));
this.btnOriginalSize = new Common.UI.Button({
el: $("#image-button-original-size")
});
this.lockedControls.push(this.btnOriginalSize);
this.btnInsertFromFile = new Common.UI.Button({
el: $("#image-button-from-file")
});
this.lockedControls.push(this.btnInsertFromFile);
this.btnInsertFromUrl = new Common.UI.Button({
el: $("#image-button-from-url")
});
this.lockedControls.push(this.btnInsertFromUrl);
this.spnWidth.on("change", _.bind(this.onWidthChange, this));
this.spnHeight.on("change", _.bind(this.onHeightChange, this));
this.btnOriginalSize.on("click", _.bind(this.setOriginalSize, this));
this.btnInsertFromFile.on("click", _.bind(function (btn) {
if (this.api) {
this.api.asc_changeImageFromFile();
}
Common.NotificationCenter.trigger("edit:complete", this);
},
this));
this.btnInsertFromUrl.on("click", _.bind(this.insertFromUrl, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
},
setApi: function (api) {
if (api == undefined) {
return;
}
this.api = api;
return this;
},
updateMetricUnit: function () {
if (this.spinners) {
for (var i = 0; i < this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]);
spinner.setStep(Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
ChangeSettings: function (props) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
this.disableControls(this._locked);
if (props) {
var value = props.asc_getWidth();
if (Math.abs(this._state.Width - value) > 0.001 || (this._state.Width === null || value === null) && (this._state.Width !== value)) {
this.spnWidth.setValue((value !== null) ? Common.Utils.Metric.fnRecalcFromMM(value) : "", true);
this._state.Width = value;
}
value = props.asc_getHeight();
if (Math.abs(this._state.Height - value) > 0.001 || (this._state.Height === null || value === null) && (this._state.Height !== value)) {
this.spnHeight.setValue((value !== null) ? Common.Utils.Metric.fnRecalcFromMM(value) : "", true);
this._state.Height = value;
}
if (props.asc_getHeight() > 0) {
this._nRatio = props.asc_getWidth() / props.asc_getHeight();
}
this.btnOriginalSize.setDisabled(props.asc_getImageUrl() === null || props.asc_getImageUrl() === undefined || this._locked);
}
},
onWidthChange: function (field, newValue, oldValue, eOpts) {
var w = field.getNumberValue();
var h = this.spnHeight.getNumberValue();
if (this.btnRatio.pressed) {
h = w / this._nRatio;
if (h > this.spnHeight.options.maxValue) {
h = this.spnHeight.options.maxValue;
w = h * this._nRatio;
this.spnWidth.setValue(w, true);
}
this.spnHeight.setValue(h, true);
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onHeightChange: function (field, newValue, oldValue, eOpts) {
var h = field.getNumberValue(),
w = this.spnWidth.getNumberValue();
if (this.btnRatio.pressed) {
w = h * this._nRatio;
if (w > this.spnWidth.options.maxValue) {
w = this.spnWidth.options.maxValue;
h = w / this._nRatio;
this.spnHeight.setValue(h, true);
}
this.spnWidth.setValue(w, true);
}
if (this.api) {
var props = new Asc.asc_CImgProperty();
props.asc_putWidth(Common.Utils.Metric.fnRecalcToMM(w));
props.asc_putHeight(Common.Utils.Metric.fnRecalcToMM(h));
this.api.asc_setGraphicObjectProps(props);
}
Common.NotificationCenter.trigger("edit:complete", this);
},
setOriginalSize: function () {
if (this.api) {
var imgsize = this.api.asc_getOriginalImageSize();
var w = imgsize.asc_getImageWidth();
var h = imgsize.asc_getImageHeight();
var properties = new Asc.asc_CImgProperty();
properties.asc_putWidth(w);
properties.asc_putHeight(h);
this.api.asc_setGraphicObjectProps(properties);
Common.NotificationCenter.trigger("edit:complete", this);
}
},
insertFromUrl: function () {
var me = this;
(new Common.Views.ImageFromUrlDialog({
handler: function (result, value) {
if (result == "ok") {
if (me.api) {
var checkUrl = value.replace(/ /g, "");
if (!_.isEmpty(checkUrl)) {
var props = new Asc.asc_CImgProperty();
props.asc_putImageUrl(checkUrl);
me.api.asc_setGraphicObjectProps(props);
}
}
}
Common.NotificationCenter.trigger("edit:complete", me);
}
})).show();
},
setLocked: function (locked) {
this._locked = locked;
},
disableControls: function (disable) {
if (this._state.DisabledControls !== disable) {
this._state.DisabledControls = disable;
_.each(this.lockedControls, function (item) {
item.setDisabled(disable);
});
}
},
textKeepRatio: "Constant Proportions",
textSize: "Size",
textWidth: "Width",
textHeight: "Height",
textOriginalSize: "Default Size",
textInsert: "Insert Image",
textFromUrl: "From URL",
textFromFile: "From File"
},
SSE.Views.ImageSettings || {}));
});

View File

@@ -0,0 +1,253 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/LeftMenu.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/view/About", "common/main/lib/view/Comments", "common/main/lib/view/Chat", "common/main/lib/view/SearchDialog", "spreadsheeteditor/main/app/view/FileMenu"], function (menuTemplate, $, _, Backbone) {
var SCALE_MIN = 40;
var MENU_SCALE_PART = 300;
SSE.Views.LeftMenu = Backbone.View.extend(_.extend({
el: "#left-menu",
template: _.template(menuTemplate),
events: function () {
return {
"click #left-btn-support": function () {
window.open("http://feedback.onlyoffice.com/");
},
"click #left-btn-comments": _.bind(this.onCoauthOptions, this),
"click #left-btn-chat": _.bind(this.onCoauthOptions, this)
};
},
initialize: function () {
this.minimizedMode = true;
},
render: function () {
var el = $(this.el);
el.html(this.template({}));
this.btnFile = new Common.UI.Button({
action: "file",
el: $("#left-btn-file", this.el),
hint: this.tipFile + Common.Utils.String.platformKey("Alt+F"),
enableToggle: true,
disabled: true,
toggleGroup: "leftMenuGroup"
});
this.btnSearch = new Common.UI.Button({
action: "search",
el: $("#left-btn-search", this.el),
hint: this.tipSearch + Common.Utils.String.platformKey("Ctrl+F"),
disabled: true,
enableToggle: true
});
this.btnAbout = new Common.UI.Button({
action: "about",
el: $("#left-btn-about", this.el),
hint: this.tipAbout,
enableToggle: true,
disabled: true,
toggleGroup: "leftMenuGroup"
});
this.btnSupport = new Common.UI.Button({
action: "support",
el: $("#left-btn-support", this.el),
hint: this.tipSupport,
disabled: true
});
this.btnComments = new Common.UI.Button({
el: $("#left-btn-comments", this.el),
hint: this.tipComments + Common.Utils.String.platformKey("Ctrl+Shift+H"),
enableToggle: true,
disabled: true,
toggleGroup: "leftMenuGroup"
});
this.btnChat = new Common.UI.Button({
el: $("#left-btn-chat", this.el),
hint: this.tipChat + Common.Utils.String.platformKey("Ctrl+Alt+Q", null, function (string) {
return Common.Utils.isMac ? string.replace(/Ctrl|ctrl/g, "⌃") : string;
}),
enableToggle: true,
disabled: true,
toggleGroup: "leftMenuGroup"
});
this.btnComments.hide();
this.btnChat.hide();
this.btnComments.on("click", _.bind(this.onBtnMenuClick, this));
this.btnChat.on("click", _.bind(this.onBtnMenuClick, this));
this.btnSearch.on("click", _.bind(this.onBtnMenuClick, this));
this.btnAbout.on("toggle", _.bind(this.onBtnMenuToggle, this));
this.btnFile.on("toggle", _.bind(this.onBtnMenuToggle, this));
var menuFile = new SSE.Views.FileMenu({});
menuFile.options = {
alias: "FileMenu"
};
this.btnFile.panel = menuFile.render();
this.btnAbout.panel = (new Common.Views.About({
el: $("#about-menu-panel"),
appName: "Spreadsheet Editor"
})).render();
return this;
},
onBtnMenuToggle: function (btn, state) {
if (state) {
this.btnFile.pressed && this.fireEvent("file:show", this);
btn.panel["show"]();
this.$el.width(SCALE_MIN);
if (this.btnSearch.isActive()) {
this.btnSearch.toggle(false);
}
} else {
(this.btnFile.id == btn.id) && this.fireEvent("file:hide", this);
btn.panel["hide"]();
}
if (this.mode.isEdit) {
SSE.getController("Toolbar").DisableToolbar(state == true);
}
Common.NotificationCenter.trigger("layout:changed", "leftmenu");
},
onBtnMenuClick: function (btn, e) {
this.btnFile.toggle(false);
this.btnAbout.toggle(false);
if (btn.options.action == "search") {} else {
if (btn.pressed) {
if (! (this.$el.width() > SCALE_MIN)) {
this.$el.width(localStorage.getItem("sse-mainmenu-width") || MENU_SCALE_PART);
}
} else {
localStorage.setItem("sse-mainmenu-width", this.$el.width());
this.$el.width(SCALE_MIN);
}
}
Common.NotificationCenter.trigger("layout:changed", "leftmenu");
},
onCoauthOptions: function (e) {
if (this.mode.canCoAuthoring) {
this.panelComments[this.btnComments.pressed ? "show" : "hide"]();
this.fireEvent((this.btnComments.pressed) ? "comments:show": "comments:hide", this);
if (this.btnChat.pressed) {
if (this.btnChat.$el.hasClass("notify")) {
this.btnChat.$el.removeClass("notify");
}
this.panelChat.show();
this.panelChat.focus();
} else {
this.panelChat["hide"]();
}
}
},
setOptionsPanel: function (name, panel) {
if (name == "chat") {
this.panelChat = panel.render("#left-panel-chat");
} else {
if (name == "comment") {
this.panelComments = panel;
}
}
},
markCoauthOptions: function (opt) {
if (this.btnChat.isVisible() && !this.btnChat.isDisabled() && !this.btnChat.pressed) {
this.btnChat.$el.addClass("notify");
}
},
close: function (menu) {
this.btnFile.toggle(false);
this.btnAbout.toggle(false);
this.$el.width(SCALE_MIN);
if (this.mode.canCoAuthoring) {
this.panelComments["hide"]();
this.panelChat["hide"]();
if (this.btnComments.pressed) {
this.fireEvent("comments:hide", this);
}
this.btnComments.toggle(false, true);
this.btnChat.toggle(false, true);
}
},
isOpened: function () {
var isopened = this.btnFile.pressed || this.btnSearch.pressed; ! isopened && (isopened = this.btnComments.pressed || this.btnChat.pressed);
return isopened;
},
disableMenu: function (menu, disable) {
this.btnFile.setDisabled(false);
this.btnAbout.setDisabled(false);
this.btnSupport.setDisabled(false);
this.btnSearch.setDisabled(false);
this.btnComments.setDisabled(false);
this.btnChat.setDisabled(false);
},
showMenu: function (menu) {
var re = /^(\w+):?(\w*)$/.exec(menu);
if (re[1] == "file") {
if (!this.btnFile.pressed) {
this.btnFile.toggle(true);
this.btnFile.$el.focus();
}
this.btnFile.panel.show(re[2].length ? re[2] : undefined);
} else {
if (menu == "chat") {
if (this.btnChat.isVisible() && !this.btnChat.isDisabled() && !this.btnChat.pressed) {
this.btnChat.toggle(true);
this.onBtnMenuClick(this.btnChat);
this.onCoauthOptions();
this.panelChat.focus();
}
} else {
if (menu == "comments") {
if (this.btnComments.isVisible() && !this.btnComments.isDisabled() && !this.btnComments.pressed) {
this.btnComments.toggle(true);
this.onBtnMenuClick(this.btnComments);
this.onCoauthOptions();
this.btnComments.$el.focus();
}
}
}
}
},
getMenu: function (type) {
switch (type) {
case "file":
return this.btnFile.panel;
case "about":
return this.btnAbout.panel;
default:
return null;
}
},
setMode: function (mode) {
this.mode = mode;
return this;
},
tipComments: "Comments",
tipChat: "Chat",
tipAbout: "About",
tipSupport: "Feedback & Support",
tipFile: "File",
tipSearch: "Search"
},
SSE.Views.LeftMenu || {}));
});

View File

@@ -1,358 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var SCALE_MIN = 40;
var SCALE_FULL = "100%";
var SCALE_PART = 300;
var MAINMENU_TOOLBAR_ID = "mainmenu-toolbar-id";
var MAINMENU_PANEL_ID = "mainmenu-panel-id";
var MAINMENU_FULL_PANEL_ID = "mainmenu-full-panel-id";
Ext.define("SSE.view.MainMenu", {
extend: "Ext.panel.Panel",
alias: "widget.ssemainmenu",
requires: ["Ext.toolbar.Toolbar", "Ext.button.Button", "Ext.container.Container", "Ext.toolbar.Spacer"],
cls: "lm-style",
id: MAINMENU_PANEL_ID,
bodyCls: "lm-body",
width: SCALE_MIN,
layout: "card",
currentFullScaleMenuBtn: undefined,
fullScaledItemCnt: undefined,
buttonCollection: [],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
listeners: {
afterrender: function () {
var owner = this.ownerCt;
if (Ext.isDefined(owner)) {
owner.addListener("resize", Ext.bind(this.resizeMenu, this));
}
}
},
initComponent: function () {
this.items = [];
this.dockedItems = this.buildDockedItems();
this.addEvents("panelshow", "panelhide");
this.callParent(arguments);
},
buildDockedItems: function () {
var addedButtons = [],
item,
cardId,
config;
var me = this;
for (var i = 0; i < this.buttonCollection.length; i++) {
item = this.buttonCollection[i];
cardId = -1;
config = {
xtype: "button",
id: item.id,
itemScale: item.scale,
tooltip: item.tooltip,
disabled: item.disabled === true,
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn " + item.cls,
style: "margin-bottom: 8px;"
};
if (item.scale == "modal") {
config.enableToggle = true;
config.listeners = item.listeners;
config.getApi = function () {
return me.api;
};
} else {
config.isFullScale = item.scale == "full";
config.bodyItems = item.items;
config.toggleGroup = "tbMainMenu";
config.listeners = {
click: function (btnCall) {
if (btnCall.pressed) {
me.openButtonMenu(btnCall);
}
},
toggle: function (btnCall, pressed) {
btnCall[pressed ? "addCls" : "removeCls"]("asc-main-menu-btn-selected");
if (!pressed) {
me.fireEvent("panelbeforehide");
if (btnCall.isFullScale) {
if (Ext.isDefined(me.fullScaledItemCnt) && me.fullScaledItemCnt.isVisible()) {
me.fullScaledItemCnt.hide();
me.currentFullScaleMenuBtn = undefined;
}
var panel = me.fullScaledItemCnt;
} else {
window.localStorage.setItem("sse-mainmenu-width", me.getWidth());
panel = Ext.getCmp(btnCall.bodyCardId);
me.setWidth(SCALE_MIN);
}
me.fireEvent("panelhide", panel, btnCall.isFullScale);
}
}
};
}
addedButtons.push(config);
}
this.mainToolbar = Ext.create("Ext.toolbar.Toolbar", {
cls: "lm-default-toolbar",
width: this.width || SCALE_MIN,
vertical: true,
dock: "left",
defaultType: "button",
items: addedButtons,
style: "padding-top:15px;",
listeners: {
afterrender: function (cmp) {
cmp.getEl().on("keydown", me._onMenuKeyDown, me, {
button: undefined
});
}
}
});
return this.mainToolbar;
},
closeFullScaleMenu: function () {
if (Ext.isDefined(this.currentFullScaleMenuBtn)) {
this.currentFullScaleMenuBtn.toggle(false);
}
},
openButtonMenu: function (btn) {
this.fireEvent("panelbeforeshow", btn.isFullScale);
if (Ext.isNumber(btn.itemScale)) {
var saved_width = window.localStorage.getItem("sse-mainmenu-width");
saved_width = saved_width ? parseInt(saved_width) : btn.itemScale;
this.setSize({
width: saved_width
});
} else {
this.setWidth(btn.isFullScale ? SCALE_MIN : SCALE_PART);
}
if (btn.isFullScale) {
var ownerEl = this.ownerCt.el;
var startPos = ownerEl.getXY();
var panel = this.fullScaledItemCnt;
this.currentFullScaleMenuBtn = btn;
this.fullScaledItemCnt.setSize(ownerEl.getWidth() - SCALE_MIN, ownerEl.getHeight());
this.fullScaledItemCnt.setPosition(startPos[0] + this.width, startPos[1]);
this.fullScaledItemCnt.show();
this.fullScaledItemCnt.getLayout().setActiveItem(Ext.getCmp(btn.bodyCardId));
} else {
panel = Ext.getCmp(btn.bodyCardId);
this.getLayout().setActiveItem(btn.bodyCardId);
}
btn.removeCls("notify");
this.fireEvent("panelshow", panel, btn.isFullScale);
this.doComponentLayout();
Common.component.Analytics.trackEvent("Main Menu", btn.tooltip);
},
resizeMenu: function (Component, adjWidth, adjHeight, eOpts) {
if (Ext.isDefined(this.fullScaledItemCnt) && this.fullScaledItemCnt.isVisible()) {
var ownerEl = this.ownerCt.el;
var startPos = ownerEl.getXY();
this.fullScaledItemCnt.setSize(adjWidth - SCALE_MIN, adjHeight);
this.fullScaledItemCnt.setPosition(startPos[0] + this.width, startPos[1]);
} else {
for (var i = 0; i < this.items.length; i++) {
var h = this.items.items[i].getHeight();
if (adjHeight != h) {
this.items.items[i].setHeight(adjHeight);
}
}
}
this.doComponentLayout();
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage", Ext.bind(this.onCoAuthoringChatReceiveMessage, this));
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
this.api.asc_registerCallback("asc_onGetLicense", Ext.bind(this.onGetLicense, this));
return this;
},
selectMenu: function (clsname) {
var btnCall, btn, i, panel;
var tbMain = this.mainToolbar;
for (i = tbMain.items.length; i > 0; i--) {
btnCall = tbMain.items.items[i - 1];
if (btnCall.iconCls && !(btnCall.iconCls.search(clsname) < 0)) {
break;
} else {
btnCall = undefined;
}
}
if (btnCall && !btnCall.pressed) {
if (Ext.isDefined(tbMain)) {
for (i = 0; i < tbMain.items.length; i++) {
btn = tbMain.items.items[i];
if (Ext.isDefined(btn) && btn.componentCls === "x-btn") {
if (btn.id != btnCall.id && btn.pressed) {
btn.toggle(false);
}
}
}
}
btnCall.toggle(true);
if (btnCall.itemScale != "modal") {
this.openButtonMenu(btnCall);
}
}
},
clearSelection: function (exclude) {
var btn, i;
var tbMain = this.mainToolbar;
if (Ext.isDefined(tbMain)) {
for (i = 0; i < tbMain.items.length; i++) {
btn = tbMain.items.items[i];
if (Ext.isDefined(btn) && btn.componentCls === "x-btn") {
if (btn.pressed) {
if (exclude) {
if (typeof exclude == "object") {
if (exclude.id == btn.id) {
continue;
}
} else {
if (btn.iconCls && !(btn.iconCls.search(exclude) < 0)) {
continue;
}
}
}
btn.toggle(false);
}
}
}
}
},
disableMenu: function (btns, disabled) {
var btn, i;
var tbMain = this.mainToolbar;
if (Ext.isDefined(tbMain)) {
var apply_all = false;
typeof btns == "string" && (btns == "all" ? apply_all = true : btns = [btns]);
for (i = 0; i < tbMain.items.length; i++) {
btn = tbMain.items.items[i];
if (Ext.isDefined(btn) && btn.componentCls === "x-btn") {
if (apply_all || !(btns.indexOf(btn.id) < 0)) {
btn.pressed && btn.toggle(false);
btn.setDisabled(disabled);
}
}
}
}
},
onCoAuthoringChatReceiveMessage: function (messages) {
var mainMenu = Ext.getCmp("view-main-menu");
if (mainMenu) {
var activeStep;
mainMenu.getLayout().getActiveItem() && (activeStep = mainMenu.getLayout().getActiveItem().down("container"));
var btnChat = Ext.getCmp("id-menu-chat");
if (btnChat) {
if (!activeStep || !activeStep.isXType("commonchatpanel") || activeStep.getWidth() < 1) {
btnChat.addCls("notify");
}
}
}
},
onCoAuthoringDisconnect: function () {
this.disableMenu(["id-menu-comments", "id-menu-chat"], true);
},
onGetLicense: function (license) {
var panel = Ext.getCmp("main-menu-about");
if (panel) {
panel.setLicInfo(license);
}
},
createDelayedElements: function () {
var me = this;
this.hkEsc = new Ext.util.KeyMap(document, [{
key: Ext.EventObject.ESC,
fn: function (key, e) {
if (Ext.isDefined(me.currentFullScaleMenuBtn)) {
e.stopPropagation();
e.preventDefault();
me.currentFullScaleMenuBtn.toggle(false);
}
}
}]);
var addedItems = [],
addedButtons = this.mainToolbar.items.items,
item;
for (var i = 0; i < this.buttonCollection.length; i++) {
item = this.buttonCollection[i];
if (item.scale == "modal") {} else {
if (item.scale != "full") {
var cardPanel = Ext.create("Ext.container.Container", {
items: item.items,
menubutton: addedButtons[i],
listeners: {
afterrender: function (cmp) {
cmp.getEl().on("keydown", me._onMenuKeyDown, me, {
button: cmp.menubutton
});
}
}
});
addedButtons[i].bodyCardId = cardPanel.getId();
addedItems.push(cardPanel);
} else {
if (this.fullScaledItemCnt === undefined) {
this.fullScaledItemCnt = Ext.create("Ext.container.Container", {
id: MAINMENU_FULL_PANEL_ID,
layout: "card",
shadow: false,
floating: true,
toFrontOnShow: true,
closeMenu: function () {
me.closeFullScaleMenu();
},
getApi: function () {
return me.api;
}
});
}
addedButtons[i].bodyCardId = item.items[0].id;
this.fullScaledItemCnt.add(item.items);
}
}
}
me.api.asc_getLicense();
this.add(addedItems);
},
_onMenuKeyDown: function (event, target, opt) {
if (event.getKey() == event.ESC) {
if (opt.button) {
opt.button.toggle(false);
} else {
this.clearSelection();
}
}
}
});

View File

@@ -1,353 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.MainSettingsGeneral", {
extend: "Ext.container.Container",
alias: "widget.ssemainsettingsgeneral",
cls: "sse-documentsettings-body",
requires: ["Ext.button.Button", "Ext.container.Container", "Ext.form.Label", "Ext.form.field.Checkbox", "Ext.util.Cookies"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this._changedProps = {
zoomIdx: 5,
showchangesIdx: 1,
fontrenderIdx: 0,
unitIdx: 0,
saveVal: 600
};
this._oldUnit = undefined;
this.chLiveComment = Ext.create("Ext.form.field.Checkbox", {
id: "docsettings-live-comment",
checked: true,
boxLabel: this.strLiveComment,
width: 500
});
this._arrZoom = [[50, "50%"], [60, "60%"], [70, "70%"], [80, "80%"], [90, "90%"], [100, "100%"], [110, "110%"], [120, "120%"], [150, "150%"], [175, "175%"], [200, "200%"]];
this.cmbZoom = Ext.create("Ext.form.field.ComboBox", {
width: 90,
editable: false,
store: this._arrZoom,
mode: "local",
triggerAction: "all",
value: this._arrZoom[5][1],
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this._changedProps.zoomIdx = records[0].index;
combo.blur();
},
this)
}
});
this._arrFontRender = [[c_oAscFontRenderingModeType.hintingAndSubpixeling, this.txtWin], [c_oAscFontRenderingModeType.noHinting, this.txtMac], [c_oAscFontRenderingModeType.hinting, this.txtNative]];
this.cmbFontRender = Ext.create("Ext.form.field.ComboBox", {
id: "docsettings-font-render",
width: 150,
editable: false,
store: this._arrFontRender,
mode: "local",
triggerAction: "all",
value: this._arrFontRender[0][1],
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this._changedProps.fontrenderIdx = records[0].index;
combo.blur();
},
this)
}
});
this._arrUnit = [[Common.MetricSettings.c_MetricUnits.cm, this.txtCm], [Common.MetricSettings.c_MetricUnits.pt, this.txtPt]];
this.cmbUnit = Ext.create("Ext.form.field.ComboBox", {
id: "docsettings-combo-unit",
width: 150,
editable: false,
store: this._arrUnit,
mode: "local",
triggerAction: "all",
value: this._arrUnit[0][1],
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this._changedProps.unitIdx = records[0].index;
combo.blur();
},
this)
}
});
this._arrAutoSave = [[0, this.textDisabled], [60, this.textMinute], [300, this.text5Minutes], [600, this.text10Minutes], [1800, this.text30Minutes], [3600, this.text60Minutes]];
this.cmbAutoSave = Ext.create("Ext.form.field.ComboBox", {
id: "docsettings-combo-save",
width: 150,
editable: false,
store: this._arrAutoSave,
mode: "local",
triggerAction: "all",
value: this._arrAutoSave[3][1],
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this._changedProps.saveVal = records[0].data.field1;
combo.blur();
},
this)
}
});
this.btnOk = Ext.widget("button", {
cls: "asc-blue-button",
width: 90,
height: 22,
text: this.okButtonText,
listeners: {
click: function (btn) {
this.applySettings();
},
scope: this
}
});
this.items = [{
xtype: "container",
layout: {
type: "table",
columns: 2,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
style: "padding: 5px 10px;"
}
},
height: "100%",
items: [{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtLiveComment,
style: "display: block;text-align: right; margin-bottom: 1px;",
width: "100%",
hideId: "element-coauthoring"
},
this.chLiveComment, {
xtype: "tbspacer",
hideId: "element-coauthoring"
},
{
xtype: "tbspacer"
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.strZoom,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%"
},
this.cmbZoom, {
xtype: "tbspacer"
},
{
xtype: "tbspacer"
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.strFontRender,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%"
},
this.cmbFontRender, {
xtype: "tbspacer",
hideId: "element-edit-mode"
},
{
xtype: "tbspacer"
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.textAutoSave,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%",
hideId: "element-autosave"
},
this.cmbAutoSave, {
xtype: "tbspacer",
hideId: "element-autosave"
},
{
xtype: "tbspacer"
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.strUnit,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%",
hideId: "element-edit-mode"
},
this.cmbUnit, {
xtype: "tbspacer",
height: 10
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "tbspacer"
},
this.btnOk]
}];
this.addEvents("savedocsettings");
this.addEvents("changemeasureunit");
this.callParent(arguments);
},
setApi: function (o) {
this.api = o;
},
applySettings: function () {
window.localStorage.setItem("sse-settings-livecomment", this.chLiveComment.getValue() ? 1 : 0);
window.localStorage.setItem("sse-settings-zoom", this._arrZoom[this._changedProps.zoomIdx][0]);
window.localStorage.setItem("sse-settings-fontrender", this._arrFontRender[this._changedProps.fontrenderIdx][0]);
window.localStorage.setItem("sse-settings-unit", this._arrUnit[this._changedProps.unitIdx][0]);
window.localStorage.setItem("sse-settings-autosave", this._changedProps.saveVal);
Common.component.Analytics.trackEvent("File Menu", "SaveSettings");
this.fireEvent("savedocsettings", this);
if (this._oldUnit !== this._arrUnit[this._changedProps.unitIdx][0]) {
this.fireEvent("changemeasureunit", this);
}
},
updateSettings: function () {
value = window.localStorage.getItem("sse-settings-livecomment");
this.chLiveComment.setValue(!(value !== null && parseInt(value) == 0));
var value = window.localStorage.getItem("sse-settings-zoom");
this._changedProps.zoomIdx = 5;
if (value !== null) {
for (var i = 0; i < this._arrZoom.length; i++) {
if (this._arrZoom[i][0] == parseInt(value)) {
this._changedProps.zoomIdx = i;
break;
}
}
}
this.cmbZoom.setValue(this._arrZoom[this._changedProps.zoomIdx][1]);
value = window.localStorage.getItem("sse-settings-fontrender");
if (value !== null) {
value = parseInt(value);
} else {
value = window.devicePixelRatio > 1 ? c_oAscFontRenderingModeType.noHinting : c_oAscFontRenderingModeType.hintingAndSubpixeling;
}
for (i = 0; i < this._arrFontRender.length; i++) {
if (this._arrFontRender[i][0] == value) {
this._changedProps.fontrenderIdx = i;
break;
}
}
this.cmbFontRender.setValue(this._arrFontRender[this._changedProps.fontrenderIdx][1]);
value = window.localStorage.getItem("sse-settings-unit");
this._changedProps.unitIdx = 0;
if (value !== null) {
for (i = 0; i < this._arrUnit.length; i++) {
if (this._arrUnit[i][0] == parseInt(value)) {
this._changedProps.unitIdx = i;
break;
}
}
}
this.cmbUnit.setValue(this._arrUnit[this._changedProps.unitIdx][1]);
this._oldUnit = this._arrUnit[this._changedProps.unitIdx][0];
value = window.localStorage.getItem("sse-settings-autosave");
value = (value !== null) ? parseInt(value) : 600;
this._changedProps.saveVal = 600;
var idx = 3;
for (i = 0; i < this._arrAutoSave.length; i++) {
if (this._arrAutoSave[i][0] == value) {
this._changedProps.saveVal = value;
idx = i;
break;
}
}
this.cmbAutoSave.setValue(this._arrAutoSave[idx][1]);
this._ShowHideDocSettings("element-autosave", this.mode.isEdit && (this.mode.canAutosave > -1));
},
_ShowHideSettingsItem: function (cmp, visible) {
var tr = cmp.getEl().up("tr");
if (tr) {
tr.setDisplayed(visible);
}
},
_ShowHideDocSettings: function (id, visible) {
if (!this.rendered) {
return;
}
var components = Ext.ComponentQuery.query('[hideId="' + id + '"]', this);
for (var i = 0; i < components.length; i++) {
this._ShowHideSettingsItem(components[i], visible);
}
},
setMode: function (mode) {
this.mode = mode;
if (this.mode.canAutosave > -1) {
var idx = 0;
for (idx = 1; idx < this._arrAutoSave.length; idx++) {
if (this.mode.canAutosave < this._arrAutoSave[idx][0]) {
break;
}
}
}
var arr = [];
arr = this._arrAutoSave.slice(idx, this._arrAutoSave.length);
arr.unshift(this._arrAutoSave[0]);
if (arr.length > 0) {
this.cmbAutoSave.getStore().loadData(arr);
}
},
strLiveComment: "Turn on live commenting option",
txtLiveComment: "Live Commenting",
strInputMode: "Turn on hieroglyphs",
strZoom: "Default Zoom Value",
strShowChanges: "Realtime Collaboration Changes",
txtAll: "View All",
txtLast: "View Last",
okButtonText: "Apply",
txtWin: "as Windows",
txtMac: "as OS X",
txtNative: "Native",
strFontRender: "Font Hinting",
strUnit: "Unit of Measurement",
txtCm: "Centimeter",
txtPt: "Point",
textDisabled: "Disabled",
textMinute: "Every Minute",
text5Minutes: "Every 5 Minutes",
text10Minutes: "Every 10 Minutes",
text30Minutes: "Every 30 Minutes",
text60Minutes: "Every Hour",
textAutoSave: "Autosave"
});

View File

@@ -1,366 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.MainSettingsPrint", {
extend: "Ext.container.Container",
alias: "widget.ssemainsettingsprint",
cls: "sse-documentsettings-body",
requires: ["Ext.button.Button", "Ext.container.Container", "Ext.form.Label", "Common.component.IndeterminateCheckBox"],
listeners: {
show: function (cmp, eOpts) {}
},
height: "100%",
initComponent: function () {
var me = this;
this.cmbSheet = Ext.create("Ext.form.field.ComboBox", {
id: "advsettings-print-combo-sheets",
width: 260,
editable: false,
store: Ext.create("Ext.data.Store", {
fields: ["sheetname", {
type: "int",
name: "sheetindex"
}],
data: [{
sheetname: me.strAllSheets,
sheetindex: -255
}]
}),
queryMode: "local",
displayField: "sheetname",
valueField: "sheetindex",
triggerAction: "all"
});
this.cmbPaperSize = Ext.widget("combo", {
width: 260,
store: Ext.create("Ext.data.Store", {
fields: ["description", "size"],
data: [{
size: "215.9|279.4",
description: "US Letter (21,59cm x 27,94cm)"
},
{
size: "215.9|355.6",
description: "US Legal (21,59cm x 35,56cm)"
},
{
size: "210|297",
description: "A4 (21cm x 29,7cm)"
},
{
size: "148.1|209.9",
description: "A5 (14,81cm x 20,99cm)"
},
{
size: "176|250.1",
description: "B5 (17,6cm x 25,01cm)"
},
{
size: "104.8|241.3",
description: "Envelope #10 (10,48cm x 24,13cm)"
},
{
size: "110.1|220.1",
description: "Envelope DL (11,01cm x 22,01cm)"
},
{
size: "279.4|431.7",
description: "Tabloid (27,94cm x 43,17cm)"
},
{
size: "297|420.1",
description: "A3 (29,7cm x 42,01cm)"
},
{
size: "304.8|457.1",
description: "Tabloid Oversize (30,48cm x 45,71cm)"
},
{
size: "196.8|273",
description: "ROC 16K (19,68cm x 27,3cm)"
},
{
size: "119.9|234.9",
description: "Envelope Choukei 3 (11,99cm x 23,49cm)"
},
{
size: "330.2|482.5",
description: "Super B/A3 (33,02cm x 48,25cm)"
}]
}),
displayField: "description",
valueField: "size",
queryMode: "local",
editable: false
});
this.cmbPaperOrientation = Ext.widget("combo", {
store: Ext.create("Ext.data.Store", {
fields: ["description", "orient"],
data: [{
description: me.strPortrait,
orient: c_oAscPageOrientation.PagePortrait
},
{
description: me.strLandscape,
orient: c_oAscPageOrientation.PageLandscape
}]
}),
displayField: "description",
valueField: "orient",
queryMode: "local",
editable: false,
width: 200
});
this.chPrintGrid = Ext.widget("cmdindeterminatecheckbox", {
boxLabel: this.textPrintGrid,
width: 500
});
this.chPrintRows = Ext.widget("cmdindeterminatecheckbox", {
boxLabel: this.textPrintHeadings,
width: 500
});
this.spnMarginLeft = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0.19 cm",
listeners: {}
});
this.spnMarginRight = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0.19 cm",
listeners: {}
});
this.spnMarginTop = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0 cm",
listeners: {}
});
this.spnMarginBottom = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0 cm",
listeners: {}
});
this.btnOk = Ext.widget("button", {
id: "advsettings-print-button-save",
cls: "asc-blue-button",
width: 90,
height: 22,
text: this.okButtonText
});
this.items = [{
xtype: "container",
layout: {
type: "table",
columns: 2,
tableAttrs: {
style: "width: 100%;"
},
tdAttrs: {
style: "padding: 10px 10px;"
}
},
items: [{
xtype: "label",
cellCls: "doc-info-label-cell",
text: me.textSettings,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%"
},
this.cmbSheet, {
xtype: "tbspacer",
height: 5
},
{
xtype: "tbspacer",
height: 5
},
{
xtype: "label",
cellCls: "doc-info-label-cell",
text: me.textPageSize,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%"
},
this.cmbPaperSize, {
xtype: "label",
cellCls: "doc-info-label-cell",
text: me.textPageOrientation,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%"
},
this.cmbPaperOrientation, {
xtype: "label",
cellCls: "doc-info-label-cell label-align-top",
text: me.strMargins,
style: "display: block;text-align: right;",
width: "100%"
},
this.cntMargins = Ext.widget("container", {
height: 100,
width: 200,
layout: {
type: "hbox"
},
defaults: {
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
height: 100
},
items: [{
flex: 1,
items: [{
xtype: "label",
width: "100%",
text: me.strTop
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginTop, {
xtype: "tbspacer",
height: 12
},
{
xtype: "label",
width: "100%",
text: me.strLeft
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginLeft]
},
{
xtype: "tbspacer",
width: 20
},
{
flex: 1,
items: [{
xtype: "label",
text: me.strBottom,
width: "100%"
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginBottom, {
xtype: "tbspacer",
height: 12
},
{
xtype: "label",
text: me.strRight,
width: "100%"
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginRight]
}]
}), {
xtype: "label",
cellCls: "doc-info-label-cell label-align-top",
text: me.strPrint,
style: "display: block;text-align: right; margin-top: 4px;",
width: "100%"
},
this.cntAdditional = Ext.widget("container", {
height: 45,
width: 500,
layout: {
type: "vbox",
align: "stretch"
},
items: [this.chPrintGrid, this.chPrintRows]
}), {
xtype: "tbspacer"
},
{
xtype: "tbspacer"
},
{
xtype: "tbspacer"
},
this.btnOk]
}];
this.addEvents("savedocsettings");
this.callParent(arguments);
},
applySettings: function () {},
setMode: function (mode) {},
updateMetricUnit: function () {
var spinners = this.query("commonmetricspinner");
if (spinners) {
for (var i = 0; i < spinners.length; i++) {
var spinner = spinners[i];
spinner.setDefaultUnit(Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
spinner.setStep(Common.MetricSettings.getCurrentMetric() == Common.MetricSettings.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
okButtonText: "Save",
strPortrait: "Portrait",
strLandscape: "Landscape",
textPrintGrid: "Print Gridlines",
textPrintHeadings: "Print Rows and Columns Headings",
strLeft: "Left",
strRight: "Right",
strTop: "Top",
strBottom: "Bottom",
strMargins: "Margins",
textPageSize: "Page Size",
textPageOrientation: "Page Orientation",
strPrint: "Print",
textSettings: "Settings for"
});

View File

@@ -1,274 +1,149 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.OpenDialog", {
extend: "Ext.window.Window",
alias: "widget.sseopendialog",
requires: ["Ext.window.Window", "Common.plugin.ComboBoxScrollPane"],
modal: true,
closable: false,
resizable: false,
height: 218,
width: 250,
padding: "15px 0 0 0",
layout: {
type: "vbox",
align: "stretch"
},
cls: "csv-open-dialog",
initComponent: function () {
this.title = this.title || this.txtTitle;
var encodedata = [];
if (this.codepages) {
encodedata = [];
for (var i = 0; i < this.codepages.length; i++) {
var codepage = this.codepages[i];
var c = [];
c[0] = codepage.asc_getCodePage();
c[1] = codepage.asc_getCodePageName();
encodedata.push(c);
}
} else {
encodedata = [[37, "IBM EBCDIC (US-Canada)"], [437, "OEM United States"], [500, "IBM EBCDIC (International)"], [708, "Arabic (ASMO 708)"], [720, "Arabic (DOS)"], [737, "Greek (DOS)"], [775, "Baltic (DOS)"], [850, "Western European (DOS)"], [852, "Central European (DOS)"], [855, "OEM Cyrillic"], [857, "Turkish (DOS)"], [858, "OEM Multilingual Latin I"], [860, "Portuguese (DOS)"], [861, "Icelandic (DOS)"], [862, "Hebrew (DOS)"], [863, "French Canadian (DOS)"], [864, "Arabic (864) "], [865, "Nordic (DOS)"], [866, "Cyrillic (DOS)"], [869, "Greek, Modern (DOS)"], [870, "IBM EBCDIC (Multilingual Latin-2)"], [874, "Thai (Windows)"], [875, "IBM EBCDIC (Greek Modern)"], [932, "Japanese (Shift-JIS)"], [936, "Chinese Simplified (GB2312)"], [949, "Korean"], [950, "Chinese Traditional (Big5)"], [1026, "IBM EBCDIC (Turkish Latin-5)"], [1047, "IBM Latin-1"], [1140, "IBM EBCDIC (US-Canada-Euro)"], [1141, "IBM EBCDIC (Germany-Euro)"], [1142, "IBM EBCDIC (Denmark-Norway-Euro)"], [1143, "IBM EBCDIC (Finland-Sweden-Euro)"], [1144, "IBM EBCDIC (Italy-Euro)"], [1145, "IBM EBCDIC (Spain-Euro)"], [1146, "IBM EBCDIC (UK-Euro)"], [1147, "IBM EBCDIC (France-Euro)"], [1148, "IBM EBCDIC (International-Euro)"], [1149, "IBM EBCDIC (Icelandic-Euro)"], [1200, "Unicode"], [1201, "Unicode (Big-Endian)"], [1250, "Central European (Windows)"], [1251, "Cyrillic (Windows)"], [1252, "Western European (Windows)"], [1253, "Greek (Windows)"], [1254, "Turkish (Windows)"], [1255, "Hebrew (Windows) "], [1256, "Arabic (Windows) "], [1257, "Baltic (Windows)"], [1258, "Vietnamese (Windows)"], [1361, "Korean (Johab)"], [10000, "Western European (Mac)"], [10001, "Japanese (Mac)"], [10002, "Chinese Traditional (Mac)"], [10003, "Korean (Mac)"], [10004, "Arabic (Mac) "], [10005, "Hebrew (Mac)"], [10006, "Greek (Mac) "], [10007, "Cyrillic (Mac)"], [10008, "Chinese Simplified (Mac)"], [10010, "Romanian (Mac)"], [10017, "Ukrainian (Mac)"], [10021, "Thai (Mac)"], [10029, "Central European (Mac) "], [10079, "Icelandic (Mac)"], [10081, "Turkish (Mac)"], [10082, "Croatian (Mac)"], [12000, "Unicode (UTF-32)"], [12001, "Unicode (UTF-32 Big-Endian)"], [20000, "Chinese Traditional (CNS)"], [20001, "TCA Taiwan"], [20002, "Chinese Traditional (Eten)"], [20003, "IBM5550 Taiwan"], [20004, "TeleText Taiwan"], [20005, "Wang Taiwan"], [20105, "Western European (IA5)"], [20106, "German (IA5)"], [20107, "Swedish (IA5) "], [20108, "Norwegian (IA5) "], [20127, "US-ASCII"], [20261, "T.61 "], [20269, "ISO-6937"], [20273, "IBM EBCDIC (Germany)"], [20277, "IBM EBCDIC (Denmark-Norway) "], [20278, "IBM EBCDIC (Finland-Sweden)"], [20280, "IBM EBCDIC (Italy)"], [20284, "IBM EBCDIC (Spain)"], [20285, "IBM EBCDIC (UK)"], [20290, "IBM EBCDIC (Japanese katakana)"], [20297, "IBM EBCDIC (France)"], [20420, "IBM EBCDIC (Arabic)"], [20423, "IBM EBCDIC (Greek)"], [20424, "IBM EBCDIC (Hebrew)"], [20833, "IBM EBCDIC (Korean Extended)"], [20838, "IBM EBCDIC (Thai)"], [20866, "Cyrillic (KOI8-R)"], [20871, "IBM EBCDIC (Icelandic) "], [20880, "IBM EBCDIC (Cyrillic Russian)"], [20905, "IBM EBCDIC (Turkish)"], [20924, "IBM Latin-1 "], [20932, "Japanese (JIS 0208-1990 and 0212-1990)"], [20936, "Chinese Simplified (GB2312-80) "], [20949, "Korean Wansung "], [21025, "IBM EBCDIC (Cyrillic Serbian-Bulgarian)"], [21866, "Cyrillic (KOI8-U)"], [28591, "Western European (ISO) "], [28592, "Central European (ISO)"], [28593, "Latin 3 (ISO)"], [28594, "Baltic (ISO)"], [28595, "Cyrillic (ISO) "], [28596, "Arabic (ISO)"], [28597, "Greek (ISO) "], [28598, "Hebrew (ISO-Visual)"], [28599, "Turkish (ISO)"], [28603, "Estonian (ISO)"], [28605, "Latin 9 (ISO)"], [29001, "Europa"], [38598, "Hebrew (ISO-Logical)"], [50220, "Japanese (JIS)"], [50221, "Japanese (JIS-Allow 1 byte Kana) "], [50222, "Japanese (JIS-Allow 1 byte Kana - SO/SI)"], [50225, "Korean (ISO)"], [50227, "Chinese Simplified (ISO-2022)"], [51932, "Japanese (EUC)"], [51936, "Chinese Simplified (EUC) "], [51949, "Korean (EUC)"], [52936, "Chinese Simplified (HZ)"], [54936, "Chinese Simplified (GB18030)"], [57002, "ISCII Devanagari "], [57003, "ISCII Bengali "], [57004, "ISCII Tamil"], [57005, "ISCII Telugu "], [57006, "ISCII Assamese "], [57007, "ISCII Oriya"], [57008, "ISCII Kannada"], [57009, "ISCII Malayalam "], [57010, "ISCII Gujarati"], [57011, "ISCII Punjabi"], [65000, "Unicode (UTF-7)"], [65001, "Unicode (UTF-8)"]];
}
var encodestore = Ext.create("Ext.data.ArrayStore", {
autoDestroy: true,
storeId: "encodeStore",
idIndex: 0,
fields: [{
name: "value",
type: "int"
},
{
name: "name",
type: "string"
}],
data: encodedata
});
this.cmbEncoding = Ext.create("Ext.form.field.ComboBox", {
store: encodestore,
displayField: "name",
queryMode: "local",
typeAhead: false,
editable: false,
listeners: {
keydown: this._handleKeyDown,
select: function (combo, records, eOpts) {
this.encoding = records[0].data.value;
},
scope: this
},
enableKeyEvents: true,
plugins: [{
pluginId: "scrollpane",
ptype: "comboboxscrollpane",
settings: {
enableKeyboardNavigation: true
}
}]
});
this.cmbEncoding.select(encodestore.getAt(0));
this.encoding = encodestore.getAt(0).data.value;
var delimiterstore = Ext.create("Ext.data.ArrayStore", {
autoDestroy: true,
storeId: "delimiterStore",
idIndex: 0,
fields: [{
name: "value",
type: "int"
},
{
name: "description",
type: "string"
}],
data: [[4, ","], [2, ";"], [3, ":"], [1, this.txtTab], [5, this.txtSpace]]
});
this.cmbDelimiter = Ext.create("Ext.form.field.ComboBox", {
width: 70,
store: delimiterstore,
displayField: "description",
queryMode: "local",
typeAhead: false,
editable: false,
listeners: {
select: function (combo, records, eOpts) {
this.delimiter = records[0].data.value;
},
scope: this
}
});
this.cmbDelimiter.select(delimiterstore.getAt(0));
this.delimiter = delimiterstore.getAt(0).data.value;
this.items = [{
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
padding: "0 20px 0 20px",
height: 46,
width: 210,
items: [{
xtype: "label",
text: this.txtEncoding,
style: "font-weight: bold;margin:0 0 4px 0;"
},
this.cmbEncoding]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
layout: {
type: "vbox",
align: "left"
},
padding: "0 20px 0 20px",
height: 46,
width: 210,
items: [{
xtype: "label",
text: this.txtDelimiter,
style: "font-weight: bold;margin:0 0 4px 0;"
},
this.cmbDelimiter]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "tbspacer",
height: 8,
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
},
{
xtype: "container",
height: 40,
layout: {
type: "vbox",
align: "center",
pack: "center"
},
items: [{
xtype: "container",
width: 86,
height: 24,
layout: {
type: "hbox",
align: "middle"
},
items: [this.btnOk = Ext.widget("button", {
cls: "asc-blue-button",
width: 86,
height: 22,
margin: "0 5px 0 0",
text: this.okButtonText,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 1, {
encoding: this.encoding,
delimiter: this.delimiter
});
this.close();
},
scope: this
}
})]
}]
}];
this.callParent(arguments);
},
setSettings: function (s) {
var index = this.cmbEncoding.getStore().find("value", s.asc_getCodePage ? s.asc_getCodePage() : s.encoding);
if (! (index < 0)) {
this.cmbEncoding.select(this.cmbEncoding.getStore().getAt(index));
this.encoding = s.asc_getCodePage();
}
index = this.cmbDelimiter.getStore().find("value", s.asc_getDelimiter ? s.asc_getDelimiter() : s.delimiter);
if (! (index < 0)) {
this.cmbDelimiter.select(this.cmbDelimiter.getStore().getAt(index));
this.delimiter = s.asc_getDelimiter();
}
},
scrollViewToNode: function (dataview, node) {
if (dataview && node) {
var plugin = dataview.getPlugin("scrollpane");
if (plugin) {
var doScroll = new Ext.util.DelayedTask(function () {
plugin.scrollToElement(node, false, true);
});
doScroll.delay(100);
}
}
},
_handleKeyDown: function (combo, event) {
if (event.ctrlKey || event.altKey) {
return;
}
var charcode = String.fromCharCode(event.getCharCode());
if (/[A-Z0-9]/.test(charcode)) {
if ((new Date().getTime()) - combo.lastsearchtime > 3000) {
combo.lastsearchquery = "";
}
var str = combo.lastsearchquery + charcode;
var index = combo.getStore().find("name", str, combo.lastsearchindex);
if (index < 0) {
str = charcode;
index = combo.getStore().find("name", str, combo.lastsearchindex);
if (index < 0) {
index = combo.getStore().find("name", str, 0);
}
}
combo.lastsearchtime = new Date().getTime();
if (! (index < 0)) {
var item = combo.getStore().getAt(index);
var node = combo.getPicker().getNode(item);
combo.select(item);
this.scrollViewToNode(combo, node);
combo.lastsearchquery = str;
combo.lastsearchindex = ++index < combo.getStore().getCount() ? index : 0;
} else {
combo.lastsearchquery = "";
combo.lastsearchindex = 0;
}
}
},
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtEncoding: "Encoding ",
txtDelimiter: "Delimiter",
txtTab: "Tab",
txtSpace: "Space",
txtTitle: "Choose CSV options"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["common/main/lib/component/Window"], function () {
SSE.Views = SSE.Views || {};
SSE.Views.OpenDialog = Common.UI.Window.extend(_.extend({
applyFunction: undefined,
initialize: function (options) {
var t = this,
_options = {};
_.extend(_options, {
width: 250,
height: 220,
contentWidth: 390,
header: true,
cls: "open-dlg",
contentTemplate: "",
title: t.txtTitle
},
options);
this.template = options.template || ['<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="content-panel" >', '<label class="header">' + t.txtEncoding + "</label>", '<div id="id-codepages-combo" class="input-group-nr" style="margin-top:10px;margin-bottom:10px;"></div>', '<label class="header">' + t.txtDelimiter + "</label>", '<div id="id-delimiters-combo" class="input-group-nr" style="margin-top:10px;max-width: 110px;"></div>', "</div>", "</div>", '<div class="separator horizontal"/>', '<div class="footer center">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">' + t.okButtonText + "</button>", "</div>"].join("");
this.handler = options.handler;
this.codepages = options.codepages;
this.settings = options.settings;
_options.tpl = _.template(this.template, _options);
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
if (this.$window) {
this.$window.find(".tool").hide();
this.$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
this.initCodePages();
}
},
onBtnClick: function (event) {
if (this.handler && this.cmbEncoding && this.cmbDelimiter) {
this.handler.call(this, this.cmbEncoding.getValue(), this.cmbDelimiter.getValue());
}
this.close();
},
initCodePages: function () {
var i, c, codepage, encodedata = [],
listItems = [],
length = 0;
if (this.codepages) {
encodedata = [];
for (i = 0; i < this.codepages.length; ++i) {
codepage = this.codepages[i];
c = [];
c[0] = codepage.asc_getCodePage();
c[1] = codepage.asc_getCodePageName();
encodedata.push(c);
}
} else {
encodedata = [[37, "IBM EBCDIC (US-Canada)"], [437, "OEM United States"], [500, "IBM EBCDIC (International)"], [708, "Arabic (ASMO 708)"], [720, "Arabic (DOS)"], [737, "Greek (DOS)"], [775, "Baltic (DOS)"], [850, "Western European (DOS)"], [852, "Central European (DOS)"], [855, "OEM Cyrillic"], [857, "Turkish (DOS)"], [858, "OEM Multilingual Latin I"], [860, "Portuguese (DOS)"], [861, "Icelandic (DOS)"], [862, "Hebrew (DOS)"], [863, "French Canadian (DOS)"], [864, "Arabic (864) "], [865, "Nordic (DOS)"], [866, "Cyrillic (DOS)"], [869, "Greek, Modern (DOS)"], [870, "IBM EBCDIC (Multilingual Latin-2)"], [874, "Thai (Windows)"], [875, "IBM EBCDIC (Greek Modern)"], [932, "Japanese (Shift-JIS)"], [936, "Chinese Simplified (GB2312)"], [949, "Korean"], [950, "Chinese Traditional (Big5)"], [1026, "IBM EBCDIC (Turkish Latin-5)"], [1047, "IBM Latin-1"], [1140, "IBM EBCDIC (US-Canada-Euro)"], [1141, "IBM EBCDIC (Germany-Euro)"], [1142, "IBM EBCDIC (Denmark-Norway-Euro)"], [1143, "IBM EBCDIC (Finland-Sweden-Euro)"], [1144, "IBM EBCDIC (Italy-Euro)"], [1145, "IBM EBCDIC (Spain-Euro)"], [1146, "IBM EBCDIC (UK-Euro)"], [1147, "IBM EBCDIC (France-Euro)"], [1148, "IBM EBCDIC (International-Euro)"], [1149, "IBM EBCDIC (Icelandic-Euro)"], [1200, "Unicode"], [1201, "Unicode (Big-Endian)"], [1250, "Central European (Windows)"], [1251, "Cyrillic (Windows)"], [1252, "Western European (Windows)"], [1253, "Greek (Windows)"], [1254, "Turkish (Windows)"], [1255, "Hebrew (Windows) "], [1256, "Arabic (Windows) "], [1257, "Baltic (Windows)"], [1258, "Vietnamese (Windows)"], [1361, "Korean (Johab)"], [10000, "Western European (Mac)"], [10001, "Japanese (Mac)"], [10002, "Chinese Traditional (Mac)"], [10003, "Korean (Mac)"], [10004, "Arabic (Mac) "], [10005, "Hebrew (Mac)"], [10006, "Greek (Mac) "], [10007, "Cyrillic (Mac)"], [10008, "Chinese Simplified (Mac)"], [10010, "Romanian (Mac)"], [10017, "Ukrainian (Mac)"], [10021, "Thai (Mac)"], [10029, "Central European (Mac) "], [10079, "Icelandic (Mac)"], [10081, "Turkish (Mac)"], [10082, "Croatian (Mac)"], [12000, "Unicode (UTF-32)"], [12001, "Unicode (UTF-32 Big-Endian)"], [20000, "Chinese Traditional (CNS)"], [20001, "TCA Taiwan"], [20002, "Chinese Traditional (Eten)"], [20003, "IBM5550 Taiwan"], [20004, "TeleText Taiwan"], [20005, "Wang Taiwan"], [20105, "Western European (IA5)"], [20106, "German (IA5)"], [20107, "Swedish (IA5) "], [20108, "Norwegian (IA5) "], [20127, "US-ASCII"], [20261, "T.61 "], [20269, "ISO-6937"], [20273, "IBM EBCDIC (Germany)"], [20277, "IBM EBCDIC (Denmark-Norway) "], [20278, "IBM EBCDIC (Finland-Sweden)"], [20280, "IBM EBCDIC (Italy)"], [20284, "IBM EBCDIC (Spain)"], [20285, "IBM EBCDIC (UK)"], [20290, "IBM EBCDIC (Japanese katakana)"], [20297, "IBM EBCDIC (France)"], [20420, "IBM EBCDIC (Arabic)"], [20423, "IBM EBCDIC (Greek)"], [20424, "IBM EBCDIC (Hebrew)"], [20833, "IBM EBCDIC (Korean Extended)"], [20838, "IBM EBCDIC (Thai)"], [20866, "Cyrillic (KOI8-R)"], [20871, "IBM EBCDIC (Icelandic) "], [20880, "IBM EBCDIC (Cyrillic Russian)"], [20905, "IBM EBCDIC (Turkish)"], [20924, "IBM Latin-1 "], [20932, "Japanese (JIS 0208-1990 and 0212-1990)"], [20936, "Chinese Simplified (GB2312-80) "], [20949, "Korean Wansung "], [21025, "IBM EBCDIC (Cyrillic Serbian-Bulgarian)"], [21866, "Cyrillic (KOI8-U)"], [28591, "Western European (ISO) "], [28592, "Central European (ISO)"], [28593, "Latin 3 (ISO)"], [28594, "Baltic (ISO)"], [28595, "Cyrillic (ISO) "], [28596, "Arabic (ISO)"], [28597, "Greek (ISO) "], [28598, "Hebrew (ISO-Visual)"], [28599, "Turkish (ISO)"], [28603, "Estonian (ISO)"], [28605, "Latin 9 (ISO)"], [29001, "Europa"], [38598, "Hebrew (ISO-Logical)"], [50220, "Japanese (JIS)"], [50221, "Japanese (JIS-Allow 1 byte Kana) "], [50222, "Japanese (JIS-Allow 1 byte Kana - SO/SI)"], [50225, "Korean (ISO)"], [50227, "Chinese Simplified (ISO-2022)"], [51932, "Japanese (EUC)"], [51936, "Chinese Simplified (EUC) "], [51949, "Korean (EUC)"], [52936, "Chinese Simplified (HZ)"], [54936, "Chinese Simplified (GB18030)"], [57002, "ISCII Devanagari "], [57003, "ISCII Bengali "], [57004, "ISCII Tamil"], [57005, "ISCII Telugu "], [57006, "ISCII Assamese "], [57007, "ISCII Oriya"], [57008, "ISCII Kannada"], [57009, "ISCII Malayalam "], [57010, "ISCII Gujarati"], [57011, "ISCII Punjabi"], [65000, "Unicode (UTF-7)"], [65001, "Unicode (UTF-8)"]];
}
length = encodedata.length;
if (length) {
for (i = 0; i < length; ++i) {
listItems.push({
value: encodedata[i][0],
displayValue: encodedata[i][1]
});
}
this.cmbEncoding = new Common.UI.ComboBox({
el: $("#id-codepages-combo", this.$window),
menuStyle: "min-width: 220px;",
cls: "input-group-nr",
menuCls: "scrollable-menu",
data: listItems,
editable: false
});
this.cmbDelimiter = new Common.UI.ComboBox({
el: $("#id-delimiters-combo", this.$window),
menuStyle: "min-width: 110px;",
cls: "input-group-nr",
data: [{
value: 4,
displayValue: ","
},
{
value: 2,
displayValue: ";"
},
{
value: 3,
displayValue: ":"
},
{
value: 1,
displayValue: this.txtTab
},
{
value: 5,
displayValue: this.txtSpace
}],
editable: false
});
this.cmbDelimiter.setValue(4);
if (encodedata.length) {
this.cmbEncoding.setValue(encodedata[0][0]);
if (this.settings && this.settings.asc_getCodePage()) {
this.cmbEncoding.setValue(this.settings.asc_getCodePage());
}
if (this.settings && this.settings.asc_getDelimiter()) {
this.cmbDelimiter.setValue(this.settings.asc_getDelimiter());
}
}
}
},
okButtonText: "OK",
cancelButtonText: "Cancel",
txtDelimiter: "Delimiter",
txtEncoding: "Encoding ",
txtSpace: "Space",
txtTab: "Tab",
txtTitle: "Choose CSV options"
},
SSE.Views.OpenDialog || {}));
});

View File

@@ -1,441 +1,334 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var c_paragraphLinerule = {
LINERULE_LEAST: 0,
LINERULE_AUTO: 1,
LINERULE_EXACT: 2
};
Ext.define("SSE.view.ParagraphSettings", {
extend: "Common.view.AbstractSettingsPanel",
alias: "widget.sseparagraphsettings",
height: 176,
requires: ["Ext.DomHelper", "Ext.button.Button", "Ext.form.Label", "Ext.container.Container", "Ext.toolbar.Spacer", "Common.component.MetricSpinner", "Ext.form.field.ComboBox", "SSE.view.ParagraphSettingsAdvanced"],
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onParaSpacingLine", Ext.bind(this._onLineSpacing, this));
},
initComponent: function () {
this.title = this.txtTitle;
this._initSettings = true;
this._state = {
LineRuleIdx: 1,
LineHeight: 1.5,
LineSpacingBefore: 0,
LineSpacingAfter: 0.35
};
this._arrLineRule = [this.textAtLeast, this.textAuto, this.textExact];
this._arrLineDefaults = [[5, "cm", 0.03, 0.01], [1, "", 0.5, 0.01], [5, "cm", 0.03, 0.01]];
this.cmbLineRule = Ext.create("Ext.form.field.ComboBox", {
id: "table-combo-line-rule",
width: 85,
editable: false,
store: this._arrLineRule,
mode: "local",
triggerAction: "all",
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
if (this.api) {
this.api.asc_putPrLineSpacing(records[0].index, this._arrLineDefaults[records[0].index][0]);
}
this.numLineHeight.setDefaultUnit(this._arrLineDefaults[records[0].index][1]);
this.numLineHeight.setMinValue(this._arrLineDefaults[records[0].index][2]);
this.numLineHeight.setStep(this._arrLineDefaults[records[0].index][3]);
this.fireEvent("editcomplete", this);
},
this)
}
});
this.cmbLineRule.setValue(this._arrLineRule[1]);
this.controls.push(this.cmbLineRule);
this.numLineHeight = Ext.widget("commonmetricspinner", {
id: "paragraph-spin-line-height",
readOnly: false,
step: 0.01,
width: 85,
value: "1.5",
defaultUnit: "",
maxValue: 132,
minValue: 0,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.cmbLineRule.getValue() == "") {
return;
}
var type = c_paragraphLinerule.LINERULE_AUTO;
for (var i = 0; i < this._arrLineRule.length; i++) {
if (this.cmbLineRule.getValue() == this._arrLineRule[i]) {
type = i;
break;
}
}
if (this.api) {
this.api.asc_putPrLineSpacing(type, (type == c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.MetricSettings.fnRecalcToMM(field.getNumberValue()));
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this.numLineHeight);
this.numSpacingBefore = Ext.create("Common.component.MetricSpinner", {
id: "paragraph-spin-spacing-before",
readOnly: false,
step: 0.1,
width: 85,
defaultUnit: "cm",
value: "0 cm",
maxValue: 55.88,
minValue: 0,
allowAuto: true,
autoText: this.txtAutoText,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.api) {
var num = field.getNumberValue();
if (num < 0) {
this.api.asc_putLineSpacingBeforeAfter(0, -1);
} else {
this.api.asc_putLineSpacingBeforeAfter(0, Common.MetricSettings.fnRecalcToMM(field.getNumberValue()));
}
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this.numSpacingBefore);
this.numSpacingAfter = Ext.create("Common.component.MetricSpinner", {
id: "paragraph-spin-spacing-after",
readOnly: false,
step: 0.1,
width: 85,
defaultUnit: "cm",
value: "0.35 cm",
maxValue: 55.88,
minValue: 0,
allowAuto: true,
autoText: this.txtAutoText,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.api) {
var num = field.getNumberValue();
if (num < 0) {
this.api.asc_putLineSpacingBeforeAfter(1, -1);
} else {
this.api.asc_putLineSpacingBeforeAfter(1, Common.MetricSettings.fnRecalcToMM(field.getNumberValue()));
}
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this.numSpacingAfter);
this._SpacingPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 107,
width: 190,
items: [{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
height: 41,
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 8px;vertical-align: middle;"
}
},
items: [{
xtype: "label",
text: this.strLineHeight,
style: "display: block;",
width: 85
},
{
xtype: "label",
text: this.textAt,
style: "display: block;",
width: 85
},
{
xtype: "tbspacer",
height: 2
},
{
xtype: "tbspacer",
height: 2
},
this.cmbLineRule, this.numLineHeight]
},
{
xtype: "tbspacer",
height: 10
},
{
xtype: "container",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 8px;"
}
},
defaults: {
xtype: "container",
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 48,
style: "float:left;"
},
items: [{
items: [{
xtype: "label",
text: this.strSpacingBefore,
width: 85
},
{
xtype: "tbspacer",
height: 3
},
this.numSpacingBefore]
},
{
items: [{
xtype: "label",
text: this.strSpacingAfter,
width: 85
},
{
xtype: "tbspacer",
height: 3
},
this.numSpacingAfter]
}]
}]
});
this.items = [{
xtype: "tbspacer",
height: 9
},
{
xtype: "label",
style: "font-weight: bold;margin-top: 1px;",
text: this.strParagraphSpacing
},
this._SpacingPanel, {
xtype: "tbspacer",
height: 3
},
{
xtype: "tbspacer",
width: "100%",
height: 10,
style: "padding-right: 10px;",
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
},
{
xtype: "tbspacer",
height: 3
},
{
xtype: "container",
height: 20,
width: "100%",
items: [{
xtype: "box",
html: '<div style="width:100%;text-align:center;padding-right:15px;"><label id="paragraph-advanced-link" class="asc-advanced-link">' + this.textAdvanced + "</label></div>",
listeners: {
afterrender: function (cmp) {
document.getElementById("paragraph-advanced-link").onclick = Ext.bind(this._openAdvancedSettings, this);
},
scope: this
}
}]
}];
this.addEvents("editcomplete");
this.callParent(arguments);
},
_onLineSpacing: function (value) {
var linerule = value.asc_getLineRule();
var line = value.asc_getLine();
this.numLineHeight.suspendEvents(false);
this.cmbLineRule.suspendEvents(false);
if (this._state.LineRuleIdx !== linerule) {
this.cmbLineRule.setValue((linerule !== null) ? this._arrLineRule[linerule] : "");
this.numLineHeight.setMinValue(this._arrLineDefaults[(linerule !== null) ? linerule : 1][2]);
this.numLineHeight.setDefaultUnit(this._arrLineDefaults[(linerule !== null) ? linerule : 1][1]);
this.numLineHeight.setStep(this._arrLineDefaults[(linerule !== null) ? linerule : 1][3]);
this._state.LineRuleIdx = linerule;
}
if (Math.abs(this._state.LineHeight - line) > 0.001 || (this._state.LineHeight === null || line === null) && (this._state.LineHeight !== line)) {
var val = "";
if (linerule == c_paragraphLinerule.LINERULE_AUTO) {
val = line;
} else {
if (linerule !== null && line !== null) {
val = Common.MetricSettings.fnRecalcFromMM(line);
}
}
this.numLineHeight.setValue((val !== null) ? val : "");
this._state.LineHeight = line;
}
this.numLineHeight.resumeEvents();
this.cmbLineRule.resumeEvents();
},
ChangeSettings: function (prop) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
if (prop) {
this.SuspendEvents();
var Spacing = {
Line: prop.asc_getSpacing().asc_getLine(),
Before: prop.asc_getSpacing().asc_getBefore(),
After: prop.asc_getSpacing().asc_getAfter(),
LineRule: prop.asc_getSpacing().asc_getLineRule()
};
if (this._state.LineRuleIdx !== Spacing.LineRule) {
this.cmbLineRule.setValue((Spacing.LineRule !== null) ? this._arrLineRule[Spacing.LineRule] : "");
this.numLineHeight.setMinValue(this._arrLineDefaults[(Spacing.LineRule !== null) ? Spacing.LineRule : 1][2]);
this.numLineHeight.setDefaultUnit(this._arrLineDefaults[(Spacing.LineRule !== null) ? Spacing.LineRule : 1][1]);
this.numLineHeight.setStep(this._arrLineDefaults[(Spacing.LineRule !== null) ? Spacing.LineRule : 1][3]);
this._state.LineRuleIdx = Spacing.LineRule;
}
if (Math.abs(this._state.LineHeight - Spacing.Line) > 0.001 || (this._state.LineHeight === null || Spacing.Line === null) && (this._state.LineHeight !== Spacing.Line)) {
var val = "";
if (Spacing.LineRule == c_paragraphLinerule.LINERULE_AUTO) {
val = Spacing.Line;
} else {
if (Spacing.LineRule !== null && Spacing.Line !== null) {
val = Common.MetricSettings.fnRecalcFromMM(Spacing.Line);
}
}
this.numLineHeight.setValue((val !== null) ? val : "");
this._state.LineHeight = Spacing.Line;
}
if (Math.abs(this._state.LineSpacingBefore - Spacing.Before) > 0.001 || (this._state.LineSpacingBefore === null || Spacing.Before === null) && (this._state.LineSpacingBefore !== Spacing.Before)) {
this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before < 0) ? Spacing.Before : Common.MetricSettings.fnRecalcFromMM(Spacing.Before)) : "");
this._state.LineSpacingBefore = Spacing.Before;
}
if (Math.abs(this._state.LineSpacingAfter - Spacing.After) > 0.001 || (this._state.LineSpacingAfter === null || Spacing.After === null) && (this._state.LineSpacingAfter !== Spacing.After)) {
this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After < 0) ? Spacing.After : Common.MetricSettings.fnRecalcFromMM(Spacing.After)) : "");
this._state.LineSpacingAfter = Spacing.After;
}
this.ResumeEvents();
}
},
updateMetricUnit: function () {
var spinners = this.query("commonmetricspinner");
if (spinners) {
for (var i = 0; i < spinners.length; i++) {
var spinner = spinners[i];
if (spinner.id == "paragraph-spin-line-height") {
continue;
}
spinner.setDefaultUnit(Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
spinner.setStep(Common.MetricSettings.getCurrentMetric() == Common.MetricSettings.c_MetricUnits.cm ? 0.01 : 1);
}
}
this._arrLineDefaults[2][1] = this._arrLineDefaults[0][1] = Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()];
this._arrLineDefaults[2][2] = this._arrLineDefaults[0][2] = parseFloat(Common.MetricSettings.fnRecalcFromMM(0.3).toFixed(2));
this._arrLineDefaults[2][3] = this._arrLineDefaults[0][3] = (Common.MetricSettings.getCurrentMetric() == Common.MetricSettings.c_MetricUnits.cm) ? 0.01 : 1;
if (this._state.LineRuleIdx !== null) {
this.numLineHeight.setDefaultUnit(this._arrLineDefaults[this._state.LineRuleIdx][1]);
this.numLineHeight.setStep(this._arrLineDefaults[this._state.LineRuleIdx][3]);
}
},
_openAdvancedSettings: function (e) {
var me = this;
var win;
if (me.api) {
var selectedElements = me.api.asc_getGraphicObjectProps();
if (selectedElements && Ext.isArray(selectedElements)) {
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].asc_getObjectType();
elValue = selectedElements[i].asc_getObjectValue();
if (c_oAscTypeSelectElement.Paragraph == elType) {
win = Ext.create("SSE.view.ParagraphSettingsAdvanced");
win.updateMetricUnit();
win.setSettings({
paragraphProps: elValue,
api: me.api
});
break;
}
}
}
}
if (win) {
win.addListener("onmodalresult", Ext.bind(function (o, mr, s) {
if (mr == 1 && s) {
me.api.asc_setGraphicObjectProps(s.paragraphProps);
}
},
this), false);
win.addListener("close", function () {
me.fireEvent("editcomplete", me);
},
false);
win.show();
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
strParagraphSpacing: "Spacing",
strLineHeight: "Line Spacing",
strSpacingBefore: "Before",
strSpacingAfter: "After",
textAuto: "Multiple",
textAtLeast: "At least",
textExact: "Exactly",
textAt: "At",
txtTitle: "Paragraph",
txtAutoText: "Auto",
textAdvanced: "Show advanced settings"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
var c_paragraphLinerule = {
LINERULE_LEAST: 0,
LINERULE_AUTO: 1,
LINERULE_EXACT: 2
};
define(["text!spreadsheeteditor/main/app/template/ParagraphSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/ComboBox", "common/main/lib/component/MetricSpinner", "spreadsheeteditor/main/app/view/ParagraphSettingsAdvanced"], function (menuTemplate, $, _, Backbone) {
SSE.Views.ParagraphSettings = Backbone.View.extend(_.extend({
el: "#id-paragraph-settings",
template: _.template(menuTemplate),
events: {},
options: {
alias: "ParagraphSettings"
},
initialize: function () {
var me = this;
this._initSettings = true;
this._state = {
LineRuleIdx: 1,
LineHeight: 1.5,
LineSpacingBefore: 0,
LineSpacingAfter: 0.35,
DisabledControls: false
};
this.spinners = [];
this.lockedControls = [];
this._locked = false;
this.render();
this._arrLineRule = [{
displayValue: this.textAtLeast,
defaultValue: 5,
value: c_paragraphLinerule.LINERULE_LEAST,
minValue: 0.03,
step: 0.01,
defaultUnit: "cm"
},
{
displayValue: this.textAuto,
defaultValue: 1,
value: c_paragraphLinerule.LINERULE_AUTO,
minValue: 0.5,
step: 0.01,
defaultUnit: ""
},
{
displayValue: this.textExact,
defaultValue: 5,
value: c_paragraphLinerule.LINERULE_EXACT,
minValue: 0.03,
step: 0.01,
defaultUnit: "cm"
}];
this.cmbLineRule = new Common.UI.ComboBox({
el: $("#paragraph-combo-line-rule"),
cls: "input-group-nr",
menuStyle: "min-width: 85px;",
editable: false,
data: this._arrLineRule
});
this.cmbLineRule.setValue(this._arrLineRule[this._state.LineRuleIdx].value);
this.lockedControls.push(this.cmbLineRule);
this.numLineHeight = new Common.UI.MetricSpinner({
el: $("#paragraph-spin-line-height"),
step: 0.01,
width: 85,
value: "1.5",
defaultUnit: "",
maxValue: 132,
minValue: 0.5
});
this.lockedControls.push(this.numLineHeight);
this.numSpacingBefore = new Common.UI.MetricSpinner({
el: $("#paragraph-spin-spacing-before"),
step: 0.1,
width: 85,
value: "0 cm",
defaultUnit: "cm",
maxValue: 55.88,
minValue: 0,
allowAuto: true,
autoText: this.txtAutoText
});
this.spinners.push(this.numSpacingBefore);
this.lockedControls.push(this.numSpacingBefore);
this.numSpacingAfter = new Common.UI.MetricSpinner({
el: $("#paragraph-spin-spacing-after"),
step: 0.1,
width: 85,
value: "0.35 cm",
defaultUnit: "cm",
maxValue: 55.88,
minValue: 0,
allowAuto: true,
autoText: this.txtAutoText
});
this.spinners.push(this.numSpacingAfter);
this.lockedControls.push(this.numSpacingAfter);
this.numLineHeight.on("change", _.bind(this.onNumLineHeightChange, this));
this.numSpacingBefore.on("change", _.bind(this.onNumSpacingBeforeChange, this));
this.numSpacingAfter.on("change", _.bind(this.onNumSpacingAfterChange, this));
this.cmbLineRule.on("selected", _.bind(this.onLineRuleSelect, this));
this.cmbLineRule.on("hide:after", _.bind(this.onHideMenus, this));
$(this.el).on("click", "#paragraph-advanced-link", _.bind(this.openAdvancedSettings, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
this.linkAdvanced = $("#paragraph-advanced-link");
},
setApi: function (api) {
this.api = api;
if (this.api) {
this.api.asc_registerCallback("asc_onParaSpacingLine", _.bind(this._onLineSpacing, this));
}
return this;
},
onNumLineHeightChange: function (field, newValue, oldValue, eOpts) {
if (this.cmbLineRule.getRawValue() === "") {
return;
}
var type = c_paragraphLinerule.LINERULE_AUTO;
if (this.api) {
this.api.asc_putPrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue() == c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onNumSpacingBeforeChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
var num = field.getNumberValue();
if (num < 0) {
this.api.asc_putLineSpacingBeforeAfter(0, -1);
} else {
this.api.asc_putLineSpacingBeforeAfter(0, Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
}
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onNumSpacingAfterChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
var num = field.getNumberValue();
if (num < 0) {
this.api.asc_putLineSpacingBeforeAfter(1, -1);
} else {
this.api.asc_putLineSpacingBeforeAfter(1, Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
}
}
Common.NotificationCenter.trigger("edit:complete", this);
},
onLineRuleSelect: function (combo, record) {
if (this.api) {
this.api.asc_putPrLineSpacing(record.value, record.defaultValue);
}
this.numLineHeight.setDefaultUnit(this._arrLineRule[record.value].defaultUnit);
this.numLineHeight.setMinValue(this._arrLineRule[record.value].minValue);
this.numLineHeight.setStep(this._arrLineRule[record.value].step);
Common.NotificationCenter.trigger("edit:complete", this);
},
_onLineSpacing: function (value) {
var linerule = value.asc_getLineRule();
var line = value.asc_getLine();
if (this._state.LineRuleIdx !== linerule) {
this.cmbLineRule.setValue((linerule !== null) ? this._arrLineRule[linerule].value : "");
this.numLineHeight.setMinValue(this._arrLineRule[(linerule !== null) ? linerule : 1].minValue);
this.numLineHeight.setDefaultUnit(this._arrLineRule[(linerule !== null) ? linerule : 1].defaultUnit);
this.numLineHeight.setStep(this._arrLineRule[(linerule !== null) ? linerule : 1].step);
this._state.LineRuleIdx = linerule;
}
if (Math.abs(this._state.LineHeight - line) > 0.001 || (this._state.LineHeight === null || line === null) && (this._state.LineHeight !== line)) {
var val = "";
if (linerule == c_paragraphLinerule.LINERULE_AUTO) {
val = line;
} else {
if (linerule !== null && line !== null) {
val = Common.Utils.Metric.fnRecalcFromMM(line);
}
}
this.numLineHeight.setValue((val !== null) ? val : "", true);
this._state.LineHeight = line;
}
},
ChangeSettings: function (prop) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
this.disableControls(this._locked);
if (prop) {
var Spacing = {
Line: prop.asc_getSpacing().asc_getLine(),
Before: prop.asc_getSpacing().asc_getBefore(),
After: prop.asc_getSpacing().asc_getAfter(),
LineRule: prop.asc_getSpacing().asc_getLineRule()
};
if (this._state.LineRuleIdx !== Spacing.LineRule) {
this.cmbLineRule.setValue((Spacing.LineRule !== null) ? this._arrLineRule[Spacing.LineRule].value : "");
this.numLineHeight.setMinValue(this._arrLineRule[(Spacing.LineRule !== null) ? Spacing.LineRule : 1].minValue);
this.numLineHeight.setDefaultUnit(this._arrLineRule[(Spacing.LineRule !== null) ? Spacing.LineRule : 1].defaultUnit);
this.numLineHeight.setStep(this._arrLineRule[(Spacing.LineRule !== null) ? Spacing.LineRule : 1].step);
this._state.LineRuleIdx = Spacing.LineRule;
}
if (Math.abs(this._state.LineHeight - Spacing.Line) > 0.001 || (this._state.LineHeight === null || Spacing.Line === null) && (this._state.LineHeight !== Spacing.Line)) {
var val = "";
if (Spacing.LineRule == c_paragraphLinerule.LINERULE_AUTO) {
val = Spacing.Line;
} else {
if (Spacing.LineRule !== null && Spacing.Line !== null) {
val = Common.Utils.Metric.fnRecalcFromMM(Spacing.Line);
}
}
this.numLineHeight.setValue((val !== null) ? val : "", true);
this._state.LineHeight = Spacing.Line;
}
if (Math.abs(this._state.LineSpacingBefore - Spacing.Before) > 0.001 || (this._state.LineSpacingBefore === null || Spacing.Before === null) && (this._state.LineSpacingBefore !== Spacing.Before)) {
this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before < 0) ? Spacing.Before : Common.Utils.Metric.fnRecalcFromMM(Spacing.Before)) : "", true);
this._state.LineSpacingBefore = Spacing.Before;
}
if (Math.abs(this._state.LineSpacingAfter - Spacing.After) > 0.001 || (this._state.LineSpacingAfter === null || Spacing.After === null) && (this._state.LineSpacingAfter !== Spacing.After)) {
this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After < 0) ? Spacing.After : Common.Utils.Metric.fnRecalcFromMM(Spacing.After)) : "", true);
this._state.LineSpacingAfter = Spacing.After;
}
}
},
updateMetricUnit: function () {
if (this.spinners) {
for (var i = 0; i < this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]);
spinner.setStep(Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm ? 0.01 : 1);
}
}
this._arrLineRule[2].defaultUnit = this._arrLineRule[0].defaultUnit = Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this._arrLineRule[2].minValue = this._arrLineRule[0].minValue = parseFloat(Common.Utils.Metric.fnRecalcFromMM(0.3).toFixed(2));
this._arrLineRule[2].step = this._arrLineRule[0].step = (Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm) ? 0.01 : 1;
if (this._state.LineRuleIdx !== null) {
this.numLineHeight.setDefaultUnit(this._arrLineRule[this._state.LineRuleIdx].defaultUnit);
this.numLineHeight.setStep(this._arrLineRule[this._state.LineRuleIdx].step);
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
openAdvancedSettings: function (e) {
if (this.linkAdvanced.hasClass("disabled")) {
return;
}
var me = this;
var win;
if (me.api && !this._locked) {
var selectedElements = me.api.asc_getGraphicObjectProps();
if (selectedElements && selectedElements.length > 0) {
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].asc_getObjectType();
elValue = selectedElements[i].asc_getObjectValue();
if (c_oAscTypeSelectElement.Paragraph == elType) {
(new SSE.Views.ParagraphSettingsAdvanced({
paragraphProps: elValue,
api: me.api,
handler: function (result, value) {
if (result == "ok") {
if (me.api) {
me.borderAdvancedProps = value.borderProps;
me.api.asc_setGraphicObjectProps(value.paragraphProps);
}
}
Common.NotificationCenter.trigger("edit:complete", me);
}
})).show();
break;
}
}
}
}
},
onHideMenus: function (e) {
Common.NotificationCenter.trigger("edit:complete", this);
},
setLocked: function (locked) {
this._locked = locked;
},
disableControls: function (disable) {
if (this._state.DisabledControls !== disable) {
this._state.DisabledControls = disable;
_.each(this.lockedControls, function (item) {
item.setDisabled(disable);
});
this.linkAdvanced.toggleClass("disabled", disable);
}
},
strParagraphSpacing: "Spacing",
strLineHeight: "Line Spacing",
strSpacingBefore: "Before",
strSpacingAfter: "After",
textAuto: "Multiple",
textAtLeast: "At least",
textExact: "Exactly",
textAdvanced: "Show advanced settings",
textAt: "At",
txtAutoText: "Auto"
},
SSE.Views.ParagraphSettings || {}));
});

View File

@@ -1,579 +1,266 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.PrintSettings", {
extend: "Ext.window.Window",
alias: "widget.sseprintsettings",
requires: ["Ext.window.Window", "Ext.form.field.ComboBox", "Ext.form.RadioGroup", "Ext.Array", "Common.component.MetricSpinner", "Common.component.IndeterminateCheckBox"],
cls: "asc-advanced-settings-window",
modal: true,
resizable: false,
plain: true,
constrain: true,
height: 588,
width: 466,
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var me = this;
this.addEvents("onmodalresult");
this._spacer = Ext.create("Ext.toolbar.Spacer", {
width: "100%",
height: 10,
html: '<div style="width: 100%; height: 40%; border-bottom: 1px solid #C7C7C7"></div>'
});
this.cmbPaperSize = Ext.widget("combo", {
store: Ext.create("Ext.data.Store", {
fields: ["description", "size"],
data: [{
size: "215.9|279.4",
description: "US Letter (21,59cm x 27,94cm)"
},
{
size: "215.9|355.6",
description: "US Legal (21,59cm x 35,56cm)"
},
{
size: "210|297",
description: "A4 (21cm x 29,7cm)"
},
{
size: "148.1|209.9",
description: "A5 (14,81cm x 20,99cm)"
},
{
size: "176|250.1",
description: "B5 (17,6cm x 25,01cm)"
},
{
size: "104.8|241.3",
description: "Envelope #10 (10,48cm x 24,13cm)"
},
{
size: "110.1|220.1",
description: "Envelope DL (11,01cm x 22,01cm)"
},
{
size: "279.4|431.7",
description: "Tabloid (27,94cm x 43,17cm)"
},
{
size: "297|420.1",
description: "A3 (29,7cm x 42,01cm)"
},
{
size: "304.8|457.1",
description: "Tabloid Oversize (30,48cm x 45,71cm)"
},
{
size: "196.8|273",
description: "ROC 16K (19,68cm x 27,3cm)"
},
{
size: "119.9|234.9",
description: "Envelope Choukei 3 (11,99cm x 23,49cm)"
},
{
size: "330.2|482.5",
description: "Super B/A3 (33,02cm x 48,25cm)"
}]
}),
displayField: "description",
valueField: "size",
queryMode: "local",
editable: false,
flex: 1
});
this.cmbPaperOrientation = Ext.widget("combo", {
store: Ext.create("Ext.data.Store", {
fields: ["description", "orient"],
data: [{
description: me.strPortrait,
orient: c_oAscPageOrientation.PagePortrait
},
{
description: me.strLandscape,
orient: c_oAscPageOrientation.PageLandscape
}]
}),
displayField: "description",
valueField: "orient",
queryMode: "local",
editable: false,
width: 115
});
this.chPrintGrid = Ext.widget("cmdindeterminatecheckbox", {
boxLabel: this.textPrintGrid
});
this.chPrintRows = Ext.widget("cmdindeterminatecheckbox", {
boxLabel: this.textPrintHeadings
});
this.spnMarginLeft = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0.19 cm",
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {},
this)
}
});
this.spnMarginRight = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0.19 cm",
listeners: {
change: function (field, newValue, oldValue, eOpts) {}
}
});
this.spnMarginTop = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0 cm",
listeners: {
change: function (field, newValue, oldValue, eOpts) {}
}
});
this.spnMarginBottom = Ext.create("Common.component.MetricSpinner", {
readOnly: false,
maxValue: 48.25,
minValue: 0,
step: 0.1,
defaultUnit: "cm",
value: "0 cm",
listeners: {
change: function (field, newValue, oldValue, eOpts) {}
}
});
this.items = [this.topCnt = Ext.widget("container", {
height: 490,
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "container",
width: 160,
padding: "18 0 0 0",
layout: {
type: "vbox",
align: "stretch"
},
defaults: {
xtype: "container",
padding: "0 10 0 0",
layout: {
type: "hbox",
align: "middle",
pack: "end"
}
},
items: [{
height: 80,
padding: "0 10px 10px 0",
items: [{
xtype: "label",
text: me.textPrintRange,
style: "font-weight: bold;"
}]
},
{
height: 62,
items: [{
xtype: "label",
text: me.textPageSize,
style: "font-weight: bold;"
}]
},
{
height: 58,
items: [{
xtype: "label",
text: me.textPageOrientation,
style: "font-weight: bold;"
}]
},
{
height: 124,
items: [{
xtype: "label",
text: this.strMargins,
style: "font-weight: bold;"
}]
},
{
height: 68,
items: [{
xtype: "label",
text: me.textLayout,
style: "font-weight: bold;"
}]
},
{
height: 70,
items: [{
xtype: "label",
text: me.strPrint,
style: "font-weight: bold;"
}]
}]
},
{
xtype: "box",
cls: "advanced-settings-separator",
height: "100%",
width: 8
},
{
xtype: "container",
padding: "18 0 0 10",
width: 280,
layout: {
type: "vbox",
align: "stretch"
},
items: [{
xtype: "container",
height: 70,
padding: "0 10",
layout: {
type: "hbox",
align: "middle"
},
items: [this.groupRange = Ext.widget("radiogroup", {
id: "dialog-printoptions-grouprange",
columns: 1,
width: 280,
vertical: true,
items: [{
boxLabel: this.textCurrentSheet,
name: "printrange",
inputValue: c_oAscPrintType.ActiveSheets,
checked: true
},
{
boxLabel: this.textAllSheets,
name: "printrange",
inputValue: c_oAscPrintType.EntireWorkbook
},
{
boxLabel: this.textSelection,
name: "printrange",
inputValue: c_oAscPrintType.Selection
}]
})]
},
this._spacer.cloneConfig({
style: "margin: 15px 0 10px 0;",
height: 6
}), {
xtype: "container",
height: 25,
padding: "0 10",
layout: {
type: "hbox",
align: "middle"
},
items: [this.cmbPaperSize]
},
this._spacer.cloneConfig({
style: "margin: 17px 0 10px 0;",
height: 6
}), {
xtype: "container",
height: 25,
padding: "0 10",
layout: {
type: "hbox",
align: "middle"
},
items: [this.cmbPaperOrientation]
},
this._spacer.cloneConfig({
style: "margin: 16px 0 4px 0;",
height: 6
}), this.cntMargins = Ext.widget("container", {
height: 100,
padding: "0 10",
layout: {
type: "hbox"
},
defaults: {
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
height: 100
},
items: [{
flex: 1,
items: [{
xtype: "label",
width: "100%",
text: me.strTop
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginTop, {
xtype: "tbspacer",
height: 12
},
{
xtype: "label",
width: "100%",
text: me.strLeft
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginLeft]
},
{
xtype: "tbspacer",
width: 20
},
{
flex: 1,
items: [{
xtype: "label",
text: me.strBottom,
width: "100%"
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginBottom, {
xtype: "tbspacer",
height: 12
},
{
xtype: "label",
text: me.strRight,
width: "100%"
},
{
xtype: "tbspacer",
height: 3
},
this.spnMarginRight]
}]
}), this._spacer.cloneConfig({
style: "margin: 14px 0 6px 0;",
height: 6
}), this.cntLayout = Ext.widget("container", {
height: 45,
padding: "0 10",
layout: {
type: "vbox",
align: "stretch"
},
items: [this.groupLayout = Ext.widget("radiogroup", {
columns: 1,
width: 280,
vertical: true,
items: [{
boxLabel: this.textActualSize,
name: "printlayout",
inputValue: c_oAscLayoutPageType.ActualSize
},
{
boxLabel: this.textFit,
name: "printlayout",
inputValue: c_oAscLayoutPageType.FitToWidth,
checked: true
}]
})]
}), this._spacer.cloneConfig({
style: "margin: 14px 0 8px 0;",
height: 6
}), this.cntAdditional = Ext.widget("container", {
height: 65,
padding: "0 10",
layout: {
type: "vbox",
align: "stretch"
},
items: [this.chPrintGrid, this.chPrintRows]
})]
}]
}), this._spacer.cloneConfig({
style: "margin: 0 18px"
}), {
xtype: "container",
height: 40,
layout: {
type: "vbox",
align: "center",
pack: "center"
},
items: [{
xtype: "container",
width: 466,
height: 24,
style: "padding: 0 30px;",
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "button",
width: 100,
height: 22,
text: this.textHideDetails,
listeners: {
scope: this,
click: this.handlerShowDetails
}
},
this.btnOk = Ext.widget("button", {
id: "dialog-print-options-ok",
cls: "asc-blue-button",
width: 150,
height: 22,
style: "margin:0 10px 0 60px;",
text: this.btnPrint,
listeners: {}
}), this.btnCancel = Ext.widget("button", {
cls: "asc-darkgray-button",
width: 86,
height: 22,
text: this.cancelButtonText,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 0);
this.close();
},
scope: this
}
})]
}]
}];
this.callParent(arguments);
this.setTitle(this.textTitle);
},
afterRender: function () {
this.callParent(arguments);
},
checkMargins: function () {
if (this.cmbPaperOrientation.getValue() == c_oAscPageOrientation.PagePortrait) {
var pagewidth = /^\d{3}\.?\d*/.exec(this.cmbPaperSize.getValue());
var pageheight = /\d{3}\.?\d*$/.exec(this.cmbPaperSize.getValue());
} else {
pageheight = /^\d{3}\.?\d*/.exec(this.cmbPaperSize.getValue());
pagewidth = /\d{3}\.?\d*$/.exec(this.cmbPaperSize.getValue());
}
var ml = Common.MetricSettings.fnRecalcToMM(this.spnMarginLeft.getNumberValue());
var mr = Common.MetricSettings.fnRecalcToMM(this.spnMarginRight.getNumberValue());
var mt = Common.MetricSettings.fnRecalcToMM(this.spnMarginTop.getNumberValue());
var mb = Common.MetricSettings.fnRecalcToMM(this.spnMarginBottom.getNumberValue());
if (ml > pagewidth) {
return "left";
}
if (mr > pagewidth - ml) {
return "right";
}
if (mt > pageheight) {
return "top";
}
if (mb > pageheight - mt) {
return "bottom";
}
return null;
},
handlerShowDetails: function (btn) {
if (!this.extended) {
this.extended = true;
this.cntMargins.setDisabled(true);
this.cntLayout.setDisabled(true);
this.cntAdditional.setDisabled(true);
this.topCnt.setHeight(218);
this.setHeight(316);
btn.setText(this.textShowDetails);
} else {
this.extended = false;
this.cntMargins.setDisabled(false);
this.cntLayout.setDisabled(false);
this.cntAdditional.setDisabled(false);
this.topCnt.setHeight(490);
this.setHeight(588);
btn.setText(this.textHideDetails);
}
},
updateMetricUnit: function () {
var spinners = this.query("commonmetricspinner");
if (spinners) {
for (var i = 0; i < spinners.length; i++) {
var spinner = spinners[i];
spinner.setDefaultUnit(Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
spinner.setStep(Common.MetricSettings.getCurrentMetric() == Common.MetricSettings.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
textTitle: "Print Settings",
strLeft: "Left",
strRight: "Right",
strTop: "Top",
strBottom: "Bottom",
strPortrait: "Portrait",
strLandscape: "Landscape",
textPrintGrid: "Print Gridlines",
textPrintHeadings: "Print Rows and Columns Headings",
textPageSize: "Page Size",
textPageOrientation: "Page Orientation",
strMargins: "Margins",
strPrint: "Print",
btnPrint: "Save & Print",
textPrintRange: "Print Range",
textLayout: "Layout",
textCurrentSheet: "Current Sheet",
textAllSheets: "All Sheets",
textSelection: "Selection",
textActualSize: "Actual Size",
textFit: "Fit to width",
textShowDetails: "Show Details",
cancelButtonText: "Cancel",
textHideDetails: "Hide Details"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/PrintSettings.template", "common/main/lib/view/AdvancedSettingsWindow", "common/main/lib/component/MetricSpinner", "common/main/lib/component/CheckBox", "common/main/lib/component/RadioBox", "common/main/lib/component/ListView"], function (contentTemplate) {
SSE.Views.PrintSettings = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
alias: "PrintSettings",
contentWidth: 280,
height: 482
},
initialize: function (options) {
_.extend(this.options, {
title: this.textTitle,
template: ['<div class="box" style="height:' + (this.options.height - 85) + 'px;">', '<div class="menu-panel" style="overflow: hidden;">', '<div style="height: 90px; line-height: 90px;" class="div-category">' + this.textPrintRange + "</div>", '<div style="height: 55px; line-height: 55px;" class="div-category">' + this.textPageSize + "</div>", '<div style="height: 55px; line-height: 55px;" class="div-category">' + this.textPageOrientation + "</div>", '<div style="height: 122px; line-height: 122px;" class="div-category">' + this.strMargins + "</div>", '<div style="height: 73px; line-height: 73px;" class="div-category">' + this.strPrint + "</div>", "</div>", '<div class="separator"/>', '<div class="content-panel">' + _.template(contentTemplate)({
scope: this
}) + "</div>", "</div>", '<div class="separator horizontal"/>', '<div class="footer justify">', '<button id="printadv-dlg-btn-hide" class="btn btn-text-default" style="margin-right: 55px; width: 100px;">' + this.textHideDetails + "</button>", '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px; width: 150px;">' + this.btnPrint + "</button>", '<button class="btn normal dlg-btn" result="cancel" style="width: 86px;">' + this.cancelButtonText + "</button>", "</div>"].join("")
},
options);
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
this.spinners = [];
},
render: function () {
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
this.radioCurrent = new Common.UI.RadioBox({
el: $("#printadv-dlg-radio-current"),
labelText: this.textCurrentSheet,
name: "asc-radio-printrange",
checked: true
});
this.radioCurrent.on("change", _.bind(this.onRadioRangeChange, this));
this.radioAll = new Common.UI.RadioBox({
el: $("#printadv-dlg-radio-all"),
labelText: this.textAllSheets,
name: "asc-radio-printrange"
});
this.radioAll.on("change", _.bind(this.onRadioRangeChange, this));
this.radioSelection = new Common.UI.RadioBox({
el: $("#printadv-dlg-radio-selection"),
labelText: this.textSelection,
name: "asc-radio-printrange"
});
this.radioSelection.on("change", _.bind(this.onRadioRangeChange, this));
this.cmbPaperSize = new Common.UI.ComboBox({
el: $("#printadv-dlg-combo-pages"),
style: "width: 260px;",
menuStyle: "max-height: 280px; min-width: 260px;",
editable: false,
cls: "input-group-nr",
data: [{
value: "215.9|279.4",
displayValue: "US Letter (21,59cm x 27,94cm)"
},
{
value: "215.9|355.6",
displayValue: "US Legal (21,59cm x 35,56cm)"
},
{
value: "210|297",
displayValue: "A4 (21cm x 29,7cm)"
},
{
value: "148.1|209.9",
displayValue: "A5 (14,81cm x 20,99cm)"
},
{
value: "176|250.1",
displayValue: "B5 (17,6cm x 25,01cm)"
},
{
value: "104.8|241.3",
displayValue: "Envelope #10 (10,48cm x 24,13cm)"
},
{
value: "110.1|220.1",
displayValue: "Envelope DL (11,01cm x 22,01cm)"
},
{
value: "279.4|431.7",
displayValue: "Tabloid (27,94cm x 43,17cm)"
},
{
value: "297|420.1",
displayValue: "A3 (29,7cm x 42,01cm)"
},
{
value: "304.8|457.1",
displayValue: "Tabloid Oversize (30,48cm x 45,71cm)"
},
{
value: "196.8|273",
displayValue: "ROC 16K (19,68cm x 27,3cm)"
},
{
value: "119.9|234.9",
displayValue: "Envelope Choukei 3 (11,99cm x 23,49cm)"
},
{
value: "330.2|482.5",
displayValue: "Super B/A3 (33,02cm x 48,25cm)"
}]
});
this.cmbPaperOrientation = new Common.UI.ComboBox({
el: $("#printadv-dlg-combo-orient"),
style: "width: 115px;",
menuStyle: "min-width: 115px;",
editable: false,
cls: "input-group-nr",
data: [{
value: c_oAscPageOrientation.PagePortrait,
displayValue: this.strPortrait
},
{
value: c_oAscPageOrientation.PageLandscape,
displayValue: this.strLandscape
}]
});
this.chPrintGrid = new Common.UI.CheckBox({
el: $("#printadv-dlg-chb-grid"),
labelText: this.textPrintGrid
});
this.chPrintRows = new Common.UI.CheckBox({
el: $("#printadv-dlg-chb-rows"),
labelText: this.textPrintHeadings
});
this.spnMarginTop = new Common.UI.MetricSpinner({
el: $("#printadv-dlg-spin-margin-top"),
step: 0.1,
width: 115,
defaultUnit: "cm",
value: "0 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginTop);
this.spnMarginBottom = new Common.UI.MetricSpinner({
el: $("#printadv-dlg-spin-margin-bottom"),
step: 0.1,
width: 115,
defaultUnit: "cm",
value: "0 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginBottom);
this.spnMarginLeft = new Common.UI.MetricSpinner({
el: $("#printadv-dlg-spin-margin-left"),
step: 0.1,
width: 115,
defaultUnit: "cm",
value: "0.19 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginLeft);
this.spnMarginRight = new Common.UI.MetricSpinner({
el: $("#printadv-dlg-spin-margin-right"),
step: 0.1,
width: 115,
defaultUnit: "cm",
value: "0.19 cm",
maxValue: 48.25,
minValue: 0
});
this.spinners.push(this.spnMarginRight);
this.btnHide = new Common.UI.Button({
el: $("#printadv-dlg-btn-hide")
});
this.btnHide.on("click", _.bind(this.handlerShowDetails, this));
this.panelDetails = $("#printadv-dlg-content-to-hide");
this.updateMetricUnit();
this.options.afterrender && this.options.afterrender.call(this);
},
setRange: function (value) {
(value == c_oAscPrintType.ActiveSheets) ? this.radioCurrent.setValue(true) : ((value == c_oAscPrintType.EntireWorkbook) ? this.radioAll.setValue(true) : this.radioSelection.setValue(true));
},
setLayout: function (value) {},
getRange: function () {
return (this.radioCurrent.getValue() ? c_oAscPrintType.ActiveSheets : (this.radioAll.getValue() ? c_oAscPrintType.EntireWorkbook : c_oAscPrintType.Selection));
},
getLayout: function () {},
onRadioRangeChange: function (radio, newvalue) {
if (newvalue) {
this.fireEvent("changerange", this);
}
},
updateMetricUnit: function () {
if (this.spinners) {
for (var i = 0; i < this.spinners.length; i++) {
var spinner = this.spinners[i];
spinner.setDefaultUnit(Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()]);
spinner.setStep(Common.Utils.Metric.getCurrentMetric() == Common.Utils.Metric.c_MetricUnits.cm ? 0.1 : 1);
}
}
},
handlerShowDetails: function (btn) {
if (!this.extended) {
this.extended = true;
this.panelDetails.css({
"display": "none"
});
this.setHeight(286);
btn.setCaption(this.textShowDetails);
} else {
this.extended = false;
this.panelDetails.css({
"display": "block"
});
this.setHeight(482);
btn.setCaption(this.textHideDetails);
}
},
textTitle: "Print Settings",
strLeft: "Left",
strRight: "Right",
strTop: "Top",
strBottom: "Bottom",
strPortrait: "Portrait",
strLandscape: "Landscape",
textPrintGrid: "Print Gridlines",
textPrintHeadings: "Print Rows and Columns Headings",
textPageSize: "Page Size",
textPageOrientation: "Page Orientation",
strMargins: "Margins",
strPrint: "Print",
btnPrint: "Save & Print",
textPrintRange: "Print Range",
textLayout: "Layout",
textCurrentSheet: "Current Sheet",
textAllSheets: "All Sheets",
textSelection: "Selection",
textActualSize: "Actual Size",
textFit: "Fit to width",
textShowDetails: "Show Details",
cancelButtonText: "Cancel",
textHideDetails: "Hide Details"
},
SSE.Views.PrintSettings || {}));
});

View File

@@ -1,75 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.RecentFiles", {
extend: "Ext.panel.Panel",
alias: "widget.sserecentfiles",
cls: "sse-recentfiles",
layout: {
type: "vbox",
align: "stretch"
},
requires: ["Ext.container.Container", "Ext.data.Model", "Ext.data.Store", "Ext.view.View", "Ext.XTemplate", "Common.plugin.DataViewScrollPane"],
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this.callParent(arguments);
var me = this;
me.add({
xtype: "container",
flex: 1,
layout: "fit",
cls: "container-recent-file-list",
items: [{
xtype: "dataview",
store: "RecentFiles",
tpl: Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap">', '<div class="thumb"></div>', '<div class="file-name">{title:htmlEncode}</div>', '<div class="file-info">{folder:htmlEncode}</div>', "</div>", "</tpl>"),
singleSelect: true,
trackOver: true,
style: "overflow:auto",
overItemCls: "x-item-over",
itemSelector: "div.thumb-wrap",
cls: "x-view-context",
plugins: [{
ptype: "dataviewscrollpane",
pluginId: "scrollpane",
areaSelector: ".x-view-context",
settings: {
enableKeyboardNavigation: true
}
}]
}]
});
}
});

View File

@@ -1,231 +1,212 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
var SCALE_MIN = 40;
var MENU_SCALE_PART = 260;
var RIGHTMENU_TOOLBAR_ID = "rightmenu-toolbar-id";
var RIGHTMENU_PANEL_ID = "rightmenu-panel-id";
Ext.define("SSE.view.RightMenu", {
extend: "Ext.panel.Panel",
alias: "widget.sserightmenu",
requires: ["Ext.toolbar.Toolbar", "Ext.button.Button", "Ext.container.Container", "Ext.toolbar.Spacer", "SSE.view.RightPanel", "Ext.util.Cookies"],
cls: "rm-style",
id: RIGHTMENU_PANEL_ID,
bodyCls: "rm-body",
width: SCALE_MIN,
buttonCollection: [],
listeners: {
afterrender: function () {
var owner = this.ownerCt;
if (Ext.isDefined(owner)) {
owner.addListener("resize", Ext.bind(this.resizeMenu, this));
}
}
},
initComponent: function () {
this.dockedItems = this.buildDockedItems();
this._rightSettings = Ext.widget("sserightpanel", {
id: "view-right-panel-settings",
btnImage: this.btnImage,
btnShape: this.btnShape,
btnText: this.btnText
});
this.items = [this._rightSettings];
this.addEvents("editcomplete");
this.callParent(arguments);
},
buildDockedItems: function () {
var me = this;
me.btnShape = Ext.create("Ext.button.Button", {
id: "id-right-menu-shape",
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn menuShape",
asctype: c_oAscTypeSelectElement.Shape,
enableToggle: true,
allowDepress: true,
toggleGroup: "tabpanelbtnsGroup",
disabled: true,
style: "margin-bottom:8px;"
});
me.btnImage = Ext.create("Ext.Button", {
id: "id-right-menu-image",
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn menuImage",
asctype: c_oAscTypeSelectElement.Image,
enableToggle: true,
allowDepress: true,
toggleGroup: "tabpanelbtnsGroup",
disabled: true,
style: "margin-bottom:8px;"
});
me.btnText = Ext.create("Ext.Button", {
id: "id-right-menu-text",
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn menuText",
asctype: c_oAscTypeSelectElement.Paragraph,
enableToggle: true,
allowDepress: true,
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
this.rightToolbar = Ext.create("Ext.toolbar.Toolbar", {
cls: "rm-default-toolbar",
width: this.width || SCALE_MIN,
vertical: true,
dock: "right",
defaultType: "button",
style: "padding-top:15px",
items: [me.btnShape, me.btnImage, me.btnText]
});
return this.rightToolbar;
},
resizeMenu: function (Component, adjWidth, adjHeight, eOpts) {
for (var i = 0; i < this.items.length; i++) {
if (this.items.items[i].el && adjHeight != this.items.items[i].getHeight()) {
this.items.items[i].setHeight(adjHeight);
}
}
this.doComponentLayout();
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
return this;
},
disableMenu: function (disabled) {
var btn, i;
var tbMain = this.rightToolbar;
if (Ext.isDefined(tbMain)) {
for (i = 0; i < tbMain.items.length; i++) {
btn = tbMain.items.items[i];
if (btn) {
btn.pressed && btn.toggle(false);
btn.setDisabled(disabled);
}
}
}
},
onCoAuthoringDisconnect: function () {
this.disableMenu(true);
if (this._rightSettings) {
this._rightSettings.setDisabled(true);
this._rightSettings.setMode({
isEdit: false
});
}
},
onSelectionChanged: function (info) {
var SelectedObjects = [];
if (info.asc_getFlags().asc_getSelectionType() == c_oAscSelectionType.RangeImage || info.asc_getFlags().asc_getSelectionType() == c_oAscSelectionType.RangeShape || info.asc_getFlags().asc_getSelectionType() == c_oAscSelectionType.RangeShapeText) {
SelectedObjects = this.api.asc_getGraphicObjectProps();
}
if (SelectedObjects.length <= 0 && !this._rightSettings.minimizedMode) {
this.clearSelection();
this._rightSettings.minimizedMode = true;
this.setWidth(SCALE_MIN);
}
this._rightSettings.onFocusObject(SelectedObjects);
},
clearSelection: function (exclude) {
var btn, i;
var tbMain = this.rightToolbar;
if (Ext.isDefined(tbMain)) {
for (i = 0; i < tbMain.items.length; i++) {
btn = tbMain.items.items[i];
if (Ext.isDefined(btn) && btn.componentCls === "x-btn") {
if (btn.pressed) {
if (exclude) {
if (typeof exclude == "object") {
if (exclude.id == btn.id) {
continue;
}
} else {
if (btn.iconCls && !(btn.iconCls.search(exclude) < 0)) {
continue;
}
}
}
btn.toggle(false);
}
}
}
}
},
createDelayedElements: function () {
var me = this;
this.api.asc_registerCallback("asc_onSelectionChanged", Ext.bind(this.onSelectionChanged, this));
me._rightSettings.setHeight(me.getHeight());
var toggleHandler = function (btn, pressed) {
if (pressed && !me._rightSettings.minimizedMode) {
btn.addCls("asc-main-menu-btn-selected");
var panel = me._rightSettings._settings[btn.asctype].panel;
var props = me._rightSettings._settings[btn.asctype].props;
me._rightSettings.TabPanel.getLayout().setActiveItem(panel);
me._rightSettings.TabPanel.setHeight(panel.initialHeight);
if (props) {
panel.ChangeSettings.call(panel, props);
}
}
};
var clickHandler = function (btn) {
if (btn.pressed) {
if (me._rightSettings.minimizedMode) {
if (me._rightSettings.TabPanel.hidden) {
me._rightSettings.TabPanel.setVisible(true);
}
me.setWidth(MENU_SCALE_PART);
me._rightSettings.minimizedMode = false;
toggleHandler(btn, btn.pressed);
} else {
btn.addCls("asc-main-menu-btn-selected");
}
} else {
me._rightSettings.minimizedMode = true;
me.setWidth(SCALE_MIN);
btn.removeCls("asc-main-menu-btn-selected");
}
me.fireEvent("editcomplete", me);
};
var button;
var tips = [me.txtShapeSettings, me.txtImageSettings, me.txtParagraphSettings];
for (var i = this.rightToolbar.items.items.length; i--;) {
button = this.rightToolbar.items.items[i];
button.on({
"click": clickHandler,
"toggle": toggleHandler
});
button.setTooltip(tips[i]);
}
},
txtImageSettings: "Image Settings",
txtShapeSettings: "Shape Settings",
txtParagraphSettings: "Text Settings"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
var SCALE_MIN = 40;
var MENU_SCALE_PART = 260;
define(["text!spreadsheeteditor/main/app/template/RightMenu.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/component/MetricSpinner", "common/main/lib/component/CheckBox", "spreadsheeteditor/main/app/view/ParagraphSettings", "spreadsheeteditor/main/app/view/ImageSettings", "spreadsheeteditor/main/app/view/ChartSettings", "spreadsheeteditor/main/app/view/ShapeSettings", "common/main/lib/component/Scroller"], function (menuTemplate, $, _, Backbone) {
SSE.Views.RightMenu = Backbone.View.extend(_.extend({
el: "#right-menu",
template: _.template(menuTemplate),
events: {},
initialize: function () {
this.minimizedMode = true;
this.btnText = new Common.UI.Button({
hint: this.txtParagraphSettings,
asctype: c_oAscTypeSelectElement.Paragraph,
enableToggle: true,
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
this.btnImage = new Common.UI.Button({
hint: this.txtImageSettings,
asctype: c_oAscTypeSelectElement.Image,
enableToggle: true,
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
this.btnChart = new Common.UI.Button({
hint: this.txtChartSettings,
asctype: c_oAscTypeSelectElement.Chart,
enableToggle: true,
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
this.btnShape = new Common.UI.Button({
hint: this.txtShapeSettings,
asctype: c_oAscTypeSelectElement.Shape,
enableToggle: true,
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
this._settings = [];
this._settings[c_oAscTypeSelectElement.Paragraph] = {
panel: "id-paragraph-settings",
btn: this.btnText
};
this._settings[c_oAscTypeSelectElement.Image] = {
panel: "id-image-settings",
btn: this.btnImage
};
this._settings[c_oAscTypeSelectElement.Shape] = {
panel: "id-shape-settings",
btn: this.btnShape
};
this._settings[c_oAscTypeSelectElement.Chart] = {
panel: "id-chart-settings",
btn: this.btnChart
};
return this;
},
render: function () {
var el = $(this.el);
this.trigger("render:before", this);
el.css("width", "40px");
el.css("z-index", 101);
el.show();
el.html(this.template({}));
this.btnText.el = $("#id-right-menu-text");
this.btnText.render();
this.btnImage.el = $("#id-right-menu-image");
this.btnImage.render();
this.btnChart.el = $("#id-right-menu-chart");
this.btnChart.render();
this.btnShape.el = $("#id-right-menu-shape");
this.btnShape.render();
this.btnText.on("click", _.bind(this.onBtnMenuClick, this));
this.btnImage.on("click", _.bind(this.onBtnMenuClick, this));
this.btnChart.on("click", _.bind(this.onBtnMenuClick, this));
this.btnShape.on("click", _.bind(this.onBtnMenuClick, this));
this.paragraphSettings = new SSE.Views.ParagraphSettings();
this.imageSettings = new SSE.Views.ImageSettings();
this.chartSettings = new SSE.Views.ChartSettings();
this.shapeSettings = new SSE.Views.ShapeSettings();
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el).find(".right-panel"),
suppressScrollX: true,
useKeyboard: false
});
}
this.trigger("render:after", this);
return this;
},
setApi: function (api) {
this.api = api;
this.paragraphSettings.setApi(api);
this.imageSettings.setApi(api);
this.chartSettings.setApi(api);
this.shapeSettings.setApi(api);
},
setMode: function (mode) {},
onBtnMenuClick: function (btn, e) {
var target_pane = $("#" + this._settings[btn.options.asctype].panel);
var target_pane_parent = target_pane.parent();
if (btn.pressed) {
if (this.minimizedMode) {
$(this.el).width(MENU_SCALE_PART);
target_pane_parent.css("display", "inline-block");
this.minimizedMode = false;
window.localStorage.setItem("sse-hidden-right-settings", 0);
}
target_pane_parent.find("> .active").removeClass("active");
target_pane.addClass("active");
if (this.scroller) {
this.scroller.scrollTop(0);
}
} else {
target_pane_parent.css("display", "none");
$(this.el).width(SCALE_MIN);
this.minimizedMode = true;
window.localStorage.setItem("sse-hidden-right-settings", 1);
}
this.fireEvent("rightmenuclick", [this, btn.options.asctype, this.minimizedMode]);
},
SetActivePane: function (type, open) {
if (this.minimizedMode && open !== true || this._settings[type] === undefined) {
return;
}
if (this.minimizedMode) {
this._settings[type].btn.toggle(true, false);
this._settings[type].btn.trigger("click", this._settings[type].btn);
} else {
var target_pane = $("#" + this._settings[type].panel);
if (!target_pane.hasClass("active")) {
target_pane.parent().find("> .active").removeClass("active");
target_pane.addClass("active");
if (this.scroller) {
this.scroller.update();
}
}
if (!this._settings[type].btn.isActive()) {
this._settings[type].btn.toggle(true, false);
}
}
},
GetActivePane: function () {
return (this.minimizedMode) ? null : $(".settings-panel.active")[0].id;
},
SetDisabled: function (id, disabled, all) {
if (all) {
this.paragraphSettings.disableControls(disabled);
this.shapeSettings.disableControls(disabled);
this.imageSettings.disableControls(disabled);
this.chartSettings.disableControls(disabled);
} else {
var cmp = $("#" + id);
if (disabled !== cmp.hasClass("disabled")) {
cmp.toggleClass("disabled", disabled);
(disabled) ? cmp.attr({
disabled: disabled
}) : cmp.removeAttr("disabled");
}
}
},
clearSelection: function () {
var target_pane = $(".right-panel");
target_pane.find("> .active").removeClass("active");
_.each(this._settings, function (item) {
if (item.btn.isActive()) {
item.btn.toggle(false, true);
}
});
target_pane.css("display", "none");
$(this.el).width(SCALE_MIN);
this.minimizedMode = true;
window.localStorage.setItem("sse-hidden-right-settings", 1);
Common.NotificationCenter.trigger("layout:changed", "rightmenu");
},
txtParagraphSettings: "Paragraph Settings",
txtImageSettings: "Image Settings",
txtShapeSettings: "Shape Settings",
txtChartSettings: "Chart Settings"
},
SSE.Views.RightMenu || {}));
});

View File

@@ -1,262 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.RightPanel", {
extend: "Ext.container.Container",
alias: "widget.sserightpanel",
width: 220,
layout: {
type: "auto"
},
autoScroll: true,
cls: "asc-right-panel-container",
preventHeader: true,
requires: ["Ext.toolbar.Toolbar", "Ext.container.Container", "Common.plugin.ScrollPane", "SSE.view.ImageSettings", "SSE.view.ShapeSettings", "SSE.view.ParagraphSettings", "Ext.button.Button", "Ext.panel.Panel"],
uses: ["Ext.DomHelper", "Ext.util.Cookies"],
listeners: {
afterrender: function () {
var owner = this.ownerCt;
if (Ext.isDefined(owner)) {
owner.addListener("resize", Ext.bind(this.resizeRightPanels, this));
}
}
},
resizeRightPanels: function (cnt) {
this.doComponentLayout();
},
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
var me = this;
me.editMode = true;
me.minimizedMode = true;
me.plugins = [{
ptype: "scrollpane",
pluginId: "scrollpane",
areaSelector: ".x-container",
settings: {
enableKeyboardNavigation: true,
verticalGutter: 0
}
}];
me.callParent(arguments);
},
updateScrollPane: function () {
var me = this;
me.getPlugin("scrollpane").updateScrollPane();
},
onFocusObject: function (SelectedObjects) {
if (!this.editMode) {
return;
}
for (var i = 0; i < this._settings.length; i++) {
if (this._settings[i]) {
this._settings[i].hidden = 1;
}
}
for (i = 0; i < SelectedObjects.length; i++) {
var type = SelectedObjects[i].asc_getObjectType();
if (type >= this._settings.length || this._settings[type] === undefined) {
continue;
}
var value = SelectedObjects[i].asc_getObjectValue();
if (type == c_oAscTypeSelectElement.Image) {
if (value.asc_getShapeProperties() !== null) {
type = c_oAscTypeSelectElement.Shape;
}
}
this._settings[type].props = value;
this._settings[type].hidden = 0;
}
var lastactive = -1,
currentactive, priorityactive = -1;
for (i = 0; i < this._settings.length; i++) {
if (this._settings[i] === undefined) {
continue;
}
if (this._settings[i].hidden) {
if (!this._settings[i].btn.isDisabled()) {
this._settings[i].btn.setDisabled(true);
}
if (this.TabPanel.getLayout().getActiveItem() == this._settings[i].panel) {
currentactive = -1;
}
} else {
if (this._settings[i].btn.isDisabled()) {
this._settings[i].btn.setDisabled(false);
}
lastactive = i;
if (this._settings[i].needShow) {
this._settings[i].needShow = false;
priorityactive = i;
} else {
if (this.TabPanel.getLayout().getActiveItem() == this._settings[i].panel) {
currentactive = i;
}
}
}
}
if (!this.minimizedMode) {
var active;
if (priorityactive > -1) {
active = priorityactive;
} else {
if (lastactive >= 0 && currentactive < 0) {
active = lastactive;
} else {
if (currentactive >= 0) {
active = currentactive;
}
}
}
if (active !== undefined) {
if (!this._settings[active].btn.pressed) {
this._settings[active].btn.toggle();
} else {
if (this._settings[active].panel.ChangeSettings) {
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
}
}
}
}
this._settings[c_oAscTypeSelectElement.Image].needShow = false;
},
onInsertImage: function () {
this._settings[c_oAscTypeSelectElement.Image].needShow = true;
},
SendThemeColors: function (effectcolors, standartcolors) {
this.effectcolors = effectcolors;
if (standartcolors && standartcolors.length > 0) {
this.standartcolors = standartcolors;
}
if (this.ShapePanel) {
this.ShapePanel.SendThemeColors(effectcolors, standartcolors);
}
},
setApi: function (api) {
this.api = api;
return this;
},
setMode: function (mode) {
this.editMode = mode.isEdit;
},
FillAutoShapes: function () {
this.ShapePanel.FillAutoShapes();
},
hideMenus: function () {
for (var i = 0; i < this._settings.length; i++) {
if (this._settings[i] === undefined) {
continue;
}
if (Ext.isDefined(this._settings[i].panel.hideMenus)) {
this._settings[i].panel.hideMenus();
}
}
},
updateMetricUnit: function () {
this.ImagePanel.updateMetricUnit();
this.ParagraphPanel.updateMetricUnit();
},
_onSelectionChanged: function (info) {
var need_disable = info.asc_getLocked();
if (this._settings.prevDisabled != need_disable) {
this._settings.prevDisabled = need_disable;
this._settings.forEach(function (item) {
item.panel[need_disable ? "disable" : "enable"]();
});
}
},
createDelayedElements: function () {
var me = this;
me.panelHolder = Ext.create("Ext.container.Container", {
layout: {
type: "anchor"
},
items: [me.TabPanel = Ext.create("Ext.panel.Panel", {
hidden: true,
id: "view-tab-panel",
cls: "asc-right-tabpanel",
preventHeader: true,
layout: "card",
items: [me.ShapePanel = Ext.create("SSE.view.ShapeSettings", {
id: "view-shape-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Shape
}), me.ImagePanel = Ext.create("SSE.view.ImageSettings", {
id: "view-image-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Image
}), me.ParagraphPanel = Ext.create("SSE.view.ParagraphSettings", {
id: "view-paragraph-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Paragraph
})],
listeners: {
afterlayout: function () {
me.updateScrollPane();
}
}
})],
listeners: {
afterlayout: function () {
me.updateScrollPane();
}
}
});
me.add(me.panelHolder);
me.ShapePanel.setApi(me.api);
me.ImagePanel.setApi(me.api);
me.ParagraphPanel.setApi(me.api);
me.api.asc_registerCallback("asc_onSelectionChanged", Ext.bind(me._onSelectionChanged, me));
me._settings = [];
me._settings[c_oAscTypeSelectElement.Image] = {
panel: me.ImagePanel,
btn: me.btnImage,
hidden: 1
};
me._settings[c_oAscTypeSelectElement.Shape] = {
panel: me.ShapePanel,
btn: me.btnShape,
hidden: 1
};
me._settings[c_oAscTypeSelectElement.Paragraph] = {
panel: me.ParagraphPanel,
btn: me.btnText,
hidden: 1
};
if (this.effectcolors && this.standartcolors) {
this.ShapePanel.SendThemeColors(this.effectcolors, this.standartcolors);
}
}
});

View File

@@ -1,133 +1,97 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.SetValueDialog", {
extend: "Ext.window.Window",
alias: "widget.setvaluedialog",
requires: ["Ext.window.Window", "Ext.window.MessageBox"],
modal: true,
resizable: false,
plain: true,
height: 138,
width: 222,
padding: "20px",
layout: {
type: "vbox",
align: "stretch"
},
listeners: {
show: function () {
this.udRetValue.focus(false, 500);
}
},
initComponent: function () {
var me = this;
this.addEvents("onmodalresult");
this.items = [{
xtype: "container",
height: 42,
layout: {
type: "hbox",
align: "stretch"
},
items: [this.udRetValue = Ext.widget("numberfield", {
minValue: 0,
maxValue: me.maxvalue,
value: me.startvalue,
step: 1,
flex: 1,
allowDecimals: true,
validateOnBlur: false,
msgTarget: "side",
minText: this.txtMinText,
maxText: this.txtMaxText,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
me.btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
me.btnCancel.fireEvent("click");
}
}
}
}
})]
},
{
xtype: "container",
height: 30,
layout: {
type: "vbox",
align: "center"
},
items: [{
xtype: "container",
width: 182,
layout: {
type: "hbox",
align: "middle"
},
items: [this.btnOk = Ext.widget("button", {
cls: "asc-blue-button",
width: 86,
height: 22,
margin: "0 5px 0 0",
text: this.okButtonText,
listeners: {
click: function (btn) {
if (me.udRetValue.isValid()) {
me.fireEvent("onmodalresult", me, 1, me.udRetValue.value);
me.close();
}
}
}
}), this.btnCancel = Ext.widget("button", {
cls: "asc-darkgray-button",
width: 86,
height: 22,
text: this.cancelButtonText,
listeners: {
click: function (btn) {
me.fireEvent("onmodalresult", this, 0);
me.close();
}
}
})]
}]
}];
this.callParent(arguments);
},
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtMinText: "The minimum value for this field is {0}",
txtMaxText: "The maximum value for this field is {0}"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["common/main/lib/component/Window", "common/main/lib/component/ComboBox"], function () {
SSE.Views.SetValueDialog = Common.UI.Window.extend(_.extend({
options: {
width: 214,
header: true,
style: "min-width: 214px;",
cls: "modal-dlg"
},
initialize: function (options) {
_.extend(this.options, {
title: this.textTitle
},
options || {});
this.template = ['<div class="box">', '<div class="input-row">', '<div id="id-spin-set-value"></div>', "</div>", '<div class="footer center">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + "</button>", "</div>"].join("");
this.options.tpl = _.template(this.template, this.options);
this.startvalue = this.options.startvalue;
this.maxvalue = this.options.maxvalue;
this.defaultUnit = this.options.defaultUnit;
this.step = this.options.step;
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
this.spnSize = new Common.UI.MetricSpinner({
el: $("#id-spin-set-value"),
width: 182,
step: this.step,
defaultUnit: this.defaultUnit,
minValue: 0,
maxValue: this.maxvalue,
value: this.startvalue + " " + this.defaultUnit
});
var $window = this.getChild();
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
this.spnSize.on("entervalue", _.bind(this.onEnterValue, this));
this.spnSize.on("change", _.bind(this.onChange, this));
this.spnSize.$el.find("input").focus();
},
_handleInput: function (state) {
if (this.options.handler) {
this.options.handler.call(this, this, state);
}
this.close();
},
onBtnClick: function (event) {
this._handleInput(event.currentTarget.attributes["result"].value);
},
onEnterValue: function (event) {
this._handleInput("ok");
},
onChange: function () {
var val = this.spnSize.getNumberValue();
val = val / this.step;
val = (val | val) * this.step;
this.spnSize.setValue(val, true);
},
getSettings: function () {
return this.spnSize.getNumberValue();
},
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtMinText: "The minimum value for this field is {0}",
txtMaxText: "The maximum value for this field is {0}"
},
SSE.Views.SetValueDialog || {}));
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,152 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.SheetCopyDialog", {
extend: "Ext.window.Window",
alias: "widget.ssesheetcopydialog",
requires: ["Ext.window.Window", "Common.plugin.GridScrollPane"],
modal: true,
closable: true,
resizable: false,
plain: true,
height: 300,
width: 280,
padding: "20px",
layout: "vbox",
constrain: true,
layoutConfig: {
align: "stretch"
},
listeners: {
show: function () {
this.sheetList.getSelectionModel().select(0);
}
},
initComponent: function () {
var me = this;
var _btnOk = Ext.create("Ext.Button", {
id: "wscopydialog-button-ok",
text: Ext.Msg.buttonText.ok,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
me._modalresult = 1;
me.fireEvent("onmodalresult", me, me._modalresult, me.sheetList.getSelectionModel().selected.items[0].data.sheetindex);
me.close();
}
}
});
var _btnCancel = Ext.create("Ext.Button", {
id: "wscopydialog-button-cancel",
text: me.cancelButtonText,
width: 80,
cls: "asc-darkgray-button",
listeners: {
click: function () {
me._modalresult = 0;
me.fireEvent("onmodalresult", this, this._modalresult);
me.close();
}
}
});
Ext.define("worksheet", {
extend: "Ext.data.Model",
fields: [{
type: "int",
name: "sheetindex"
},
{
type: "string",
name: "name"
}]
});
this.sheetList = Ext.create("Ext.grid.Panel", {
activeItem: 0,
id: "wscopydialog-sheetlist-list",
scroll: false,
store: {
model: "worksheet",
data: this.names
},
columns: [{
flex: 1,
sortable: false,
dataIndex: "name"
}],
plugins: [{
ptype: "gridscrollpane"
}],
height: 160,
width: 240,
hideHeaders: true,
listeners: {
itemdblclick: function (o, record, item, index, e, eOpts) {
_btnOk.fireEvent("click", _btnOk);
}
}
});
this.items = [{
xtype: "label",
text: this.listtitle || this.labelList,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 10
},
this.sheetList, {
xtype: "tbspacer",
height: 14
},
{
xtype: "container",
width: 240,
layout: "hbox",
layoutConfig: {
align: "stretch"
},
items: [{
xtype: "tbspacer",
flex: 1
},
_btnOk, {
xtype: "tbspacer",
width: 5
},
_btnCancel]
}];
this.callParent(arguments);
},
labelList: "Copy before sheet",
cancelButtonText: "Cancel"
});

View File

@@ -1,178 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.SheetRenameDialog", {
extend: "Ext.window.Window",
alias: "widget.ssesheetrenamedialog",
requires: ["Ext.window.Window"],
modal: true,
closable: true,
resizable: false,
preventHeader: true,
plain: true,
height: 116,
width: 280,
padding: "20px",
layout: "vbox",
constrain: true,
layoutConfig: {
align: "stretch"
},
listeners: {
show: function () {
this.txtName.focus(true, 100);
}
},
initComponent: function () {
this.addEvents("onmodalresult");
var me = this;
var checkName = function (n) {
var ac = me.names.length;
while (! (--ac < 0)) {
if (me.names[ac] == n) {
return ac == me.renameindex ? -255 : true;
}
}
return false;
};
var _btnOk = Ext.create("Ext.Button", {
id: "wsrenamedialog-button-ok",
text: Ext.Msg.buttonText.ok,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
if (
/*me.txtName.getValue().length ||*/
! me.txtName.isValid()) {} else {
var res = checkName(me.txtName.getValue());
if (res === true) {
Ext.Msg.show({
title: me.errTitle,
msg: me.errNameExists,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
fn: function () {
me.txtName.focus(true, 500);
}
});
} else {
me._modalresult = res == -255 ? 0 : 1;
me.fireEvent("onmodalresult", me, me._modalresult, me.txtName.getValue());
me.close();
}
}
}
}
});
var _btnCancel = Ext.create("Ext.Button", {
id: "wsrenamedialog-button-cancel",
text: me.cancelButtonText,
width: 80,
cls: "asc-darkgray-button",
listeners: {
click: function () {
me._modalresult = 0;
me.fireEvent("onmodalresult", me, me._modalresult);
me.close();
}
}
});
this.txtName = Ext.create("Ext.form.Text", {
id: "wsrenamedialog-text-wsname",
width: 240,
msgTarget: "side",
validateOnBlur: false,
allowBlank: false,
value: this.names[this.renameindex],
enforceMaxLength: true,
maxLength: 31,
validator: function (value) {
if (value.length > 2 && value[0] == '"' && value[value.length - 1] == '"') {
return true;
}
if (!/[:\\\/\*\?\[\]\']/.test(value)) {
return true;
} else {
return me.errNameWrongChar;
}
},
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
_btnCancel.fireEvent("click");
}
}
}
}
});
this.items = [{
xtype: "label",
text: this.labelSheetName,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 4
},
this.txtName, {
xtype: "tbspacer",
height: 4
},
{
xtype: "container",
width: 240,
layout: "hbox",
layoutConfig: {
align: "stretch"
},
items: [{
xtype: "tbspacer",
flex: 1
},
_btnOk, {
xtype: "tbspacer",
width: 5
},
_btnCancel]
}];
this.callParent(arguments);
},
labelSheetName: "Sheet Name",
errTitle: "Error",
errNameExists: "Worksheet with such name already exist.",
errNameWrongChar: "A sheet name cannot contain characters: \\/*?[]:",
cancelButtonText: "Cancel"
});

View File

@@ -0,0 +1,888 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/StatusBar.template", "tip", "common/main/lib/component/TabBar", "common/main/lib/component/Menu", "common/main/lib/component/Window", "common/main/lib/component/ThemeColorPalette"], function (template) {
if (SSE.Views.Statusbar) {
var RenameDialog = SSE.Views.Statusbar.RenameDialog;
var CopyDialog = SSE.Views.Statusbar.CopyDialog;
}
SSE.Views.Statusbar = Common.UI.BaseView.extend(_.extend({
el: "#statusbar",
template: _.template(template),
events: function () {
return {
"click #status-btn-tabfirst": _.bind(this.onBtnTabScroll, this, "first"),
"click #status-btn-tabback": _.bind(this.onBtnTabScroll, this, "backward"),
"click #status-btn-tabnext": _.bind(this.onBtnTabScroll, this, "forward"),
"click #status-btn-tablast": _.bind(this.onBtnTabScroll, this, "last")
};
},
api: undefined,
initialize: function () {},
render: function () {
$(this.el).html(this.template());
var me = this;
this.editMode = false;
this.btnZoomDown = new Common.UI.Button({
el: $("#status-btn-zoomdown", this.el),
hint: this.tipZoomOut + " (Ctrl+-)",
hintAnchor: "top"
});
this.btnZoomUp = new Common.UI.Button({
el: $("#status-btn-zoomup", this.el),
hint: this.tipZoomIn + " (Ctrl++)",
hintAnchor: "top-right"
});
this.btnScrollFirst = new Common.UI.Button({
el: $("#status-btn-tabfirst", this.el),
hint: this.tipFirst,
disabled: true,
hintAnchor: "top"
});
this.btnScrollBack = new Common.UI.Button({
el: $("#status-btn-tabback", this.el),
hint: this.tipPrev,
disabled: true,
hintAnchor: "top"
});
this.btnScrollNext = new Common.UI.Button({
el: $("#status-btn-tabnext", this.el),
hint: this.tipNext,
disabled: true,
hintAnchor: "top"
});
this.btnScrollLast = new Common.UI.Button({
el: $("#status-btn-tablast", this.el),
hint: this.tipLast,
disabled: true,
hintAnchor: "top"
});
this.btnAddWorksheet = new Common.UI.Button({
el: $("#status-btn-addtab", this.el),
hint: this.tipAddTab,
disabled: true,
hintAnchor: "top"
});
this.cntZoom = new Common.UI.Button({
el: $(".cnt-zoom", this.el),
hint: this.tipZoomFactor,
hintAnchor: "top"
});
this.cntZoom.cmpEl.on({
"show.bs.dropdown": function () {
_.defer(function () {
me.api.asc_enableKeyEvents(false);
me.cntZoom.cmpEl.find("ul").focus();
},
100);
},
"hide.bs.dropdown": function () {
_.defer(function () {
me.api.asc_enableKeyEvents(true);
},
100);
}
});
this.zoomMenu = new Common.UI.Menu({
style: "margin-top:-5px;",
menuAlign: "bl-tl",
items: [{
caption: "50%",
value: 50
},
{
caption: "75%",
value: 75
},
{
caption: "100%",
value: 100
},
{
caption: "125%",
value: 125
},
{
caption: "150%",
value: 150
},
{
caption: "175%",
value: 175
},
{
caption: "200%",
value: 200
}]
});
this.zoomMenu.render($(".cnt-zoom", this.el));
this.zoomMenu.cmpEl.attr({
tabindex: -1
});
this.labelZoom = $("#status-label-zoom", this.$el);
this.panelUsers = $("#status-users-box", this.el);
this.panelUsers.find("#status-users-block").on("click", _.bind(this.onUsersClick, this));
this.tabBarBox = $("#status-sheets-bar-box", this.el);
this.tabbar = new Common.UI.TabBar({
el: "#status-sheets-bar",
placement: "bottom",
draggable: false
}).render();
this.tabbar.on({
"tab:invisible": _.bind(this.onTabInvisible, this),
"tab:changed": _.bind(this.onSheetChanged, this),
"tab:contextmenu": _.bind(this.onTabMenu, this),
"tab:dblclick": _.bind(function () {
if (me.editMode && (me.rangeSelectionMode !== c_oAscSelectionDialogType.Chart) && (me.rangeSelectionMode !== c_oAscSelectionDialogType.FormatTable)) {
me.fireEvent("sheet:changename");
}
},
this),
"tab:move": _.bind(function (tabIndex, index) {
me.tabBarScroll = {
scrollLeft: me.tabbar.scrollX
};
if (_.isUndefined(index) || tabIndex === index) {
return;
}
if (tabIndex < index) {
++index;
}
me.fireEvent("sheet:move", [false, true, tabIndex, index]);
},
this)
});
var menuHiddenItems = new Common.UI.Menu({
menuAlign: "tl-tr"
});
menuHiddenItems.on("item:click", function (obj, item, e) {
me.fireEvent("show:hidden", [me, item.value]);
});
var menuColorItems = new Common.UI.Menu({
menuAlign: "tl-tr",
cls: "color-tab",
items: [{
template: _.template('<div id="id-tab-menu-color" style="width: 165px; height: 220px; margin: 10px;"></div>')
},
{
template: _.template('<a id="id-tab-menu-new-color" style="padding-left:12px;">' + me.textNewColor + "</a>")
}]
});
function dummyCmp() {
return {
isDummy: true,
on: function () {}
};
}
me.mnuTabColor = dummyCmp();
this.tabMenu = new Common.UI.Menu({
menuAlign: "bl-tl",
items: [{
caption: this.itemInsert,
value: "ins"
},
{
caption: this.itemDelete,
value: "del"
},
{
caption: this.itemRename,
value: "ren"
},
{
caption: this.itemCopy,
value: "copy"
},
{
caption: this.itemMove,
value: "move"
},
{
caption: this.itemHide,
value: "hide"
},
{
caption: this.itemHidden,
menu: menuHiddenItems
},
{
caption: this.itemTabColor,
menu: menuColorItems
}]
}).on("render:after", function (btn) {
var colorVal = $('<div class="btn-color-value-line"></div>');
$("button:first-child", btn.cmpEl).append(colorVal);
colorVal.css("background-color", btn.currentColor || "transparent");
me.mnuTabColor = new Common.UI.ThemeColorPalette({
el: $("#id-tab-menu-color"),
dynamiccolors: 10,
colors: [me.textThemeColors, "-", {
color: "3366FF",
effectId: 1
},
{
color: "0000FF",
effectId: 2
},
{
color: "000090",
effectId: 3
},
{
color: "660066",
effectId: 4
},
{
color: "800000",
effectId: 5
},
{
color: "FF0000",
effectId: 1
},
{
color: "FF6600",
effectId: 1
},
{
color: "FFFF00",
effectId: 2
},
{
color: "CCFFCC",
effectId: 3
},
{
color: "008000",
effectId: 4
},
"-", {
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 3
},
{
color: "FFFFFF",
effectId: 4
},
{
color: "000000",
effectId: 5
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
{
color: "FFFFFF",
effectId: 2
},
{
color: "000000",
effectId: 1
},
"-", "--", "-", me.textStandartColors, "-", "transparent", "5301B3", "980ABD", "B2275F", "F83D26", "F86A1D", "F7AC16", "F7CA12", "FAFF44", "D6EF39", "-", "--"]
});
me.mnuTabColor.on("select", function (picker, color) {
me.fireEvent("sheet:setcolor", [color]);
});
});
this.tabbar.$el.append('<div class="menu-backdrop" data-toggle="dropdown" style="width:0; height:0;"/>');
this.tabMenu.render(this.tabbar.$el);
this.tabMenu.on("show:after", _.bind(this.onTabMenuAfterShow, this));
this.tabMenu.on("hide:after", _.bind(this.onTabMenuAfterHide, this));
this.tabMenu.on("item:click", _.bind(this.onTabMenuClick, this));
this.boxMath = $("#status-math-box", this.el);
this.labelSum = $("#status-math-sum", this.boxMath);
this.labelCount = $("#status-math-count", this.boxMath);
this.labelAverage = $("#status-math-average", this.boxMath);
this.boxMath.hide();
this.boxZoom = $("#status-zoom-box", this.el);
this.boxZoom.find(".separator").css("border-left-color", "transparent");
return this;
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onSheetsChanged", _.bind(this.update, this));
return this;
},
setMode: function (mode) {
this.mode = _.extend({},
this.mode, mode);
this.btnAddWorksheet.setVisible(this.mode.isEdit);
this.btnAddWorksheet.setDisabled(this.mode.isDisconnected);
},
setVisible: function (visible) {
visible ? this.show() : this.hide();
},
update: function () {
var me = this;
this.fireEvent("updatesheetsinfo", this);
this.tabbar.empty(true);
this.tabMenu.items[6].menu.removeAll();
this.tabMenu.items[6].hide();
this.btnAddWorksheet.setDisabled(true);
if (this.api) {
var wc = this.api.asc_getWorksheetsCount(),
i = -1;
var hidentems = [],
items = [],
tab,
locked;
var sindex = this.api.asc_getActiveWorksheetIndex();
while (++i < wc) {
locked = me.api.asc_isWorksheetLockedOrDeleted(i);
tab = {
sheetindex: i,
active: sindex == i,
label: me.api.asc_getWorksheetName(i),
cls: locked ? "coauth-locked" : "",
isLockTheDrag: locked
};
this.api.asc_isWorksheetHidden(i) ? hidentems.push(tab) : items.push(tab);
}
if (hidentems.length) {
hidentems.forEach(function (item) {
me.tabMenu.items[6].menu.addItem(new Common.UI.MenuItem({
style: "white-space: pre-wrap",
caption: Common.Utils.String.htmlEncode(item.label),
value: item.sheetindex
}));
});
this.tabMenu.items[6].show();
}
this.tabbar.add(items);
if (!_.isUndefined(this.tabBarScroll)) {
this.tabbar.$bar.scrollLeft(this.tabBarScroll.scrollLeft);
this.tabBarScroll = undefined;
} else {
this.tabbar.setTabVisible("last");
}
this.btnAddWorksheet.setDisabled(me.mode.isDisconnected || me.api.asc_isWorkbookLocked());
$("#status-label-zoom").text(Common.Utils.String.format(this.zoomText, Math.floor((this.api.asc_getZoom() + 0.005) * 100)));
me.fireEvent("sheet:updateColors", [true]);
}
},
setMathInfo: function (info) {
if (info.count > 1) {
if (!this.boxMath.is(":visible")) {
this.boxMath.show();
}
this.labelCount.text(this.textCount + ": " + info.count);
this.labelSum.text((info.sum && info.sum.length) ? (this.textSum + ": " + info.sum) : "");
this.labelAverage.text((info.average && info.average.length) ? (this.textAverage + ": " + info.average) : "");
} else {
if (this.boxMath.is(":visible")) {
this.boxMath.hide();
}
}
var me = this;
_.delay(function () {
me.onTabInvisible(undefined, me.tabbar.checkInvisible(true));
},
30);
},
onUsersClick: function () {
this.fireEvent("click:users", this);
},
onSheetChanged: function (o, index, tab) {
this.api.asc_showWorksheet(tab.sheetindex);
if (this.hasTabInvisible && !this.tabbar.isTabVisible(index)) {
this.tabbar.setTabVisible(index);
}
this.fireEvent("sheet:changed", [this, tab.sheetindex]);
this.fireEvent("sheet:updateColors", [true]);
Common.NotificationCenter.trigger("comments:updatefilter", {
property: "uid",
value: new RegExp("^(doc_|sheet" + this.api.asc_getActiveWorksheetId() + "_)")
},
false);
},
onTabMenu: function (o, index, tab) {
if (this.mode.isEdit && (this.rangeSelectionMode !== c_oAscSelectionDialogType.Chart) && (this.rangeSelectionMode !== c_oAscSelectionDialogType.FormatTable)) {
if (tab && tab.sheetindex >= 0) {
var rect = tab.$el.get(0).getBoundingClientRect(),
childPos = tab.$el.offset(),
parentPos = tab.$el.parent().offset();
if (!tab.isActive()) {
this.tabbar.setActive(tab);
}
var issheetlocked = this.api.asc_isWorksheetLockedOrDeleted(tab.sheetindex),
isdoclocked = this.api.asc_isWorkbookLocked();
this.tabMenu.items[0].setDisabled(isdoclocked);
this.tabMenu.items[1].setDisabled(issheetlocked);
this.tabMenu.items[2].setDisabled(issheetlocked);
this.tabMenu.items[3].setDisabled(issheetlocked);
this.tabMenu.items[4].setDisabled(issheetlocked);
this.tabMenu.items[5].setDisabled(issheetlocked);
this.tabMenu.items[6].setDisabled(isdoclocked);
this.tabMenu.items[7].setDisabled(issheetlocked);
this.api.asc_closeCellEditor();
this.api.asc_enableKeyEvents(false);
this.tabMenu.atposition = (function () {
return {
top: rect.top,
left: rect.left - parentPos.left - 2
};
})();
this.tabMenu.hide();
this.tabMenu.show();
}
}
},
onTabMenuAfterShow: function (obj) {
if (obj.atposition) {
obj.setOffset(obj.atposition.left);
}
this.enableKeyEvents = true;
},
onTabMenuAfterHide: function () {
if (!_.isUndefined(this.enableKeyEvents)) {
if (this.api) {
this.api.asc_enableKeyEvents(this.enableKeyEvents);
}
this.enableKeyEvents = undefined;
}
},
onTabMenuClick: function (o, item) {
if (item && this.api) {
this.enableKeyEvents = (item.value === "ins" || item.value === "hide");
}
},
onTabInvisible: function (obj, opts) {
if (this.btnScrollFirst.isDisabled() !== (!opts.first)) {
this.btnScrollFirst.setDisabled(!opts.first);
this.btnScrollBack.setDisabled(!opts.first);
}
if (this.btnScrollNext.isDisabled() !== (!opts.last)) {
this.btnScrollNext.setDisabled(!opts.last);
this.btnScrollLast.setDisabled(!opts.last);
}
this.hasTabInvisible = opts.first || opts.last;
},
onBtnTabScroll: function (action, e) {
this.tabbar.setTabVisible(action);
},
updateTabbarBorders: function () {
var right = parseInt(this.boxZoom.css("width")),
visible = false;
if (this.boxMath.is(":visible")) {
right += parseInt(this.boxMath.css("width"));
visible = true;
}
if (this.panelUsers.is(":visible")) {
right += parseInt(this.panelUsers.css("width"));
visible = true;
}
this.boxZoom.find(".separator").css("border-left-color", visible ? "" : "transparent");
this.tabBarBox.css("right", right + "px");
},
changeViewMode: function (edit) {
if (edit) {
this.tabBarBox.css("left", "152px");
} else {
this.tabBarBox.css("left", "");
}
this.tabbar.options.draggable = edit;
this.editMode = edit;
},
tipZoomIn: "Zoom In",
tipZoomOut: "Zoom Out",
tipZoomFactor: "Magnification",
tipFirst: "First Sheet",
tipLast: "Last Sheet",
tipPrev: "Previous Sheet",
tipNext: "Next Sheet",
tipAddTab: "Add Worksheet",
itemInsert: "Insert",
itemDelete: "Delete",
itemRename: "Rename",
itemCopy: "Copy",
itemMove: "Move",
itemHide: "Hide",
itemHidden: "Hidden",
itemTabColor: "Tab Color",
textThemeColors: "Theme Colors",
textStandartColors: "Standart Colors",
textNoColor: "No Color",
textNewColor: "Add New Custom Color",
zoomText: "Zoom {0}%",
textSum: "SUM",
textCount: "COUNT",
textAverage: "AVERAGE"
},
SSE.Views.Statusbar || {}));
SSE.Views.Statusbar.RenameDialog = Common.UI.Window.extend(_.extend({
options: {
header: false,
width: 280,
cls: "modal-dlg"
},
template: '<div class="box">' + '<div class="input-row">' + "<label><%= label %></label>" + "</div>" + '<div class="input-row" id="txt-sheet-name" />' + "</div>" + '<div class="footer right">' + '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button>' + '<button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button>' + "</div>",
initialize: function (options) {
_.extend(this.options, options || {},
{
label: this.labelSheetName,
btns: {
ok: this.okButtonText,
cancel: this.cancelButtonText
}
});
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild();
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
this.txtName = new Common.UI.InputField({
el: $window.find("#txt-sheet-name"),
style: "width:100%;",
value: this.options.current,
allowBlank: false,
validation: _.bind(this.nameValidator, this)
});
if (this.txtName) {
this.txtName.$el.find("input").attr("maxlength", 31);
this.txtName.$el.on("keypress", "input[type=text]", _.bind(this.onNameKeyPress, this));
}
},
show: function (x, y) {
Common.UI.Window.prototype.show.apply(this, arguments);
var edit = this.txtName.$el.find("input");
_.delay(function (me) {
edit.focus();
edit.select();
},
100, this);
},
onBtnClick: function (event) {
this.doClose(event.currentTarget.attributes["result"].value);
},
doClose: function (res) {
if (res == "ok") {
if (this.txtName.checkValidate() !== true) {
_.delay(function (me) {
me.txtName.focus();
},
100, this);
return;
}
}
if (this.options.handler) {
this.options.handler.call(this, res, this.txtName.getValue());
}
this.close();
},
onNameKeyPress: function (e) {
if (e.keyCode == Common.UI.Keys.RETURN) {
this.doClose("ok");
}
},
nameValidator: function (value) {
if (this.options.names) {
var testval = value.toLowerCase();
for (var i = this.options.names.length - 1; i >= 0; --i) {
if (this.options.names[i] === testval) {
return this.errNameExists;
}
}
}
if (value.length > 2 && value[0] == '"' && value[value.length - 1] == '"') {
return true;
}
if (!/[:\\\/\*\?\[\]\']/.test(value)) {
return true;
}
return this.errNameWrongChar;
},
errNameExists: "Worksheet with such name already exist.",
errNameWrongChar: "A sheet name cannot contains characters: \\, /, *, ?, [, ], :",
labelSheetName: "Sheet Name"
},
RenameDialog || {}));
SSE.Views.Statusbar.CopyDialog = Common.UI.Window.extend(_.extend({
options: {
width: 270,
height: 300,
cls: "modal-dlg"
},
template: '<div class="box">' + '<div class="input-row">' + "<label><%= label %></label>" + "</div>" + '<div id="status-list-names" style="height: 170px;"/>' + "</div>" + '<div class="footer center">' + '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button>' + '<button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button>' + "</div>",
initialize: function (options) {
_.extend(this.options, options || {},
{
label: options.ismove ? this.textMoveBefore : this.textCopyBefore,
btns: {
ok: this.okButtonText,
cancel: this.cancelButtonText
}
});
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild();
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
var pages = [];
this.options.names.forEach(function (item) {
pages.push(new Common.UI.DataViewModel(item));
},
this);
if (pages.length) {
pages.push(new Common.UI.DataViewModel({
value: this.options.ismove ? this.itemMoveToEnd : this.itemCopyToEnd,
inindex: -255
}));
}
this.listNames = new Common.UI.ListView({
el: $("#status-list-names", $window),
store: new Common.UI.DataViewStore(pages),
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="pointer-events:none;"><%= Common.Utils.String.htmlEncode(value) %></div>')
});
this.listNames.selectByIndex(0);
this.listNames.on("entervalue", _.bind(this.onPrimary, this));
this.listNames.on("item:dblclick", _.bind(this.onPrimary, this));
this.mask = $(".modals-mask");
this.mask.on("mousedown", _.bind(this.onUpdateFocus, this));
},
show: function (x, y) {
Common.UI.Window.prototype.show.apply(this, arguments);
_.delay(function (me) {
me.listNames.$el.find(".listview").focus();
},
100, this);
},
hide: function () {
Common.UI.Window.prototype.hide.apply(this, arguments);
this.mask.off("mousedown", _.bind(this.onUpdateFocus, this));
},
onBtnClick: function (event) {
var active = this.listNames.getSelectedRec();
if (this.options.handler) {
this.options.handler.call(this, event.currentTarget.attributes["result"].value, active[0].get("inindex"));
}
this.close();
},
onPrimary: function () {
if (this.options.handler) {
this.options.handler.call(this, "ok", this.listNames.getSelectedRec()[0].get("inindex"));
}
this.close();
},
onUpdateFocus: function () {
_.delay(function (me) {
me.listNames.$el.find(".listview").focus();
},
100, this);
},
itemCopyToEnd: "(Copy to end)",
itemMoveToEnd: "(Move to end)",
textCopyBefore: "Copy before sheet",
textMoveBefore: "Move before sheet"
},
CopyDialog || {}));
});

View File

@@ -1,149 +1,150 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("SSE.view.TableOptionsDialog", {
extend: "Ext.window.Window",
alias: "widget.tableoptionsdialog",
requires: ["Ext.window.Window"],
closable: true,
resizable: false,
height: 145,
width: 300,
padding: "12px 20px 0 20px",
constrain: true,
layout: {
type: "vbox",
align: "stretch"
},
listeners: {
show: function () {
var options = this.api.asc_getAddFormatTableOptions();
this.txtDataRange.setValue(options.asc_getRange());
this.chTitle.setValue(options.asc_getIsTitle());
this.api.asc_setSelectionDialogMode(true, options.asc_getRange());
},
beforedestroy: function () {
this.api.asc_setSelectionDialogMode(false);
}
},
initComponent: function () {
var me = this;
var worksheets = "",
names = this.names;
if (names) {
worksheets = names[0];
var i = names.length;
while (--i) {
worksheets += ("|" + names[i]);
}
}
var longRe = new RegExp(worksheets + "![A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*");
var shortRe = new RegExp(worksheets + "![A-Z]+[1-9]\d*");
this.txtDataRange = Ext.create("Ext.form.Text", {
height: 22,
msgTarget: "side",
validateOnBlur: false,
allowBlank: false,
value: "",
editable: false,
check: false,
validator: function (value) {
if (!this.check) {
return true;
}
var isvalid = longRe.test(value); ! isvalid && (isvalid = shortRe.test(value));
if (isvalid) {
$("#" + this.id + " input").css("color", "black");
return true;
} else {
$("#" + this.id + " input").css("color", "red");
return "ERROR! Invalid cells range";
}
}
});
this.chTitle = Ext.widget("checkbox", {
style: "margin: 0 26px 0 0",
boxLabel: this.txtTitle
});
var _btnOk = Ext.create("Ext.Button", {
text: Ext.Msg.buttonText.ok,
width: 80,
style: "margin: 0 6px 0 0;",
cls: "asc-blue-button",
listeners: {
click: function () {
if (me.txtDataRange.validate()) {
me.fireEvent("onmodalresult", me, 1, me.getSettings());
me.close();
}
}
}
});
var _btnCancel = Ext.create("Ext.Button", {
text: this.textCancel,
width: 80,
cls: "asc-darkgray-button",
listeners: {
click: function () {
me.close();
}
}
});
this.items = [this.txtDataRange, this.chTitle, {
xtype: "container",
height: 26,
style: "margin: 8px 0 0 0;",
layout: {
type: "hbox",
align: "stretch",
pack: "end"
},
items: [_btnOk, _btnCancel]
}];
if (this.api) {
this.api.asc_registerCallback("asc_onSelectionRangeChanged", Ext.bind(this._onRangeChanged, this));
}
this.callParent(arguments);
this.setTitle(this.txtFormat);
},
_onRangeChanged: function (info) {
this.txtDataRange.setValue(info);
},
getSettings: function () {
var options = this.api.asc_getAddFormatTableOptions();
options.asc_setRange(this.txtDataRange.getValue());
options.asc_setIsTitle(this.chTitle.getValue());
return options;
},
txtTitle: "Title",
txtFormat: "Format as table",
textCancel: "Cancel"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
if (Common === undefined) {
var Common = {};
}
define(["common/main/lib/component/ComboBox", "common/main/lib/component/CheckBox", "common/main/lib/component/InputField", "common/main/lib/component/Window"], function () {
SSE.Views.TableOptionsDialog = Common.UI.Window.extend(_.extend({
options: {
width: 350,
cls: "modal-dlg",
modal: false
},
initialize: function (options) {
_.extend(this.options, {
title: this.txtFormat
},
options);
this.template = ['<div class="box">', '<div id="id-dlg-tableoptions-range" class="input-row" style="margin-bottom: 10px;"></div>', '<div class="input-row" id="id-dlg-tableoptions-title"></div>', "</div>", '<div class="footer right">', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + "</button>", '<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + "</button>", "</div>"].join("");
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild(),
me = this;
me.inputRange = new Common.UI.InputField({
el: $("#id-dlg-tableoptions-range"),
name: "range",
style: "width: 100%;",
allowBlank: false,
blankError: this.txtEmpty,
validateOnChange: true
});
me.cbTitle = new Common.UI.CheckBox({
el: $("#id-dlg-tableoptions-title"),
labelText: this.txtTitle
});
$window.find(".dlg-btn").on("click", _.bind(this.onBtnClick, this));
me.inputRange.cmpEl.find("input").on("keypress", _.bind(this.onKeyPress, this));
this.on("close", _.bind(this.onClose, this));
},
onPrimary: function () {
this._handleInput("ok");
return false;
},
setSettings: function (settings) {
var me = this;
if (settings.api) {
me.api = settings.api;
var options = me.api.asc_getAddFormatTableOptions();
this.inputRange.setValue(options.asc_getRange());
this.cbTitle.setValue(options.asc_getIsTitle());
me.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.FormatTable, options.asc_getRange());
me.api.asc_registerCallback("asc_onSelectionRangeChanged", _.bind(me.onApiRangeChanged, me));
Common.NotificationCenter.trigger("cells:range", c_oAscSelectionDialogType.FormatTable);
}
me.inputRange.validation = function (value) {
var isvalid = me.api.asc_checkDataRange(c_oAscSelectionDialogType.FormatTable, value, false);
return (isvalid == c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true;
};
},
getSettings: function () {
var options = this.api.asc_getAddFormatTableOptions();
options.asc_setRange(this.inputRange.getValue());
options.asc_setIsTitle(this.cbTitle.checked);
return options;
},
onApiRangeChanged: function (info) {
this.inputRange.setValue(info);
if (this.inputRange.cmpEl.hasClass("error")) {
this.inputRange.cmpEl.removeClass("error");
}
},
isRangeValid: function () {
var isvalid = this.api.asc_checkDataRange(c_oAscSelectionDialogType.FormatTable, this.inputRange.getValue(), true);
if (isvalid == c_oAscError.ID.No) {
return true;
} else {
if (isvalid == c_oAscError.ID.AutoFilterDataRangeError) {
Common.UI.warning({
msg: this.errorAutoFilterDataRange
});
}
}
return false;
},
onBtnClick: function (event) {
this._handleInput(event.currentTarget.attributes["result"].value);
},
onClose: function (event) {
if (this.api) {
this.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.None);
}
Common.NotificationCenter.trigger("cells:range", c_oAscSelectionDialogType.None);
Common.NotificationCenter.trigger("edit:complete", this);
},
onKeyPress: function (event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput("ok");
}
},
_handleInput: function (state) {
if (this.options.handler) {
if (state == "ok") {
if (this.isRangeValid() !== true) {
return;
}
}
this.options.handler.call(this, this, state);
}
this.close();
},
txtTitle: "Title",
txtFormat: "Format as table",
textCancel: "Cancel",
txtEmpty: "This field is required",
txtInvalidRange: "ERROR! Invalid cells range",
errorAutoFilterDataRange: "The operation could not be done for the selected range of cells.<br>Select a uniform data range inside or outside the table and try again."
},
SSE.Views.TableOptionsDialog || {}));
});

File diff suppressed because one or more lines are too long

View File

@@ -1,312 +1,133 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
window.cancelButtonText = "Cancel";
Ext.define("SSE.view.Viewport", {
extend: "Ext.container.Viewport",
alias: "widget.sseviewport",
layout: "fit",
uses: ["SSE.view.DocumentHolder", "SSE.view.MainMenu", "SSE.view.File", "SSE.view.DocumentStatusInfo", "SSE.view.CellInfo", "Common.view.ChatPanel", "Common.view.CommentsPanel", "Common.view.Header", "SSE.view.Toolbar", "Common.view.SearchDialog", "Common.view.About", "SSE.view.RightMenu"],
initComponent: function () {
this.header = Ext.widget("commonheader", {
config: {
headerCaption: "Spreadsheet Editor"
}
});
this.applicationUI = Ext.widget("container", {
layout: {
type: "vbox",
align: "stretch"
},
flex: 1,
hidden: true,
items: [{
xtype: "container",
flex: 1,
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "ssemainmenu",
id: "view-main-menu",
maxWidth: 600,
listeners: {
panelshow: function (panel, fulscreen) {
if (fulscreen) {
var menu = Ext.getCmp("view-main-menu");
menu.clearSelection({
id: menu.currentFullScaleMenuBtn.id
});
}
}
},
buttonCollection: [{
cls: "menuFile",
tooltip: this.tipFile + " (Alt+F)",
id: "id-menu-file",
scale: "full",
disabled: true,
items: [{
xtype: "ssefile",
id: "main-menu-file-options",
width: "100%",
height: "100%"
}]
},
{
cls: "menuSearch",
scale: "modal",
id: "main-menu-search",
disabled: true,
tooltip: this.tipSearch + " (Ctrl+F)"
},
{
cls: "menuComments",
id: "id-menu-comments",
hideMode: "display",
scale: 300,
tooltip: this.tipComments + " (Ctrl+Shift+H)",
disabled: true,
items: [{
xtype: "commoncommentspanel",
height: "100%"
}]
},
{
cls: "menuChat",
id: "id-menu-chat",
scale: 300,
tooltip: this.tipChat + " (Ctrl+Alt+Q)",
disabled: true,
items: [{
xtype: "commonchatpanel",
height: "100%"
}]
},
{
cls: "menuAbout",
id: "id-menu-about",
tooltip: "About",
scale: "full",
disabled: true,
items: [{
xtype: "commonabout",
id: "main-menu-about",
width: "100%",
height: "100%"
}]
}]
},
{
xtype: "splitter",
id: "main-menu-splitter",
cls: "splitter-document-area",
defaultSplitMin: 300,
hidden: true
},
{
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
maintainFlex: true,
flex: 1,
items: [{
xtype: "ssecellinfo",
id: "cell-edit",
style: "border-left:solid 1px #afafaf;"
},
{
xtype: "splitter",
id: "field-formula-splitter",
defaultSplitMin: 23,
cls: "splitter-document-area"
},
{
id: "editor_sdk",
minHeight: 70,
xtype: "ssedocumentholder",
maintainFlex: true,
flex: 1
}]
}]
},
{
xtype: "documentstatusinfo",
id: "view-status"
}]
});
this.items = {
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
items: [this.header, this.applicationUI]
};
Ext.tip.QuickTipManager.init();
this.callParent(arguments);
},
applyMode: function () {
this.hkSaveAs[this.mode.canDownload ? "enable" : "disable"]();
this.hkChat[this.mode.canCoAuthoring ? "enable" : "disable"]();
this.hkComments[(this.mode.canCoAuthoring && this.mode.isEdit) ? "enable" : "disable"]();
},
setMode: function (m, delay) {
m.isDisconnected ? this.mode.canDownload = this.mode.canCoAuthoring = false : this.mode = m;
if (!delay) {
this.applyMode();
}
},
applyEditorMode: function () {
var me = this;
me._toolbar = Ext.widget("ssetoolbar", {
id: "view-toolbar"
});
me._rightMenu = Ext.widget("sserightmenu", {
id: "view-right-menu"
});
me.applicationUI.insert(0, me._toolbar);
me.applicationUI.items.items[1].add(me._rightMenu);
me._toolbar.setVisible(true);
},
createDelayedElements: function () {
var _self = this;
this.hotKeys = new Ext.util.KeyMap(document, [{
key: "f",
ctrl: true,
shift: false,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuSearch");
}
}
}
},
{
key: [Ext.EventObject.PAGE_DOWN, Ext.EventObject.PAGE_UP],
ctrl: false,
shift: false,
alt: true,
defaultEventAction: "stopEvent",
fn: function (key, event) {
if (canHotKey()) {
var cmp = Ext.getCmp("view-status");
if (cmp) {
cmp.setActiveWorksheet(undefined, key == event.PAGE_DOWN ? ACTIVE_TAB_NEXT : ACTIVE_TAB_PREV);
}
}
}
},
{
key: "f",
alt: true,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
Ext.menu.Manager.hideAll();
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuFile");
}
}
}
}]);
this.hkSaveAs = new Ext.util.KeyMap(document, {
key: "s",
ctrl: true,
shift: true,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
Ext.menu.Manager.hideAll();
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuFile");
}
}
}
});
this.hkHelp = new Ext.util.KeyMap(document, {
key: Ext.EventObject.F1,
ctrl: false,
shift: false,
defaultEventAction: "stopEvent",
scope: this,
fn: function () {
if (canHotKey()) {
Ext.menu.Manager.hideAll();
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuFile");
}
}
}
});
this.hkChat = new Ext.util.KeyMap(document, {
key: "q",
ctrl: true,
alt: true,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuChat");
}
}
}
});
this.hkComments = new Ext.util.KeyMap(document, {
key: "H",
ctrl: true,
shift: true,
defaultEventAction: "stopEvent",
fn: function () {
if (canHotKey()) {
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuComments");
}
}
}
});
},
tipChat: "Chat",
tipComments: "Comments",
tipFile: "File",
tipSearch: "Search"
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["text!spreadsheeteditor/main/app/template/Viewport.template", "jquery", "underscore", "backbone", "common/main/lib/component/BaseView", "common/main/lib/component/Layout"], function (viewportTemplate, $, _, Backbone) {
SSE.Views.Viewport = Backbone.View.extend({
el: "#viewport",
template: _.template(viewportTemplate),
events: {},
initialize: function () {},
render: function () {
var el = $(this.el);
el.html(this.template({}));
if (Common.Utils.isSafari) {
$("body").addClass("safari");
$("body").mousewheel(function (e) {
e.preventDefault();
e.stopPropagation();
});
} else {
if (Common.Utils.isChrome) {
$("body").addClass("chrome");
}
}
var $container = $("#viewport-vbox-layout", el);
var items = $container.find(" > .layout-item");
this.vlayout = new Common.UI.VBoxLayout({
box: $container,
items: [{
el: items[0],
rely: true
},
{
el: items[1],
rely: true
},
{
el: items[2],
stretch: true
},
{
el: items[3],
height: 25
}]
});
$container = $("#viewport-hbox-layout", el);
items = $container.find(" > .layout-item");
this.hlayout = new Common.UI.HBoxLayout({
box: $container,
items: [{
el: items[0],
rely: true,
resize: {
hidden: true,
autohide: false,
min: 300,
max: 600
}
},
{
el: items[1],
stretch: true
},
{
el: $(items[2]).hide(),
rely: true
}]
});
$container = $container.find(".layout-ct.vbox");
items = $container.find(" > .layout-item");
this.celayout = new Common.UI.VBoxLayout({
box: $container,
items: [{
el: items[0],
rely: true,
resize: {
min: 19,
max: -100
}
},
{
el: items[1],
stretch: true
}]
});
return this;
},
applyEditorMode: function () {
var me = this,
toolbarView = SSE.getController("Toolbar").getView("Toolbar"),
rightMenuView = SSE.getController("RightMenu").getView("RightMenu");
me._toolbar = toolbarView.render(this.mode.isEditDiagram);
me._rightMenu = rightMenuView.render();
},
setMode: function (mode, delay) {
if (mode.isDisconnected) {
if (_.isUndefined(this.mode)) {
this.mode = {};
}
this.mode.canCoAuthoring = false;
} else {
this.mode = mode;
}
}
});
});