From d53b8cd8afeed3de3fcdfece196d92fc1a3e80aa Mon Sep 17 00:00:00 2001 From: Olivier Paroz Date: Mon, 27 Jul 2015 04:28:33 +0200 Subject: JS cleanup All methods should be documented Public methods first, then private ones Finish "use strict" implementation --- js/galleryview.js | 124 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) (limited to 'js/galleryview.js') diff --git a/js/galleryview.js b/js/galleryview.js index 75b35b6c..5d3ae12e 100644 --- a/js/galleryview.js +++ b/js/galleryview.js @@ -86,7 +86,7 @@ if (albumPath !== Gallery.currentAlbum) { this.loadVisibleRows.loading = false; Gallery.currentAlbum = albumPath; - this.setupButtons(albumPath); + this._setupButtons(albumPath); } Gallery.albumMap[albumPath].viewedItems = 0; @@ -104,65 +104,6 @@ }.bind(this), 0); }, - /** - * Sets up all the buttons of the interface - * - * @param {string} albumPath - */ - setupButtons: function (albumPath) { - this.shareButtonSetup(albumPath); - this.infoButtonSetup(); - - this.breadcrumb = new Gallery.Breadcrumb(albumPath); - this.breadcrumb.setMaxWidth($(window).width() - Gallery.buttonsWidth); - - var currentSort = Gallery.config.albumSorting; - this.sortControlsSetup(currentSort.type, currentSort.order); - Gallery.albumMap[Gallery.currentAlbum].images.sort(Gallery.utility.sortBy(currentSort.type, - currentSort.order)); - Gallery.albumMap[Gallery.currentAlbum].subAlbums.sort(Gallery.utility.sortBy('name', - currentSort.albumOrder)); - }, - - /** - * Shows or hides the share button depending on if we're in a public gallery or not - * - * @param {string} albumPath - */ - shareButtonSetup: function (albumPath) { - var shareButton = $('#share-button'); - if (albumPath === '' || Gallery.token) { - shareButton.hide(); - } else { - shareButton.show(); - } - }, - - /** - * Shows or hides the info button based on the information we've received from the server - */ - infoButtonSetup: function () { - var infoButton = $('#album-info-button'); - infoButton.find('span').hide(); - var infoContentElement = $('.album-info-content'); - infoContentElement.slideUp(); - infoContentElement.css('max-height', $(window).height() - Gallery.browserToolbarHeight); - var albumInfo = Gallery.config.albumInfo; - if (Gallery.config.albumError) { - infoButton.hide(); - var text = '' + t('gallery', 'Configuration error') + '
' + - Gallery.config.albumError.message + '

'; - Gallery.utility.showHtmlNotification(text, 7); - } else if ($.isEmptyObject(albumInfo)) { - infoButton.hide(); - } else { - infoButton.show(); - if (albumInfo.inherit !== 'yes' || albumInfo.level === 0) { - infoButton.find('span').delay(1000).slideDown(); - } - } - }, - /** * Manages the sorting interface * @@ -276,6 +217,69 @@ this.loadVisibleRows.loading = showRows(album); return this.loadVisibleRows.loading; } + }, + + /** + * Sets up all the buttons of the interface + * + * @param {string} albumPath + * @private + */ + _setupButtons: function (albumPath) { + this._shareButtonSetup(albumPath); + this._infoButtonSetup(); + + this.breadcrumb = new Gallery.Breadcrumb(albumPath); + this.breadcrumb.setMaxWidth($(window).width() - Gallery.buttonsWidth); + + var currentSort = Gallery.config.albumSorting; + this.sortControlsSetup(currentSort.type, currentSort.order); + Gallery.albumMap[Gallery.currentAlbum].images.sort(Gallery.utility.sortBy(currentSort.type, + currentSort.order)); + Gallery.albumMap[Gallery.currentAlbum].subAlbums.sort(Gallery.utility.sortBy('name', + currentSort.albumOrder)); + }, + + /** + * Shows or hides the share button depending on if we're in a public gallery or not + * + * @param {string} albumPath + * @private + */ + _shareButtonSetup: function (albumPath) { + var shareButton = $('#share-button'); + if (albumPath === '' || Gallery.token) { + shareButton.hide(); + } else { + shareButton.show(); + } + }, + + /** + * Shows or hides the info button based on the information we've received from the server + * + * @private + */ + _infoButtonSetup: function () { + var infoButton = $('#album-info-button'); + infoButton.find('span').hide(); + var infoContentElement = $('.album-info-content'); + infoContentElement.slideUp(); + infoContentElement.css('max-height', $(window).height() - Gallery.browserToolbarHeight); + var albumInfo = Gallery.config.albumInfo; + if (Gallery.config.albumError) { + infoButton.hide(); + var text = '' + t('gallery', 'Configuration error') + '
' + + Gallery.config.albumError.message + '

'; + Gallery.utility.showHtmlNotification(text, 7); + } else if ($.isEmptyObject(albumInfo)) { + infoButton.hide(); + } else { + infoButton.show(); + if (albumInfo.inherit !== 'yes' || albumInfo.level === 0) { + infoButton.find('span').delay(1000).slideDown(); + } + } } }; -- cgit v1.2.3