diff --git a/ui (gen4)/features/base.js b/ui (gen4)/features/base.js index 84940707..ccb38bc1 100755 --- a/ui (gen4)/features/base.js +++ b/ui (gen4)/features/base.js @@ -599,19 +599,26 @@ actions.Actions({ // actions if that info is needed. // NOTE: to make things clean, this is triggered in action handlers // below... + // XXX do we need a vertical shift event?? shiftImage: ['- Interface/Image shift (do not use directly)', core.notUserCallable(function(gid){ // This is the image shift protocol root function // // Not for direct use. })], + shiftImageOrder: ['- Interface/Image horizontal shift (do not use directly)', + core.notUserCallable(function(gid){ + // This is the image shift protocol root function + // + // Not for direct use. + })], // XXX to be used for things like mark/place and dragging... // XXX revise... // XXX undo... shiftImageTo: ['- Edit|Sort|Image/', {undo: function(a){ this.shiftImageTo(a.args[1], a.args[0]) }}, - function(target, to){ this.data.shiftImageTo(target, to) }], + function(target, to){ this.data.shiftImage(target, to) }], shiftImageUp: ['Edit|Image/Shift image up', 'If implicitly shifting current image (i.e. no arguments), focus ' @@ -862,6 +869,19 @@ module.Base = core.ImageGridFeatures.Feature({ 'shiftImageRight', ], function(){ this.shiftImage.apply(this, [].slice(arguments, 1))}], + // horizontal shifting... + [[ + 'shiftImageLeft', + 'shiftImageRight', + ], + function(){ this.shiftImageOrder.apply(this, [].slice(arguments, 1))}], + ['shiftImageTo.pre', + function(a){ + var i = this.data.getImageOrder(a) + return function(){ + // only trigger if order changed... + i != this.data.getImageOrder(a) + && this.shiftImageOrder.apply(this, [].slice(arguments, 1)) } }], // manage changes... // everything changed... diff --git a/ui (gen4)/features/sort.js b/ui (gen4)/features/sort.js index 5b4850dd..21307590 100755 --- a/ui (gen4)/features/sort.js +++ b/ui (gen4)/features/sort.js @@ -391,7 +391,7 @@ module.SortActions = actions.Actions({ if(order){ this.data.order = order.slice() this.sortImages('update' + (reverse ? ' reverse' : '')) - this.data.sort_method = mode + this.data.sort_method = title } }], @@ -409,7 +409,8 @@ module.SortActions = actions.Actions({ // Store/load sort data: // .data.sort_method - current sort mode (optional) - // .data.sort_cache - manual sort order (optional) + // .data.sort_order - saved sort order (optional) + // .data.sort_cache - cached sort order (optional) load: [function(data){ return function(){ if(data.data && data.data.sort_method){ @@ -493,6 +494,15 @@ module.Sort = core.ImageGridFeatures.Feature({ // manage changes... ['sortImages', function(_, target){ this.markChanged('data') }], + // NOTE: this always saves to 'Manual' this is correct regardless + // of save mode as in the current logic, the only mode that + // results from a manual shift is a manual sort... + // XXX this may pose a problem with saved sorts, the question + // is whether a saved mode can be edited or just saved or + // updated... + ['shiftImageOrder', + function(){ this.markChanged('sort_order', ['Manual']) }], + ['saveOrder', function(_, title){ this.markChanged('sort_order', [title]) }], ['cacheOrder', diff --git a/ui (gen4)/imagegrid/data.js b/ui (gen4)/imagegrid/data.js index 3e05ecc9..18d0f694 100755 --- a/ui (gen4)/imagegrid/data.js +++ b/ui (gen4)/imagegrid/data.js @@ -2587,6 +2587,7 @@ var DataPrototype = { // load initial state... if(json != null){ this.loadJSON(json) + } else { this._reset() } diff --git a/ui (gen4)/imagegrid/file.js b/ui (gen4)/imagegrid/file.js index 2f13a331..2dc34e17 100755 --- a/ui (gen4)/imagegrid/file.js +++ b/ui (gen4)/imagegrid/file.js @@ -827,6 +827,15 @@ module.buildIndex = function(index, base_path){ img.forEach(function(_, img){ img.base_path = base_path }) } + // extra stuff... + // ...this will restore stuff stored in the data but not explicitly + // restored above... + Object.keys(index.data).forEach(function(k){ + if(d[k] === undefined){ + d[k] = index.data[k] + } + }) + res.data = d res.images = img