From: Vincent Vanwaelscappel Date: Tue, 3 Sep 2013 16:41:30 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a501e553ccab6a6c517d6183ff18fcfeb0d02c7c;p=fluidbook-html5.git --- diff --git a/js/libs/fluidbook/fluidbook.desktop.js b/js/libs/fluidbook/fluidbook.desktop.js index 6ba6aaf3..986387fb 100644 --- a/js/libs/fluidbook/fluidbook.desktop.js +++ b/js/libs/fluidbook/fluidbook.desktop.js @@ -38,11 +38,18 @@ FluidbookDesktop.prototype = { }) } }, - 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); diff --git a/js/libs/fluidbook/fluidbook.nav.js b/js/libs/fluidbook/fluidbook.nav.js index e61180ef..156633dd 100644 --- a/js/libs/fluidbook/fluidbook.nav.js +++ b/js/libs/fluidbook/fluidbook.nav.js @@ -1,7 +1,6 @@ function FluidbookNav(fluidbook) { this.fluidbook = fluidbook; this._dimensions = this.fluidbook.datas.iconsDimensions; - this.setNav(); } @@ -122,6 +121,25 @@ FluidbookNav.prototype = { } } 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; + }) } } @@ -135,7 +153,6 @@ FluidbookNav.prototype = { }, addMultilangLink: function(langs) { var l = ''; - var flag = this.fluidbook.l10n.getActiveFlag(); if (flag === false) { return; @@ -146,15 +163,12 @@ FluidbookNav.prototype = { }, setSearch: function() { var $this = this; - var res = '
'; res += ''; res += this.getLink('interface-search', '#', 'submitSearch'); res += '
'; res += '
'; - $("#search").append(res); - $("#submitSearch").click(function() { $("#searchForm").submit(); return false; @@ -169,9 +183,7 @@ FluidbookNav.prototype = { window.location.hash = '/search/' + q; return false; }); - $("#q").keyup(searchHints); - $(document).on('click', ".hint", function() { var e = $("#q").val().split(' '); e.pop(); @@ -186,7 +198,6 @@ FluidbookNav.prototype = { $this.fluidbook.hideSearchHints(); }, 250); }); - $("#nav").append($("#search")); }, setAfterSearch: function() { @@ -196,9 +207,7 @@ FluidbookNav.prototype = { 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); } diff --git a/js/libs/modernizr/tests.js b/js/libs/modernizr/tests.js index b4bf8894..eda053c4 100644 --- a/js/libs/modernizr/tests.js +++ b/js/libs/modernizr/tests.js @@ -17,16 +17,24 @@ Modernizr.addTest('csstransformspreserve3d', function() { }); 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 diff --git a/js/libs/screenfull.js b/js/libs/screenfull.js new file mode 100644 index 00000000..f8b2c492 --- /dev/null +++ b/js/libs/screenfull.js @@ -0,0 +1,128 @@ +/*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);