[SSE mobile] open Function panel for CellEditor

This commit is contained in:
Maxim Kadushkin 2016-12-21 17:33:17 +03:00
parent 0496f3ba90
commit 35073c9028
3 changed files with 81 additions and 74 deletions

View file

@ -51,22 +51,24 @@ define([
'CellEditor' 'CellEditor'
], ],
// events: function() { events: function() {
// return { return {
// 'keyup input#ce-cell-name': _.bind(this.onCellName,this), // 'keyup input#ce-cell-name': _.bind(this.onCellName,this),
// 'keyup textarea#ce-cell-content': _.bind(this.onKeyupCellEditor,this), // 'keyup textarea#ce-cell-content': _.bind(this.onKeyupCellEditor,this),
// 'blur textarea#ce-cell-content': _.bind(this.onBlurCellEditor,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() { initialize: function() {
// this.addListeners({ this.addListeners({
// 'CellEditor': {}, 'CellEditor': {
'function:click': this.onInsertFunction.bind(this)
}
// 'Viewport': { // 'Viewport': {
// 'layout:resizedrag': _.bind(this.onLayoutResize, this) // 'layout:resizedrag': _.bind(this.onLayoutResize, this)
// } // }
// }); });
}, },
setApi: function(api) { setApi: function(api) {
@ -168,13 +170,10 @@ define([
}, },
onInsertFunction: function() { onInsertFunction: function() {
if ( this.mode.isEdit && !this.editor.$btnfunc['hasClass']('disabled')) { SSE.getController('AddContainer').showModal({
var controller = this.getApplication().getController('FormulaDialog'); panel: 'function',
if (controller) { button: '#ce-function'
$('#ce-func-label', this.editor.el).blur(); });
controller.showDialog();
}
}
} }
}); });
}); });

View file

@ -51,6 +51,9 @@ define([
SSE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() { SSE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() {
// private // private
var parentButton = null,
options;
return { return {
models: [], models: [],
collections: [], collections: [],
@ -68,7 +71,7 @@ define([
// //
}, },
showModal: function() { showModal: function(opts) {
var me = this; var me = this;
if ($$('.container-add.modal-in').length > 0) { if ($$('.container-add.modal-in').length > 0) {
@ -77,8 +80,11 @@ define([
uiApp.closeModal(); uiApp.closeModal();
options = opts;
parentButton = !opts ? '#toolbar-add' : opts.button;
me._showByStack(Common.SharedSettings.get('phone')); me._showByStack(Common.SharedSettings.get('phone'));
this.api.asc_closeCellEditor();
SSE.getController('Toolbar').getView('Toolbar').hideSearch(); SSE.getController('Toolbar').getView('Toolbar').hideSearch();
}, },
@ -88,47 +94,39 @@ define([
} }
}, },
_dummyEditController: function () {
var layout =
'<div class="content-block inset">' +
'<div class="content-block-inner"> ' +
'<p>Under Construction</p>' +
'</div>' +
'</div>';
return {
getCaption: function () { return 'Dummy' },
getLayout : function () { return layout }
}
},
_layoutEditorsByStack: function () { _layoutEditorsByStack: function () {
var me = this, var me = this,
addViews = []; addViews = [];
addViews.push({ // var seltype = this.api.asc_getCellInfo().asc_getFlags().asc_getSelectionType();
caption: me.textChart,
id: 'add-chart',
layout: SSE.getController('AddChart').getView('AddChart').rootLayout()
});
addViews.push({ if ( !options )
caption: me.textFormula, addViews.push({
id: 'add-formula', caption: me.textChart,
layout: SSE.getController('AddFunction').getView('AddFunction').rootLayout() id: 'add-chart',
}); layout: SSE.getController('AddChart').getView('AddChart').rootLayout()
});
addViews.push({ if ( !options || options.panel == 'function' )
caption: me.textShape, addViews.push({
id: 'add-shape', caption: me.textFormula,
layout: SSE.getController('AddShape').getView('AddShape').rootLayout() id: 'add-formula',
}); layout: SSE.getController('AddFunction').getView('AddFunction').rootLayout()
});
addViews.push({ if ( !options )
caption: me.textOther, addViews.push({
id: 'add-other', caption: me.textShape,
layout: SSE.getController('AddOther').getView('AddOther').rootLayout() 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; return addViews;
}, },
@ -153,33 +151,40 @@ define([
); );
if (isAndroid) { if (layoutAdds.length < 2) {
$layoutNavbar $layoutNavbar
.find('.center') .find('.center')
.append('<div class="toolbar tabbar"><div data-page="index" class="toolbar-inner"></div></div>'); .removeClass('categories')
.html(layoutAdds[0].caption);
} else {
if (isAndroid) {
$layoutNavbar
.find('.center')
.append('<div class="toolbar tabbar"><div data-page="index" class="toolbar-inner"></div></div>');
_.each(layoutAdds, function (layout, index) { _.each(layoutAdds, function (layout, index) {
$layoutNavbar
.find('.toolbar-inner')
.append(
'<a href="#' + layout.id + '" class="tab-link ' + (index < 1 ? 'active' : '') + '">' + layout.caption + '</a>'
);
});
$layoutNavbar $layoutNavbar
.find('.toolbar-inner') .find('.toolbar-inner')
.append( .append('<span class="tab-link-highlight" style="width: ' + (100 / layoutAdds.length) + '%;"></span>');
'<a href="#' + layout.id + '" class="tab-link ' + (index < 1 ? 'active' : '') + '">' + layout.caption + '</a>' } else {
);
});
$layoutNavbar
.find('.toolbar-inner')
.append('<span class="tab-link-highlight" style="width: ' + (100/layoutAdds.length) + '%;"></span>');
} else {
$layoutNavbar
.find('.center')
.append('<div class="buttons-row"></div>');
_.each(layoutAdds, function (layout, index) {
$layoutNavbar $layoutNavbar
.find('.buttons-row') .find('.center')
.append( .append('<div class="buttons-row"></div>');
'<a href="#' + layout.id + '" class="tab-link button ' + (index < 1 ? 'active' : '') + '">' + layout.caption + '</a>'
); _.each(layoutAdds, function (layout, index) {
}); $layoutNavbar
.find('.buttons-row')
.append(
'<a href="#' + layout.id + '" class="tab-link button ' + (index < 1 ? 'active' : '') + '">' + layout.caption + '</a>'
);
});
}
} }
@ -232,7 +237,7 @@ define([
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>', '</div>',
$$('#toolbar-add') $$(parentButton)
); );
// Prevent hide overlay. Conflict popover and modals. // Prevent hide overlay. Conflict popover and modals.

View file

@ -52,7 +52,10 @@ define([
template: _.template(template), template: _.template(template),
events: { 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) { initialize: function (options) {
@ -64,7 +67,7 @@ define([
this.$cellname = $('#ce-cell-name', this.el); this.$cellname = $('#ce-cell-name', this.el);
this.$btnexpand = $('#ce-btn-expand', this.el); this.$btnexpand = $('#ce-btn-expand', this.el);
// this.$btnfunc = $('#ce-func-label', this.el); // this.$btnfunc = $('#ce-function', this.el);
return this; return this;
}, },