From cf02d3c2d58f63103308bfdb57d8a6e691a0faa9 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 28 Nov 2014 03:57:10 +0300 Subject: [PATCH] split .config and added default config inheritance + added fit-overflow option to help controling fitting of images on screen... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/actions.js | 9 +++++++++ ui (gen4)/testing.js | 3 +++ ui (gen4)/viewer.js | 29 ++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ui (gen4)/lib/actions.js b/ui (gen4)/lib/actions.js index 43c1c02c..b78d2a2d 100755 --- a/ui (gen4)/lib/actions.js +++ b/ui (gen4)/lib/actions.js @@ -639,6 +639,9 @@ module.MetaActions = { // // This will pre-process an object to setup the action mechanics. // +// If the this and prototype both contain a .config attribute then this +// will make set .config.__proto__ = .config +// // // The action format: // { @@ -668,6 +671,7 @@ module.MetaActions = { // For more documentation see: Action(..). // // XXX add doc, ldoc, tags and save them to each action... +// XXX is .config processing correct here??? var Actions = module.Actions = function Actions(a, b){ @@ -694,6 +698,11 @@ function Actions(a, b){ if(proto != null){ obj.__proto__ = proto + + // XXX is this the right way to go??? + if(obj.config != null && proto.config != null){ + obj.config.__proto__ = proto.config + } } return obj diff --git a/ui (gen4)/testing.js b/ui (gen4)/testing.js index 50019672..d04caac6 100755 --- a/ui (gen4)/testing.js +++ b/ui (gen4)/testing.js @@ -102,6 +102,9 @@ module.setupActions = function(viewer){ var vv = Object.create(v.Viewer) + // XXX need to automate this... + vv.config = Object.create(vv.config || {}) + return vv } diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js index 49b159a9..2ed6d34f 100755 --- a/ui (gen4)/viewer.js +++ b/ui (gen4)/viewer.js @@ -137,14 +137,10 @@ var Client = module.Client = actions.Actions({ - // XXX should this be here??? config: { 'steps-to-change-direction': 3, - 'max-screen-images': 30, - 'zoom-step': 1.2, }, - // basic state... // NOTE: the setters in the following use the appropriate actions // so to avoid recursion do not use these in the specific @@ -646,6 +642,15 @@ var Viewer = module.Viewer = actions.Actions(Client, { + config: { + 'max-screen-images': 30, + + 'zoom-step': 1.2, + + // added to number of images to fit to indicate scroll ability... + 'fit-overflow': 0.2, + }, + /* // Images... get images(){ @@ -967,7 +972,7 @@ actions.Actions(Client, { this.ribbons.setOrigin() //var n = Math.round(this.ribbons.getScreenWidthImages())-1 - var d = this.config['zoom-step'] + var d = this.config['zoom-step'] || 1.2 var s = a.ribbons.getScale() * d var n = Math.floor(this.ribbons.getScreenWidthImages(s)) @@ -978,7 +983,7 @@ actions.Actions(Client, { this.ribbons.setOrigin() //var n = Math.round(this.ribbons.getScreenWidthImages())+1 - var d = this.config['zoom-step'] + var d = this.config['zoom-step'] || 1.2 var s = a.ribbons.getScale() / d var n = Math.ceil(this.ribbons.getScreenWidthImages(s)) @@ -993,8 +998,18 @@ actions.Actions(Client, { }], // NOTE: if this gets a count argument it will fit count images, // default is one. + // NOTE: this will add .config['fit-overflow'] to odd counts if no + // overflow if passed. + // ...this is done to add ability to control scroll indication. fitImage: ['Fit image', - function(count){ + function(count, overflow){ + if(count != null){ + overflow = overflow == false ? 0 : overflow + var o = overflow != null ? overflow + : count % 2 != 1 ? 0 + : (this.config['fit-overflow'] || 0) + count += o + } this.ribbons.fitImage(count) this.ribbons.updateImage('*') }],