diff --git a/Viewer/cfg/requirejs.js b/Viewer/cfg/requirejs.js index 7d2d8ba4..b9859729 100644 --- a/Viewer/cfg/requirejs.js +++ b/Viewer/cfg/requirejs.js @@ -17,11 +17,10 @@ * require('./cfg/requirejs.js')(require) * * -**********************************************************************/ +**********************************************************/(function(){ var _requirejs = typeof(requirejs) != 'undefined' && requirejs - var setup = function(require){ var res = {} var requirejs = _requirejs @@ -130,6 +129,5 @@ typeof(process) == 'undefined' ? - /********************************************************************** -* vim:set ts=4 sw=4 : */ +* vim:set ts=4 sw=4 : */ })() diff --git a/Viewer/e.js b/Viewer/e.js index ca7a249c..c0d05f99 100644 --- a/Viewer/e.js +++ b/Viewer/e.js @@ -8,6 +8,18 @@ * **********************************************************************/ +// Global scope pollution test... +global.__global = {...global} +global.scopeDiff = function(cur=global, base=__global){ + return Object.keys(cur) + .filter(function(k){ return base[k] !== cur[k] }) + .reduce(function(res, k){ + res[k] = cur[k] + return res }, {})} + + +/*********************************************************************/ + //require('v8-compile-cache') var electron = require('electron') diff --git a/Viewer/ig.js b/Viewer/ig.js index 276859bc..404c07eb 100755 --- a/Viewer/ig.js +++ b/Viewer/ig.js @@ -8,6 +8,18 @@ //var DEBUG = DEBUG != null ? DEBUG : true +// Global scope pollution test... +global.__global = global.__global || {...global} +global.scopeDiff = function(cur=global, base=__global){ + return Object.keys(cur) + .filter(function(k){ return base[k] !== cur[k] }) + .reduce(function(res, k){ + res[k] = cur[k] + return res }, {})} + + +/*********************************************************************/ + require('v8-compile-cache') // NOTE: this fixes several issues with lib/util conflicting with stuff... require('repl') diff --git a/Viewer/imagegrid/ribbons.js b/Viewer/imagegrid/ribbons.js index 83ca44aa..e405f918 100755 --- a/Viewer/imagegrid/ribbons.js +++ b/Viewer/imagegrid/ribbons.js @@ -95,8 +95,7 @@ var BaseRibbonsClassPrototype = { : null return ref ? (px / ref) * 100 - : ref - }, + : ref }, px2vw: function(px){ return this.px2v(px, 'vw') }, px2vh: function(px){ return this.px2v(px, 'vh') }, px2vmin: function(px){ return this.px2v(px, 'vmin') }, @@ -120,8 +119,7 @@ var BaseRibbonsClassPrototype = { .attr('gid', JSON.stringify(gid) // this removes the extra quots... - .replace(/^"(.*)"$/g, '$1')) - }, + .replace(/^"(.*)"$/g, '$1')) }, } var BaseRibbonsPrototype = { @@ -134,8 +132,7 @@ var BaseRibbonsPrototype = { __init__: function(viewer, images){ this.viewer = $(viewer) - this.images = images - }, + this.images = images }, // utils... px2v: BaseRibbonsClassPrototype.px2v, @@ -154,8 +151,7 @@ var BaseRibbonsPrototype = { // NOTE: this will reset locally referenced .images to .parent.images set parent(parent){ this.__parent = parent - delete this.__images - }, + delete this.__images }, // maintain images in .parent.images if available... // @@ -167,11 +163,8 @@ var BaseRibbonsPrototype = { if(this.parent){ this.parent.images = images delete this.__images - } else { - this.__images = images - } - }, + this.__images = images } }, // Helpers... @@ -193,8 +186,7 @@ var BaseRibbonsPrototype = { target = target || this.viewer //prevent_nested = prevent_nested || false if(target.length == 0){ - return this - } + return this } var t = target[0] // handle nesting... @@ -214,8 +206,7 @@ var BaseRibbonsPrototype = { s.oTransition s.transition - return this - }, + return this }, // Restore CSS transitions... // @@ -250,11 +241,9 @@ var BaseRibbonsPrototype = { now = target target = this.viewer } else { - target = target || this.viewer - } + target = target || this.viewer } if(target.length == 0){ - return this - } + return this } var t = target[0] // sync... @@ -263,8 +252,7 @@ var BaseRibbonsPrototype = { var l = t.getAttribute('__prevent_transitions') if(l != null && !force && l != '0'){ t.setAttribute('__prevent_transitions', parseInt(l)-1) - return this - } + return this } t.removeAttribute('__prevent_transitions') target.removeClass('no-transitions') @@ -284,8 +272,7 @@ var BaseRibbonsPrototype = { var l = t.getAttribute('__prevent_transitions') if(l != null && !force && l != '0'){ t.setAttribute('__prevent_transitions', l-1) - return this - } + return this } t.removeAttribute('__prevent_transitions') target.removeClass('no-transitions') @@ -296,11 +283,9 @@ var BaseRibbonsPrototype = { s.msTransition s.oTransition s.transition - }, 0) - } + }, 0) } - return this - }, + return this }, // Shorthand wrappers of the above... // @@ -309,14 +294,12 @@ var BaseRibbonsPrototype = { this.preventTransitions() func.apply(this, [...arguments].slice(1)) this.restoreTransitions(true) - return this - }, + return this }, noTransitionsDeep: function(func){ this.preventTransitions(null, true) func.apply(this, [...arguments].slice(1)) this.restoreTransitions(true) - return this - }, + return this }, // Scale... @@ -335,20 +318,17 @@ var BaseRibbonsPrototype = { scale: function(scale){ // get... if(arguments.length == 0){ - return this.getRibbonSet().scale() || 1 - } + return this.getRibbonSet().scale() || 1 } // set... var ribbon_set = this.getRibbonSet() if(ribbon_set.length == 0){ - return this - } + return this } ribbon_set.scale(scale) - return this - }, + return this }, // Get visible image tile size... // @@ -392,8 +372,7 @@ var BaseRibbonsPrototype = { top: '-200%', left: '-200%', }) - .appendTo(this.viewer) - } + .appendTo(this.viewer) } // account for image rotation... // NOTE: this way we do not need to account for margins... @@ -425,11 +404,9 @@ var BaseRibbonsPrototype = { // remove the tmp image we created... if(tmp != null){ - tmp.remove() - } + tmp.remove() } - return res - }, + return res }, getScreenWidthImages: function(scale, min){ scale = scale || this.scale() @@ -437,8 +414,7 @@ var BaseRibbonsPrototype = { var W = this.viewer.width() var w = this.getVisibleImageSize(min ? 'min' : 'width', scale) - return W/w - }, + return W/w }, // XXX this does not account for ribbon spacing... getScreenHeightRibbons: function(scale){ scale = scale || this.scale() @@ -446,8 +422,7 @@ var BaseRibbonsPrototype = { var H = this.viewer.height() var h = this.getVisibleImageSize('height', scale) - return H/h - }, + return H/h }, // Fit image to view... // @@ -469,16 +444,14 @@ var BaseRibbonsPrototype = { // n images will be higher than the viewer, adjust for height... if(h*scale >= H){ - scale = H/h - } + scale = H/h } this .scale(scale) //.centerRibbon(null, null, scale) //.centerImage(null, null, null, scale) - return this - }, + return this }, // NOTE: if fit_whole_images is true (default) this will fit a discrete // number of images in width... // XXX this does not account for ribbon spacing... @@ -493,8 +466,7 @@ var BaseRibbonsPrototype = { // n ribbons will be wider than the viewer... if(w*scale >= W){ - scale = W/w - } + scale = W/w } // shift the scale to the point where screen width is a whole // number of images... @@ -502,13 +474,11 @@ var BaseRibbonsPrototype = { var d = this.getScreenWidthImages(scale) d = d / Math.ceil(d) - scale *= d - } + scale *= d } this.scale(scale) - return this - }, + return this }, // Contextual getters... @@ -530,23 +500,19 @@ var BaseRibbonsPrototype = { if(create && ribbon_set.length == 0){ ribbon_set = $('
') .addClass('ribbon-set') - .appendTo(this.viewer) - } + .appendTo(this.viewer) } // ribbon locator... var locator = ribbon_set.find('.ribbon-locator') if(create && locator.length == 0){ ribbon_set .append($('') - .addClass('ribbon-locator')) - } + .addClass('ribbon-locator')) } - return ribbon_set - }, + return ribbon_set }, getRibbonLocator: function(create){ return this.getRibbonSet(create) - .find('.ribbon-locator') - }, + .find('.ribbon-locator') }, // Get image... // @@ -585,8 +551,7 @@ var BaseRibbonsPrototype = { || target == 'prev' || typeof(target) == typeof(123)){ offset = target - target = 'current' - } + target = 'current' } // get the base image... // current... @@ -596,13 +561,11 @@ var BaseRibbonsPrototype = { // gid... } else if(typeof(target) == typeof('str')){ //return this.viewer.find('.image[gid="'+JSON.stringify(target)+'"]') - img = this.viewer.find(IMAGE+'[gid='+JSON.stringify(target)+']') - } + img = this.viewer.find(IMAGE+'[gid='+JSON.stringify(target)+']') } // we got a collection... if(img == null){ - return $(target).filter(IMAGE) - } + return $(target).filter(IMAGE) } // get the offset... if(offset != null && offset != 0){ @@ -615,11 +578,9 @@ var BaseRibbonsPrototype = { var res = img[list](IMAGE) // handle overflow... res = res.eq(Math.min(offset, res.length-1)) - img = res.length == 0 ? img : res - } + img = res.length == 0 ? img : res } - return img - }, + return img }, // Get images... // @@ -662,16 +623,14 @@ var BaseRibbonsPrototype = { // XXX should this be here or in a marks plugin... getImageMarks: function(img, cls){ img = img || this.getImage() - gid = typeof(img) == typeof('str') ? img : null + var gid = typeof(img) == typeof('str') ? img : null gid = gid == null ? this.elemGID(img) : gid var marks = this.viewer.find('.mark[gid='+JSON.stringify(gid)+']') if(cls != null){ - return marks.filter('.'+cls) - } - return marks - }, + return marks.filter('.'+cls) } + return marks }, // Get an image at a relative to viewer position... // @@ -726,8 +685,7 @@ var BaseRibbonsPrototype = { } else if(typeof(target) != typeof(123)){ target = $(target) if(target.length == 0){ - return $() - } + return $() } var w = target.hasClass('image') ? this.getVisibleImageSize('width', null, target) : target.outerWidth() @@ -735,8 +693,7 @@ var BaseRibbonsPrototype = { // position is either 'current', 'center' or a jQuery // object... delta = delta || w / 10 - target = target.offset().left + w/2 - } + target = target.offset().left + w/2 } var that = this var res = ribbon.find(IMAGE) @@ -753,8 +710,7 @@ var BaseRibbonsPrototype = { // of images at large magnifications when nothing // other than the current image fully fit... if(L > l+w || l > L+W){ - return - } + return } // distance between centers... if(position == 'center' || position == 'current'){ @@ -766,13 +722,13 @@ var BaseRibbonsPrototype = { // distance between right edges... } else { - return [target - (l + w), img] - } - }) + return [target - (l + w), img] } }) // drop images outside the viewer... - .filter(function(e){ return e != null }) + .filter(function(e){ + return e != null }) // sort images by distance... - .sort(function(a, b){ return Math.abs(a[0]) - Math.abs(b[0]) }) + .sort(function(a, b){ + return Math.abs(a[0]) - Math.abs(b[0]) }) var a = res[0] ? res[0][0] : null var b = res[1] ? res[1][0] : null @@ -789,9 +745,7 @@ var BaseRibbonsPrototype = { // a single hit... } else { // NOTE: if no image is on screen this will get nothing... - return res[0] ? res[0][1] : null - } - }, + return res[0] ? res[0][1] : null } }, // Get ribbon... // @@ -838,8 +792,7 @@ var BaseRibbonsPrototype = { } else if(target == 'base'){ var r = this.viewer.find('.base.ribbon').first() if(r.length == 0){ - return this.viewer.find(RIBBON).first() - } + return this.viewer.find(RIBBON).first() } return r // index... @@ -855,8 +808,7 @@ var BaseRibbonsPrototype = { ? this.getImage(target).parents('.ribbon').first() : r } - return $(target).filter(RIBBON) - }, + return $(target).filter(RIBBON) }, // Like .getRibbon(..) but returns ribbon index instead of the actual // ribbon object... getRibbonOrder: function(target){ @@ -918,7 +870,9 @@ var BaseRibbonsPrototype = { return { width: dfl_h ? '' : (this.px2vmin(h) + 'vmin'), height: dfl_w ? '' : (this.px2vmin(w) + 'vmin'), - margin: this.px2vmin(-((w - h)/2)) +'vmin '+ this.px2vmin((w - h)/2) + 'vmin', + margin: + this.px2vmin(-((w - h)/2)) +'vmin ' + + this.px2vmin((w - h)/2) + 'vmin', } } else if((o == 0 || o == 180) && image_p != viewer_p){ @@ -926,8 +880,7 @@ var BaseRibbonsPrototype = { width: dfl_h ? '' : (this.px2vmin(h) + 'vmin'), height: dfl_w ? '' : (this.px2vmin(w) + 'vmin'), margin: '', - } - } + } } // square image... } else { @@ -935,9 +888,7 @@ var BaseRibbonsPrototype = { width: '', height: '', margin: '', - } - } - }, + } } }, correctImageProportionsForRotation: function(images, W, H){ var that = this W = W || this.viewer.innerWidth() @@ -949,9 +900,7 @@ var BaseRibbonsPrototype = { var data = that._calcImageProportions(this, W, H) data - && $(this).css(data) - }) - }, + && $(this).css(data) }) }, // center a ribbon vertically... // @@ -969,8 +918,7 @@ var BaseRibbonsPrototype = { var locator = this.getRibbonLocator() if(locator.length == 0 || ribbon.length == 0){ - return this - } + return this } // NOTE: we need to use the same unit here as is used to size // the image blocks... @@ -981,8 +929,7 @@ var BaseRibbonsPrototype = { locator.transform({ x: 0, y: this.px2v(-(t + h/2), unit) + unit, z: 0 }) - return this - }, + return this }, // center an image horizontally... // @@ -1005,8 +952,7 @@ var BaseRibbonsPrototype = { var ribbon = this.getRibbon(target) if(ribbon.length == 0){ - return this - } + return this } var l = target[0].offsetLeft var w = target[0].offsetWidth @@ -1017,9 +963,7 @@ var BaseRibbonsPrototype = { ribbon.transform({x: -this.px2vmin(l + image_offset) + 'vmin', y: 0, z: 0}) - return this - }, - + return this }, } var BaseRibbons = @@ -1056,8 +1000,7 @@ var RibbonsClassPrototype = { // .addClass('ribbon-container') // .append(that.elemGID($('