]> _ Git - fluidbook-html5.git/commitdiff
Merge branch 'master' into burgermenu
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 19 Sep 2017 12:54:32 +0000 (14:54 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 19 Sep 2017 12:54:32 +0000 (14:54 +0200)
# Conflicts:
# js/libs/fluidbook/fluidbook.js
# js/libs/fluidbook/fluidbook.menu.js
# js/libs/fluidbook/fluidbook.nav.js

1  2 
js/libs/fluidbook/fluidbook.js
js/libs/fluidbook/fluidbook.menu.js
js/libs/fluidbook/fluidbook.nav.js
js/main.js
style/fluidbook.less

index 581afd1e368d75b530a4c6955745e8e2b5121a5f,06ebb9b58fd04054835a76c4d6138b4759382dc6..581f6fe3f1f7befce0cc272b7228aa9d43fc7f90
@@@ -32,7 -32,6 +32,7 @@@ Fluidbook.prototype = 
          this.service = new FluidbookService(this, datas.id);
          this.support = new FluidbookSupport(this);
          this.loader = new FluidbookLoader(this);
-         this.index = new FluidbookIndex(this);
++        this.index = new FluidbookIndex(this); // ToDo: check this?
          this.search = new FluidbookSearch(this);
          this.pad = new FluidbookPad(this);
          this.links = new FluidbookLinks(this);
          this.search.kill();
      },
      hideSearchHints: function () {
 -        this.killLastSearchHint();
 -        $("#searchHints").html('');
 -        $("#searchHints").hide();
 +        // this.killLastSearchHint();
 +        // $("#searchHints").html('');
 +        // $("#searchHints").hide();
 +        this.menuSearchHints.html('').hide(); // Clear and hide all hints
 +    },
 +
 +    hideSearchResults: function () {
 +        this.menuSearchResults.html('').hide();
 +    },
 +
 +    // Check if a search is active in the interface
 +    isSearchActive: function () {
 +
 +        if (!this.datas.search) {
 +            return false; // Search feature disabled on this Fluidbook
 +        }
 +
 +        return ($('#q').val().length > 0);
      },
-     getLocationToShare: function () {
-         if (this.datas.phonegap) {
-             return this.datas.offlineLink;
-         } else {
-             var l = window.location.toString();
-             var e = l.split("#");
-             return e[0];
-         }
-     },
-     sendEmail: function () {
-         window.location = 'mailto:?subject=' + encodeURIComponent(this.datas.title) + '&body=' + encodeURIComponent(this.datas.title + ' : ' + this.getLocationToShare());
-         this.stats.track(5);
-     },
-     sendTwitter: function () {
-         this.service.open('twitterShare', {
-             url: this.getLocationToShare(),
-             post: this.datas.twitter_description.replace('%title%', this.datas.title)
-         }, 'width=650,height=400');
-         this.stats.track(13);
-     },
-     sendFacebook: function () {
-         this.service.open('facebookShare', {
-             url: this.getLocationToShare()
-         }, 'width=650,height=400');
-         this.stats.track(12);
-     },
-     sendGoogleplus: function () {
-         this.service.open('googleplusShare', {
-             url: this.getLocationToShare()
-         }, 'width=650,height=400');
-         this.stats.track(12);
-     },
-     sendLinkedin: function () {
-         this.service.open('linkedinShare', {
-             url: this.getLocationToShare()
-         }, 'width=650,height=400');
-         this.stats.track(12);
-     },
-     sendViadeo: function () {
-         this.service.open('viadeoShare', {
-             url: this.getLocationToShare()
-         }, 'width=650,height=400');
-         this.stats.track(12);
-     },
 +
 +    // Clear search query and close search related menu items
 +    closeSearch: function () {
 +        $('#q').val(''); // Clear search field
 +        this.hideSearchHints();
 +        this.hideSearchResults();
 +        this.showMenuItems(); // Show menu items that were hidden previously
 +    },
 +
++
      print: function () {
          var $this = this;
          var pdf;
index d6352db22b648d00f2f4498c5dfc6e2bec941dc3,0c981ac428ace59b19eb81c0c3a8814ab7869067..72a00c258964d59c639d69e97efc4911aae0da6b
@@@ -295,11 -295,9 +296,11 @@@ FluidbookMenu.prototype = 
          view += '<div class="content">';
          view += '<ul class="chapters localesList">';
          var $this = this;
 -        $.each(this.fluidbook.l10n.multilang, function (k, v) {
 +
 +        Object.keys(this.fluidbook.l10n.multilang).forEach(function (langCode) {
 +            var v = this.fluidbook.l10n.multilang[langCode];
              var url = v.url;
-             if (url.substr(0, 3) == '../' && !$this.fluidbook.datas.standalone) {
+             if (url.substr(0, 3) == '../' && !$this.fluidbook.datas.standalone && !$this.fluidbook.support.offline) {
                  url = '../' + url;
              }
              /*'datas' => array(__('Langue') => 'lang',
index 89f76ad574fc5708c85b9c115e000fa09a83422b,daf0ebcdbf492d0069d5892e2ca7b0d819524c7d..6f47acf3577187f828c1608b8fee6ac1bb0ade11
@@@ -258,21 -83,16 +258,25 @@@ FluidbookNav.prototype = 
          }
  
  
 -        var all = "index,chapters,print,friend,bookmark,archives,basket,fullscreen,sound,3d,help".split(",");
 -        var hide = array_diff(all, this.fluidbook.datas.navOrder);
 -        var loop = [].concat(this.fluidbook.datas.navOrder).concat(hide);
 +        // All possible icons and default ordering
 +        var all = "extra,index,chapters,search,friend,print,bookmark,archives,basket,fullscreen,sound,3d,help,lang".split(",");
 +        // var hide = array_diff(all, this.fluidbook.datas.navOrder); // Array of icons that aren't in the navOrder list and should be hidden
 +        // var loop = [].concat(this.fluidbook.datas.navOrder).concat(hide);
 +        var loop = this.fluidbook.datas.navOrder;
 +        var localeIconIndex;
 +
+         if (!this.fluidbook.datas.displayChaptersIcon) {
+             hide.push('chapters');
+         }
 +        // If the locales icon is included, it should always be placed last in the list for formatting reasons
 +        // if ((localeIconIndex = loop.indexOf('lang')) !== -1) {
 +        //     loop.push(loop.splice(localeIconIndex, 1)[0]); // Push to end of array
 +        // }
 +
          for (var e in loop) {
              var icon = loop[e];
 -            var visible = hide.indexOf(icon) == -1;
 +            //var visible = hide.indexOf(icon) == -1;
              var link;
  
              if (icon == 'home' && !skipHome) {
  
                  }
  
+                 $('#home').on('click', function () {
+                     var $this = this;
+                     fluidbook.displayLoader();
+                     setTimeout(function () {
+                         window.location = $($this).attr('href');
+                     }, 500);
+                     return false;
+                 })
              } else if (icon == 'index') {
 -                link = this.addLink('nav-index', '#/index', 'index', 'overview');
 +                link = this.addLink(navType, 'interface-index', '#/index', 'index', 'overview', 'overview');
              } else if (icon == 'chapters') {
 -                if (this.fluidbook.datas.chaptersPage != '') {
 -                    link = this.addLink('nav-sommaire', '#/page/' + this.fluidbook.datas.chaptersPage, 'chapters', 'chapters');
 -                } else if (this.fluidbook.datas.chapters.length > 0) {
 -                    link = this.addLink('nav-sommaire', '#/chapters', 'chapters', 'chapters');
 +                if (this.fluidbook.datas.displayChaptersIcon) {
 +                    if (this.fluidbook.datas.chaptersPage != '') {
 +                        link = this.addLink(navType, 'interface-chapters', '#/page/' + this.fluidbook.datas.chaptersPage, 'chapters', 'chapters', 'chapters');
 +                    } else if (this.fluidbook.datas.chapters.length > 0) {
 +
 +                        // NOTE: Currently the MMenu breaks when the non-cascading chapter UL HTML is inserted so it will
 +                        // be opened in a popup for now. Todo: fix this so it works as a sub panel of it's own
 +                        if (navType == 'menu' && this.fluidbook.datas.chaptersCascade) {
 +                            link = this.addLink(navType, 'interface-chapters', '', 'chapters', 'chapters', 'chapters');
 +
 +                            // Get HTML for submenus (appended later)
 +                            this.chaptersMenuHTML = this.makeChapterLists(this.fluidbook.datas.chapters);
 +
 +                        } else {
 +                            link = this.addLink(navType, 'interface-chapters', '#/chapters', 'chapters', 'chapters', 'chapters');
 +                        }
 +                    }
                  }
-                 // Sharing icons - this may contain many different icons
 +
++            // Sharing icons - this may contain many different icons
              } else if (icon == 'friend') {
 -                    link = this.addLink('nav-friend', '#/share', 'share', 'share');
+                 if (this.fluidbook.share.isEnabled()) {
-                 if (navType == 'horizontalNav') {
 +
-                     if (this.fluidbook.datas.share) {
-                         link = this.addLink(navType, 'interface-share', '#/share', 'share', 'share', 'share');
-                     }
++                    if (navType == 'horizontalNav') {
 +
-                 } else if (navType == 'menu') {
++                        if (this.fluidbook.datas.share) {
++                            link = this.addLink(navType, 'interface-share', '#/share', 'share', 'share', 'share');
++                        }
 +
-                     var shareLinks = {},
-                         shareHTML = '';
++                    } else if (navType == 'menu') {
 +
-                     if (this.fluidbook.datas.friend) {
-                         shareLinks['email'] = 'E-mail';
-                     }
-                     if (this.fluidbook.datas.facebook) {
-                         shareLinks['facebook'] = 'Facebook';
-                     }
-                     if (this.fluidbook.datas.twitter) {
-                         shareLinks['twitter'] = 'Twitter';
-                     }
-                     if (this.fluidbook.datas.googleplus) {
-                         shareLinks['googleplus'] = 'Google Plus';
-                     }
-                     if (this.fluidbook.datas.linkedin) {
-                         shareLinks['linkedin'] = 'LinkedIn';
-                     }
-                     if (this.fluidbook.datas.viadeo) {
-                         shareLinks['viadeo'] = 'Viadeo';
-                     }
++                        var shareLinks = {},
++                            shareHTML = '';
 +
-                     // Generate links
-                     for (var shareType in shareLinks) {
-                         if (shareLinks.hasOwnProperty(shareType)) { // Ensure we don't get inherited properties
-                             shareHTML += '<a href="#" data-service="' + shareType + '" class="share" title="' + shareLinks[shareType] + '">';
-                             shareHTML += getSpriteIcon('interface-' + shareType);
-                             shareHTML += '</a>';
++                        if (this.fluidbook.datas.friend) {
++                            shareLinks['email'] = 'E-mail';
++                        }
++                        if (this.fluidbook.datas.facebook) {
++                            shareLinks['facebook'] = 'Facebook';
++                        }
++                        if (this.fluidbook.datas.twitter) {
++                            shareLinks['twitter'] = 'Twitter';
++                        }
++                        if (this.fluidbook.datas.googleplus) {
++                            shareLinks['googleplus'] = 'Google Plus';
++                        }
++                        if (this.fluidbook.datas.linkedin) {
++                            shareLinks['linkedin'] = 'LinkedIn';
++                        }
++                        if (this.fluidbook.datas.viadeo) {
++                            shareLinks['viadeo'] = 'Viadeo';
++                        }
 +
-                     // Save HTML so it can be added to menu once MMenu is initialised
-                     this.shareLinksHTML = '<div id="shareLinks"><div class="share-icons">' + shareHTML + '</div></div>';
-                 }
++                        // Generate links
++                        for (var shareType in shareLinks) {
++                            if (shareLinks.hasOwnProperty(shareType)) { // Ensure we don't get inherited properties
++                                shareHTML += '<a href="#" data-service="' + shareType + '" class="share" title="' + shareLinks[shareType] + '">';
++                                shareHTML += getSpriteIcon('interface-' + shareType);
++                                shareHTML += '</a>';
++                            }
 +                        }
++
++                        // Save HTML so it can be added to menu once MMenu is initialised
++                        this.shareLinksHTML = '<div id="shareLinks"><div class="share-icons">' + shareHTML + '</div></div>';
 +                    }
 +
 -            } else if (icon == 'bookmark') {
 +
+                     $("#share").click(function () {
+                         if ($this.fluidbook.datas.phonegap != 'android') {
+                             return true;
+                         }
+                         $this.fluidbook.share.intentShare();
+                         return false;
+                     });
+                 }
-                 link = this.addLink(navType, 'interface-bookmarks', '#/bookmark', 'bookmarks', 'bookmarks', 'bookmarks');
 +
 +            } else if (icon == 'bookmark' && this.fluidbook.datas.bookmark) {
 -                    link = this.addLink('nav-bookmark', '#/bookmark', 'bookmarks', 'bookmarks');
+                 if (this.fluidbook.datas.bookmark) {
 -            } else if (icon == 'pdf' || icon == 'print') {
 -                if ($("#print").length == 0 && (this.fluidbook.datas.print || this.fluidbook.datas.pdf)) {
 -                    link = 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) {
 -                    link = this.addMultilangLink();
 -                }
++                    link = this.addLink(navType, 'interface-bookmarks', '#/bookmark', 'bookmarks', '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' && this.fluidbook.datas.pdf) {
 +                link = this.addLink(navType, 'interface-download', '#', 'download', 'download', 'download');
 +
 +            } else if (icon == 'print' && this.fluidbook.datas.print) {
 +                link = this.addLink(navType, 'interface-print', '#', 'print', 'print', 'print');
 +
 +            } else if (icon == 'lang' && this.fluidbook.l10n.multilangEnabled) {
 +                // Note: the "!" at the beginning of the title/help parameters means that we don't want these strings translated
 +                link = this.addLink(navType, 'interface-locales', '#/locales', 'locales', '!' + this.fluidbook.l10n.getCurrentLanguageName(), '!Select Language');
 +
              } else if (icon == 'archives') {
                  if (this.fluidbook.datas.archivesLink != '') {
 -                    link = this.addLink('nav-archives', this.fluidbook.datas.archivesLink, 'archives', '!' + this.fluidbook.datas.archivesLabel);
 +                    link = this.addLink(navType, 'nav-archives', this.fluidbook.datas.archivesLink, 'archives', '!' + this.fluidbook.datas.archivesLabel, '!' + this.fluidbook.datas.archivesLabel);
                  } else if (this.fluidbook.datas.externalArchives != '') {
 -                    link = this.addLink('nav-archives', '#/archives', 'archives', '!' + this.fluidbook.datas.archivesLabel);
 +                    link = this.addLink(navType, 'nav-archives', '#/archives', 'archives', '!' + this.fluidbook.datas.archivesLabel, '!' + this.fluidbook.datas.archivesLabel);
                  }
 +
              } else if (icon == 'help') {
 -                link = this.addLink('nav-help', '#', 'help', '');
 -            } else if (icon == 'zoom' && !this.fluidbook.support.isMobile) {
 -                link = this.addLink('nav-zoomin', '#', 'zoomin', 'zoom in');
 -                link = this.addLink('nav-zoomout', '#', 'zoomout', 'zoom out');
 +                link = this.addLink(navType, 'interface-help', '#', 'help', 'help', 'help');
  
 -                $("#zoomin").click(function (e) {
 -                    $this.fluidbook.desktop.clickZoom(e, 'in');
 -                    return false;
 -                });
 +            } else if (icon == 'zoom' && !this.fluidbook.support.isMobile) {
 +                link = this.addLink(navType, 'nav-zoomin', '#', 'zoomin', 'zoom in', 'zoom in');
 +                link = this.addLink(navType, 'nav-zoomout', '#', 'zoomout', 'zoom out', 'zoom out');
  
 -                $("#zoomout").click(function () {
 -                    $this.fluidbook.desktop.clickZoom(e, 'out');
 -                    return false;
 -                });
              } else if (icon == 'fullscreen' && Modernizr.fullscreen && !DATAS.phonegap) {
 -                link = this.addLink('nav-fullscreen', '#', 'fullscreen', 'switch between fullscreen and normal');
 -                $("#fullscreen").click(function () {
 -                    screenfull.toggle();
 -                    return false;
 -                })
 -            }
 +                link = this.addLink(navType, 'interface-' + icon, '#', icon, 'full screen', 'switch between fullscreen and normal');
 +
 +            } else if (icon == 'search') {
 +
 +                // Only the horizontal icon menu has the search icon, which opens the main menu
 +                if (this.fluidbook.datas.search && navType == 'horizontalNav') {
 +                    link = this.addLink(navType, 'interface-search', '#', 'searchIcon', 'search', 'search');
 +                }
 +
 +            } else if (icon == 'extra') {
 +
 +                if (this.fluidbook.datas.navExtraImage == '' || this.fluidbook.datas.navExtraLink == '') {
 +                    continue;
 +                }
 +
 +                var id = 'extra',
 +                    $nav = this.getNavFromType(navType),
 +                    elementID = navType + '_' + id,
 +                    navExtraImage;
 +
 +                if ($nav.find('#' + elementID).length > 0) {
 +                    continue;
 +                }
 +
 +                if (navType == 'horizontalNav') {
 +                    navExtraImage = this.fluidbook.datas.navExtraImage;
 +                } else if (navType == 'menu') {
 +                    navExtraImage = this.fluidbook.datas.navExtraImageMobile || this.fluidbook.datas.navExtraImage; // Fallback to desktop image
 +                }
 +
 +                link = '<a id="' + elementID + '" href="' + this.fluidbook.datas.navExtraLink + '"><img src="data/images/' + navExtraImage + '"></a>';
 +
 +                $nav.find('ul').append('<li>' + link + '</li>');
 +
  
 -            if (!visible) {
 -                $(link).addClass('hidden');
              }
 -        }
  
 -        if (this.fluidbook.datas.search) {
 -            this.setSearch();
 +            // if (!visible) {
 +            //     $(link).addClass('hidden');
 +            // }
          }
 +
 +
          if (this.fluidbook.datas.afterSearch != '' && this.fluidbook.datas.themeEnableAfterSearch) {
              this.setAfterSearch();
          }
diff --cc js/main.js
Simple merge
Simple merge