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;
}
- 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();
}