diff --git a/ui/data.js b/ui/data.js index c30bb924..be5c4cb0 100755 --- a/ui/data.js +++ b/ui/data.js @@ -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') diff --git a/ui/keybindings.js b/ui/keybindings.js index d261f2a9..6b59b8c6 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -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 shift-F2 and for '+ - 'single ribbon crop view press F3.'+ + doc: 'To crop marked images press shift-F2 for '+ + 'single ribbon crop view press F3 and to open the crop '+ + 'dialog for more options press C.'+ '

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') diff --git a/ui/ui.js b/ui/ui.js index 0731073f..497d584e 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -554,6 +554,9 @@ var FIELD_TYPES = { // format: // ['a', 'b', 'c', ...] + // + // an item can be of the folowing format: + // ['|' '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 diff --git a/ui/urlhistory.js b/ui/urlhistory.js index 1424cd72..52f7c0b8 100755 --- a/ui/urlhistory.js +++ b/ui/urlhistory.js @@ -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 = 'Recently opened:' + + 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 : */