mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
cleanup + added 'activate' option to .makeEditable(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d90b167068
commit
edd0fba141
@ -87,7 +87,6 @@ var StatusBarActions = actions.Actions({
|
|||||||
},
|
},
|
||||||
|
|
||||||
__statusbar_elements__: {
|
__statusbar_elements__: {
|
||||||
// XXX use .makeEditable(..)
|
|
||||||
index: function(item, gid, img){
|
index: function(item, gid, img){
|
||||||
var that = this
|
var that = this
|
||||||
gid = gid || this.current
|
gid = gid || this.current
|
||||||
@ -111,36 +110,15 @@ 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)')
|
||||||
.prop('contenteditable', true)
|
.makeEditable({ clear_on_edit: false })
|
||||||
.keydown(function(){
|
// select image when done...
|
||||||
// keep this from affecting the viewer...
|
.on('edit-done', function(_, text){
|
||||||
event.stopPropagation()
|
var i = parseInt(text)
|
||||||
|
|
||||||
var n = keyboard.toKeyName(event.keyCode)
|
|
||||||
|
|
||||||
var i = parseInt($(this).text())
|
|
||||||
i = i >= 1 ? i-1
|
i = i >= 1 ? i-1
|
||||||
: i == null ? 'current'
|
: i == null ? 'current'
|
||||||
: i
|
: i
|
||||||
|
that.focusImage(i,
|
||||||
// lose focus and exit...
|
item.hasClass('global') ? 'global' : undefined)
|
||||||
if(n == 'Esc' || n == 'Enter'){
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
// get image on enter...
|
|
||||||
if(n == 'Enter'){
|
|
||||||
that.focusImage(i,
|
|
||||||
item.hasClass('global') ? 'global' : undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear selection....
|
|
||||||
window.getSelection().removeAllRanges()
|
|
||||||
$(this).blur()
|
|
||||||
|
|
||||||
that.updateStatusBar()
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
// update image position...
|
// update image position...
|
||||||
// XXX this appears to be run in the node context...
|
// XXX this appears to be run in the node context...
|
||||||
@ -210,14 +188,12 @@ 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 })
|
||||||
|
.on('edit-done', function(_, text){
|
||||||
|
that.focusRibbon(text == '*' ? that.base : parseInt(text))
|
||||||
|
})
|
||||||
.click(function(){
|
.click(function(){
|
||||||
$(this)
|
$(this).selectText()
|
||||||
.makeEditable({
|
|
||||||
clear_on_edit: false
|
|
||||||
})
|
|
||||||
.on('edit-done', function(_, text){
|
|
||||||
that.focusRibbon(text == '*' ? that.base : parseInt(text))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.blur(function(){
|
.blur(function(){
|
||||||
that.updateStatusBar()
|
that.updateStatusBar()
|
||||||
|
|||||||
@ -38,6 +38,7 @@ module.makeEditableItem =
|
|||||||
function(list, item, elem, callback, options){
|
function(list, item, elem, callback, options){
|
||||||
return elem
|
return elem
|
||||||
.makeEditable({
|
.makeEditable({
|
||||||
|
activate: true,
|
||||||
clear_on_edit: false,
|
clear_on_edit: false,
|
||||||
})
|
})
|
||||||
.on('edit-done', callback || function(){})
|
.on('edit-done', callback || function(){})
|
||||||
@ -93,6 +94,7 @@ function(actions, list_key, options){
|
|||||||
var _makeEditable = function(elem){
|
var _makeEditable = function(elem){
|
||||||
return $(elem).find('.text')
|
return $(elem).find('.text')
|
||||||
.makeEditable({
|
.makeEditable({
|
||||||
|
activate: true,
|
||||||
blur_on_abort: false,
|
blur_on_abort: false,
|
||||||
blur_on_commit: false,
|
blur_on_commit: false,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -367,21 +367,29 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
//
|
//
|
||||||
// Options format:
|
// Options format:
|
||||||
// {
|
// {
|
||||||
|
// // activate (focus) element when done...
|
||||||
|
// activate: false,
|
||||||
|
//
|
||||||
|
// // set multi line edit mode...
|
||||||
// multiline: false,
|
// multiline: false,
|
||||||
//
|
//
|
||||||
|
// // reset value on abort...
|
||||||
// reset_on_abort: true,
|
// reset_on_abort: true,
|
||||||
//
|
//
|
||||||
|
// // blur element on abort/commit...
|
||||||
// blur_on_abort: false,
|
// blur_on_abort: false,
|
||||||
// blur_on_commit: false,
|
// blur_on_commit: false,
|
||||||
//
|
//
|
||||||
|
// // 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,
|
||||||
//
|
//
|
||||||
|
// // clear element value on edit...
|
||||||
// clear_on_edit: true,
|
// clear_on_edit: true,
|
||||||
//
|
//
|
||||||
|
// // Keys that will abort the edit...
|
||||||
// abort_keys: [
|
// abort_keys: [
|
||||||
// 'Esc',
|
// 'Esc',
|
||||||
// ...
|
|
||||||
// ],
|
// ],
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -415,10 +423,10 @@ if(typeof(jQuery) != typeof(undefined)){
|
|||||||
this.text('')
|
this.text('')
|
||||||
}
|
}
|
||||||
|
|
||||||
this
|
this.prop('contenteditable', true)
|
||||||
.prop('contenteditable', true)
|
|
||||||
// NOTE: this will also focus the element...
|
// NOTE: this will also focus the element...
|
||||||
.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')){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user