diff --git a/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js b/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js index a6da1bba3..b3a35d3e8 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js +++ b/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js @@ -51,22 +51,24 @@ define([ 'CellEditor' ], - // events: function() { - // return { + events: function() { + return { // 'keyup input#ce-cell-name': _.bind(this.onCellName,this), // 'keyup textarea#ce-cell-content': _.bind(this.onKeyupCellEditor,this), // 'blur textarea#ce-cell-content': _.bind(this.onBlurCellEditor,this), - // 'click button#ce-func-label': _.bind(this.onInsertFunction, this) - // }; - // }, + // 'click a#ce-function': _.bind(this.onInsertFunction, this) + }; + }, initialize: function() { - // this.addListeners({ - // 'CellEditor': {}, + this.addListeners({ + 'CellEditor': { + 'function:click': this.onInsertFunction.bind(this) + } // 'Viewport': { // 'layout:resizedrag': _.bind(this.onLayoutResize, this) // } - // }); + }); }, setApi: function(api) { @@ -168,13 +170,10 @@ define([ }, onInsertFunction: function() { - if ( this.mode.isEdit && !this.editor.$btnfunc['hasClass']('disabled')) { - var controller = this.getApplication().getController('FormulaDialog'); - if (controller) { - $('#ce-func-label', this.editor.el).blur(); - controller.showDialog(); - } - } + SSE.getController('AddContainer').showModal({ + panel: 'function', + button: '#ce-function' + }); } }); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddContainer.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddContainer.js index 845efc756..48f22c626 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddContainer.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddContainer.js @@ -51,6 +51,9 @@ define([ SSE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() { // private + var parentButton = null, + options; + return { models: [], collections: [], @@ -68,7 +71,7 @@ define([ // }, - showModal: function() { + showModal: function(opts) { var me = this; if ($$('.container-add.modal-in').length > 0) { @@ -77,8 +80,11 @@ define([ uiApp.closeModal(); + options = opts; + parentButton = !opts ? '#toolbar-add' : opts.button; me._showByStack(Common.SharedSettings.get('phone')); + this.api.asc_closeCellEditor(); SSE.getController('Toolbar').getView('Toolbar').hideSearch(); }, @@ -88,47 +94,39 @@ define([ } }, - _dummyEditController: function () { - var layout = - '
' + - '
' + - '

Under Construction

' + - '
' + - '
'; - - return { - getCaption: function () { return 'Dummy' }, - getLayout : function () { return layout } - } - }, - _layoutEditorsByStack: function () { var me = this, addViews = []; - addViews.push({ - caption: me.textChart, - id: 'add-chart', - layout: SSE.getController('AddChart').getView('AddChart').rootLayout() - }); + // var seltype = this.api.asc_getCellInfo().asc_getFlags().asc_getSelectionType(); - addViews.push({ - caption: me.textFormula, - id: 'add-formula', - layout: SSE.getController('AddFunction').getView('AddFunction').rootLayout() - }); + if ( !options ) + addViews.push({ + caption: me.textChart, + id: 'add-chart', + layout: SSE.getController('AddChart').getView('AddChart').rootLayout() + }); - addViews.push({ - caption: me.textShape, - id: 'add-shape', - layout: SSE.getController('AddShape').getView('AddShape').rootLayout() - }); + if ( !options || options.panel == 'function' ) + addViews.push({ + caption: me.textFormula, + id: 'add-formula', + layout: SSE.getController('AddFunction').getView('AddFunction').rootLayout() + }); - addViews.push({ - caption: me.textOther, - id: 'add-other', - layout: SSE.getController('AddOther').getView('AddOther').rootLayout() - }); + if ( !options ) + addViews.push({ + caption: me.textShape, + id: 'add-shape', + layout: SSE.getController('AddShape').getView('AddShape').rootLayout() + }); + + if ( !options ) + addViews.push({ + caption: me.textOther, + id: 'add-other', + layout: SSE.getController('AddOther').getView('AddOther').rootLayout() + }); return addViews; }, @@ -153,33 +151,40 @@ define([ ); - if (isAndroid) { + if (layoutAdds.length < 2) { $layoutNavbar .find('.center') - .append('
'); + .removeClass('categories') + .html(layoutAdds[0].caption); + } else { + if (isAndroid) { + $layoutNavbar + .find('.center') + .append('
'); - _.each(layoutAdds, function (layout, index) { + _.each(layoutAdds, function (layout, index) { + $layoutNavbar + .find('.toolbar-inner') + .append( + '' + layout.caption + '' + ); + }); $layoutNavbar .find('.toolbar-inner') - .append( - '' + layout.caption + '' - ); - }); - $layoutNavbar - .find('.toolbar-inner') - .append(''); - } else { - $layoutNavbar - .find('.center') - .append('
'); - - _.each(layoutAdds, function (layout, index) { + .append(''); + } else { $layoutNavbar - .find('.buttons-row') - .append( - '' + layout.caption + '' - ); - }); + .find('.center') + .append('
'); + + _.each(layoutAdds, function (layout, index) { + $layoutNavbar + .find('.buttons-row') + .append( + '' + layout.caption + '' + ); + }); + } } @@ -232,7 +237,7 @@ define([ '' + '' + '', - $$('#toolbar-add') + $$(parentButton) ); // Prevent hide overlay. Conflict popover and modals. diff --git a/apps/spreadsheeteditor/mobile/app/view/CellEditor.js b/apps/spreadsheeteditor/mobile/app/view/CellEditor.js index 8930c8096..a1e247f3a 100644 --- a/apps/spreadsheeteditor/mobile/app/view/CellEditor.js +++ b/apps/spreadsheeteditor/mobile/app/view/CellEditor.js @@ -52,7 +52,10 @@ define([ template: _.template(template), events: { - 'click button#ce-btn-expand': 'expandEditor' + 'click button#ce-btn-expand': 'expandEditor', + 'click #ce-function': function (e) { + this.fireEvent('function:click', this); + } }, initialize: function (options) { @@ -64,7 +67,7 @@ define([ this.$cellname = $('#ce-cell-name', this.el); this.$btnexpand = $('#ce-btn-expand', this.el); - // this.$btnfunc = $('#ce-func-label', this.el); + // this.$btnfunc = $('#ce-function', this.el); return this; },