mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added image sord dialog...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ba38f67c6c
commit
b5dd4f4d82
@ -1,7 +1,7 @@
|
|||||||
#=======================================================================
|
#=======================================================================
|
||||||
|
|
||||||
__version__ = '''0.0.01'''
|
__version__ = '''0.0.01'''
|
||||||
__sub_version__ = '''20130613200255'''
|
__sub_version__ = '''20130622165505'''
|
||||||
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
__copyright__ = '''(c) Alex A. Naanou 2011'''
|
||||||
|
|
||||||
|
|
||||||
@ -329,7 +329,11 @@ def build_previews(image, path=None, config=CONFIG, dry_run=True, verbosity=0):
|
|||||||
image['preview'][str(max(*img.size)) + 'px'] = img_path
|
image['preview'][str(max(*img.size)) + 'px'] = img_path
|
||||||
|
|
||||||
# previews...
|
# previews...
|
||||||
for k, spec in sizes.items():
|
preview = None
|
||||||
|
# NOTE: do the big previews first...
|
||||||
|
s = sizes.items()
|
||||||
|
s.sort(lambda a, b: cmp(b[1], a[1]))
|
||||||
|
for k, spec in s:
|
||||||
|
|
||||||
if k in image['preview'].keys():
|
if k in image['preview'].keys():
|
||||||
continue
|
continue
|
||||||
@ -344,6 +348,11 @@ def build_previews(image, path=None, config=CONFIG, dry_run=True, verbosity=0):
|
|||||||
|
|
||||||
# add image to index...
|
# add image to index...
|
||||||
if not os.path.exists(p):
|
if not os.path.exists(p):
|
||||||
|
# use the preview to speed things up...
|
||||||
|
# NOTE: this will degrade the quality of previews after
|
||||||
|
# several resizes...
|
||||||
|
## if preview != None:
|
||||||
|
## img = preview
|
||||||
scale = spec/float(max(*img.size))
|
scale = spec/float(max(*img.size))
|
||||||
preview = img.resize((int(img.size[0]*scale), int(img.size[1]*scale)), Image.ANTIALIAS)
|
preview = img.resize((int(img.size[0]*scale), int(img.size[1]*scale)), Image.ANTIALIAS)
|
||||||
|
|
||||||
|
|||||||
@ -274,7 +274,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
// XXX STUB: use a real path browser...
|
// XXX STUB: use a real path browser...
|
||||||
O: doc('Open a directory path',
|
O: doc('Open a directory path',
|
||||||
function(){
|
function(){
|
||||||
loadDirectory()
|
loadDirectoryDialog()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
||||||
@ -451,6 +451,10 @@ var KEYBOARD_CONFIG = {
|
|||||||
S: {
|
S: {
|
||||||
default: doc('Start slideshow',
|
default: doc('Start slideshow',
|
||||||
function(){ toggleSlideShowMode('on') }),
|
function(){ toggleSlideShowMode('on') }),
|
||||||
|
shift: doc('Sort images',
|
||||||
|
function(){
|
||||||
|
sortImagesDialog()
|
||||||
|
}),
|
||||||
ctrl: doc('Save current state',
|
ctrl: doc('Save current state',
|
||||||
function(){
|
function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -477,7 +481,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
}),
|
}),
|
||||||
'ctrl+shift': doc('Export',
|
'ctrl+shift': doc('Export',
|
||||||
function(){
|
function(){
|
||||||
exportPreviews()
|
exportPreviewsDialog()
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Z: {
|
Z: {
|
||||||
|
|||||||
85
ui/ui.js
85
ui/ui.js
@ -490,6 +490,43 @@ var FIELD_TYPES = {
|
|||||||
return field.find('.path').val()
|
return field.find('.path').val()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
choice: {
|
||||||
|
type: 'choice',
|
||||||
|
text: null,
|
||||||
|
default: false,
|
||||||
|
html: '<div class="field choice">'+
|
||||||
|
'<span class="text"></span>'+
|
||||||
|
'<div class="item">'+
|
||||||
|
'<input type="radio" class="value"/>'+
|
||||||
|
'<span class="item-text"></span>'+
|
||||||
|
'</div>'+
|
||||||
|
'</div>',
|
||||||
|
// format: ['a', 'b', 'c', ...]
|
||||||
|
test: function(val){
|
||||||
|
return typeof(val) == typeof([]) && val.constructor.name == 'Array'
|
||||||
|
},
|
||||||
|
set: function(field, value){
|
||||||
|
var t = field.find('.text').text()
|
||||||
|
var item = field.find('.item').last()
|
||||||
|
for(var i=0; i < value.length; i++){
|
||||||
|
item.find('.value')
|
||||||
|
.val(value[i])
|
||||||
|
item.find('.item-text')
|
||||||
|
.text(value[i])
|
||||||
|
item.appendTo(field)
|
||||||
|
|
||||||
|
item = item.clone()
|
||||||
|
}
|
||||||
|
field.find('.value')
|
||||||
|
.attr('name', t)
|
||||||
|
.first()
|
||||||
|
.attr('checked', '')
|
||||||
|
},
|
||||||
|
get: function(field){
|
||||||
|
return $(field).find('.value:checked').val()
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a complex form dialog
|
// Show a complex form dialog
|
||||||
@ -642,8 +679,11 @@ function getDir(message, dfl, btn){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************** Domain-specific dialogs ***/
|
||||||
|
|
||||||
// XXX do reporting...
|
// XXX do reporting...
|
||||||
function exportPreviews(dfl){
|
function exportPreviewsDialog(dfl){
|
||||||
dfl = dfl == null ? BASE_URL : dfl
|
dfl = dfl == null ? BASE_URL : dfl
|
||||||
var res = $.Deferred()
|
var res = $.Deferred()
|
||||||
|
|
||||||
@ -653,7 +693,7 @@ function exportPreviews(dfl){
|
|||||||
'Image name pattern': '%f',
|
'Image name pattern': '%f',
|
||||||
'Fav directory name': 'fav',
|
'Fav directory name': 'fav',
|
||||||
'Destination': {ndir: dfl},
|
'Destination': {ndir: dfl},
|
||||||
}, 'OK', 'exportPreviews')
|
}, 'OK', 'exportPreviewsDialog')
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
exportTo(
|
exportTo(
|
||||||
data['Destination'],
|
data['Destination'],
|
||||||
@ -675,7 +715,7 @@ function exportPreviews(dfl){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadDirectory(dfl){
|
function loadDirectoryDialog(dfl){
|
||||||
dfl = dfl == null ? BASE_URL : dfl
|
dfl = dfl == null ? BASE_URL : dfl
|
||||||
// browser version...
|
// browser version...
|
||||||
var getter = window.listDir != null ? getDir : prompt
|
var getter = window.listDir != null ? getDir : prompt
|
||||||
@ -697,8 +737,45 @@ function loadDirectory(dfl){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sortImagesDialog(message){
|
||||||
|
updateStatus('Sort...').show()
|
||||||
|
|
||||||
|
message = message == null ? 'Sort images by:' : message
|
||||||
|
cfg = {}
|
||||||
|
cfg[message] = [
|
||||||
|
'Date (ascending)',
|
||||||
|
'Name (ascending)',
|
||||||
|
'Date (decending)',
|
||||||
|
'Name (decending)',
|
||||||
|
]
|
||||||
|
|
||||||
|
formDialog(null, '',
|
||||||
|
cfg,
|
||||||
|
'OK',
|
||||||
|
'sortImagesDialog')
|
||||||
|
.done(function(res){
|
||||||
|
res = res[message]
|
||||||
|
|
||||||
|
if(/Date/.test(res)){
|
||||||
|
var method = sortImagesByDate
|
||||||
|
} else {
|
||||||
|
var method = sortImagesByName
|
||||||
|
}
|
||||||
|
if(/\(ascending\)/.test(res)){
|
||||||
|
var reverse = null
|
||||||
|
} else {
|
||||||
|
var reverse = true
|
||||||
|
}
|
||||||
|
|
||||||
|
showStatusQ('Sorting by: '+res+'...')
|
||||||
|
|
||||||
|
method(reverse)
|
||||||
|
})
|
||||||
|
.fail(function(){
|
||||||
|
showStatusQ('Sort: canceled.')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************ Specific dialogs ***/
|
|
||||||
|
|
||||||
function showImageInfo(){
|
function showImageInfo(){
|
||||||
var gid = getImageGID(getImage())
|
var gid = getImageGID(getImage())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user