',
'<% _.each(docs, function(item) { %>',
'
',
'
style="background-image: url(<%= item.icon %>);" <% } %> />',
'
<%= item.name %>
',
'
',
'<% }) %>',
'
'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template({
scope: this,
docs: this.options[0].docs
}));
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
_onBlankDocument: function() {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, 'blank']);
},
_onDocumentTemplate: function(e) {
if ( this.menu )
this.menu.fireEvent('create:new', [this.menu, e.currentTarget.attributes['template'].value]);
},
fromBlankText : 'From Blank',
newDocumentText : 'New Spreadsheet',
newDescriptionText : 'Create a new blank text document which you will be able to style and format after it is created during the editing. Or choose one of the templates to start a document of a certain type or purpose where some styles have already been pre-applied.',
fromTemplateText : 'From Template'
}, SSE.Views.FileMenuPanels.CreateNew || {}));
SSE.Views.FileMenuPanels.DocumentInfo = Common.UI.BaseView.extend(_.extend({
el: '#panel-info',
menu: undefined,
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.rendered = false;
this.template = _.template([
'
',
'',
'' + this.txtTitle + ' ',
'- ',
' ',
'',
'' + this.txtAuthor + ' ',
'- ',
' ',
'',
'' + this.txtPlacement + ' ',
'- ',
' ',
'',
'' + this.txtDate + ' ',
'- ',
' ',
' ',
'
'
].join(''));
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template());
this.lblTitle = $('#id-info-title');
this.lblPlacement = $('#id-info-placement');
this.lblDate = $('#id-info-date');
this.lblAuthor = $('#id-info-author');
this.rendered = true;
this.updateInfo(this.doc);
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
},
hide: function() {
Common.UI.BaseView.prototype.hide.call(this,arguments);
},
updateInfo: function(doc) {
this.doc = doc;
if (!this.rendered)
return;
doc = doc || {};
this.lblTitle.text((doc.title) ? doc.title : '-');
if (doc.info) {
if (doc.info.author)
this.lblAuthor.text(doc.info.author);
this._ShowHideInfoItem('author', doc.info.author!==undefined && doc.info.author!==null);
if (doc.info.created )
this.lblDate.text( doc.info.created );
this._ShowHideInfoItem('date', doc.info.created!==undefined && doc.info.created!==null);
if (doc.info.folder )
this.lblPlacement.text( doc.info.folder );
this._ShowHideInfoItem('placement', doc.info.folder!==undefined && doc.info.folder!==null);
} 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);
},
setMode: function(mode) {
return this;
},
txtTitle: 'Document Title',
txtAuthor: 'Author',
txtPlacement: 'Placement',
txtDate: 'Creation Date'
}, SSE.Views.FileMenuPanels.DocumentInfo || {}));
SSE.Views.FileMenuPanels.DocumentRights = Common.UI.BaseView.extend(_.extend({
el: '#panel-rights',
menu: undefined,
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.rendered = false;
this.template = _.template([
'
',
'',
'' + this.txtRights + ' ',
'
',
' ',
'',
'' + this.txtBtnAccessRights + ' ',
' ',
'
'
].join(''));
this.templateRights = _.template([
'
',
'<% _.each(users, function(item) { %>',
'',
'<%= Common.Utils.String.htmlEncode(item.user) %> ',
'<%= Common.Utils.String.htmlEncode(item.permissions) %> ',
' ',
'<% }); %>',
'
'
].join(''));
this.menu = options.menu;
},
render: function() {
$(this.el).html(this.template());
this.cntRights = $('#id-info-rights');
this.btnEditRights = new Common.UI.Button({
el: '#id-info-btn-edit'
});
this.btnEditRights.on('click', _.bind(this.changeAccessRights, this));
this.rendered = true;
this.updateInfo(this.doc);
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: $(this.el),
suppressScrollX: true
});
}
return this;
},
show: function() {
Common.UI.BaseView.prototype.show.call(this,arguments);
},
hide: function() {
Common.UI.BaseView.prototype.hide.call(this,arguments);
},
updateInfo: function(doc) {
this.doc = doc;
if (!this.rendered)
return;
doc = doc || {};
if (doc.info) {
if (doc.info.sharingSettings)
this.cntRights.html(this.templateRights({users: doc.info.sharingSettings}));
this._ShowHideInfoItem('rights', doc.info.sharingSettings!==undefined && doc.info.sharingSettings!==null && doc.info.sharingSettings.length>0);
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('rights', visible);
this._ShowHideInfoItem('edit-rights', visible);
},
setMode: function(mode) {
this.sharingSettingsUrl = mode.sharingSettingsUrl;
return this;
},
changeAccessRights: function(btn,event,opts) {
if (this._docAccessDlg) return;
var me = this;
me._docAccessDlg = new Common.Views.DocumentAccessDialog({
settingsurl: this.sharingSettingsUrl
});
me._docAccessDlg.on('accessrights', function(obj, rights){
me.doc.info.sharingSettings = rights;
me._ShowHideInfoItem('rights', me.doc.info.sharingSettings!==undefined && me.doc.info.sharingSettings!==null && me.doc.info.sharingSettings.length>0);
me.cntRights.html(me.templateRights({users: me.doc.info.sharingSettings}));
}).on('close', function(obj){
me._docAccessDlg = undefined;
});
me._docAccessDlg.show();
},
onLostEditRights: function() {
this._readonlyRights = true;
if (!this.rendered)
return;
this._ShowHideInfoItem('edit-rights', false);
},
txtRights: 'Persons who have rights',
txtBtnAccessRights: 'Change access rights'
}, SSE.Views.FileMenuPanels.DocumentRights || {}));
SSE.Views.FileMenuPanels.Help = Common.UI.BaseView.extend({
el: '#panel-help',
menu: undefined,
template: _.template([
'
'
].join('')),
initialize: function(options) {
Common.UI.BaseView.prototype.initialize.call(this,arguments);
this.menu = options.menu;
this.urlPref = 'resources/help/en/';
this.en_data = [
{src: "UsageInstructions/OpenCreateNew.htm", name: "Create a new spreadsheet or open an existing one", headername: "Usage Instructions", selected: true},
{src: "UsageInstructions/ManageSheets.htm", name: "Manage sheets"},
{src: "UsageInstructions/InsertDeleteCells.htm", name: "Insert or delete cells, rows, and columns"},
{src: "UsageInstructions/CopyPasteData.htm", name: "Copy and paste data"},
{src: "UsageInstructions/FontTypeSizeStyle.htm", name: "Set font type, size, style, and colors"},
{src: "UsageInstructions/AlignText.htm", name: "Align data in cells"},
{src: "UsageInstructions/AddBorders.htm", name: "Add borders"},
{src: "UsageInstructions/MergeCells.htm", name: "Merge cells"},
{src: "UsageInstructions/ClearFormatting.htm", name: "Clear text, format in a cell"},
{src: "UsageInstructions/SortData.htm", name: "Sort data"},
{src: "UsageInstructions/InsertFunction.htm", name: "Insert function"},
{src: "UsageInstructions/ChangeNumberFormat.htm", name: "Change number format"},
{src: "UsageInstructions/UndoRedo.htm", name: "Undo/redo your actions"},
{src: "UsageInstructions/ViewDocInfo.htm", name: "View file information"},
{src: "UsageInstructions/SavePrintDownload.htm", name: "Save/print/download your spreadsheet"},
{src: "HelpfulHints/About.htm", name: "About ONLYOFFICE Spreadsheet Editor", headername: "Helpful Hints"},
{src: "HelpfulHints/SupportedFormats.htm", name: "Supported Formats of Spreadsheets"},
{src: "HelpfulHints/Navigation.htm", name: "Navigation through Your Spreadsheet"},
{src: "HelpfulHints/Search.htm", name: "Search Function"},
{src: "HelpfulHints/KeyboardShortcuts.htm", name: "Keyboard Shortcuts"}
];
if (Common.Utils.isIE) {
window.onhelp = function () { return false; }
}
},
render: function() {
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([
'
'
].join(''))
});
this.viewHelpPicker.on('item:add', function(dataview, itemview, record) {
if (record.has('headername')) {
$(itemview.el).before('');
}
});
this.viewHelpPicker.on('item:select', function(dataview, itemview, record) {
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%";
Common.Gateway.on('internalcommand', function(data) {
if (data.type == 'help:hyperlink') {
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);
}
}
});
$('#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;
}
}
});
});