From 0255f1b309e1793bde2905badf568af386978d1c Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Wed, 16 Nov 2016 11:01:10 +0300 Subject: [PATCH] [DE mobile] Change css name of settings container. --- .../mobile/resources/less/ios/_container.less | 7 + apps/documenteditor/mobile/app-dev.js | 2 + apps/documenteditor/mobile/app.js | 2 + .../mobile/app/controller/Search.js | 223 ++++++++++++++++++ .../mobile/app/controller/Settings.js | 4 +- .../mobile/app/controller/Toolbar.js | 83 +------ .../mobile/app/controller/add/AddContainer.js | 4 +- .../app/controller/edit/EditContainer.js | 4 +- .../mobile/app/template/Search.template | 105 +++++++++ .../mobile/app/template/Settings.template | 24 +- .../mobile/app/template/Toolbar.template | 2 +- apps/documenteditor/mobile/app/view/Search.js | 183 ++++++++++++++ .../documenteditor/mobile/app/view/Toolbar.js | 57 +---- .../mobile/resources/css/app-ios.css | 121 +++++----- .../mobile/resources/css/app-material.css | 61 +++++ .../mobile/resources/less/ios/_search.less | 18 +- .../resources/less/material/_search.less | 112 +++++++++ 17 files changed, 796 insertions(+), 216 deletions(-) create mode 100644 apps/documenteditor/mobile/app/controller/Search.js create mode 100644 apps/documenteditor/mobile/app/template/Search.template create mode 100644 apps/documenteditor/mobile/app/view/Search.js diff --git a/apps/common/mobile/resources/less/ios/_container.less b/apps/common/mobile/resources/less/ios/_container.less index 48bfa040b..96aa963e0 100644 --- a/apps/common/mobile/resources/less/ios/_container.less +++ b/apps/common/mobile/resources/less/ios/_container.less @@ -19,7 +19,9 @@ &.popover { width: 360px; } +} +.settings { &.popup, &.popover { .list-block { @@ -27,6 +29,10 @@ ul { border-radius: 0 !important; background: #fff; + + &:last-child { + .hairline(bottom, @listBlockBorderColor); + } } &:first-child { @@ -70,6 +76,7 @@ } } } + .popover-inner { height: 400px; } diff --git a/apps/documenteditor/mobile/app-dev.js b/apps/documenteditor/mobile/app-dev.js index e9007d7ab..ff262b9b7 100644 --- a/apps/documenteditor/mobile/app-dev.js +++ b/apps/documenteditor/mobile/app-dev.js @@ -134,6 +134,7 @@ require([ controllers : [ 'Editor', 'Toolbar', + 'Search', 'Main', 'DocumentHolder', 'Settings', @@ -198,6 +199,7 @@ require([ 'common/main/lib/util/utils', 'documenteditor/mobile/app/controller/Editor', 'documenteditor/mobile/app/controller/Toolbar', + 'documenteditor/mobile/app/controller/Search', 'documenteditor/mobile/app/controller/Main', 'documenteditor/mobile/app/controller/DocumentHolder', 'documenteditor/mobile/app/controller/Settings', diff --git a/apps/documenteditor/mobile/app.js b/apps/documenteditor/mobile/app.js index fe0c684f2..464ec6dde 100644 --- a/apps/documenteditor/mobile/app.js +++ b/apps/documenteditor/mobile/app.js @@ -145,6 +145,7 @@ require([ controllers : [ 'Editor', 'Toolbar', + 'Search', 'Main', 'DocumentHolder', 'Settings', @@ -209,6 +210,7 @@ require([ 'common/main/lib/util/utils', 'documenteditor/mobile/app/controller/Editor', 'documenteditor/mobile/app/controller/Toolbar', + 'documenteditor/mobile/app/controller/Search', 'documenteditor/mobile/app/controller/Main', 'documenteditor/mobile/app/controller/DocumentHolder', 'documenteditor/mobile/app/controller/Settings', diff --git a/apps/documenteditor/mobile/app/controller/Search.js b/apps/documenteditor/mobile/app/controller/Search.js new file mode 100644 index 000000000..c912ee7b1 --- /dev/null +++ b/apps/documenteditor/mobile/app/controller/Search.js @@ -0,0 +1,223 @@ +/* + * + * (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 + * + */ + +/** + * Search.js + * Document Editor + * + * Created by Alexander Yuzhin on 11/15/16 + * Copyright (c) 2016 Ascensio System SIA. All rights reserved. + * + */ + + +define([ + 'core', + 'jquery', + 'underscore', + 'backbone', + 'documenteditor/mobile/app/view/Search' +], function (core, $, _, Backbone) { + 'use strict'; + + DE.Controllers.Search = Backbone.Controller.extend((function() { + // private + + var _isShow = false, + _startPoint = {}; + + var pointerEventToXY = function(e){ + var out = {x:0, y:0}; + if(e.type == 'touchstart' || e.type == 'touchend'){ + var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; + out.x = touch.pageX; + out.y = touch.pageY; + } else if (e.type == 'mousedown' || e.type == 'mouseup') { + out.x = e.pageX; + out.y = e.pageY; + } + return out; + }; + + return { + models: [], + collections: [], + views: [ + 'Search' + ], + + initialize: function() { + this.addListeners({ + 'Search': { + 'searchbar:show' : this.onSearchbarShow, + 'searchbar:hide' : this.onSearchbarHide, + 'searchbar:render' : this.onSearchbarRender + } + }); + }, + + setApi: function(api) { + this.api = api; + }, + + setMode: function (mode) { + this.getView('Search').setMode(mode); + }, + + onLaunch: function() { + var me = this; + me.createView('Search').render(); + + $('#editor_sdk').single('mousedown touchstart', _.bind(me.onEditorTouchStart, me)); + $('#editor_sdk').single('mouseup touchend', _.bind(me.onEditorTouchEnd, me)); + }, + + showSearch: function () { + this.getView('Search').showSearch(); + }, + + hideSearch: function () { + this.getView('Search').hideSearch(); + }, + + // Handlers + + onEditorTouchStart: function (e) { + _startPoint = pointerEventToXY(e); + }, + + onEditorTouchEnd: function (e) { + var _endPoint = pointerEventToXY(e); + + if (_isShow) { + var distance = Math.sqrt((_endPoint.x -= _startPoint.x) * _endPoint.x + (_endPoint.y -= _startPoint.y) * _endPoint.y); + + if (distance < 1) { + this.hideSearch(); + } + } + }, + + onSearchbarRender: function(bar) { + var me = this; + + me.searchBar = uiApp.searchbar('.searchbar.document .searchbar.search', { + customSearch: true, + onSearch : _.bind(me.onSearchChange, me), + onEnable : _.bind(me.onSearchEnable, me), + onClear : _.bind(me.onSearchClear, me) + }); + + me.replaceBar = uiApp.searchbar('.searchbar.document .searchbar.replace', { + customSearch: true, + onSearch : _.bind(me.onReplaceChange, me), + onEnable : _.bind(me.onReplaceEnable, me), + onClear : _.bind(me.onReplaceClear, me) + }); + + me.searchPrev = $('.searchbar.document .prev'); + me.searchNext = $('.searchbar.document .next'); + + me.searchPrev.single('click', _.bind(me.onSearchPrev, me)); + me.searchNext.single('click', _.bind(me.onSearchNext, me)); + }, + + onSearchbarShow: function(bar) { + _isShow = true; + }, + + onSearchEnable: function (bar) { + this.replaceBar.container.removeClass('searchbar-active'); + }, + + onSearchbarHide: function(bar) { + _isShow = false; + }, + + onSearchChange: function(search) { + var me = this, + isEmpty = (search.query.trim().length < 1); + + _.each([me.searchPrev, me.searchNext], function(btn) { + btn[isEmpty ? 'addClass' : 'removeClass']('disabled'); + }); + }, + + onSearchClear: function(search) { +// window.focus(); +// document.activeElement.blur(); + }, + + onReplaceChange: function(replace) { + var me = this, + isEmpty = (replace.query.trim().length < 1); + + }, + + onReplaceEnable: function (bar) { + this.searchBar.container.removeClass('searchbar-active'); + }, + + onReplaceClear: function(replace) { + // + }, + + onSearchPrev: function(btn) { + this.onQuerySearch(this.searchBar.query, 'back'); + }, + + onSearchNext: function(btn) { + this.onQuerySearch(this.searchBar.query, 'next'); + }, + + onQuerySearch: function(query, direction, opts) { + if (query && query.length) { + if (!this.api.asc_findText(query, direction != 'back', opts && opts.matchcase, opts && opts.matchword)) { + var me = this; + uiApp.alert( + '', + me.textNoTextFound, + function () { + me.searchBar.input.focus(); + } + ); + } + } + }, + + // API handlers + + textNoTextFound : 'Text not found', + } + })()); +}); \ No newline at end of file diff --git a/apps/documenteditor/mobile/app/controller/Settings.js b/apps/documenteditor/mobile/app/controller/Settings.js index 3d4baa225..e7259ccb7 100644 --- a/apps/documenteditor/mobile/app/controller/Settings.js +++ b/apps/documenteditor/mobile/app/controller/Settings.js @@ -107,7 +107,7 @@ define([ showModal: function() { if (Common.SharedSettings.get('phone')) { modalView = uiApp.popup( - '