diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index 392a61ebb..8c465e99a 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -61,7 +61,7 @@ define([ 'Common.Views.Chat': { 'hide': _.bind(this.onHideChat, this) }, - 'Statusbar': { + 'Common.Views.Header': { 'click:users': _.bind(this.clickStatusbarUsers, this) }, 'LeftMenu': { @@ -83,7 +83,9 @@ define([ 'recent:open': _.bind(this.onOpenRecent, this) }, 'Toolbar': { - 'file:settings': _.bind(this.clickToolbarSettings,this) + 'file:settings': _.bind(this.clickToolbarSettings,this), + 'file:open': this.clickToolbarTab.bind(this, 'file'), + 'file:close': this.clickToolbarTab.bind(this, 'other') }, 'SearchDialog': { 'hide': _.bind(this.onSearchDlgHide, this), @@ -216,16 +218,12 @@ define([ if (close_menu) { menu.hide(); - this.leftMenu.btnFile.toggle(false, true); - this.menuExpand(this.leftMenu.btnFile, 'files', false); } }, clickSaveAsFormat: function(menu, format) { this.api.asc_DownloadAs(format); menu.hide(); - this.leftMenu.btnFile.toggle(false, true); - this.menuExpand(this.leftMenu.btnFile, 'files', false); }, applySettings: function(menu) { @@ -242,12 +240,9 @@ define([ value = Common.localStorage.getItem("pe-settings-autosave"); this.api.asc_setAutoSaveGap(parseInt(value)); - value = Common.localStorage.getItem("pe-settings-showsnaplines"); - this.api.put_ShowSnapLines(value===null || parseInt(value) == 1); + this.api.put_ShowSnapLines( Common.localStorage.getBool("pe-settings-showsnaplines") ); menu.hide(); - this.leftMenu.btnFile.toggle(false, true); - this.menuExpand(this.leftMenu.btnFile, 'files', false); }, onCreateNew: function(menu, type) { @@ -260,16 +255,12 @@ define([ if (menu) { menu.hide(); - this.leftMenu.btnFile.toggle(false, true); - this.menuExpand(this.leftMenu.btnFile, 'files', false); } }, onOpenRecent: function(menu, url) { if (menu) { menu.hide(); - this.leftMenu.btnFile.toggle(false, true); - this.menuExpand(this.leftMenu.btnFile, 'files', false); } var recentDocPage = window.open(url); @@ -280,15 +271,18 @@ define([ }, clickToolbarSettings: function(obj) { - if (this.leftMenu.btnFile.pressed && this.leftMenu.btnFile.panel.active == 'opts') - this.leftMenu.close(); - else - this.leftMenu.showMenu('file:opts'); + this.leftMenu.showMenu('file:opts'); + }, + + clickToolbarTab: function (tab, e) { + if (tab == 'file') + this.leftMenu.menuFile.show(); else + this.leftMenu.menuFile.hide(); }, /** coauthoring begin **/ clickStatusbarUsers: function() { - this.leftMenu.btnFile.panel.panels['rights'].changeAccessRights(); + this.leftMenu.menuFile.panels['rights'].changeAccessRights(); }, onHideChat: function() { @@ -384,7 +378,7 @@ define([ }, menuFilesHide: function(obj) { - $(this.leftMenu.btnFile.el).blur(); + // $(this.leftMenu.btnFile.el).blur(); }, /** coauthoring begin **/ @@ -431,12 +425,11 @@ define([ case 'search': if ((!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) { Common.UI.Menu.Manager.hideAll(); - var full_menu_pressed = (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed); + var full_menu_pressed = this.leftMenu.btnAbout.pressed; this.showSearchDlg(true); this.leftMenu.btnSearch.toggle(true,true); - this.leftMenu.btnFile.toggle(false); this.leftMenu.btnAbout.toggle(false); - full_menu_pressed && this.menuExpand(this.leftMenu.btnFile, 'files', false); + full_menu_pressed && this.menuExpand(this.leftMenu.btnAbout, 'files', false); } return false; case 'save': @@ -463,6 +456,12 @@ define([ return false; case 'escape': // if (!this.leftMenu.isOpened()) return true; + // TODO: + if ( this.leftMenu.menuFile.isVisible() ) { + this.leftMenu.menuFile.hide(); + return false; + } + var statusbar = PE.getController('Statusbar'); var menu_opened = statusbar.statusbar.$el.find('.open > [data-toggle="dropdown"]'); if (menu_opened.length) { @@ -476,7 +475,8 @@ define([ return false; } } - if (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || + + if ( this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || $(e.target).parents('#left-menu').length ) { this.leftMenu.close(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 831b30f29..a27255e85 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -427,8 +427,8 @@ define([ case Asc.c_oAscAsyncAction['ForceSaveButton']: clearTimeout(this._state.timerSave); force = true; - title = this.saveTitleText; - text = this.saveTextText; + // title = this.saveTitleText; + // text = this.saveTextText; break; case Asc.c_oAscAsyncAction['ForceSaveTimeout']: @@ -503,8 +503,10 @@ define([ if (!this.isShowOpenDialog) this.loadMask.show(); - } - else { + } else + if ( action.id == Asc.c_oAscAsyncAction.Save ) { + appHeader.setSaveStatus('begin'); + } else { this.getApplication().getController('Statusbar').setStatusCaption(text, force); } }, @@ -529,6 +531,8 @@ define([ me._isDocReady = true; + Common.NotificationCenter.trigger('app:ready', me.appOptions); + me.api.SetDrawingFreeze(false); me.hidePreloader(); me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); @@ -577,6 +581,7 @@ define([ Common.localStorage.setItem("pe-settings-showsnaplines", me.api.get_ShowSnapLines() ? 1 : 0); + var application = me.getApplication(); var toolbarController = application.getController('Toolbar'), statusbarController = application.getController('Statusbar'), documentHolderController = application.getController('DocumentHolder'), @@ -753,16 +758,18 @@ define([ this.updatePlugins(this.plugins, true); this.applyModeCommonElements(); - this.applyModeEditorElements(); - this.api.asc_setViewMode(!this.appOptions.isEdit); + if ( this.appOptions.isEdit ) { + this.applyModeEditorElements(); + } else { + Common.NotificationCenter.trigger('app:face', this.appOptions); - this.api.asc_LoadDocument(); - - if (!this.appOptions.isEdit) { this.hidePreloader(); this.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } + + this.api.asc_setViewMode(!this.appOptions.isEdit); + this.api.asc_LoadDocument(); }, applyModeCommonElements: function() { @@ -868,6 +875,8 @@ define([ if (me.stackLongActions.exist({id: ApplyEditRights, type: Asc.c_oAscAsyncActionType['BlockInteraction']})) { me.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], ApplyEditRights); } else if (!this._isDocReady) { + Common.NotificationCenter.trigger('app:face', me.appOptions); + me.hidePreloader(); me.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); } @@ -1128,6 +1137,8 @@ define([ this.updateWindowTitle(); + this.api.isDocumentModified() && appHeader.setSaveStatus('changed'); + var toolbarView = this.getApplication().getController('Toolbar').getView('Toolbar'); if (toolbarView) { var isSyncButton = $('.btn-icon', toolbarView.btnSave.cmpEl).hasClass('btn-synch'), @@ -1358,12 +1369,8 @@ define([ return; var me = this, - shapegrouparray = [], - shapeStore = this.getCollection('ShapeGroups'); + shapegrouparray = []; - shapeStore.reset(); - - var groupscount = groupNames.length; _.each(groupNames, function(groupName, index){ var store = new Backbone.Collection([], { model: PE.Models.ShapeModel @@ -1391,11 +1398,7 @@ define([ }); }); - shapeStore.add(shapegrouparray); - - setTimeout(function(){ - me.getApplication().getController('Toolbar').fillAutoShapes(); - }, 50); + this.getCollection('ShapeGroups').reset(shapegrouparray); }, fillLayoutsStore: function(layouts){ @@ -1440,10 +1443,6 @@ define([ }); artStore.reset(arr); - setTimeout(function(){ - me.getApplication().getController('Toolbar').fillTextArt(); - }, 50); - setTimeout(function(){ me.getApplication().getController('RightMenu').fillTextArt(); }, 50); @@ -1503,11 +1502,11 @@ define([ }, onMeta: function(meta) { - var app = this.getApplication(), - filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file'); appHeader.setDocumentCaption(meta.title); this.updateWindowTitle(true); this.document.title = meta.title; + + var filemenu = this.getApplication().getController('LeftMenu').getView('LeftMenu').getMenu('file'); filemenu.loadDocument({doc:this.document}); filemenu.panels['info'].updateInfo(this.document); Common.Gateway.metaChange(meta); @@ -1760,8 +1759,6 @@ define([ criticalErrorExtText: 'Press "Ok" to to back to document list.', openTitleText: 'Opening Document', openTextText: 'Opening document...', - saveTitleText: 'Saving Document', - saveTextText: 'Saving document...', loadFontsTitleText: 'Loading Data', loadFontsTextText: 'Loading data...', loadImagesTitleText: 'Loading Images', @@ -1888,7 +1885,6 @@ define([ errorAccessDeny: 'You are trying to perform an action you do not have rights for.
Please contact your Document Server administrator.', titleServerVersion: 'Editor updated', errorServerVersion: 'The editor version has been updated. The page will be reloaded to apply the changes.', - textChangesSaved: 'All changes saved', errorBadImageUrl: 'Image url is incorrect' } })(), PE.Controllers.Main || {})) diff --git a/apps/presentationeditor/main/app/controller/Statusbar.js b/apps/presentationeditor/main/app/controller/Statusbar.js index ae5e6480a..b6d92e1da 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -72,9 +72,7 @@ define([ }, onLaunch: function() { - this.statusbar = this.createView('Statusbar', { - storeUsers: this.getApplication().getCollection('Common.Collections.Users') - }).render(); + this.statusbar = this.createView('Statusbar', {}).render(); this.statusbar.$el.css('z-index', 1); this.bindViewEvents(this.statusbar, this.events); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 44cb29368..e8e2bc085 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -114,7 +114,16 @@ define([ this.addListeners({ 'Toolbar': { - 'changecompact' : this.onChangeCompactView + 'view:compact' : this.onChangeCompactView, + 'insert:image' : this.onInsertImageClick.bind(this), + 'insert:text' : this.onInsertText.bind(this), + 'insert:textart' : this.onInsertTextart.bind(this), + 'insert:shape' : this.onInsertShape.bind(this) + }, + 'FileMenu': { + 'filemenu:hide': function () { + this.toolbar.setTab(''); + }.bind(this) } }); @@ -128,15 +137,17 @@ define([ btn_id = cmp.closest('.btn-group').attr('id'); if (cmp.attr('id') != 'editor_sdk' && cmp_sdk.length<=0) { - if ( me.toolbar.btnInsertText.pressed && btn_id != me.toolbar.btnInsertText.id || - me.toolbar.btnInsertShape.pressed && btn_id != me.toolbar.btnInsertShape.id ) { + if ( me.toolbar.btnsInsertText.pressed && !me.toolbar.btnsInsertText.contains(btn_id) || + me.toolbar.btnsInsertShape.pressed && !me.toolbar.btnsInsertShape.contains(btn_id) ) + { me._isAddingShape = false; me._addAutoshape(false); - me.toolbar.btnInsertShape.toggle(false, true); - me.toolbar.btnInsertText.toggle(false, true); + me.toolbar.btnsInsertShape.toggle(false, true); + me.toolbar.btnsInsertText.toggle(false, true); Common.NotificationCenter.trigger('edit:complete', me.toolbar); - } else if ( me.toolbar.btnInsertShape.pressed && btn_id == me.toolbar.btnInsertShape.id) { + } else + if ( me.toolbar.btnsInsertShape.pressed && me.toolbar.btnsInsertShape.contains(btn_id) ) { _.defer(function(){ me.api.StartAddShape('', false); Common.NotificationCenter.trigger('edit:complete', me.toolbar); @@ -148,11 +159,11 @@ define([ this.onApiEndAddShape = function() { this.toolbar.fireEvent('insertshape', this.toolbar); - if (this.toolbar.btnInsertShape.pressed) - this.toolbar.btnInsertShape.toggle(false, true); + if ( this.toolbar.btnsInsertShape.pressed ) + this.toolbar.btnsInsertShape.toggle(false, true); - if (this.toolbar.btnInsertText.pressed) - this.toolbar.btnInsertText.toggle(false, true); + if ( this.toolbar.btnsInsertText.pressed ) + this.toolbar.btnsInsertText.toggle(false, true); $(document.body).off('mouseup', checkInsertAutoshape); }; @@ -175,6 +186,18 @@ define([ this.toolbar = this.createView('Toolbar'); // this.toolbar.on('render:after', _.bind(this.onToolbarAfterRender, this)); + + var me = this; + Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me)); + Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me)); + + PE.getCollection('Common.Collections.TextArt').bind({ + reset: me.onResetTextArt.bind(this) + }); + + PE.getCollection('ShapeGroups').bind({ + reset: me.onResetAutoshapes.bind(this) + }); }, onToolbarAfterRender: function(toolbar) { @@ -182,8 +205,6 @@ define([ * UI Events */ - toolbar.btnNewDocument.on('click', _.bind(this.onNewDocument, this)); - toolbar.btnOpenDocument.on('click', _.bind(this.onOpenDocument, this)); toolbar.btnAddSlide.on('click', _.bind(this.onBtnAddSlide, this)); toolbar.mnuAddSlidePicker.on('item:click', _.bind(this.onAddSlide, this)); if (toolbar.mnuChangeSlidePicker) @@ -231,10 +252,6 @@ define([ toolbar.btnInsertHyperlink.on('click', _.bind(this.onHyperlinkClick, this)); toolbar.mnuTablePicker.on('select', _.bind(this.onTablePickerSelect, this)); toolbar.btnInsertTable.menu.on('item:click', _.bind(this.onInsertTableClick, this)); - toolbar.btnInsertImage.menu.on('item:click', _.bind(this.onInsertImageClick, this)); - toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); - toolbar.btnInsertText.menu.on('item:click', _.bind(this.onInsertTextClick, this)); - toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnClearStyle.on('click', _.bind(this.onClearStyleClick, this)); toolbar.btnCopyStyle.on('toggle', _.bind(this.onCopyStyleToggle, this)); toolbar.btnAdvSettings.on('click', _.bind(this.onAdvSettingsClick, this)); @@ -299,13 +316,9 @@ define([ }, onChangeCompactView: function(view, compact) { - Common.localStorage.setItem('pe-compact-toolbar', compact ? 1 : 0); - - if (!compact && !this._state.changeslide_inited) { - this.toolbar.mnuChangeSlidePicker.on('item:click', _.bind(this.onChangeSlide, this)); - } - this._state.changeslide_inited = true; + this.toolbar.setFolded(compact); + Common.localStorage.setBool('pe-compact-toolbar', compact); Common.NotificationCenter.trigger('layout:changed', 'toolbar'); Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, @@ -552,10 +565,12 @@ define([ this.toolbar.lockToolbar(PE.enumLock.noSlides, this._state.no_slides, {array: this.toolbar.paragraphControls}); this.toolbar.lockToolbar(PE.enumLock.noSlides, this._state.no_slides, {array: [ this.toolbar.btnChangeSlide, this.toolbar.btnPreview, this.toolbar.btnCopy, this.toolbar.btnPaste, - this.toolbar.btnCopyStyle, this.toolbar.btnInsertTable, this.toolbar.btnInsertImage, this.toolbar.btnInsertChart, - this.toolbar.btnInsertText, this.toolbar.btnInsertShape, this.toolbar.btnColorSchemas, this.toolbar.btnShapeAlign, + this.toolbar.btnCopyStyle, this.toolbar.btnInsertTable, this.toolbar.btnInsertChart, + this.toolbar.btnColorSchemas, this.toolbar.btnShapeAlign, this.toolbar.btnShapeArrange, this.toolbar.btnSlideSize, this.toolbar.listTheme ]}); + this.toolbar.lockToolbar(PE.enumLock.noSlides, this._state.no_slides, + { array: this.toolbar.btnsInsertImage.concat(this.toolbar.btnsInsertText, this.toolbar.btnsInsertShape) }); } }, @@ -1312,19 +1327,16 @@ define([ } }, - onInsertImageClick: function(menu, item, e) { - if (item.value === 'file') { - this.toolbar.fireEvent('insertimage', this.toolbar); + onInsertImageClick: function(opts, e) { + var me = this; + if (opts === 'file') { + me.toolbar.fireEvent('insertimage', this.toolbar); - if (this.api) - this.api.asc_addImage(); + me.api.asc_addImage(); Common.NotificationCenter.trigger('edit:complete', this.toolbar); - Common.component.Analytics.trackEvent('ToolBar', 'Image'); } else { - var me = this; - (new Common.Views.ImageFromUrlDialog({ handler: function(result, value) { if (result == 'ok') { @@ -1349,38 +1361,54 @@ define([ } }, - onBtnInsertTextClick: function(btn, e) { - if (this.api) - this._addAutoshape(btn.pressed, 'textRect'); + onInsertText: function(status) { + if ( status == 'begin' ) { + this._addAutoshape(true, 'textRect'); - if (this.toolbar.btnInsertShape.pressed) - this.toolbar.btnInsertShape.toggle(false, true); + if ( !this.toolbar.btnsInsertText.pressed ) + this.toolbar.btnsInsertText.toggle(true, true); + } else + this._addAutoshape(false, 'textRect'); - Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertShape); + if ( this.toolbar.btnsInsertShape.pressed ) + this.toolbar.btnsInsertShape.toggle(false, true); + + Common.NotificationCenter.trigger('edit:complete', this.toolbar); Common.component.Analytics.trackEvent('ToolBar', 'Add Text'); }, - onInsertTextClick: function(menu, item, e) { - if (item.value === 'text') { - if (this.api) - this._addAutoshape(true, 'textRect'); - this.toolbar.btnInsertText.toggle(true, true); + onInsertShape: function (type) { + var me = this; + if ( type == 'menu:hide' ) { + if ( me.toolbar.btnsInsertShape.pressed && !me._isAddingShape ) { + me.toolbar.btnsInsertShape.toggle(false, true); + } + me._isAddingShape = false; - if (this.toolbar.btnInsertShape.pressed) - this.toolbar.btnInsertShape.toggle(false, true); + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } else { + me._addAutoshape(true, type); + me._isAddingShape = true; - Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertShape); - Common.component.Analytics.trackEvent('ToolBar', 'Add Text'); + if ( me.toolbar.btnsInsertText.pressed ) + me.toolbar.btnsInsertText.toggle(false, true); + + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Add Shape'); } }, - - onInsertShapeHide: function(btn, e) { - if (this.toolbar.btnInsertShape.pressed && !this._isAddingShape) { - this.toolbar.btnInsertShape.toggle(false, true); - } - this._isAddingShape = false; - Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertShape); + onInsertTextart: function (data) { + var me = this; + + me.toolbar.fireEvent('inserttextart', me.toolbar); + me.api.AddTextArt(data); + + if ( me.toolbar.btnsInsertShape.pressed ) + me.toolbar.btnsInsertShape.toggle(false, true); + + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art'); }, onClearStyleClick: function(btn, e) { @@ -1654,88 +1682,18 @@ define([ this._state.clrtext_asccolor = color; }, - fillAutoShapes: function() { - var me = this, - shapesStore = this.getApplication().getCollection('ShapeGroups'); - - for (var i = 0; i < shapesStore.length; i++) { - var shapeGroup = shapesStore.at(i); - - var menuItem = new Common.UI.MenuItem({ - caption: shapeGroup.get('groupName'), - menu: new Common.UI.Menu({ - menuAlign: 'tl-tr', - items: [ - { template: _.template('') } - ] - }) - }); - - me.toolbar.btnInsertShape.menu.addItem(menuItem); - - var shapePicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-shapegroup' + i), - store: shapeGroup.get('groupStore'), - parentMenu: menuItem.menu, - showLast: false, - itemTemplate: _.template('
') - }); - - shapePicker.on('item:click', function(picker, item, record, e) { - if (me.api) { - me._addAutoshape(true, record.get('data').shapeType); - me._isAddingShape = true; - - if (me.toolbar.btnInsertText.pressed) { - me.toolbar.btnInsertText.toggle(false, true); - } - if (e.type !== 'click') - me.toolbar.btnInsertShape.menu.hide(); - Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertShape); - Common.component.Analytics.trackEvent('ToolBar', 'Add Shape'); - } - }); - } + onResetAutoshapes: function () { + setTimeout(function () { + this.toolbar.updateAutoshapeMenu(PE.getCollection('ShapeGroups')); + }.bind(this), 0); }, - fillTextArt: function() { - var me = this; - - if (this.toolbar.mnuTextArtPicker) { - var models = this.getApplication().getCollection('Common.Collections.TextArt').models, - count = this.toolbar.mnuTextArtPicker.store.length; - if (count>0 && count==models.length) { - var data = this.toolbar.mnuTextArtPicker.store.models; - _.each(models, function(template, index){ - data[index].set('imageUrl', template.get('imageUrl')); - }); - } else { - this.toolbar.mnuTextArtPicker.store.reset(models); - } - } else { - this.toolbar.mnuTextArtPicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-insart'), - store: this.getApplication().getCollection('Common.Collections.TextArt'), - parentMenu: this.toolbar.mnuInsertTextArt.menu, - showLast: false, - itemTemplate: _.template('
') - }); - - this.toolbar.mnuTextArtPicker.on('item:click', function(picker, item, record, e) { - if (me.api) { - me.toolbar.fireEvent('inserttextart', me.toolbar); - me.api.AddTextArt(record.get('data')); - - if (me.toolbar.btnInsertShape.pressed) - me.toolbar.btnInsertShape.toggle(false, true); - - if (e.type !== 'click') - me.toolbar.btnInsertText.menu.hide(); - Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertText); - Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art'); - } - }); - } + onResetTextArt: function (collection, opts) { + (new Promise(function (resolve, reject) { + resolve(); + })).then(function () { + this.toolbar.updateTextartMenu(collection); + }.bind(this)); }, fillEquations: function() { @@ -1796,11 +1754,11 @@ define([ if (me.api) { me.api.asc_AddMath(record.get('data').equationType); - if (me.toolbar.btnInsertText.pressed) { - me.toolbar.btnInsertText.toggle(false, true); + if (me.toolbar.btnsInsertText.pressed) { + me.toolbar.btnsInsertText.toggle(false, true); } - if (me.toolbar.btnInsertShape.pressed) { - me.toolbar.btnInsertShape.toggle(false, true); + if (me.toolbar.btnsInsertShape.pressed) { + me.toolbar.btnsInsertShape.toggle(false, true); } if (e.type !== 'click') @@ -2074,6 +2032,61 @@ define([ this.onToolbarAfterRender(this.toolbar); }, + onAppShowed: function (config) { + var me = this; + + var compactview = !config.isEdit; + if ( config.isEdit ) { + if ( Common.localStorage.itemExists("pe-compact-toolbar") ) { + compactview = Common.localStorage.getBool("pe-compact-toolbar"); + } else + if ( config.customization && config.customization.compactToolbar ) + compactview = true; + } + + me.toolbar.render(_.extend({compactview: compactview}, config)); + }, + + onAppReady: function (config) { + var me = this; + + if ( config.canComments ) { + var _btnsComment = []; + var slots = me.toolbar.$el.find('.slot-comment'); + slots.each(function(index, el) { + var _cls = 'btn-toolbar'; + /x-huge/.test(el.className) && (_cls += ' x-huge icon-top'); + + var button = new Common.UI.Button({ + cls: _cls, + iconCls: 'btn-menu-comments', + caption: 'Comment' + }).render( slots.eq(index) ); + + _btnsComment.push(button); + }); + + if ( _btnsComment.length ) { + var _comments = PE.getController('Common.Controllers.Comments').getView(); + // Array.prototype.push.apply(me.toolbar.toolbarControls, _btnsComment); + _btnsComment.forEach(function (btn) { + btn.updateHint( _comments.textAddComment ); + btn.on('click', function (btn, e) { + Common.NotificationCenter.trigger('app:comment:add', 'toolbar'); + }); + }, this); + } + } + + (new Promise(function(accept) { + accept(); + })).then(function () { + if ( config.isEdit ) { + me.toolbar.onAppReady(config); + } + }); + }, + textEmptyImgUrl : 'You need to specify image URL.', textWarning : 'Warning', textFontSizeErr : 'The entered value must be more than 0', diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index c67b4a1f4..50371dc51 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -65,8 +65,25 @@ define([ // When controller is created let's setup view event listeners initialize: function() { + var me = this; + // This most important part when we will tell our controller what events should be handled this.addListeners({ + 'Toolbar': { + 'render:before' : function (toolbar) { + toolbar.setExtra('right', me.header.getPanel('right')); + toolbar.setExtra('left', me.header.getPanel('left')); + }, + 'view:compact' : function (toolbar, state) { + me.viewport.vlayout.panels[0].height = state ? 40 : 40+67; + } + }, + 'Common.Views.Header': { + 'go:back': function (opts) { + Common.NotificationCenter.trigger('goback', /new/.test(opts)); + // Common.component.Analytics.trackEvent('Back to Folder'); + } + }, // Events generated by main view 'Viewport': { @@ -84,8 +101,9 @@ define([ // Create and render main view this.viewport = this.createView('Viewport').render(); this.header = this.createView('Common.Views.Header', { - headerCaption: 'Presentation Editor' - }).render(); + headerCaption: 'Presentation Editor', + storeUsers: PE.getCollection('Common.Collections.Users') + }); this.docPreview = this.createView('DocumentPreview', {}).render(); Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this)); @@ -96,8 +114,22 @@ define([ this.api.Resize(); Common.localStorage.setItem('pe-mainmenu-width',leftPanel.width()); }, this); + + Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this)); }, + onAppShowed: function (config) { + var me = this; + + if ( !config.isEdit || + ( !Common.localStorage.itemExists("pe-compact-toolbar") && + config.customization && config.customization.compactToolbar )) + { + me.viewport.vlayout.panels[0].height = 40; + } + }, + + onLayoutChanged: function(area) { switch (area) { default: diff --git a/apps/presentationeditor/main/app/template/LeftMenu.template b/apps/presentationeditor/main/app/template/LeftMenu.template index 064780aac..408883566 100644 --- a/apps/presentationeditor/main/app/template/LeftMenu.template +++ b/apps/presentationeditor/main/app/template/LeftMenu.template @@ -1,6 +1,5 @@
- diff --git a/apps/presentationeditor/main/app/template/Toolbar.template b/apps/presentationeditor/main/app/template/Toolbar.template index aa3993020..f5bd9782d 100644 --- a/apps/presentationeditor/main/app/template/Toolbar.template +++ b/apps/presentationeditor/main/app/template/Toolbar.template @@ -1,211 +1,155 @@ -
- - - -
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
-
- - -
-
-
-
- - - - -
-
-
-
-
- - - - - -
-
-
-
-
- - -
-
-
-
-
- - - - - - -
-
-
-
-
- -
-
-
-
-
-
- +
+
+
+
+ + < + + + + > + +
+
+
+
+
+
+
+ +
+
+ +
-
-
-
- - - -
-
-
- -
-
- -
-
-
-
-
- -
-
-
-
- -
-
- -
-
-
-
-
- -
-
- -
-
-
-
-
- - -
-
- - -
-
-
-
-
- - -
-
- - - - - - - -
-
-
-
-
- - - - -
-
- - - -
-
-
-
-
- - - - -
-
- - - -
-
-
-
-
- -
-
- -
-
-
-
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
- -
-
-
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+ + +
+
+
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+ +
+
+ +
+
+
+
+
+ + +
+
+ + + + + + + +
+
+
+
+
+ + + + +
+
+ + + +
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+ + + + +
+
+
+ + +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/apps/presentationeditor/main/app/template/Viewport.template b/apps/presentationeditor/main/app/template/Viewport.template index 8c9e0cad9..2a5121016 100644 --- a/apps/presentationeditor/main/app/template/Viewport.template +++ b/apps/presentationeditor/main/app/template/Viewport.template @@ -1,12 +1,13 @@
+
+ +
-
-
+
-
diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index d8e5e36c6..513122bb9 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -49,6 +49,7 @@ define([ PE.Views.FileMenu = Common.UI.BaseView.extend(_.extend({ el: '#file-menu-panel', + options: {alias:'FileMenu'}, template: _.template(tpl), @@ -195,13 +196,11 @@ define([ panel = this.active || ((this.mode.canDownload && (!this.mode.isDesktopApp || !this.mode.isOffline)) ? 'saveas' : 'info'); this.$el.show(); this.selectMenu(panel); - if (this.mode.isEdit) PE.getController('Toolbar').DisableToolbar(true); this.api.asc_enableKeyEvents(false); }, hide: function() { this.$el.hide(); - if (this.mode.isEdit) PE.getController('Toolbar').DisableToolbar(false); this.fireEvent('filemenu:hide', [this]); this.api.asc_enableKeyEvents(true); }, @@ -312,6 +311,10 @@ define([ this.panels['info'].updateInfo(this.document); }, + isVisible: function () { + return !this.$el.is(':hidden'); + }, + btnSaveCaption : 'Save', btnDownloadCaption : 'Download as...', btnInfoCaption : 'Document Info...', diff --git a/apps/presentationeditor/main/app/view/LeftMenu.js b/apps/presentationeditor/main/app/view/LeftMenu.js index ad7bdf4ae..24b70ed54 100644 --- a/apps/presentationeditor/main/app/view/LeftMenu.js +++ b/apps/presentationeditor/main/app/view/LeftMenu.js @@ -90,15 +90,6 @@ define([ 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'), @@ -169,13 +160,10 @@ define([ this.btnSearch.on('click', _.bind(this.onBtnMenuClick, this)); this.btnThumbs.on('click', _.bind(this.onBtnMenuClick, this)); this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); - this.btnFile.on('toggle', _.bind(this.onBtnMenuToggle, this)); this.btnAbout.on('click', _.bind(this.onFullMenuClick, this)); - this.btnFile.on('click', _.bind(this.onFullMenuClick, this)); - var menuFile = new PE.Views.FileMenu({}); - menuFile.options = {alias:'FileMenu'}; - this.btnFile.panel = menuFile.render(); + this.menuFile = new PE.Views.FileMenu({}); + this.menuFile.render(); this.btnAbout.panel = (new Common.Views.About({el: $('#about-menu-panel'), appName: 'Presentation Editor'})).render(); return this; @@ -196,12 +184,11 @@ define([ }, onBtnMenuClick: function(btn, e) { - var full_menu_pressed = (this.btnFile.pressed || this.btnAbout.pressed); - if (this.btnFile.pressed) this.btnFile.toggle(false); + var full_menu_pressed = this.btnAbout.pressed; if (this.btnAbout.pressed) this.btnAbout.toggle(false); if (btn.options.action == 'search') { - full_menu_pressed && this.fireEvent('panel:show', [this.btnFile, 'files', false]); + full_menu_pressed && this.fireEvent('panel:show', [this.btnAbout, 'files', false]); return; } else if (btn.options.action == 'thumbs') { @@ -282,7 +269,6 @@ define([ /** coauthoring end **/ close: function(menu) { - this.btnFile.toggle(false); this.btnAbout.toggle(false); this.btnThumbs.toggle(false); this.$el.width(SCALE_MIN); @@ -308,7 +294,7 @@ define([ }, isOpened: function() { - var isopened = this.btnFile.pressed || this.btnSearch.pressed; + var isopened = this.btnSearch.pressed; /** coauthoring begin **/ !isopened && (isopened = this.btnComments.pressed || this.btnChat.pressed); /** coauthoring end **/ @@ -316,7 +302,6 @@ define([ }, disableMenu: function(menu, disable) { - this.btnFile.setDisabled(disable); this.btnSearch.setDisabled(disable); this.btnThumbs.setDisabled(disable); this.btnAbout.setDisabled(disable); @@ -330,12 +315,8 @@ define([ showMenu: function(menu) { var re = /^(\w+):?(\w*)$/.exec(menu); - if (re[1] == 'file' && this.btnFile.isVisible()) { - if (!this.btnFile.pressed) { - this.btnFile.toggle(true); -// this.onBtnMenuClick(this.btnFile); - } - this.btnFile.panel.show(re[2].length ? re[2] : undefined); + if ( re[1] == 'file' ) { + this.menuFile.show(re[2].length ? re[2] : undefined); } else { /** coauthoring begin **/ if (menu == 'chat') { @@ -362,7 +343,7 @@ define([ getMenu: function(type) { switch (type) { default: return null; - case 'file': return this.btnFile.panel; + case 'file': return this.menuFile; case 'about': return this.btnAbout.panel; } }, @@ -398,7 +379,6 @@ define([ /** coauthoring end **/ tipAbout : 'About', tipSupport : 'Feedback & Support', - tipFile : 'File', tipSearch : 'Search', tipSlides: 'Slides', tipPlugins : 'Plugins', diff --git a/apps/presentationeditor/main/app/view/Statusbar.js b/apps/presentationeditor/main/app/view/Statusbar.js index 6723eae1f..b43d3f0f6 100644 --- a/apps/presentationeditor/main/app/view/Statusbar.js +++ b/apps/presentationeditor/main/app/view/Statusbar.js @@ -70,22 +70,7 @@ define([ el: '#statusbar', template: _.template(template), - storeUsers: undefined, - - tplUser: ['
  • " class="<% if (!user.get("online")) { %> offline <% } if (user.get("view")) {%> viewmode <% } %>">', - '
    ;" >', - '', - '
    ', - '
  • '].join(''), - - templateUserList: _.template('
      ' + - '<% _.each(users, function(item) { %>' + - '<%= _.template(usertpl, {user: item, scope: scope}) %>' + - '<% }); %>' + - '
    '), - - events: { - }, + events: {}, api: undefined, pages: undefined, @@ -164,39 +149,6 @@ define([ this.zoomMenu.render($('.cnt-zoom',this.el)); this.zoomMenu.cmpEl.attr({tabindex: -1}); - /** coauthoring begin **/ - this.panelUsersList = $('#status-users-list', this.el); - this.storeUsers.bind({ - add : _.bind(this._onAddUser, this), - change : _.bind(this._onUsersChanged, this), - reset : _.bind(this._onResetUsers, this) - }); - - this.panelUsers = $('#status-users-ct', this.el); - this.panelUsers.on('shown.bs.dropdown', function () { - me.panelUsersList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true}); - var tip = me.panelUsersBlock.data('bs.tooltip'); - if (tip) tip.hide(); - }); - - this.panelUsersBlock = this.panelUsers.find('#status-users-block'); - this.panelUsersBlock.tooltip({ - title: this.tipAccessRights, - html: true, - placement: 'top' - }); - this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this)); - - this.lblUserCount = this.panelUsers.find('#status-users-count'); - - this.lblChangeRights = this.panelUsers.find('#status-change-rights'); - this.lblChangeRights.on('click', _.bind(this.onUsersClick, this)); - - this.$el.find('#status-users-menu').on('click', function() { - return false; - }); - /** coauthoring end **/ - this.txtGoToPage = new Common.UI.InputField({ el : $('#status-goto-page'), allowBlank : true, @@ -280,11 +232,6 @@ define([ 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; @@ -294,8 +241,6 @@ define([ setMode: function(mode) { this.mode = mode; this.$el.find('.el-edit')[this.mode.isEdit?'show':'hide'](); - this.lblChangeRights[(!this.mode.isOffline && this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length)?'show':'hide'](); - this.panelUsers[(!this.mode.isOffline && this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length)?'show':'hide'](); }, setVisible: function(visible) { @@ -304,69 +249,6 @@ define([ : this.hide(); }, - /** coauthoring begin **/ - onUsersClick: function() { - this.panelUsers.removeClass('open'); - this.fireEvent('click:users', this); - }, - - onApiUsersChanged: function(users) { - var length = 0; - _.each(users, function(item){ - if (!item.asc_getView()) - length++; - }); - - this.panelUsers[(length>1 || this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length)?'show':'hide'](); - this.lblUserCount.css({ - 'font-size': (length > 1 ? '11px' : '14px'), - 'font-weight': (length > 1 ? 'bold' : 'normal'), - 'margin-top': (length > 1 ? '0' : '-1px') - }); - this.lblUserCount.text(length > 1 ? length : '+'); - $('#status-users-icon').css('margin-bottom', length > 1 ? '0' : '2px'); - - var usertip = this.panelUsersBlock.data('bs.tooltip'); - if (usertip) { - usertip.options.title = (length > 1) ? this.tipViewUsers : this.tipAccessRights; - usertip.setContent(); - } - (length > 1) ? this.panelUsersBlock.attr('data-toggle', 'dropdown') : this.panelUsersBlock.removeAttr('data-toggle'); - this.panelUsersBlock.toggleClass('dropdown-toggle', length > 1); - (length > 1) ? this.panelUsersBlock.off('click') : this.panelUsersBlock.on('click', _.bind(this.onUsersClick, this)); - }, - - _onAddUser: function(m, c, opts) { - if (this.panelUsersList) { - this.panelUsersList.find('ul').append(_.template(this.tplUser, {user: m, scope: this})); - this.panelUsersList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true}); - } - }, - - _onUsersChanged: function(m) { - if (m.changed.online != undefined && this.panelUsersList) { - this.panelUsersList.find('#status-chat-user-'+ m.get('id'))[m.changed.online?'removeClass':'addClass']('offline'); - this.panelUsersList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true}); - } - }, - - _onResetUsers: function(c, opts) { - if (this.panelUsersList) { - this.panelUsersList.html(this.templateUserList({users: c.models, usertpl: this.tplUser, scope: this})); - this.panelUsersList.scroller = new Common.UI.Scroller({ - el : $('#status-users-list ul'), - useKeyboard : true, - minScrollbarLength : 40, - alwaysVisibleY: true - }); - } - }, - - getUserName: function (username) { - return Common.Utils.String.htmlEncode(username); - }, - /** coauthoring end **/ - showStatusMessage: function(message) { $('#status-label-action').text(message); }, @@ -377,9 +259,6 @@ define([ pageIndexText : 'Slide {0} of {1}', goToPageText : 'Go to Slide', - tipUsers : 'Document is currently being edited by several users.', - tipMoreUsers : 'and %1 users.', - tipShowUsers : 'To see all users click the icon below.', tipFitPage : 'Fit to Slide', tipFitWidth : 'Fit to Width', tipZoomIn : 'Zoom In', @@ -387,9 +266,7 @@ define([ tipZoomFactor : 'Magnification', txtPageNumInvalid: 'Slide number invalid', tipPreview : 'Start Slideshow', - tipAccessRights : 'Manage document access rights', - tipViewUsers : 'View users and manage document access rights', - txAccessRights : 'Change access rights' + tipAccessRights : 'Manage document access rights' }, PE.Views.Statusbar || {})); } ); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 56a3cb5dd..a8a586c4e 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -58,7 +58,7 @@ define([ ,'common/main/lib/component/SynchronizeTip' /** coauthoring end **/ -], function (Backbone, toolbarTemplate) { +], function (Backbone, template) { 'use strict'; PE.enumLock = { @@ -84,323 +84,464 @@ define([ inEquation: 'in-equation' }; - PE.Views.Toolbar = Backbone.View.extend(_.extend({ - el: '#toolbar', + var buttonsArray = function (opts) { + }; - // Compile our stats template - template: _.template(toolbarTemplate), + buttonsArray.prototype = new Array; - // Delegated events for creating new items, and clearing completed ones. - events: { - // - }, + buttonsArray.prototype.disable = function (state) { + this.forEach(function(btn) { + btn.setDisabled(state); + }); + }; - initialize: function () { - var me = this; + buttonsArray.prototype.toggle = function (state, suppress) { + this.forEach(function(btn) { + btn.toggle(state, suppress); + }); + }; - me.paragraphControls = []; - me.shapeControls = []; - me.slideOnlyControls = []; - me.synchTooltip = undefined; - me.schemeNames = [ - me.txtScheme1, me.txtScheme2, me.txtScheme3, me.txtScheme4, me.txtScheme5, - me.txtScheme6, me.txtScheme7, me.txtScheme8, me.txtScheme9, me.txtScheme10, - me.txtScheme11, me.txtScheme12, me.txtScheme13, me.txtScheme14, me.txtScheme15, - me.txtScheme16, me.txtScheme17, me.txtScheme18, me.txtScheme19, me.txtScheme20, - me.txtScheme21 - ]; - me._state = { - hasCollaborativeChanges: undefined - }; - me.btnSaveCls = 'btn-save'; - me.btnSaveTip = this.tipSave + Common.Utils.String.platformKey('Ctrl+S'); + buttonsArray.prototype.pressed = function () { + return this.some(function(btn) { + return btn.pressed; + }); + }; + + buttonsArray.prototype.on = function (event, func) { + this.forEach(function(btn) { + btn.on.apply(btn, arguments); + }); + }; + + buttonsArray.prototype.contains = function (id) { + return this.some(function(btn) { + return btn.id == id; + }); + }; + + PE.Views.Toolbar = Backbone.View.extend(_.extend((function(){ + var $tabs, $boxTabs; + var $panels, $marker, $scrollL; + var lastPanel; + var isFolded = false; + var optsFold = {timeout: 2000}; + + var config = {}; + + function hasTabInvisible() { + var _left_bound_ = $boxTabs.offset().left, + _right_bound_ = _left_bound_ + $boxTabs.width(); + + var tab = $tabs.first().get(0); + var rect = tab.getBoundingClientRect(); + + if (!(rect.left < _left_bound_)) { + tab = $tabs.last().get(0); + rect = tab.getBoundingClientRect(); + + if (!(rect.right > _right_bound_)) + return false; + } + + return true; + } + + function isTabActive(tab) { + var t = $tabs.filter('.active').find('> a'); + return t.length && t.data('tab') == tab; + } + + function onResize(e) { + if ( hasTabInvisible() ){ + if ( !$boxTabs.parent().hasClass('short') ) + $boxTabs.parent().addClass('short'); + } else + if ( $boxTabs.parent().hasClass('short') ) { + $boxTabs.parent().removeClass('short'); + } + } + + function onScrollTabs(opts, e) { + var sv = $boxTabs.scrollLeft(); + if ( sv || opts == 'right') { + $boxTabs.animate({scrollLeft: opts == 'left' ? sv - 100 : sv + 100}, 200); + } + } + + function collapseToolbar() { + optsFold.$bar.removeClass('expanded'); + } + + function expandToolbar() { + clearTimeout(optsFold.timer); + + optsFold.$bar.addClass('expanded'); + optsFold.timer = setTimeout(collapseToolbar, optsFold.timeout); + } + + function onShowCoveredPanel(state) { + collapseToolbar(); + + if ( state ) + optsFold.$bar.addClass('cover'); else + optsFold.$bar.removeClass('cover'); + } + + function setFolded(value) { + isFolded = value; + + if ( isFolded ) { + if ( !optsFold.$bar ) optsFold.$bar = this.$el.find('.toolbar'); + if ( !optsFold.$box ) optsFold.$box = this.$el.find('.box-controls'); + + optsFold.$bar.addClass('folded'); + optsFold.$box.on({ + mouseleave: function (e) { + optsFold.timer = setTimeout(collapseToolbar, optsFold.timeout); + }, + mouseenter: function (e) { + clearTimeout(optsFold.timer); + } + }); + + // $(document.body).on('focus', 'input, textarea', function(e) { + // }); + // + // $(document.body).on('blur', 'input, textarea', function(e) { + // }); + // + // Common.NotificationCenter.on({ + // 'modal:show': function(){ + // }, + // 'modal:close': function(dlg) { + // }, + // 'modal:hide': function(dlg) { + // }, + // 'dataview:focus': function(e){ + // }, + // 'dataview:blur': function(e){ + // }, + // 'menu:show': function(e){ + // }, + // 'menu:hide': function(e){ + // }, + // 'edit:complete': _.bind(me.onEditComplete, me) + // }); + + } else { + clearTimeout(optsFold.timer); + optsFold.$bar.removeClass('folded'); + optsFold.$box.off(); + } + } + + return { + el: '#toolbar', + + // Delegated events for creating new items, and clearing completed ones. + events: { + // + }, + + initialize: function () { + var me = this; + + config.tabs = [ + { caption: 'File', action: 'file'}, + { caption: 'Home', action: 'home', extcls: 'canedit'}, + { caption: 'Insert', action: 'ins', extcls: 'canedit'} ]; + + config.$layout = $(_.template(template, config)); + + me.paragraphControls = []; + me.shapeControls = []; + me.slideOnlyControls = []; + me.synchTooltip = undefined; + me.schemeNames = [ + me.txtScheme1, me.txtScheme2, me.txtScheme3, me.txtScheme4, me.txtScheme5, + me.txtScheme6, me.txtScheme7, me.txtScheme8, me.txtScheme9, me.txtScheme10, + me.txtScheme11, me.txtScheme12, me.txtScheme13, me.txtScheme14, me.txtScheme15, + me.txtScheme16, me.txtScheme17, me.txtScheme18, me.txtScheme19, me.txtScheme20, + me.txtScheme21 + ]; + me._state = { + hasCollaborativeChanges: undefined + }; + me.btnSaveCls = 'btn-save'; + me.btnSaveTip = this.tipSave + Common.Utils.String.platformKey('Ctrl+S'); /** * UI Components */ - var _set = PE.enumLock; - me.btnNewDocument = new Common.UI.Button({ - id : 'id-toolbar-btn-newdocument', - cls : 'btn-toolbar', - iconCls : 'btn-newdocument', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides] - }); - me.paragraphControls.push(me.btnNewDocument); + var _set = PE.enumLock; - me.btnOpenDocument = new Common.UI.Button({ - id : 'id-toolbar-btn-opendocument', - cls : 'btn-toolbar', - iconCls : 'btn-opendocument', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides] - }); - me.paragraphControls.push(me.btnOpenDocument); - - me.btnAddSlide = new Common.UI.Button({ - id : 'id-toolbar-button-add-slide', - cls : 'btn-toolbar', - iconCls : 'btn-addslide', - split : true, - lock : [_set.menuFileOpen, _set.slideDeleted, _set.lostConnect, _set.disableOnStart], - menu : true - }); - me.slideOnlyControls.push(me.btnAddSlide); - - me.btnChangeSlide = new Common.UI.Button({ - id : 'id-toolbar-button-change-slide', - cls : 'btn-toolbar', - iconCls : 'btn-changeslide', - lock : [_set.menuFileOpen, _set.slideDeleted, _set.slideLock, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : true - }); - me.slideOnlyControls.push(me.btnChangeSlide); - - me.btnPreview = new Common.UI.Button({ - id : 'id-toolbar-button-preview', - cls : 'btn-toolbar', - iconCls : 'btn-preview', - lock : [_set.menuFileOpen, _set.slideDeleted, _set.noSlides, _set.disableOnStart], - split : true, - menu : new Common.UI.Menu({ - items : [ - {caption: this.textShowBegin, value: 0}, - {caption: this.textShowCurrent, value: 1}, - {caption: '--'}, - me.mnuShowSettings = new Common.UI.MenuItem({ - caption: this.textShowSettings, - value: 2, - lock: [_set.lostConnect] - }) - ] - }) - }); - me.slideOnlyControls.push(me.btnPreview); - - me.btnPrint = new Common.UI.Button({ - id : 'id-toolbar-btn-print', - cls : 'btn-toolbar', - iconCls : 'btn-print', - lock : [_set.slideDeleted, _set.noSlides, _set.cantPrint] - }); - me.paragraphControls.push(me.btnPrint); - - me.btnSave = new Common.UI.Button({ - id : 'id-toolbar-btn-save', - cls : 'btn-toolbar', - iconCls : me.btnSaveCls, - lock : [_set.lostConnect] - }); - - me.btnUndo = new Common.UI.Button({ - id : 'id-toolbar-btn-undo', - cls : 'btn-toolbar', - iconCls : 'btn-undo', - lock : [_set.undoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] - }); - me.slideOnlyControls.push(me.btnUndo); - - me.btnRedo = new Common.UI.Button({ - id : 'id-toolbar-btn-redo', - cls : 'btn-toolbar', - iconCls : 'btn-redo', - lock : [_set.redoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] - }); - me.slideOnlyControls.push(me.btnRedo); - - me.btnCopy = new Common.UI.Button({ - id : 'id-toolbar-btn-copy', - cls : 'btn-toolbar', - iconCls : 'btn-copy', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart] - }); - me.slideOnlyControls.push(me.btnCopy); - - me.btnPaste = new Common.UI.Button({ - id : 'id-toolbar-btn-paste', - cls : 'btn-toolbar', - iconCls : 'btn-paste', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides] - }); - me.paragraphControls.push(me.btnPaste); - - me.cmbFontName = new Common.UI.ComboBoxFonts({ - cls : 'input-group-nr', - menuCls : 'scrollable-menu', - menuStyle : 'min-width: 325px;', - hint : me.tipFontName, - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - store : new Common.Collections.Fonts() - }); - me.paragraphControls.push(me.cmbFontName); - - me.cmbFontSize = new Common.UI.ComboBox({ - cls : 'input-group-nr', - menuStyle : 'min-width: 55px;', - hint : me.tipFontSize, - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - data : [ - { value: 8, displayValue: "8" }, - { value: 9, displayValue: "9" }, - { value: 10, displayValue: "10" }, - { value: 11, displayValue: "11" }, - { value: 12, displayValue: "12" }, - { value: 14, displayValue: "14" }, - { value: 16, displayValue: "16" }, - { value: 18, displayValue: "18" }, - { value: 20, displayValue: "20" }, - { value: 22, displayValue: "22" }, - { value: 24, displayValue: "24" }, - { value: 26, displayValue: "26" }, - { value: 28, displayValue: "28" }, - { value: 36, displayValue: "36" }, - { value: 48, displayValue: "48" }, - { value: 72, displayValue: "72" } - ] - }); - me.paragraphControls.push(me.cmbFontSize); - - me.btnBold = new Common.UI.Button({ - id : 'id-toolbar-btn-bold', - cls : 'btn-toolbar', - iconCls : 'btn-bold', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - enableToggle: true - }); - me.paragraphControls.push(me.btnBold); - - me.btnItalic = new Common.UI.Button({ - id : 'id-toolbar-btn-italic', - cls : 'btn-toolbar', - iconCls : 'btn-italic', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - enableToggle: true - }); - me.paragraphControls.push(me.btnItalic); - - me.btnUnderline = new Common.UI.Button({ - id : 'id-toolbar-btn-underline', - cls : 'btn-toolbar', - iconCls : 'btn-underline', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - enableToggle: true - }); - me.paragraphControls.push(me.btnUnderline); - - me.btnStrikeout = new Common.UI.Button({ - id : 'id-toolbar-btn-strikeout', - cls : 'btn-toolbar', - iconCls : 'btn-strikeout', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - enableToggle: true - }); - me.paragraphControls.push(me.btnStrikeout); - - me.btnSuperscript = new Common.UI.Button({ - id : 'id-toolbar-btn-superscript', - cls : 'btn-toolbar', - iconCls : 'btn-superscript', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock, _set.inEquation], - enableToggle: true, - toggleGroup : 'superscriptGroup' - }); - me.paragraphControls.push(me.btnSuperscript); - - me.btnSubscript = new Common.UI.Button({ - id : 'id-toolbar-btn-subscript', - cls : 'btn-toolbar', - iconCls : 'btn-subscript', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock, _set.inEquation], - enableToggle: true, - toggleGroup : 'superscriptGroup' - }); - me.paragraphControls.push(me.btnSubscript); - - me.btnFontColor = new Common.UI.Button({ - id : 'id-toolbar-btn-fontcolor', - cls : 'btn-toolbar', - iconCls : 'btn-fontcolor', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], - split : true, - menu : new Common.UI.Menu({ - items: [ - { template: _.template('
    ') }, - { template: _.template('' + me.textNewColor + '') } - ] - }) - }).on('render:after', function(btn) { - var colorVal = $('
    '); - $('button:first-child', btn.cmpEl).append(colorVal); - colorVal.css('background-color', btn.currentColor || 'transparent'); - - me.mnuFontColorPicker = new Common.UI.ThemeColorPalette({ - el: $('#id-toolbar-menu-fontcolor') + me.btnAddSlide = new Common.UI.Button({ + id : 'id-toolbar-button-add-slide', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-addslide', + split : true, + caption : me.capAddSlide, + lock : [_set.menuFileOpen, _set.slideDeleted, _set.lostConnect, _set.disableOnStart], + menu : true }); - }); - me.paragraphControls.push(me.btnFontColor); + me.slideOnlyControls.push(me.btnAddSlide); - me.btnClearStyle = new Common.UI.Button({ - id : 'id-toolbar-btn-clearstyle', - cls : 'btn-toolbar', - iconCls : 'btn-clearstyle', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] - }); - me.paragraphControls.push(me.btnClearStyle); + me.btnChangeSlide = new Common.UI.Button({ + id : 'id-toolbar-button-change-slide', + cls : 'btn-toolbar', + iconCls : 'btn-changeslide', + lock : [_set.menuFileOpen, _set.slideDeleted, _set.slideLock, _set.lostConnect, _set.noSlides, _set.disableOnStart], + menu : true + }); + me.slideOnlyControls.push(me.btnChangeSlide); - me.btnCopyStyle = new Common.UI.Button({ - id : 'id-toolbar-btn-copystyle', - cls : 'btn-toolbar', - iconCls : 'btn-copystyle', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.noParagraphSelected, _set.disableOnStart], - enableToggle: true - }); - me.slideOnlyControls.push(me.btnCopyStyle); + me.btnPreview = new Common.UI.Button({ + id : 'id-toolbar-button-preview', + cls : 'btn-toolbar', + iconCls : 'btn-preview', + lock : [_set.menuFileOpen, _set.slideDeleted, _set.noSlides, _set.disableOnStart], + split : true, + menu : new Common.UI.Menu({ + items : [ + {caption: this.textShowBegin, value: 0}, + {caption: this.textShowCurrent, value: 1}, + {caption: '--'}, + me.mnuShowSettings = new Common.UI.MenuItem({ + caption: this.textShowSettings, + value: 2, + lock: [_set.lostConnect] + }) + ] + }) + }); + me.slideOnlyControls.push(me.btnPreview); - me.btnMarkers = new Common.UI.Button({ - id : 'id-toolbar-btn-markers', - cls : 'btn-toolbar', - iconCls : 'btn-setmarkers', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], - enableToggle: true, - toggleGroup : 'markersGroup', - split : true, - menu : true - }); - me.paragraphControls.push(me.btnMarkers); + me.btnPrint = new Common.UI.Button({ + id : 'id-toolbar-btn-print', + cls : 'btn-toolbar', + iconCls : 'btn-print', + lock : [_set.slideDeleted, _set.noSlides, _set.cantPrint] + }); + me.paragraphControls.push(me.btnPrint); - me.btnNumbers = new Common.UI.Button({ - id : 'id-toolbar-btn-numbering', - cls : 'btn-toolbar', - iconCls : 'btn-numbering', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], - enableToggle: true, - toggleGroup : 'markersGroup', - split : true, - menu : true - }); - me.paragraphControls.push(me.btnNumbers); + me.btnSave = new Common.UI.Button({ + id : 'id-toolbar-btn-save', + cls : 'btn-toolbar', + iconCls : me.btnSaveCls, + lock : [_set.lostConnect] + }); - var clone = function(source) { - var obj = {}; - for (var prop in source) - obj[prop] = (typeof(source[prop])=='object') ? clone(source[prop]) : source[prop]; - return obj; - }; + me.btnUndo = new Common.UI.Button({ + id : 'id-toolbar-btn-undo', + cls : 'btn-toolbar', + iconCls : 'btn-undo', + lock : [_set.undoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] + }); + me.slideOnlyControls.push(me.btnUndo); - this.mnuMarkersPicker = { - conf: {index:0}, - selectByIndex: function (idx) { - this.conf.index = idx; - } - }; - this.mnuNumbersPicker = clone(this.mnuMarkersPicker); + me.btnRedo = new Common.UI.Button({ + id : 'id-toolbar-btn-redo', + cls : 'btn-toolbar', + iconCls : 'btn-redo', + lock : [_set.redoLock, _set.slideDeleted, _set.lostConnect, _set.disableOnStart] + }); + me.slideOnlyControls.push(me.btnRedo); - me.btnHorizontalAlign = new Common.UI.Button({ - id : 'id-toolbar-btn-halign', - cls : 'btn-toolbar', - iconCls : 'btn-align-left', - icls : 'btn-align-left', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], - menu : new Common.UI.Menu({ - items: [ + me.btnCopy = new Common.UI.Button({ + id : 'id-toolbar-btn-copy', + cls : 'btn-toolbar', + iconCls : 'btn-copy', + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart] + }); + me.slideOnlyControls.push(me.btnCopy); + + me.btnPaste = new Common.UI.Button({ + id : 'id-toolbar-btn-paste', + cls : 'btn-toolbar', + iconCls : 'btn-paste', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides] + }); + me.paragraphControls.push(me.btnPaste); + + me.cmbFontName = new Common.UI.ComboBoxFonts({ + cls : 'input-group-nr', + menuCls : 'scrollable-menu', + menuStyle : 'min-width: 325px;', + hint : me.tipFontName, + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + store : new Common.Collections.Fonts() + }); + me.paragraphControls.push(me.cmbFontName); + + me.cmbFontSize = new Common.UI.ComboBox({ + cls : 'input-group-nr', + menuStyle : 'min-width: 55px;', + hint : me.tipFontSize, + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + data : [ + { value: 8, displayValue: "8" }, + { value: 9, displayValue: "9" }, + { value: 10, displayValue: "10" }, + { value: 11, displayValue: "11" }, + { value: 12, displayValue: "12" }, + { value: 14, displayValue: "14" }, + { value: 16, displayValue: "16" }, + { value: 18, displayValue: "18" }, + { value: 20, displayValue: "20" }, + { value: 22, displayValue: "22" }, + { value: 24, displayValue: "24" }, + { value: 26, displayValue: "26" }, + { value: 28, displayValue: "28" }, + { value: 36, displayValue: "36" }, + { value: 48, displayValue: "48" }, + { value: 72, displayValue: "72" } + ] + }); + me.paragraphControls.push(me.cmbFontSize); + + me.btnBold = new Common.UI.Button({ + id : 'id-toolbar-btn-bold', + cls : 'btn-toolbar', + iconCls : 'btn-bold', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + enableToggle: true + }); + me.paragraphControls.push(me.btnBold); + + me.btnItalic = new Common.UI.Button({ + id : 'id-toolbar-btn-italic', + cls : 'btn-toolbar', + iconCls : 'btn-italic', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + enableToggle: true + }); + me.paragraphControls.push(me.btnItalic); + + me.btnUnderline = new Common.UI.Button({ + id : 'id-toolbar-btn-underline', + cls : 'btn-toolbar', + iconCls : 'btn-underline', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + enableToggle: true + }); + me.paragraphControls.push(me.btnUnderline); + + me.btnStrikeout = new Common.UI.Button({ + id : 'id-toolbar-btn-strikeout', + cls : 'btn-toolbar', + iconCls : 'btn-strikeout', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + enableToggle: true + }); + me.paragraphControls.push(me.btnStrikeout); + + me.btnSuperscript = new Common.UI.Button({ + id : 'id-toolbar-btn-superscript', + cls : 'btn-toolbar', + iconCls : 'btn-superscript', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock, _set.inEquation], + enableToggle: true, + toggleGroup : 'superscriptGroup' + }); + me.paragraphControls.push(me.btnSuperscript); + + me.btnSubscript = new Common.UI.Button({ + id : 'id-toolbar-btn-subscript', + cls : 'btn-toolbar', + iconCls : 'btn-subscript', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock, _set.inEquation], + enableToggle: true, + toggleGroup : 'superscriptGroup' + }); + me.paragraphControls.push(me.btnSubscript); + + me.btnFontColor = new Common.UI.Button({ + id : 'id-toolbar-btn-fontcolor', + cls : 'btn-toolbar', + iconCls : 'btn-fontcolor', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noTextSelected, _set.shapeLock], + split : true, + menu : new Common.UI.Menu({ + items: [ + { template: _.template('
    ') }, + { template: _.template('' + me.textNewColor + '') } + ] + }) + }).on('render:after', function(btn) { + var colorVal = $('
    '); + $('button:first-child', btn.cmpEl).append(colorVal); + colorVal.css('background-color', btn.currentColor || 'transparent'); + + me.mnuFontColorPicker = new Common.UI.ThemeColorPalette({ + el: $('#id-toolbar-menu-fontcolor') + }); + }); + me.paragraphControls.push(me.btnFontColor); + + me.btnClearStyle = new Common.UI.Button({ + id : 'id-toolbar-btn-clearstyle', + cls : 'btn-toolbar', + iconCls : 'btn-clearstyle', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] + }); + me.paragraphControls.push(me.btnClearStyle); + + me.btnCopyStyle = new Common.UI.Button({ + id : 'id-toolbar-btn-copystyle', + cls : 'btn-toolbar', + iconCls : 'btn-copystyle', + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.noParagraphSelected, _set.disableOnStart], + enableToggle: true + }); + me.slideOnlyControls.push(me.btnCopyStyle); + + me.btnMarkers = new Common.UI.Button({ + id : 'id-toolbar-btn-markers', + cls : 'btn-toolbar', + iconCls : 'btn-setmarkers', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], + enableToggle: true, + toggleGroup : 'markersGroup', + split : true, + menu : true + }); + me.paragraphControls.push(me.btnMarkers); + + me.btnNumbers = new Common.UI.Button({ + id : 'id-toolbar-btn-numbering', + cls : 'btn-toolbar', + iconCls : 'btn-numbering', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], + enableToggle: true, + toggleGroup : 'markersGroup', + split : true, + menu : true + }); + me.paragraphControls.push(me.btnNumbers); + + var clone = function(source) { + var obj = {}; + for (var prop in source) + obj[prop] = (typeof(source[prop])=='object') ? clone(source[prop]) : source[prop]; + return obj; + }; + + this.mnuMarkersPicker = { + conf: {index:0}, + selectByIndex: function (idx) { + this.conf.index = idx; + } + }; + this.mnuNumbersPicker = clone(this.mnuMarkersPicker); + + me.btnHorizontalAlign = new Common.UI.Button({ + id : 'id-toolbar-btn-halign', + cls : 'btn-toolbar', + iconCls : 'btn-align-left', + icls : 'btn-align-left', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], + menu : new Common.UI.Menu({ + items: [ { caption : me.textAlignLeft + Common.Utils.String.platformKey('Ctrl+L'), iconCls : 'mnu-align-left', @@ -434,1288 +575,1466 @@ define([ toggleGroup : 'halignGroup', value : 3 } - ] - }) - }); - me.paragraphControls.push(me.btnHorizontalAlign); - - me.btnVerticalAlign = new Common.UI.Button({ - id : 'id-toolbar-btn-valign', - cls : 'btn-toolbar', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], - iconCls : 'btn-align-middle', - icls : 'btn-align-middle', - menu : new Common.UI.Menu({ - items: [ - { - caption : me.textAlignTop, - iconCls : 'mnu-align-top', - icls : 'btn-align-top', - checkable : true, - toggleGroup : 'valignGroup', - value : Asc.c_oAscVAlign.Top - }, - { - caption : me.textAlignMiddle, - iconCls : 'mnu-align-middle', - icls : 'btn-align-middle', - checkable : true, - toggleGroup : 'valignGroup', - value : Asc.c_oAscVAlign.Center, - checked : true - }, - { - caption : me.textAlignBottom, - iconCls : 'mnu-align-bottom', - icls : 'btn-align-bottom', - checkable : true, - toggleGroup : 'valignGroup', - value : Asc.c_oAscVAlign.Bottom - } - ] - }) - }); - me.paragraphControls.push(me.btnVerticalAlign); - - me.btnDecLeftOffset = new Common.UI.Button({ - id : 'id-toolbar-btn-decoffset', - cls : 'btn-toolbar', - iconCls : 'btn-decoffset', - lock : [_set.decIndentLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] - }); - me.paragraphControls.push(me.btnDecLeftOffset); - - me.btnIncLeftOffset = new Common.UI.Button({ - id : 'id-toolbar-btn-incoffset', - cls : 'btn-toolbar', - iconCls : 'btn-incoffset', - lock : [_set.incIndentLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] - }); - me.paragraphControls.push(me.btnIncLeftOffset); - - me.btnLineSpace = new Common.UI.Button({ - id : 'id-toolbar-btn-linespace', - cls : 'btn-toolbar', - iconCls : 'btn-linespace', - lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], - menu : new Common.UI.Menu({ - style: 'min-width: 60px;', - items: [ - { caption: '1.0', value: 1.0, checkable: true, toggleGroup: 'linesize' }, - { caption: '1.15', value: 1.15, checkable: true, toggleGroup: 'linesize' }, - { caption: '1.5', value: 1.5, checkable: true, toggleGroup: 'linesize' }, - { caption: '2.0', value: 2.0, checkable: true, toggleGroup: 'linesize' }, - { caption: '2.5', value: 2.5, checkable: true, toggleGroup: 'linesize' }, - { caption: '3.0', value: 3.0, checkable: true, toggleGroup: 'linesize' } - ] - }) - }); - me.paragraphControls.push(me.btnLineSpace); - - me.btnInsertTable = new Common.UI.Button({ - id : 'id-toolbar-btn-inserttable', - cls : 'btn-toolbar', - iconCls : 'btn-inserttable', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : new Common.UI.Menu({ - items: [ - { template: _.template('
    ') }, - { caption: me.mniCustomTable, value: 'custom' } - ] - }) - }).on('render:after', function(btn) { - me.mnuTablePicker = new Common.UI.DimensionPicker({ - el : $('#id-toolbar-menu-tablepicker'), - minRows : 8, - minColumns : 10, - maxRows : 8, - maxColumns : 10 + ] + }) }); - }); - me.slideOnlyControls.push(me.btnInsertTable); + me.paragraphControls.push(me.btnHorizontalAlign); - me.btnInsertImage = new Common.UI.Button({ - id : 'id-toolbar-btn-insertimage', - cls : 'btn-toolbar', - iconCls : 'btn-insertimage', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : new Common.UI.Menu({ - items: [ - { caption: me.mniImageFromFile, value: 'file' }, - { caption: me.mniImageFromUrl, value: 'url' } - ] - }) - }); - me.slideOnlyControls.push(me.btnInsertImage); + me.btnVerticalAlign = new Common.UI.Button({ + id : 'id-toolbar-btn-valign', + cls : 'btn-toolbar', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], + iconCls : 'btn-align-middle', + icls : 'btn-align-middle', + menu : new Common.UI.Menu({ + items: [ + { + caption : me.textAlignTop, + iconCls : 'mnu-align-top', + icls : 'btn-align-top', + checkable : true, + toggleGroup : 'valignGroup', + value : Asc.c_oAscVAlign.Top + }, + { + caption : me.textAlignMiddle, + iconCls : 'mnu-align-middle', + icls : 'btn-align-middle', + checkable : true, + toggleGroup : 'valignGroup', + value : Asc.c_oAscVAlign.Center, + checked : true + }, + { + caption : me.textAlignBottom, + iconCls : 'mnu-align-bottom', + icls : 'btn-align-bottom', + checkable : true, + toggleGroup : 'valignGroup', + value : Asc.c_oAscVAlign.Bottom + } + ] + }) + }); + me.paragraphControls.push(me.btnVerticalAlign); - me.btnInsertChart = new Common.UI.Button({ - id : 'id-toolbar-btn-insertchart', - cls : 'btn-toolbar', - iconCls : 'btn-insertchart', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : new Common.UI.Menu({ - style: 'width: 435px;', - items: [ - { template: _.template('') } - ] - }) - }).on('render:after', function(btn) { - me.mnuInsertChartPicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-insertchart'), - parentMenu: btn.menu, - showLast: false, - restoreHeight: 421, - groups: new Common.UI.DataViewGroupStore([ - { id: 'menu-chart-group-bar', caption: me.textColumn, headername: me.textCharts }, - { 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, inline: true }, - { id: 'menu-chart-group-scatter', caption: me.textPoint, inline: true }, - { id: 'menu-chart-group-stock', caption: me.textStock, inline: true } - ]), - store: new Common.UI.DataViewStore([ - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal, allowSelected: true, iconCls: 'column-normal', selected: true}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked, allowSelected: true, iconCls: 'column-stack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer, allowSelected: true, iconCls: 'column-pstack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3d, allowSelected: true, iconCls: 'column-3d-normal'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked3d, allowSelected: true, iconCls: 'column-3d-stack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer3d, allowSelected: true, iconCls: 'column-3d-pstack'}, - { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3dPerspective, allowSelected: true, iconCls: 'column-3d-normal-per'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineNormal, allowSelected: true, iconCls: 'line-normal'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStacked, allowSelected: true, iconCls: 'line-stack'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStackedPer, allowSelected: true, iconCls: 'line-pstack'}, - { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.line3d, allowSelected: true, iconCls: 'line-3d'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie, allowSelected: true, iconCls: 'pie-normal'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.doughnut, allowSelected: true, iconCls: 'pie-doughnut'}, - { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie3d, allowSelected: true, iconCls: 'pie-3d-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal, allowSelected: true, iconCls: 'bar-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked, allowSelected: true, iconCls: 'bar-stack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer, allowSelected: true, iconCls: 'bar-pstack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal3d, allowSelected: true, iconCls: 'bar-3d-normal'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked3d, allowSelected: true, iconCls: 'bar-3d-stack'}, - { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer3d, allowSelected: true, iconCls: 'bar-3d-pstack'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaNormal, allowSelected: true, iconCls: 'area-normal'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStacked, allowSelected: true, iconCls: 'area-stack'}, - { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStackedPer, allowSelected: true, iconCls: 'area-pstack'}, - { group: 'menu-chart-group-scatter', type: Asc.c_oAscChartTypeSettings.scatter, allowSelected: true, iconCls: 'point-normal'}, - { group: 'menu-chart-group-stock', type: Asc.c_oAscChartTypeSettings.stock, allowSelected: true, iconCls: 'stock-normal'} - ]), - itemTemplate: _.template('
    ') - }) - }); + me.btnDecLeftOffset = new Common.UI.Button({ + id : 'id-toolbar-btn-decoffset', + cls : 'btn-toolbar', + iconCls : 'btn-decoffset', + lock : [_set.decIndentLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] + }); + me.paragraphControls.push(me.btnDecLeftOffset); - me.slideOnlyControls.push(me.btnInsertChart); + me.btnIncLeftOffset = new Common.UI.Button({ + id : 'id-toolbar-btn-incoffset', + cls : 'btn-toolbar', + iconCls : 'btn-incoffset', + lock : [_set.incIndentLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] + }); + me.paragraphControls.push(me.btnIncLeftOffset); - me.btnInsertText = new Common.UI.Button({ - id : 'id-toolbar-btn-inserttext', - cls : 'btn-toolbar', - iconCls : 'btn-inserttext', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - enableToggle: true, - split : true, - menu : new Common.UI.Menu({ - items : [ - {caption: this.textInsText, value: 'text'}, - this.mnuInsertTextArt = new Common.UI.MenuItem({ - caption: this.textInsTextArt, - value: 'art', - menu: new Common.UI.Menu({ - menuAlign: 'tl-tr', - cls: 'menu-shapes', - items: [ - { template: _.template('
    ') } - ] - }) - }) - ] - }) - }); - me.slideOnlyControls.push(me.btnInsertText); + me.btnLineSpace = new Common.UI.Button({ + id : 'id-toolbar-btn-linespace', + cls : 'btn-toolbar', + iconCls : 'btn-linespace', + lock : [_set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected], + menu : new Common.UI.Menu({ + style: 'min-width: 60px;', + items: [ + { caption: '1.0', value: 1.0, checkable: true, toggleGroup: 'linesize' }, + { caption: '1.15', value: 1.15, checkable: true, toggleGroup: 'linesize' }, + { caption: '1.5', value: 1.5, checkable: true, toggleGroup: 'linesize' }, + { caption: '2.0', value: 2.0, checkable: true, toggleGroup: 'linesize' }, + { caption: '2.5', value: 2.5, checkable: true, toggleGroup: 'linesize' }, + { caption: '3.0', value: 3.0, checkable: true, toggleGroup: 'linesize' } + ] + }) + }); + me.paragraphControls.push(me.btnLineSpace); - this.btnInsertEquation = new Common.UI.Button({ - id : 'id-toolbar-btn-insertequation', - cls : 'btn-toolbar', - iconCls : 'btn-insertequation', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - split : true, - menu : new Common.UI.Menu({cls: 'menu-shapes'}) - }); - this.slideOnlyControls.push(this.btnInsertEquation); - - me.btnInsertHyperlink = new Common.UI.Button({ - id : 'id-toolbar-btn-inserthyperlink', - cls : 'btn-toolbar', - iconCls : 'btn-inserthyperlink', - lock : [_set.hyperlinkLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] - }); - me.paragraphControls.push(me.btnInsertHyperlink); - - me.btnInsertShape = new Common.UI.Button({ - id : 'id-toolbar-btn-insertshape', - cls : 'btn-toolbar', - iconCls : 'btn-insertshape', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - enableToggle: true, - menu : new Common.UI.Menu({cls: 'menu-shapes'}) - }); - me.slideOnlyControls.push(me.btnInsertShape); - - me.btnColorSchemas = new Common.UI.Button({ - id : 'id-toolbar-btn-colorschemas', - cls : 'btn-toolbar', - iconCls : 'btn-colorschemas', - lock : [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : new Common.UI.Menu({ - items : [], - maxHeight : 600, - restoreHeight: 600 - }).on('show:before', function(mnu) { - this.scroller = new Common.UI.Scroller({ - el: $(this.el).find('.dropdown-menu '), - useKeyboard: this.enableKeyEvents && !this.handleSelect, - minScrollbarLength : 40, - alwaysVisibleY: true + me.btnInsertTable = new Common.UI.Button({ + id : 'id-toolbar-btn-inserttable', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-inserttable', + caption : me.capInsertTable, + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], + menu : new Common.UI.Menu({ + items: [ + { template: _.template('
    ') }, + { caption: me.mniCustomTable, value: 'custom' } + ] + }) + }).on('render:after', function(btn) { + me.mnuTablePicker = new Common.UI.DimensionPicker({ + el : $('#id-toolbar-menu-tablepicker'), + minRows : 8, + minColumns : 10, + maxRows : 8, + maxColumns : 10 }); - }).on('show:after', function(btn, e) { - var mnu = $(this.el).find('.dropdown-menu '), - docH = Common.Utils.innerHeight(), - menuH = mnu.outerHeight(), - top = parseInt(mnu.css('top')); - - if (menuH > docH) { - mnu.css('max-height', (docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5) + 'px'); - this.scroller.update({minScrollbarLength : 40}); - } else if ( mnu.height() < this.options.restoreHeight ) { - mnu.css('max-height', (Math.min(docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5, this.options.restoreHeight)) + 'px'); - menuH = mnu.outerHeight(); - if (top+menuH > docH) { - mnu.css('top', 0); - } - this.scroller.update({minScrollbarLength : 40}); - } - }) - }); - me.slideOnlyControls.push(me.btnColorSchemas); - - me.btnHide = new Common.UI.Button({ - id : 'id-toolbar-btn-hidebars', - cls : 'btn-toolbar', - iconCls : 'btn-hidebars', - lock : [_set.menuFileOpen, _set.slideDeleted, _set.disableOnStart], - menu : true - }); - me.slideOnlyControls.push(me.btnHide); - - this.btnFitPage = { - conf: {checked:false}, - setChecked: function(val) { this.conf.checked = val;}, - isChecked: function () { return this.conf.checked; } - }; - this.btnFitWidth = clone(this.btnFitPage); - this.mnuZoom = {options: {value: 100}}; - - me.btnAdvSettings = new Common.UI.Button({ - id : 'id-toolbar-btn-settings', - cls : 'btn-toolbar', - iconCls : 'btn-settings', - lock : [_set.slideDeleted, _set.disableOnStart] - }); - me.slideOnlyControls.push(me.btnAdvSettings); - - me.btnShapeAlign = new Common.UI.Button({ - id : 'id-toolbar-btn-shape-align', - cls : 'btn-toolbar', - iconCls : 'btn-align-shape', - lock : [_set.slideDeleted, _set.shapeLock, _set.lostConnect, _set.noSlides, _set.noObjectSelected, _set.disableOnStart], - menu : new Common.UI.Menu({ - items: [ - { - caption : me.textShapeAlignLeft, - iconCls : 'mnu-shape-align-left', - value : Asc.c_oAscAlignShapeType.ALIGN_LEFT - }, - { - caption : me.textShapeAlignCenter, - iconCls : 'mnu-shape-align-center', - value : Asc.c_oAscAlignShapeType.ALIGN_CENTER - }, - { - caption : me.textShapeAlignRight, - iconCls : 'mnu-shape-align-right', - value : Asc.c_oAscAlignShapeType.ALIGN_RIGHT - }, - { - caption : me.textShapeAlignTop, - iconCls : 'mnu-shape-align-top', - value : Asc.c_oAscAlignShapeType.ALIGN_TOP - }, - { - caption : me.textShapeAlignMiddle, - iconCls : 'mnu-shape-align-middle', - value : Asc.c_oAscAlignShapeType.ALIGN_MIDDLE - }, - { - caption : me.textShapeAlignBottom, - iconCls : 'mnu-shape-align-bottom', - value : Asc.c_oAscAlignShapeType.ALIGN_BOTTOM - }, - {caption: '--' }, - { - caption : me.txtDistribHor, - iconCls : 'mnu-distrib-hor', - value : 6 - }, - { - caption : me.txtDistribVert, - iconCls : 'mnu-distrib-vert', - value : 7 - } - ] - }) - }); - me.shapeControls.push(me.btnShapeAlign); - me.slideOnlyControls.push(me.btnShapeAlign); - - me.btnShapeArrange = new Common.UI.Button({ - id : 'id-toolbar-btn-shape-arrange', - cls : 'btn-toolbar', - iconCls : 'btn-arrange-shape', - lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.noObjectSelected, _set.disableOnStart], - menu : new Common.UI.Menu({ - items: [ - { - caption : me.textArrangeFront, - iconCls : 'mnu-arrange-front', - value : 1 - }, - { - caption : me.textArrangeBack, - iconCls : 'mnu-arrange-back', - value : 2 - }, - { - caption : me.textArrangeForward, - iconCls : 'mnu-arrange-forward', - value : 3 - }, - { - caption : me.textArrangeBackward, - iconCls : 'mnu-arrange-backward', - value : 4 - }, - {caption: '--' }, - me.mnuGroupShapes = new Common.UI.MenuItem({ - caption: me.txtGroup, - iconCls: 'mnu-group', - value: 5 - }), - me.mnuUnGroupShapes = new Common.UI.MenuItem({ - caption: me.txtUngroup, - iconCls: 'mnu-ungroup', - value: 6 - }) - ] - }) - }); - me.slideOnlyControls.push(me.btnShapeArrange ); - - me.btnSlideSize = new Common.UI.Button({ - id : 'id-toolbar-btn-slide-size', - cls : 'btn-toolbar', - iconCls : 'btn-slidesize', - lock : [_set.docPropsLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], - menu : new Common.UI.Menu({ - items: [ - { - caption : me.mniSlideStandard, - checkable : true, - toggleGroup : 'slidesize', - value : 0 - }, - { - caption : me.mniSlideWide, - checkable : true, - toggleGroup : 'slidesize', - value : 1 - }, - {caption: '--'}, - { - caption : me.mniSlideAdvanced, - value : 'advanced' - } - ] - }) - }); - me.slideOnlyControls.push(me.btnSlideSize); - - me.listTheme = new Common.UI.ComboDataView({ - cls : 'combo-styles', - itemWidth : 85, - enableKeyEvents: true, - itemHeight : 38, - hint: this.tipSlideTheme, - lock: [_set.themeLock, _set.lostConnect, _set.noSlides], - beforeOpenHandler: function(e) { - var cmp = this, - menu = cmp.openButton.menu, - minMenuColumn = 6; - - if (menu.cmpEl) { - var itemEl = $(cmp.cmpEl.find('.dataview.inner .style').get(0)).parent(); - var itemMargin = /*parseInt($(itemEl.get(0)).parent().css('margin-right'))*/-1; - var itemWidth = itemEl.is(':visible') ? parseInt(itemEl.css('width')) : - (cmp.itemWidth + parseInt(itemEl.css('padding-left')) + parseInt(itemEl.css('padding-right')) + - parseInt(itemEl.css('border-left-width')) + parseInt(itemEl.css('border-right-width'))); - - var minCount = cmp.menuPicker.store.length >= minMenuColumn ? minMenuColumn : cmp.menuPicker.store.length, - columnCount = Math.min(cmp.menuPicker.store.length, Math.round($('.dataview', $(cmp.fieldPicker.el)).width() / (itemMargin + itemWidth) + 0.5)); - - columnCount = columnCount < minCount ? minCount : columnCount; - menu.menuAlignEl = cmp.cmpEl; - - menu.menuAlign = 'tl-tl'; - var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - columnCount * (itemMargin + itemWidth) - 1; - menu.setOffset(Math.min(offset, 0)); - - menu.cmpEl.css({ - 'width' : columnCount * (itemWidth + itemMargin), - 'min-height': cmp.cmpEl.height() - }); - } - - if (cmp.menuPicker.scroller) { - cmp.menuPicker.scroller.update({ - includePadding: true, - suppressScrollX: true - }); - } - } - }); - - me.listTheme.fieldPicker.itemTemplate = _.template([ - '
    ', - '
    ', - '
    ' - ].join('')); - me.listTheme.menuPicker.itemTemplate = _.template([ - '
    ', - '
    ', - '
    ' - ].join('')); - - this.lockControls = [ this.btnNewDocument, this.btnOpenDocument, this.btnAddSlide, this.btnChangeSlide, this.btnSave, - this.btnCopy, this.btnPaste, this.btnUndo, this.btnRedo, this.cmbFontName, this.cmbFontSize, - this.btnBold, this.btnItalic, this.btnUnderline, this.btnStrikeout, this.btnSuperscript, - this.btnSubscript, this.btnFontColor, this.btnClearStyle, this.btnCopyStyle, this.btnMarkers, - this.btnNumbers, this.btnDecLeftOffset, this.btnIncLeftOffset, this.btnLineSpace, this.btnHorizontalAlign, - this.btnVerticalAlign, this.btnShapeArrange, this.btnShapeAlign, this.btnInsertTable, this.btnInsertImage, - this.btnInsertChart, this.btnInsertText, this.btnInsertEquation, - this.btnInsertHyperlink, this.btnInsertShape, this.btnColorSchemas, this.btnSlideSize, this.listTheme, this.mnuShowSettings - ]; - - // Disable all components before load document - _.each([me.btnSave] - .concat(me.paragraphControls), - function(cmp) { - if (_.isFunction(cmp.setDisabled)) - cmp.setDisabled(true); - }); - this.lockToolbar(PE.enumLock.disableOnStart, true, {array: me.slideOnlyControls.concat(me.shapeControls)}); - - return this; - }, - - lockToolbar: function(causes, lock, opts) { - !opts && (opts = {}); - - var controls = opts.array || this.lockControls; - opts.merge && (controls = _.union(this.lockControls,controls)); - - function doLock(cmp, cause) { - if ( _.contains(cmp.options.lock, cause) ) { - var index = cmp.keepState.indexOf(cause); - if (lock) { - if (index < 0) { - cmp.keepState.push(cause); - } - } else { - if (!(index < 0)) { - cmp.keepState.splice(index, 1); - } - } - } - } - - _.each(controls, function(item) { - if (_.isFunction(item.setDisabled)) { - !item.keepState && (item.keepState = []); - if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) { - item.keepState = _.difference(item.keepState, opts.clear); - } - - _.isArray(causes) ? _.each(causes, function(c) {doLock(item, c)}) : doLock(item, causes); - - if (!(item.keepState.length > 0)) { - item.isDisabled() && item.setDisabled(false); - } else { - !item.isDisabled() && item.setDisabled(true); - } - } - }); - }, - - render: function (mode) { - var me = this, - el = $(this.el); - - /** - * Render UI layout - */ - - this.trigger('render:before', this); - - var value = Common.localStorage.getItem('pe-compact-toolbar'); - var valueCompact = !!(value!==null && parseInt(value) == 1 || value === null && mode.customization && mode.customization.compactToolbar); - - el.html(this.template({ - isCompactView: valueCompact - })); - - me.rendererComponents(valueCompact ? 'short' : 'full'); - me.isCompactView = valueCompact; - - this.trigger('render:after', this); - - return this; - }, - - rendererComponents: function(mode) { - var prefix = (mode === 'short') ? 'short' : 'full'; - - var replacePlacholder = function(id, cmp) { - var placeholderEl = $(id), - placeholderDom = placeholderEl.get(0); - - if (placeholderDom && cmp) { - if (cmp.rendered) { - cmp.el = document.getElementById(cmp.id); - placeholderDom.appendChild(document.getElementById(cmp.id)); - } else { - cmp.render(placeholderEl); - } - } - }; - - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-field-fontname', this.cmbFontName); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-field-fontsize', this.cmbFontSize); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-newdocument', this.btnNewDocument); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-opendocument', this.btnOpenDocument); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-addslide', this.btnAddSlide); - if (mode === 'short') { - $('button', this.btnAddSlide.cmpEl).removeClass('large'); - } else { - $('button', this.btnAddSlide.cmpEl).addClass('large'); - } - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-changeslide', this.btnChangeSlide); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-preview', this.btnPreview); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-print', this.btnPrint); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-save', this.btnSave); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-undo', this.btnUndo); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-redo', this.btnRedo); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-copy', this.btnCopy); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-paste', this.btnPaste); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-bold', this.btnBold); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-italic', this.btnItalic); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-underline', this.btnUnderline); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-strikeout', this.btnStrikeout); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-superscript', this.btnSuperscript); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-subscript', this.btnSubscript); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-fontcolor', this.btnFontColor); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-clearstyle', this.btnClearStyle); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-copystyle', this.btnCopyStyle); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-markers', this.btnMarkers); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-numbering', this.btnNumbers); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-incoffset', this.btnIncLeftOffset); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-decoffset', this.btnDecLeftOffset); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-halign', this.btnHorizontalAlign); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-valign', this.btnVerticalAlign); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-linespace', this.btnLineSpace); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-arrange-shape', this.btnShapeArrange); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-align-shape', this.btnShapeAlign); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-insertshape', this.btnInsertShape); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-inserttext', this.btnInsertText); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-insertequation', this.btnInsertEquation); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-inserthyperlink',this.btnInsertHyperlink); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-inserttable', this.btnInsertTable); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-insertimage', this.btnInsertImage); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-insertchart', this.btnInsertChart); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-colorschemas', this.btnColorSchemas); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-slidesize', this.btnSlideSize); - replacePlacholder('#id-toolbar-full-placeholder-field-styles', this.listTheme); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-hidebars', this.btnHide); - replacePlacholder('#id-toolbar-' + prefix + '-placeholder-btn-settings', this.btnAdvSettings); - replacePlacholder('#id-toolbar-full-placeholder-field-styles', this.listTheme); - - }, - - createDelayedElements: function() { - // set hints - this.btnNewDocument.updateHint(this.tipNewDocument); - this.btnOpenDocument.updateHint(this.tipOpenDocument); - this.btnAddSlide.updateHint(this.tipAddSlide + Common.Utils.String.platformKey('Ctrl+M')); - this.btnChangeSlide.updateHint(this.tipChangeSlide); - this.btnPreview.updateHint(this.tipPreview); - this.btnPrint.updateHint(this.tipPrint + Common.Utils.String.platformKey('Ctrl+P')); - this.btnSave.updateHint(this.btnSaveTip); - this.btnUndo.updateHint(this.tipUndo + Common.Utils.String.platformKey('Ctrl+Z')); - this.btnRedo.updateHint(this.tipRedo + Common.Utils.String.platformKey('Ctrl+Y')); - this.btnCopy.updateHint(this.tipCopy + Common.Utils.String.platformKey('Ctrl+C')); - this.btnPaste.updateHint(this.tipPaste + Common.Utils.String.platformKey('Ctrl+V')); - this.btnBold.updateHint(this.textBold + Common.Utils.String.platformKey('Ctrl+B')); - this.btnItalic.updateHint(this.textItalic + Common.Utils.String.platformKey('Ctrl+I')); - this.btnUnderline.updateHint(this.textUnderline + Common.Utils.String.platformKey('Ctrl+U')); - this.btnStrikeout.updateHint(this.textStrikeout); - this.btnSuperscript.updateHint(this.textSuperscript); - this.btnSubscript.updateHint(this.textSubscript); - this.btnFontColor.updateHint(this.tipFontColor); - this.btnClearStyle.updateHint(this.tipClearStyle); - this.btnCopyStyle.updateHint(this.tipCopyStyle + Common.Utils.String.platformKey('Ctrl+Shift+C')); - this.btnMarkers.updateHint(this.tipMarkers); - this.btnNumbers.updateHint(this.tipNumbers); - this.btnHorizontalAlign.updateHint(this.tipHAligh); - this.btnVerticalAlign.updateHint(this.tipVAligh); - this.btnDecLeftOffset.updateHint(this.tipDecPrLeft + Common.Utils.String.platformKey('Ctrl+Shift+M')); - this.btnIncLeftOffset.updateHint(this.tipIncPrLeft); - this.btnLineSpace.updateHint(this.tipLineSpace); - this.btnInsertTable.updateHint(this.tipInsertTable); - this.btnInsertImage.updateHint(this.tipInsertImage); - this.btnInsertChart.updateHint(this.tipInsertChart); - this.btnInsertText.updateHint(this.tipInsertText); - this.btnInsertEquation.updateHint(this.tipInsertEquation); - this.btnInsertHyperlink.updateHint(this.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K')); - this.btnInsertShape.updateHint(this.tipInsertShape); - this.btnColorSchemas.updateHint(this.tipColorSchemas); - this.btnHide.updateHint(this.tipViewSettings); - this.btnAdvSettings.updateHint(this.tipAdvSettings); - this.btnShapeAlign.updateHint(this.tipShapeAlign); - this.btnShapeArrange.updateHint(this.tipShapeArrange); - this.btnSlideSize.updateHint(this.tipSlideSize); - - // set menus - - var me = this; - - this.btnHide.setMenu( - new Common.UI.Menu({ - cls: 'pull-right', - style: 'min-width: 180px;', - items: [ - this.mnuitemCompactToolbar = new Common.UI.MenuItem({ - caption : this.textCompactView, - checkable : true - }), - this.mnuitemHideTitleBar = new Common.UI.MenuItem({ - caption : this.textHideTitleBar, - checkable : true - }), - this.mnuitemHideStatusBar = new Common.UI.MenuItem({ - caption : this.textHideStatusBar, - checkable : true - }), - this.mnuitemHideRulers = new Common.UI.MenuItem({ - caption : this.textHideLines, - checkable : true - }), - { caption: '--' }, - this.btnFitPage = new Common.UI.MenuItem({ - caption: this.textFitPage, - checkable: true, - checked: this.btnFitPage.isChecked() - }), - this.btnFitWidth = new Common.UI.MenuItem({ - caption: this.textFitWidth, - checkable: true, - checked: this.btnFitWidth.isChecked() - }), - this.mnuZoom = new Common.UI.MenuItem({ - template: _.template([ - '' - ].join('')), - stopPropagation: true, - value: this.mnuZoom.options.value - }) - ] - }) - ); - if (this.mode.isDesktopApp || this.mode.canBrandingExt && this.mode.customization && this.mode.customization.header===false) - this.mnuitemHideTitleBar.hide(); - if (this.mode.canBrandingExt && this.mode.customization && this.mode.customization.statusBar===false) - this.mnuitemHideStatusBar.hide(); - - this.mnuZoomOut = new Common.UI.Button({ - el : $('#id-menu-zoom-out'), - cls : 'btn-toolbar' - }); - this.mnuZoomIn = new Common.UI.Button({ - el : $('#id-menu-zoom-in'), - cls : 'btn-toolbar' - }); - - this.btnMarkers.setMenu( - new Common.UI.Menu({ - items: [ - { template: _.template('') } - ] - }) - ); - - this.btnNumbers.setMenu( - new Common.UI.Menu({ - items: [ - { template: _.template('') } - ] - }) - ); - - this.btnAddSlide.setMenu( - new Common.UI.Menu({ - items: [ - { template: _.template('') } - ] - }) - ); - - this.btnChangeSlide.setMenu( - new Common.UI.Menu({ - items: [ - { template: _.template('') } - ] - }) - ); - - // set dataviews - - var _conf = this.mnuMarkersPicker.conf; - this.mnuMarkersPicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-markers'), - parentMenu: this.btnMarkers.menu, - restoreHeight: 92, - allowScrollbar: false, - store: new Common.UI.DataViewStore([ - { offsety:0, data:{type:0, subtype:-1} }, - { offsety:38, data:{type:0, subtype:1} }, - { offsety:76, data:{type:0, subtype:2} }, - { offsety:114, data:{type:0, subtype:3} }, - { offsety:152, data:{type:0, subtype:4} }, - { offsety:190, data:{type:0, subtype:5} }, - { offsety:228, data:{type:0, subtype:6} }, - { offsety:266, data:{type:0, subtype:7} } - ]), - itemTemplate: _.template('
    ') - }); - _conf && this.mnuMarkersPicker.selectByIndex(_conf.index, true); - - _conf = this.mnuNumbersPicker.conf; - this.mnuNumbersPicker = new Common.UI.DataView({ - el: $('#id-toolbar-menu-numbering'), - parentMenu: this.btnNumbers.menu, - restoreHeight: 164, - allowScrollbar: false, - store: new Common.UI.DataViewStore([ - { offsety: 0, data:{type:1,subtype:-1} }, - { offsety: 296, data:{type:1,subtype:4} }, - { offsety: 370, data:{type:1,subtype:5} }, - { offsety: 444, data:{type:1,subtype:6} }, - { offsety: 74, data:{type:1,subtype:1} }, - { offsety: 148, data:{type:1,subtype:2} }, - { offsety: 222, data:{type:1,subtype:3} }, - { offsety: 518, data:{type:1,subtype:7} } - ]), - itemTemplate: _.template('
    ') - }); - _conf && this.mnuNumbersPicker.selectByIndex(_conf.index, true); - - this.mnuAddSlidePicker = new Common.UI.DataView({ - el : $('#id-toolbar-menu-addslide'), - parentMenu : this.btnAddSlide.menu, - showLast: false, - restoreHeight: 300, - style: 'max-height: 300px;', - store : PE.getCollection('SlideLayouts'), - itemTemplate: _.template([ - '
    ', - '
    ', - '
    <%= title %>
    ', - '
    ' - ].join('')) - }); - if (this.btnAddSlide.menu) { - this.btnAddSlide.menu.on('show:after', function () { - me.onSlidePickerShowAfter(me.mnuAddSlidePicker); - me.mnuAddSlidePicker.scroller.update({alwaysVisibleY: true}); - me.mnuAddSlidePicker.scroller.scrollTop(0); }); - } - this.mnuAddSlidePicker._needRecalcSlideLayout = true; + me.slideOnlyControls.push(me.btnInsertTable); - var createDataPicker = function (btn) { - me.mnuChangeSlidePicker = new Common.UI.DataView({ - el : $('#id-toolbar-menu-changeslide'), - parentMenu : me.btnChangeSlide.menu, + me.btnInsertChart = new Common.UI.Button({ + id : 'id-toolbar-btn-insertchart', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-insertchart', + caption : me.capInsertChart, + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], + menu : new Common.UI.Menu({ + style: 'width: 435px;', + items: [ + { template: _.template('') } + ] + }) + }).on('render:after', function(btn) { + me.mnuInsertChartPicker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-insertchart'), + parentMenu: btn.menu, + showLast: false, + restoreHeight: 421, + groups: new Common.UI.DataViewGroupStore([ + { id: 'menu-chart-group-bar', caption: me.textColumn, headername: me.textCharts }, + { 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, inline: true }, + { id: 'menu-chart-group-scatter', caption: me.textPoint, inline: true }, + { id: 'menu-chart-group-stock', caption: me.textStock, inline: true } + ]), + store: new Common.UI.DataViewStore([ + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal, allowSelected: true, iconCls: 'column-normal', selected: true}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked, allowSelected: true, iconCls: 'column-stack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer, allowSelected: true, iconCls: 'column-pstack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3d, allowSelected: true, iconCls: 'column-3d-normal'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStacked3d, allowSelected: true, iconCls: 'column-3d-stack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barStackedPer3d, allowSelected: true, iconCls: 'column-3d-pstack'}, + { group: 'menu-chart-group-bar', type: Asc.c_oAscChartTypeSettings.barNormal3dPerspective, allowSelected: true, iconCls: 'column-3d-normal-per'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineNormal, allowSelected: true, iconCls: 'line-normal'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStacked, allowSelected: true, iconCls: 'line-stack'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.lineStackedPer, allowSelected: true, iconCls: 'line-pstack'}, + { group: 'menu-chart-group-line', type: Asc.c_oAscChartTypeSettings.line3d, allowSelected: true, iconCls: 'line-3d'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie, allowSelected: true, iconCls: 'pie-normal'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.doughnut, allowSelected: true, iconCls: 'pie-doughnut'}, + { group: 'menu-chart-group-pie', type: Asc.c_oAscChartTypeSettings.pie3d, allowSelected: true, iconCls: 'pie-3d-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal, allowSelected: true, iconCls: 'bar-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked, allowSelected: true, iconCls: 'bar-stack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer, allowSelected: true, iconCls: 'bar-pstack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarNormal3d, allowSelected: true, iconCls: 'bar-3d-normal'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStacked3d, allowSelected: true, iconCls: 'bar-3d-stack'}, + { group: 'menu-chart-group-hbar', type: Asc.c_oAscChartTypeSettings.hBarStackedPer3d, allowSelected: true, iconCls: 'bar-3d-pstack'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaNormal, allowSelected: true, iconCls: 'area-normal'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStacked, allowSelected: true, iconCls: 'area-stack'}, + { group: 'menu-chart-group-area', type: Asc.c_oAscChartTypeSettings.areaStackedPer, allowSelected: true, iconCls: 'area-pstack'}, + { group: 'menu-chart-group-scatter', type: Asc.c_oAscChartTypeSettings.scatter, allowSelected: true, iconCls: 'point-normal'}, + { group: 'menu-chart-group-stock', type: Asc.c_oAscChartTypeSettings.stock, allowSelected: true, iconCls: 'stock-normal'} + ]), + itemTemplate: _.template('
    ') + }) + }); + + me.slideOnlyControls.push(me.btnInsertChart); + + me.btnInsertEquation = new Common.UI.Button({ + id : 'id-toolbar-btn-insertequation', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-insertequation', + caption : me.capInsertEquation, + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], + split : true, + menu : new Common.UI.Menu({cls: 'menu-shapes'}) + }); + me.slideOnlyControls.push(this.btnInsertEquation); + + me.btnInsertHyperlink = new Common.UI.Button({ + id : 'id-toolbar-btn-inserthyperlink', + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-inserthyperlink', + caption : me.capInsertHyperlink, + lock : [_set.hyperlinkLock, _set.slideDeleted, _set.paragraphLock, _set.lostConnect, _set.noSlides, _set.noParagraphSelected] + }); + me.paragraphControls.push(me.btnInsertHyperlink); + + me.btnColorSchemas = new Common.UI.Button({ + id : 'id-toolbar-btn-colorschemas', + cls : 'btn-toolbar', + iconCls : 'btn-colorschemas', + lock : [_set.themeLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], + menu : new Common.UI.Menu({ + items : [], + maxHeight : 600, + restoreHeight: 600 + }).on('show:before', function(mnu) { + this.scroller = new Common.UI.Scroller({ + el: $(this.el).find('.dropdown-menu '), + useKeyboard: this.enableKeyEvents && !this.handleSelect, + minScrollbarLength : 40, + alwaysVisibleY: true + }); + }).on('show:after', function(btn, e) { + var mnu = $(this.el).find('.dropdown-menu '), + docH = Common.Utils.innerHeight(), + menuH = mnu.outerHeight(), + top = parseInt(mnu.css('top')); + + if (menuH > docH) { + mnu.css('max-height', (docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5) + 'px'); + this.scroller.update({minScrollbarLength : 40}); + } else if ( mnu.height() < this.options.restoreHeight ) { + mnu.css('max-height', (Math.min(docH - parseInt(mnu.css('padding-top')) - parseInt(mnu.css('padding-bottom'))-5, this.options.restoreHeight)) + 'px'); + menuH = mnu.outerHeight(); + if (top+menuH > docH) { + mnu.css('top', 0); + } + this.scroller.update({minScrollbarLength : 40}); + } + }) + }); + me.slideOnlyControls.push(me.btnColorSchemas); + + me.btnHide = new Common.UI.Button({ + id : 'id-toolbar-btn-hidebars', + cls : 'btn-toolbar', + iconCls : 'btn-hidebars', + lock : [_set.menuFileOpen, _set.slideDeleted, _set.disableOnStart], + menu : true + }); + me.slideOnlyControls.push(me.btnHide); + + this.btnFitPage = { + conf: {checked:false}, + setChecked: function(val) { this.conf.checked = val;}, + isChecked: function () { return this.conf.checked; } + }; + this.btnFitWidth = clone(this.btnFitPage); + this.mnuZoom = {options: {value: 100}}; + + me.btnAdvSettings = new Common.UI.Button({ + id : 'id-toolbar-btn-settings', + cls : 'btn-toolbar', + iconCls : 'btn-settings', + lock : [_set.slideDeleted, _set.disableOnStart] + }); + me.slideOnlyControls.push(me.btnAdvSettings); + + me.btnShapeAlign = new Common.UI.Button({ + id : 'id-toolbar-btn-shape-align', + cls : 'btn-toolbar', + iconCls : 'btn-align-shape', + lock : [_set.slideDeleted, _set.shapeLock, _set.lostConnect, _set.noSlides, _set.noObjectSelected, _set.disableOnStart], + menu : new Common.UI.Menu({ + items: [ + { + caption : me.textShapeAlignLeft, + iconCls : 'mnu-shape-align-left', + value : Asc.c_oAscAlignShapeType.ALIGN_LEFT + }, + { + caption : me.textShapeAlignCenter, + iconCls : 'mnu-shape-align-center', + value : Asc.c_oAscAlignShapeType.ALIGN_CENTER + }, + { + caption : me.textShapeAlignRight, + iconCls : 'mnu-shape-align-right', + value : Asc.c_oAscAlignShapeType.ALIGN_RIGHT + }, + { + caption : me.textShapeAlignTop, + iconCls : 'mnu-shape-align-top', + value : Asc.c_oAscAlignShapeType.ALIGN_TOP + }, + { + caption : me.textShapeAlignMiddle, + iconCls : 'mnu-shape-align-middle', + value : Asc.c_oAscAlignShapeType.ALIGN_MIDDLE + }, + { + caption : me.textShapeAlignBottom, + iconCls : 'mnu-shape-align-bottom', + value : Asc.c_oAscAlignShapeType.ALIGN_BOTTOM + }, + {caption: '--' }, + { + caption : me.txtDistribHor, + iconCls : 'mnu-distrib-hor', + value : 6 + }, + { + caption : me.txtDistribVert, + iconCls : 'mnu-distrib-vert', + value : 7 + } + ] + }) + }); + me.shapeControls.push(me.btnShapeAlign); + me.slideOnlyControls.push(me.btnShapeAlign); + + me.btnShapeArrange = new Common.UI.Button({ + id : 'id-toolbar-btn-shape-arrange', + cls : 'btn-toolbar', + iconCls : 'btn-arrange-shape', + lock : [_set.slideDeleted, _set.lostConnect, _set.noSlides, _set.noObjectSelected, _set.disableOnStart], + menu : new Common.UI.Menu({ + items: [ + { + caption : me.textArrangeFront, + iconCls : 'mnu-arrange-front', + value : 1 + }, + { + caption : me.textArrangeBack, + iconCls : 'mnu-arrange-back', + value : 2 + }, + { + caption : me.textArrangeForward, + iconCls : 'mnu-arrange-forward', + value : 3 + }, + { + caption : me.textArrangeBackward, + iconCls : 'mnu-arrange-backward', + value : 4 + }, + {caption: '--' }, + me.mnuGroupShapes = new Common.UI.MenuItem({ + caption: me.txtGroup, + iconCls: 'mnu-group', + value: 5 + }), + me.mnuUnGroupShapes = new Common.UI.MenuItem({ + caption: me.txtUngroup, + iconCls: 'mnu-ungroup', + value: 6 + }) + ] + }) + }); + me.slideOnlyControls.push(me.btnShapeArrange ); + + me.btnSlideSize = new Common.UI.Button({ + id : 'id-toolbar-btn-slide-size', + cls : 'btn-toolbar', + iconCls : 'btn-slidesize', + lock : [_set.docPropsLock, _set.slideDeleted, _set.lostConnect, _set.noSlides, _set.disableOnStart], + menu : new Common.UI.Menu({ + items: [ + { + caption : me.mniSlideStandard, + checkable : true, + toggleGroup : 'slidesize', + value : 0 + }, + { + caption : me.mniSlideWide, + checkable : true, + toggleGroup : 'slidesize', + value : 1 + }, + {caption: '--'}, + { + caption : me.mniSlideAdvanced, + value : 'advanced' + } + ] + }) + }); + me.slideOnlyControls.push(me.btnSlideSize); + + me.listTheme = new Common.UI.ComboDataView({ + cls : 'combo-styles', + itemWidth : 85, + enableKeyEvents: true, + itemHeight : 38, + hint: this.tipSlideTheme, + lock: [_set.lostConnect, _set.noSlides], + beforeOpenHandler: function(e) { + var cmp = this, + menu = cmp.openButton.menu, + minMenuColumn = 6; + + if (menu.cmpEl) { + var itemEl = $(cmp.cmpEl.find('.dataview.inner .style').get(0)).parent(); + var itemMargin = /*parseInt($(itemEl.get(0)).parent().css('margin-right'))*/-1; + var itemWidth = itemEl.is(':visible') ? parseInt(itemEl.css('width')) : + (cmp.itemWidth + parseInt(itemEl.css('padding-left')) + parseInt(itemEl.css('padding-right')) + + parseInt(itemEl.css('border-left-width')) + parseInt(itemEl.css('border-right-width'))); + + var minCount = cmp.menuPicker.store.length >= minMenuColumn ? minMenuColumn : cmp.menuPicker.store.length, + columnCount = Math.min(cmp.menuPicker.store.length, Math.round($('.dataview', $(cmp.fieldPicker.el)).width() / (itemMargin + itemWidth) + 0.5)); + + columnCount = columnCount < minCount ? minCount : columnCount; + menu.menuAlignEl = cmp.cmpEl; + + menu.menuAlign = 'tl-tl'; + var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - columnCount * (itemMargin + itemWidth) - 1; + menu.setOffset(Math.min(offset, 0)); + + menu.cmpEl.css({ + 'width' : columnCount * (itemWidth + itemMargin), + 'min-height': cmp.cmpEl.height() + }); + } + + if (cmp.menuPicker.scroller) { + cmp.menuPicker.scroller.update({ + includePadding: true, + suppressScrollX: true + }); + } + } + }); + + me.listTheme.fieldPicker.itemTemplate = _.template([ + '
    ', + '
    ', + '
    ' + ].join('')); + me.listTheme.menuPicker.itemTemplate = _.template([ + '
    ', + '
    ', + '
    ' + ].join('')); + + this.lockControls = [ this.btnAddSlide, this.btnChangeSlide, this.btnSave, + this.btnCopy, this.btnPaste, this.btnUndo, this.btnRedo, this.cmbFontName, this.cmbFontSize, + this.btnBold, this.btnItalic, this.btnUnderline, this.btnStrikeout, this.btnSuperscript, + this.btnSubscript, this.btnFontColor, this.btnClearStyle, this.btnCopyStyle, this.btnMarkers, + this.btnNumbers, this.btnDecLeftOffset, this.btnIncLeftOffset, this.btnLineSpace, this.btnHorizontalAlign, + this.btnVerticalAlign, this.btnShapeArrange, this.btnShapeAlign, this.btnInsertTable, this.btnInsertChart, + this.btnInsertEquation, this.btnInsertHyperlink, this.btnColorSchemas, this.btnSlideSize, this.listTheme, this.mnuShowSettings + ]; + + // Disable all components before load document + _.each([me.btnSave] + .concat(me.paragraphControls), + function(cmp) { + if (_.isFunction(cmp.setDisabled)) + cmp.setDisabled(true); + }); + this.lockToolbar(PE.enumLock.disableOnStart, true, {array: me.slideOnlyControls.concat(me.shapeControls)}); + + return this; + }, + + lockToolbar: function (causes, lock, opts) { + !opts && (opts = {}); + + var controls = opts.array || this.lockControls; + opts.merge && (controls = _.union(this.lockControls, controls)); + + function doLock(cmp, cause) { + if (_.contains(cmp.options.lock, cause)) { + var index = cmp.keepState.indexOf(cause); + if (lock) { + if (index < 0) { + cmp.keepState.push(cause); + } + } else { + if (!(index < 0)) { + cmp.keepState.splice(index, 1); + } + } + } + } + + _.each(controls, function (item) { + if (_.isFunction(item.setDisabled)) { + !item.keepState && (item.keepState = []); + if (opts.clear && opts.clear.length > 0 && item.keepState.length > 0) { + item.keepState = _.difference(item.keepState, opts.clear); + } + + _.isArray(causes) ? _.each(causes, function (c) { + doLock(item, c) + }) : doLock(item, causes); + + if (!(item.keepState.length > 0)) { + item.isDisabled() && item.setDisabled(false); + } else { + !item.isDisabled() && item.setDisabled(true); + } + } + }); + }, + + render: function (mode) { + var me = this; + + /** + * Render UI layout + */ + + this.fireEvent('render:before', [this]); + + me.isCompactView = mode.compactview; + if ( mode.isEdit ) { + me.$el.html(me.rendererComponents(config.$layout)); + } else { + config.$layout.find('.canedit').hide(); + config.$layout.addClass('folded'); + + me.$el.html(config.$layout); + } + + this.fireEvent('render:after', [this]); + + $boxTabs = me.$el.find('.tabs > ul'); + $tabs = $boxTabs.find('> li'); + $panels = me.$el.find('.box-panels > .panel'); + $tabs.parent().on('click', '.ribtab', function (e) { + var tab = $(e.target).data('tab'); + if (tab == 'file') { + me.fireEvent('file:open'); + } else + if ( isTabActive('file') ) + me.fireEvent('file:close'); + + me.setTab(tab); + }); + + $marker = me.$el.find('.tabs .marker'); + var $scrollR = me.$el.find('.tabs .scroll.right'); + $scrollL = me.$el.find('.tabs .scroll.left'); + + $scrollL.on('click', onScrollTabs.bind(this, 'left')); + $scrollR.on('click', onScrollTabs.bind(this, 'right')); + + Common.NotificationCenter.on({ + 'window:resize': onResize + }); + + if ( me.isCompactView ) + me.setFolded(true); else + me.setTab('home'); + + return this; + }, + + rendererComponents: function (html) { + var $host = $(html); + var _injectComponent = function (id, cmp) { + var $slot = $host.find(id); + if ($slot.length) { + cmp.rendered ? + $slot.append(cmp.$el) : cmp.render($slot); + } + }; + + _injectComponent('#slot-field-fontname', this.cmbFontName); + _injectComponent('#slot-field-fontsize', this.cmbFontSize); + _injectComponent('#slot-btn-addslide', this.btnAddSlide); + _injectComponent('#slot-btn-changeslide', this.btnChangeSlide); + _injectComponent('#slot-btn-preview', this.btnPreview); + _injectComponent('#slot-btn-print', this.btnPrint); + _injectComponent('#slot-btn-save', this.btnSave); + _injectComponent('#slot-btn-undo', this.btnUndo); + _injectComponent('#slot-btn-redo', this.btnRedo); + _injectComponent('#slot-btn-copy', this.btnCopy); + _injectComponent('#slot-btn-paste', this.btnPaste); + _injectComponent('#slot-btn-bold', this.btnBold); + _injectComponent('#slot-btn-italic', this.btnItalic); + _injectComponent('#slot-btn-underline', this.btnUnderline); + _injectComponent('#slot-btn-strikeout', this.btnStrikeout); + _injectComponent('#slot-btn-superscript', this.btnSuperscript); + _injectComponent('#slot-btn-subscript', this.btnSubscript); + _injectComponent('#slot-btn-fontcolor', this.btnFontColor); + _injectComponent('#slot-btn-clearstyle', this.btnClearStyle); + _injectComponent('#slot-btn-copystyle', this.btnCopyStyle); + _injectComponent('#slot-btn-markers', this.btnMarkers); + _injectComponent('#slot-btn-numbering', this.btnNumbers); + _injectComponent('#slot-btn-incoffset', this.btnIncLeftOffset); + _injectComponent('#slot-btn-decoffset', this.btnDecLeftOffset); + _injectComponent('#slot-btn-halign', this.btnHorizontalAlign); + _injectComponent('#slot-btn-valign', this.btnVerticalAlign); + _injectComponent('#slot-btn-linespace', this.btnLineSpace); + _injectComponent('#slot-btn-arrange-shape', this.btnShapeArrange); + _injectComponent('#slot-btn-align-shape', this.btnShapeAlign); + _injectComponent('#slot-btn-insertequation', this.btnInsertEquation); + _injectComponent('#slot-btn-insertlink', this.btnInsertHyperlink); + _injectComponent('#slot-btn-inserttable', this.btnInsertTable); + _injectComponent('#slot-btn-insertchart', this.btnInsertChart); + _injectComponent('#slot-btn-colorschemas', this.btnColorSchemas); + _injectComponent('#slot-btn-slidesize', this.btnSlideSize); + _injectComponent('#slot-field-styles', this.listTheme); + _injectComponent('#slot-btn-hidebars', this.btnHide); + _injectComponent('#slot-btn-settings', this.btnAdvSettings); + + function _injectBtns(opts) { + var array = new buttonsArray; + var $slots = $host.find(opts.slot); + $slots.each(function(index, el) { + var button = new Common.UI.Button(opts.btnconfig); + button.render( $slots.eq(index) ); + + array.push(button); + }); + + return array; + } + + var me = this; + me.btnsInsertImage = _injectBtns({ + slot: '.slot-insertimg', + btnconfig: { + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-insertimage', + caption : me.capInsertImage, + lock : [PE.enumLock.slideDeleted, PE.enumLock.lostConnect, PE.enumLock.noSlides, PE.enumLock.disableOnStart], + menu : true + } + }); + + me.btnsInsertText = _injectBtns({ + slot: '.slot-inserttext', + btnconfig: { + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-inserttext', + caption : me.capInsertText, + lock : [PE.enumLock.slideDeleted, PE.enumLock.lostConnect, PE.enumLock.noSlides, PE.enumLock.disableOnStart], + enableToggle: true, + split : true, + menu : true + } + }); + + me.btnsInsertShape = _injectBtns({ + slot: '.slot-insertshape', + btnconfig: { + cls : 'btn-toolbar x-huge icon-top', + iconCls : 'btn-insertshape', + caption : me.capInsertShape, + lock : [PE.enumLock.slideDeleted, PE.enumLock.lostConnect, PE.enumLock.noSlides, PE.enumLock.disableOnStart], + enableToggle: true, + menu : true + } + }); + + Array.prototype.push.apply(me.slideOnlyControls, me.btnsInsertImage, me.btnsInsertText, me.btnsInsertShape); + Array.prototype.push.apply(me.lockControls, me.btnsInsertImage, me.btnsInsertText, me.btnsInsertShape); + + return $host; + }, + + onAppReady: function (config) { + var me = this; + (new Promise( function(resolve, reject) { + resolve(); + })).then(function () { + if ( !config.isEdit ) return; + + me.btnsInsertImage.forEach(function (btn) { + btn.updateHint(me.tipInsertImage); + btn.setMenu( + new Common.UI.Menu({ + items: [ + { caption: me.mniImageFromFile, value: 'file' }, + { caption: me.mniImageFromUrl, value: 'url' } + ] + }).on('item:click', function (menu, item, e) { + me.fireEvent('insert:image', [item.value]); + }) + ); + }); + + me.btnsInsertText.forEach(function (btn) { + btn.updateHint(me.tipInsertText); + btn.setMenu( + new Common.UI.Menu({ + items : [ + {caption: me.textInsText, value: 'text'}, + {caption: me.textInsTextArt, value: 'art', + menu: new Common.UI.Menu({ + menuAlign: 'tl-tr', + cls: 'menu-shapes', + items: [ + { template: _.template('
    ') } + ] + }) + } + ] + }).on('item:click', function (menu, item, e) { + if ( item.value == 'text' ) + me.fireEvent('insert:text', ['begin']); + }) + ); + btn.on('click', function (btn, e) { + me.fireEvent('insert:text', [btn.pressed?'begin':'end']); + }); + }); + + me.btnsInsertShape.forEach(function (btn) { + btn.updateHint(me.tipInsertShape); + btn.setMenu( + new Common.UI.Menu({ + cls: 'menu-shapes' + }).on('hide:after', function (e) { + me.fireEvent('insert:shape', ['menu:hide']); + }) + ); + }); + }); + }, + + createDelayedElements: function () { + // set hints + this.btnAddSlide.updateHint(this.tipAddSlide + Common.Utils.String.platformKey('Ctrl+M')); + this.btnChangeSlide.updateHint(this.tipChangeSlide); + this.btnPreview.updateHint(this.tipPreview); + this.btnPrint.updateHint(this.tipPrint + Common.Utils.String.platformKey('Ctrl+P')); + this.btnSave.updateHint(this.btnSaveTip); + this.btnUndo.updateHint(this.tipUndo + Common.Utils.String.platformKey('Ctrl+Z')); + this.btnRedo.updateHint(this.tipRedo + Common.Utils.String.platformKey('Ctrl+Y')); + this.btnCopy.updateHint(this.tipCopy + Common.Utils.String.platformKey('Ctrl+C')); + this.btnPaste.updateHint(this.tipPaste + Common.Utils.String.platformKey('Ctrl+V')); + this.btnBold.updateHint(this.textBold + Common.Utils.String.platformKey('Ctrl+B')); + this.btnItalic.updateHint(this.textItalic + Common.Utils.String.platformKey('Ctrl+I')); + this.btnUnderline.updateHint(this.textUnderline + Common.Utils.String.platformKey('Ctrl+U')); + this.btnStrikeout.updateHint(this.textStrikeout); + this.btnSuperscript.updateHint(this.textSuperscript); + this.btnSubscript.updateHint(this.textSubscript); + this.btnFontColor.updateHint(this.tipFontColor); + this.btnClearStyle.updateHint(this.tipClearStyle); + this.btnCopyStyle.updateHint(this.tipCopyStyle + Common.Utils.String.platformKey('Ctrl+Shift+C')); + this.btnMarkers.updateHint(this.tipMarkers); + this.btnNumbers.updateHint(this.tipNumbers); + this.btnHorizontalAlign.updateHint(this.tipHAligh); + this.btnVerticalAlign.updateHint(this.tipVAligh); + this.btnDecLeftOffset.updateHint(this.tipDecPrLeft + Common.Utils.String.platformKey('Ctrl+Shift+M')); + this.btnIncLeftOffset.updateHint(this.tipIncPrLeft); + this.btnLineSpace.updateHint(this.tipLineSpace); + this.btnInsertTable.updateHint(this.tipInsertTable); + this.btnInsertChart.updateHint(this.tipInsertChart); + this.btnInsertEquation.updateHint(this.tipInsertEquation); + this.btnInsertHyperlink.updateHint(this.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K')); + this.btnColorSchemas.updateHint(this.tipColorSchemas); + this.btnHide.updateHint(this.tipViewSettings); + this.btnAdvSettings.updateHint(this.tipAdvSettings); + this.btnShapeAlign.updateHint(this.tipShapeAlign); + this.btnShapeArrange.updateHint(this.tipShapeArrange); + this.btnSlideSize.updateHint(this.tipSlideSize); + + // set menus + + var me = this; + + this.btnHide.setMenu( + new Common.UI.Menu({ + cls: 'pull-right', + style: 'min-width: 180px;', + items: [ + this.mnuitemCompactToolbar = new Common.UI.MenuItem({ + caption: this.textCompactView, + checkable: true, + checked: me.isCompactView + }), + this.mnuitemHideTitleBar = new Common.UI.MenuItem({ + caption: this.textHideTitleBar, + checkable: true + }), + this.mnuitemHideStatusBar = new Common.UI.MenuItem({ + caption: this.textHideStatusBar, + checkable: true + }), + this.mnuitemHideRulers = new Common.UI.MenuItem({ + caption: this.textHideLines, + checkable: true + }), + {caption: '--'}, + this.btnFitPage = new Common.UI.MenuItem({ + caption: this.textFitPage, + checkable: true, + checked: this.btnFitPage.isChecked() + }), + this.btnFitWidth = new Common.UI.MenuItem({ + caption: this.textFitWidth, + checkable: true, + checked: this.btnFitWidth.isChecked() + }), + this.mnuZoom = new Common.UI.MenuItem({ + template: _.template([ + '' + ].join('')), + stopPropagation: true, + value: this.mnuZoom.options.value + }) + ] + }) + ); + if (this.mode.isDesktopApp || this.mode.canBrandingExt && this.mode.customization && this.mode.customization.header === false) + this.mnuitemHideTitleBar.hide(); + if (this.mode.canBrandingExt && this.mode.customization && this.mode.customization.statusBar === false) + this.mnuitemHideStatusBar.hide(); + + this.mnuZoomOut = new Common.UI.Button({ + el: $('#id-menu-zoom-out'), + cls: 'btn-toolbar' + }); + this.mnuZoomIn = new Common.UI.Button({ + el: $('#id-menu-zoom-in'), + cls: 'btn-toolbar' + }); + + this.btnMarkers.setMenu( + new Common.UI.Menu({ + items: [ + {template: _.template('')} + ] + }) + ); + + this.btnNumbers.setMenu( + new Common.UI.Menu({ + items: [ + {template: _.template('')} + ] + }) + ); + + this.btnAddSlide.setMenu( + new Common.UI.Menu({ + items: [ + {template: _.template('')} + ] + }) + ); + + this.btnChangeSlide.setMenu( + new Common.UI.Menu({ + items: [ + {template: _.template('')} + ] + }) + ); + + // set dataviews + + var _conf = this.mnuMarkersPicker.conf; + this.mnuMarkersPicker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-markers'), + parentMenu: this.btnMarkers.menu, + restoreHeight: 92, + allowScrollbar: false, + store: new Common.UI.DataViewStore([ + {offsety: 0, data: {type: 0, subtype: -1}}, + {offsety: 38, data: {type: 0, subtype: 1}}, + {offsety: 76, data: {type: 0, subtype: 2}}, + {offsety: 114, data: {type: 0, subtype: 3}}, + {offsety: 152, data: {type: 0, subtype: 4}}, + {offsety: 190, data: {type: 0, subtype: 5}}, + {offsety: 228, data: {type: 0, subtype: 6}}, + {offsety: 266, data: {type: 0, subtype: 7}} + ]), + itemTemplate: _.template('
    ') + }); + _conf && this.mnuMarkersPicker.selectByIndex(_conf.index, true); + + _conf = this.mnuNumbersPicker.conf; + this.mnuNumbersPicker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-numbering'), + parentMenu: this.btnNumbers.menu, + restoreHeight: 164, + allowScrollbar: false, + store: new Common.UI.DataViewStore([ + {offsety: 0, data: {type: 1, subtype: -1}}, + {offsety: 296, data: {type: 1, subtype: 4}}, + {offsety: 370, data: {type: 1, subtype: 5}}, + {offsety: 444, data: {type: 1, subtype: 6}}, + {offsety: 74, data: {type: 1, subtype: 1}}, + {offsety: 148, data: {type: 1, subtype: 2}}, + {offsety: 222, data: {type: 1, subtype: 3}}, + {offsety: 518, data: {type: 1, subtype: 7}} + ]), + itemTemplate: _.template('
    ') + }); + _conf && this.mnuNumbersPicker.selectByIndex(_conf.index, true); + + this.mnuAddSlidePicker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-addslide'), + parentMenu: this.btnAddSlide.menu, showLast: false, restoreHeight: 300, style: 'max-height: 300px;', - store : PE.getCollection('SlideLayouts'), + store: PE.getCollection('SlideLayouts'), itemTemplate: _.template([ '
    ', - '
    ', - '
    <%= title %>
    ', + '
    ', + '
    <%= title %>
    ', '
    ' ].join('')) }); - if (me.btnChangeSlide.menu) { - me.btnChangeSlide.menu.on('show:after', function () { - me.onSlidePickerShowAfter(me.mnuChangeSlidePicker); - me.mnuChangeSlidePicker.scroller.update({alwaysVisibleY: true}); - me.mnuChangeSlidePicker.scroller.scrollTop(0); + if (this.btnAddSlide.menu) { + this.btnAddSlide.menu.on('show:after', function () { + me.onSlidePickerShowAfter(me.mnuAddSlidePicker); + me.mnuAddSlidePicker.scroller.update({alwaysVisibleY: true}); + me.mnuAddSlidePicker.scroller.scrollTop(0); }); } - me.mnuChangeSlidePicker._needRecalcSlideLayout = true; - }; - // btnChangeSlide isn't in compact toolbar mode -> may be rendered after createDelayedElements - if (this.btnChangeSlide.rendered) - createDataPicker(this.btnChangeSlide); - else - this.btnChangeSlide.on('render:after', createDataPicker); - - this.listenTo(PE.getCollection('SlideLayouts'), 'reset', function() { - me.mnuAddSlidePicker._needRecalcSlideLayout = true; - if (me.mnuChangeSlidePicker) + this.mnuAddSlidePicker._needRecalcSlideLayout = true; + + var createDataPicker = function (btn) { + me.mnuChangeSlidePicker = new Common.UI.DataView({ + el: $('#id-toolbar-menu-changeslide'), + parentMenu: me.btnChangeSlide.menu, + showLast: false, + restoreHeight: 300, + style: 'max-height: 300px;', + store: PE.getCollection('SlideLayouts'), + itemTemplate: _.template([ + '
    ', + '
    ', + '
    <%= title %>
    ', + '
    ' + ].join('')) + }); + if (me.btnChangeSlide.menu) { + me.btnChangeSlide.menu.on('show:after', function () { + me.onSlidePickerShowAfter(me.mnuChangeSlidePicker); + me.mnuChangeSlidePicker.scroller.update({alwaysVisibleY: true}); + me.mnuChangeSlidePicker.scroller.scrollTop(0); + }); + } me.mnuChangeSlidePicker._needRecalcSlideLayout = true; - }); + }; + // btnChangeSlide isn't in compact toolbar mode -> may be rendered after createDelayedElements + if (this.btnChangeSlide.rendered) + createDataPicker(this.btnChangeSlide); + else + this.btnChangeSlide.on('render:after', createDataPicker); - var mode = this.mode; - var value = Common.localStorage.getItem('pe-compact-toolbar'); - var valueCompact = !!(value!==null && parseInt(value) == 1 || value === null && mode.customization && mode.customization.compactToolbar); + this.listenTo(PE.getCollection('SlideLayouts'), 'reset', function () { + me.mnuAddSlidePicker._needRecalcSlideLayout = true; + if (me.mnuChangeSlidePicker) + me.mnuChangeSlidePicker._needRecalcSlideLayout = true; + }); - value = Common.localStorage.getItem('pe-hidden-title'); - var valueTitle = (value!==null && parseInt(value) == 1); + this.mnuitemCompactToolbar.on('toggle', _.bind(this.changeViewMode, this)); - value = Common.localStorage.getItem('pe-hidden-status'); - var valueStatus = (value!==null && parseInt(value) == 1); - - value = Common.localStorage.getItem("pe-hidden-rulers"); - var valueRulers = (value !== null && parseInt(value) == 1); - - this.mnuitemCompactToolbar.setChecked(valueCompact, true); - this.mnuitemCompactToolbar.on('toggle', _.bind(this.changeViewMode, this)); - - this.mnuitemHideTitleBar.setChecked(valueTitle, true); - this.mnuitemHideStatusBar.setChecked(valueStatus, true); - this.mnuitemHideRulers.setChecked(valueRulers, true); + this.mnuitemHideTitleBar.setChecked(Common.localStorage.getBool('pe-hidden-title'), true); + this.mnuitemHideStatusBar.setChecked(Common.localStorage.getBool('pe-hidden-status'), true); + this.mnuitemHideRulers.setChecked(Common.localStorage.getItem("pe-hidden-rulers"), true); // // Enable none paragraph components - this.lockToolbar(PE.enumLock.disableOnStart, false, {array: this.slideOnlyControls.concat(this.shapeControls)}); + this.lockToolbar(PE.enumLock.disableOnStart, false, {array: this.slideOnlyControls.concat(this.shapeControls)}); - /** coauthoring begin **/ - var hidetip = Common.localStorage.getItem('pe-hide-synch'); - this.showSynchTip = !(hidetip && parseInt(hidetip) == 1); - this.needShowSynchTip = false; - - if (this.needShowSynchTip) { - this.needShowSynchTip = false; - this.onCollaborativeChanges(); - } - /** coauthoring end **/ - - }, - - setApi: function(api) { - this.api = api; - - if (this.api) { - this.api.asc_registerCallback('asc_onSendThemeColorSchemes', _.bind(this.onSendThemeColorSchemes, this)); /** coauthoring begin **/ - this.api.asc_registerCallback('asc_onCollaborativeChanges', _.bind(this.onCollaborativeChanges, this)); - this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onApiUsersChanged, this)); - this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onApiUsersChanged, this)); + this.showSynchTip = !Common.localStorage.getBool('pe-hide-synch'); + this.needShowSynchTip = false; + + if (this.needShowSynchTip) { + this.needShowSynchTip = false; + this.onCollaborativeChanges(); + } /** coauthoring end **/ - } - return this; - }, + }, - setMode: function(mode) { - if (mode.isDisconnected) { - this.lockToolbar( PE.enumLock.lostConnect, true ); - } - this.mode = mode; - if (!mode.nativeApp) { - var nativeBtnGroup = $('.toolbar-group-native'); + setApi: function (api) { + this.api = api; - if (nativeBtnGroup) { - nativeBtnGroup.hide(); - } - } - - if (mode.isDesktopApp) - $('.toolbar-group-native').hide(); - - this.lockToolbar(PE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]}); - }, - - changeViewMode: function(item, compact) { - var me = this, - toolbarFull = $('#id-toolbar-full'), - toolbarShort = $('#id-toolbar-short'); - - me.isCompactView = compact; - - if (toolbarFull && toolbarShort) { - if (compact) { - toolbarShort.css({ - display: 'table' - }); - toolbarFull.css({ - display: 'none' - }); - toolbarShort.parent().css({ - height: '41px' - }); - this.rendererComponents('short'); - } else { - toolbarShort.css({ - display: 'none' - }); - toolbarFull.css({ - display: 'table' - }); - toolbarShort.parent().css({ - height: '67px' - }); - this.rendererComponents('full'); - - // layout styles - _.defer(function(){ - var listStylesVisible = (me.listTheme.rendered); - - if (me.listTheme.menuPicker.store.length > 0 && listStylesVisible){ - me.listTheme.fillComboView(me.listTheme.menuPicker.getSelectedRec(), true); - } - - if (me.btnInsertEquation.rendered) - PE.getController('Toolbar').fillEquations(); - - }, 100); + if (this.api) { + this.api.asc_registerCallback('asc_onSendThemeColorSchemes', _.bind(this.onSendThemeColorSchemes, this)); + /** coauthoring begin **/ + this.api.asc_registerCallback('asc_onCollaborativeChanges', _.bind(this.onCollaborativeChanges, this)); + this.api.asc_registerCallback('asc_onAuthParticipantsChanged', _.bind(this.onApiUsersChanged, this)); + this.api.asc_registerCallback('asc_onParticipantsChanged', _.bind(this.onApiUsersChanged, this)); + /** coauthoring end **/ } - this.fireEvent('changecompact', [this, compact]); - } - }, + return this; + }, - onSendThemeColorSchemes: function(schemas) { - var me = this, - mnuColorSchema = me.btnColorSchemas.menu; + setMode: function (mode) { + if (mode.isDisconnected) { + this.lockToolbar(PE.enumLock.lostConnect, true); + } + this.mode = mode; + if (!mode.nativeApp) { + var nativeBtnGroup = $('.toolbar-group-native'); - if (mnuColorSchema) { - if (mnuColorSchema && mnuColorSchema.items.length > 0) { - _.each(mnuColorSchema.items, function(item) { - item.remove(); - }); + if (nativeBtnGroup) { + nativeBtnGroup.hide(); + } } - if (mnuColorSchema == null) { - mnuColorSchema = new Common.UI.Menu({ - maxHeight : 600, - restoreHeight: 600 - }).on('render:after', function(mnu) { - this.scroller = new Common.UI.Scroller({ - el: $(this.el).find('.dropdown-menu '), - useKeyboard: this.enableKeyEvents && !this.handleSelect, - minScrollbarLength : 40 + if (mode.isDesktopApp) + $('.toolbar-group-native').hide(); + + this.lockToolbar(PE.enumLock.cantPrint, !mode.canPrint || mode.disableDownload, {array: [this.btnPrint]}); + }, + + changeViewMode: function (item, compact) { + this.fireEvent('view:compact', [this, compact]); + }, + + onSendThemeColorSchemes: function (schemas) { + var me = this, + mnuColorSchema = me.btnColorSchemas.menu; + + if (mnuColorSchema) { + if (mnuColorSchema && mnuColorSchema.items.length > 0) { + _.each(mnuColorSchema.items, function (item) { + item.remove(); }); - }); - } - mnuColorSchema.items = []; + } - var itemTemplate = _.template([ - '', + if (mnuColorSchema == null) { + mnuColorSchema = new Common.UI.Menu({ + maxHeight: 600, + restoreHeight: 600 + }).on('render:after', function (mnu) { + this.scroller = new Common.UI.Scroller({ + el: $(this.el).find('.dropdown-menu '), + useKeyboard: this.enableKeyEvents && !this.handleSelect, + minScrollbarLength: 40 + }); + }); + } + mnuColorSchema.items = []; + + var itemTemplate = _.template([ + '', '', '<% _.each(options.colors, function(color) { %>', - '', + '', '<% }) %>', '', '<%= caption %>', - '' - ].join('')); + '' + ].join('')); - _.each(schemas, function(schema, index) { - var colors = schema.get_colors();//schema.colors; - var schemecolors = []; - for (var j = 2; j < 7; j++) { - var clr = '#' + Common.Utils.ThemeColor.getHexColor(colors[j].get_r(), colors[j].get_g(), colors[j].get_b()); - schemecolors.push(clr); - } + _.each(schemas, function (schema, index) { + var colors = schema.get_colors();//schema.colors; + var schemecolors = []; + for (var j = 2; j < 7; j++) { + var clr = '#' + Common.Utils.ThemeColor.getHexColor(colors[j].get_r(), colors[j].get_g(), colors[j].get_b()); + schemecolors.push(clr); + } - if (index == 21) { - mnuColorSchema.addItem({ - caption : '--' - }); - } else { - mnuColorSchema.addItem({ - template: itemTemplate, - cls : 'color-schemas-menu', - colors : schemecolors, - caption : (index < 21) ? (me.schemeNames[index] || schema.get_name()) : schema.get_name(), - value : index - }); - } + if (index == 21) { + mnuColorSchema.addItem({ + caption: '--' + }); + } else { + mnuColorSchema.addItem({ + template: itemTemplate, + cls: 'color-schemas-menu', + colors: schemecolors, + caption: (index < 21) ? (me.schemeNames[index] || schema.get_name()) : schema.get_name(), + value: index + }); + } + }, this); + } + }, + + /** coauthoring begin **/ + onCollaborativeChanges: function () { + if (this._state.hasCollaborativeChanges) return; + if (!this.btnSave.rendered) { + this.needShowSynchTip = true; + return; + } + + var previewPanel = PE.getController('Viewport').getView('DocumentPreview'); + if (previewPanel && previewPanel.isVisible()) { + this.needShowSynchTip = true; + return; + } + + this._state.hasCollaborativeChanges = true; + var iconEl = $('.btn-icon', this.btnSave.cmpEl); + iconEl.removeClass(this.btnSaveCls); + iconEl.addClass('btn-synch'); + if (this.showSynchTip) { + this.btnSave.updateHint(''); + if (this.synchTooltip === undefined) + this.createSynchTip(); + + this.synchTooltip.show(); + } else { + this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); + } + + this.btnSave.setDisabled(false); + Common.Gateway.collaborativeChanges(); + }, + + createSynchTip: function () { + this.synchTooltip = new Common.UI.SynchronizeTip({ + target: $('#id-toolbar-btn-save') + }); + this.synchTooltip.on('dontshowclick', function () { + this.showSynchTip = false; + this.synchTooltip.hide(); + this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); + Common.localStorage.setItem("pe-hide-synch", 1); }, this); - } - }, + this.synchTooltip.on('closeclick', function () { + this.synchTooltip.hide(); + this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); + }, this); + }, - /** coauthoring begin **/ - onCollaborativeChanges: function() { - if (this._state.hasCollaborativeChanges) return; - if (!this.btnSave.rendered) { - this.needShowSynchTip = true; - return; - } + synchronizeChanges: function () { + if (this.btnSave.rendered) { + var iconEl = $('.btn-icon', this.btnSave.cmpEl); - var previewPanel = PE.getController('Viewport').getView('DocumentPreview'); - if (previewPanel && previewPanel.isVisible()) { - this.needShowSynchTip = true; - return; - } - - this._state.hasCollaborativeChanges = true; - var iconEl = $('.btn-icon', this.btnSave.cmpEl); - iconEl.removeClass(this.btnSaveCls); - iconEl.addClass('btn-synch'); - if (this.showSynchTip){ - this.btnSave.updateHint(''); - if (this.synchTooltip===undefined) - this.createSynchTip(); - - this.synchTooltip.show(); - } else { - this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); - } - - this.btnSave.setDisabled(false); - Common.Gateway.collaborativeChanges(); - }, - - createSynchTip: function () { - this.synchTooltip = new Common.UI.SynchronizeTip({ - target : $('#id-toolbar-btn-save') - }); - this.synchTooltip.on('dontshowclick', function() { - this.showSynchTip = false; - this.synchTooltip.hide(); - this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); - Common.localStorage.setItem("pe-hide-synch", 1); - }, this); - this.synchTooltip.on('closeclick', function() { - this.synchTooltip.hide(); - this.btnSave.updateHint(this.tipSynchronize + Common.Utils.String.platformKey('Ctrl+S')); - }, this); - }, - - synchronizeChanges: function() { - if (this.btnSave.rendered) { - var iconEl = $('.btn-icon', this.btnSave.cmpEl); - - if (iconEl.hasClass('btn-synch')) { - iconEl.removeClass('btn-synch'); - iconEl.addClass(this.btnSaveCls); - if (this.synchTooltip) - this.synchTooltip.hide(); - this.btnSave.updateHint(this.btnSaveTip); - this.btnSave.setDisabled(!this.mode.forcesave); - this._state.hasCollaborativeChanges = false; + if (iconEl.hasClass('btn-synch')) { + iconEl.removeClass('btn-synch'); + iconEl.addClass(this.btnSaveCls); + if (this.synchTooltip) + this.synchTooltip.hide(); + this.btnSave.updateHint(this.btnSaveTip); + this.btnSave.setDisabled(!this.mode.forcesave); + this._state.hasCollaborativeChanges = false; + } } - } - }, + }, - onApiUsersChanged: function(users) { - var editusers = []; - _.each(users, function(item){ - if (!item.asc_getView()) - editusers.push(item); - }); + onApiUsersChanged: function (users) { + var editusers = []; + _.each(users, function (item) { + if (!item.asc_getView()) + editusers.push(item); + }); - var length = _.size(editusers); - var cls = (length>1) ? 'btn-save-coauth' : 'btn-save'; - if (cls !== this.btnSaveCls && this.btnSave.rendered) { - this.btnSaveTip = ((length>1) ? this.tipSaveCoauth : this.tipSave )+ Common.Utils.String.platformKey('Ctrl+S'); + var length = _.size(editusers); + var cls = (length > 1) ? 'btn-save-coauth' : 'btn-save'; + if (cls !== this.btnSaveCls && this.btnSave.rendered) { + this.btnSaveTip = ((length > 1) ? this.tipSaveCoauth : this.tipSave ) + Common.Utils.String.platformKey('Ctrl+S'); - var iconEl = $('.btn-icon', this.btnSave.cmpEl); - if (!iconEl.hasClass('btn-synch')) { - iconEl.removeClass(this.btnSaveCls); - iconEl.addClass(cls); - this.btnSave.updateHint(this.btnSaveTip); + var iconEl = $('.btn-icon', this.btnSave.cmpEl); + if (!iconEl.hasClass('btn-synch')) { + iconEl.removeClass(this.btnSaveCls); + iconEl.addClass(cls); + this.btnSave.updateHint(this.btnSaveTip); + } + this.btnSaveCls = cls; } - this.btnSaveCls = cls; - } - }, + }, - /** coauthoring end **/ + /** coauthoring end **/ - onSlidePickerShowAfter: function(picker) { - if (!picker._needRecalcSlideLayout) return; - - if (picker.cmpEl && picker.dataViewItems.length>0) { - var dataViewItems = picker.dataViewItems, - el = $(dataViewItems[0].el), - itemW = el.outerWidth() + parseInt(el.css('margin-left')) + parseInt(el.css('margin-right')), - columnCount = Math.floor(picker.cmpEl.width() / itemW), - col = 0, maxHeight = 0; + onSlidePickerShowAfter: function (picker) { + if (!picker._needRecalcSlideLayout) return; - for (var i=0; i 0) { + var dataViewItems = picker.dataViewItems, + el = $(dataViewItems[0].el), + itemW = el.outerWidth() + parseInt(el.css('margin-left')) + parseInt(el.css('margin-right')), + columnCount = Math.floor(picker.cmpEl.width() / itemW), + col = 0, maxHeight = 0; - if (height>maxHeight) - maxHeight = height; - else - div.css({'height' : maxHeight }); + for (var i = 0; i < dataViewItems.length; i++) { + var div = $(dataViewItems[i].el).find('.title'), + height = div.height(); - col++; - if (col>columnCount-1) { col = 0; maxHeight = 0;} + if (height > maxHeight) + maxHeight = height; + else + div.css({'height': maxHeight}); + + col++; + if (col > columnCount - 1) { + col = 0; + maxHeight = 0; + } + } + picker._needRecalcSlideLayout = false; } - picker._needRecalcSlideLayout = false; - } - }, + }, - textBold: 'Bold', - textItalic: 'Italic', - textUnderline: 'Underline', - textStrikeout: 'Strikeout', - textSuperscript: 'Superscript', - textSubscript: 'Subscript', - tipFontName: 'Font Name', - tipFontSize: 'Font Size', - tipCopy: 'Copy', - tipPaste: 'Paste', - tipUndo: 'Undo', - tipRedo: 'Redo', - tipPrint: 'Print', - tipSave: 'Save', - tipFontColor: 'Font color', - tipMarkers: 'Bullets', - tipNumbers: 'Numbering', - tipBack: 'Back', - tipClearStyle: 'Clear Style', - tipCopyStyle: 'Copy Style', - textTitleError: 'Error', - tipHAligh: 'Horizontal Align', - tipVAligh: 'Vertical Align', - textAlignTop: 'Align text to the top', - textAlignMiddle: 'Align text to the middle', - textAlignBottom: 'Align text to the bottom', - textAlignLeft: 'Left align text', - textAlignRight: 'Right align text', - textAlignCenter: 'Center text', - textAlignJust: 'Justify', - tipDecPrLeft: 'Decrease Indent', - tipIncPrLeft: 'Increase Indent', - tipLineSpace: 'Line Spacing', - tipInsertTable: 'Insert Table', - tipInsertImage: 'Insert Picture', - mniImageFromFile: 'Picture from file', - mniImageFromUrl: 'Picture from url', - mniCustomTable: 'Insert Custom Table', - tipInsertHyperlink: 'Add Hyperlink', - tipInsertText: 'Insert Text', - tipInsertShape: 'Insert Autoshape', - tipPreview: 'Start Slideshow', - tipAddSlide: 'Add Slide', - tipNewDocument: 'New Document', - tipOpenDocument: 'Open Document', - tipShapeAlign: 'Align Shape', - tipShapeArrange: 'Arrange Shape', - textShapeAlignLeft: 'Align Left', - textShapeAlignRight: 'Align Right', - textShapeAlignCenter: 'Align Center', - textShapeAlignTop: 'Align Top', - textShapeAlignBottom: 'Align Bottom', - textShapeAlignMiddle: 'Align Middle', - textArrangeFront: 'Bring To Front', - textArrangeBack: 'Send To Back', - textArrangeForward: 'Bring Forward', - textArrangeBackward: 'Send Backward', - txtGroup: 'Group', - txtUngroup: 'Ungroup', - txtDistribHor: 'Distribute Horizontally', - txtDistribVert: 'Distribute Vertically', - tipChangeSlide: 'Change Slide Layout', - textOK: 'OK', - textCancel: 'Cancel', - tipColorSchemas: 'Change Color Scheme', - textNewColor: 'Add New Custom Color', - mniSlideStandard: 'Standard (4:3)', - mniSlideWide: 'Widescreen (16:9)', - mniSlideAdvanced: 'Advanced Settings', - tipSlideSize: 'Select Slide Size', - tipViewSettings: 'View Settings', - tipAdvSettings: 'Advanced Settings', - textCompactView: 'View Compact Toolbar', - textHideTitleBar: 'Hide Title Bar', - textHideStatusBar: 'Hide Status Bar', - textHideLines: 'Hide Rulers', - textFitPage: 'Fit to Slide', - textFitWidth: 'Fit to Width', - textZoom: 'Zoom', - tipInsertChart: 'Insert Chart', - textLine: 'Line', - textColumn: 'Column', - textBar: 'Bar', - textArea: 'Area', - textPie: 'Pie', - textPoint: 'XY (Scatter)', - textStock: 'Stock', - tipSynchronize: 'The document has been changed by another user. Please click to save your changes and reload the updates.', - txtScheme1: 'Office', - txtScheme2: 'Grayscale', - txtScheme3: 'Apex', - txtScheme4: 'Aspect', - txtScheme5: 'Civic', - txtScheme6: 'Concourse', - txtScheme7: 'Equity', - txtScheme8: 'Flow', - txtScheme9: 'Foundry', - txtScheme10: 'Median', - txtScheme11: 'Metro', - txtScheme12: 'Module', - txtScheme13: 'Opulent', - txtScheme14: 'Oriel', - txtScheme15: 'Origin', - txtScheme16: 'Paper', - txtScheme17: 'Solstice', - txtScheme18: 'Technic', - txtScheme19: 'Trek', - txtScheme20: 'Urban', - txtScheme21: 'Verve', - tipSlideTheme: 'Slide Theme', - tipSaveCoauth: 'Save your changes for the other users to see them.', - textInsText: 'Insert text box', - textInsTextArt: 'Insert Text Art', - textShowBegin: 'Show from Beginning', - textShowCurrent: 'Show from Current slide', - textShowSettings: 'Show Settings', - tipInsertEquation: 'Insert Equation', - textCharts: 'Charts', - tipChangeChart: 'Change Chart Type' - }, PE.Views.Toolbar || {})); + setTab: function (tab) { + if ( !tab || !tab.length ) { + if ( isFolded ) onShowCoveredPanel(false); + else tab = lastPanel; + } + + if ( tab ) { + $tabs.removeClass('active'); + $panels.removeClass('active'); + + var panel = $panels.filter('[data-tab=' + tab + ']'); + if (panel.length) { + lastPanel = tab; + panel.addClass('active'); + } + + var $tp = $tabs.find('> a[data-tab=' + tab + ']').parent(); + if ($tp.length) { + $tp.addClass('active'); + + $marker.width($tp.width()); + + if ($scrollL.is(':visible')) + $marker.css({left: $tp.position().left + $boxTabs.scrollLeft() - $scrollL.width()}); + else $marker.css({left: $tp.position().left}); + } + + if ( isFolded ) { + if ( panel.length ) + expandToolbar(); else + onShowCoveredPanel(true); + } + } + }, + + addTab: function (tab, panel, after) { + function _get_tab_action(index) { + if ( !config.tabs[index] ) + return _get_tab_action(--index); + + return config.tabs[index].action; + } + + var _tplTab = '
  • <%= caption %>
  • '; + + config.tabs[after + 1] = tab; + var _after_action = _get_tab_action( after ); + + var _elements = $tabs || config.$layout.find('.tabs'); + var $target = _elements.find('a[data-tab=' + _after_action + ']'); + if ( $target.length ) { + $target.parent().after( _.template(_tplTab, tab) ); + + if ( panel ) { + _elements = $panels || config.$layout.find('.box-panels > .panel'); + $target = _elements.filter('[data-tab=' + _after_action + ']'); + + if ( $target.length ) { + $target.after(panel); + } + } + + // synchronize matched elements + $tabs && ($tabs = $boxTabs.find('> li')); + $panels && ($panels = this.$el.find('.box-panels > .panel')); + } + }, + + setFolded: function (f) { + setFolded.call(this, f); + }, + + setExtra: function (place, el) { + if ( $tabs ) { + } else { + if ( place == 'right' ) { + config.$layout.find('.extra.right').html(el); + } else + if ( place == 'left' ) { + config.$layout.find('.extra.left').html(el); + } + } + }, + + isCompact: function () { + return isFolded; + }, + + updateTextartMenu: function (collection) { + var me = this; + + me.btnsInsertText.forEach(function (btn) { + if ( btn.textartPicker ) { + if ( btn.textartPicker.store.size() == collection.size() ) { + btn.textartPicker.store.each(function (model, index) { + model.set('imageUrl', collection.at(index).get('imageUrl')); + }); + } else { + btn.textartPicker.store.reset( collection.models ); + } + } else { + btn.textartPicker = new Common.UI.DataView({ + el: $('.view-insert-art', btn.menu.items[1].$el), + store: collection, + parentMenu: btn.menu.items[1], + showLast: false, + itemTemplate: _.template('
    ') + }); + + btn.textartPicker.on('item:click', function(picker, item, record, e) { + me.fireEvent('insert:textart', [record.get('data')]); + + if (e.type !== 'click') this.menu.hide(); + }); + } + }); + }, + + updateAutoshapeMenu: function (collection) { + var me = this; + for (var i = 0; i < collection.size(); i++) { + var group = collection.at(i); + + me.btnsInsertShape.forEach(function (btn, index) { + var menuitem = new Common.UI.MenuItem({ + caption: group.get('groupName'), + menu: new Common.UI.Menu({ + menuAlign: 'tl-tr', + items: [ + { template: _.template('
    ') } + ] + }) + }); + + btn.menu.addItem(menuitem); + + (new Common.UI.DataView({ + el: $('.shapegroup-' + i, menuitem.$el), + store: group.get('groupStore'), + parentMenu: menuitem.menu, + showLast: false, + itemTemplate: _.template('
    ') + })).on('item:click', function (picker, item, record, e) { + if (e.type !== 'click') Common.UI.Menu.Manager.hideAll(); + me.fireEvent('insert:shape', [record.get('data').shapeType]); + }); + }); + } + }, + + textBold: 'Bold', + textItalic: 'Italic', + textUnderline: 'Underline', + textStrikeout: 'Strikeout', + textSuperscript: 'Superscript', + textSubscript: 'Subscript', + tipFontName: 'Font Name', + tipFontSize: 'Font Size', + tipCopy: 'Copy', + tipPaste: 'Paste', + tipUndo: 'Undo', + tipRedo: 'Redo', + tipPrint: 'Print', + tipSave: 'Save', + tipFontColor: 'Font color', + tipMarkers: 'Bullets', + tipNumbers: 'Numbering', + tipBack: 'Back', + tipClearStyle: 'Clear Style', + tipCopyStyle: 'Copy Style', + textTitleError: 'Error', + tipHAligh: 'Horizontal Align', + tipVAligh: 'Vertical Align', + textAlignTop: 'Align text to the top', + textAlignMiddle: 'Align text to the middle', + textAlignBottom: 'Align text to the bottom', + textAlignLeft: 'Left align text', + textAlignRight: 'Right align text', + textAlignCenter: 'Center text', + textAlignJust: 'Justify', + tipDecPrLeft: 'Decrease Indent', + tipIncPrLeft: 'Increase Indent', + tipLineSpace: 'Line Spacing', + tipInsertTable: 'Insert Table', + tipInsertImage: 'Insert Picture', + mniImageFromFile: 'Picture from file', + mniImageFromUrl: 'Picture from url', + mniCustomTable: 'Insert Custom Table', + tipInsertHyperlink: 'Add Hyperlink', + tipInsertText: 'Insert Text', + tipInsertShape: 'Insert Autoshape', + tipPreview: 'Start Slideshow', + tipAddSlide: 'Add Slide', + tipShapeAlign: 'Align Shape', + tipShapeArrange: 'Arrange Shape', + textShapeAlignLeft: 'Align Left', + textShapeAlignRight: 'Align Right', + textShapeAlignCenter: 'Align Center', + textShapeAlignTop: 'Align Top', + textShapeAlignBottom: 'Align Bottom', + textShapeAlignMiddle: 'Align Middle', + textArrangeFront: 'Bring To Front', + textArrangeBack: 'Send To Back', + textArrangeForward: 'Bring Forward', + textArrangeBackward: 'Send Backward', + txtGroup: 'Group', + txtUngroup: 'Ungroup', + txtDistribHor: 'Distribute Horizontally', + txtDistribVert: 'Distribute Vertically', + tipChangeSlide: 'Change Slide Layout', + textOK: 'OK', + textCancel: 'Cancel', + tipColorSchemas: 'Change Color Scheme', + textNewColor: 'Add New Custom Color', + mniSlideStandard: 'Standard (4:3)', + mniSlideWide: 'Widescreen (16:9)', + mniSlideAdvanced: 'Advanced Settings', + tipSlideSize: 'Select Slide Size', + tipViewSettings: 'View Settings', + tipAdvSettings: 'Advanced Settings', + textCompactView: 'View Compact Toolbar', + textHideTitleBar: 'Hide Title Bar', + textHideStatusBar: 'Hide Status Bar', + textHideLines: 'Hide Rulers', + textFitPage: 'Fit to Slide', + textFitWidth: 'Fit to Width', + textZoom: 'Zoom', + tipInsertChart: 'Insert Chart', + textLine: 'Line', + textColumn: 'Column', + textBar: 'Bar', + textArea: 'Area', + textPie: 'Pie', + textPoint: 'XY (Scatter)', + textStock: 'Stock', + tipSynchronize: 'The document has been changed by another user. Please click to save your changes and reload the updates.', + txtScheme1: 'Office', + txtScheme2: 'Grayscale', + txtScheme3: 'Apex', + txtScheme4: 'Aspect', + txtScheme5: 'Civic', + txtScheme6: 'Concourse', + txtScheme7: 'Equity', + txtScheme8: 'Flow', + txtScheme9: 'Foundry', + txtScheme10: 'Median', + txtScheme11: 'Metro', + txtScheme12: 'Module', + txtScheme13: 'Opulent', + txtScheme14: 'Oriel', + txtScheme15: 'Origin', + txtScheme16: 'Paper', + txtScheme17: 'Solstice', + txtScheme18: 'Technic', + txtScheme19: 'Trek', + txtScheme20: 'Urban', + txtScheme21: 'Verve', + tipSlideTheme: 'Slide Theme', + tipSaveCoauth: 'Save your changes for the other users to see them.', + textInsText: 'Insert text box', + textInsTextArt: 'Insert Text Art', + textShowBegin: 'Show from Beginning', + textShowCurrent: 'Show from Current slide', + textShowSettings: 'Show Settings', + tipInsertEquation: 'Insert Equation', + textCharts: 'Charts', + tipChangeChart: 'Change Chart Type', + capInsertText: 'Text Box', + capInsertImage: 'Picture', + capInsertShape: 'Shape', + capInsertTable: 'Table', + capInsertChart: 'Chart', + capInsertHyperlink: 'Hyperlink', + capInsertEquation: 'Equation', + capAddSlide: 'Add Slide', + capTabFile: 'File', + capTabHome: 'Home', + capTabInsert: 'Insert' + } + }()), PE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/app/view/Viewport.js b/apps/presentationeditor/main/app/view/Viewport.js index 3dfc918e5..fcb4b73c3 100644 --- a/apps/presentationeditor/main/app/view/Viewport.js +++ b/apps/presentationeditor/main/app/view/Viewport.js @@ -87,15 +87,12 @@ define([ box: $container, items: [{ el: items[0], - rely: true + height: Common.localStorage.getBool('pe-compact-toolbar') ? 40 : 40+67 }, { el: items[1], - rely: true - }, { - el: items[2], stretch: true }, { - el: items[3], + el: items[2], height: 25 }] }); @@ -126,17 +123,10 @@ define([ }, applyEditorMode: function() { - var me = this, - toolbarView = PE.getController('Toolbar').getView('Toolbar'), - rightMenuView = PE.getController('RightMenu').getView('RightMenu'), - statusBarView = PE.getController('Statusbar').getView('Statusbar'); + PE.getController('RightMenu').getView('RightMenu').render(); - me._toolbar = toolbarView.render(this.mode); - me._rightMenu = rightMenuView.render(); - - var value = Common.localStorage.getItem('pe-hidden-status'); - if (value !== null && parseInt(value) == 1) - statusBarView.setVisible(false); + if ( Common.localStorage.getBool('pe-hidden-status') ) + PE.getController('Statusbar').getView('Statusbar').setVisible(false); }, setMode: function(mode, delay) { diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index fe010e70d..8a0bfa456 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -78,10 +78,22 @@ "Common.Views.ExternalDiagramEditor.textClose": "Close", "Common.Views.ExternalDiagramEditor.textSave": "Save & Exit", "Common.Views.ExternalDiagramEditor.textTitle": "Chart Editor", - "Common.Views.Header.openNewTabText": "Open in New Tab", - "Common.Views.Header.textBack": "Go to Documents", + "del_Common.Views.Header.openNewTabText": "Open in New Tab", + "del_Common.Views.Header.textBack": "Go to Documents", "del_Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE", + "del_Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.itemBackNewTab": "Open in New Tab", + "Common.Views.Header.itemBackCurrTab": "Open in Current Tab", + "Common.Views.Header.textSaveBegin": "Saving...", + "Common.Views.Header.textSaveEnd": "All changes saved", + "Common.Views.Header.textSaveChanged": "Modified", + "Common.Views.Header.textSaveExpander": "All changes saved", + "Common.Views.Header.textBack": "Go to Documents", + "Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE", "Common.Views.Header.txtRename": "Rename", + "Common.Views.Header.txtAccessRights": "Change access rights", + "Common.Views.Header.tipAccessRights": "Manage document access rights", + "Common.Views.Header.labelCoUsersDescr": "Document is currently being edited by several users.", "Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel", "Common.Views.ImageFromUrlDialog.okButtonText": "OK", "Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:", @@ -166,8 +178,8 @@ "PE.Controllers.Main.saveErrorText": "An error has occurred while saving the file", "PE.Controllers.Main.savePreparingText": "Preparing to save", "PE.Controllers.Main.savePreparingTitle": "Preparing to save. Please wait...", - "PE.Controllers.Main.saveTextText": "Saving presentation...", - "PE.Controllers.Main.saveTitleText": "Saving Presentation", + "del_PE.Controllers.Main.saveTextText": "Saving presentation...", + "del_PE.Controllers.Main.saveTitleText": "Saving Presentation", "PE.Controllers.Main.splitDividerErrorText": "The number of rows must be a divisor of %1.", "PE.Controllers.Main.splitMaxColsErrorText": "The number of columns must be less than %1.", "PE.Controllers.Main.splitMaxRowsErrorText": "The number of rows must be less than %1.", @@ -247,7 +259,7 @@ "PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "PE.Controllers.Main.titleServerVersion": "Editor updated", "PE.Controllers.Main.errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.", - "PE.Controllers.Main.textChangesSaved": "All changes saved", + "del_PE.Controllers.Main.textChangesSaved": "All changes saved", "PE.Controllers.Main.errorBadImageUrl": "Image URL is incorrect", "PE.Controllers.Statusbar.zoomText": "Zoom {0}%", "PE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.
    The text style will be displayed using one of the system fonts, the saved font will be used when it is available.
    Do you want to continue?", @@ -870,7 +882,7 @@ "PE.Views.LeftMenu.tipAbout": "About", "PE.Views.LeftMenu.tipChat": "Chat", "PE.Views.LeftMenu.tipComments": "Comments", - "PE.Views.LeftMenu.tipFile": "File", + "del_PE.Views.LeftMenu.tipFile": "File", "PE.Views.LeftMenu.tipPlugins": "Plugins", "PE.Views.LeftMenu.tipSearch": "Search", "PE.Views.LeftMenu.tipSlides": "Slides", @@ -1097,15 +1109,15 @@ "PE.Views.Statusbar.tipAccessRights": "Manage document access rights", "PE.Views.Statusbar.tipFitPage": "Fit to Slide", "PE.Views.Statusbar.tipFitWidth": "Fit to Width", - "PE.Views.Statusbar.tipMoreUsers": "and %1 users.", + "del_PE.Views.Statusbar.tipMoreUsers": "and %1 users.", "PE.Views.Statusbar.tipPreview": "Start Slideshow", - "PE.Views.Statusbar.tipShowUsers": "To see all users click the icon below.", - "PE.Views.Statusbar.tipUsers": "Document is currently being edited by several users.", - "PE.Views.Statusbar.tipViewUsers": "View users and manage document access rights", + "del_PE.Views.Statusbar.tipShowUsers": "To see all users click the icon below.", + "del_PE.Views.Statusbar.tipUsers": "Document is currently being edited by several users.", + "del_PE.Views.Statusbar.tipViewUsers": "View users and manage document access rights", "PE.Views.Statusbar.tipZoomFactor": "Magnification", "PE.Views.Statusbar.tipZoomIn": "Zoom In", "PE.Views.Statusbar.tipZoomOut": "Zoom Out", - "PE.Views.Statusbar.txAccessRights": "Change access rights", + "del_PE.Views.Statusbar.txAccessRights": "Change access rights", "PE.Views.Statusbar.txtPageNumInvalid": "Invalid slide number", "PE.Views.TableSettings.deleteColumnText": "Delete Column", "PE.Views.TableSettings.deleteRowText": "Delete Row", @@ -1258,6 +1270,17 @@ "PE.Views.Toolbar.textTitleError": "Error", "PE.Views.Toolbar.textUnderline": "Underline", "PE.Views.Toolbar.textZoom": "Zoom", + "PE.Views.Toolbar.capInsertText": "Text Box", + "PE.Views.Toolbar.capInsertImage": "Picture", + "PE.Views.Toolbar.capInsertShape": "Shape", + "PE.Views.Toolbar.capInsertTable": "Table", + "PE.Views.Toolbar.capInsertChart": "Chart", + "PE.Views.Toolbar.capInsertHyperlink": "Hyperlink", + "PE.Views.Toolbar.capInsertEquation": "Equation", + "PE.Views.Toolbar.capAddSlide": "Add Slide", + "PE.Views.Toolbar.capTabFile": "File", + "PE.Views.Toolbar.capTabHome": "Home", + "PE.Views.Toolbar.capTabInsert": "Insert", "PE.Views.Toolbar.tipAddSlide": "Add Slide", "PE.Views.Toolbar.tipAdvSettings": "Advanced Settings", "PE.Views.Toolbar.tipBack": "Back", @@ -1283,9 +1306,9 @@ "PE.Views.Toolbar.tipInsertText": "Insert Text", "PE.Views.Toolbar.tipLineSpace": "Line Spacing", "PE.Views.Toolbar.tipMarkers": "Bullets", - "PE.Views.Toolbar.tipNewDocument": "New Presentation", + "del_PE.Views.Toolbar.tipNewDocument": "New Presentation", "PE.Views.Toolbar.tipNumbers": "Numbering", - "PE.Views.Toolbar.tipOpenDocument": "Open Presentation", + "del_PE.Views.Toolbar.tipOpenDocument": "Open Presentation", "PE.Views.Toolbar.tipPaste": "Paste", "PE.Views.Toolbar.tipPreview": "Start Slideshow", "PE.Views.Toolbar.tipPrint": "Print", diff --git a/apps/presentationeditor/main/resources/less/app.less b/apps/presentationeditor/main/resources/less/app.less index f8c21a415..d71350e13 100644 --- a/apps/presentationeditor/main/resources/less/app.less +++ b/apps/presentationeditor/main/resources/less/app.less @@ -111,6 +111,7 @@ @import "../../../../common/main/resources/less/common.less"; @import "../../../../common/main/resources/less/opendialog.less"; @import "../../../../common/main/resources/less/plugins.less"; +@import "../../../../common/main/resources/less/toolbar.less"; // App // -------------------------------------------------- diff --git a/apps/presentationeditor/main/resources/less/toolbar.less b/apps/presentationeditor/main/resources/less/toolbar.less index ac9652adb..682f18809 100644 --- a/apps/presentationeditor/main/resources/less/toolbar.less +++ b/apps/presentationeditor/main/resources/less/toolbar.less @@ -1,72 +1,6 @@ + .toolbar { - padding: 10px 0; - background-color: @gray-light; - .box-inner-shadow(0 -1px 0 @gray-dark); - - .toolbar-group { - display: table-cell; - vertical-align: top; - white-space: nowrap; - padding-left: 12px; - - &:last-child { - padding-right: 12px; - } - } - - .toolbar-row { - height: 20px; - font-size: 0; - - &:not(:first-child) { - margin-top: 6px; - } - } - - .separator { - margin-left: 12px; - - &.long { - height: 46px; - } - - &.short { - height: 20px; - } - } - - .btn-placeholder { -// background-color: red; - display: inline-block; - width: 20px; - height: 20px; - - &:not(:first-child) { - margin-left: 1px; - } - - &.large { - width: 31px; - height: 31px; - margin: 8px 0; - - &.split { - width: 40px; - } - } - - &.split { - width: 28px; - } - - &.border { - border: 1px solid @gray; - .border-radius(1px); - width: 22px; - height: 22px; - } - } - + z-index: 101; &.masked { .btn-toolbar.disabled .btn-icon:not(.btn-print):not(.btn-save):not(.btn-save-coauth):not(.btn-settings):not(.btn-hidebars) { @@ -323,7 +257,10 @@ .toolbar-btn-icon(btn-linespace, 36, @toolbar-icon-size); .toolbar-btn-icon(btn-arrange-shape, 37, @toolbar-icon-size); .toolbar-btn-icon(btn-align-shape, 38, @toolbar-icon-size); -.toolbar-btn-icon(btn-insertshape, 39, @toolbar-icon-size); + +//.toolbar-btn-icon(btn-insertshape, 39, @toolbar-icon-size); +.button-normal-icon(btn-insertshape, 39, @toolbar-icon-size); + .toolbar-btn-icon(btn-inserttext, 40, @toolbar-icon-size); .toolbar-btn-icon(btn-inserthyperlink, 41, @toolbar-icon-size); .toolbar-btn-icon(btn-inserttable, 42, @toolbar-icon-size); @@ -338,6 +275,8 @@ .toolbar-btn-icon(btn-save-coauth, 69, @toolbar-icon-size); .toolbar-btn-icon(btn-insertequation, 74, @toolbar-icon-size); +.button-otherstates-icon2(btn-toolbar, @toolbar-icon-size); + // add slide .btn-toolbar .btn-addslide {background-position: 0 -120px;} .btn-toolbar.active > .btn-addslide, @@ -383,7 +322,7 @@ border: none; border-radius: 0; padding: 3px 10px; - color: #ffffff; + color: #fff; font: 11px arial; white-space: nowrap; letter-spacing: 1px; @@ -392,4 +331,4 @@ .item-equation { border: 1px solid @gray; .background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px); -} \ No newline at end of file +}