From 2282a0ba7110107094699976feaf980ed17125a0 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sat, 14 Jul 2012 19:45:30 +0200 Subject: [PATCH] Fixes problems with misalgined image previews. --- src/_h5ai/js/inc/ext/preview-img.js | 10 ++++++++-- src/_h5ai/js/inc/model/entry.js | 20 ++++---------------- src/_h5ai/js/inc/parser/generic-json.js | 8 ++++---- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/_h5ai/js/inc/ext/preview-img.js b/src/_h5ai/js/inc/ext/preview-img.js index 628c676f..7bd43375 100644 --- a/src/_h5ai/js/inc/ext/preview-img.js +++ b/src/_h5ai/js/inc/ext/preview-img.js @@ -129,9 +129,15 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource', clearTimeout(spinnerTimeout); $container.spin(false); - $img.attr('src', src).show(); + // $img.hide().attr('src', src).fadeIn(100); + $img.fadeOut(100, function () { - adjustSize(); + $img.attr('src', src).fadeIn(200); + setTimeout(adjustSize, 1); + }); + + // adjustSize(); + // setTimeout(adjustSize, 1); $('#preview-bar-label').text(currentEntries[currentIdx].label); $('#preview-bar-percent').text('' + (100 * $img.width() / width).toFixed(0) + '%'); diff --git a/src/_h5ai/js/inc/model/entry.js b/src/_h5ai/js/inc/model/entry.js index 45699801..85d080c8 100644 --- a/src/_h5ai/js/inc/model/entry.js +++ b/src/_h5ai/js/inc/model/entry.js @@ -31,27 +31,15 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty sequence = sequence.replace(/\/+/g, '/'); if (sequence === '/') { - return { - parent: null, - parentname: null, - name: '/' - }; + return { parent: null, name: '/' }; } match = reSplitPath2.exec(sequence); if (match) { - return { - parent: match[1], - parentname: match[2], - name: match[3] - }; + return { parent: match[1], name: match[3] }; } match = reSplitPath.exec(sequence); if (match) { - return { - parent: '/', - parentname: '/', - name: match[1] - }; + return { parent: '/', name: match[1] }; } }, @@ -127,7 +115,7 @@ modulejs.define('model/entry', ['_', 'core/types', 'core/ajax'], function (_, ty return modulejs.require('ext/folderstatus'); } catch (e) {} - return []; + return {}; }()), fetchStatus = function (absHref, callback) { diff --git a/src/_h5ai/js/inc/parser/generic-json.js b/src/_h5ai/js/inc/parser/generic-json.js index 64a742be..eece589a 100644 --- a/src/_h5ai/js/inc/parser/generic-json.js +++ b/src/_h5ai/js/inc/parser/generic-json.js @@ -12,16 +12,16 @@ modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry' parseJson = function (absHref, json) { - if (json.hasOwnProperty('customHeader')) { + if (_.has(json, 'customHeader')) { settings.custom.header = json.customHeader; } - if (json.hasOwnProperty('customFooter')) { + if (_.has(json, 'customFooter')) { settings.custom.footer = json.customFooter; } - if (json.hasOwnProperty('mode')) { + if (_.has(json, 'mode')) { parser.mode = json.mode; } - if (json.hasOwnProperty('server')) { + if (_.has(json, 'server')) { parser.server = json.server; }