]> _ Git - fluidbook-html5.git/commitdiff
Add storage polyfill
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jun 2015 09:52:59 +0000 (09:52 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jun 2015 09:52:59 +0000 (09:52 +0000)
js/libs/fluidbook/fluidbook.cache.js
js/libs/fluidbook/fluidbook.l10n.js
js/libs/fluidbook/fluidbook.nav.js

index 5ef4632e831fcc5325530ebf775c93d7aad550ac..fd757ce74c9938b5db69d732f321119a2169599a 100644 (file)
@@ -1,67 +1,67 @@
 function FluidbookCache(options) {
-       this._cache = {};
-       this.options = options;
-       this._prefix = 'fluidbook.' + this.options.id + '.';
-       this._support = false;
-       this._date = this.options.cacheDate;
-       this._support = Modernizr.localstorage;
-       this.init();
+    this._cache = {};
+    this.options = options;
+    this._prefix = 'fluidbook.' + this.options.id + '.';
+    this._support = false;
+    this._date = this.options.cacheDate;
+    this._support = Modernizr.localstorage;
+    this.init();
 
 }
 
 FluidbookCache.prototype = {
-       init: function() {
-               if (this._support) {
-                       this.checkValidity();
-               }
-       },
-       clear: function() {
-               if (this._support) {
-                       for (var i = localStorage.length - 1; i >= 0; i--) {
-                               var key = localStorage.key(i);
-                               if (key.indexOf(this._prefix) == 0) {
-                                       localStorage.removeItem(key);
-                               }
-                       }
-               } else {
-                       this._cache = {};
-               }
-       },
-       isset: function(key) {
-               if (this._support) {
-                       var res = localStorage.getItem(this._prefix + key) != null;
-                       return res;
-               } else {
-                       return this._cache[key] != null;
-               }
-       },
-       get: function(key) {
-               var res;
-               if (this._support) {
-                       res = localStorage.getItem(this._prefix + key);
-               } else {
-                       res = this._cache[key];
-               }
-               var f = res.substr(0, 1);
-               if (f == '[' || f == '{') {
-                       res = json_parse(res);
-               }
-               return res;
-       },
-       set: function(key, value) {
-               if (typeof value !== "string") {
-                       value = JSON.stringify(value);
-               }
-               if (this._support) {
-                       localStorage.setItem(this._prefix + key, value);
-               } else {
-                       this._cache[key] = value;
-               }
-       },
-       checkValidity: function() {
-               if (!this.isset('validity') || this.get('validity') != this._date) {
-                       this.clear();
-                       this.set('validity', this._date);
-               }
-       }
+    init: function () {
+        if (this._support) {
+            this.checkValidity();
+        }
+    },
+    clear: function () {
+        if (this._support) {
+            for (var i = localStorage.length - 1; i >= 0; i--) {
+                var key = localStorage.key(i);
+                if (key.indexOf(this._prefix) == 0) {
+                    localStorage.removeItem(key);
+                }
+            }
+        } else {
+            this._cache = {};
+        }
+    },
+    isset: function (key) {
+        if (this._support) {
+            var res = localStorage.getItem(this._prefix + key) != null;
+            return res;
+        } else {
+            return this._cache[key] != null;
+        }
+    },
+    get: function (key) {
+        var res;
+        if (this._support) {
+            res = localStorage.getItem(this._prefix + key);
+        } else {
+            res = this._cache[key];
+        }
+        var f = res.substr(0, 1);
+        if (f == '[' || f == '{') {
+            res = json_parse(res);
+        }
+        return res;
+    },
+    set: function (key, value) {
+        if (typeof value !== "string") {
+            value = JSON.stringify(value);
+        }
+        if (this._support) {
+            localStorage.setItem(this._prefix + key, value);
+        } else {
+            this._cache[key] = value;
+        }
+    },
+    checkValidity: function () {
+        if (!this.isset('validity') || this.get('validity') != this._date) {
+            this.clear();
+            this.set('validity', this._date);
+        }
+    }
 }
\ No newline at end of file
index 2d8f998ab41348cbb9487b52a471adca58adc9e4..dd070f1b2e88305ef065935a41d0cda4a31a784d 100644 (file)
 function FluidbookL10N(fluidbook, lang) {
-       this.translations = {};
-       this.multilang = [];
-       this.multilangEnabled = false;
-       this.fluidbook = fluidbook;
+    this.translations = {};
+    this.multilang = [];
+    this.multilangEnabled = false;
+    this.fluidbook = fluidbook;
 
-       this.load(lang);
-       this.initMultilang();
+    this.load(lang);
+    this.initMultilang();
 }
 
 FluidbookL10N.prototype = {
-       load: function(lang) {
-               if (lang == undefined || lang == null || lang == '') {
-                       lang = 'default';
-               }
-               this.lang = lang;
+    load: function (lang) {
+        if (lang == undefined || lang == null || lang == '') {
+            lang = 'default';
+        }
+        this.lang = lang;
 
-               this.dir = (this.getActiveLang() == 'ar' || this.getActiveLang() == 'he') ? 'rtl' : 'ltr';
-               $('html').attr('dir', this.dir);
-               if (this.dir == 'rtl') {
-                       $('html').removeClass('ltr').addClass('rtl');
-               } else {
-                       $("html").removeClass('rtl').addClass('ltr');
-               }
+        this.dir = (this.getActiveLang() == 'ar' || this.getActiveLang() == 'he') ? 'rtl' : 'ltr';
+        $('html').attr('dir', this.dir);
+        if (this.dir == 'rtl') {
+            $('html').removeClass('ltr').addClass('rtl');
+        } else {
+            $("html").removeClass('rtl').addClass('ltr');
+        }
 
-               this.translations = this.fluidbook.datas.l10n[lang];
-               this.updateTranslations();
-       },
-       getActiveLang: function() {
-               if (this.lang != 'default') {
-                       return this.lang;
-               }
-               return this.fluidbook.datas.defaultLang;
-       },
-       initMultilang: function() {
-               var forceLocales = window.sessionStorage.getItem('locales');
-               var force = false;
-               if (forceLocales === undefined || forceLocales === null || forceLocales === 'undefined') {
-                       force = false;
-               } else {
-                       force = true;
-                       try {
-                               forceLocales = json_parse(forceLocales);
-                       } catch (err) {
-                               force = false;
-                       }
-               }
+        this.translations = this.fluidbook.datas.l10n[lang];
+        this.updateTranslations();
+    },
+    getActiveLang: function () {
+        if (this.lang != 'default') {
+            return this.lang;
+        }
+        return this.fluidbook.datas.defaultLang;
+    },
+    initMultilang: function () {
+        var forceLocales;
+        try {
+            forceLocales = window.sessionStorage.getItem('locales');
+        } catch (err) {
 
-               if (!force) {
-                       if (this.fluidbook.datas.multilang == '') {
-                               return;
-                       }
-                       if (this.fluidbook.datas.multiApp) {
-                               return;
-                       }
-               }
+        }
+        var force = false;
+        if (forceLocales === undefined || forceLocales === null || forceLocales === 'undefined') {
+            force = false;
+        } else {
+            force = true;
+            try {
+                forceLocales = json_parse(forceLocales);
+            } catch (err) {
+                force = false;
+            }
+        }
 
-               this.multilangEnabled = true;
-               var $this = this;
-               var ml = this.fluidbook.datas.multilang.replace(/\r/g, "\n").replace(/\n+/g, "\n");
+        if (!force) {
+            if (this.fluidbook.datas.multilang == '') {
+                return;
+            }
+            if (this.fluidbook.datas.multiApp) {
+                return;
+            }
+        }
 
-               var e = ml.split("\n");
-               $.each(e, function(k, v) {
-                       if (v == '') {
-                               return;
-                       }
-                       var l = v.split(',');
-                       if (l[0] == '') {
-                               return;
-                       }
+        this.multilangEnabled = true;
+        var $this = this;
+        var ml = this.fluidbook.datas.multilang.replace(/\r/g, "\n").replace(/\n+/g, "\n");
 
-                       var url = l[2];
-                       if (force) {
-                               var publications = forceLocales[l[0]];
-                               var pubid = publications[0];
+        var e = ml.split("\n");
+        $.each(e, function (k, v) {
+            if (v == '') {
+                return;
+            }
+            var l = v.split(',');
+            if (l[0] == '') {
+                return;
+            }
 
-                               try {
-                                       url = pubid;
-                               } catch (err) {
-                                       url = '';
-                               }
-                       }
+            var url = l[2];
+            if (force) {
+                var publications = forceLocales[l[0]];
+                var pubid = publications[0];
 
-                       var o = {lang: l[0], flag: l[1], url: url, langName: l[3], countryName: l[4]};
+                try {
+                    url = pubid;
+                } catch (err) {
+                    url = '';
+                }
+            }
 
-                       $this.multilang[$this.multilang.length] = o;
-               });
-       },
-       getActiveFlag: function() {
-               var active = this.getActiveLang();
-               var res = [];
-               for (var i = 0; i < this.multilang.length; i++) {
-                       var l = this.multilang[i];
-                       if (l.lang == active) {
-                               res.push(l);
-                       }
-               }
+            var o = {lang: l[0], flag: l[1], url: url, langName: l[3], countryName: l[4]};
 
-               if (res.length == 1) {
-                       return res[0].flag;
-               } else if (res.length == 0) {
-                       return false;
-               } else {
-                       if (this.fluidbook.datas.country != '') {
-                               for (var i in res) {
-                                       if (res[i].flag == this.fluidbook.datas.country) {
-                                               return res[i].flag;
-                                       }
-                               }
-                               return res[0].flag;
-                       }
-               }
-       },
-       updateTranslations: function() {
-               var $this = this;
-               $("#q").attr('placeholder', this.__('search'));
-               $("i.l10n").each(function() {
-                       var t = $this.fluidbook.l10n.__($(this).attr('str'));
-                       $(this).replaceWith(t);
-               });
-       },
-       __: function(str, markupIfNonAvailable) {
-               if (str === undefined) {
-                       return;
-               }
-               if (str.substr(0, 1) == '!') {
-                       return str.substr(1);
-               }
+            $this.multilang[$this.multilang.length] = o;
+        });
+    },
+    getActiveFlag: function () {
+        var active = this.getActiveLang();
+        var res = [];
+        for (var i = 0; i < this.multilang.length; i++) {
+            var l = this.multilang[i];
+            if (l.lang == active) {
+                res.push(l);
+            }
+        }
 
+        if (res.length == 1) {
+            return res[0].flag;
+        } else if (res.length == 0) {
+            return false;
+        } else {
+            if (this.fluidbook.datas.country != '') {
+                for (var i in res) {
+                    if (res[i].flag == this.fluidbook.datas.country) {
+                        return res[i].flag;
+                    }
+                }
+                return res[0].flag;
+            }
+        }
+    },
+    updateTranslations: function () {
+        var $this = this;
+        $("#q").attr('placeholder', this.__('search'));
+        $("i.l10n").each(function () {
+            var t = $this.fluidbook.l10n.__($(this).attr('str'));
+            $(this).replaceWith(t);
+        });
+    },
+    __: function (str, markupIfNonAvailable) {
+        if (str === undefined) {
+            return;
+        }
+        if (str.substr(0, 1) == '!') {
+            return str.substr(1);
+        }
 
-               if (this.translations[str] == undefined || this.translations[str] == null || this.translations[str] == '') {
-                       if (markupIfNonAvailable == undefined || markupIfNonAvailable) {
-                               return '~ ' + str + ' ~';
-                       } else {
-                               return str;
-                       }
-               }
-               return this.translations[str];
-       }
+
+        if (this.translations[str] == undefined || this.translations[str] == null || this.translations[str] == '') {
+            if (markupIfNonAvailable == undefined || markupIfNonAvailable) {
+                return '~ ' + str + ' ~';
+            } else {
+                return str;
+            }
+        }
+        return this.translations[str];
+    }
 };
\ No newline at end of file
index 3a51c81c9e106ac7b104d75c8ab0e11ccd0a53f6..9f4e256cf86892aff0afe138aff5b97f16c52962 100644 (file)
 function FluidbookNav(fluidbook) {
-       this.fluidbook = fluidbook;
-       this._dimensions = this.fluidbook.datas.iconsDimensions;
-       this._inited = false;
-       this.setNav();
+    this.fluidbook = fluidbook;
+    this._dimensions = this.fluidbook.datas.iconsDimensions;
+    this._inited = false;
+    this.setNav();
 
 }
 
 FluidbookNav.prototype = {
-       getIcon: function(name) {
-               var src = 'data/images/' + name + '.';
-               if (this.fluidbook.support.SVG) {
-                       src += 'svg';
-               } else {
-                       src += 'png';
-               }
-               if (this._dimensions[name] == undefined) {
-                       return '';
-               }
-               return this.fluidbook.loader.getImage(src, this._dimensions[name][0], this._dimensions[name][1]);
-       },
-       addLink: function(name, href, id, help, before, c) {
-               if ($("#nav").find('#' + id).length > 0) {
-                       return;
-               }
-               var l = this.getLink(name, href, id, help, c);
-               if (before == undefined) {
-                       $("#nav").append(l);
-               } else {
-                       $("#nav #" + before).before(l);
-               }
-       },
-       getLink: function(name, href, id, help, className, icon) {
-               if (icon == undefined) {
-                       icon = true;
-               }
-               var res = '<a href="' + href + '"';
-               if (id != undefined) {
-                       res += ' id="' + id + '"';
-               }
-               if (className != undefined) {
-                       res += ' class="' + className + '"';
-               }
-               if (help != undefined && help != '') {
-                       res += ' data-tooltip="' + this.fluidbook.l10n.__(help) + '"';
-               }
-               res += '>';
-               if (icon) {
-                       res += this.getIcon(name);
-               }
-               res += '</a>';
-               return res;
-       },
-       setNav: function() {
-               if (this._inited == true) {
-                       return;
-               }
-               this._inited = true;
-               /*
-                * __('overview')
-                * __('chapters')
-                * __('tell a friend')
-                * __('share on facebook')
-                * __('share on twitter')
-                * __('home')
-                */
-               var $this = this;
-               // index, chapters, print, friend, bookmark, pdf, archives, basket, fullscreen, sound, 3d, help
+    getIcon: function (name) {
+        var src = 'data/images/' + name + '.';
+        if (this.fluidbook.support.SVG) {
+            src += 'svg';
+        } else {
+            src += 'png';
+        }
+        if (this._dimensions[name] == undefined) {
+            return '';
+        }
+        return this.fluidbook.loader.getImage(src, this._dimensions[name][0], this._dimensions[name][1]);
+    },
+    addLink: function (name, href, id, help, before, c) {
+        if ($("#nav").find('#' + id).length > 0) {
+            return;
+        }
+        var l = this.getLink(name, href, id, help, c);
+        if (before == undefined) {
+            $("#nav").append(l);
+        } else {
+            $("#nav #" + before).before(l);
+        }
+    },
+    getLink: function (name, href, id, help, className, icon) {
+        if (icon == undefined) {
+            icon = true;
+        }
+        var res = '<a href="' + href + '"';
+        if (id != undefined) {
+            res += ' id="' + id + '"';
+        }
+        if (className != undefined) {
+            res += ' class="' + className + '"';
+        }
+        if (help != undefined && help != '') {
+            res += ' data-tooltip="' + this.fluidbook.l10n.__(help) + '"';
+        }
+        res += '>';
+        if (icon) {
+            res += this.getIcon(name);
+        }
+        res += '</a>';
+        return res;
+    },
+    setNav: function () {
+        if (this._inited == true) {
+            return;
+        }
+        this._inited = true;
+        /*
+         * __('overview')
+         * __('chapters')
+         * __('tell a friend')
+         * __('share on facebook')
+         * __('share on twitter')
+         * __('home')
+         */
+        var $this = this;
+        // index, chapters, print, friend, bookmark, pdf, archives, basket, fullscreen, sound, 3d, help
 
-               var skipHome = (window.sessionStorage.getItem('home') === '0');
-               var forceHome = (window.sessionStorage.getItem('home') === '1');
+        try {
+            var skipHome = (window.sessionStorage.getItem('home') === '0');
+            var forceHome = (window.sessionStorage.getItem('home') === '1');
 
-               if (forceHome) {
-                       if (this.fluidbook.datas.navOrder.indexOf('home') === -1) {
-                               this.fluidbook.datas.navOrder.unshift('home');
-                       }
-               }
+            if (forceHome) {
+                if (this.fluidbook.datas.navOrder.indexOf('home') === -1) {
+                    this.fluidbook.datas.navOrder.unshift('home');
+                }
+            }
+        } catch (err) {
 
-               for (var e in this.fluidbook.datas.navOrder) {
-                       var icon = this.fluidbook.datas.navOrder[e];
-                       if (icon == 'home' && !skipHome) {
+        }
 
-                               var homeURL = this.fluidbook.datas.home;
-                               if (this.fluidbook.datas.home == '%apphome%') {
-                                       homeURL = decodeURIComponent();
-                               }
-                               if (homeURL != '') {
-                                       this.addLink('nav-home', window.sessionStorage.getItem('apphome'), 'home', 'home');
-                               }
-                       } else if (icon == 'index') {
-                               this.addLink('nav-index', '#/index', 'index', 'overview');
-                       } else if (icon == 'chapters') {
-                               if (this.fluidbook.datas.displayChaptersIcon) {
-                                       if (this.fluidbook.datas.chaptersPage != '') {
-                                               this.addLink('nav-sommaire', '#/page/' + this.fluidbook.datas.chaptersPage, 'chapters', 'chapters');
-                                       } else if (this.fluidbook.datas.chapters.length > 0) {
-                                               this.addLink('nav-sommaire', '#/chapters', 'chapters', 'chapters');
-                                       }
-                               }
-                       } else if (icon == 'friend') {
-                               if (this.fluidbook.datas.share) {
-                                       this.addLink('nav-friend', '#/share', 'share', 'share');
-                                       $("#share").click(function() {
-                                               if ($this.fluidbook.datas.phonegap != 'android') {
-                                                       return true;
-                                               }
-                                               $this.fluidbook.intentShare();
-                                               return false;
-                                       });
-                               }
-                       } else if (icon == 'bookmark') {
-                               if (this.fluidbook.datas.bookmark) {
-                                       this.addLink('nav-bookmark', '#/bookmark', 'bookmarks', 'bookmarks');
-                                       $("#bookmarks").click(function() {
-                                               if (!$this.fluidbook.bookmarks.hasBookmarkedPages()) {
-                                                       var message = $this.fluidbook.l10n.__("you don't have any bookmarks");
-                                                       if ($this.fluidbook.datas.phonegap) {
-                                                               navigator.notification.alert(message, function() {
-                                                               }, $this.fluidbook.l10n.__('bookmarks'));
-                                                       } else {
-                                                               window.alert(message);
-                                                       }
-                                                       return false;
-                                               }
-                                       });
-                               }
-                       } else if (icon == 'pdf' || icon == 'print') {
-                               if ($("#print").length == 0 && (this.fluidbook.datas.print || this.fluidbook.datas.pdf)) {
-                                       this.addLink('nav-print', '#', 'print', '!' + this.fluidbook.l10n.__('print') + ' | ' + this.fluidbook.l10n.__('download pdf'));
-                                       $("#print").on('click', function() {
-                                               $this.fluidbook.print();
-                                               return false;
-                                       });
-                               }
-                       } else if (icon == 'lang') {
-                               if (this.fluidbook.l10n.multilangEnabled) {
-                                       this.addMultilangLink();
-                               }
-                       } else if (icon == 'archives') {
-                               if (this.fluidbook.datas.archivesLink != '') {
-                                       this.addLink('nav-archives', this.fluidbook.datas.archivesLink, 'archives', '!' + this.fluidbook.datas.archivesLabel);
-                               } else if (this.fluidbook.datas.externalArchives != '') {
-                                       this.addLink('nav-archives', '#/archives', 'archives', '!' + this.fluidbook.datas.archivesLabel);
-                               }
-                       } 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');
+        for (var e in this.fluidbook.datas.navOrder) {
+            var icon = this.fluidbook.datas.navOrder[e];
+            if (icon == 'home' && !skipHome) {
 
-                               $("#zoomin").click(function(e) {
-                                       $this.fluidbook.desktop.clickZoom(e, 'in');
-                                       return false;
-                               });
+                var homeURL = this.fluidbook.datas.home;
+                if (this.fluidbook.datas.home == '%apphome%') {
+                    homeURL = decodeURIComponent();
+                }
+                try {
+                    if (homeURL != '') {
+                        this.addLink('nav-home', window.sessionStorage.getItem('apphome'), 'home', 'home');
+                    }
+                } catch (err) {
 
-                               $("#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;
-                               })
-                       }
-               }
+                }
+            } else if (icon == 'index') {
+                this.addLink('nav-index', '#/index', 'index', 'overview');
+            } else if (icon == 'chapters') {
+                if (this.fluidbook.datas.displayChaptersIcon) {
+                    if (this.fluidbook.datas.chaptersPage != '') {
+                        this.addLink('nav-sommaire', '#/page/' + this.fluidbook.datas.chaptersPage, 'chapters', 'chapters');
+                    } else if (this.fluidbook.datas.chapters.length > 0) {
+                        this.addLink('nav-sommaire', '#/chapters', 'chapters', 'chapters');
+                    }
+                }
+            } else if (icon == 'friend') {
+                if (this.fluidbook.datas.share) {
+                    this.addLink('nav-friend', '#/share', 'share', 'share');
+                    $("#share").click(function () {
+                        if ($this.fluidbook.datas.phonegap != 'android') {
+                            return true;
+                        }
+                        $this.fluidbook.intentShare();
+                        return false;
+                    });
+                }
+            } else if (icon == 'bookmark') {
+                if (this.fluidbook.datas.bookmark) {
+                    this.addLink('nav-bookmark', '#/bookmark', 'bookmarks', 'bookmarks');
+                    $("#bookmarks").click(function () {
+                        if (!$this.fluidbook.bookmarks.hasBookmarkedPages()) {
+                            var message = $this.fluidbook.l10n.__("you don't have any bookmarks");
+                            if ($this.fluidbook.datas.phonegap) {
+                                navigator.notification.alert(message, function () {
+                                }, $this.fluidbook.l10n.__('bookmarks'));
+                            } else {
+                                window.alert(message);
+                            }
+                            return false;
+                        }
+                    });
+                }
+            } else if (icon == 'pdf' || icon == 'print') {
+                if ($("#print").length == 0 && (this.fluidbook.datas.print || this.fluidbook.datas.pdf)) {
+                    this.addLink('nav-print', '#', 'print', '!' + this.fluidbook.l10n.__('print') + ' | ' + this.fluidbook.l10n.__('download pdf'));
+                    $("#print").on('click', function () {
+                        $this.fluidbook.print();
+                        return false;
+                    });
+                }
+            } else if (icon == 'lang') {
+                if (this.fluidbook.l10n.multilangEnabled) {
+                    this.addMultilangLink();
+                }
+            } else if (icon == 'archives') {
+                if (this.fluidbook.datas.archivesLink != '') {
+                    this.addLink('nav-archives', this.fluidbook.datas.archivesLink, 'archives', '!' + this.fluidbook.datas.archivesLabel);
+                } else if (this.fluidbook.datas.externalArchives != '') {
+                    this.addLink('nav-archives', '#/archives', 'archives', '!' + this.fluidbook.datas.archivesLabel);
+                }
+            } 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');
 
-               if (this.fluidbook.datas.search) {
-                       this.setSearch();
-               }
-               if (this.fluidbook.datas.afterSearch != '') {
-                       this.setAfterSearch();
-               }
-               this.setInterface();
-       },
-       addMultilangLink: function(langs) {
-               var l = '<a id="localesContainer" help="!Select language" href="#/locales"><span id="locales"></span></a>';
-               var flag = this.fluidbook.l10n.getActiveFlag();
-               if (flag === false) {
-                       return;
-               }
+                $("#zoomin").click(function (e) {
+                    $this.fluidbook.desktop.clickZoom(e, 'in');
+                    return false;
+                });
 
-               $("#nav").append(l);
-               $("#nav #locales").css('background-image', 'url("images/flags/' + flag + '.png")');
-       },
-       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 += '</form>';
-               $("#search").append(res);
-               $("#submitSearch").click(function() {
-                       $("#searchForm").submit();
-                       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;
+                })
+            }
+        }
 
-               // Search form
-               $("#searchForm").submit(function() {
-                       var q = $("#q").val();
-                       if (q == '') {
-                               return false;
-                       }
-                       window.location.hash = '/search/' + q;
-                       return false;
-               });
-               $("#q").keyup(searchHints);
-               $(document).on('click', ".hint", function() {
-                       var e = $("#q").val().split(' ');
-                       e.pop();
-                       e.push($(this).attr('term'));
-                       $("#q").val(e.join(' '));
-                       $("#searchForm").submit();
-                       return false;
-               })
+        if (this.fluidbook.datas.search) {
+            this.setSearch();
+        }
+        if (this.fluidbook.datas.afterSearch != '') {
+            this.setAfterSearch();
+        }
+        this.setInterface();
+    },
+    addMultilangLink: function (langs) {
+        var l = '<a id="localesContainer" help="!Select language" href="#/locales"><span id="locales"></span></a>';
+        var flag = this.fluidbook.l10n.getActiveFlag();
+        if (flag === false) {
+            return;
+        }
 
-               $("#q").blur(function(e) {
-                       setTimeout(function() {
-                               $this.fluidbook.hideSearchHints();
-                       }, 250);
-               });
-               $("#nav").append($("#search"));
-       },
-       setAfterSearch: function() {
-               $("#nav").append('<div id="afterSearch"><div class="c">' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '</div><div class="links">' + this.fluidbook.datas.links.aftersearch + '</div></div>');
-       },
-       setInterface: function() {
+        $("#nav").append(l);
+        $("#nav #locales").css('background-image', 'url("images/flags/' + flag + '.png")');
+    },
+    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 += '</form>';
+        $("#search").append(res);
+        $("#submitSearch").click(function () {
+            $("#searchForm").submit();
+            return false;
+        })
 
-               var res = this.getLink('interface-previous', '#', 'previous', '', '', false);
-               res += this.getLink('interface-next', '#', 'next', '', '', false);
-               $('#interface').append(res);
-               $(document).on('click', '#next', goNextPage);
-               $(document).on('click', '#previous', goPreviousPage);
-       }
+        // Search form
+        $("#searchForm").submit(function () {
+            var q = $("#q").val();
+            if (q == '') {
+                return false;
+            }
+            window.location.hash = '/search/' + q;
+            return false;
+        });
+        $("#q").keyup(searchHints);
+        $(document).on('click', ".hint", function () {
+            var e = $("#q").val().split(' ');
+            e.pop();
+            e.push($(this).attr('term'));
+            $("#q").val(e.join(' '));
+            $("#searchForm").submit();
+            return false;
+        })
+
+        $("#q").blur(function (e) {
+            setTimeout(function () {
+                $this.fluidbook.hideSearchHints();
+            }, 250);
+        });
+        $("#nav").append($("#search"));
+    },
+    setAfterSearch: function () {
+        $("#nav").append('<div id="afterSearch"><div class="c">' + this.fluidbook.loader.getImage('data/images/' + this.fluidbook.datas.afterSearch) + '</div><div class="links">' + this.fluidbook.datas.links.aftersearch + '</div></div>');
+    },
+    setInterface: function () {
+
+        var res = this.getLink('interface-previous', '#', 'previous', '', '', false);
+        res += this.getLink('interface-next', '#', 'next', '', '', false);
+        $('#interface').append(res);
+        $(document).on('click', '#next', goNextPage);
+        $(document).on('click', '#previous', goPreviousPage);
+    }
 };
\ No newline at end of file