diff --git a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js index d2ecea7311..3f3f006c71 100644 --- a/apps/spreadsheeteditor/main/app/view/FormulaWizard.js +++ b/apps/spreadsheeteditor/main/app/view/FormulaWizard.js @@ -39,46 +39,56 @@ */ define([ - 'common/main/lib/component/Window', + 'common/main/lib/view/AdvancedSettingsWindow', 'common/main/lib/component/MetricSpinner' ], function () { 'use strict'; - SSE.Views.FormulaWizard = Common.UI.Window.extend(_.extend({ + SSE.Views.FormulaWizard = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { - width: 420, - height: 460, - header: true, - style: 'min-width: 350px;', - cls: 'modal-dlg', - buttons: ['ok', 'cancel'] + contentWidth: 580, + height: 420 }, initialize : function(options) { + var me = this; _.extend(this.options, { - title: this.textTitle - }, options || {}); - - this.template = [ - '
', - '', - '
', - '
', - '', - '
', + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '', + '
', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '', + '', + '', + '', + '', + '
', + '
', + '
', '
', '
', - '
', - '', - '', - '', - '', - '', - '
', - '
', - '
' - ].join(''); + '
' + ].join('') + }, options); - this.options.tpl = _.template(this.template)(this.options); this.props = this.options.props; this.funcprops = this.options.funcprops; this.api = this.options.api; @@ -90,22 +100,26 @@ define([ this.helpUrl = undefined; this.minArgCount = 1; this.maxArgCount = 1; + this.minArgWidth = 50; - Common.UI.Window.prototype.initialize.call(this, this.options); + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); }, render: function() { - Common.UI.Window.prototype.render.call(this); + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var $window = this.getChild(); - $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); $window.find('input').on('keypress', _.bind(this.onKeyPress, this)); + this.contentPanel = $window.find('.content-panel'); + this.innerPanel = $window.find('.inner-content'); + this.panelArgs = $window.find('#formula-wizard-panel-args'); this.tableArgs = $window.find('#formula-wizard-tbl-args'); this.panelDesc = $window.find('#formula-wizard-panel-desc'); this.lblArgDesc = $window.find('#formula-wizard-arg-desc'); - this.lblResult = $window.find('#formula-wizard-value'); + this.lblFormulaResult = $window.find('#formula-wizard-value'); + this.lblFunctionResult = $window.find('#formula-wizard-lbl-val-func'); this._preventCloseCellEditor = false; @@ -113,7 +127,7 @@ define([ }, afterRender: function() { - this.setSettings(); + this._setDefaults(); }, _handleInput: function(state) { @@ -123,7 +137,7 @@ define([ this.close(); }, - onBtnClick: function(event) { + onDlgBtnClick: function(event) { this._handleInput(event.currentTarget.attributes['result'].value); }, @@ -133,28 +147,25 @@ define([ } }, - setSettings: function () { + onPrimary: function() { + this._handleInput('ok'); + return false; + }, + + _setDefaults: function () { var me = this; if (this.funcprops) { var props = this.funcprops; props.args ? $('#formula-wizard-args').html('' + props.name + '' + props.args) : $('#formula-wizard-args').addClass('hidden'); props.desc ? $('#formula-wizard-desc').text(props.desc) : $('#formula-wizard-desc').addClass('hidden'); - props.name ? $('#formula-wizard-name').html('' + this.textFunction + ': ' + props.name) : $('#formula-wizard-name').addClass('hidden'); + props.name ? $('#formula-wizard-name').html(this.textFunction + ': ' + props.name) : $('#formula-wizard-name').addClass('hidden'); this.$window.find('#formula-wizard-help').on('click', function (e) { me.showHelp(); }) } - var height = this.panelDesc.outerHeight(); - height = this.$window.find('.box').height() - height - 33;// #formula-wizard-name height - this.panelArgs.height(height); - height = parseInt((height-8)/30) * 30; - this.tableArgs.parent().height(height); - this.scrollerY = new Common.UI.Scroller({ - el: this.tableArgs.parent(), - minScrollbarLength : 20, - alwaysVisibleY: true - }); + this.recalcArgTableSize(); + this.minArgWidth = this.$window.find('#formula-wizard-lbl-func-res').width(); if (this.props) { // fill arguments @@ -162,8 +173,10 @@ define([ this.minArgCount = props.asc_getArgumentMin(); this.maxArgCount = props.asc_getArgumentMax(); - var result = props.asc_getFormulaResult(); - this.lblResult.html('' + this.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); + var result = props.asc_getFunctionResult(); + this.lblFunctionResult.html('= ' + ((result!==undefined && result!==null) ? result : '')); + result = props.asc_getFormulaResult(); + this.lblFormulaResult.html('' + this.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); var argres = props.asc_getArgumentsResult(), argtype = props.asc_getArgumentsType(), @@ -207,6 +220,25 @@ define([ } }, + recalcArgTableSize: function() { + var height = this.panelDesc.outerHeight(); + height = this.$window.find('.box').height() - 7 - height - 60; + height = parseInt(height/30) * 30; + this.tableArgs.parent().css('max-height', height); + if (!this.scrollerY) + this.scrollerY = new Common.UI.Scroller({ + el: this.tableArgs.parent(), + minScrollbarLength : 20, + alwaysVisibleY: true + }); + else + this.scrollerY.update(); + }, + + checkDescriptionSize: function() { + (this.contentPanel.height() < this.innerPanel.height()) && this.recalcArgTableSize(); + }, + fillArgs: function (types, argval, argres) { var argcount = this.args.length; for (var j=0; j
' + '
' + - '
', + '
', div = $(Common.Utils.String.format(argtpl, argcount)); this.tableArgs.append(div); @@ -237,8 +269,10 @@ define([ argres = argres ? argres[index] : undefined; arg.lblValue.html('= '+ (argres!==null && argres !==undefined ? argres : '' + arg.argTypeName + '' )); - res = res ? res.asc_getFormulaResult() : undefined; - me.lblResult.html('' + me.textValue + ': ' + ((res!==undefined && res!==null)? res : '')); + var result = res ? res.asc_getFunctionResult() : undefined; + me.lblFunctionResult.html('= ' + ((result!==undefined && result!==null)? result : '')); + result = res ? res.asc_getFormulaResult() : undefined; + me.lblFormulaResult.html('' + me.textValue + ': ' + ((result!==undefined && result!==null)? result : '')); }); txt.setValue((argval!==undefined && argval!==null) ? argval : ''); @@ -292,6 +326,7 @@ define([ this.fillArgs(this.repeatedArg); this.scrollerY.update(); } + this.checkDescriptionSize(); }, onSelectData: function(input) { @@ -365,12 +400,13 @@ define([ }, close: function () { - Common.UI.Window.prototype.close.call(this); + Common.Views.AdvancedSettingsWindow.prototype.close.call(this); this.api.asc_closeCellEditor(!this._preventCloseCellEditor); }, textTitle: 'Function Argumens', textValue: 'Formula result', + textFunctionRes: 'Function result', textFunction: 'Function', textHelp: 'Help on this function'