diff --git a/ui (gen4)/lib/util.js b/ui (gen4)/lib/util.js index 91cbc828..cc3ce438 100755 --- a/ui (gen4)/lib/util.js +++ b/ui (gen4)/lib/util.js @@ -399,22 +399,23 @@ if(typeof(jQuery) != typeof(undefined)){ // } // // This listens to these events triggerable by user: - // 'commit' - will commit changes and fire 'edit-done' with - // field text. - // 'abort' - will reset field and trigger 'edit-aborted' - // with original (before edit started) field text + // 'edit-commit' - will commit changes, this is passed the + // new text just edited. + // 'edit-abort' - will reset field, this is passed the + // original text before the edit. // // // NOTE: removing tabindex will reset focus, so this will attempt to // focus the first [tabindex] element up the tree... // + // XXX add option to select the element on start or just focus it... + // XXX multiline fields need to retain original function of arrows + // until we are at last line, then pass it through... // XXX should we just use form elements??? // ...it's a trade-off, here we add editing functionality and fight // a bit the original function, in an input we'll need to fight part // of the editing functionality and add our own navigation... // XXX move this to a more generic spot... - // XXX should this reset field to it's original state after - // commit/abort??? jQuery.fn.makeEditable = function(options){ var that = this @@ -465,14 +466,14 @@ if(typeof(jQuery) != typeof(undefined)){ // abort... if((options.abort_keys || ['Esc']).indexOf(n) >= 0){ - that.trigger('abort') + that.trigger('edit-abort', original) // done -- single line... } else if(n == 'Enter' && !options.multiline){ event.preventDefault() - that.trigger('commit') + that.trigger('edit-commit', that.text()) // done -- multiline... } else if(n == 'Enter' @@ -480,7 +481,7 @@ if(typeof(jQuery) != typeof(undefined)){ && options.multiline){ event.preventDefault() - that.trigger('commit') + that.trigger('edit-commit', that.text()) // continue handling... } else { @@ -498,9 +499,7 @@ if(typeof(jQuery) != typeof(undefined)){ .selectText() }) // user triggerable events... - .on('abort', events.abort = function(){ - that.trigger('edit-aborted', original) - + .on('edit-abort', events['edit-abort'] = function(){ options.clear_selection_on_abort !== false && window.getSelection().removeAllRanges() @@ -517,9 +516,7 @@ if(typeof(jQuery) != typeof(undefined)){ that.makeEditable(false) }) - .on('commit', events.commit = function(){ - that.trigger('edit-done', that.text()) - + .on('edit-commit', events['edit-commit'] = function(){ options.clear_selection_on_commit !== false && window.getSelection().removeAllRanges() diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index fb449614..b7f20dea 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -128,7 +128,7 @@ function(text, options){ // // options format: // { -// select_text: | | 'first' | 'last', +// select_text: | 'first' | 'last' | , // // ... // } @@ -139,22 +139,21 @@ function(text, options){ var elem = (options.action ? this.Action : this).call(this, text, options) .on('select', function(){ var text = elem.find('.text') - - if(options.select_text == 'first' || options.select_text == 'last'){ - text[options.selected_index]() + // get the specific .text element... + // select index... + typeof(options.select_text) == typeof(123) ? + text.eq(options.select_text) .selectText() - - } else if(typeof(options.select_text) == typeof('str')){ - elem.find(options.selected_index) + // first/last + : (options.select_text == 'first' || options.select_text == 'last') ? + text[options.select_text]() .selectText() - - } else if(typeof(options.select_text) == typeof(123)){ - text.eq(options.selected_index) + // selector... + : typeof(options.select_text) == typeof('str') ? + elem.find(options.select_text) .selectText() - - } else { - text.selectText() - } + // all... + : text.selectText() }) return elem } @@ -176,7 +175,8 @@ function(text, options){ // // NOTE: by default this will select all the elements, if there // // are more than one, this may result in an odd element // // state... -// editable_index: , +// // NOTE: the selector is used to filter text elements... +// edit_text: | 'first' | 'last' | , // // // item event to start the edit on... // start_on: 'select', @@ -198,7 +198,7 @@ function(text, options){ // ... // } // -// XXX add option to select the element on start... +// XXX add option to select the element on start or just focus it... Items.Editable = function(text, options){ options = options || {} @@ -211,8 +211,17 @@ function(text, options){ editable = elem.find('.text') // get the specific .text element... - editable = options.editable_index != null ? - editable.eq(options.editable_index) + editable = + // index... + typeof(options.edit_text) == typeof(123) ? + editable.eq(options.edit_text) + // first/last... + : (options.edit_text == 'first' || options.edit_text == 'last') ? + editable[options.edit_text]() + // selecter... + : typeof(options.edit_text) == typeof('str') ? + editable.filter(options.edit_text) + // all... : editable // edit the element... @@ -227,19 +236,19 @@ function(text, options){ // deselect on abort -- if we started with a select... start_on == 'select' && editable - .on('edit-aborted', function(){ + .on('edit-abort', function(){ dialog.select(null) }) // edit event handlers... options.editaborted - && editable.on('edit-aborted', options.editaborted) + && editable.on('edit-abort', options.editaborted) options.editdone - && editable.on('edit-done', options.editdone) + && editable.on('edit-commit', options.editdone) }) .on('deselect', function(){ editable.trigger( - options.abort_on_deselect !== false ? 'abort' : 'commit') + options.abort_on_deselect !== false ? 'edit-abort' : 'edit-commit') }) return elem @@ -400,7 +409,7 @@ function(list, options){ clear_on_edit: true, }) // update list on edit done... - .on('edit-done', function(evt, text){ + .on('edit-commit', function(evt, text){ var txt = $(this).text() txt = options.normalize ?