})
}
},
- clickZoom: function(e) {
+ clickZoom: function(e, way) {
+ if (way == undefined) {
+ if (this.desktopScale == 1) {
+ way = 'in';
+ } else {
+ way = 'out';
+ }
+ }
var newScale;
- if (this.desktopScale == 1) {
+ if (way == 'in') {
newScale = (this.fluidbook.datas.zoom / 100) / this.fluidbook.resize.bookScale;
- } else {
+ } else if (way == 'out') {
newScale = 1;
}
this.updateDesktopScale(newScale);
function FluidbookNav(fluidbook) {
this.fluidbook = fluidbook;
this._dimensions = this.fluidbook.datas.iconsDimensions;
-
this.setNav();
}
}
} else if (icon == 'help') {
this.addLink('nav-help', '#', 'help', '');
+ } else if (icon == 'zoom' && !this.fluidbook.support.isMobile) {
+ this.addLink('nav-zoomin', '#', 'zoomin', 'zoom in');
+ this.addLink('nav-zoomout', '#', 'zoomout', 'zoom out');
+
+ $("#zoomin").click(function(e) {
+ $this.fluidbook.desktop.clickZoom(e, 'in');
+ return false;
+ });
+
+ $("#zoomout").click(function() {
+ $this.fluidbook.desktop.clickZoom(e, 'out');
+ return false;
+ });
+ } else if (icon == 'fullscreen' && Modernizr.fullscreen) {
+ this.addLink('nav-fullscreen', '#', 'fullscreen', 'switch between fullscreen and normal');
+ $("#fullscreen").click(function() {
+ screenfull.toggle();
+ return false;
+ })
}
}
},
addMultilangLink: function(langs) {
var l = '<a id="locales" help="!Select language" href="#/locales"></a>';
-
var flag = this.fluidbook.l10n.getActiveFlag();
if (flag === false) {
return;
},
setSearch: function() {
var $this = this;
-
var res = '<form action="#" id="searchForm" method="post">';
res += '<input type="text" id="q" name="q" type="search" value="" placeholder="' + this.fluidbook.l10n.__('search') + '" autocorrect="off" autocomplete="off" autocapitalize="off" />';
res += this.getLink('interface-search', '#', 'submitSearch');
res += '<div id="searchHints"></div>';
res += '</form>';
-
$("#search").append(res);
-
$("#submitSearch").click(function() {
$("#searchForm").submit();
return false;
window.location.hash = '/search/' + q;
return false;
});
-
$("#q").keyup(searchHints);
-
$(document).on('click', ".hint", function() {
var e = $("#q").val().split(' ');
e.pop();
$this.fluidbook.hideSearchHints();
}, 250);
});
-
$("#nav").append($("#search"));
},
setAfterSearch: function() {
var res = this.getLink('interface-previous', '#', 'previous', '', 'hidden');
res += this.getLink('interface-next', '#', 'next');
-
$('#interface').append(res);
-
$(document).on('click', '#next', goNextPage);
$(document).on('click', '#previous', goPreviousPage);
}
});
Modernizr.addTest('ftouch', function() {
- var bool;
+ var bool;
- if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || ('onmsgesturechange' in window)) {
- bool = true;
- } else {
- var query = ['@media (',Modernizr._prefixes.join('touch-enabled),('),'heartz',')','{#modernizr{top:9px;position:absolute}}'].join('');
- Modernizr.testStyles(query, function( node ) {
- bool = node.offsetTop === 9;
- });
- }
+ if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch || ('onmsgesturechange' in window)) {
+ bool = true;
+ } else {
+ var query = ['@media (', Modernizr._prefixes.join('touch-enabled),('), 'heartz', ')', '{#modernizr{top:9px;position:absolute}}'].join('');
+ Modernizr.testStyles(query, function(node) {
+ bool = node.offsetTop === 9;
+ });
+ }
+
+ return bool;
+});
- return bool;
+Modernizr.addTest('fullscreen',function(){
+ for(var i = 0; i < Modernizr._domPrefixes.length; i++) {
+ if( document[Modernizr._domPrefixes[i].toLowerCase() + 'CancelFullScreen'])
+ return true;
+ }
+ return !!document['cancelFullScreen'] || false;
});
\ No newline at end of file
--- /dev/null
+/*global Element */
+(function (window, document) {
+ 'use strict';
+
+ var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element, // IE6 throws without typeof check
+
+ fn = (function () {
+ var val, valLength;
+ var fnMap = [
+ [
+ 'requestFullscreen',
+ 'exitFullscreen',
+ 'fullscreenElement',
+ 'fullscreenEnabled',
+ 'fullscreenchange',
+ 'fullscreenerror'
+ ],
+ // new WebKit
+ [
+ 'webkitRequestFullscreen',
+ 'webkitExitFullscreen',
+ 'webkitFullscreenElement',
+ 'webkitFullscreenEnabled',
+ 'webkitfullscreenchange',
+ 'webkitfullscreenerror'
+
+ ],
+ // old WebKit (Safari 5.1)
+ [
+ 'webkitRequestFullScreen',
+ 'webkitCancelFullScreen',
+ 'webkitCurrentFullScreenElement',
+ 'webkitCancelFullScreen',
+ 'webkitfullscreenchange',
+ 'webkitfullscreenerror'
+
+ ],
+ [
+ 'mozRequestFullScreen',
+ 'mozCancelFullScreen',
+ 'mozFullScreenElement',
+ 'mozFullScreenEnabled',
+ 'mozfullscreenchange',
+ 'mozfullscreenerror'
+ ]
+ ];
+ var i = 0;
+ var l = fnMap.length;
+ var ret = {};
+
+ for (; i < l; i++) {
+ val = fnMap[i];
+ if (val && val[1] in document) {
+ for (i = 0, valLength = val.length; i < valLength; i++) {
+ ret[fnMap[0][i]] = val[i];
+ }
+ return ret;
+ }
+ }
+ return false;
+ })(),
+
+ screenfull = {
+ request: function (elem) {
+ var request = fn.requestFullscreen;
+
+ elem = elem || document.documentElement;
+
+ // Work around Safari 5.1 bug: reports support for
+ // keyboard in fullscreen even though it doesn't.
+ // Browser sniffing, since the alternative with
+ // setTimeout is even worse.
+ if (/5\.1[\.\d]* Safari/.test(navigator.userAgent)) {
+ elem[request]();
+ } else {
+ elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
+ }
+ },
+ exit: function () {
+ document[fn.exitFullscreen]();
+ },
+ toggle: function (elem) {
+ if (this.isFullscreen) {
+ this.exit();
+ } else {
+ this.request(elem);
+ }
+ },
+ onchange: function () {},
+ onerror: function () {},
+ raw: fn
+ };
+
+ if (!fn) {
+ return window.screenfull = false;
+ }
+
+ Object.defineProperties(screenfull, {
+ isFullscreen: {
+ get: function () {
+ return !!document[fn.fullscreenElement];
+ }
+ },
+ element: {
+ enumerable: true,
+ get: function () {
+ return document[fn.fullscreenElement];
+ }
+ },
+ enabled: {
+ enumerable: true,
+ get: function () {
+ // Coerce to boolean in case of old WebKit
+ return !!document[fn.fullscreenEnabled];
+ }
+ }
+ });
+
+ document.addEventListener(fn.fullscreenchange, function (e) {
+ screenfull.onchange.call(screenfull, e);
+ });
+
+ document.addEventListener(fn.fullscreenerror, function (e) {
+ screenfull.onerror.call(screenfull, e);
+ });
+
+ window.screenfull = screenfull;
+})(window, document);