cleanup and refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-06-07 06:03:16 +03:00
parent edd0fba141
commit c49aa7857b
7 changed files with 38 additions and 19 deletions

View File

@ -1274,7 +1274,8 @@ stretching in width... */
} }
.overlay-info .ribbon-number:before { .overlay-info .ribbon-number:before {
content: "R:"; content: "R:";
opacity: 0.6;
opacity: 0.7;
} }
/* XXX not sure if we need to expand this /* XXX not sure if we need to expand this
.overlay-info .ribbon-number:hover:before { .overlay-info .ribbon-number:hover:before {

View File

@ -2017,6 +2017,7 @@ var FileSystemWriterUIActions = actions.Actions({
var path = elem.find('.text').last() var path = elem.find('.text').last()
.makeEditable({ .makeEditable({
activate: true,
clear_on_edit: false, clear_on_edit: false,
abort_keys: [ abort_keys: [
'Esc', 'Esc',
@ -2046,6 +2047,7 @@ var FileSystemWriterUIActions = actions.Actions({
// XXX multiline??? // XXX multiline???
var path = elem.find('.text').last() var path = elem.find('.text').last()
.makeEditable({ .makeEditable({
activate: true,
multiline: true, multiline: true,
clear_on_edit: false, clear_on_edit: false,
abort_keys: [ abort_keys: [

View File

@ -110,7 +110,7 @@ var StatusBarActions = actions.Actions({
: $('<span>') : $('<span>')
.addClass('position editable') .addClass('position editable')
.attr('info', 'Image position (click to edit)') .attr('info', 'Image position (click to edit)')
.makeEditable({ clear_on_edit: false }) .makeEditable()
// select image when done... // select image when done...
.on('edit-done', function(_, text){ .on('edit-done', function(_, text){
var i = parseInt(text) var i = parseInt(text)
@ -188,7 +188,7 @@ var StatusBarActions = actions.Actions({
item = $('<span>') item = $('<span>')
.addClass('ribbon-number') .addClass('ribbon-number')
.attr('info', 'Current ribbon (click to edit)') .attr('info', 'Current ribbon (click to edit)')
.makeEditable({ clear_on_edit: false }) .makeEditable()
.on('edit-done', function(_, text){ .on('edit-done', function(_, text){
that.focusRibbon(text == '*' ? that.base : parseInt(text)) that.focusRibbon(text == '*' ? that.base : parseInt(text))
}) })

View File

@ -39,7 +39,6 @@ function(list, item, elem, callback, options){
return elem return elem
.makeEditable({ .makeEditable({
activate: true, activate: true,
clear_on_edit: false,
}) })
.on('edit-done', callback || function(){}) .on('edit-done', callback || function(){})
.on('edit-aborted edit-done', function(_, text){ .on('edit-aborted edit-done', function(_, text){
@ -95,6 +94,7 @@ function(actions, list_key, options){
return $(elem).find('.text') return $(elem).find('.text')
.makeEditable({ .makeEditable({
activate: true, activate: true,
clear_on_edit: true,
blur_on_abort: false, blur_on_abort: false,
blur_on_commit: false, blur_on_commit: false,
}) })

View File

@ -373,6 +373,9 @@ if(typeof(jQuery) != typeof(undefined)){
// // set multi line edit mode... // // set multi line edit mode...
// multiline: false, // multiline: false,
// //
// // clear element value on edit...
// clear_on_edit: false,
//
// // reset value on abort... // // reset value on abort...
// reset_on_abort: true, // reset_on_abort: true,
// //
@ -384,9 +387,6 @@ if(typeof(jQuery) != typeof(undefined)){
// clear_selection_on_abort: true, // clear_selection_on_abort: true,
// clear_selection_on_commit: true, // clear_selection_on_commit: true,
// //
// // clear element value on edit...
// clear_on_edit: true,
//
// // Keys that will abort the edit... // // Keys that will abort the edit...
// abort_keys: [ // abort_keys: [
// 'Esc', // 'Esc',
@ -419,12 +419,12 @@ if(typeof(jQuery) != typeof(undefined)){
var original = this.text() var original = this.text()
if(options.clear_on_edit == null || options.clear_on_edit){
this.text('')
}
this.prop('contenteditable', true) this.prop('contenteditable', true)
options.activate
&& options.clear_on_edit
&& this.text('')
// NOTE: this will also focus the element... // NOTE: this will also focus the element...
options.activate && this.selectText() options.activate && this.selectText()
@ -467,9 +467,16 @@ if(typeof(jQuery) != typeof(undefined)){
that.trigger('commit') that.trigger('commit')
} }
}) })
.on('blur', function(){ .blur(function(){
window.getSelection().removeAllRanges() window.getSelection().removeAllRanges()
}) })
.on('focus click', function(evt){
evt.stopPropagation()
options.clear_on_edit
&& $(this)
.text('')
.selectText()
})
// user triggerable events... // user triggerable events...
.on('abort', function(){ .on('abort', function(){
that.trigger('edit-aborted', original) that.trigger('edit-aborted', original)

View File

@ -143,7 +143,9 @@ var BrowserClassPrototype = {
.attr('tabindex', 0) .attr('tabindex', 0)
// focus the widget if something inside is clicked... // focus the widget if something inside is clicked...
.click(function(){ .click(function(){
$(this).focus() if($(this).find(':focus').length == 0){
$(this).focus()
}
}) })
if(options.flat){ if(options.flat){
@ -524,7 +526,17 @@ var BrowserPrototype = {
//trigger: widget.triggerEventWithSource, //trigger: widget.triggerEventWithSource,
// specific events... // 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'), blur: widget.proxyToDom('blur'),
@ -1118,7 +1130,6 @@ var BrowserPrototype = {
if(focus && browser.find(':focus').length == 0){ if(focus && browser.find(':focus').length == 0){
that.focus() that.focus()
} }
}) })
}, },

View File

@ -129,11 +129,9 @@ var OverlayPrototype = {
.addClass('blur') .addClass('blur')
.append(this.dom) .append(this.dom)
// pass focus to the client... // pass focus to the client if it is not focused already...
this.on('focus click', function(){ this.on('focus click', function(){
if(client.dom && client.focus){ client.focus && client.focus()
client.focus()
}
}) })
this.focus() this.focus()