From c49aa7857b95cc35e5d3c705a1fae6ed485240f0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 7 Jun 2016 06:03:16 +0300 Subject: [PATCH] cleanup and refactoring... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/layout.less | 3 ++- ui (gen4)/features/filesystem.js | 2 ++ ui (gen4)/features/ui-status.js | 4 ++-- ui (gen4)/features/ui-widgets.js | 2 +- ui (gen4)/lib/util.js | 23 +++++++++++++++-------- ui (gen4)/lib/widget/browse.js | 17 ++++++++++++++--- ui (gen4)/lib/widget/overlay.js | 6 ++---- 7 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ui (gen4)/css/layout.less b/ui (gen4)/css/layout.less index adbd7427..de24d421 100755 --- a/ui (gen4)/css/layout.less +++ b/ui (gen4)/css/layout.less @@ -1274,7 +1274,8 @@ stretching in width... */ } .overlay-info .ribbon-number:before { content: "R:"; - opacity: 0.6; + + opacity: 0.7; } /* XXX not sure if we need to expand this .overlay-info .ribbon-number:hover:before { diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 482680ab..27b9b8ec 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -2017,6 +2017,7 @@ var FileSystemWriterUIActions = actions.Actions({ var path = elem.find('.text').last() .makeEditable({ + activate: true, clear_on_edit: false, abort_keys: [ 'Esc', @@ -2046,6 +2047,7 @@ var FileSystemWriterUIActions = actions.Actions({ // XXX multiline??? var path = elem.find('.text').last() .makeEditable({ + activate: true, multiline: true, clear_on_edit: false, abort_keys: [ diff --git a/ui (gen4)/features/ui-status.js b/ui (gen4)/features/ui-status.js index 2c63a50a..73fbafca 100755 --- a/ui (gen4)/features/ui-status.js +++ b/ui (gen4)/features/ui-status.js @@ -110,7 +110,7 @@ var StatusBarActions = actions.Actions({ : $('') .addClass('position editable') .attr('info', 'Image position (click to edit)') - .makeEditable({ clear_on_edit: false }) + .makeEditable() // select image when done... .on('edit-done', function(_, text){ var i = parseInt(text) @@ -188,7 +188,7 @@ var StatusBarActions = actions.Actions({ item = $('') .addClass('ribbon-number') .attr('info', 'Current ribbon (click to edit)') - .makeEditable({ clear_on_edit: false }) + .makeEditable() .on('edit-done', function(_, text){ that.focusRibbon(text == '*' ? that.base : parseInt(text)) }) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 7e184044..09346170 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -39,7 +39,6 @@ function(list, item, elem, callback, options){ return elem .makeEditable({ activate: true, - clear_on_edit: false, }) .on('edit-done', callback || function(){}) .on('edit-aborted edit-done', function(_, text){ @@ -95,6 +94,7 @@ function(actions, list_key, options){ return $(elem).find('.text') .makeEditable({ activate: true, + clear_on_edit: true, blur_on_abort: false, blur_on_commit: false, }) diff --git a/ui (gen4)/lib/util.js b/ui (gen4)/lib/util.js index fa38644e..09e703e0 100755 --- a/ui (gen4)/lib/util.js +++ b/ui (gen4)/lib/util.js @@ -373,6 +373,9 @@ if(typeof(jQuery) != typeof(undefined)){ // // set multi line edit mode... // multiline: false, // + // // clear element value on edit... + // clear_on_edit: false, + // // // reset value on abort... // reset_on_abort: true, // @@ -384,9 +387,6 @@ if(typeof(jQuery) != typeof(undefined)){ // clear_selection_on_abort: true, // clear_selection_on_commit: true, // - // // clear element value on edit... - // clear_on_edit: true, - // // // Keys that will abort the edit... // abort_keys: [ // 'Esc', @@ -419,12 +419,12 @@ if(typeof(jQuery) != typeof(undefined)){ var original = this.text() - if(options.clear_on_edit == null || options.clear_on_edit){ - this.text('') - } - this.prop('contenteditable', true) + options.activate + && options.clear_on_edit + && this.text('') + // NOTE: this will also focus the element... options.activate && this.selectText() @@ -467,9 +467,16 @@ if(typeof(jQuery) != typeof(undefined)){ that.trigger('commit') } }) - .on('blur', function(){ + .blur(function(){ window.getSelection().removeAllRanges() }) + .on('focus click', function(evt){ + evt.stopPropagation() + options.clear_on_edit + && $(this) + .text('') + .selectText() + }) // user triggerable events... .on('abort', function(){ that.trigger('edit-aborted', original) diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 6da08967..d5bd3a5b 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -143,7 +143,9 @@ var BrowserClassPrototype = { .attr('tabindex', 0) // focus the widget if something inside is clicked... .click(function(){ - $(this).focus() + if($(this).find(':focus').length == 0){ + $(this).focus() + } }) if(options.flat){ @@ -524,7 +526,17 @@ var BrowserPrototype = { //trigger: widget.triggerEventWithSource, // specific events... - focus: widget.proxyToDom('focus'), + focus: function(handler){ + if(handler != null){ + this.on('focus', handler) + + // focus only if we do not have focus... + } else if(!this.dom.is(':focus') + && this.dom.find(':focus').length == 0) { + this.dom.focus() + } + return this + }, blur: widget.proxyToDom('blur'), @@ -1118,7 +1130,6 @@ var BrowserPrototype = { if(focus && browser.find(':focus').length == 0){ that.focus() } - }) }, diff --git a/ui (gen4)/lib/widget/overlay.js b/ui (gen4)/lib/widget/overlay.js index 0874d333..8c08275a 100755 --- a/ui (gen4)/lib/widget/overlay.js +++ b/ui (gen4)/lib/widget/overlay.js @@ -129,11 +129,9 @@ var OverlayPrototype = { .addClass('blur') .append(this.dom) - // pass focus to the client... + // pass focus to the client if it is not focused already... this.on('focus click', function(){ - if(client.dom && client.focus){ - client.focus() - } + client.focus && client.focus() }) this.focus()