mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 02:40:08 +00:00
making the .Editable(..) item constructor more functional...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
37f601f77b
commit
cdc50df278
@ -25,7 +25,7 @@ var drawer = require('lib/widget/drawer')
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var GLOBAL_KEYBOARD =
|
var GLOBAL_KEYBOARD =
|
||||||
module.GLOBAL_KEYBOARD2 = {
|
module.GLOBAL_KEYBOARD = {
|
||||||
'Global': {
|
'Global': {
|
||||||
doc: 'Global bindings that take priority over other sections.',
|
doc: 'Global bindings that take priority over other sections.',
|
||||||
pattern: '*',
|
pattern: '*',
|
||||||
|
|||||||
@ -367,7 +367,9 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
//
|
//
|
||||||
// Options format:
|
// Options format:
|
||||||
// {
|
// {
|
||||||
// // activate (focus) element when done...
|
// // activate (focus) element...
|
||||||
|
// //
|
||||||
|
// // NOTE: this will also select the element text...
|
||||||
// activate: false,
|
// activate: false,
|
||||||
//
|
//
|
||||||
// // set multi line edit mode...
|
// // set multi line edit mode...
|
||||||
@ -386,8 +388,6 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
// // restore focus before disabling the editor...
|
// // restore focus before disabling the editor...
|
||||||
// keep_focus_on_parent: true,
|
// keep_focus_on_parent: true,
|
||||||
//
|
//
|
||||||
// stop_propagation: false,
|
|
||||||
//
|
|
||||||
// // clear selection on abort/commit...
|
// // clear selection on abort/commit...
|
||||||
// clear_selection_on_abort: true,
|
// clear_selection_on_abort: true,
|
||||||
// clear_selection_on_commit: true,
|
// clear_selection_on_commit: true,
|
||||||
@ -444,7 +444,8 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
&& this.text('')
|
&& this.text('')
|
||||||
|
|
||||||
// NOTE: this will also focus the element...
|
// NOTE: this will also focus the element...
|
||||||
options.activate && this.selectText()
|
options.activate
|
||||||
|
&& this.selectText()
|
||||||
|
|
||||||
// do not setup handlers more than once...
|
// do not setup handlers more than once...
|
||||||
if(!this.hasClass('editable-field')){
|
if(!this.hasClass('editable-field')){
|
||||||
|
|||||||
@ -166,8 +166,28 @@ function(text, options){
|
|||||||
// // show as action (via. .Action(..))
|
// // show as action (via. .Action(..))
|
||||||
// action: <bool>,
|
// action: <bool>,
|
||||||
//
|
//
|
||||||
|
// // if true, set multi-line mode...
|
||||||
|
// //
|
||||||
|
// // (see: util.makeEditable(..) for more info)
|
||||||
|
// multiline: false,
|
||||||
|
//
|
||||||
|
// // .text element index to edit...
|
||||||
|
// //
|
||||||
|
// // 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: <number>,
|
||||||
|
//
|
||||||
|
// // item event to start the edit on...
|
||||||
|
// start_on: 'select',
|
||||||
|
//
|
||||||
|
// // if true, trigger abort on deselect...
|
||||||
|
// abort_on_deselect: true,
|
||||||
|
//
|
||||||
// // If true, clear text when item is selected...
|
// // If true, clear text when item is selected...
|
||||||
// clear_on_edit: true,
|
// //
|
||||||
|
// // (see: util.makeEditable(..) for more info)
|
||||||
|
// clear_on_edit: false,
|
||||||
//
|
//
|
||||||
// // Called when editing is abrted...
|
// // Called when editing is abrted...
|
||||||
// editaborted: <func>,
|
// editaborted: <func>,
|
||||||
@ -177,33 +197,51 @@ function(text, options){
|
|||||||
//
|
//
|
||||||
// ...
|
// ...
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// XXX add option to select the element on start...
|
||||||
Items.Editable =
|
Items.Editable =
|
||||||
function(text, options){
|
function(text, options){
|
||||||
options = options || {}
|
options = options || {}
|
||||||
var dialog = this.dialog
|
var dialog = this.dialog
|
||||||
var editable
|
var editable
|
||||||
|
var start_on = options.start_on || 'select'
|
||||||
|
|
||||||
var elem = (options.action ? this.Action : this).call(this, text, options)
|
var elem = (options.action ? this.Action : this).call(this, text, options)
|
||||||
.on('select', function(){
|
.on(start_on, function(){
|
||||||
editable = elem.find('.text')
|
editable = elem.find('.text')
|
||||||
|
|
||||||
|
// get the specific .text element...
|
||||||
|
editable = options.editable_index != null ?
|
||||||
|
editable.eq(options.editable_index)
|
||||||
|
: editable
|
||||||
|
|
||||||
|
// edit the element...
|
||||||
|
editable
|
||||||
.makeEditable({
|
.makeEditable({
|
||||||
activate: true,
|
activate: true,
|
||||||
clear_on_edit: options.clear_on_edit,
|
clear_on_edit: options.clear_on_edit,
|
||||||
blur_on_abort: false,
|
blur_on_abort: false,
|
||||||
blur_on_commit: false,
|
blur_on_commit: false,
|
||||||
|
multiline: options.multiline,
|
||||||
})
|
})
|
||||||
// deselect on abort...
|
|
||||||
|
// deselect on abort -- if we started with a select...
|
||||||
|
start_on == 'select' && editable
|
||||||
.on('edit-aborted', function(){
|
.on('edit-aborted', function(){
|
||||||
dialog.select(null)
|
dialog.select(null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// edit event handlers...
|
||||||
options.editaborted
|
options.editaborted
|
||||||
&& editable.on('edit-aborted', options.editaborted)
|
&& editable.on('edit-aborted', options.editaborted)
|
||||||
options.editdone
|
options.editdone
|
||||||
&& editable.on('edit-done', options.editdone)
|
&& editable.on('edit-done', options.editdone)
|
||||||
})
|
})
|
||||||
.on('deselect', function(){
|
.on('deselect', function(){
|
||||||
editable.trigger('abort')
|
editable.trigger(
|
||||||
|
options.abort_on_deselect !== false ? 'abort' : 'commit')
|
||||||
})
|
})
|
||||||
|
|
||||||
return elem
|
return elem
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,6 +666,9 @@ var BrowserPrototype = {
|
|||||||
cls: null,
|
cls: null,
|
||||||
|
|
||||||
// Initial path...
|
// Initial path...
|
||||||
|
//
|
||||||
|
// NOTE: this can be a number indicating the item to select when
|
||||||
|
// load is done.
|
||||||
//path: null,
|
//path: null,
|
||||||
|
|
||||||
//show_path: true,
|
//show_path: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user