mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 03:40:09 +00:00
added recently opened list diaolg (ctrl-H) and now choice widget supports default value...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c0767e20aa
commit
8da1eb0fab
@ -1126,7 +1126,7 @@ function updateImage(image, gid, size){
|
||||
img_data = STUB_IMAGE_DATA
|
||||
}
|
||||
|
||||
/*
|
||||
/* XXX does not seem to be needing this...
|
||||
// set the current class...
|
||||
if(gid == DATA.current){
|
||||
image.addClass('current')
|
||||
|
||||
@ -53,7 +53,7 @@ var KEYBOARD_CONFIG = {
|
||||
return false
|
||||
}),
|
||||
},
|
||||
F5: doc('Reload viewer',
|
||||
F5: doc('Full reload viewer',
|
||||
function(){
|
||||
reload()
|
||||
return false
|
||||
@ -228,8 +228,9 @@ var KEYBOARD_CONFIG = {
|
||||
//
|
||||
'.single-ribbon-mode:not(.single-image-mode), .marked-only-view:not(.single-image-mode)': {
|
||||
title: 'Cropped ribbon views',
|
||||
doc: 'To crop marked images press <b>shift-F2</b> and for '+
|
||||
'single ribbon crop view press <b>F3</b>.'+
|
||||
doc: 'To crop marked images press <b>shift-F2</b> for '+
|
||||
'single ribbon crop view press <b>F3</b> and to open the crop '+
|
||||
'dialog for more options press <b>C</b>.'+
|
||||
'<p>NOTE: toggling crop views is only possible from ribbon view.',
|
||||
|
||||
Esc: {
|
||||
@ -332,7 +333,7 @@ var KEYBOARD_CONFIG = {
|
||||
'#9': doc('Fit nine images', function(){ fitNImages(9) }),
|
||||
|
||||
// cropping...
|
||||
C: doc('Show data crop dialog', cropImagesDialog),
|
||||
C: doc('Show ribbon crop dialog', cropImagesDialog),
|
||||
|
||||
// XXX add a non FXX key for macs...
|
||||
F2: {
|
||||
@ -513,16 +514,22 @@ var KEYBOARD_CONFIG = {
|
||||
reverseImageOrder()
|
||||
}),
|
||||
},
|
||||
H: doc('Flip image horizontally',
|
||||
function(){
|
||||
var o = getImage().attr('orientation')
|
||||
// need to rotate relative to user, not relative to image...
|
||||
if(o == 90 || o == 270){
|
||||
flipVertical()
|
||||
} else {
|
||||
flipHorizontal()
|
||||
}
|
||||
}),
|
||||
H: {
|
||||
default: doc('Flip image horizontally',
|
||||
function(){
|
||||
var o = getImage().attr('orientation')
|
||||
// need to rotate relative to user, not relative to image...
|
||||
if(o == 90 || o == 270){
|
||||
flipVertical()
|
||||
} else {
|
||||
flipHorizontal()
|
||||
}
|
||||
}),
|
||||
ctrl: doc('Show recently opend urls',
|
||||
function(){
|
||||
recentlyOpenedDialog()
|
||||
}),
|
||||
},
|
||||
V: doc('Flip image vertically',
|
||||
function(){
|
||||
var o = getImage().attr('orientation')
|
||||
|
||||
50
ui/ui.js
50
ui/ui.js
@ -554,6 +554,9 @@ var FIELD_TYPES = {
|
||||
|
||||
// format:
|
||||
// ['a', 'b', 'c', ...]
|
||||
//
|
||||
// an item can be of the folowing format:
|
||||
// <text> ['|' 'default' ]
|
||||
choice: {
|
||||
type: 'choice',
|
||||
text: null,
|
||||
@ -569,22 +572,43 @@ var FIELD_TYPES = {
|
||||
return typeof(val) == typeof([]) && val.constructor.name == 'Array'
|
||||
},
|
||||
set: function(field, value){
|
||||
var t = field.find('.text').text()
|
||||
var t = field.find('.text').html()
|
||||
t = t == '' ? Math.random()+'' : t
|
||||
var item = field.find('.item').last()
|
||||
for(var i=0; i < value.length; i++){
|
||||
item.find('.value')
|
||||
.val(value[i])
|
||||
var txt = value[i]
|
||||
|
||||
// get options...
|
||||
var opts = txt.split(/\|/g)
|
||||
txt = opts[0].trim()
|
||||
opts = opts
|
||||
.slice(1)
|
||||
.map(function(e){ return e.trim() })
|
||||
|
||||
var val = item.find('.value')
|
||||
val.val(txt)
|
||||
|
||||
// set checked state...
|
||||
if(opts.indexOf('default') >= 0){
|
||||
val.prop('checked', true)
|
||||
opts.splice(opts.indexOf('default'), 1)
|
||||
} else {
|
||||
val.prop('checked', false)
|
||||
}
|
||||
|
||||
item.find('.item-text')
|
||||
.text(value[i])
|
||||
.html(txt)
|
||||
item.appendTo(field)
|
||||
|
||||
item = item.clone()
|
||||
}
|
||||
field.find('.value')
|
||||
var values = field.find('.value')
|
||||
.attr('name', t)
|
||||
.first()
|
||||
.attr('checked', '')
|
||||
// set the default...
|
||||
if(values.filter(':checked').length == 0){
|
||||
values.first()
|
||||
.prop('checked', true)
|
||||
}
|
||||
},
|
||||
get: function(field){
|
||||
return $(field).find('.value:checked').val()
|
||||
@ -739,7 +763,7 @@ function formDialog(root, message, config, btn, cls){
|
||||
text = t.replace(/\\\|/g, '|')
|
||||
}
|
||||
// setup text and data...
|
||||
html.find('.text').text(text)
|
||||
html.find('.text').html(text)
|
||||
field.set(html, config[t])
|
||||
|
||||
// NOTE: this is here to isolate t and field.get values...
|
||||
@ -797,9 +821,13 @@ function formDialog(root, message, config, btn, cls){
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
form.find('.field input').first()
|
||||
.focus()
|
||||
.select()
|
||||
var e = form.find('.field input:checked')
|
||||
if(e.length > 0){
|
||||
e.focus()
|
||||
} else {
|
||||
form.find('.field input').first()
|
||||
.focus()
|
||||
}
|
||||
}, 100)
|
||||
|
||||
return res
|
||||
|
||||
@ -115,6 +115,62 @@ var loadURLHistoryNext = makeURLHistoryLoader(getURLHistoryNext, 'at last URL')
|
||||
var loadURLHistoryPrev = makeURLHistoryLoader(getURLHistoryPrev, 'at first URL')
|
||||
|
||||
|
||||
// NOTE: this can accept either path or history index...
|
||||
// NOTE: this will not reload an already loaded url...
|
||||
function loadURLHistoryAt(a){
|
||||
a = a < 0 ? BASE_URL_HISTORY + a : a
|
||||
var url = typeof(a) == typeof(123) ? Math.min(a < 0 ? 0 : a, BASE_URL_HISTORY.length-1) : a
|
||||
if(url != BASE_URL){
|
||||
statusNotify(loadDir(url))
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Dialogs...
|
||||
*/
|
||||
|
||||
function recentlyOpenedDialog(){
|
||||
|
||||
updateStatus('Recently opened...').show()
|
||||
|
||||
var dict = {}
|
||||
var title = '<b>Recently opened:</b>'
|
||||
|
||||
var cfg = {}
|
||||
cfg[title] = BASE_URL_HISTORY.map(function(e){
|
||||
if(e == BASE_URL){
|
||||
var ee = e.italics()
|
||||
dict[ee] = e
|
||||
return ee + ' | default'
|
||||
}
|
||||
dict[e] = e
|
||||
return e
|
||||
})
|
||||
|
||||
formDialog(null, '',
|
||||
cfg,
|
||||
'OK',
|
||||
'recentlyOpenedDialog')
|
||||
.done(function(res){
|
||||
res = dict[res[title]]
|
||||
|
||||
loadURLHistoryAt(res)
|
||||
|
||||
if(res == BASE_URL){
|
||||
showStatusQ('Already at: '+res+'...')
|
||||
} else {
|
||||
showStatusQ('Opening: '+res+'...')
|
||||
}
|
||||
})
|
||||
.fail(function(){
|
||||
showStatusQ('Keeping current...')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user