From daa462184b7f2c74d02842631c242f630b0a49d4 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 8 Jun 2016 18:10:39 +0300 Subject: [PATCH] edded export index preview limit + now crop is dropped on .load(..)... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/base.js | 6 ++-- ui (gen4)/features/filesystem.js | 53 ++++++++++++++++++++++++++++---- ui (gen4)/features/ui-widgets.js | 3 +- ui (gen4)/imagegrid/file.js | 1 - 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index ad71a9ef..cebcdbbf 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -691,6 +691,9 @@ module.CropActions = actions.Actions({ // load the crop stack if present... load: [function(data){ + // clear previous crop state... + delete this.crop_stack + if(data.crop_stack){ this.crop_stack = data.crop_stack.map(function(j){ return data.Data(j) @@ -727,8 +730,7 @@ module.CropActions = actions.Actions({ // true if current viewer is cropped... get cropped(){ - return this.crop_stack != null - }, + return this.crop_stack != null }, // crop... // diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 27b9b8ec..7e931e82 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -1214,6 +1214,14 @@ var FileSystemWriterActions = actions.Actions({ '1920', ], 'export-preview-size': 1000, + + 'export-preview-size-limits': [ + '900', + '1000', + '1280', + '1920', + ], + 'export-preview-size-limit': 'no limit', }, // This can be: @@ -1484,8 +1492,8 @@ var FileSystemWriterActions = actions.Actions({ function(path, max_size, include_orig, logger){ logger = logger || this.logger - // XXX if size is not given save all sizes... - //max_size = max_size || this.config['export-preview-size'] + max_size = parseInt(max_size || this.config['export-preview-size-limit']) || null + // XXX make this dependant on max_size.... include_orig = include_orig || true // XXX is this correct??? @@ -1546,8 +1554,19 @@ var FileSystemWriterActions = actions.Actions({ if(previews || img.path){ Object.keys(previews || {}) // limit preview size... + // NOTE: also remove the preview resolution if + // it's smaller... .filter(function(res){ - return !max_size || parseInt(res) <= max_size}) + // no size limit or match... + if(!max_size || parseInt(res) <= max_size){ + return true + + // skip and remove... + } else { + delete previews[res] + return false + } + }) // get paths... .map(function(res){ return decodeURI(previews[res]) }) // XXX might be a good idea to include include @@ -1585,11 +1604,15 @@ var FileSystemWriterActions = actions.Actions({ } }) + // prep the index... + var index = this.prepareIndexForWrite(json, true) + // NOTE: if we are to use .saveIndex(..) here, do not forget // to reset .changes queue.push(file.writeIndex( - this.prepareIndexForWrite(json, true).prepared, + index.prepared, index_path, + index.date, this.config['index-filename-template'], logger || this.logger) // set hidden file attribute on Windows... @@ -1597,7 +1620,6 @@ var FileSystemWriterActions = actions.Actions({ typeof(process) != 'undefined' && (process.platform == 'win32' || process.platform == 'win64') - // XXX do we need to quote path??? && child_process .spawn('attrib', ['+h', index_path]) })) @@ -1874,7 +1896,7 @@ var FileSystemWriterUIActions = actions.Actions({ // XXX use closest preview instead of hi-res when // this is set... // XXX need to add option to save full index... - //'size_limit', + 'size_limit', // XXX might be a good idea to include source data links //'include_source_url', // bool 'comment', @@ -1983,6 +2005,25 @@ var FileSystemWriterUIActions = actions.Actions({ })) }, + 'size_limit': function(actions, make, parent){ + return make(['Limit image size: ', + function(){ + return actions.config['export-preview-size-limit'] || 'no limit' }], + { buttons: [ + ['×', function(p){ + actions.config['export-preview-size-limit'] = 'no limit' + parent.update() + }], + ] }) + // XXX add validation??? + .on('open', + widgets.makeNestedConfigListEditor(actions, parent, + 'export-preview-size-limits', + 'export-preview-size-limit', + { + sort: function(a, b){ return parseInt(a) - parseInt(b) }, + })) + }, // XXX BUG: history closing errors -- non-critical... 'target_dir': function(actions, make, parent){ var elem = make(['To: ', diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 09346170..b9438ad5 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -335,7 +335,8 @@ module.makeUIContainer = function(make){ // Compensate for click focusing the parent dialog when // a child is created... // XXX is this the right way to go??? - .on('click', function(evt){ that.modal.focus() }) + .on('click', function(evt){ + that.modal && that.modal.focus() }) return o }) diff --git a/ui (gen4)/imagegrid/file.js b/ui (gen4)/imagegrid/file.js index 08bebe32..938c1933 100755 --- a/ui (gen4)/imagegrid/file.js +++ b/ui (gen4)/imagegrid/file.js @@ -18,7 +18,6 @@ if(typeof(process) != 'undefined'){ var guaranteeEvents = requirejs('guarantee-events') - } else { return module }