From 31f51ff6ac5ca7f353ef9d920d98a79e97a87070 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 24 Apr 2017 14:34:09 +0300 Subject: [PATCH] experementing... Signed-off-by: Alex A. Naanou --- ui (gen4)/css/experimenting.css | 5 +- ui (gen4)/features/location.js | 69 ++++++++++++++++++++++ ui (gen4)/features/ui-partial-ribbons-2.js | 2 + ui (gen4)/imagegrid/ribbons.js | 1 + 4 files changed, 76 insertions(+), 1 deletion(-) diff --git a/ui (gen4)/css/experimenting.css b/ui (gen4)/css/experimenting.css index eedb760c..3954b5da 100755 --- a/ui (gen4)/css/experimenting.css +++ b/ui (gen4)/css/experimenting.css @@ -340,9 +340,12 @@ body { } /* make buttons a bit different in action browser... */ -.browse-widget.browse-actions.show-keys .list .button { +.browse-widget.browse-actions .list .button { background-color: rgba(0, 0, 0, 0.12); } +.dark .browse-widget.browse-actions .list .button { + background-color: rgba(255, 255, 255, 0.2); +} diff --git a/ui (gen4)/features/location.js b/ui (gen4)/features/location.js index 8444d58a..d586f1b8 100755 --- a/ui (gen4)/features/location.js +++ b/ui (gen4)/features/location.js @@ -177,6 +177,75 @@ var LocationActions = actions.Actions({ return res }], + + // XXX need a way to get save method... + // - rename .location.method to .location.load and add .location.save + // - treat method as protocol and add a method registry API + // this is more flexible as we can add as many methods per + // protocol as we need and add a command action: + // - execute command in current protocol + // .locationCall("command", ...) + // - execute command in specific protocol + // .locationCall('protocol:command', ..) + // - show current protocol + // .locationCall("?") + // - list commands + // .locationCall("??") + // .locationCall('protocol:??') + // we can implicitly define protocols via action attrs: + // loadIndex: ['...', + // {locationProtocol: 'file:load'}, + // function(){ ... }], + locationDispatch: ['- File/', + function(spec){ + spec = spec instanceof Array ? spec : spec.split(':') + var args = [].slice.call(arguments, 1) + + var action = spec.pop() + var protocol = spec.shift() || this.location.method + + // format: + // { + // 'protocol:method': 'actionName', + // ... + // } + var cache = this.__location_protocol_cache = + this.__location_protocol_cache || this.cacheLocationProtocols() + + // get protocol... + if(action == '?'){ + return protocol + + // get available methods for protocol... + } else if(action == '??'){ + return Object.keys(cache) + .filter(function(e){ return e.startsWith(protocol + ':') }) + .map(function(e){ return e.split(':').pop() }) + + // list all protocols... + } else if(protocol == '??' && action == '*'){ + return Object.keys(cache) + .map(function(e){ return e.split(':').pop() }) + .unique() + + // list protocols implementing specific action... + } else if(protocol == '??'){ + return Object.keys(cache) + .filter(function(e){ return e.endsWith(':'+ action) }) + .map(function(e){ return e.split(':')[0] }) + .unique() + + // call method... + } else { + // XXX args??? + this[cache[protocol +':'+ action]].call(this) + } + }], + saveLocation: ['- File/Save location', + function(location){ + // XXX + this.locationDispatch('save') + }], }) module.Location = core.ImageGridFeatures.Feature({ diff --git a/ui (gen4)/features/ui-partial-ribbons-2.js b/ui (gen4)/features/ui-partial-ribbons-2.js index 0105022c..65037875 100755 --- a/ui (gen4)/features/ui-partial-ribbons-2.js +++ b/ui (gen4)/features/ui-partial-ribbons-2.js @@ -132,6 +132,8 @@ var PartialRibbonsActions = actions.Actions({ // - revise .updateImage(..) // // Q: can this be done within 1/60s??? + // XXX one approach here might be: + // wait for images to preload and only then update... } else { //console.log('UPDATE', t - this.__last_ribbon_update) var c = gids.indexOf(data.getImage('current', r_gid)) diff --git a/ui (gen4)/imagegrid/ribbons.js b/ui (gen4)/imagegrid/ribbons.js index e7152a01..f998e328 100755 --- a/ui (gen4)/imagegrid/ribbons.js +++ b/ui (gen4)/imagegrid/ribbons.js @@ -1504,6 +1504,7 @@ var RibbonsPrototype = { return image[0] })) }, + // XXX add options for images to preload and only then do the update... updateImage: function(image, gid, size, sync, callback){ var that = this image = (image == '*' ? this.viewer.find(IMAGE)