[SSE mobile] created view for CellEditor controller
This commit is contained in:
parent
d629c1cb9c
commit
7c5a886a47
|
@ -36,36 +36,37 @@
|
|||
* CellEditor Controller
|
||||
*
|
||||
* Created by Maxim Kadushkin on 11/24/2016
|
||||
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
|
||||
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'core'
|
||||
], function (Viewport) {
|
||||
'core',
|
||||
'spreadsheeteditor/mobile/app/view/CellEditor'
|
||||
], function (core) {
|
||||
'use strict';
|
||||
|
||||
SSE.Controllers.CellEditor = Backbone.Controller.extend({
|
||||
defEditorHeight: 30,
|
||||
maxEditorHeight: 70,
|
||||
views: [
|
||||
'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-btn-expand': _.bind(this.expandEditorField,this),
|
||||
// 'click button#ce-func-label': _.bind(this.onInsertFunction, this)
|
||||
};
|
||||
},
|
||||
// };
|
||||
// },
|
||||
|
||||
initialize: function() {
|
||||
this.addListeners({
|
||||
'CellEditor': {},
|
||||
'Viewport': {
|
||||
// this.addListeners({
|
||||
// 'CellEditor': {},
|
||||
// 'Viewport': {
|
||||
// 'layout:resizedrag': _.bind(this.onLayoutResize, this)
|
||||
}
|
||||
});
|
||||
// }
|
||||
// });
|
||||
},
|
||||
|
||||
setApi: function(api) {
|
||||
|
@ -100,11 +101,7 @@ define([
|
|||
},
|
||||
|
||||
onLaunch: function() {
|
||||
this.editor = { $el: $('#cell-editing-box') };
|
||||
this.editor.$el.height(this.defEditorHeight);
|
||||
|
||||
this.editor.$btnexpand = this.editor.$el.find('#ce-btn-expand');
|
||||
this.editor.$btnexpand.on('click', this.expandEditorField.bind(this));
|
||||
this.editor = this.createView('CellEditor').render();
|
||||
|
||||
// this.bindViewEvents(this.editor, this.events);
|
||||
// this.editor.$el.parent().find('.after').css({zIndex: '4'}); // for spreadsheets - bug 23127
|
||||
|
@ -122,12 +119,7 @@ define([
|
|||
},
|
||||
|
||||
onApiCellSelection: function(info) {
|
||||
if ( info ) {
|
||||
if ( !this.editor.$cellname )
|
||||
this.editor.$cellname = this.editor.$el.find('#ce-cell-name');
|
||||
|
||||
this.editor.$cellname.html(typeof(info)=='string' ? info : info.asc_getName());
|
||||
}
|
||||
this.editor.updateCellInfo(info);
|
||||
},
|
||||
|
||||
onApiDisconnect: function() {
|
||||
|
@ -148,17 +140,6 @@ define([
|
|||
// this.editor.cellNameDisabled(status != Asc.c_oAscSelectionDialogType.None);
|
||||
},
|
||||
|
||||
onLayoutResize: function(o, r) {
|
||||
if (r == 'cell:edit') {
|
||||
if (this.editor.$el.height() > 19) {
|
||||
if (!this.editor.$btnexpand.hasClass('btn-collapse'))
|
||||
this.editor.$btnexpand['addClass']('btn-collapse');
|
||||
} else {
|
||||
this.editor.$btnexpand['removeClass']('btn-collapse');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onCellName: function(e) {
|
||||
if (e.keyCode == Common.UI.Keys.RETURN){
|
||||
var name = this.editor.$cellname.val();
|
||||
|
@ -186,19 +167,6 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
expandEditorField: function() {
|
||||
if (this.editor.$el.height() > this.defEditorHeight) {
|
||||
this.editor.$el.height(this.defEditorHeight);
|
||||
this.editor.$btnexpand.removeClass('collapse');
|
||||
} else {
|
||||
this.editor.$el.height(this.maxEditorHeight);
|
||||
this.editor.$btnexpand.addClass('collapse');
|
||||
}
|
||||
|
||||
// Common.NotificationCenter.trigger('layout:changed', 'celleditor');
|
||||
// Common.NotificationCenter.trigger('edit:complete', this.editor, {restorefocus:true});
|
||||
},
|
||||
|
||||
onInsertFunction: function() {
|
||||
if ( this.mode.isEdit && !this.editor.$btnfunc['hasClass']('disabled')) {
|
||||
var controller = this.getApplication().getController('FormulaDialog');
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<div id="cell-editing-box">
|
||||
<div class="ce-group group-name">
|
||||
<span id="ce-cell-name"></span>
|
||||
<button id="ce-func-label" type="button" class="btn"><span class="btn-icon">ƒ₍ₓ₎</span></button>
|
||||
</div>
|
||||
<div class="ce-group group-content">
|
||||
<textarea id="ce-cell-content" spellcheck="false" rows="1" cols="20"></textarea>
|
||||
</div>
|
||||
<div class="ce-group group-expand">
|
||||
<button id="ce-btn-expand" type="button" class="btn"><span class="caret">❯</span></button>
|
||||
</div>
|
||||
</div>
|
|
@ -1,19 +1,7 @@
|
|||
<div class="views">
|
||||
<div class="view view-main">
|
||||
<div class="pages navbar-through">
|
||||
<div data-page="index" class="page">
|
||||
<div id="cell-editing-box">
|
||||
<div class="ce-group group-name">
|
||||
<span id="ce-cell-name"></span>
|
||||
<button id="ce-func-label" type="button" class="btn"><span class="btn-icon">ƒ₍ₓ₎</span></button>
|
||||
</div>
|
||||
<div class="ce-group group-content">
|
||||
<textarea id="ce-cell-content" spellcheck="false" rows="1" cols="20"></textarea>
|
||||
</div>
|
||||
<div class="ce-group group-expand">
|
||||
<button id="ce-btn-expand" type="button" class="btn"><span class="caret">❯</span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div data-page="index" class="page flex-horizontal">
|
||||
<div id="editor_sdk" class="page-content no-fastclick">
|
||||
</div>
|
||||
</div>
|
||||
|
|
99
apps/spreadsheeteditor/mobile/app/view/CellEditor.js
Normal file
99
apps/spreadsheeteditor/mobile/app/view/CellEditor.js
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System Limited 2010-2016
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* CellEdit.js
|
||||
*
|
||||
* Created by Maxim Kadushkin on 11/28/2016
|
||||
* Copyright (c) 2016 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'text!spreadsheeteditor/mobile/app/template/CellEditor.template',
|
||||
'backbone'
|
||||
], function (template, Backbone) {
|
||||
'use strict';
|
||||
|
||||
SSE.Views.CellEditor = Backbone.View.extend({
|
||||
defEditorHeight: 30,
|
||||
maxEditorHeight: 70,
|
||||
|
||||
el: '.pages > .page',
|
||||
template: _.template(template),
|
||||
|
||||
events: {
|
||||
'click button#ce-btn-expand': 'expandEditor'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
},
|
||||
|
||||
render: function () {
|
||||
var $el = $(this.el);
|
||||
this.$el = $(this.template()).prependTo($el);
|
||||
|
||||
this.$cellname = $('#ce-cell-name', this.el);
|
||||
this.$btnexpand = $('#ce-btn-expand', this.el);
|
||||
// this.$btnfunc = $('#ce-func-label', this.el);
|
||||
|
||||
// this.$el.height(this.defEditorHeight);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
updateCellInfo: function(info) {
|
||||
if (info) {
|
||||
this.$cellname.html(typeof(info)=='string' ? info : info.asc_getName());
|
||||
}
|
||||
},
|
||||
|
||||
expandEditor: function() {
|
||||
if (this.$el.height() > this.defEditorHeight) {
|
||||
this.$el.height(this.defEditorHeight);
|
||||
this.$btnexpand.removeClass('collapse');
|
||||
} else {
|
||||
this.$el.height(this.maxEditorHeight);
|
||||
this.$btnexpand.addClass('collapse');
|
||||
}
|
||||
|
||||
// Common.NotificationCenter.trigger('layout:changed', 'celleditor');
|
||||
// Common.NotificationCenter.trigger('edit:complete', this.editor, {restorefocus:true});
|
||||
},
|
||||
|
||||
cellNameDisabled: function(disabled){
|
||||
// (disabled) ? this.$cellname.attr('disabled', 'disabled') : this.$cellname.removeAttr('disabled');
|
||||
// this.$btnfunc.toggleClass('disabled', disabled);
|
||||
// this.btnNamedRanges.setDisabled(disabled);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,6 +1,20 @@
|
|||
|
||||
@appStatusbarHeight: 30px;
|
||||
|
||||
.navbar-through {
|
||||
> .page {
|
||||
padding-top: @appToolbarHeight;
|
||||
}
|
||||
}
|
||||
|
||||
.flex-horizontal {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.flex-vertical {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
}
|
||||
|
||||
#cell-editing-box {
|
||||
box-sizing: border-box;
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
@ -18,6 +19,7 @@
|
|||
background-color: #fff;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
overflow: hidden;
|
||||
|
||||
.btn {
|
||||
border: 0 none;
|
||||
|
@ -26,6 +28,7 @@
|
|||
}
|
||||
|
||||
.ce-group {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.group-name {
|
||||
|
@ -88,12 +91,14 @@
|
|||
.caret {
|
||||
display: block;
|
||||
transform: rotate(90deg);
|
||||
transition: transform 0.1s ease;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&.collapse {
|
||||
.caret {
|
||||
transform: rotate(-90deg);
|
||||
transition: transform 0.1s ease;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue