added status bar index editing...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-03-24 23:14:25 +03:00
parent d0480ab14e
commit b0b0d92c0b

View File

@ -11,6 +11,7 @@ define(function(require){ var module = {}
var toggler = require('lib/toggler') var toggler = require('lib/toggler')
var actions = require('lib/actions') var actions = require('lib/actions')
var features = require('lib/features') var features = require('lib/features')
var keyboard = require('lib/keyboard')
var data = require('data') var data = require('data')
var images = require('images') var images = require('images')
@ -68,6 +69,8 @@ var StatusBarActions = actions.Actions({
'gid', 'gid',
'path', 'path',
], ],
'status-bar-index-live-update-on-edit': false,
}, },
__statusbar_elements__: { __statusbar_elements__: {
@ -83,13 +86,48 @@ var StatusBarActions = actions.Actions({
.append($('<span>') .append($('<span>')
.addClass('position') .addClass('position')
.attr('info', 'Image position (click to edit image position)') .attr('info', 'Image position (click to edit image position)')
.prop('contenteditable', true)
.keydown(function(){
// keep this from affecting the viewer...
event.stopPropagation()
var n = keyboard.toKeyName(event.keyCode)
console.log('KEY:', n)
// lose focus and exit...
if(n == 'Esc' || n == 'Enter'){
event.preventDefault()
// get image on enter...
if(n == 'Enter'){
that.focusImage(parseInt($(this).text())-1,
item.hasClass('global') ? 'global' : undefined)
}
// clear selection....
window.getSelection().removeAllRanges()
$(this).blur()
return false
}
})
// update image position...
.keyup(function(){
event.stopPropagation()
that.config['status-bar-index-live-update-on-edit']
&& that.focusImage(parseInt($(this).text())-1,
item.hasClass('global') ? 'global' : undefined)
})
.click(function(){ .click(function(){
// XXX enter edit mode -> select contents... // select the text...
// XXX might be a good idea to live select window.getSelection().removeAllRanges()
// the indexed image... (???) var range = document.createRange()
//$(this) range.selectNodeContents(this)
// .prop('contenteditable', true) window.getSelection().addRange(range)
// XXX })
.blur(function(){
that.updateStatusBar()
})) }))
.append($('<span>') .append($('<span>')
.addClass('length') .addClass('length')
@ -108,14 +146,14 @@ var StatusBarActions = actions.Actions({
// update... // update...
// global index... // global index...
if(item.hasClass('global')){ if(item.hasClass('global')){
item.find('.position') item.find('.position:not(:focus)')
.text(this.data.getImageOrder(gid)+1) .text(this.data.getImageOrder(gid)+1)
item.find('.length') item.find('.length')
.text('/'+ this.data.length) .text('/'+ this.data.length)
// ribbon index... // ribbon index...
} else { } else {
item.find('.position') item.find('.position:not(:focus)')
.text(this.data.getImageOrder('ribbon', gid)+1) .text(this.data.getImageOrder('ribbon', gid)+1)
item.find('.length') item.find('.length')
.text('/'+ this.data.getImages(gid).len) .text('/'+ this.data.getImages(gid).len)