mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
tweakign the makeWditable(..) jQuery extension...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c987abac35
commit
2acbdb70f0
@ -235,6 +235,11 @@ var ExternalEditorUIActions = actions.Actions({
|
|||||||
.on('open', function(){
|
.on('open', function(){
|
||||||
var editors = that.config['external-editors']
|
var editors = that.config['external-editors']
|
||||||
|
|
||||||
|
// commit all fields...
|
||||||
|
dialog.dom
|
||||||
|
.find('.editable-field[contenteditable]')
|
||||||
|
.trigger('commit')
|
||||||
|
|
||||||
// updated editor...
|
// updated editor...
|
||||||
if(editor_i >= 0){
|
if(editor_i >= 0){
|
||||||
that.config['external-editors'] = editors.slice()
|
that.config['external-editors'] = editors.slice()
|
||||||
|
|||||||
@ -267,11 +267,19 @@ 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
|
||||||
|
//
|
||||||
// XXX should we just use form elements???
|
// XXX should we just use form elements???
|
||||||
// ...it's a trade-off, here we add editing functionality and fight
|
// ...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
|
// a bit the original function, in an input we'll need to fight part
|
||||||
// of the editing functionality and add our own navigation...
|
// of the editing functionality and add our own navigation...
|
||||||
// XXX move this to a more generic spot...
|
// 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){
|
jQuery.fn.makeEditable = function(options){
|
||||||
options = options || {}
|
options = options || {}
|
||||||
var that = this
|
var that = this
|
||||||
@ -304,15 +312,14 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
(options.reset_on_abort == null || options.reset_on_abort)
|
(options.reset_on_abort == null || options.reset_on_abort)
|
||||||
&& that.text(original)
|
&& that.text(original)
|
||||||
|
|
||||||
that
|
that.trigger('abort')
|
||||||
.trigger('edit-aborted', original)
|
|
||||||
|
|
||||||
// done -- single line...
|
// done -- single line...
|
||||||
} else if(n == 'Enter'
|
} else if(n == 'Enter'
|
||||||
&& !options.multiline){
|
&& !options.multiline){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
that.trigger('edit-done', that.text())
|
that.trigger('commit')
|
||||||
|
|
||||||
// done -- multiline...
|
// done -- multiline...
|
||||||
} else if(n == 'Enter'
|
} else if(n == 'Enter'
|
||||||
@ -320,9 +327,16 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
&& options.multiline){
|
&& options.multiline){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
that.trigger('edit-done', that.text())
|
that.trigger('commit')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// user triggerable events...
|
||||||
|
.on('abort', function(){
|
||||||
|
that.trigger('edit-aborted', original)
|
||||||
|
})
|
||||||
|
.on('commit', function(){
|
||||||
|
that.trigger('edit-done', that.text())
|
||||||
|
})
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user