Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
align with backend (#409)
Browse files Browse the repository at this point in the history
* align with backend

* formatting

* WRTC
  • Loading branch information
ildyria authored Sep 16, 2023
1 parent 3398bbe commit 603ba2a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion scripts/3rd-party/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ const SmartAlbumID = Object.freeze({
* @property {string} landing_page_enable - actually a boolean
* @property {string} lang
* @property {string[]} lang_available
* @property {string} layout - actually a number: `0`, `1` or `2`
* @property {string} layout - `square`, `justified` or `unjustified`
* @property {string} [location]
* @property {string} location_decoding - actually a boolean
* @property {string} location_show - actually a boolean
Expand Down
2 changes: 1 addition & 1 deletion scripts/main/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ build.photo = function (data, disabled = false) {
lychee.locale["PHOTO_THUMBNAIL"]
}' data-overlay='false' draggable='false' data-tabindex='${tabindex.get_next_tab_index()}'></span>`;
}
} else if (lychee.layout === 0) {
} else if (lychee.layout === "square") {
if (data.size_variants.thumb2x !== null) {
thumb2x = data.size_variants.thumb2x.url;
}
Expand Down
13 changes: 6 additions & 7 deletions scripts/main/lychee.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const lychee = {
/**
* Values:
*
* - `0`: Use default, "square" layout.
* - `1`: Use Flickr-like "justified" layout.
* - `2`: Use Google-like "unjustified" layout
* - `square`: Use default, "square" layout.
* - `justified`: Use Flickr-like "justified" layout.
* - `unjustified`: Use Google-like "unjustified" layout
*
* @type {number}
* @type {string}
*/
layout: 1,
layout: "justified",
/**
* Display search in public mode.
* @type {boolean}
Expand Down Expand Up @@ -546,8 +546,7 @@ lychee.parsePublicInitializationData = function (data) {
lychee.album_decoration = data.config.album_decoration || "layers";
lychee.album_decoration_orientation = data.config.album_decoration_orientation || "row";
lychee.checkForUpdates = data.config.check_for_updates;
lychee.layout = Number.parseInt(data.config.layout, 10);
if (Number.isNaN(lychee.layout)) lychee.layout = 1;
lychee.layout = data.config.layout || "justified";
lychee.landing_page_enable = data.config.landing_page_enable;
lychee.public_search = data.config.public_search;
lychee.image_overlay_type = data.config.image_overlay_type || "exif";
Expand Down
4 changes: 2 additions & 2 deletions scripts/main/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ search.find = function (term) {
if (albumsData !== "") albums_divider += " (" + (search.json.tag_albums.length + search.json.albums.length) + ")";
if (photosData !== "") {
photos_divider += " (" + search.json.photos.length + ")";
if (lychee.layout === 1) {
if (lychee.layout === "justified") {
photosData = '<div class="justified-layout">' + photosData + "</div>";
} else if (lychee.layout === 2) {
} else if (lychee.layout === "unjustified") {
photosData = '<div class="unjustified-layout">' + photosData + "</div>";
}
}
Expand Down
16 changes: 8 additions & 8 deletions scripts/main/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ view.album = {
}

if (photosData !== "") {
if (lychee.layout === 1) {
if (lychee.layout === "justified") {
// The CSS class 'laying-out' prevents the DIV from being
// rendered.
// The CSS class will eventually be removed by the
Expand All @@ -269,7 +269,7 @@ view.album = {
// the correct width of the container.
// TODO: Re-add the CSS class `laying-out` here after https://github.com/LycheeOrg/Lychee-front/pull/335 has been merged.
photosData = '<div class="justified-layout">' + photosData + "</div>";
} else if (lychee.layout === 2) {
} else if (lychee.layout === "unjustified") {
photosData = '<div class="unjustified-layout">' + photosData + "</div>";
}
}
Expand Down Expand Up @@ -380,7 +380,7 @@ view.album = {
srcset = "";

// This mimicks the structure of build.photo
if (lychee.layout === 0) {
if (lychee.layout === "square") {
src = data.size_variants.thumb.url;
if (data.size_variants.thumb2x !== null) {
srcset = `${data.size_variants.thumb2x.url} 2x`;
Expand Down Expand Up @@ -516,7 +516,7 @@ view.album = {
*/
const photos = album.json.photos;

if (lychee.layout === 1) {
if (lychee.layout === "justified") {
/** @type {jQuery} */
const jqJustifiedLayout = $(".justified-layout");
let containerWidth = parseFloat(jqJustifiedLayout.width());
Expand Down Expand Up @@ -606,7 +606,7 @@ view.album = {
});
// Show updated layout
jqJustifiedLayout.removeClass("laying-out");
} else if (lychee.layout === 2) {
} else if (lychee.layout === "unjustified") {
/** @type {jQuery} */
const jqUnjustifiedLayout = $(".unjustified-layout");
let containerWidth = parseFloat(jqUnjustifiedLayout.width());
Expand Down Expand Up @@ -1383,9 +1383,9 @@ view.settings = {
<p>${lychee.locale["LAYOUT_TYPE"]}
<span class="select" style="width:270px">
<select name="layout" id="layout">
<option value="0">${lychee.locale["LAYOUT_SQUARES"]}</option>
<option value="1">${lychee.locale["LAYOUT_JUSTIFIED"]}</option>
<option value="2">${lychee.locale["LAYOUT_UNJUSTIFIED"]}</option>
<option value="square">${lychee.locale["LAYOUT_SQUARES"]}</option>
<option value="justified">${lychee.locale["LAYOUT_JUSTIFIED"]}</option>
<option value="unjustified">${lychee.locale["LAYOUT_UNJUSTIFIED"]}</option>
</select>
</span>
</p>
Expand Down

0 comments on commit 603ba2a

Please sign in to comment.