// Note: iOS won't catch click events unless the element has a cursor:pointer style
// This was added for #viewOverlay in the CSS
// More details: https://stackoverflow.com/a/16006333
- $(document).on('click', ".mview .back, #viewOverlay", function () {
+ $(document).on('click', ".mview .button.back, #viewOverlay", function (e) {
+ e.stopImmediatePropagation();
+ e.stopPropagation();
+ e.preventDefault();
$this.closeView(function () {
- }, true);
+ }, false);
return false;
});
},
_openView: function (view, param1, param2, callback) {
- console.log(view, param1, param2);
var $this = this;
var preload = {
index: 'thumbnails',
}, 420);
},
- viewWrap: function (content, menu, attributes, cls, replace) {
+ viewWrap: function (content, menu, attributes, cls, replace, hash) {
if (attributes === undefined) {
attributes = '';
}
if (cls === undefined) {
cls = '';
}
- var res = '<div class="mview ' + cls + '" data-menu="' + menu + '" role="dialog" aria-labelledby="mview-dialog-title"' + attributes + '>' + content + '</div>';
+ if (hash !== undefined) {
+ hash = ' data-hash="' + hash + '"';
+ } else {
+ hash = '';
+ }
+ var res = '<div class="mview ' + cls + '"' + hash + ' data-menu="' + menu + '" role="dialog" aria-labelledby="mview-dialog-title"' + attributes + '>' + content + '</div>';
if (replace === true) {
$("#view").html(res);
} else {
},
openMultimedia: function (multimedia, callback) {
- var a = $('a[href="#/multimedia/' + multimedia + '"]');
+ var hash = '#/multimedia/' + multimedia;
+ var a = $('a[href="' + hash + '"]');
var markup = decodeURIComponent($(a).attr('data-multimedia'));
var view = this.getCaption('', $(a).attr('data-popup-close') === null || $(a).attr('data-popup-close') === undefined || $(a).attr('data-popup-close') === '1');
var links = '';
var read = multimedia.indexOf('r_') == 0 ? ' data-readmode="1"' : '';
read += ' dir="ltr"';
- this.viewWrap(view, 'multimedia', read);
+ this.viewWrap(view, 'multimedia', read, '', false, hash);
if (animateLinks) {
this.fluidbook.links.doAnimateLinks($("#view"), 500);
this._openiframe(markup, '', callback);
},
- _openiframe: function (markup, maxWidth, callback) {
+ _openiframe: function (markup, maxWidth, callback,hash) {
var $this = this;
view += markup;
view += '</div></div>';
- this.viewWrap(view, 'iframe', maxWidth + ' dir="ltr"');
+ this.viewWrap(view, 'iframe', maxWidth + ' dir="ltr"','',false,hash);
if (callback != undefined) {
callback();
}
},
openIframe: function (iframe, callback) {
- var href = '#/iframe/' + iframe;
+ var hash='#/iframe/' + iframe;
+ var href = hash;
var a = $('a[href="' + href + '"]');
if ($(a).length === 0) {
a = this.fluidbook.links.getLinkByHref(href);
if ($(a).data('max-width')) {
maxWidth = ' data-max-width="' + $(a).data('max-width') + '"';
}
- this._openiframe(markup, maxWidth, callback);
+ this._openiframe(markup, maxWidth, callback,hash);
},
openVideo: function (video, callback) {
- var a = $('a[href="#/video/' + video + '"]');
+ var hash = '#/video/' + video;
+ var a = $('a[href="' + hash + '"]');
var markup = decodeURIComponent($(a).attr('data-video'));
var view = this.getCaption();
view += '<div class="content">';
view += markup;
view += '</div>';
- this.viewWrap(view, 'video');
+ this.viewWrap(view, 'video', '', '', false, hash);
this.fluidbook.stats.track(11);
this.fluidbook.initVideos();
},
openSlideshow: function (slideshow, callback) {
- var a = $('a[href="#/slideshow/' + slideshow + '"]');
+ var hash = '#/slideshow/' + slideshow;
+ var a = $('a[href="' + hash + '"]');
var markup = decodeURIComponent($(a).attr('data-slideshow'));
var view = this.getCaption();
view += '<div class="content">';
view += markup;
view += '</div>';
- this.viewWrap(view, 'slideshow');
+ this.viewWrap(view, 'slideshow', '', '', false, hash);
// TODO: check which type should be passed to fluidbook.stats.track() ???
// this.fluidbook.stats.track(11);
return '<a href="#/closeview" role="button" aria-label="' + this.fluidbook.l10n.__('close') + '" aria-keyshortcuts="Escape" class="button back' + c + '">' + getSpriteIcon('interface-close') + '</a>';
},
openAudio: function (audio, callback) {
- var a = $('a[href="#/audio/' + audio + '"]');
+ var hash = '#/audio/' + audio;
+ var a = $('a[href="' + hash + '"]');
var markup = decodeURIComponent($(a).attr('data-audio'));
var view = this.getCaption();
view += '<div class="content">';
view += markup;
view += '</div>';
- this.viewWrap(view, 'audio');
+ this.viewWrap(view, 'audio', '', '', false, hash);
this.fluidbook.stats.track(11);
var $this = this;
var times = [250, 500, 750, 1000, 1250];
}
},
openWebVideo: function (service, video, callback) {
- var a = $('a[href="#/webvideo/' + service + '/' + video + '"]');
+ var hash = '#/webvideo/' + service + '/' + video;
+ var a = $('a[href="' + hash + '"]');
var markup = decodeURIComponent($(a).attr('data-video'));
var view = this.getCaption();
view += '<div class="content noscroll">';
view += markup;
view += '</div>';
- this.viewWrap(view, 'webvideo');
+ this.viewWrap(view, 'webvideo', '', '', false, hash);
this.fluidbook.initVideos();
this.fluidbook.stats.track(11);
});
view += '</ul>';
view += '</div>';
- this.viewWrap(view, 'locales');
+ this.viewWrap(view, 'locales',[],'',false,'#/locales');
if (callback != undefined) {
callback();
}
callback = function () {
};
}
-
- var currentHash = window.location.hash;
- window.location.hash = '/page/' + this.fluidbook.currentPage;
- if (window.location.hash == currentHash) {
+ if (all || $("#view .mview").length <= 1) {
+ var currentHash = window.location.hash;
+ window.location.hash = '#/page/' + this.fluidbook.currentPage;
+ if (window.location.hash == currentHash) {
+ this._closeView(callback, true, animate);
+ }
+ } else {
this._closeView(callback, all, animate);
}
},
_closeView: function (callback, all, animate) {
- this.hideOverlay();
var $this = this;
if (all == undefined) {
all = false;
all = all || ($("#view .mview").length <= 1);
if (!this.viewMode()) {
+ this.hideOverlay();
callback();
return;
}
}
if (all) {
+ this.hideOverlay();
$("#view").attr('aria-hidden', 'true');
$("#main").attr('aria-hidden', 'false').show();
$('body').removeClass('view');
+ } else {
+ window.location.hash = $("#view .mview").eq(-2).data('hash');
}
resize();
},
if (hh == undefined) {
hh = this.fluidbook.resize.hh;
}
- var m = $(".mview");
+
+ $("#viewOverlay").css({width: ww, height: hh});
+
+ var $this = this;
+ $('.mview').each(function () {
+ $this.resizeView($(this), ww, hh);
+ })
+ },
+
+ resizeView: function (m, ww, hh) {
var w = ww * 0.6;
var h = hh * 0.8;
+ var s = 1;
var forceHeight = false;
var contentHeight = null;
var fullscreen = m.data('fullscreen') === '1';
var nw, nh;
- $("#viewOverlay").css({width: ww, height: hh});
-
var maxWidth = 100000;
if (m.data('max-width')) {
maxWidth = m.data('max-width');
this.fluidbook.settings.chaptersColumns = 1;
}
- var w;
if (this.fluidbook.settings.chaptersColumns > 1) {
w = this.fluidbook.settings.chaptersColMaxWidth * this.fluidbook.settings.chaptersColumns;
} else {
if (this.fluidbook.settings.chaptersColumns > 1) {
if (w < this.fluidbook.settings.chaptersColMaxWidth * this.fluidbook.settings.chaptersColumns) {
- $('.mview[data-menu=chapters] ul.chapters').addClass('onecolumn');
+ $(m).find('ul.chapters').addClass('onecolumn');
} else {
- $('.mview[data-menu=chapters] ul.chapters').removeClass('onecolumn');
+ $(m).find('ul.chapters').removeClass('onecolumn');
}
}
var rw = parseInt($("#grandvision-cart").css('width'));
var rh = parseInt($("#grandvision-cart").css('height'));
if (ww < rw || hh < rh) {
- var s = Math.min(ww / rw, h / rh);
+ s = Math.min(ww / rw, h / rh);
} else {
s = 1;
}
}
break;
case 'webvideo':
- var w = Math.max(ww * 0.8, 600);
+ w = Math.max(ww * 0.8, 600);
h = (w / 16) * 9;
if (h > hh * 0.9) {
h = hh * 0.9;
forceHeight = true;
- var w = Math.max(ww * 0.8);
- var h = Math.max(hh * 0.8);
+ w = Math.max(ww * 0.8);
+ h = Math.max(hh * 0.8);
if (ww < 600) {
w = ww;
h = hh;
fullscreen = true;
}
- var s = Math.min(w / nw, h / nh, maxVideoScale); // Make sure scale doesn't go above maxVideoScale...
+ s = Math.min(w / nw, h / nh, maxVideoScale); // Make sure scale doesn't go above maxVideoScale...
if (!fullscreen) {
w = nw * s;
nw = parseInt($(iframe).data('width'));
nh = parseInt($(iframe).data('height'));
- var w = Math.max(ww * 0.8);
- var h = Math.max(hh * 0.8);
+ w = Math.max(ww * 0.8);
+ h = Math.max(hh * 0.8);
if (ww < 600) {
w = ww;
h = hh;
fullscreen = true;
}
- var s, x, y;
+ var x, y;
if (readmode) {
w = nw;
forceHeight = false;
var d = this.fluidbook.links_zoomhd.getContainerDimensions();
w = d.width;
h = d.height;
- console.log(d);
}
break;
case 'archives':
w = Math.min(maxWidth, w);
css = {};
- ccss = {};
+ var ccss = {};
if (fullscreen) {
w = ww;
h = hh;