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

@@ -0,0 +1,620 @@
/*
* (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!documenteditor/main/app/template/ChartSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "documenteditor/main/app/view/ImageSettingsAdvanced"], function (menuTemplate, $, _, Backbone) {
DE.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 = {
WrappingStyle: c_oAscWrapStyle2.Inline,
CanBeFlow: true,
Width: 0,
Height: 0,
FromGroup: false,
ChartStyle: 1,
ChartType: -1,
SeveralCharts: false,
DisabledControls: false
};
this.lockedControls = [];
this._locked = false;
this._noApply = false;
this._originalProps = null;
this.render();
var viewData = [{
offsetx: 0,
data: c_oAscWrapStyle2.Inline,
iconCls: "wrap-inline",
tip: this.txtInline,
selected: true
},
{
offsetx: 50,
data: c_oAscWrapStyle2.Square,
iconCls: "wrap-square",
tip: this.txtSquare
},
{
offsetx: 100,
data: c_oAscWrapStyle2.Tight,
iconCls: "wrap-tight",
tip: this.txtTight
},
{
offsetx: 150,
data: c_oAscWrapStyle2.Through,
iconCls: "wrap-through",
tip: this.txtThrough
},
{
offsetx: 200,
data: c_oAscWrapStyle2.TopAndBottom,
iconCls: "wrap-topAndBottom",
tip: this.txtTopAndBottom
},
{
offsetx: 250,
data: c_oAscWrapStyle2.InFront,
iconCls: "wrap-inFront",
tip: this.txtInFront
},
{
offsetx: 300,
data: c_oAscWrapStyle2.Behind,
iconCls: "wrap-behind",
tip: this.txtBehind
}];
this.btnWrapType = new Common.UI.Button({
cls: "btn-large-dataview",
iconCls: "item-wrap wrap-inline",
menu: new Common.UI.Menu({
items: [{
template: _.template('<div id="id-chart-menu-wrap" style="width: 235px; margin: 0 5px;"></div>')
}]
})
});
this.btnWrapType.on("render:after", function (btn) {
me.mnuWrapPicker = new Common.UI.DataView({
el: $("#id-chart-menu-wrap"),
parentMenu: btn.menu,
store: new Common.UI.DataViewStore(viewData),
itemTemplate: _.template('<div id="<%= id %>" class="item-wrap" style="background-position: -<%= offsetx %>px 0;"></div>')
});
});
this.btnWrapType.render($("#chart-button-wrap"));
this.mnuWrapPicker.on("item:click", _.bind(this.onSelectWrap, this, this.btnWrapType));
this.lockedControls.push(this.btnWrapType);
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.labelWidth = $(this.el).find("#chart-label-width");
this.labelHeight = $(this.el).find("#chart-label-height");
this.btnEditData = new Common.UI.Button({
el: $("#chart-button-edit-data")
});
this.lockedControls.push(this.btnEditData);
this.btnEditData.on("click", _.bind(this.setEditData, 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_onImgWrapStyleChanged", _.bind(this._ChartWrapStyleChanged, this));
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 (props && props.get_ChartProperties()) {
this._originalProps = new CImgProperty(props);
this._noApply = true;
var value = props.get_WrappingStyle();
if (this._state.WrappingStyle !== value) {
var record = this.mnuWrapPicker.store.findWhere({
data: value
});
this.mnuWrapPicker.selectRecord(record, true);
if (record) {
this.btnWrapType.setIconCls("item-wrap " + record.get("iconCls"));
} else {
this.btnWrapType.setIconCls("");
}
this._state.WrappingStyle = value;
}
this.chartProps = props.get_ChartProperties();
value = props.get_SeveralCharts() || this._locked;
if (this._state.SeveralCharts !== value) {
this.btnEditData.setDisabled(value);
this._state.SeveralCharts = value;
}
value = props.get_SeveralChartTypes();
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.get_SeveralChartStyles();
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.get_CanBeFlow() && !this._locked;
var fromgroup = props.get_FromGroup() || this._locked;
if (this._state.CanBeFlow !== value || this._state.FromGroup !== fromgroup) {
this.btnWrapType.setDisabled(!value || fromgroup);
this._state.CanBeFlow = value;
this._state.FromGroup = fromgroup;
}
value = props.get_Width();
if (Math.abs(this._state.Width - value) > 0.001) {
this.labelWidth[0].innerHTML = this.textWidth + ": " + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this._state.Width = value;
}
value = props.get_Height();
if (Math.abs(this._state.Height - value) > 0.001) {
this.labelHeight[0].innerHTML = this.textHeight + ": " + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this._state.Height = value;
}
}
},
updateMetricUnit: function () {
var value = Common.Utils.Metric.fnRecalcFromMM(this._state.Width);
this.labelWidth[0].innerHTML = this.textWidth + ": " + value.toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
value = Common.Utils.Metric.fnRecalcFromMM(this._state.Height);
this.labelHeight[0].innerHTML = this.textHeight + ": " + value.toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
},
createDelayedElements: function () {
this.updateMetricUnit();
},
_ChartWrapStyleChanged: function (style) {
if (this._state.WrappingStyle !== style) {
this._noApply = true;
var record = this.mnuWrapPicker.store.findWhere({
data: style
});
this.mnuWrapPicker.selectRecord(record, true);
if (record) {
this.btnWrapType.setIconCls("item-wrap " + record.get("iconCls"));
}
this._state.WrappingStyle = style;
this._noApply = false;
}
},
onSelectWrap: 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.btnWrapType.setIconCls("item-wrap " + rawData.iconCls);
if (this.api) {
var props = new CImgProperty();
props.put_WrappingStyle((rawData.data));
if (this._state.WrappingStyle === c_oAscWrapStyle2.Inline && rawData.data !== c_oAscWrapStyle2.Inline) {
props.put_PositionH(new CImagePositionH());
props.get_PositionH().put_UseAlign(false);
props.get_PositionH().put_RelativeFrom(c_oAscRelativeFromH.Column);
var val = this._originalProps.get_Value_X(c_oAscRelativeFromH.Column);
props.get_PositionH().put_Value(val);
props.put_PositionV(new CImagePositionV());
props.get_PositionV().put_UseAlign(false);
props.get_PositionV().put_RelativeFrom(c_oAscRelativeFromV.Paragraph);
val = this._originalProps.get_Value_Y(c_oAscRelativeFromV.Paragraph);
props.get_PositionV().put_Value(val);
}
this.api.ImgApply(props);
}
this.fireEvent("editcomplete", this);
},
setEditData: function () {
var diagramEditor = DE.getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");
if (diagramEditor) {
diagramEditor.setEditMode(true);
diagramEditor.show();
var chart = this.api.asc_getChartObject();
if (chart) {
diagramEditor.setChartData(new Asc.asc_CChartBinary(chart));
}
}
},
openAdvancedSettings: function (e) {
if (this.linkAdvanced.hasClass("disabled")) {
return;
}
var me = this;
var win;
if (me.api && !this._locked) {
var selectedElements = me.api.getSelectedElements();
if (selectedElements && selectedElements.length > 0) {
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].get_ObjectType();
elValue = selectedElements[i].get_ObjectValue();
if (c_oAscTypeSelectElement.Image == elType) {
var imgsizeMax = this.api.GetSectionInfo();
imgsizeMax = {
width: imgsizeMax.get_PageWidth() - (imgsizeMax.get_MarginLeft() + imgsizeMax.get_MarginRight()),
height: imgsizeMax.get_PageHeight() - (imgsizeMax.get_MarginTop() + imgsizeMax.get_MarginBottom())
};
(new DE.Views.ImageSettingsAdvanced({
imageProps: elValue,
sizeMax: imgsizeMax,
handler: function (result, value) {
if (result == "ok") {
if (me.api) {
me.api.ImgApply(value.imageProps);
}
}
me.fireEvent("editcomplete", me);
}
})).show();
break;
}
}
}
}
},
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 CImgProperty();
this.chartProps.changeType(rawData.type);
props.put_ChartProperties(this.chartProps);
this.api.ImgApply(props);
}
this.fireEvent("editcomplete", 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 CImgProperty();
this.chartProps.putStyle(rawData.data);
props.put_ChartProperties(this.chartProps);
this.api.ImgApply(props);
}
this.fireEvent("editcomplete", 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);
}
},
textSize: "Size",
textWrap: "Wrapping Style",
textWidth: "Width",
textHeight: "Height",
textAdvanced: "Show advanced settings",
txtInline: "Inline",
txtSquare: "Square",
txtTight: "Tight",
txtThrough: "Through",
txtTopAndBottom: "Top and bottom",
txtBehind: "Behind",
txtInFront: "In front",
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"
},
DE.Views.ChartSettings || {}));
});

View File

@@ -1,106 +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("DE.view.ChromeRecommendation", {
extend: "Ext.window.Window",
alias: "widget.dechromerecommendation",
requires: ["Ext.window.Window"],
modal: true,
closable: true,
resizable: false,
plain: true,
width: 375,
height: 185,
layout: {
type: "border"
},
onEsc: function () {
this.close();
},
initComponent: function () {
this.addEvents("onmodalresult");
this.items = [{
xtype: "container",
region: "center",
layout: {
type: "vbox",
align: "center"
},
items: [{
xtype: "box",
padding: "15px 0 0 0",
html: '<p style="width: 320px; text-align: center; font-size: 8pt; font-family: Arial; color: #636363; padding-top: 10px;">' + this.useChromeMessage + "</p>"
}]
},
{
xtype: "container",
region: "south",
height: 58,
style: "border-top: 1px solid #E5E5E5",
padding: "16px 0 0 0",
layout: {
type: "hbox",
align: "center",
pack: "center"
},
items: [{
xtype: "button",
cls: "asc-blue-button",
width: 85,
text: Ext.Msg.buttonText["ok"],
margin: "0 5px 0 0",
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 0);
this.close();
},
scope: this
}
},
{
xtype: "button",
cls: "asc-darkgray-button",
text: this.dontShowButtonText,
autoSize: true,
listeners: {
click: function (btn) {
this.fireEvent("onmodalresult", this, 1);
this.close();
},
scope: this
}
}]
}];
this.callParent(arguments);
},
dontShowButtonText: "Don't show again",
useChromeMessage: "We recommend that you use one of the latest versions of the Google Chrome web browser to speed up your work at documents."
});

View File

@@ -1,90 +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("DE.view.CreateFile", {
extend: "Ext.panel.Panel",
alias: "widget.decreatenew",
cls: "de-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",
emptyText: '<div class="empty-text">' + this.noTemplatesText + "</div>",
deferEmptyText: false,
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",
noTemplatesText: "There are no templates"
});

View File

@@ -1,227 +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("DE.view.DockablePanel", {
extend: "Ext.panel.Panel",
alias: "widget.dedockablepanel",
requires: ["DE.view.UndockedWindow"],
draggable: true,
tolerance: 5,
bodyPadding: "0 0 0 15px",
listeners: {
show: function (cmp) {
if (cmp.dockConfig && !cmp.dockConfig.isVisible) {
var size = cmp.getSize();
var header = cmp.ownerCt.getHeader().getSize();
cmp.dockConfig.isVisible = true;
cmp.dockConfig.size.height = size.height;
cmp.setHeight(size.height - header.height);
}
}
},
constructor: function (config) {
this.controls = [];
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
var me = this;
me.tools = [{
type: "pin",
qtip: this.textUndock,
handler: function () {
var pos = me.ownerCt.ownerCt.getPosition();
if (me.actionConfig) {
me.undock.apply(me, [me.actionConfig.undockPos[0], me.actionConfig.undockPos[1]]);
} else {
me.undock.apply(me, [pos[0] - 20, pos[1] + 10]);
}
},
scope: me
}];
me.addEvents("docked", "undocked");
me.callParent(arguments);
},
initDraggable: function () {
var me = this;
me.draggable = {
delegate: me.getHeader().getEl(),
tolerance: 100,
constrain: true,
constrainTo: document.body,
listeners: {
dragstart: function () {
me.startDragPos = me.getPosition(true);
},
dragend: function () {
var owner_pos = me.ownerCt.getPosition(),
pos = me.getPosition(true);
if (pos[0] < owner_pos[0] - 20) {
me.undock.apply(me, pos);
} else {
me.setPosition(me.startDragPos);
}
}
}
};
Ext.Component.prototype.initDraggable.call(me);
},
dock: function (suspend) {
var me = this,
ownerCt, size, win;
if (me.dockConfig) {
ownerCt = me.dockConfig.ownerCt;
win = me.dockConfig.win;
size = me.dockConfig.size;
win.remove(me, false);
me.getHeader().show();
me.setSize(size);
ownerCt.add(me);
win.destroy();
delete me.dockConfig;
if (!suspend) {
me.fireEvent("docked", me);
}
}
},
undock: function (x, y, suspend, ownerWidth) {
var me = this,
ownerCt = me.ownerCt,
ownerPos = (ownerCt) ? ownerCt.ownerCt.getPosition() : [0, 0],
size = me.getSize(),
bodySize = me.body.getSize(),
ctWidth = (ownerWidth > 0) ? ownerWidth : ownerCt.ownerCt.getWidth(),
win,
isVisible = me.isVisible();
if (me.dockConfig) {
return;
}
size.width = ctWidth;
bodySize.width = ctWidth;
ownerCt.remove(me, false);
me.getHeader().hide();
me.setPosition(0, 0);
if (isVisible) {
me.setSize(bodySize);
} else {
me.setWidth(ctWidth);
}
win = Ext.create("DE.view.UndockedWindow", {
items: me,
title: me.title,
tools: [{
type: "pin",
qtip: me.textRedock,
handler: function () {
me.dock();
}
}],
listeners: {
move: function (cmp, x, y) {
var xy = ownerCt.getPosition();
if (ownerCt.isVisible(true)) {
if ((xy[0] - x) <= me.tolerance) {
Ext.defer(me.dock, 10, me);
}
}
},
afterrender: function () {
win.dd.addListener("dragend", Ext.bind(function () {
var xy = win.getPosition();
me.actionConfig = {
undockPos: [xy[0], xy[1]]
};
me.fireEvent("changeposition", me);
},
this), this);
}
}
});
me.dockConfig = {
ownerCt: ownerCt,
win: win,
size: size,
isVisible: isVisible
};
win.show();
if (Ext.isNumber(x) && Ext.isNumber(y)) {
var pos = this.checkWindowPosition({
x: x,
y: y
},
{
width: win.getWidth(),
height: win.getHeight()
});
win.setPagePosition(pos.x, pos.y);
me.actionConfig = {
undockPos: [pos.x, pos.y]
};
}
ownerCt.doLayout();
if (!suspend) {
me.fireEvent("undocked", me, ownerPos, ctWidth);
}
},
isUndocked: function () {
return typeof this.dockConfig !== "undefined";
},
checkWindowPosition: function (position, size) {
var bodypos = Ext.getBody().getSize();
if (position.x > bodypos.width - 10) {
position.x = Math.max(bodypos.width - 10 - size.width, 0);
} else {
if (position.x < 0) {
position.x = 10;
}
}
if (position.y > bodypos.height - 10) {
position.y = Math.max(bodypos.height - 10 - size.height, 0);
} else {
if (position.y < 0) {
position.y = 10;
}
}
return position;
},
SuspendEvents: function () {
for (var i = 0; i < this.controls.length; i++) {
this.controls[i].suspendEvents(false);
}
},
ResumeEvents: function () {
for (var i = 0; i < this.controls.length; i++) {
this.controls[i].resumeEvents();
}
},
textRedock: "Redock to original panel"
});

View File

@@ -1,231 +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("DE.view.DockableTabPanel", {
extend: "Ext.panel.Panel",
alias: "widget.dedockabletabpanel",
requires: ["DE.view.UndockedWindow"],
draggable: true,
tolerance: 5,
layout: "card",
constructor: function (config) {
this.controls = [];
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
var me = this;
me.tools = [{
type: "pin",
qtip: this.textUndock,
handler: function () {
var pos = me.ownerCt.ownerCt.getPosition();
if (me.actionConfig) {
me.undock.apply(me, [me.actionConfig.undockPos[0], me.actionConfig.undockPos[1]]);
} else {
me.undock.apply(me, [pos[0] - 20, pos[1] + 10]);
}
},
scope: me
}];
me.addEvents("docked", "undocked");
me.callParent(arguments);
},
initDraggable: function () {
var me = this;
me.draggable = {
delegate: me.getHeader().getEl(),
tolerance: 100,
constrain: true,
constrainTo: document.body,
listeners: {
dragstart: function () {
me.startDragPos = me.getPosition(true);
},
dragend: function () {
var owner_pos = me.ownerCt.getPosition(),
pos = me.getPosition(true);
if (pos[0] < owner_pos[0] - 20) {
var calcSizeObj = me.getPanelSize.apply(me);
me.hide();
Ext.defer(me.undock, 5, me, [pos[0], pos[1], false, null, calcSizeObj]);
} else {
me.setPosition(me.startDragPos);
}
}
}
};
if (me.tabButtons) {
me.getHeader().insert(0, me.tabButtons);
}
Ext.Component.prototype.initDraggable.call(me);
},
dock: function (suspend) {
var me = this,
ownerCt, size, win;
if (me.dockConfig) {
ownerCt = me.dockConfig.ownerCt;
win = me.dockConfig.win;
size = me.dockConfig.size;
win.remove(me, false);
if (me.tabButtons) {
me.getHeader().insert(0, me.tabButtons);
}
me.getHeader().show();
me.setSize(size);
ownerCt.add(me);
win.hide();
delete me.dockConfig;
if (!suspend) {
me.fireEvent("docked", me);
}
}
},
getPanelSize: function () {
return {
size: this.getSize(),
bodySize: this.body.getSize(),
header: this.getHeader().getHeight()
};
},
undock: function (x, y, suspend, ownerWidth, calcSizeObj) {
var me = this,
ownerCt = me.ownerCt,
ownerPos = (ownerCt) ? ownerCt.ownerCt.getPosition() : [0, 0],
ctWidth = (ownerWidth > 0) ? ownerWidth : ownerCt.ownerCt.getWidth(),
size = (calcSizeObj) ? calcSizeObj.size : me.getSize(),
bodySize = (calcSizeObj) ? calcSizeObj.bodySize : me.body.getSize(),
header = (calcSizeObj) ? calcSizeObj.header : me.getHeader().getHeight();
if (me.dockConfig) {
return;
}
size.width = ctWidth;
bodySize.width = ctWidth;
ownerCt.remove(me, false);
me.show();
me.getHeader().hide();
me.setPosition(0, 0);
if (me.isVisible()) {
me.setSize(bodySize);
me.body.setSize(bodySize);
} else {
me.setWidth(ctWidth);
}
if (me.win === undefined) {
me.win = Ext.create("DE.view.UndockedWindow", {
items: me,
title: me.title,
tools: [{
type: "pin",
qtip: me.textRedock,
handler: function () {
me.dock();
}
}],
listeners: {
move: function (cmp, x, y) {
var xy = ownerCt.getPosition();
if (ownerCt.isVisible(true)) {
if ((xy[0] - x) <= me.tolerance) {
Ext.defer(me.dock, 10, me);
}
}
},
afterrender: function () {
me.win.dd.addListener("dragend", Ext.bind(function () {
var xy = me.win.getPosition();
me.actionConfig = {
undockPos: [xy[0], xy[1]]
};
me.fireEvent("changeposition", me);
},
this), this);
}
}
});
} else {
me.win.add(me);
}
if (me.tabButtons) {
me.win.getHeader().insert(0, me.tabButtons);
}
me.dockConfig = {
ownerCt: ownerCt,
win: me.win,
size: size,
headerHeight: header
};
me.win.show();
if (Ext.isNumber(x) && Ext.isNumber(y)) {
var pos = this.checkWindowPosition({
x: x,
y: y
},
{
width: me.win.getWidth(),
height: me.win.getHeight()
});
me.win.setPagePosition(pos.x, (pos.y + me.win.getHeight() > Ext.getBody().getSize().height) ? 0 : pos.y);
me.actionConfig = {
undockPos: [pos.x, pos.y]
};
}
ownerCt.doLayout();
me.doLayout();
if (!suspend) {
me.fireEvent("undocked", me, ownerPos, ctWidth);
}
},
isUndocked: function () {
return typeof this.dockConfig !== "undefined";
},
checkWindowPosition: function (position, size) {
var bodypos = Ext.getBody().getSize();
if (position.x > bodypos.width - 10) {
position.x = Math.max(bodypos.width - 10 - size.width, 0);
} else {
if (position.x < 0) {
position.x = 10;
}
}
if (position.y > bodypos.height - 10) {
position.y = Math.max(bodypos.height - 10 - size.height, 0);
} else {
if (position.y < 0) {
position.y = 10;
}
}
return position;
},
textRedock: "Redock to original panel",
textUndock: "Undock panel"
});

View File

@@ -1,294 +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("DE.model.ModelHelpMenu", {
extend: "Ext.data.Model",
fields: [{
type: "string",
name: "name"
},
{
type: "string",
name: "src"
},
{
type: "string",
name: "headername"
}]
});
Ext.define("DE.view.DocumentHelp", {
extend: "Ext.container.Container",
alias: "widget.dedocumenthelp",
cls: "de-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/SetPageParameters.htm",
name: "Set page parameters",
headername: "Usage Instructions"
},
{
src: "UsageInstructions/CopyPasteUndoRedo.htm",
name: "Copy/paste text passages, undo/redo your actions"
},
{
src: "UsageInstructions/NonprintingCharacters.htm",
name: "Show/hide nonprinting characters"
},
{
src: "UsageInstructions/AlignText.htm",
name: "Align your text in a line or paragraph"
},
{
src: "UsageInstructions/FormattingPresets.htm",
name: "Apply formatting presets"
},
{
src: "UsageInstructions/BackgroundColor.htm",
name: "Select background color for a paragraph"
},
{
src: "UsageInstructions/ParagraphIndents.htm",
name: "Change paragraph indents"
},
{
src: "UsageInstructions/LineSpacing.htm",
name: "Set paragraph line spacing"
},
{
src: "UsageInstructions/PageBreaks.htm",
name: "Insert page breaks"
},
{
src: "UsageInstructions/AddBorders.htm",
name: "Add Borders"
},
{
src: "UsageInstructions/FontTypeSizeColor.htm",
name: "Set font type, size, and color"
},
{
src: "UsageInstructions/DecorationStyles.htm",
name: "Apply font decoration styles"
},
{
src: "UsageInstructions/CopyClearFormatting.htm",
name: "Copy/clear text formatting"
},
{
src: "UsageInstructions/CreateLists.htm",
name: "Create lists"
},
{
src: "UsageInstructions/InsertTables.htm",
name: "Insert tables"
},
{
src: "UsageInstructions/InsertImages.htm",
name: "Insert images"
},
{
src: "UsageInstructions/AddHyperlinks.htm",
name: "Add hyperlinks"
},
{
src: "UsageInstructions/InsertHeadersFooters.htm",
name: "Insert headers and footers"
},
{
src: "UsageInstructions/InsertPageNumbers.htm",
name: "Insert page numbers"
},
{
src: "UsageInstructions/ViewDocInfo.htm",
name: "View document information"
},
{
src: "UsageInstructions/SavePrintDownload.htm",
name: "Save/print/download your document"
},
{
src: "UsageInstructions/OpenCreateNew.htm",
name: "Create a new document or open an existing one"
},
{
src: "HelpfulHints/About.htm",
name: "About ONLYOFFICE Document Editor",
headername: "Helpful Hints"
},
{
src: "HelpfulHints/SupportedFormats.htm",
name: "Supported Formats of Electronic Documents"
},
{
src: "HelpfulHints/Navigation.htm",
name: "Navigation through Your Document"
},
{
src: "HelpfulHints/Search.htm",
name: "Search Function"
},
{
src: "HelpfulHints/KeyboardShortcuts.htm",
name: "Keyboard Shortcuts"
}];
this.menuStore = Ext.create("Ext.data.Store", {
model: "DE.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,
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 + "/";
}
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,395 +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("DE.view.DocumentInfo", {
extend: "Ext.container.Container",
alias: "widget.dedocumentinfo",
cls: "de-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);
},
hide: function (cmp, eOpts) {
cmp.stopUpdatingStatisticInfo();
},
show: function (cmp, eOpts) {
cmp.updateStatisticInfo();
}
},
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"
});
this.lblStatPages = Ext.create("Ext.form.Label", {
text: "",
width: 150,
height: 14,
style: "text-align:left"
});
this.lblStatWords = Ext.create("Ext.form.Label", {
text: "",
width: 150,
height: 14,
style: "text-align:left"
});
this.lblStatParagraphs = Ext.create("Ext.form.Label", {
text: "",
width: 150,
height: 14,
style: "text-align:left"
});
this.lblStatSymbols = Ext.create("Ext.form.Label", {
text: "",
width: 150,
height: 14,
style: "text-align:left"
});
this.lblStatSpaces = Ext.create("Ext.form.Label", {
text: "",
width: 150,
height: 14,
style: "text-align:left"
});
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, {
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)
}
}), this.tbsRights = Ext.create("Ext.toolbar.Spacer", {
colspan: 2,
height: 5,
hideId: "element-to-hide"
}), {
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtStatistics,
style: "display: block;text-align: right;",
width: "100%"
},
{
xtype: "container",
width: "100%",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding: 0 20px 5px 0;vertical-align: top;"
}
},
items: [{
xtype: "label",
text: this.txtPages
},
this.lblStatPages, {
xtype: "label",
text: this.txtParagraphs
},
this.lblStatParagraphs, {
xtype: "label",
text: this.txtWords
},
this.lblStatWords, {
xtype: "label",
text: this.txtSymbols
},
this.lblStatSymbols, {
xtype: "label",
text: this.txtSpaces
},
this.lblStatSpaces]
}]
}];
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);
}
},
updateStatisticInfo: function () {
if (this.api && this.doc) {
this.api.startGetDocInfo();
}
},
stopUpdatingStatisticInfo: function () {
if (this.api) {
this.api.stopGetDocInfo();
}
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onGetDocInfoStart", Ext.bind(this._onGetDocInfoStart, this));
this.api.asc_registerCallback("asc_onGetDocInfoStop", Ext.bind(this._onGetDocInfoEnd, this));
this.api.asc_registerCallback("asc_onDocInfo", Ext.bind(this._onDocInfo, this));
this.api.asc_registerCallback("asc_onGetDocInfoEnd", Ext.bind(this._onGetDocInfoEnd, this));
return this;
},
loadConfig: function (data) {
this.sharingSettingsUrl = data.config.sharingSettingsUrl;
return this;
},
_onGetDocInfoStart: function () {
this.inProgress = true;
this.infoObj = {
PageCount: 0,
WordsCount: 0,
ParagraphCount: 0,
SymbolsCount: 0,
SymbolsWSCount: 0
};
Ext.defer(function () {
if (!this.inProgress) {
return;
}
this.lblStatPages.setText(this.txtLoading);
this.lblStatWords.setText(this.txtLoading);
this.lblStatParagraphs.setText(this.txtLoading);
this.lblStatSymbols.setText(this.txtLoading);
this.lblStatSpaces.setText(this.txtLoading);
},
2000, this);
},
_onDocInfo: function (obj) {
if (obj) {
if (obj.get_PageCount() > -1) {
this.infoObj.PageCount = obj.get_PageCount();
}
if (obj.get_WordsCount() > -1) {
this.infoObj.WordsCount = obj.get_WordsCount();
}
if (obj.get_ParagraphCount() > -1) {
this.infoObj.ParagraphCount = obj.get_ParagraphCount();
}
if (obj.get_SymbolsCount() > -1) {
this.infoObj.SymbolsCount = obj.get_SymbolsCount();
}
if (obj.get_SymbolsWSCount() > -1) {
this.infoObj.SymbolsWSCount = obj.get_SymbolsWSCount();
}
}
},
_onGetDocInfoEnd: function () {
this.inProgress = false;
this.lblStatPages.setText(this.infoObj.PageCount);
this.lblStatWords.setText(this.infoObj.WordsCount);
this.lblStatParagraphs.setText(this.infoObj.ParagraphCount);
this.lblStatSymbols.setText(this.infoObj.SymbolsCount);
this.lblStatSpaces.setText(this.infoObj.SymbolsWSCount);
},
_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",
txtStatistics: "Statistics",
txtPages: "Pages",
txtWords: "Words",
txtParagraphs: "Paragraphs",
txtSymbols: "Symbols",
txtSpaces: "Symbols with spaces",
txtLoading: "Loading...",
txtBtnAccessRights: "Change access rights"
});

View File

@@ -1,171 +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("DE.view.DocumentLanguage", {
extend: "Ext.window.Window",
alias: "widget.dedocumentlanguage",
requires: ["Ext.window.Window", "Ext.form.field.ComboBox", "Common.plugin.ComboBoxScrollPane", "Common.component.util.LanguageName"],
modal: true,
closable: true,
closeAction: "hide",
resizable: false,
preventHeader: true,
plain: true,
height: 114,
width: 350,
padding: "20px",
layout: "vbox",
layoutConfig: {
align: "stretch"
},
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
var _btnOk = Ext.create("Ext.Button", {
id: "langdialog-button-ok",
text: this.okButtonText,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
this._modalresult = 1;
this.fireEvent("onmodalresult", this._modalresult);
this.close();
},
scope: this
}
});
var _btnCancel = Ext.create("Ext.Button", {
id: "langdialog-button-cancel",
text: this.cancelButtonText,
width: 80,
cls: "asc-darkgray-button",
listeners: {
click: function () {
this._modalresult = 0;
this.fireEvent("onmodalresult", this._modalresult);
this.close();
},
scope: this
}
});
this.cmbLangs = Ext.create("Ext.form.field.ComboBox", {
store: this.langs,
mode: "local",
triggerAction: "all",
editable: false,
enableKeyEvents: true,
width: 310,
listConfig: {
maxHeight: 200
},
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this.langNum = records[0].index;
},
this),
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
_btnCancel.fireEvent("click");
}
}
}
},
plugins: [{
ptype: "comboboxscrollpane",
pluginId: "scrollpane",
settings: {
enableKeyboardNavigation: true
}
}]
});
this.addEvents("onmodalresult");
this.items = [{
xtype: "label",
text: this.textLang,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 3
},
this.cmbLangs, {
xtype: "tbspacer",
height: 3
},
{
xtype: "container",
width: 310,
layout: "hbox",
layoutConfig: {
align: "stretch"
},
items: [{
xtype: "tbspacer",
flex: 1
},
_btnOk, {
xtype: "tbspacer",
width: 5
},
_btnCancel]
}];
this.callParent(arguments);
},
setSettings: function (currentLang) {
this.langNum = undefined;
if (currentLang) {
var rec = this.cmbLangs.findRecord("field1", currentLang);
if (rec) {
this.cmbLangs.select(rec);
} else {
if (this.cmbLangs.picker && this.cmbLangs.picker.selModel) {
this.cmbLangs.picker.selModel.deselectAll();
this.cmbLangs.picker.selModel.lastSelected = null;
}
this.cmbLangs.setValue(Common.util.LanguageName.getLocalLanguageName(currentLang)[1]);
}
}
},
getSettings: function () {
return (this.langNum !== undefined) ? this.langs[this.langNum][0] : undefined;
},
textLang: "Select document language",
cancelButtonText: "Cancel",
okButtonText: "Ok"
});

View File

@@ -1,423 +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("DE.view.DocumentSettings", {
extend: "Ext.container.Container",
alias: "widget.dedocumentsettings",
cls: "de-documentsettings-body",
requires: ["Ext.button.Button", "Ext.container.Container", "Ext.form.Label", "Ext.form.field.Checkbox"],
listeners: {
show: function (cmp, eOpts) {
cmp.updateSettings();
}
},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
this._changedProps = {
zoomIdx: 5,
showchangesIdx: 1,
unitIdx: 0,
saveVal: 600
};
this._oldUnit = undefined;
this.chInputMode = Ext.create("Ext.form.field.Checkbox", {
id: "docsettings-input-mode",
boxLabel: this.strInputMode,
width: 500
});
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", {
id: "docsettings-combo-zoom",
width: 150,
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._arrShowChanges = [this.txtAll, this.txtLast];
this.cmbShowChanges = Ext.create("Ext.form.field.ComboBox", {
id: "docsettings-show-changes",
width: 150,
editable: false,
store: this._arrShowChanges,
mode: "local",
triggerAction: "all",
value: this._arrShowChanges[1],
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
this._changedProps.showchangesIdx = records[0].index;
combo.blur();
},
this)
}
});
this._arrFontRender = [this.txtWin, this.txtMac, 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],
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;"
}
},
items: [{
xtype: "label",
cellCls: "doc-info-label-cell",
text: this.txtInput,
style: "display: block;text-align: right; margin-bottom: 1px;",
width: "100%",
hideId: "element-edit-mode"
},
this.chInputMode, {
xtype: "tbspacer",
hideId: "element-edit-mode"
},
{
xtype: "tbspacer"
},
{
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.strShowChanges,
style: "display: block;text-align: right; margin-bottom: 5px;",
width: "100%",
hideId: "element-coauthoring"
},
this.cmbShowChanges, {
xtype: "tbspacer",
hideId: "element-coauthoring"
},
{
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;
return this;
},
applySettings: function () {
this.api.SetTextBoxInputMode(this.chInputMode.getValue());
this.api.SetCollaborativeMarksShowType((this._changedProps.showchangesIdx == 0) ? c_oAscCollaborativeMarksShowType.All : c_oAscCollaborativeMarksShowType.LastChanges);
switch (this._changedProps.fontrenderIdx) {
case 0:
this.api.SetFontRenderingMode(3);
break;
case 1:
this.api.SetFontRenderingMode(1);
break;
case 2:
this.api.SetFontRenderingMode(2);
break;
}
if (this.mode.canAutosave > -1) {
this.api.asc_setAutoSaveGap(this._changedProps.saveVal);
}
window.localStorage.setItem("de-settings-inputmode", this.chInputMode.getValue() ? 1 : 0);
window.localStorage.setItem("de-settings-zoom", this._arrZoom[this._changedProps.zoomIdx][0]);
window.localStorage.setItem("de-settings-livecomment", this.chLiveComment.getValue() ? 1 : 0);
window.localStorage.setItem("de-settings-showchanges", this._changedProps.showchangesIdx);
window.localStorage.setItem("de-settings-fontrender", this._changedProps.fontrenderIdx);
window.localStorage.setItem("de-settings-unit", this._arrUnit[this._changedProps.unitIdx][0]);
window.localStorage.setItem("de-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 () {
var value = window.localStorage.getItem("de-settings-inputmode");
this.chInputMode.setValue(value !== null && parseInt(value) == 1);
value = window.localStorage.getItem("de-settings-livecomment");
this.chLiveComment.setValue(!(value !== null && parseInt(value) == 0));
value = window.localStorage.getItem("de-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("de-settings-showchanges");
this._changedProps.showchangesIdx = (value !== null && parseInt(value) == 0) ? 0 : 1;
this.cmbShowChanges.setValue(this._arrShowChanges[this._changedProps.showchangesIdx]);
value = window.localStorage.getItem("de-settings-fontrender");
this._changedProps.fontrenderIdx = (value !== null) ? parseInt(value) : (window.devicePixelRatio > 1 ? 1 : 0);
this.cmbFontRender.setValue(this._arrFontRender[this._changedProps.fontrenderIdx]);
value = window.localStorage.getItem("de-settings-unit");
this._changedProps.unitIdx = 0;
if (value !== null) {
for (var 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("de-settings-autosave");
value = (value !== null) ? parseInt(value) : 600;
this._changedProps.saveVal = 600;
var idx = 3;
for (var 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-edit-mode", this.mode.isEdit);
this._ShowHideDocSettings("element-coauthoring", this.mode.canCoAuthoring && this.mode.isEdit);
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) {
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 option",
strInputMode: "Turn on hieroglyphs",
strZoom: "Default Zoom Value",
strShowChanges: "Realtime Collaboration Changes",
txtAll: "View All",
txtLast: "View Last",
okButtonText: "Apply",
txtInput: "Alternate Input",
txtLiveComment: "Live Commenting",
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,574 +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("DE.view.DocumentStatusInfo", {
extend: "Ext.container.Container",
alias: "widget.documentstatusinfo",
requires: ["Ext.form.field.Number", "Ext.button.Button", "Ext.form.Label", "Ext.toolbar.Spacer", "Ext.util.Cookies", "Ext.Img", "Common.component.LoadMask", "Common.component.util.LanguageName"],
uses: ["Ext.tip.ToolTip", "Ext.menu.Menu", "Common.view.Participants"],
layout: {
type: "hbox",
align: "middle"
},
config: {
caption: ""
},
cls: "de-documentstatusinfo",
height: 27,
disabled: true,
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
me._currLang = {
cls: ""
};
this.addEvents("editcomplete");
var txtPages = Ext.widget("label", {
id: "status-label-pages",
text: Ext.String.format(me.pageIndexText, 0, 0),
cls: "statusinfo-pages",
style: "cursor:pointer;margin:0 40px;",
listeners: {
afterrender: function (ct) {
ct.getEl().on("mousedown", onShowPageMenu, me);
}
}
});
var txtCaption = Ext.widget("label", {
id: "status-label-caption",
text: this.getCaption(),
cls: "statusinfo-caption",
height: 14
});
var 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; margin: 0 5px;",
listeners: {
afterrender: Ext.bind(function (ct) {
ct.getEl().on("mousedown", onShowZoomMenu, this);
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)
}
});
var btnFitToPage = Ext.widget("button", {
id: "status-button-fit-page",
cls: "asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-fittopage",
enableToggle: true,
listeners: {
toggle: function (btn, pressed) {
if (me.api) {
if (pressed) {
me.api.zoomFitToPage();
} else {
me.api.zoomCustomMode();
}
}
btnFitToWidth.toggle(false, true);
},
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipFitPage,
"data-qalign": "bl-tl?"
});
}
}
});
var btnFitToWidth = Ext.widget("button", {
id: "status-button-fit-width",
cls: "asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-fittowidth",
enableToggle: true,
style: "margin: 0 20px 0 5px;",
listeners: {
toggle: function (btn, pressed) {
if (me.api) {
if (pressed) {
me.api.zoomFitToWidth();
} else {
me.api.zoomCustomMode();
}
}
btnFitToPage.toggle(false, true);
},
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipFitWidth,
"data-qalign": "bl-tl?"
});
}
}
});
var 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-right:40px",
listeners: {
click: function () {
if (me.api) {
me.api.zoomIn();
}
me.fireEvent("editcomplete", me);
},
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipZoomIn + " (Ctrl++)",
"data-qalign": "bl-tl?"
});
}
}
});
var btnZoomOut = Ext.widget("button", {
id: "status-button-zoom-out",
cls: "asc-btn-zoom asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-zoomout",
listeners: {
click: function () {
if (me.api) {
me.api.zoomOut();
}
me.fireEvent("editcomplete", me);
},
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipZoomOut + " (Ctrl+-)",
"data-qalign": "bl-tl?"
});
}
}
});
this.fieldPageNumber = Ext.widget("numberfield", {
id: "status-field-page",
width: 40,
minValue: 1,
maxValue: 10000,
value: 1,
allowDecimals: false,
hideTrigger: true,
keyNavEnabled: false,
mouseWheelEnabled: false,
enableKeyEvents: true,
selectOnFocus: true,
listeners: {
specialkey: function (field, event, eOpts) {
if (event.getKey() == event.ENTER) {
if (me.api) {
var page = me.fieldPageNumber.getValue();
if (Ext.isNumber(page)) {
if (page > me.fieldPageNumber.maxValue) {
page = me.fieldPageNumber.maxValue;
}
if (page < me.fieldPageNumber.minValue) {
page = me.fieldPageNumber.minValue;
}
me.fieldPageNumber.setValue(page);
me.fieldPageNumber.selectText();
me.api.goToPage(page - 1);
}
}
}
}
}
});
this.userPanel = Ext.widget("statusinfoparticipants", {
userIconCls: "de-icon-statusinfo-users"
});
this.btnChangeLang = Ext.widget("button", {
id: "status-button-lang",
cls: "asc-statusbar-text-btn en",
iconCls: "asc-lang-flag",
text: "English (United States)",
menuAlign: "bl-tl?",
hideId : "element-edit-mode",
menu: {
items: [],
showSeparator: false,
maxHeight: 300,
listeners: {
beforeshow: function () {
if (me._currMenuLangId !== me._currLang.id) {
me.changeLanguageMenu(this);
me._currMenuLangId = me._currLang.id;
}
},
afterrender: function () {
this.showBy(this.el, me.btnChangeLang.menuAlign);
}
},
onShow: function () {
var self = this;
self.el.show();
self.callParent(arguments);
if (self.floating && self.constrain) {
var y = self.el.getY();
self.doConstrain();
var h = self.getHeight();
var maxHeight = Ext.Element.getViewportHeight();
if (y + h > maxHeight) {
y = maxHeight - h;
}
self.el.setY(y);
if (self.currentCheckedItem !== undefined) {
self.currentCheckedItem.getEl().scrollIntoView(self.layout.getRenderTarget());
}
}
}
},
listeners: {
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipSetLang,
"data-qalign": "bl-tl?"
});
}
}
});
var _OpenDocLangDlg = function () {
if (me.langDlg === undefined) {
me.langDlg = Ext.create("DE.view.DocumentLanguage", {
langs: me._docLangArr
});
me.langDlg.addListener("onmodalresult", Ext.bind(_OnOpenDocLangDlg, [me, me.langDlg]), false);
me.langDlg.addListener("close", Ext.bind(function (cnt, eOpts) {
me.fireEvent("editcomplete", me);
},
this));
}
me.langDlg.setSettings(me.api.asc_getDefaultLanguage());
me.langDlg.show();
};
var _OnOpenDocLangDlg = function (mr) {
if (mr == 1 && me.api) {
var lang = this[1].getSettings();
if (lang !== undefined) {
me.api.asc_setDefaultLanguage(lang);
}
}
};
var btnDocLang = Ext.widget("button", {
id: "status-button-doc-lang",
cls: "asc-statusbar-icon-btn",
iconCls: "asc-statusbar-btn btn-doc-lang",
style: "margin: 0 0 0 5px;",
hideId: "element-edit-mode",
listeners: {
click: _OpenDocLangDlg,
render: function (obj) {
obj.getEl().set({
"data-qtip": me.tipSetDocLang,
"data-qalign": "bl-tl?"
});
}
}
});
var onShowPageMenu = function () {
this.menuGoToPage.show();
this.menuGoToPage.showBy(txtPages, "bl-tl", [0, -10]);
};
var onShowZoomMenu = function () {
me.menuZoomTo.show();
me.menuZoomTo.showBy(txtZoom, "b-t", [0, -10]);
};
var onZoomChange = function (percent, type) {
btnFitToPage.toggle(type == 2, true);
btnFitToWidth.toggle(type == 1, true);
txtZoom.setText(Ext.String.format(me.zoomText, percent));
txtZoom.zf = percent;
me.doLayout();
};
var onCountPages = function (count) {
txtPages.setText(Ext.String.format(me.pageIndexText, me.api.getCurrentPage() + 1, count));
me.fieldPageNumber.setMinValue((count > 0) ? 1 : 0);
me.fieldPageNumber.setMaxValue(count);
};
var onCurrentPage = function (number) {
txtPages.setText(Ext.String.format(me.pageIndexText, number + 1, me.api.getCountPages()));
me.fieldPageNumber.setValue(number + 1);
};
var onTextLanguage = function (langid) {
if (me._currLang.id !== langid && langid !== null && langid !== undefined) {
var langnames = Common.util.LanguageName.getLocalLanguageName(langid);
me.btnChangeLang.getEl().removeCls(me._currLang.cls);
me._currLang.cls = langnames[0];
if (me._currLang.cls.indexOf("-") > -1) {
me._currLang.cls += " " + me._currLang.cls.split("-")[0];
}
me.btnChangeLang.getEl().addCls(me._currLang.cls);
me.btnChangeLang.setText(langnames[1]);
}
me._currLang.id = langid;
};
this.setApi = function (o) {
this.api = o;
if (this.api) {
this.api.asc_registerCallback("asc_onZoomChange", Ext.bind(onZoomChange, this));
this.api.asc_registerCallback("asc_onCountPages", Ext.bind(onCountPages, this));
this.api.asc_registerCallback("asc_onCurrentPage", Ext.bind(onCurrentPage, this));
this.api.asc_registerCallback("asc_onTextLanguage", Ext.bind(onTextLanguage, this));
this.userPanel.setApi(this.api);
}
return this;
};
this.items = [txtPages, me.userPanel, Ext.widget("label", {
text: "Powered by ONLYOFFICE",
cls: "statusinfo-pages",
style: "cursor:pointer;",
listeners: {
afterrender: function (cmp) {
cmp.el.addListener("click", function () {
var newDocumentPage = window.open("http://www.onlyoffice.com");
newDocumentPage && newDocumentPage.focus();
});
}
}
}), {
xtype: "container",
flex: 1,
layout: {
type: "hbox",
pack: "center"
},
style: "min-height: 1.1em;",
items: [txtCaption]
},
{
xtype: "tbseparator",
width: 2,
height: 27,
style: "padding-top:2px;margin-right:6px;",
hideId: "element-edit-mode",
html: '<div style="width: 100%; height: 100%; border-left: 1px solid rgba(0, 0, 0, 0.1); border-right: 1px solid rgba(255, 255, 255, 0.5);"></div>'
},
me.btnChangeLang, btnDocLang, {
xtype: "tbseparator",
width: 2,
height: 27,
style: "padding-top:2px;margin-left:6px;margin-right:20px;",
hideId: "element-edit-mode",
html: '<div style="width: 100%; height: 100%; border-left: 1px solid rgba(0, 0, 0, 0.1); border-right: 1px solid rgba(255, 255, 255, 0.5);"></div>'
},
btnFitToPage, btnFitToWidth, btnZoomOut, txtZoom, btnZoomIn];
me.callParent(arguments);
},
applyCaption: function (value) {
var c = Ext.get("status-label-caption");
if (c) {
Ext.DomHelper.overwrite(c, value);
}
this.doLayout();
return value;
},
changeLanguageMenu: function (menu) {
if (this._currLang.id === null || this._currLang.id === undefined) {
for (var i = 0; i < menu.items.length; i++) {
menu.items.items[i].setChecked(false);
}
menu.currentCheckedItem = undefined;
} else {
for (var i = 0; i < menu.items.length; i++) {
if (menu.items.items[i].langid === this._currLang.id) {
menu.currentCheckedItem = menu.items.items[i];
if (!menu.items.items[i].checked) {
menu.items.items[i].setChecked(true);
}
break;
} else {
if (menu.items.items[i].checked) {
menu.items.items[i].setChecked(false);
}
}
}
}
},
setLanguages: function (langs) {
var me = this,
arr = [];
me._docLangArr = [];
if (langs && langs.length > 0) {
Ext.each(langs, function (lang, index) {
var langnames = Common.util.LanguageName.getLocalLanguageName(lang.asc_getId());
me._docLangArr.push([lang.asc_getId(), langnames[1]]);
var mnu = Ext.widget("menucheckitem", {
text: langnames[1],
langid: lang.asc_getId(),
langname: langnames[0],
checked: false,
group: "popupstatuslang",
listeners: {
click: function (item, e, eOpt) {
if (me.api) {
if (item.langid !== undefined) {
me.api.put_TextPrLang(item.langid);
me._currLang.id = item.langid;
me._currMenuLangId = item.langid;
me.btnChangeLang.menu.currentCheckedItem = item;
me.btnChangeLang.setText(item.text);
me.btnChangeLang.getEl().removeCls(me._currLang.cls);
me._currLang.cls = item.langname;
if (me._currLang.cls.indexOf("-") > -1) {
me._currLang.cls += " " + me._currLang.cls.split("-")[0];
}
me.btnChangeLang.getEl().addCls(me._currLang.cls);
}
me.fireEvent("editcomplete", me);
}
}
}
});
arr.push(mnu);
});
me.btnChangeLang.menu.insert(0, arr);
if (me._currLang && (me._currLang.id !== undefined)) {
var langname = Common.util.LanguageName.getLocalLanguageName(me._currLang.id);
me.btnChangeLang.setText(langname[1]);
me.btnChangeLang.getEl().removeCls(me._currLang.cls);
me._currLang.cls = langname[0];
if (me._currLang.cls.indexOf("-") > -1) {
me._currLang.cls += " " + me._currLang.cls.split("-")[0];
}
me.btnChangeLang.getEl().addCls(me._currLang.cls);
}
}
},
createDelayedElements: function () {
var me = this;
var txtGoToPage = Ext.widget("label", {
id: "status-label-page",
text: me.goToPageText
});
var defaultPadding = 20;
var defaultContainerOffset = 7;
this.menuGoToPage = Ext.widget("menu", {
id: "status-menu-page",
autoHeight: true,
autoWidth: true,
plain: true,
items: [{
xtype: "container",
cls: "de-documentstatusinfo-menu-inner",
layout: {
type: "hbox",
align: "middle",
padding: defaultPadding / 2 + "px " + defaultPadding + "px"
},
items: [txtGoToPage, {
xtype: "tbspacer",
width: defaultContainerOffset
},
this.fieldPageNumber],
listeners: {
afterrender: function (ct) {
var textWidth = txtGoToPage.getWidth();
ct.getEl().setWidth(defaultContainerOffset + 2 * defaultPadding + textWidth + me.fieldPageNumber.getWidth());
}
}
}],
listeners: {
show: function (ct) {
me.fieldPageNumber.setValue(me.api.getCurrentPage() + 1);
me.fieldPageNumber.focus(true, 300);
}
}
});
this.menuZoomTo = Ext.widget("menu", {
plain: true,
bodyCls: "status-zoom-menu",
minWidth: 100,
listeners: {
hide: function () {
me.fireEvent("editcomplete", me);
},
click: function (menu, item) {
me.api.zoom(item.zf);
}
},
items: [{
text: "50%",
zf: 50
},
{
text: "75%",
zf: 75
},
{
text: "100%",
zf: 100
},
{
text: "125%",
zf: 125
},
{
text: "150%",
zf: 150
},
{
text: "175%",
zf: 175
},
{
text: "200%",
zf: 200
}]
});
},
_ShowHideStatusInfo: function (id, visible) {
var components = Ext.ComponentQuery.query('[hideId="' + id + '"]', this);
for (var i = 0; i < components.length; i++) {
components[i].setVisible(visible);
}
},
setMode: function (m) {
this.userPanel.setMode(m);
this._ShowHideStatusInfo("element-edit-mode", m.isEdit);
},
zoomText: "Zoom {0}%",
goToPageText: "Go to Page",
pageIndexText: "Page {0} of {1}",
tipFitPage: "Fit Page",
tipFitWidth: "Fit Width",
tipZoomIn: "Zoom In",
tipZoomOut: "Zoom Out",
tipZoomFactor: "Magnification",
tipHideLines: "Hide lines",
tipShowLines: "Show lines",
tipSetLang: "Set Text Language",
tipSetDocLang: "Set Document Language"
});

View File

@@ -1,428 +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("DE.view.File", {
extend: "Ext.panel.Panel",
alias: "widget.defile",
cls: "de-file-body",
layout: "card",
toolbarWidth: 260,
activeBtn: undefined,
requires: ["Ext.toolbar.Toolbar", "Ext.button.Button", "Ext.container.Container"],
uses: ["DE.view.DocumentInfo", "DE.view.DocumentHelp", "DE.view.DocumentSettings", "Common.view.About"],
listeners: {
afterrender: function (Component, eOpts) {
var cnt = this.ownerCt;
if (Ext.isDefined(cnt)) {
cnt.addListener("show", Ext.Function.bind(this._onShow, this));
cnt.addListener("hide", Ext.Function.bind(this._onHide, this));
}
}
},
initComponent: function () {
this.addEvents("editdocument");
this.callParent(arguments);
},
loadConfig: function (data) {
this.editorConfig = data.config;
},
loadDocument: function (data) {
this.document = data.doc;
},
_onShow: function () {
if (this.activeBtn === undefined) {
var btn = this[this.btnDomnloadAs.isVisible() ? "btnDomnloadAs" : "btnDocumentInfo"];
this.activeBtn = btn.toggle(true);
} else {
this.redrawButton(this.activeBtn);
}
if (this.activeBtn == this.btnDocumentInfo) {
this.getLayout().setActiveItem(this.cardDocumentInfo);
this.cardDocumentInfo.updateStatisticInfo();
} else {
if (this.activeBtn == this.btnDocumentSettings) {
this.getLayout().setActiveItem(this.cardDocumentSettings);
this.cardDocumentSettings.updateSettings();
}
}
},
_onHide: function () {
if (this.activeBtn == this.btnDocumentInfo) {
this.cardDocumentInfo.stopUpdatingStatisticInfo();
}
},
buildItems: function () {
var docInfo = [{
name: "PDF",
imgCls: "doc-format btn-pdf",
type: c_oAscFileType.PDF
},
{
name: "DOCX",
imgCls: "doc-format btn-docx",
type: c_oAscFileType.DOCX
}];
this.cardDownloadAs = Ext.widget("container", {
cls: "de-file-table",
layout: {
type: "table",
columns: 3
}
});
var me = this;
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",
listeners: {
click: Ext.bind(function (btn) {
var api = me.ownerCt.getApi();
if (api) {
api.asc_DownloadAs(btn.docType);
me.closeMenu();
}
Common.component.Analytics.trackEvent("Download As", item.name);
},
this)
}
}]
});
},
this);
this.cardDocumentInfo = Ext.widget("dedocumentinfo");
this.cardCreateNew = Ext.widget("decreatenew");
this.cardRecentFiles = Ext.widget("derecentfiles");
this.cardHelp = Ext.widget("dedocumenthelp");
this.cardDocumentSettings = Ext.widget("dedocumentsettings");
this.cardDocumentSettings.addListener("savedocsettings", Ext.bind(this.closeMenu, this));
return [this.cardDownloadAs, this.cardDocumentInfo, this.cardCreateNew, this.cardRecentFiles, this.cardHelp, this.cardDocumentSettings];
},
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.btnDomnloadAs = 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.btnSave.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", {
id: "file-button-createnew",
text: this.btnCreateNewCaption,
textAlign: "left",
enableToggle: true,
cls: "asc-filemenu-btn",
padding: "0 27px",
height: 27
});
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: "de-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.btnDomnloadAs, 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;
},
getSeparator: function () {
return {
xtype: "container",
html: '<hr class="de-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(function (btnCall) {
if (btnCall.pressed) {
if (this.activeBtn != btnCall) {
this.getLayout().setActiveItem(card);
this.activeBtn = btnCall;
}
Common.component.Analytics.trackEvent("File Menu", btnCall.label);
}
},
this),
toggle: Ext.Function.bind(function (btnCall) {
this.redrawButton(btnCall);
},
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();
},
applyMode: function () {
this.cardDocumentInfo.updateInfo(this.document);
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.btnDomnloadAs.setVisible(this.mode.canDownload);
this.hkSaveAs[this.mode.canDownload ? "enable" : "disable"]();
this.btnSave.setVisible(this.mode.isEdit);
this.btnToEdit.setVisible(this.mode.canEdit && this.mode.isEdit === false);
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 () {
this.hkSaveAs = new Ext.util.KeyMap(document, {
key: "s",
ctrl: true,
shift: true,
defaultEventAction: "stopEvent",
scope: this,
fn: function () {
if (this.ownerCt && this.ownerCt.isVisible()) {
this.btnDomnloadAs.toggle(true);
this.btnDomnloadAs.fireEvent("click", this.btnDomnloadAs);
}
}
});
this.hkHelp = new Ext.util.KeyMap(document, {
key: Ext.EventObject.F1,
ctrl: false,
shift: false,
defaultEventAction: "stopEvent",
scope: this,
fn: function () {
if (this.ownerCt && this.ownerCt.isVisible()) {
this.btnHelp.toggle(true);
this.btnHelp.fireEvent("click", this.btnHelp);
}
}
});
this.add(this.buildItems.call(this));
this.addDocked(this.buildDockedItems());
this.setConfig();
this.applyMode();
},
setConfig: function () {
var me = this;
if (this.editorConfig.templates && this.editorConfig.templates.length > 0) {
this.btnCreateNew.setText(this.btnCreateNew.getText() + "...");
this.btnCreateNew.enableToggle = true;
this.btnCreateNew.on("click", function (btnCall) {
if (btnCall.pressed) {
if (me.activeBtn != btnCall) {
me.getLayout().setActiveItem(me.cardCreateNew);
me.activeBtn = btnCall;
}
Common.component.Analytics.trackEvent("File Menu", "Create");
}
});
this.btnCreateNew.on("toggle", function (btnCall) {
me.redrawButton(btnCall);
});
} else {
this.btnCreateNew.on("click", function (btnCall) {
if (Ext.isEmpty(me.editorConfig.createUrl)) {
Ext.MessageBox.show({
title: me.textError,
msg: me.textCanNotCreateNewDoc,
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR,
width: 300
});
} else {
if (btnCall.pressed) {
var newDocumentPage = window.open(Ext.String.format("{0}?title={1}&action=create&doctype=text", me.editorConfig.createUrl, me.newDocumentTitle));
if (newDocumentPage) {
newDocumentPage.focus();
}
Common.component.Analytics.trackEvent("Create New", "Blank");
}
}
me.closeMenu();
});
}
this.cardHelp.setLangConfig(this.editorConfig.lang);
},
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",
newDocumentTitle: "Unnamed document",
textError: "Error",
textCanNotCreateNewDoc: "Can not create a new document. Address to create a document is not configured.",
btnSettingsCaption: "Advanced Settings..."
});

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!documenteditor/main/app/template/FileMenu.template", "underscore", "common/main/lib/component/BaseView"], function (tpl, _) {
DE.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(["documenteditor/main/app/view/FileMenuPanels"], function () {
me.panels = {
"saveas": (new DE.Views.FileMenuPanels.ViewSaveAs({
menu: me
})).render(),
"opts": (new DE.Views.FileMenuPanels.Settings({
menu: me
})).render(),
"info": (new DE.Views.FileMenuPanels.DocumentInfo({
menu: me
})).render(),
"help": (new DE.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) {
DE.getController("Toolbar").DisableToolbar(true);
}
this.api.asc_enableKeyEvents(false);
},
hide: function () {
this.$el.hide();
if (this.mode.isEdit) {
DE.getController("Toolbar").DisableToolbar(false);
}
this.fireEvent("filemenu:hide", [this]);
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.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 DE.Views.FileMenuPanels.CreateNew({
menu: this,
docs: this.mode.templates
})).render());
}
}
if (this.mode.canOpenRecent) {
if (this.mode.recent) {
this.panels["recent"] = (new DE.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;
this.panels["info"].setApi(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..."
},
DE.Views.FileMenu || {}));
});

View File

@@ -0,0 +1,813 @@
/*
* (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 () { ! DE.Views.FileMenuPanels && (DE.Views.FileMenuPanels = {});
DE.Views.FileMenuPanels.ViewSaveAs = Common.UI.BaseView.extend({
el: "#panel-saveas",
menu: undefined,
formats: [[{
name: "PDF",
imgCls: "pdf",
type: c_oAscFileType.PDF
},
{
name: "TXT",
imgCls: "txt",
type: c_oAscFileType.TXT
},
{
name: "DOCX",
imgCls: "docx",
type: c_oAscFileType.DOCX
}], [{
name: "ODT",
imgCls: "odt",
type: c_oAscFileType.ODT
},
{
name: "HTML (Zipped)",
imgCls: "html",
type: c_oAscFileType.HTML_ZIP
}]],
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]);
}
}
}
});
DE.Views.FileMenuPanels.Settings = Common.UI.BaseView.extend(_.extend({
el: "#panel-settings",
menu: undefined,
template: _.template(["<table><tbody>", '<tr class="edit">', '<td class="left"><label><%= scope.txtInput %></label></td>', '<td class="right"><div id="fms-chb-input-mode"/></td>', "</tr>", '<tr class="divider edit"></tr>', '<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="edit">', '<td class="left"><label><%= scope.txtSpellCheck %></label></td>', '<td class="right"><div id="fms-chb-spell-check"/></td>', "</tr>", '<tr class="divider edit"></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.textAlignGuides %></label></td>', '<td class="right"><span id="fms-chb-align-guides" /></td>', "</tr>", '<tr class="divider"></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 class="coauth">', '<td class="left"><label><%= scope.strShowChanges %></label></td>', '<td class="right"><span id="fms-cmb-show-changes" /></td>', "</tr>", '<tr class="divider coauth"></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.chInputMode = new Common.UI.CheckBox({
el: $("#fms-chb-input-mode"),
labelText: this.strInputMode
});
this.chLiveComment = new Common.UI.CheckBox({
el: $("#fms-chb-live-comment"),
labelText: this.strLiveComment
});
this.chSpell = new Common.UI.CheckBox({
el: $("#fms-chb-spell-check"),
labelText: this.strSpellCheckMode
});
this.chAutosave = new Common.UI.CheckBox({
el: $("#fms-chb-autosave"),
labelText: this.strAutosave
});
this.chAlignGuides = new Common.UI.CheckBox({
el: $("#fms-chb-align-guides"),
labelText: this.strAlignGuides
});
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.cmbShowChanges = new Common.UI.ComboBox({
el: $("#fms-cmb-show-changes"),
style: "width: 160px;",
editable: false,
cls: "input-group-nr",
data: [{
value: "none",
displayValue: this.txtNone
},
{
value: "all",
displayValue: this.txtAll
},
{
value: "last",
displayValue: this.txtLast
}]
});
this.cmbFontRender = new Common.UI.ComboBox({
el: $("#fms-cmb-font-render"),
style: "width: 160px;",
editable: false,
cls: "input-group-nr",
data: [{
value: 0,
displayValue: this.txtWin
},
{
value: 1,
displayValue: this.txtMac
},
{
value: 2,
displayValue: this.txtNative
}]
});
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.edit", this.el)[mode.isEdit ? "show" : "hide"]();
$("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("de-settings-inputmode");
this.chInputMode.setValue(value !== null && parseInt(value) == 1);
value = window.localStorage.getItem("de-settings-zoom");
var item = this.cmbZoom.store.findWhere({
value: parseInt(value)
});
this.cmbZoom.setValue(item ? parseInt(item.get("value")) : 100);
value = window.localStorage.getItem("de-settings-livecomment");
this.chLiveComment.setValue(!(value !== null && parseInt(value) == 0));
value = window.localStorage.getItem("de-settings-showchanges");
item = this.cmbShowChanges.store.findWhere({
value: value
});
this.cmbShowChanges.setValue(item ? item.get("value") : "last");
value = window.localStorage.getItem("de-settings-fontrender");
item = this.cmbFontRender.store.findWhere({
value: parseInt(value)
});
this.cmbFontRender.setValue(item ? item.get("value") : (window.devicePixelRatio > 1 ? 1 : 0));
value = window.localStorage.getItem("de-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("de-settings-autosave");
this.chAutosave.setValue(value === null || parseInt(value) == 1);
value = window.localStorage.getItem("de-settings-spellcheck");
this.chSpell.setValue(value === null || parseInt(value) == 1);
value = window.localStorage.getItem("de-settings-showsnaplines");
this.chAlignGuides.setValue(value === null || parseInt(value) == 1);
},
applySettings: function () {
window.localStorage.setItem("de-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0);
window.localStorage.setItem("de-settings-zoom", this.cmbZoom.getValue());
window.localStorage.setItem("de-settings-livecomment", this.chLiveComment.isChecked() ? 1 : 0);
window.localStorage.setItem("de-settings-showchanges", this.cmbShowChanges.getValue());
window.localStorage.setItem("de-settings-fontrender", this.cmbFontRender.getValue());
window.localStorage.setItem("de-settings-unit", this.cmbUnit.getValue());
window.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
window.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
window.localStorage.setItem("de-settings-showsnaplines", this.chAlignGuides.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",
strInputMode: "Turn on hieroglyphs",
strZoom: "Default Zoom Value",
strShowChanges: "Realtime Collaboration Changes",
txtAll: "View All",
txtNone: "View Nothing",
txtLast: "View Last",
txtLiveComment: "Live Commenting",
okButtonText: "Apply",
txtInput: "Alternate Input",
txtWin: "as Windows",
txtMac: "as OS X",
txtNative: "Native",
strFontRender: "Font Hinting",
strUnit: "Unit of Measurement",
txtCm: "Centimeter",
txtPt: "Point",
textAutoSave: "Autosave",
strAutosave: "Turn on autosave",
txtSpellCheck: "Spell Checking",
strSpellCheckMode: "Turn on spell checking option",
textAlignGuides: "Alignment Guides",
strAlignGuides: "Turn on alignment guides"
},
DE.Views.FileMenuPanels.Settings || {}));
DE.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")]);
}
}
});
DE.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 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",
noTemplatesText: "There are no templates"
},
DE.Views.FileMenuPanels.CreateNew || {}));
DE.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>", '<tr class="divider rights"></tr>', "<tr>", '<td class="left" style="vertical-align: top;"><label>' + this.txtStatistics + "</label></td>", '<td class="right" style="vertical-align: top;"><div id="id-info-statistic">', "<table>", "<tr>", "<td><label>" + this.txtPages + "</label></td>", '<td><label id="id-info-pages"></label></td>', "</tr>", "<tr>", "<td><label>" + this.txtParagraphs + "</label></td>", '<td><label id="id-info-paragraphs"></label></td>', "</tr>", "<tr>", "<td><label>" + this.txtWords + "</label></td>", '<td><label id="id-info-words"></label></td>', "</tr>", "<tr>", "<td><label>" + this.txtSymbols + "</label></td>", '<td><label id="id-info-symbols"></label></td>', "</tr>", "<tr>", "<td><label>" + this.txtSpaces + "</label></td>", '<td><label id="id-info-spaces"></label></td>', "</tr>", "</table>", "</div></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.infoObj = {
PageCount: 0,
WordsCount: 0,
ParagraphCount: 0,
SymbolsCount: 0,
SymbolsWSCount: 0
};
this.inProgress = false;
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.lblStatPages = $("#id-info-pages");
this.lblStatWords = $("#id-info-words");
this.lblStatParagraphs = $("#id-info-paragraphs");
this.lblStatSymbols = $("#id-info-symbols");
this.lblStatSpaces = $("#id-info-spaces");
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);
this.updateStatisticInfo();
},
hide: function () {
Common.UI.BaseView.prototype.hide.call(this, arguments);
this.stopUpdatingStatisticInfo();
},
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);
},
updateStatisticInfo: function () {
if (this.api && this.doc) {
this.api.startGetDocInfo();
}
},
stopUpdatingStatisticInfo: function () {
if (this.api) {
this.api.stopGetDocInfo();
}
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onGetDocInfoStart", _.bind(this._onGetDocInfoStart, this));
this.api.asc_registerCallback("asc_onGetDocInfoStop", _.bind(this._onGetDocInfoEnd, this));
this.api.asc_registerCallback("asc_onDocInfo", _.bind(this._onDocInfo, this));
this.api.asc_registerCallback("asc_onGetDocInfoEnd", _.bind(this._onGetDocInfoEnd, this));
return this;
},
setMode: function (mode) {
this.sharingSettingsUrl = mode.sharingSettingsUrl;
return this;
},
_onGetDocInfoStart: function () {
var me = this;
this.inProgress = true;
this.infoObj = {
PageCount: 0,
WordsCount: 0,
ParagraphCount: 0,
SymbolsCount: 0,
SymbolsWSCount: 0
};
_.defer(function () {
if (!me.inProgress) {
return;
}
me.lblStatPages.text(me.txtLoading);
me.lblStatWords.text(me.txtLoading);
me.lblStatParagraphs.text(me.txtLoading);
me.lblStatSymbols.text(me.txtLoading);
me.lblStatSpaces.text(me.txtLoading);
},
2000);
},
_onDocInfo: function (obj) {
if (obj) {
if (obj.get_PageCount() > -1) {
this.infoObj.PageCount = obj.get_PageCount();
}
if (obj.get_WordsCount() > -1) {
this.infoObj.WordsCount = obj.get_WordsCount();
}
if (obj.get_ParagraphCount() > -1) {
this.infoObj.ParagraphCount = obj.get_ParagraphCount();
}
if (obj.get_SymbolsCount() > -1) {
this.infoObj.SymbolsCount = obj.get_SymbolsCount();
}
if (obj.get_SymbolsWSCount() > -1) {
this.infoObj.SymbolsWSCount = obj.get_SymbolsWSCount();
}
}
},
_onGetDocInfoEnd: function () {
this.inProgress = false;
this.lblStatPages.text(this.infoObj.PageCount);
this.lblStatWords.text(this.infoObj.WordsCount);
this.lblStatParagraphs.text(this.infoObj.ParagraphCount);
this.lblStatSymbols.text(this.infoObj.SymbolsCount);
this.lblStatSpaces.text(this.infoObj.SymbolsWSCount);
},
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",
txtStatistics: "Statistics",
txtPages: "Pages",
txtWords: "Words",
txtParagraphs: "Paragraphs",
txtSymbols: "Symbols",
txtSpaces: "Symbols with spaces",
txtLoading: "Loading...",
txtBtnAccessRights: "Change access rights"
},
DE.Views.FileMenuPanels.DocumentInfo || {}));
DE.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/SetPageParameters.htm",
name: "Set page parameters",
headername: "Usage Instructions",
selected: true
},
{
src: "UsageInstructions/CopyPasteUndoRedo.htm",
name: "Copy/paste text passages, undo/redo your actions"
},
{
src: "UsageInstructions/NonprintingCharacters.htm",
name: "Show/hide nonprinting characters"
},
{
src: "UsageInstructions/AlignText.htm",
name: "Align your text in a line or paragraph"
},
{
src: "UsageInstructions/FormattingPresets.htm",
name: "Apply formatting presets"
},
{
src: "UsageInstructions/BackgroundColor.htm",
name: "Select background color for a paragraph"
},
{
src: "UsageInstructions/ParagraphIndents.htm",
name: "Change paragraph indents"
},
{
src: "UsageInstructions/LineSpacing.htm",
name: "Set paragraph line spacing"
},
{
src: "UsageInstructions/PageBreaks.htm",
name: "Insert page breaks"
},
{
src: "UsageInstructions/AddBorders.htm",
name: "Add Borders"
},
{
src: "UsageInstructions/FontTypeSizeColor.htm",
name: "Set font type, size, and color"
},
{
src: "UsageInstructions/DecorationStyles.htm",
name: "Apply font decoration styles"
},
{
src: "UsageInstructions/CopyClearFormatting.htm",
name: "Copy/clear text formatting"
},
{
src: "UsageInstructions/CreateLists.htm",
name: "Create lists"
},
{
src: "UsageInstructions/InsertTables.htm",
name: "Insert tables"
},
{
src: "UsageInstructions/InsertImages.htm",
name: "Insert images"
},
{
src: "UsageInstructions/AddHyperlinks.htm",
name: "Add hyperlinks"
},
{
src: "UsageInstructions/InsertHeadersFooters.htm",
name: "Insert headers and footers"
},
{
src: "UsageInstructions/InsertPageNumbers.htm",
name: "Insert page numbers"
},
{
src: "UsageInstructions/ViewDocInfo.htm",
name: "View document information"
},
{
src: "UsageInstructions/SavePrintDownload.htm",
name: "Save/print/download your document"
},
{
src: "UsageInstructions/OpenCreateNew.htm",
name: "Create a new document or open an existing one"
},
{
src: "HelpfulHints/About.htm",
name: "About ONLYOFFICE Document Editor",
headername: "Helpful Hints"
},
{
src: "HelpfulHints/SupportedFormats.htm",
name: "Supported Formats of Electronic Documents"
},
{
src: "HelpfulHints/Navigation.htm",
name: "Navigation through Your Document"
},
{
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 () {
var me = this;
$(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", function (dataview, itemview, record) {
if (record.has("headername")) {
$(itemview.el).before('<div class="header-name">' + record.get("headername") + "</div>");
}
});
this.viewHelpPicker.on("item:select", function (dataview, itemview, record) {
me.itemclicked = true;
me.iFrame.src = me.urlPref + record.get("src");
});
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);
Common.Gateway.on("internalcommand", function (data) {
if (data.type == "help:hyperlink") {
if (!me.itemclicked) {
var src = data.data;
var rec = me.viewHelpPicker.store.find(function (record) {
return (src.indexOf(record.get("src")) > 0);
});
if (rec) {
me.viewHelpPicker.selectRecord(rec, true);
me.viewHelpPicker.scrollToRecord(rec);
}
}
me.itemclicked = false;
}
});
$("#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,312 +1,221 @@
/*
* (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("DE.view.HeaderFooterSettings", {
extend: "Common.view.AbstractSettingsPanel",
alias: "widget.deheaderfootersettings",
height: 298,
requires: ["Ext.button.Button", "Ext.form.Label", "Ext.form.field.Checkbox", "Ext.container.Container", "Ext.toolbar.Spacer", "Common.component.MetricSpinner"],
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
this.title = this.txtTitle;
this._initSettings = true;
this._state = {
PositionType: c_pageNumPosition.PAGE_NUM_POSITION_TOP,
Position: 12.5,
DiffFirst: false,
DiffOdd: false
};
var _arrPosition = [[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, "asc-right-panel-btn btn-colontitul-tl", "headerfooter-button-top-left", this.textTopLeft], [c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, "asc-right-panel-btn btn-colontitul-tc", "headerfooter-button-top-center", this.textTopCenter], [c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, "asc-right-panel-btn btn-colontitul-tr", "headerfooter-button-top-right", this.textTopRight], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, "asc-right-panel-btn btn-colontitul-bl", "headerfooter-button-bottom-left", this.textBottomLeft], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, "asc-right-panel-btn btn-colontitul-bc", "headerfooter-button-bottom-center", this.textBottomCenter], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, "asc-right-panel-btn btn-colontitul-br", "headerfooter-button-bottom-right", this.textBottomRight]];
this._btnsPosition = [];
Ext.Array.forEach(_arrPosition, function (item) {
var _btn = Ext.create("Ext.Button", {
id: item[3],
cls: item[2],
posWhere: item[0],
posAlign: item[1],
margin: "2px 12px 2px 0",
text: "",
tooltip: item[4],
listeners: {
click: Ext.bind(function (btn) {
if (this.api) {
this.api.put_PageNum(btn.posWhere, btn.posAlign);
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this._btnsPosition.push(_btn);
},
this);
this._numPosition = Ext.create("Common.component.MetricSpinner", {
id: "headerfooter-spin-position",
readOnly: false,
step: 0.1,
width: 85,
defaultUnit: "cm",
value: "1.25 cm",
maxValue: 55.88,
minValue: 0,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.put_HeadersAndFootersDistance(Common.MetricSettings.fnRecalcToMM(field.getNumberValue()));
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this._numPosition);
this._lblPosition = Ext.create("Ext.form.Label", {
text: this.textHeaderFromTop,
width: 150,
height: 14,
style: "text-align:left"
});
this._chDiffFirst = Ext.create("Ext.form.field.Checkbox", {
id: "headerfooter-check-diff-first",
boxLabel: this.textDiffFirst,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.HeadersAndFooters_DifferentFirstPage(field.getValue());
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this._chDiffFirst);
this._chDiffOdd = Ext.create("Ext.form.field.Checkbox", {
id: "headerfooter-check-diff-odd",
boxLabel: this.textDiffOdd,
listeners: {
change: Ext.bind(function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.HeadersAndFooters_DifferentOddandEvenPage(field.getValue());
}
this.fireEvent("editcomplete", this);
},
this)
}
});
this.controls.push(this._chDiffOdd);
this._PageNumPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 103,
width: "100%",
items: [{
xtype: "tbspacer",
height: 9
},
{
xtype: "container",
layout: {
type: "table",
columns: 3
},
items: [this._btnsPosition[0], this._btnsPosition[1], this._btnsPosition[2], {
xtype: "tbspacer",
height: 11
},
{
xtype: "tbspacer",
height: 11
},
{
xtype: "tbspacer",
height: 11
},
this._btnsPosition[3], this._btnsPosition[4], this._btnsPosition[5]]
}]
});
this._PositionPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 50,
width: 195,
items: [{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
height: 40,
layout: "vbox",
layoutConfig: {
align: "stretch"
},
style: "float:left;",
items: [this._lblPosition, {
xtype: "tbspacer",
height: 3
},
this._numPosition]
}]
});
this._OptionsPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 53,
width: "100%",
items: [{
xtype: "tbspacer",
height: 6
},
this._chDiffFirst, this._chDiffOdd]
});
this.items = [{
xtype: "tbspacer",
height: 9
},
{
xtype: "label",
style: "font-weight: bold;margin-top: 1px;",
text: this.textPageNum
},
this._PageNumPanel, {
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.textPosition
},
this._PositionPanel, {
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.textOptions
},
this._OptionsPanel, {
xtype: "tbspacer",
height: 7
}];
this.callParent(arguments);
},
setApi: function (api) {
this.api = api;
},
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.01 : 1);
}
}
},
ChangeSettings: function (prop) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
if (prop) {
this.SuspendEvents();
var value = prop.get_Type();
if (this._state.PositionType !== value) {
if (value == c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM) {
this._lblPosition.setText(this.textHeaderFromBottom);
} else {
this._lblPosition.setText(this.textHeaderFromTop);
}
this._state.PositionType = value;
}
value = prop.get_Position();
if (Math.abs(this._state.Position - value) > 0.001) {
this._numPosition.setValue(Common.MetricSettings.fnRecalcFromMM(value));
this._state.Position = value;
}
value = prop.get_DifferentFirst();
if (this._state.DiffFirst !== value) {
this._chDiffFirst.setValue(value);
this._state.DiffFirst = value;
}
value = prop.get_DifferentEvenOdd();
if (this._state.DiffOdd !== value) {
this._chDiffOdd.setValue(value);
this._state.DiffOdd = value;
}
this.ResumeEvents();
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
textHeaderFromTop: "Header from Top",
textHeaderFromBottom: "Header from Bottom",
textPosition: "Position",
textOptions: "Options",
textDiffFirst: "Different First Page",
textDiffOdd: "Different Odd and even Pages",
textPageNum: "Insert Page Number",
textTopLeft: "Top Left",
textTopRight: "Top Right",
textTopCenter: "Top Center",
textBottomLeft: "Bottom Left",
textBottomRight: "Bottom Right",
textBottomCenter: "Bottom Center",
textUndock: "Undock from panel",
txtTitle: "Header and Footer"
/*
* (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!documenteditor/main/app/template/HeaderFooterSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/component/MetricSpinner", "common/main/lib/component/CheckBox"], function (menuTemplate, $, _, Backbone) {
DE.Views.HeaderFooterSettings = Backbone.View.extend(_.extend({
el: "#id-header-settings",
template: _.template(menuTemplate),
events: {},
options: {
alias: "HeaderFooterSettings"
},
initialize: function () {
var me = this;
this._initSettings = true;
this._state = {
PositionType: c_pageNumPosition.PAGE_NUM_POSITION_TOP,
Position: 12.5,
DiffFirst: false,
DiffOdd: false,
SameAs: false,
DisabledControls: false
};
this.spinners = [];
this.lockedControls = [];
this._locked = false;
this.render();
var _arrPosition = [[c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, "icon-right-panel btn-colontitul-tl", "headerfooter-button-top-left", this.textTopLeft], [c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, "icon-right-panel btn-colontitul-tc", "headerfooter-button-top-center", this.textTopCenter], [c_pageNumPosition.PAGE_NUM_POSITION_TOP, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, "icon-right-panel btn-colontitul-tr", "headerfooter-button-top-right", this.textTopRight], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_LEFT, "icon-right-panel btn-colontitul-bl", "headerfooter-button-bottom-left", this.textBottomLeft], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_CENTER, "icon-right-panel btn-colontitul-bc", "headerfooter-button-bottom-center", this.textBottomCenter], [c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM, c_pageNumPosition.PAGE_NUM_POSITION_RIGHT, "icon-right-panel btn-colontitul-br", "headerfooter-button-bottom-right", this.textBottomRight]];
this._btnsPosition = [];
_.each(_arrPosition, function (item, index, list) {
var _btn = new Common.UI.Button({
cls: "btn-options huge",
iconCls: item[2],
posWhere: item[0],
posAlign: item[1],
hint: item[4]
});
_btn.render($("#" + item[3]));
_btn.on("click", _.bind(this.onBtnPositionClick, this));
this._btnsPosition.push(_btn);
this.lockedControls.push(_btn);
},
this);
this.numPosition = new Common.UI.MetricSpinner({
el: $("#headerfooter-spin-position"),
step: 0.1,
width: 85,
value: "1.25 cm",
defaultUnit: "cm",
maxValue: 55.88,
minValue: 0
});
this.spinners.push(this.numPosition);
this.lockedControls.push(this.numPosition);
this.lblPosition = $(this.el).find("#headerfooter-label-position");
this.chDiffFirst = new Common.UI.CheckBox({
el: $("#headerfooter-check-diff-first"),
labelText: this.textDiffFirst
});
this.lockedControls.push(this.chDiffFirst);
this.chDiffOdd = new Common.UI.CheckBox({
el: $("#headerfooter-check-diff-odd"),
labelText: this.textDiffOdd
});
this.lockedControls.push(this.chDiffOdd);
this.chSameAs = new Common.UI.CheckBox({
el: $("#headerfooter-check-same-as"),
labelText: this.textSameAs
});
this.lockedControls.push(this.chSameAs);
this.numPosition.on("change", _.bind(this.onNumPositionChange, this));
this.chDiffFirst.on("change", _.bind(this.onDiffFirstChange, this));
this.chDiffOdd.on("change", _.bind(this.onDiffOddChange, this));
this.chSameAs.on("change", _.bind(this.onSameAsChange, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
},
setApi: function (api) {
this.api = api;
return this;
},
ChangeSettings: function (prop) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
this.disableControls(this._locked);
if (prop) {
var value = prop.get_Type();
if (this._state.PositionType !== value) {
if (value == c_pageNumPosition.PAGE_NUM_POSITION_BOTTOM) {
this.lblPosition[0].innerHTML = this.textHeaderFromBottom;
} else {
this.lblPosition[0].innerHTML = this.textHeaderFromTop;
}
this._state.PositionType = value;
}
value = prop.get_Position();
if (Math.abs(this._state.Position - value) > 0.001) {
this.numPosition.setValue(Common.Utils.Metric.fnRecalcFromMM(value), true);
this._state.Position = value;
}
value = prop.get_DifferentFirst();
if (this._state.DiffFirst !== value) {
this.chDiffFirst.setValue(value, true);
this._state.DiffFirst = value;
}
value = prop.get_DifferentEvenOdd();
if (this._state.DiffOdd !== value) {
this.chDiffOdd.setValue(value, true);
this._state.DiffOdd = value;
}
value = prop.get_LinkToPrevious();
if (this._state.SameAs !== value) {
this.chSameAs.setDisabled(value === null);
this.chSameAs.setValue(value == true, true);
this._state.SameAs = value;
}
}
},
onBtnPositionClick: function (btn, eOpts) {
if (this.api) {
this.api.put_PageNum(btn.options.posWhere, btn.options.posAlign);
}
this.fireEvent("editcomplete", this);
},
onNumPositionChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.put_HeadersAndFootersDistance(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
}
this.fireEvent("editcomplete", this);
},
onDiffFirstChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.HeadersAndFooters_DifferentFirstPage(field.getValue() == "checked");
}
this.fireEvent("editcomplete", this);
},
onDiffOddChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.HeadersAndFooters_DifferentOddandEvenPage((field.getValue() == "checked"));
}
this.fireEvent("editcomplete", this);
},
onSameAsChange: function (field, newValue, oldValue, eOpts) {
if (this.api) {
this.api.HeadersAndFooters_LinkToPrevious((field.getValue() == "checked"));
}
this.fireEvent("editcomplete", 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.01 : 1);
}
}
},
createDelayedElements: function () {
this.updateMetricUnit();
},
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);
});
}
},
textHeaderFromTop: "Header from Top",
textHeaderFromBottom: "Header from Bottom",
textPosition: "Position",
textOptions: "Options",
textDiffFirst: "Different first page",
textDiffOdd: "Different odd and even pages",
textPageNum: "Insert Page Number",
textTopLeft: "Top Left",
textTopRight: "Top Right",
textTopCenter: "Top Center",
textBottomLeft: "Bottom Left",
textBottomRight: "Bottom Right",
textBottomCenter: "Bottom Center",
textSameAs: "Link to Previous"
},
DE.Views.HeaderFooterSettings || {}));
});

View File

@@ -1,396 +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("DE.view.TreeHeaderModel", {
extend: "Ext.data.Model",
fields: [{
name: "text",
type: "string"
},
{
name: "url",
type: "string"
},
{
name: "expanded",
type: "boolean",
defaultValue: false
},
{
name: "leaf",
type: "boolean",
defaultValue: false
}],
hasMany: {
model: "DE.view.TreeHeaderModel",
name: "headers"
}
});
Ext.define("DE.view.TreeHeaderModel2", {
extend: "Ext.data.Model",
fields: [{
name: "headerText",
type: "string"
},
{
name: "headerLevel",
type: "int",
defaultValue: 0
},
{
name: "headerId",
type: "int",
defaultValue: 0
},
{
name: "treeLevel",
type: "int",
defaultValue: 0
},
{
name: "expanded",
type: "boolean",
defaultValue: false
},
{
name: "leaf",
type: "boolean",
defaultValue: false
}],
hasMany: {
model: "DE.view.TreeHeaderModel2",
name: "headers"
}
});
Ext.define("DE.view.HeadersList", {
extend: "Ext.panel.Panel",
alias: "widget.deheaderslist",
cls: "de-headerslist",
bodyCls: "de-headerslist-body",
requires: ["Ext.tree.Panel", "Ext.data.TreeStore"],
layoutConfig: {
type: "vbox",
align: "stretch"
},
constructor: function (config) {
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var data = {
text: "MainHeader",
headers: [{
text: "Header 1",
url: "some url",
expanded: false,
headers: [{
text: "Header 2",
leaf: true
},
{
text: "Header 3",
expanded: false,
headers: [{
text: "Header 4",
leaf: true
}]
}]
},
{
text: "Header 5",
url: "some url",
leaf: true
},
{
text: "Header 6",
url: "some url",
expanded: false,
headers: [{
text: "Header 7",
leaf: true
},
{
text: "Header 8",
expanded: false,
headers: [{
text: "Very Very Very Very Long Header 3",
leaf: true
}]
}]
}]
};
var data2 = {
headerText: "MainHeader",
headerLevel: 0,
headers: [{
headerText: "Header 1",
headerLevel: 0,
expanded: false,
headers: [{
headerText: "Header 2",
headerLevel: 0,
leaf: true
},
{
headerText: "Header 3",
headerLevel: 0,
expanded: false,
headers: [{
headerText: "Header 4",
headerLevel: 0,
leaf: true
}]
}]
},
{
headerText: "Header 5",
headerLevel: 0,
leaf: true
},
{
headerText: "Header 6",
headerLevel: 0,
expanded: false,
headers: [{
headerText: "Header 7",
headerLevel: 0,
leaf: true
},
{
headerText: "Header 8",
headerLevel: 0,
expanded: false,
headers: [{
headerText: "Very Very Very Very Long Header 3",
headerLevel: 0,
leaf: true
}]
}]
}]
};
this._treestore = Ext.create("Ext.data.TreeStore", {
model: "DE.view.TreeHeaderModel2",
proxy: {
type: "memory",
reader: {
type: "json",
root: "headers"
}
}
});
this.headerListPanel = Ext.create("Ext.tree.Panel", {
preventHeader: true,
store: this._treestore,
rootVisible: false,
frame: false,
layout: "fit",
flex: 1,
emptyText: "",
cls: "x-headerslist-panel-context",
lines: false,
columns: [{
xtype: "treecolumn",
flex: 1,
dataIndex: "headerText",
renderer: function (value, metaData, record, rowIdx, colIdx, store, view) {
var _value = value || record.data.headerText;
var str = Ext.String.format('<span class="caption-inner">{0}</span><span class="caption-right-border"></span><span class="caption-right-border-padding"></span>', _value);
return str;
}
}],
hideHeaders: true,
viewConfig: {
autoScroll: true,
store: this._treestore,
singleSelect: true,
hideHeaders: true,
rootVisible: false,
listeners: {
itemupdate: function (record, index, node, eOpts) {
if (record.data.headerLevel - record.data.treeLevel > 0) {
var btn = node.querySelector("div.x-grid-cell-inner");
if (btn) {
for (var i = 0; i < (record.data.headerLevel - record.data.treeLevel); i++) {
Ext.DomHelper.insertFirst(btn, {
tag: "span",
cls: "caption-add-left-padding"
});
}
}
}
},
itemadd: function (records, index, nodes, eOpts) {
for (var j = 0; j < records.length; j++) {
if (records[j].data.headerLevel - records[j].data.treeLevel > 0) {
var btn = nodes[j].querySelector("div.x-grid-cell-inner");
if (btn) {
for (var i = 0; i < (records[j].data.headerLevel - records[j].data.treeLevel); i++) {
Ext.DomHelper.insertFirst(btn, {
tag: "span",
cls: "caption-add-left-padding"
});
}
}
}
}
},
refresh: function (view, eOpts) {
var nodes = view.getNodes();
var records = view.getRecords(nodes);
for (var i = 0; i < nodes.length; i++) {
var record = view.getRecord(nodes[i]);
if (record.data.headerLevel - record.data.treeLevel > 0) {
var btn = nodes[i].querySelector("div.x-grid-cell-inner");
if (btn) {
for (var k = 0; k < (record.data.headerLevel - record.data.treeLevel); k++) {
Ext.DomHelper.insertFirst(btn, {
tag: "span",
cls: "caption-add-left-padding"
});
}
}
}
}
},
scope: this
}
}
});
this.items = [{
xtype: "label",
cls: "de-headerslist-header",
text: this.textHeaderList,
margin: "0 0 0 20px"
},
{
xtype: "tbspacer",
height: 12
},
this.headerListPanel];
this.addListener("resize", this._onResize, this);
this.addListener("afterrender", this._onAfterRender, this);
this.callParent(arguments);
},
setApi: function (api) {
if (api == undefined) {
return;
}
if (api) {
this.api = api;
this.api.asc_registerCallback("asc_onChangeHeaderList", Ext.bind(this._refreshHeaderList, this));
this.api.asc_registerCallback("asc_onReturnHeaders", Ext.bind(this._refreshHeaderList, this));
this.api.CollectHeaders();
}
},
_refreshHeaderList: function (headers) {
if (headers) {
this._apiHeaders2Tree(headers);
this._treestore.setRootNode(this._treeHeaders);
}
},
moveToDocPosition: function (url) {
if (this.api) {
this.api.moveToDocPosition(url);
}
},
_onResize: function (panel, adjWidth, adjHeight, eOpts) {
var _height = this.getHeight() - 45;
if (this.headerListPanel.getHeight() != _height && _height > 0) {
this.headerListPanel.setHeight(_height);
}
},
_onAfterRender: function (panel, eOpts) {},
_apiHeaders2Tree: function (headers) {
this._fakeHeaders = headers;
this._treeHeaders = {
headerText: "MainHeader",
headerLevel: 0,
headerId: -1,
headers: []
};
this.index = 0;
var level = 0;
var parentNode = this._createNodeFromApiHeaders(this._fakeHeaders[this.index], this.index, level);
this._treeHeaders.headers.push(parentNode);
this.index++;
while (this.index < this._fakeHeaders.length) {
var nextNode = this._fakeHeaders[this.index];
if (nextNode.get_Level() > parentNode.headerLevel) {
this._fillChildHeaders(parentNode);
} else {
if (parentNode.headers == undefined) {
parentNode.leaf = true;
}
parentNode = this._createNodeFromApiHeaders(this._fakeHeaders[this.index], this.index, level);
this._treeHeaders.headers.push(parentNode);
this.index++;
}
}
if (parentNode.headers == undefined) {
parentNode.leaf = true;
}
},
_createNodeFromApiHeaders: function (apiNode, index, level) {
var treeNode = {
headerText: apiNode.get_headerText(),
headerLevel: apiNode.get_Level(),
headerId: index,
treeLevel: level
};
return treeNode;
},
_fillChildHeaders: function (parentNode) {
if (parentNode.headers == undefined) {
parentNode.expanded = true;
parentNode.headers = [];
}
var newNode = this._createNodeFromApiHeaders(this._fakeHeaders[this.index], this.index, parentNode.treeLevel + 1);
parentNode.headers.push(newNode);
parentNode = newNode;
this.index++;
while (this.index < this._fakeHeaders.length) {
var nextNode = this._fakeHeaders[this.index];
if (nextNode.get_Level() > parentNode.headerLevel) {
this._fillChildHeaders(parentNode);
} else {
if (parentNode.headers == undefined) {
parentNode.leaf = true;
}
break;
}
}
if (parentNode.headers == undefined) {
parentNode.leaf = true;
}
},
textHeaderList: "Document Titles Navigation"
});

View File

@@ -1,259 +1,170 @@
/*
* (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("DE.view.HyperlinkSettingsDialog", {
extend: "Ext.window.Window",
alias: "widget.dehyperlinksettingsdialog",
requires: ["Ext.window.Window"],
modal: true,
closable: true,
resizable: false,
preventHeader: true,
plain: true,
height: 216,
width: 350,
padding: "20px 20px 18px 20px",
layout: "vbox",
layoutConfig: {
align: "stretch"
},
listeners: {
show: function () {
this.txtUrl.focus(false, 500);
}
},
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
this.isTextChanged = false;
var _btnOk = Ext.create("Ext.Button", {
id: "addhyperlink-button-ok",
text: this.okButtonText,
width: 80,
cls: "asc-blue-button",
listeners: {
click: function () {
if (!this.txtUrl.isValid() || !this.txtDisplay.isValid()) {
return;
}
this._modalresult = 1;
this.fireEvent("onmodalresult", this._modalresult);
this.close();
},
scope: this
}
});
var _btnCancel = Ext.create("Ext.Button", {
id: "addhyperlink-button-cancel",
text: this.cancelButtonText,
width: 80,
cls: "asc-darkgray-button",
listeners: {
click: function () {
this._modalresult = 0;
this.fireEvent("onmodalresult", this._modalresult);
this.close();
},
scope: this
}
});
this.txtUrl = Ext.create("Ext.form.Text", {
id: "addhyperlink-text-url",
width: 310,
msgTarget: "side",
validateOnChange: false,
allowBlank: false,
value: "http://",
blankText: this.txtEmpty,
regex: /(([\-\wа-яё]+\.)+[\wа-яё]{2,3}(\/[%\-\wа-яё]+(\.[\wа-яё]{2,})?)*(([\wа-яё\-\.\?\\\/+@&#;`~=%!]*)(\.[\wа-яё]{2,})?)*\/?)/i,
regexText: this.txtNotUrl,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
_btnCancel.fireEvent("click");
}
}
}
}
});
this.txtDisplay = Ext.create("Ext.form.Text", {
id: "addhyperlink-text-display",
width: 310,
msgTarget: "side",
validateOnBlur: false,
allowBlank: false,
blankText: this.txtEmpty,
value: "",
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
_btnCancel.fireEvent("click");
}
}
},
change: function (field, newValue, oldValue) {
this.isTextChanged = true;
},
scope: this
}
});
this.txtTooltip = Ext.create("Ext.form.Text", {
id: "addhyperlink-text-tooltip",
width: 310,
msgTarget: "side",
validateOnBlur: false,
allowBlank: true,
value: "",
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
_btnCancel.fireEvent("click");
}
}
}
}
});
this.addEvents("onmodalresult");
this.items = [{
xtype: "label",
text: this.textUrl,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 3
},
this.txtUrl, {
xtype: "tbspacer",
height: 3
},
{
xtype: "label",
text: this.textDisplay,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 3
},
this.txtDisplay, {
xtype: "tbspacer",
height: 3
},
{
xtype: "label",
text: this.textTooltip,
width: "100%",
style: "text-align:left"
},
{
xtype: "tbspacer",
height: 3
},
this.txtTooltip, {
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
width: 310,
layout: "hbox",
layoutConfig: {
align: "stretch"
},
items: [{
xtype: "tbspacer",
flex: 1
},
_btnOk, {
xtype: "tbspacer",
width: 5
},
_btnCancel]
}];
this.callParent(arguments);
},
setSettings: function (props) {
if (props) {
if (props.get_Value()) {
this.txtUrl.setValue(props.get_Value());
} else {
this.txtUrl.setValue("");
}
if (props.get_Text() !== null) {
this.txtDisplay.setValue(props.get_Text());
this.txtDisplay.setDisabled(false);
} else {
this.txtDisplay.setValue(this.textDefault);
this.txtDisplay.setDisabled(true);
}
this.isTextChanged = false;
this.txtTooltip.setValue(props.get_ToolTip());
}
},
getSettings: function () {
var props = new CHyperlinkProperty();
var url = this.txtUrl.getValue().trim();
if (!/(((^https?)|(^ftp)):\/\/)/i.test(url)) {
url = "http://" + url;
}
props.put_Value(url);
if (!this.txtDisplay.isDisabled() && this.isTextChanged) {
props.put_Text(this.txtDisplay.getValue());
} else {
props.put_Text(null);
}
props.put_ToolTip(this.txtTooltip.getValue());
return props;
},
textUrl: "Link to",
textDisplay: "Display",
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtEmpty: "This field is required",
txtNotUrl: 'This field should be a URL in the format "http://www.example.com"',
textTooltip: "ScreenTip text",
textDefault: "Selected text"
/*
* (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/InputField", "common/main/lib/component/Window"], function () {
DE.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.textUrl + " *</label>", "</div>", '<div id="id-dlg-hyperlink-url" class="input-row" style="margin-bottom: 5px;"></div>', '<div class="input-row">', "<label>" + this.textDisplay + "</label>", "</div>", '<div id="id-dlg-hyperlink-display" class="input-row" style="margin-bottom: 5px;"></div>', '<div class="input-row">', "<label>" + this.textTooltip + "</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 me = this,
$window = this.getChild();
me.inputUrl = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-url"),
allowBlank: false,
blankError: me.txtEmpty,
style: "width: 100%;",
validateOnBlur: false,
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.inputDisplay = new Common.UI.InputField({
el: $("#id-dlg-hyperlink-display"),
allowBlank: true,
validateOnBlur: false,
style: "width: 100%;"
}).on("changed:after", function () {
me.isTextChanged = true;
});
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 () {
me.inputUrl.cmpEl.find("input").focus();
},
500);
},
setSettings: function (props) {
if (props) {
var me = this;
if (props.get_Value()) {
me.inputUrl.setValue(props.get_Value());
} else {
me.inputUrl.setValue("");
}
if (props.get_Text() !== null) {
me.inputDisplay.setValue(props.get_Text());
me.inputDisplay.setDisabled(false);
} else {
me.inputDisplay.setValue(this.textDefault);
me.inputDisplay.setDisabled(true);
}
this.isTextChanged = false;
me.inputTip.setValue(props.get_ToolTip());
}
},
getSettings: function () {
var me = this,
props = new CHyperlinkProperty(),
url = $.trim(me.inputUrl.getValue());
if (!/(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url)) {
url = ((me.isEmail) ? "mailto:": "http://") + url;
}
props.put_Value(url);
if (!me.inputDisplay.isDisabled() && (this.isTextChanged || _.isEmpty(me.inputDisplay.getValue()))) {
if (_.isEmpty(me.inputDisplay.getValue())) {
me.inputDisplay.setValue(url);
}
props.put_Text(me.inputDisplay.getValue());
} else {
props.put_Text(null);
}
props.put_ToolTip(me.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.inputUrl.checkValidate(),
checkdisp = this.inputDisplay.checkValidate();
if (checkurl !== true) {
this.inputUrl.cmpEl.find("input").focus();
return;
}
if (checkdisp !== true) {
this.inputDisplay.cmpEl.find("input").focus();
return;
}
}
this.options.handler.call(this, this, state);
}
this.close();
},
textUrl: "Link to",
textDisplay: "Display",
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtEmpty: "This field is required",
txtNotUrl: 'This field should be a URL in the format "http://www.example.com"',
textTooltip: "ScreenTip text",
textDefault: "Selected text",
textTitle: "Hyperlink Settings"
},
DE.Views.HyperlinkSettingsDialog || {}));
});

View File

@@ -1,526 +1,369 @@
/*
* (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("DE.view.ImageSettings", {
extend: "Common.view.AbstractSettingsPanel",
alias: "widget.deimagesettings",
height: 298,
requires: ["Ext.ComponentQuery", "Ext.container.Container", "Ext.button.Button", "Ext.form.Checkbox", "Ext.form.Text", "Ext.form.Label", "Ext.toolbar.Spacer", "Common.view.ImageFromUrlDialog", "DE.view.ImageSettingsAdvanced", "Common.component.MenuDataViewPicker"],
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
this.title = this.txtTitle;
this._initSettings = true;
this._state = {
WrappingStyle: c_oAscWrapStyle2.Inline,
CanBeFlow: true,
Width: 0,
Height: 0,
FromGroup: false
};
this._nRatio = 1;
this._noApply = false;
this._originalProps = null;
var dataTpl = Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap" data-qtip="{tip}">', '<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" style="{imgstyle}" class="item-wraplist"/>', '<tpl if="title">', '<span class="title">{title}</span>', "</tpl>", "</div>", "</tpl>");
var viewData = [{
offsetx: 0,
data: c_oAscWrapStyle2.Inline,
iconcls: "wrap-subtype wrap-inline",
tip: this.txtInline
},
{
offsetx: 50,
data: c_oAscWrapStyle2.Square,
iconcls: "wrap-subtype wrap-square",
tip: this.txtSquare
},
{
offsetx: 100,
data: c_oAscWrapStyle2.Tight,
iconcls: "wrap-subtype wrap-tight",
tip: this.txtTight
},
{
offsetx: 150,
data: c_oAscWrapStyle2.Through,
iconcls: "wrap-subtype wrap-through",
tip: this.txtThrough
},
{
offsetx: 200,
data: c_oAscWrapStyle2.TopAndBottom,
iconcls: "wrap-subtype wrap-topAndBottom",
tip: this.txtTopAndBottom
},
{
offsetx: 250,
data: c_oAscWrapStyle2.InFront,
iconcls: "wrap-subtype wrap-inFront",
tip: this.txtInFront
},
{
offsetx: 300,
data: c_oAscWrapStyle2.Behind,
iconcls: "wrap-subtype wrap-behind",
tip: this.txtBehind
}];
for (var i = 0; i < viewData.length; i++) {
viewData[i].imgstyle = Ext.String.format("background-position: {0}px 0;", -viewData[i].offsetx);
}
this.btnWrapType = Ext.widget("button", {
id: "image-button-wrap",
width: 72,
height: 58,
cls: "btn-wrap-types",
iconCls: "wrap-subtype wrap-inline",
pressedCls: "disablepressed",
menuAlign: "tl-bl?",
menu : Ext.create("Common.component.MenuDataViewPicker", {
width: 257,
height: 133,
cls: "wrap-view",
dataTpl: dataTpl,
viewData: viewData,
contentWidth: 237,
listeners: {
select: Ext.bind(function (picker, record) {
this.btnWrapType.setIconCls(record.data.iconcls);
if (this.api && !this._noApply) {
var props = new CImgProperty();
props.put_WrappingStyle((record.data.data));
if (this._state.WrappingStyle === c_oAscWrapStyle2.Inline && record.data.data !== c_oAscWrapStyle2.Inline) {
props.put_PositionH(new CImagePositionH());
props.get_PositionH().put_UseAlign(false);
props.get_PositionH().put_RelativeFrom(c_oAscRelativeFromH.Column);
var val = this._originalProps.get_Value_X(c_oAscRelativeFromH.Column);
props.get_PositionH().put_Value(val);
props.put_PositionV(new CImagePositionV());
props.get_PositionV().put_UseAlign(false);
props.get_PositionV().put_RelativeFrom(c_oAscRelativeFromV.Paragraph);
val = this._originalProps.get_Value_Y(c_oAscRelativeFromV.Paragraph);
props.get_PositionV().put_Value(val);
}
this.api.ImgApply(props);
}
this.fireEvent("editcomplete", this);
},
this),
hide: Ext.bind(function () {
this.fireEvent("editcomplete", this);
},
this)
}
})
});
this.btnWrapType.menu.picker.selectByIndex(0);
this._btnOriginalSize = Ext.create("Ext.Button", {
id: "image-button-original-size",
text: this.textOriginalSize,
width: 100,
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.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: 61,
width: 200,
items: [{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 8px;"
}
},
defaults: {
xtype: "container",
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 16,
style: "float:left;"
},
items: [{
items: [this.labelWidth = Ext.create("Ext.form.Label", {
text: this.textWidth,
width: 85
})]
},
{
items: [this.labelHeight = Ext.create("Ext.form.Label", {
text: this.textHeight,
width: 85
})]
}]
},
{
xtype: "tbspacer",
height: 8
},
this._btnOriginalSize, {
xtype: "tbspacer",
height: 3
}]
});
this._WrapPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 70,
width: 200,
items: [{
xtype: "tbspacer",
height: 6
},
{
xtype: "container",
height: 63,
width: 200,
layout: "hbox",
items: [this.btnWrapType]
}]
});
this._UrlPanel = Ext.create("Ext.container.Container", {
layout: "vbox",
layoutConfig: {
align: "stretch"
},
height: 36,
width: 200,
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.textWrap
},
this._WrapPanel, {
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, {
xtype: "tbspacer",
height: 8
},
{
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="image-advanced-link" class="asc-advanced-link">' + this.textAdvanced + "</label></div>",
listeners: {
afterrender: function (cmp) {
document.getElementById("image-advanced-link").onclick = Ext.bind(this._openAdvancedSettings, this);
},
scope: this
}
}]
}];
this.addEvents("editcomplete");
this.callParent(arguments);
},
setOriginalSize: function () {
if (this.api) {
var imgsize = this.api.get_OriginalSizeImage();
var w = imgsize.get_ImageWidth();
var h = imgsize.get_ImageHeight();
this.labelWidth.setText(this.textWidth + ": " + Ext.util.Format.round(Common.MetricSettings.fnRecalcFromMM(w), 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
this.labelHeight.setText(this.textHeight + ": " + Ext.util.Format.round(Common.MetricSettings.fnRecalcFromMM(h), 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
var properties = new CImgProperty();
properties.put_Width(w);
properties.put_Height(h);
this.api.ImgApply(properties);
this.fireEvent("editcomplete", this);
}
},
setApi: function (api) {
if (api == undefined) {
return;
}
if (this.api) {
this.api.asc_unregisterCallback("asc_onImgWrapStyleChanged", Ext.bind(this._ImgWrapStyleChanged, this));
}
this.api = api;
this.api.asc_registerCallback("asc_onImgWrapStyleChanged", Ext.bind(this._ImgWrapStyleChanged, this));
},
ChangeSettings: function (props) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
if (props) {
this._originalProps = new CImgProperty(props);
var value = props.get_WrappingStyle();
if (this._state.WrappingStyle !== value) {
this._noApply = true;
var idx = this.btnWrapType.menu.picker.store.find("data", value);
this.btnWrapType.menu.picker.selectByIndex(idx, false);
if (idx >= 0) {
this.btnWrapType.setIconCls(this.btnWrapType.menu.viewData[idx].iconcls);
} else {
this.btnWrapType.setIconCls("");
}
this._noApply = false;
this._state.WrappingStyle = value;
}
value = props.get_CanBeFlow();
var fromgroup = props.get_FromGroup();
if (this._state.CanBeFlow !== value || this._state.FromGroup !== fromgroup) {
this.btnWrapType.setDisabled(!value || fromgroup);
this._state.CanBeFlow = value;
this._state.FromGroup = fromgroup;
}
this.SuspendEvents();
value = props.get_Width();
if (Math.abs(this._state.Width - value) > 0.001) {
this.labelWidth.setText(this.textWidth + ": " + Ext.util.Format.round(Common.MetricSettings.fnRecalcFromMM(value), 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
this._state.Width = value;
}
value = props.get_Height();
if (Math.abs(this._state.Height - value) > 0.001) {
this.labelHeight.setText(this.textHeight + ": " + Ext.util.Format.round(Common.MetricSettings.fnRecalcFromMM(value), 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
this._state.Height = value;
}
this._btnOriginalSize.setDisabled(props.get_ImageUrl() === null || props.get_ImageUrl() === undefined);
this.ResumeEvents();
}
},
_ImgWrapStyleChanged: function (style) {
if (this._state.WrappingStyle !== style) {
this._noApply = true;
var idx = this.btnWrapType.menu.picker.store.find("data", style);
this.btnWrapType.menu.picker.selectByIndex(idx, false);
if (idx >= 0) {
this.btnWrapType.setIconCls(this.btnWrapType.menu.viewData[idx].iconcls);
}
this._state.WrappingStyle = style;
this._noApply = false;
}
},
_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 CImgProperty();
props.put_ImageUrl(url.value);
self.api.ImgApply(props);
}
}
},
_openAdvancedSettings: function (e) {
var me = this;
var win;
if (me.api) {
var selectedElements = me.api.getSelectedElements();
if (selectedElements && Ext.isArray(selectedElements)) {
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].get_ObjectType();
elValue = selectedElements[i].get_ObjectValue();
if (c_oAscTypeSelectElement.Image == elType) {
win = Ext.create("DE.view.ImageSettingsAdvanced", {});
win.updateMetricUnit();
win.setSettings(elValue);
break;
}
}
}
}
if (win) {
var imgsize;
if (!this._btnOriginalSize.isDisabled()) {
imgsize = this.api.get_OriginalSizeImage();
if (imgsize) {
win.setSizeOriginal({
width: imgsize.get_ImageWidth(),
height: imgsize.get_ImageHeight()
});
}
}
imgsize = this.api.GetSectionInfo();
win.setSizeMax({
width: imgsize.get_PageWidth() - (imgsize.get_MarginLeft() + imgsize.get_MarginRight()),
height: imgsize.get_PageHeight() - (imgsize.get_MarginTop() + imgsize.get_MarginBottom())
});
win.addListener("onmodalresult", Ext.bind(function (o, mr, s) {
if (mr == 1 && s) {
me.api.ImgApply(s);
}
},
this), false);
win.addListener("close", function () {
me.fireEvent("editcomplete", me);
},
false);
win.show();
}
},
updateMetricUnit: function () {
var value = Common.MetricSettings.fnRecalcFromMM(this._state.Width);
this.labelWidth.setText(this.textWidth + ": " + Ext.util.Format.round(value, 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
value = Common.MetricSettings.fnRecalcFromMM(this._state.Height);
this.labelHeight.setText(this.textHeight + ": " + Ext.util.Format.round(value, 1) + " " + Common.MetricSettings.metricName[Common.MetricSettings.getCurrentMetric()]);
},
createDelayedElements: function () {
this.updateMetricUnit();
},
textSize: "Size",
textWrap: "Wraping Style",
textKeepRatio: "Constant Proportions",
textWidth: "Width",
textHeight: "Height",
textOriginalSize: "Default Size",
textApply: "Apply",
textUrl: "Image URL",
textInsert: "Insert Image",
textUndock: "Undock from panel",
textFromUrl: "From URL",
textFromFile: "From File",
textAdvanced: "Show advanced settings",
txtTitle: "Picture",
txtInline: "Inline",
txtSquare: "Square",
txtTight: "Tight",
txtThrough: "Through",
txtTopAndBottom: "Top and bottom",
txtBehind: "Behind",
txtInFront: "In front"
/*
* (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!documenteditor/main/app/template/ImageSettings.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/view/ImageFromUrlDialog", "documenteditor/main/app/view/ImageSettingsAdvanced"], function (menuTemplate, $, _, Backbone) {
DE.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._state = {
WrappingStyle: c_oAscWrapStyle2.Inline,
CanBeFlow: true,
Width: 0,
Height: 0,
FromGroup: false,
DisabledControls: false
};
this.lockedControls = [];
this._locked = false;
this._noApply = false;
this._originalProps = null;
this.render();
var viewData = [{
offsetx: 0,
data: c_oAscWrapStyle2.Inline,
iconcls: "wrap-inline",
tip: this.txtInline,
selected: true
},
{
offsetx: 50,
data: c_oAscWrapStyle2.Square,
iconcls: "wrap-square",
tip: this.txtSquare
},
{
offsetx: 100,
data: c_oAscWrapStyle2.Tight,
iconcls: "wrap-tight",
tip: this.txtTight
},
{
offsetx: 150,
data: c_oAscWrapStyle2.Through,
iconcls: "wrap-through",
tip: this.txtThrough
},
{
offsetx: 200,
data: c_oAscWrapStyle2.TopAndBottom,
iconcls: "wrap-topAndBottom",
tip: this.txtTopAndBottom
},
{
offsetx: 250,
data: c_oAscWrapStyle2.InFront,
iconcls: "wrap-inFront",
tip: this.txtInFront
},
{
offsetx: 300,
data: c_oAscWrapStyle2.Behind,
iconcls: "wrap-behind",
tip: this.txtBehind
}];
this.btnWrapType = new Common.UI.Button({
cls: "btn-large-dataview",
iconCls: "item-wrap wrap-inline",
menu: new Common.UI.Menu({
items: [{
template: _.template('<div id="id-image-menu-wrap" style="width: 235px; margin: 0 5px;"></div>')
}]
})
});
this.btnWrapType.on("render:after", function (btn) {
me.mnuWrapPicker = new Common.UI.DataView({
el: $("#id-image-menu-wrap"),
parentMenu: btn.menu,
store: new Common.UI.DataViewStore(viewData),
itemTemplate: _.template('<div id="<%= id %>" class="item-wrap" style="background-position: -<%= offsetx %>px 0;"></div>')
});
});
this.btnWrapType.render($("#image-button-wrap"));
this.mnuWrapPicker.on("item:click", _.bind(this.onSelectWrap, this, this.btnWrapType));
this.lockedControls.push(this.btnWrapType);
this.labelWidth = $(this.el).find("#image-label-width");
this.labelHeight = $(this.el).find("#image-label-height");
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.btnOriginalSize.on("click", _.bind(this.setOriginalSize, this));
this.btnInsertFromFile.on("click", _.bind(function (btn) {
if (this.api) {
this.api.ChangeImageFromFile();
}
this.fireEvent("editcomplete", this);
},
this));
this.btnInsertFromUrl.on("click", _.bind(this.insertFromUrl, this));
$(this.el).on("click", "#image-advanced-link", _.bind(this.openAdvancedSettings, this));
},
render: function () {
var el = $(this.el);
el.html(this.template({
scope: this
}));
this.linkAdvanced = $("#image-advanced-link");
},
setApi: function (api) {
this.api = api;
if (this.api) {
this.api.asc_registerCallback("asc_onImgWrapStyleChanged", _.bind(this._ImgWrapStyleChanged, this));
}
return this;
},
updateMetricUnit: function () {
var value = Common.Utils.Metric.fnRecalcFromMM(this._state.Width);
this.labelWidth[0].innerHTML = this.textWidth + ": " + value.toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
value = Common.Utils.Metric.fnRecalcFromMM(this._state.Height);
this.labelHeight[0].innerHTML = this.textHeight + ": " + value.toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
},
createDelayedElements: function () {
this.updateMetricUnit();
},
ChangeSettings: function (props) {
if (this._initSettings) {
this.createDelayedElements();
this._initSettings = false;
}
this.disableControls(this._locked);
if (props) {
this._originalProps = new CImgProperty(props);
var value = props.get_WrappingStyle();
if (this._state.WrappingStyle !== value) {
this._noApply = true;
var record = this.mnuWrapPicker.store.findWhere({
data: value
});
this.mnuWrapPicker.selectRecord(record, true);
if (record) {
this.btnWrapType.setIconCls("item-wrap " + record.get("iconcls"));
} else {
this.btnWrapType.setIconCls("");
}
this._noApply = false;
this._state.WrappingStyle = value;
}
value = props.get_CanBeFlow() && !this._locked;
var fromgroup = props.get_FromGroup() || this._locked;
if (this._state.CanBeFlow !== value || this._state.FromGroup !== fromgroup) {
this.btnWrapType.setDisabled(!value || fromgroup);
this._state.CanBeFlow = value;
this._state.FromGroup = fromgroup;
}
value = props.get_Width();
if (Math.abs(this._state.Width - value) > 0.001) {
this.labelWidth[0].innerHTML = this.textWidth + ": " + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this._state.Width = value;
}
value = props.get_Height();
if (Math.abs(this._state.Height - value) > 0.001) {
this.labelHeight[0].innerHTML = this.textHeight + ": " + Common.Utils.Metric.fnRecalcFromMM(value).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this._state.Height = value;
}
this.btnOriginalSize.setDisabled(props.get_ImageUrl() === null || props.get_ImageUrl() === undefined || this._locked);
}
},
_ImgWrapStyleChanged: function (style) {
if (this._state.WrappingStyle !== style) {
this._noApply = true;
var record = this.mnuWrapPicker.store.findWhere({
data: style
});
this.mnuWrapPicker.selectRecord(record, true);
if (record) {
this.btnWrapType.setIconCls("item-wrap " + record.get("iconcls"));
}
this._state.WrappingStyle = style;
this._noApply = false;
}
},
onSelectWrap: 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.btnWrapType.setIconCls("item-wrap " + rawData.iconcls);
if (this.api) {
var props = new CImgProperty();
props.put_WrappingStyle((rawData.data));
if (this._state.WrappingStyle === c_oAscWrapStyle2.Inline && rawData.data !== c_oAscWrapStyle2.Inline) {
props.put_PositionH(new CImagePositionH());
props.get_PositionH().put_UseAlign(false);
props.get_PositionH().put_RelativeFrom(c_oAscRelativeFromH.Column);
var val = this._originalProps.get_Value_X(c_oAscRelativeFromH.Column);
props.get_PositionH().put_Value(val);
props.put_PositionV(new CImagePositionV());
props.get_PositionV().put_UseAlign(false);
props.get_PositionV().put_RelativeFrom(c_oAscRelativeFromV.Paragraph);
val = this._originalProps.get_Value_Y(c_oAscRelativeFromV.Paragraph);
props.get_PositionV().put_Value(val);
}
this.api.ImgApply(props);
}
this.fireEvent("editcomplete", this);
},
setOriginalSize: function () {
if (this.api) {
var imgsize = this.api.get_OriginalSizeImage();
var w = imgsize.get_ImageWidth();
var h = imgsize.get_ImageHeight();
this.labelWidth[0].innerHTML = this.textWidth + ": " + Common.Utils.Metric.fnRecalcFromMM(w).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
this.labelHeight[0].innerHTML = this.textHeight + ": " + Common.Utils.Metric.fnRecalcFromMM(h).toFixed(1) + " " + Common.Utils.Metric.metricName[Common.Utils.Metric.getCurrentMetric()];
var properties = new CImgProperty();
properties.put_Width(w);
properties.put_Height(h);
this.api.ImgApply(properties);
this.fireEvent("editcomplete", 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 CImgProperty();
props.put_ImageUrl(checkUrl);
me.api.ImgApply(props);
}
}
}
me.fireEvent("editcomplete", me);
}
})).show();
},
openAdvancedSettings: function (e) {
if (this.linkAdvanced.hasClass("disabled")) {
return;
}
var me = this;
var win;
if (me.api && !this._locked) {
var selectedElements = me.api.getSelectedElements();
if (selectedElements && selectedElements.length > 0) {
var elType, elValue;
for (var i = selectedElements.length - 1; i >= 0; i--) {
elType = selectedElements[i].get_ObjectType();
elValue = selectedElements[i].get_ObjectValue();
if (c_oAscTypeSelectElement.Image == elType) {
var imgsizeOriginal;
if (!me.btnOriginalSize.isDisabled()) {
imgsizeOriginal = me.api.get_OriginalSizeImage();
if (imgsizeOriginal) {
imgsizeOriginal = {
width: imgsizeOriginal.get_ImageWidth(),
height: imgsizeOriginal.get_ImageHeight()
};
}
}
var imgsizeMax = this.api.GetSectionInfo();
imgsizeMax = {
width: imgsizeMax.get_PageWidth() - (imgsizeMax.get_MarginLeft() + imgsizeMax.get_MarginRight()),
height: imgsizeMax.get_PageHeight() - (imgsizeMax.get_MarginTop() + imgsizeMax.get_MarginBottom())
};
(new DE.Views.ImageSettingsAdvanced({
imageProps: elValue,
sizeOriginal: imgsizeOriginal,
sizeMax: imgsizeMax,
handler: function (result, value) {
if (result == "ok") {
if (me.api) {
me.api.ImgApply(value.imageProps);
}
}
me.fireEvent("editcomplete", me);
}
})).show();
break;
}
}
}
}
},
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);
}
},
textSize: "Size",
textWrap: "Wraping Style",
textWidth: "Width",
textHeight: "Height",
textOriginalSize: "Default Size",
textInsert: "Insert Image",
textFromUrl: "From URL",
textFromFile: "From File",
textAdvanced: "Show advanced settings",
txtInline: "Inline",
txtSquare: "Square",
txtTight: "Tight",
txtThrough: "Through",
txtTopAndBottom: "Top and bottom",
txtBehind: "Behind",
txtInFront: "In front"
},
DE.Views.ImageSettings || {}));
});

View File

@@ -1,194 +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("DE.view.InsertTableDialog", {
extend: "Ext.window.Window",
alias: "widget.deinserttabledialog",
requires: ["Ext.window.Window"],
modal: true,
closable: false,
resizable: false,
preventHeader: true,
plain: true,
height: 172,
width: 236,
padding: "20px",
layout: {
type: "vbox",
align: "stretch"
},
listeners: {
show: function () {
this.udColumns.focus(false, 500);
}
},
initComponent: function () {
var me = this;
this.addEvents("onmodalresult");
this.items = [{
xtype: "label",
text: this.labelTitle || this.txtTitle,
style: "margin: 0 0 15px 0; font-size: 15px;"
},
{
xtype: "container",
height: 32,
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "label",
padding: "4px 0 0 0",
width: 130,
text: this.txtColumns
},
this.udColumns = Ext.widget("numberfield", {
minValue: 1,
maxValue: 63,
value: 2,
step: 1,
width: 64,
allowDecimals: false,
validateOnBlur: false,
msgTarget: "side",
minText: this.txtMinText,
maxText: this.txtMaxText,
listeners: {
specialkey: Ext.bind(function (field, e) {
if (e.getKey() == e.ENTER) {
this.btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
this.btnCancel.fireEvent("click");
}
}
},
this)
}
})]
},
{
xtype: "container",
height: 42,
layout: {
type: "hbox",
align: "stretch"
},
items: [{
xtype: "label",
padding: "4px 0 0 0",
width: 130,
text: this.txtRows
},
this.udRows = Ext.widget("numberfield", {
minValue: 1,
maxValue: 100,
value: 2,
step: 1,
width: 64,
allowDecimals: false,
validateOnBlur: false,
msgTarget: "side",
minText: this.txtMinText,
maxText: this.txtMaxText,
listeners: {
specialkey: Ext.bind(function (field, e) {
if (e.getKey() == e.ENTER) {
this.btnOk.fireEvent("click");
} else {
if (e.getKey() == e.ESC) {
this.btnCancel.fireEvent("click");
}
}
},
this)
}
})]
},
{
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) {
var valid_cols = this.udColumns.isValid();
var valid_rows = this.udRows.isValid();
if (!valid_cols || !valid_rows) {
return;
}
this.fireEvent("onmodalresult", this, 1, [this.udColumns.value, this.udRows.value]);
this.close();
},
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.close();
},
scope: this
}
})]
}]
}];
this.callParent(arguments);
},
txtTitle: "Table size",
txtColumns: "Number of Columns",
txtRows: "Number of Rows",
textInvalidRowsCols: "You need to specify valid rows and columns count.",
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtMinText: "The minimum value for this field is {0}",
txtMaxText: "The maximum value for this field is {0}"
});

View File

@@ -0,0 +1,256 @@
/*
* (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!documenteditor/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/About", "common/main/lib/view/SearchDialog", "documenteditor/main/app/view/FileMenu"], function (menuTemplate, $, _, Backbone) {
var SCALE_MIN = 40;
var MENU_SCALE_PART = 300;
DE.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"),
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"),
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"),
hint: this.tipAbout,
enableToggle: true,
disabled: true,
toggleGroup: "leftMenuGroup"
});
this.btnSupport = new Common.UI.Button({
action: "support",
el: $("#left-btn-support"),
hint: this.tipSupport,
disabled: true
});
this.btnComments = new Common.UI.Button({
el: $("#left-btn-comments"),
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"),
hint: this.tipChat + Common.Utils.String.platformKey("Ctrl+Alt+Q", null, function (string) {
if (Common.Utils.isMac) {
string = string.replace(/Ctrl|ctrl/g, "⌃");
}
return 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 DE.Views.FileMenu({});
menuFile.options = {
alias: "FileMenu"
};
this.btnFile.panel = menuFile.render();
this.btnAbout.panel = (new Common.Views.About({
el: $("#about-menu-panel"),
appName: "Document Editor"
})).render();
return this;
},
onBtnMenuToggle: function (btn, state) {
if (state) {
btn.panel["show"]();
this.$el.width(SCALE_MIN);
if (this.btnSearch.isActive()) {
this.btnSearch.toggle(false);
}
} else {
btn.panel["hide"]();
}
if (this.mode.isEdit) {
DE.getController("Toolbar").DisableToolbar(state == true);
}
if (!this.supressEvents) {
Common.NotificationCenter.trigger("layout:changed", "leftmenu");
}
},
onBtnMenuClick: function (btn, e) {
this.supressEvents = true;
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("de-mainmenu-width") || MENU_SCALE_PART);
}
} else {
localStorage.setItem("de-mainmenu-width", this.$el.width());
this.$el.width(SCALE_MIN);
}
}
this.supressEvents = false;
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.btnSearch.setDisabled(false);
this.btnAbout.setDisabled(false);
this.btnSupport.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.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();
}
}
}
}
},
getMenu: function (type) {
switch (type) {
default:
return null;
case "file":
return this.btnFile.panel;
case "about":
return this.btnAbout.panel;
}
},
setMode: function (mode) {
this.mode = mode;
return this;
},
tipComments: "Comments",
tipChat: "Chat",
tipAbout: "About",
tipSupport: "Feedback & Support",
tipFile: "File",
tipSearch: "Search"
},
DE.Views.LeftMenu || {}));
});

View File

@@ -1,345 +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("DE.view.MainMenu", {
extend: "Ext.panel.Panel",
alias: "widget.demainmenu",
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",
hidden: true,
currentFullScaleMenuBtn: undefined,
fullScaledItemCnt: undefined,
buttonCollection: [],
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,
config;
var me = this;
for (var i = 0; i < this.buttonCollection.length; i++) {
item = this.buttonCollection[i];
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("de-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._onContainerKeyDown, 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("de-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.doComponentLayout();
this.fireEvent("panelshow", panel, btn.isFullScale);
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++) {
if (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_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));
this.api.asc_getLicense();
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 && 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().down("container");
if (activeStep) {
var btnChat = Ext.getCmp("id-menu-chat");
if (btnChat) {
if (!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;
for (var i = 0; i < this.buttonCollection.length; i++) {
var item = this.buttonCollection[i],
cardId = -1;
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._onContainerKeyDown, 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,
hidden: true,
closeMenu: function () {
me.closeFullScaleMenu();
},
getApi: function () {
return me.api;
}
});
}
addedButtons[i].bodyCardId = item.items[0].id;
this.fullScaledItemCnt.add(item.items);
}
}
}
this.add(addedItems);
},
_onContainerKeyDown: function (event, target, opt) {
if (event.getKey() == event.ESC) {
if (opt.button) {
opt.button.toggle(false);
} else {
this.clearSelection();
}
}
}
});

View File

@@ -1,74 +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("DE.view.MenuColontitules", {
extend: "Ext.menu.Menu",
alias: "widget.demenucolontitules",
requires: ["Common.component.DataViewPicker"],
hideOnClick: true,
constructor: function (config) {
if (!config || !config.viewData) {
throw Error("Common.component.MenuDataViewPicker creation failed: required parameters are missing.");
}
this.initConfig(config);
this.callParent(arguments);
return this;
},
initComponent: function () {
var me = this,
cfg = Ext.apply({},
me.initialConfig);
delete cfg.listeners;
Ext.apply(me, {
plain: true,
showSeparator: false,
items: [{
xtype: "label",
margin: "6px 0 0 10px",
text: "Insert page number"
},
Ext.applyIf({
xtype: "cmddataviewpicker",
padding: "4px 4px 1px 10px"
},
cfg)]
});
me.callParent(arguments);
me.picker = me.down("cmddataviewpicker");
me.relayEvents(me.picker, ["select"]);
if (me.hideOnClick) {
me.on("select", me.hidePickerOnSelect, me);
}
},
hidePickerOnSelect: function (picker, columns, rows) {
Ext.menu.Manager.hideAll();
}
});

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("DE.view.RecentFiles", {
extend: "Ext.panel.Panel",
alias: "widget.derecentfiles",
cls: "de-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,223 +1,236 @@
/*
* (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("DE.view.RightMenu", {
extend: "Ext.panel.Panel",
alias: "widget.derightmenu",
requires: ["Ext.toolbar.Toolbar", "Ext.button.Button", "Ext.container.Container", "Ext.toolbar.Spacer", "DE.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("derightpanel", {
id: "view-right-panel-settings",
btnText: this.btnText,
btnTable: this.btnTable,
btnImage: this.btnImage,
btnHeaderFooter: this.btnHeaderFooter,
btnShape: this.btnShape
});
this.items = [this._rightSettings];
this.addEvents("editcomplete");
this.callParent(arguments);
},
buildDockedItems: function () {
var me = this;
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,
style: "margin-bottom: 8px;",
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
me.btnTable = Ext.create("Ext.Button", {
id: "id-right-menu-table",
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn menuTable",
asctype: c_oAscTypeSelectElement.Table,
enableToggle: true,
allowDepress: true,
style: "margin-bottom: 8px;",
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
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,
style: "margin-bottom: 8px;",
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
me.btnHeaderFooter = Ext.create("Ext.Button", {
id: "id-right-menu-header",
cls: "asc-main-menu-buttons",
iconCls: "asc-main-menu-btn menuHeaderFooter",
asctype: c_oAscTypeSelectElement.Header,
enableToggle: true,
allowDepress: true,
style: "margin-bottom: 8px;",
disabled: true,
toggleGroup: "tabpanelbtnsGroup"
});
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,
style: "margin-bottom: 8px;",
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.btnText, me.btnTable, me.btnImage, me.btnHeaderFooter, me.btnShape]
});
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 (Ext.isDefined(btn) && btn.componentCls === "x-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
});
}
},
createDelayedElements: function () {
var me = 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);
window.localStorage.setItem("de-hidden-right-settings", 0);
} else {
btn.addCls("asc-main-menu-btn-selected");
}
} else {
me.setWidth(SCALE_MIN);
me._rightSettings.minimizedMode = true;
btn.removeCls("asc-main-menu-btn-selected");
window.localStorage.setItem("de-hidden-right-settings", 1);
}
me.fireEvent("editcomplete", me);
};
var button;
var tips = [me.txtParagraphSettings, me.txtTableSettings, me.txtImageSettings, me.txtHeaderFooterSettings, me.txtShapeSettings];
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]);
}
},
txtParagraphSettings: "Paragraph Settings",
txtImageSettings: "Image Settings",
txtTableSettings: "Table Settings",
txtHeaderFooterSettings: "Header and Footer Settings",
txtShapeSettings: "Shape Settings",
txtChartSettings: "Chart 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!documenteditor/main/app/template/RightMenu.template", "jquery", "underscore", "backbone", "common/main/lib/component/Button", "common/main/lib/component/MetricSpinner", "common/main/lib/component/CheckBox", "documenteditor/main/app/view/ParagraphSettings", "documenteditor/main/app/view/HeaderFooterSettings", "documenteditor/main/app/view/ImageSettings", "documenteditor/main/app/view/ChartSettings", "documenteditor/main/app/view/TableSettings", "documenteditor/main/app/view/ShapeSettings", "common/main/lib/component/Scroller"], function (menuTemplate, $, _, Backbone) {
DE.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.btnTable = new Common.UI.Button({
hint: this.txtTableSettings,
asctype: c_oAscTypeSelectElement.Table,
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.btnHeaderFooter = new Common.UI.Button({
hint: this.txtHeaderFooterSettings,
asctype: c_oAscTypeSelectElement.Header,
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.Table] = {
panel: "id-table-settings",
btn: this.btnTable
};
this._settings[c_oAscTypeSelectElement.Image] = {
panel: "id-image-settings",
btn: this.btnImage
};
this._settings[c_oAscTypeSelectElement.Header] = {
panel: "id-header-settings",
btn: this.btnHeaderFooter
};
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.show();
el.html(this.template({}));
this.btnText.el = $("#id-right-menu-text");
this.btnText.render();
this.btnTable.el = $("#id-right-menu-table");
this.btnTable.render();
this.btnImage.el = $("#id-right-menu-image");
this.btnImage.render();
this.btnHeaderFooter.el = $("#id-right-menu-header");
this.btnHeaderFooter.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.btnTable.on("click", _.bind(this.onBtnMenuClick, this));
this.btnImage.on("click", _.bind(this.onBtnMenuClick, this));
this.btnHeaderFooter.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 DE.Views.ParagraphSettings();
this.headerSettings = new DE.Views.HeaderFooterSettings();
this.imageSettings = new DE.Views.ImageSettings();
this.chartSettings = new DE.Views.ChartSettings();
this.tableSettings = new DE.Views.TableSettings();
this.shapeSettings = new DE.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;
var fire = function () {
this.fireEvent("editcomplete", this);
};
this.paragraphSettings.setApi(api).on("editcomplete", _.bind(fire, this));
this.headerSettings.setApi(api).on("editcomplete", _.bind(fire, this));
this.imageSettings.setApi(api).on("editcomplete", _.bind(fire, this));
this.chartSettings.setApi(api).on("editcomplete", _.bind(fire, this));
this.tableSettings.setApi(api).on("editcomplete", _.bind(fire, this));
this.shapeSettings.setApi(api).on("editcomplete", _.bind(fire, this));
},
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("de-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("de-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.headerSettings.disableControls(disabled);
this.tableSettings.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");
}
}
},
txtParagraphSettings: "Paragraph Settings",
txtImageSettings: "Image Settings",
txtTableSettings: "Table Settings",
txtHeaderFooterSettings: "Header and Footer Settings",
txtShapeSettings: "Shape Settings",
txtChartSettings: "Chart Settings"
},
DE.Views.RightMenu || {}));
});

View File

@@ -1,300 +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("DE.view.RightPanel", {
extend: "Ext.container.Container",
alias: "widget.derightpanel",
width: 220,
layout: {
type: "auto"
},
autoScroll: true,
cls: "asc-right-panel-container",
preventHeader: true,
requires: ["Ext.toolbar.Toolbar", "Ext.container.Container", "Common.plugin.ScrollPane", "DE.view.TableSettings", "DE.view.ParagraphSettings", "DE.view.ImageSettings", "DE.view.HeaderFooterSettings", "DE.view.ShapeSettings", "Ext.Button"],
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;
}
var needhide = true;
for (var i = 0; i < this._settings.length; i++) {
if (this._settings[i]) {
this._settings[i].hidden = 1;
this._settings[i].locked = false;
}
}
for (i = 0; i < SelectedObjects.length; i++) {
var type = SelectedObjects[i].get_ObjectType();
if (type >= this._settings.length || this._settings[type] === undefined) {
continue;
}
var value = SelectedObjects[i].get_ObjectValue();
if (type == c_oAscTypeSelectElement.Image) {
if (value.get_ShapeProperties() !== null) {
type = c_oAscTypeSelectElement.Shape;
}
}
this._settings[type].props = value;
this._settings[type].hidden = 0;
this._settings[type].locked = value.get_Locked();
}
if (this._settings[c_oAscTypeSelectElement.Header].locked) {
for (i = 0; i < this._settings.length; i++) {
if (this._settings[i]) {
this._settings[i].locked = true;
}
}
}
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._settings[i].panel.isDisabled() !== this._settings[i].locked) {
this._settings[i].panel.setDisabled(this._settings[i].locked);
}
}
}
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 {
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
}
}
}
this._settings[c_oAscTypeSelectElement.Image].needShow = false;
this._settings[c_oAscTypeSelectElement.Shape].needShow = false;
},
onInsertTable: function () {
this._settings[c_oAscTypeSelectElement.Table].needShow = true;
},
onInsertImage: function () {
this._settings[c_oAscTypeSelectElement.Image].needShow = true;
},
onInsertShape: function () {
this._settings[c_oAscTypeSelectElement.Shape].needShow = true;
},
FillAutoShapes: function () {
this.ShapePanel.FillAutoShapes();
},
SendThemeColors: function (effectcolors, standartcolors) {
this.effectcolors = effectcolors;
if (standartcolors && standartcolors.length > 0) {
this.standartcolors = standartcolors;
}
if (this.ShapePanel && this.TablePanel && this.ParagraphPanel) {
this.ShapePanel.SendThemeColors(effectcolors, standartcolors);
this.TablePanel.SendThemeColors(effectcolors, standartcolors);
this.ParagraphPanel.SendThemeColors(effectcolors, standartcolors);
}
},
setApi: function (api) {
this.api = api;
return this;
},
setMode: function (mode) {
this.editMode = mode.isEdit;
},
updateMetricUnit: function () {
this.HeaderFooterPanel.updateMetricUnit();
this.ParagraphPanel.updateMetricUnit();
this.ImagePanel.updateMetricUnit();
},
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.ParagraphPanel = Ext.create("DE.view.ParagraphSettings", {
id: "view-paragraph-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Paragraph
}), me.TablePanel = Ext.create("DE.view.TableSettings", {
id: "view-table-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Table
}), me.ImagePanel = Ext.create("DE.view.ImageSettings", {
id: "view-image-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Image
}), me.HeaderFooterPanel = Ext.create("DE.view.HeaderFooterSettings", {
id: "view-headerfooter-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Header
}), me.ShapePanel = Ext.create("DE.view.ShapeSettings", {
id: "view-shape-settings",
cls: "asc-right-panel",
type: c_oAscTypeSelectElement.Shape
})],
listeners: {
afterlayout: function () {
me.updateScrollPane();
}
}
})],
listeners: {
afterlayout: function () {
me.updateScrollPane();
}
}
});
me.add(me.panelHolder);
me._settings = [];
me._settings[c_oAscTypeSelectElement.Paragraph] = {
panel: me.ParagraphPanel,
btn: me.btnText,
hidden: 1,
locked: false
};
me._settings[c_oAscTypeSelectElement.Table] = {
panel: me.TablePanel,
btn: me.btnTable,
hidden: 1,
locked: false
};
me._settings[c_oAscTypeSelectElement.Image] = {
panel: me.ImagePanel,
btn: me.btnImage,
hidden: 1,
locked: false
};
me._settings[c_oAscTypeSelectElement.Header] = {
panel: me.HeaderFooterPanel,
btn: me.btnHeaderFooter,
hidden: 1,
locked: false,
needShow: true
};
me._settings[c_oAscTypeSelectElement.Shape] = {
panel: me.ShapePanel,
btn: me.btnShape,
hidden: 1,
locked: false
};
if (this.api) {
this.HeaderFooterPanel.setApi(this.api);
this.ImagePanel.setApi(this.api);
this.ParagraphPanel.setApi(this.api);
this.TablePanel.setApi(this.api);
this.ShapePanel.setApi(this.api);
this.api.asc_registerCallback("asc_onFocusObject", Ext.bind(this.onFocusObject, this));
}
if (this.editMode && this.api) {
var selectedElements = this.api.getSelectedElements();
if (selectedElements.length > 0) {
this.onFocusObject(selectedElements);
}
}
if (this.effectcolors && this.standartcolors) {
this.ShapePanel.SendThemeColors(this.effectcolors, this.standartcolors);
this.TablePanel.SendThemeColors(this.effectcolors, this.standartcolors);
this.ParagraphPanel.SendThemeColors(this.effectcolors, this.standartcolors);
}
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,546 +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("DE.view.ShapeSettingsAdvancedCnt", {
extend: "Ext.container.Container",
alias: "widget.peshapesettingsadvancedcnt",
requires: ["Ext.form.field.ComboBox", "Ext.data.Model", "Ext.data.Store", "Ext.Array", "Ext.button.Button"],
cls: "image-advanced-container",
height: 330,
width: 320,
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
var me = this;
this._originalProps = null;
this._changedProps = null;
this._beginSizeIdx = 0;
this._endSizeIdx = 0;
this._arrCapType = [[c_oAscLineCapType.Flat, this.textFlat], [c_oAscLineCapType.Round, this.textRound], [c_oAscLineCapType.Square, this.textSquare]];
this.cmbCapType = Ext.create("Ext.form.field.ComboBox", {
id: "shape-advanced-cap-type",
width: 100,
editable: false,
store: this._arrCapType,
queryMode: "local",
triggerAction: "all",
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
if (this._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linecap(me._arrCapType[records[0].index][0]);
}
},
this)
}
});
this.cmbCapType.setValue(this._arrCapType[0][1]);
this._arrJoinType = [[c_oAscLineJoinType.Round, this.textRound], [c_oAscLineJoinType.Bevel, this.textBevel], [c_oAscLineJoinType.Miter, this.textMiter]];
this.cmbJoinType = Ext.create("Ext.form.field.ComboBox", {
id: "shape-advanced-join-type",
width: 100,
editable: false,
store: this._arrJoinType,
queryMode: "local",
triggerAction: "all",
listeners: {
select: Ext.bind(function (combo, records, eOpts) {
if (this._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linejoin(me._arrJoinType[records[0].index][0]);
}
},
this)
}
});
this.cmbJoinType.setValue(this._arrJoinType[0][1]);
this.styleURL = "resources/img/right-panels/Begin-EndStyle.png";
this.styleURL2x = "resources/img/right-panels/Begin-EndStyle@2x.png";
var _arrStyles = [],
_arrSize = [];
var _styleTypes = [c_oAscLineBeginType.None, c_oAscLineBeginType.Triangle, c_oAscLineBeginType.Arrow, c_oAscLineBeginType.Stealth, c_oAscLineBeginType.Diamond, c_oAscLineBeginType.Oval];
var _sizeTypes = [c_oAscLineBeginSize.small_small, c_oAscLineBeginSize.small_mid, c_oAscLineBeginSize.small_large, c_oAscLineBeginSize.mid_small, c_oAscLineBeginSize.mid_mid, c_oAscLineBeginSize.mid_large, c_oAscLineBeginSize.large_small, c_oAscLineBeginSize.large_mid, c_oAscLineBeginSize.large_large];
for (var i = 0; i < 6; i++) {
var item = {
value: i,
imagewidth: 44,
imageheight: 20,
offsetx: 80 * i + 10,
offsety: 0
};
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -item.offsety, this.styleURL2x);
_arrStyles.push(item);
}
_arrStyles[0].type = c_oAscLineBeginType.None;
_arrStyles[1].type = c_oAscLineBeginType.Triangle;
_arrStyles[2].type = c_oAscLineBeginType.Arrow;
_arrStyles[3].type = c_oAscLineBeginType.Stealth;
_arrStyles[4].type = c_oAscLineBeginType.Diamond;
_arrStyles[5].type = c_oAscLineBeginType.Oval;
for (i = 0; i < 9; i++) {
var item = {
value: i,
imagewidth: 44,
imageheight: 20,
offsetx: 80 + 10,
offsety: 20 * (i + 1)
};
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -item.offsety, this.styleURL2x);
_arrSize.push(item);
}
_arrSize[0].type = c_oAscLineBeginSize.small_small;
_arrSize[1].type = c_oAscLineBeginSize.small_mid;
_arrSize[2].type = c_oAscLineBeginSize.small_large;
_arrSize[3].type = c_oAscLineBeginSize.mid_small;
_arrSize[4].type = c_oAscLineBeginSize.mid_mid;
_arrSize[5].type = c_oAscLineBeginSize.mid_large;
_arrSize[6].type = c_oAscLineBeginSize.large_small;
_arrSize[7].type = c_oAscLineBeginSize.large_mid;
_arrSize[8].type = c_oAscLineBeginSize.large_large;
var beginStyleStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrStyles
});
var beginSizeStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrSize
});
for (i = 0; i < _arrStyles.length; i++) {
var item = _arrStyles[i];
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -(item.offsety + 200), this.styleURL2x);
}
for (i = 0; i < _arrSize.length; i++) {
var item = _arrSize[i];
item.borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", this.styleURL, item.imagewidth, item.imageheight, -item.offsetx, -(item.offsety + 200), this.styleURL2x);
}
var endStyleStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrStyles
});
var endSizeStore = Ext.create("Ext.data.Store", {
model: "DE.model.ModelBorders",
data: _arrSize
});
this._updateSizeArr = function (sizecombo, record, type, sizeidx) {
var style = Ext.String.format("background:url({0}) repeat scroll 0 -1px", "resources/img/controls/text-bg.gif");
if (record.data.value > 0) {
for (var i = 0; i < _arrSize.length; i++) {
_arrSize[i].offsetx = record.data.value * 80 + 10;
_arrSize[i].borderstyle = Ext.String.format("background:url({0}) {3}px {4}px; width:{1}px; height:{2}px; background-image: -webkit-image-set(url({0}) 1x, url({5}) 2x);", me.styleURL, _arrSize[i].imagewidth, _arrSize[i].imageheight, -_arrSize[i].offsetx, -(_arrSize[i].offsety + 200 * type), this.styleURL2x);
}
sizecombo.menu.picker.store.loadData(_arrSize);
sizecombo.setDisabled(false);
if (sizeidx !== null) {
sizecombo.menu.picker.selectByIndex(sizeidx, true);
me._selectStyleItem(sizecombo, sizecombo.menu.picker.store.getAt(sizeidx), type);
} else {
Ext.DomHelper.applyStyles(sizecombo.btnEl, style);
}
} else {
Ext.DomHelper.applyStyles(sizecombo.btnEl, style);
sizecombo.setDisabled(true);
}
};
this._selectStyleItem = function (stylecombo, record, type) {
var style;
if (stylecombo.btnEl) {
style = Ext.String.format("background:url({0}) repeat scroll {1}px {2}px, url({3}) repeat scroll 0 -1px;", me.styleURL, -(record.data.offsetx - 20), -(record.data.offsety + 200 * type), "resources/img/controls/text-bg.gif");
style += Ext.String.format("background-image: -webkit-image-set(url({0}) 1x, url({1}) 2x), -webkit-image-set(url({2}) 1x, url({3}) 2x);", me.styleURL, me.styleURL2x, "resources/img/controls/text-bg.gif", "resources/img/controls/text-bg@2x.gif");
Ext.DomHelper.applyStyles(stylecombo.btnEl, style);
}
};
var endStyleTpl = Ext.create("Ext.XTemplate", '<tpl for=".">', '<div class="thumb-wrap">', '<img src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" align="left" style="{borderstyle}"" />', "</div>", "</tpl>");
this._btnBeginStyle = Ext.create("Ext.button.Button", {
width: 100,
cls: "btn-combo-style",
pressedCls: "",
menu: this.BeginStyleMenu = Ext.create("Common.component.MenuDataViewPicker", {
width: 115,
height: 92,
cls: "arrow-view",
dataTpl: endStyleTpl,
viewData: [],
store: beginStyleStore,
contentWidth: 95,
listeners: {
select: Ext.bind(function (picker, record) {
if (me._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linebeginstyle(record.data.type);
}
if (this._beginSizeIdx === null || this._beginSizeIdx === undefined) {
this._beginSizeIdx = 4;
}
me._updateSizeArr(me._btnBeginSize, record, 0, this._beginSizeIdx);
me._selectStyleItem(me._btnBeginStyle, record, 0);
},
me),
hide: function () {
me.fireEvent("editcomplete", me);
}
}
}),
listeners: {
afterRender: function () {
me._selectStyleItem(this, this.menu.picker.store.getAt(1), 0);
}
}
});
this._btnEndStyle = Ext.create("Ext.button.Button", {
width: 100,
cls: "btn-combo-style",
pressedCls: "",
menu: this.EndStyleMenu = Ext.create("Common.component.MenuDataViewPicker", {
width: 115,
height: 92,
cls: "arrow-view",
dataTpl: endStyleTpl,
viewData: [],
store: endStyleStore,
contentWidth: 95,
listeners: {
select: Ext.bind(function (picker, record) {
if (me._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_lineendstyle(record.data.type);
}
if (this._endSizeIdx === null || this._endSizeIdx === undefined) {
this._endSizeIdx = 4;
}
me._updateSizeArr(me._btnEndSize, record, 1, this._endSizeIdx);
me._selectStyleItem(me._btnEndStyle, record, 1);
},
me),
hide: function () {
me.fireEvent("editcomplete", me);
}
}
}),
listeners: {
afterRender: function () {
me._selectStyleItem(this, this.menu.picker.store.getAt(1), 1);
}
}
});
this._btnBeginSize = Ext.create("Ext.button.Button", {
width: 100,
cls: "btn-combo-style",
pressedCls: "",
menu: this.BeginSizeMenu = Ext.create("Common.component.MenuDataViewPicker", {
width: 167,
height: 92,
cls: "arrow-view",
dataTpl: endStyleTpl,
viewData: [],
store: beginSizeStore,
contentWidth: 147,
listeners: {
select: Ext.bind(function (picker, record) {
if (me._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_linebeginsize(record.data.type);
}
this._beginSizeIdx = record.data.value;
me._selectStyleItem(me._btnBeginSize, record, 0);
},
me),
hide: function () {
me.fireEvent("editcomplete", me);
}
}
}),
listeners: {
afterRender: function () {
me._selectStyleItem(this, this.menu.picker.store.getAt(1), 0);
}
}
});
this._btnEndSize = Ext.create("Ext.button.Button", {
width: 100,
cls: "btn-combo-style",
pressedCls: "",
menu: this.BeginSizeMenu = Ext.create("Common.component.MenuDataViewPicker", {
width: 167,
height: 92,
cls: "arrow-view",
dataTpl: endStyleTpl,
viewData: [],
store: endSizeStore,
contentWidth: 147,
listeners: {
select: Ext.bind(function (picker, record) {
if (me._changedProps) {
if (this._changedProps.get_stroke() === null) {
this._changedProps.put_stroke(new CAscStroke());
}
this._changedProps.get_stroke().put_lineendsize(record.data.type);
}
this._endSizeIdx = record.data.value;
me._selectStyleItem(me._btnEndSize, record, 1);
},
me),
hide: function () {
me.fireEvent("editcomplete", me);
}
}
}),
listeners: {
afterRender: function () {
me._selectStyleItem(this, this.menu.picker.store.getAt(1), 1);
}
}
});
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.items = [{
xtype: "label",
style: "font-weight: bold;margin-top: 1px; padding-left:10px;height:13px;",
text: this.textLineStyle
},
{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
height: 40,
padding: "0 10",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 40px;vertical-align: middle;"
}
},
items: [{
xtype: "label",
text: this.textCapType,
width: 85
},
{
xtype: "label",
text: this.textJoinType,
width: 85
},
{
xtype: "tbspacer",
height: 2
},
{
xtype: "tbspacer",
height: 2
},
this.cmbCapType, this.cmbJoinType]
},
this._spacer.cloneConfig({
style: "margin: 16px 0 11px 0;",
height: 6
}), {
xtype: "label",
style: "font-weight: bold;margin-top: 1px; padding-left:10px;height:13px;",
text: this.textArrows
},
{
xtype: "tbspacer",
height: 8
},
{
xtype: "container",
height: 86,
padding: "0 10",
layout: {
type: "table",
columns: 2,
tdAttrs: {
style: "padding-right: 40px;vertical-align: middle;"
}
},
items: [{
xtype: "label",
text: this.textBeginStyle,
width: 85
},
{
xtype: "label",
text: this.textEndStyle,
width: 85
},
{
xtype: "tbspacer",
height: 2
},
{
xtype: "tbspacer",
height: 2
},
this._btnBeginStyle, this._btnEndStyle, {
xtype: "tbspacer",
height: 5
},
{
xtype: "tbspacer",
height: 5
},
{
xtype: "label",
text: this.textBeginSize,
width: 85
},
{
xtype: "label",
text: this.textEndSize,
width: 85
},
{
xtype: "tbspacer",
height: 2
},
{
xtype: "tbspacer",
height: 2
},
this._btnBeginSize, this._btnEndSize]
}];
this.callParent(arguments);
},
afterRender: function () {
this.callParent(arguments);
},
setSettings: function (props) {
this._originalProps = props;
this._changedProps = null;
},
_setDefaults: function (props) {
if (props) {
var stroke = props.get_stroke();
if (stroke) {
var value = stroke.get_linejoin();
for (var i = 0; i < this._arrJoinType.length; i++) {
if (value == this._arrJoinType[i][0]) {
this.cmbJoinType.setValue(this._arrJoinType[i][1]);
break;
}
}
value = stroke.get_linecap();
for (i = 0; i < this._arrCapType.length; i++) {
if (value == this._arrCapType[i][0]) {
this.cmbCapType.setValue(this._arrCapType[i][1]);
break;
}
}
var canchange = stroke.get_canChangeArrows();
this._btnBeginStyle.setDisabled(!canchange);
this._btnEndStyle.setDisabled(!canchange);
this._btnBeginSize.setDisabled(!canchange);
this._btnEndSize.setDisabled(!canchange);
var style = Ext.String.format("background:url({0}) repeat scroll 0 -1px", "resources/img/controls/text-bg.gif");
if (canchange) {
value = stroke.get_linebeginsize();
var rec = this._btnBeginSize.menu.picker.store.findRecord("type", value);
if (rec !== null) {
this._beginSizeIdx = rec.data.value;
} else {
this._beginSizeIdx = null;
Ext.DomHelper.applyStyles(this._btnBeginSize.btnEl, style);
}
value = stroke.get_linebeginstyle();
rec = this._btnBeginStyle.menu.picker.store.findRecord("type", value);
if (rec !== null) {
this._btnBeginStyle.menu.picker.selectByIndex(rec.data.value, false);
this._updateSizeArr(this._btnBeginSize, rec, 0, this._beginSizeIdx);
this._selectStyleItem(this._btnBeginStyle, rec, 0);
} else {
Ext.DomHelper.applyStyles(this._btnBeginStyle.btnEl, style);
}
value = stroke.get_lineendsize();
rec = this._btnEndSize.menu.picker.store.findRecord("type", value);
if (rec !== null) {
this._endSizeIdx = rec.data.value;
} else {
this._endSizeIdx = null;
Ext.DomHelper.applyStyles(this._btnEndSize.btnEl, style);
}
value = stroke.get_lineendstyle();
rec = this._btnEndStyle.menu.picker.store.findRecord("type", value);
if (rec !== null) {
this._btnEndStyle.menu.picker.selectByIndex(rec.data.value, false);
this._updateSizeArr(this._btnEndSize, rec, 1, this._endSizeIdx);
this._selectStyleItem(this._btnEndStyle, rec, 1);
} else {
Ext.DomHelper.applyStyles(this._btnEndStyle.btnEl, style);
}
} else {
Ext.DomHelper.applyStyles(this._btnBeginStyle.btnEl, style);
Ext.DomHelper.applyStyles(this._btnEndStyle.btnEl, style);
Ext.DomHelper.applyStyles(this._btnBeginSize.btnEl, style);
Ext.DomHelper.applyStyles(this._btnEndSize.btnEl, style);
}
}
}
this._changedProps = new CAscShapeProp();
},
getSettings: function () {
return this._changedProps;
},
textRound: "Round",
textMiter: "Miter",
textSquare: "Square",
textFlat: "Flat",
textBevel: "Bevel",
textTitle: "Shape - Advanced Settings",
cancelButtonText: "Cancel",
okButtonText: "Ok",
txtNone: "None",
textWeightArrows: "Weights & Arrows",
textArrows: "Arrows",
textLineStyle: "Line Style",
textCapType: "Cap Type",
textJoinType: "Join Type",
textBeginStyle: "Begin Style",
textBeginSize: "Begin Size",
textEndStyle: "End Style",
textEndSize: "End Size"
});

View File

@@ -0,0 +1,470 @@
/**
* StatusBar View
*
* Created by Maxim Kadushkin
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
*
*/
define([
'text!documenteditor/main/app/template/StatusBar.template',
'jquery',
'underscore',
'backbone',
'tip',
'common/main/lib/component/Menu',
'common/main/lib/component/Window',
'documenteditor/main/app/model/Pages'
],
function(template, $, _, Backbone){
'use strict';
function _onCountPages(count){
this.pages.set('count', count);
}
function _onCurrentPage(number){
this.pages.set('current', number+1);
}
var _tplPages = _.template('Page <%= current %> of <%= count %>');
function _updatePagesCaption(model,value,opts) {
$('#status-label-pages').text(
Common.Utils.String.format(this.pageIndexText, model.get('current'), model.get('count')) );
}
function _clickLanguage(menu, item, state) {
var $parent = $(menu.el.parentNode);
$parent.find('#status-label-lang').text(item.caption);
$parent.find('.icon-lang-flag')
.removeClass(this.langMenu.prevTip)
.addClass(item.value.tip);
this.langMenu.prevTip = item.value.tip;
this.fireEvent('langchanged', [this, item.value.code, item.caption]);
}
if ( DE.Views.Statusbar )
var LanguageDialog = DE.Views.Statusbar.LanguageDialog || {};
DE.Views.Statusbar = Backbone.View.extend(_.extend({
el: '#statusbar',
template: _.template(template),
events: {
},
api: undefined,
pages: undefined,
initialize: function () {
this.pages = new DE.Models.Pages({current:1, count:1});
this.pages.on('change', _.bind(_updatePagesCaption,this));
},
render: function () {
$(this.el).html(this.template({
scope: this
}));
this.btnZoomToPage = new Common.UI.Button({
el: $('#btn-zoom-topage',this.el),
hint: this.tipFitPage,
hintAnchor: 'top',
toggleGroup: 'status-zoom',
enableToggle: true
});
this.btnZoomToWidth = new Common.UI.Button({
el: $('#btn-zoom-towidth',this.el),
hint: this.tipFitWidth,
hintAnchor: 'top',
toggleGroup: 'status-zoom',
enableToggle: true
});
this.btnZoomDown = new Common.UI.Button({
el: $('#btn-zoom-down',this.el),
hint: this.tipZoomOut + Common.Utils.String.platformKey('Ctrl+-'),
hintAnchor: 'top'
});
this.btnZoomUp = new Common.UI.Button({
el: $('#btn-zoom-up',this.el),
hint: this.tipZoomIn + Common.Utils.String.platformKey('Ctrl++'),
hintAnchor: 'top-right'
});
this.btnDocLanguage = new Common.UI.Button({
el: $('#btn-doc-lang',this.el),
hint: this.tipSetDocLang,
hintAnchor: 'top'
});
this.btnSetSpelling = new Common.UI.Button({
el: $('#btn-doc-spell',this.el),
enableToggle: true,
hint: this.tipSetSpelling,
hintAnchor: 'top'
});
var panelLang = $('.cnt-lang',this.el);
this.langMenu = new Common.UI.Menu({
style: 'margin-top:-5px;',
maxHeight: 300,
menuAlign: 'bl-tl'
});
this.btnLanguage = new Common.UI.Button({
el: panelLang,
hint: this.tipSetLang,
hintAnchor: 'top-left'
});
this.btnLanguage.cmpEl.on('show.bs.dropdown', function () {
_.defer(function(){
me.api.asc_enableKeyEvents(false);
me.btnLanguage.cmpEl.find('ul').focus();
}, 100);
}
);
this.btnLanguage.cmpEl.on('hide.bs.dropdown', function () {
_.defer(function(){
me.api.asc_enableKeyEvents(true);
}, 100);
}
);
this.langMenu.render(panelLang);
this.langMenu.cmpEl.attr({tabindex: -1});
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);
}
);
this.cntZoom.cmpEl.on('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.langMenu.prevTip = 'en';
this.langMenu.on('item:click', _.bind(_clickLanguage,this));
/** coauthoring begin **/
this.panelUsers = $('#status-users-ct', this.el);
this.panelUsers.find('#status-users-block').on('click', _.bind(this.onUsersClick, this));
/** coauthoring end **/
// Go To Page
var me = this;
this.txtGoToPage = new Common.UI.InputField({
el : $('#status-goto-page'),
allowBlank : true,
validateOnChange: true,
style : 'width: 60px;',
maskExp: /[0-9]/,
validation : function(value) {
if (/(^[0-9]+$)/.test(value)) {
value = parseInt(value);
if (undefined !== value && value > 0 && value <= me.pages.get('count'))
return true;
}
return me.txtPageNumInvalid;
}
}).on('keypress:after', function(input, e) {
var box = me.$el.find('#status-goto-box');
if (e.keyCode === Common.UI.Keys.RETURN) {
var edit = box.find('input[type=text]'), page = parseInt(edit.val());
if (!page || page-- > me.pages.get('count') || page < 0) {
edit.select();
return false;
}
box.focus(); // for IE
box.parent().removeClass('open');
me.api.goToPage(page);
me.api.asc_enableKeyEvents(true);
return false;
}
}
);
var goto = this.$el.find('#status-goto-box');
goto.on('click', function() {
return false;
});
goto.parent().on('show.bs.dropdown',
function () {
me.txtGoToPage.setValue(me.api.getCurrentPage() + 1);
me.txtGoToPage.checkValidate();
var edit = me.txtGoToPage.$el.find('input');
_.defer(function(){edit.focus(); edit.select();}, 100);
}
);
goto.parent().on('hide.bs.dropdown',
function () { var box = me.$el.find('#status-goto-box');
if (me.api && box) {
box.focus(); // for IE
box.parent().removeClass('open');
me.api.asc_enableKeyEvents(true);
}
}
);
return this;
},
setApi: function(api) {
this.api = api;
if (this.api) {
this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this));
this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this));
/** coauthoring begin **/
this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onApiUsersChanged, this));
this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onApiUsersChanged, this));
/** coauthoring end **/
}
return this;
},
setMode: function(mode) {
this.$el.find('.el-edit')[mode.isEdit?'show':'hide']();
},
setVisible: function(visible) {
visible
? this.show()
: this.hide();
},
/** coauthoring begin **/
onUsersClick: function() {
this.fireEvent('click:users', this);
},
onApiUsersChanged: function(users) {
var editusers = [];
_.each(users, function(item){
if (!item.asc_getView())
editusers.push(item);
});
var length = _.size(editusers);
this.panelUsers[length > 1 ? 'show' : 'hide']();
var ttblock = this.panelUsers.find('#status-users-block');
if (ttblock.data('bs.tooltip')) ttblock.removeData('bs.tooltip');
if (length > 1) {
this.panelUsers.find('#status-users-count').text(length);
var tip = this.tipUsers + '<br/><br/>', i = 0;
for (var n in editusers) {
tip += '\n' + Common.Utils.String.htmlEncode(editusers[n].asc_getUserName());
if (++i > 3) break;
}
if (length > 4) {
tip += '<br/>' + this.tipMoreUsers.replace('%1', length-4);
tip += '<br/><br/>' + this.tipShowUsers;
}
ttblock.tooltip({
title: tip,
html: true,
placement: 'top-left'
});
}
},
/** coauthoring end **/
reloadLanguages: function(array) {
_.each(array, function(item) {
this.langMenu.addItem({
iconCls : item['tip'],
caption : item['title'],
value : {tip: item['tip'], code: item['code']},
checkable : true,
checked : this.langMenu.saved == item.title,
toggleGroup : 'language'
});
}, this);
this.langMenu.doLayout();
},
setLanguage: function(info) {
if (this.langMenu.prevTip != info.tip) {
var $parent = $(this.langMenu.el.parentNode);
$parent.find('.icon-lang-flag')
.removeClass(this.langMenu.prevTip)
.addClass(info.tip);
this.langMenu.prevTip = info.tip;
$parent.find('#status-label-lang').text(info.title);
var index = $parent.find('ul li a:contains("'+info.title+'")').parent().index();
index < 0 ? this.langMenu.saved = info.title :
this.langMenu.items[index-1].setChecked(true);
}
},
showStatusMessage: function(message) {
$('#status-label-action').text(message);
},
clearStatusMessage: function() {
$('#status-label-action').text('');
},
pageIndexText : 'Page {0} of {1}',
goToPageText : 'Go to Page',
tipUsers : 'Document is in the collaborative editing mode.',
tipMoreUsers : 'and %1 users.',
tipShowUsers : 'To see all users click the icon below.',
tipFitPage : 'Fit Page',
tipFitWidth : 'Fit Width',
tipZoomIn : 'Zoom In',
tipZoomOut : 'Zoom Out',
tipZoomFactor : 'Magnification',
tipSetLang : 'Set Text Language',
tipSetDocLang : 'Set Document Language',
tipSetSpelling : 'Turn on spell checking option',
txtPageNumInvalid : 'Page number invalid'
}, DE.Views.Statusbar || {}));
DE.Views.Statusbar.LanguageDialog = Common.UI.Window.extend(_.extend({
options: {
header: false,
width: 350,
cls: 'modal-dlg'
},
template: '<div class="box">' +
'<div class="input-row">' +
'<label><%= label %></label>' +
'</div>' +
'<div class="input-row" id="id-document-language">' +
'</div>' +
'</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.labelSelect,
btns: {ok: this.btnOk, cancel: this.btnCancel}
});
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.cmbLanguage = new Common.UI.ComboBox({
el: $window.find('#id-document-language'),
cls: 'input-group-nr',
menuStyle: 'min-width: 318px; max-height: 300px;',
editable: false,
template: _.template([
'<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">',
'<input type="text" class="form-control">',
'<span class="input-lang-icon" style="position: absolute;"></span>',
'<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>',
'<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',
'<% _.each(items, function(item) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>">',
'<a tabindex="-1" type="menuitem" style="padding-left: 26px !important;">',
'<span class="menu-item-icon <%= item.value %> " style="position: absolute;margin-left:-21px;"></span>',
'<%= scope.getDisplayValue(item) %>',
'</a>',
'</li>',
'<% }); %>',
'</ul>',
'</span>'
].join('')),
data: this.options.languages
});
this.cmbLanguage.scroller.update({alwaysVisibleY: true});
this.cmbLanguage.on('selected', _.bind(this.onLangSelect, this));
this.cmbLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(this.options.current)[0]);
this.onLangSelect(this.cmbLanguage, this.cmbLanguage.getSelectedRecord());
},
close: function(suppressevent) {
var $window = this.getChild();
if (!$window.find('.combobox.open').length) {
Common.UI.Window.prototype.close.call(this, arguments);
}
},
onBtnClick: function(event) {
if (this.options.handler) {
this.options.handler.call(this, event.currentTarget.attributes['result'].value, this.cmbLanguage.getValue());
}
this.close();
},
onLangSelect: function(cmb, rec, e) {
var icon = cmb.$el.find('.input-lang-icon'),
plang = icon.attr('lang');
if (plang) icon.removeClass(plang);
icon.addClass(rec.value).attr('lang',rec.value);
},
labelSelect : 'Select document language',
btnCancel : 'Cancel',
btnOk : 'Ok'
}, LanguageDialog||{}));
}
);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,54 +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("DE.view.UndockedWindow", {
extend: "Ext.window.Window",
cls: "asc-right-panel-undocked",
constrain: true,
closable: false,
resizable: false,
shadow: false,
ghost: function () {
var instance = this.callParent(arguments);
if (!instance.getEl().hasCls("asc-right-panel-undocked-ghost")) {
instance.getEl().addCls("asc-right-panel-undocked-ghost");
}
return instance;
},
constructor: function (config) {
this.callParent(arguments);
this.initConfig(config);
return this;
},
initComponent: function () {
this.callParent(arguments);
}
});

View File

@@ -1,314 +1,121 @@
/*
* (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("DE.view.Viewport", {
extend: "Ext.container.Viewport",
alias: "widget.deviewport",
layout: "fit",
requires: ["Common.view.Header", "Common.view.About", "DE.view.DocumentHolder", "DE.view.MainMenu", "DE.view.File", "DE.view.DocumentStatusInfo", "Common.view.ChatPanel"],
uses: ["DE.view.Toolbar", "DE.view.RightMenu", "DE.view.CreateFile", "DE.view.RecentFiles", "Common.view.CommentsPanel"],
initComponent: function () {
this.header = Ext.widget("commonheader", {
config: {
headerCaption: "Document Editor"
}
});
this._documentHolder = Ext.widget("dedocumentholder", {
id: "editor_sdk",
flex: 1,
maintainFlex: true,
style: "background-color:#b0b0b0;"
});
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: "demainmenu",
id: "view-main-menu",
maxWidth: 600,
buttonCollection: [{
cls: "menuFile",
id: "id-menu-file",
tooltip: this.tipFile + " (Alt+F)",
scale: "full",
disabled: true,
items: [{
xtype: "defile",
id: "main-menu-file-options",
width: "100%",
height: "100%"
}]
},
{
cls: "menuSearch",
id: "id-menu-search",
scale: "modal",
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%"
}]
}],
listeners: {
panelshow: Ext.bind(function (panel, fullScale) {
if (fullScale) {
var btn = Ext.getCmp("id-menu-search");
if (btn.pressed) {
btn.toggle();
}
} else {
this._documentHolder.changePosition();
}
},
this),
panelhide: Ext.bind(function (panel, fullScale) {
if (!fullScale) {
this._documentHolder.changePosition();
}
},
this)
}
},
{
xtype: "splitter",
id: "main-menu-splitter",
cls: "splitter-document-area",
defaultSplitMin: 300,
hidden: true
},
this._documentHolder]
},
this._documentStatus = Ext.widget("documentstatusinfo", {
id: "view-status"
})]
});
this.items = {
xtype: "container",
layout: {
type: "vbox",
align: "stretch"
},
items: [this.header, this.applicationUI]
};
this.callParent(arguments);
},
checkCanHotKey: function () {
var winElements = Ext.getDoc().query(".x-window");
for (var i = 0; i < winElements.length; i++) {
var cmp = Ext.getCmp(winElements[i].id);
if (cmp && cmp.isVisible() && cmp.modal) {
return false;
}
}
return true;
},
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 (mode, delay) {
if (mode.isDisconnected) {
if (this.mode === undefined) {
this.mode = {};
}
this.mode.canCoAuthoring = false;
} else {
this.mode = mode;
}
if (!delay) {
this.applyMode();
}
},
setApi: function (o) {
this.api = o;
return this;
},
applyEditorMode: function () {
var me = this;
me._toolbar = Ext.widget("detoolbar", {
id: "view-toolbar"
});
me.applicationUI.insert(0, me._toolbar);
me._rightMenu = Ext.widget("derightmenu", {
id: "view-right-menu"
});
me.applicationUI.items.items[1].add(me._rightMenu);
var value = window.localStorage.getItem("de-hidden-status");
if (value !== null && parseInt(value) == 1) {
this._documentStatus.setVisible(false);
}
},
createDelayedElements: function () {
var _self = this;
this.hk = new Ext.util.KeyMap(document, [{
key: "f",
ctrl: true,
shift: false,
defaultEventAction: "stopEvent",
fn: function () {
if (_self.checkCanHotKey()) {
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuSearch");
}
}
}
},
{
key: "f",
alt: true,
shift: false,
ctrl: false,
defaultEventAction: "stopEvent",
fn: function () {
if (_self.checkCanHotKey()) {
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 (_self.checkCanHotKey()) {
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 (_self.checkCanHotKey()) {
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,
shift: false,
defaultEventAction: "stopEvent",
fn: function () {
if (_self.checkCanHotKey()) {
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 (_self.checkCanHotKey()) {
var cmp = Ext.getCmp("view-main-menu");
if (cmp) {
cmp.selectMenu("menuComments");
}
}
}
});
Ext.tip.QuickTipManager.init();
this.applyMode();
},
tipFile: "File",
tipSearch: "Search",
tipComments: "Comments",
tipChat: "Chat",
tipTitles: "Titles"
/*
* (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!documenteditor/main/app/template/Viewport.template", "jquery", "underscore", "backbone", "common/main/lib/component/Layout"], function (viewportTemplate, $, _, Backbone) {
DE.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
}]
});
return this;
},
applyEditorMode: function () {
var me = this,
toolbarView = DE.getController("Toolbar").getView("Toolbar"),
rightMenuView = DE.getController("RightMenu").getView("RightMenu"),
statusBarView = DE.getController("Statusbar").getView("Statusbar");
me._toolbar = toolbarView.render();
me._rightMenu = rightMenuView.render();
var value = window.localStorage.getItem("de-hidden-status");
if (value !== null && parseInt(value) == 1) {
statusBarView.setVisible(false);
}
},
setMode: function (mode) {
if (mode.isDisconnected) {
if (_.isUndefined(this.mode)) {
this.mode = {};
}
this.mode.canCoAuthoring = false;
} else {
this.mode = mode;
}
}
});
});