Refactor wishlists api

This commit is contained in:
grandeljay 2022-11-23 16:45:04 +01:00
parent 558b2a1249
commit 7ba0a2c784
16 changed files with 503 additions and 353 deletions

View file

@ -41,6 +41,39 @@ switch ($_SERVER['REQUEST_METHOD']) {
$response = array( $response = array(
'info' => $info, 'info' => $info,
); );
} elseif (isset($_GET['wishlist_id'], $_GET['wishlist_style'], $_GET['wish_priority'])) {
/**
* Get wishes by priority
*/
$wishlist = new Wishlist($_GET['wishlist_id']);
$options = array(
'style' => $_GET['wishlist_style'],
);
$where = array(
'wishlist' => '`wishlist` = ' . $wishlist->id,
'priority' => '`priority` = ' . $_GET['wish_priority'],
);
if (-1 === intval($_GET['wish_priority'])) {
unset($where['priority']);
}
if (empty($_GET['wish_priority'])) {
$where['priority'] = '`priority` IS NULL';
}
$options['WHERE'] = '(' . implode(') AND (', $where) . ')';
$wishes = array_map(
function (Wish $wish) use ($wishlist) {
$wish->card = $wish->getCard($wishlist->user);
return $wish;
},
$wishlist->getWishes($options)
);
$response['results'] = $wishes;
} }
break; break;

View file

@ -118,6 +118,13 @@ switch ($_SERVER['REQUEST_METHOD']) {
$options['WHERE'] = '(' . implode(') AND (', $where) . ')'; $options['WHERE'] = '(' . implode(') AND (', $where) . ')';
$response['results'] = $wishlist->getCards($options); $response['results'] = $wishlist->getCards($options);
} elseif (isset($_GET['wishlist_id'])) {
/**
* Get wishlist by id
*/
$wishlist = new Wishlist($_GET['wishlist_id']);
$response['results'] = $wishlist;
} elseif (isset($_GET['userid']) || isset($_SESSION['user']->id)) { } elseif (isset($_GET['userid']) || isset($_SESSION['user']->id)) {
/** /**
* Get user wishlists * Get user wishlists
@ -136,9 +143,6 @@ switch ($_SERVER['REQUEST_METHOD']) {
'name' => $wishlist->name, 'name' => $wishlist->name,
'value' => $wishlist->id, 'value' => $wishlist->id,
'text' => $wishlist->name, 'text' => $wishlist->name,
'cards' => $wishlist->getCards($options),
'hash' => $wishlist->hash,
); );
} }

View file

@ -523,7 +523,7 @@ body.pushable > .pusher {
/** /**
* Options * Options
*/ */
.ui.dropdown.options { .ui.dropdown.wish-options {
text-align: center; text-align: center;
} }

View file

@ -2,7 +2,7 @@ $(function() {
/** /**
* Tabs * Tabs
*/ */
var current_version_tab = version.replaceAll('.', '-'); var current_version_tab = wishthis.version.replaceAll('.', '-');
$('.menu .item').tab(); $('.menu .item').tab();
$('.menu .item').tab('change tab', current_version_tab); $('.menu .item').tab('change tab', current_version_tab);

View file

@ -10,7 +10,7 @@ if ('serviceWorker' in navigator) {
}) })
} }
const urlParams = new URLSearchParams($_GET); const urlParams = new URLSearchParams(wishthis.$_GET);
$(function() { $(function() {
/** /**
@ -18,8 +18,8 @@ $(function() {
*/ */
/** API */ /** API */
$.fn.api.settings.api = { $.fn.api.settings.api = {
'get wishlists' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}', 'get wishlists' : '/?page=api&module=wishlists&api_token={apitoken}',
'get wishlists with priority' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}&wishlist_id={wishlistid}&priority={priority}', 'get wishlists by priority' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}&wishlist_id={wishlistid}&priority={priority}',
'delete wishlist' : '/?page=api&module=wishlists', 'delete wishlist' : '/?page=api&module=wishlists',
'update wish status' : '/?page=api&module=wishes', 'update wish status' : '/?page=api&module=wishes',
'delete wish' : '/?page=api&module=wishes', 'delete wish' : '/?page=api&module=wishes',
@ -40,8 +40,8 @@ $(function() {
values : response.results values : response.results
}) })
if ($_GET.id) { if (wishthis.$_GET.id) {
element.dropdown('set selected', $_GET.id); element.dropdown('set selected', wishthis.$_GET.id);
} else { } else {
if (response.results[0]) { if (response.results[0]) {
element.dropdown('set selected', response.results[0].value); element.dropdown('set selected', response.results[0].value);
@ -62,12 +62,12 @@ $(function() {
$('body') $('body')
.modal({ .modal({
autoShow : true, autoShow : true,
title : text.modal_failure_title, title : wishthis.strings.modal.failure.title,
content : content, content : content,
class : 'small', class : 'small',
actions : [ actions : [
{ {
text : text.modal_failure_approve, text : wishthis.strings.modal.failure.approve,
class : 'primary' class : 'primary'
} }
] ]
@ -80,12 +80,12 @@ $(function() {
$('body') $('body')
.modal({ .modal({
title : text.modal_error_title, title : wishthis.strings.modal.error.title,
content : response, content : response,
class : 'small', class : 'small',
actions : [ actions : [
{ {
text : text.modal_failure_approve, text : wishthis.strings.modal.failure.approve,
class: 'primary' class: 'primary'
} }
], ],
@ -100,36 +100,36 @@ $(function() {
$.fn.toast.settings.showProgress = 'bottom'; $.fn.toast.settings.showProgress = 'bottom';
$.fn.toast.settings.class = 'success'; $.fn.toast.settings.class = 'success';
$.fn.toast.settings.showIcon = true; $.fn.toast.settings.showIcon = true;
$.fn.toast.settings.title = text.modal_success_title; $.fn.toast.settings.title = wishthis.strings.modal.success.title;
/** Form Prompts */ /** Form Prompts */
$.fn.form.settings.prompt = { $.fn.form.settings.prompt = {
empty : text.form_prompt_empty, empty : wishthis.strings.form.prompt.empty,
checked : text.form_prompt_checked, checked : wishthis.strings.form.prompt.checked,
email : text.form_prompt_email, email : wishthis.strings.form.prompt.email,
url : text.form_prompt_url, url : wishthis.strings.form.prompt.url,
regExp : text.form_prompt_regExp, regExp : wishthis.strings.form.prompt.regExp,
integer : text.form_prompt_integer, integer : wishthis.strings.form.prompt.integer,
decimal : text.form_prompt_decimal, decimal : wishthis.strings.form.prompt.decimal,
number : text.form_prompt_number, number : wishthis.strings.form.prompt.number,
is : text.form_prompt_is, is : wishthis.strings.form.prompt.is,
isExactly : text.form_prompt_isExactly, isExactly : wishthis.strings.form.prompt.isExactly,
not : text.form_prompt_not, not : wishthis.strings.form.prompt.not,
notExactly : text.form_prompt_notExactly, notExactly : wishthis.strings.form.prompt.notExactly,
contain : text.form_prompt_contain, contain : wishthis.strings.form.prompt.contain,
containExactly : text.form_prompt_containExactly, containExactly : wishthis.strings.form.prompt.containExactly,
doesntContain : text.form_prompt_doesntContain, doesntContain : wishthis.strings.form.prompt.doesntContain,
doesntContainExactly : text.form_prompt_doesntContainExactly, doesntContainExactly : wishthis.strings.form.prompt.doesntContainExactly,
minLength : text.form_prompt_minLength, minLength : wishthis.strings.form.prompt.minLength,
length : text.form_prompt_length, length : wishthis.strings.form.prompt.length,
exactLength : text.form_prompt_exactLength, exactLength : wishthis.strings.form.prompt.exactLength,
maxLength : text.form_prompt_maxLength, maxLength : wishthis.strings.form.prompt.maxLength,
match : text.form_prompt_match, match : wishthis.strings.form.prompt.match,
different : text.form_prompt_different, different : wishthis.strings.form.prompt.different,
creditCard : text.form_prompt_creditCard, creditCard : wishthis.strings.form.prompt.creditCard,
minCount : text.form_prompt_minCount, minCount : wishthis.strings.form.prompt.minCount,
exactCount : text.form_prompt_exactCount, exactCount : wishthis.strings.form.prompt.exactCount,
maxCount : text.form_prompt_maxCount, maxCount : wishthis.strings.form.prompt.maxCount,
}; };
/** Calendar Text */ /** Calendar Text */
@ -147,47 +147,47 @@ $(function() {
}; };
$.fn.calendar.settings.text.days = [ $.fn.calendar.settings.text.days = [
new Date(2018, 00, 00).toLocaleString(locale, options_weekday), new Date(2018, 00, 00).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 01).toLocaleString(locale, options_weekday), new Date(2018, 00, 01).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 02).toLocaleString(locale, options_weekday), new Date(2018, 00, 02).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 03).toLocaleString(locale, options_weekday), new Date(2018, 00, 03).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 04).toLocaleString(locale, options_weekday), new Date(2018, 00, 04).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 05).toLocaleString(locale, options_weekday), new Date(2018, 00, 05).toLocaleString(wishthis.locale, options_weekday),
new Date(2018, 00, 06).toLocaleString(locale, options_weekday), new Date(2018, 00, 06).toLocaleString(wishthis.locale, options_weekday),
]; ];
$.fn.calendar.settings.text.months = [ $.fn.calendar.settings.text.months = [
new Date(0000, 01, 00).toLocaleString(locale, options_months), new Date(0000, 01, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 02, 00).toLocaleString(locale, options_months), new Date(0000, 02, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 03, 00).toLocaleString(locale, options_months), new Date(0000, 03, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 04, 00).toLocaleString(locale, options_months), new Date(0000, 04, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 05, 00).toLocaleString(locale, options_months), new Date(0000, 05, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 06, 00).toLocaleString(locale, options_months), new Date(0000, 06, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 07, 00).toLocaleString(locale, options_months), new Date(0000, 07, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 08, 00).toLocaleString(locale, options_months), new Date(0000, 08, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 09, 00).toLocaleString(locale, options_months), new Date(0000, 09, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 10, 00).toLocaleString(locale, options_months), new Date(0000, 10, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 11, 00).toLocaleString(locale, options_months), new Date(0000, 11, 00).toLocaleString(wishthis.locale, options_months),
new Date(0000, 12, 00).toLocaleString(locale, options_months), new Date(0000, 12, 00).toLocaleString(wishthis.locale, options_months),
]; ];
$.fn.calendar.settings.text.monthsShort = [ $.fn.calendar.settings.text.monthsShort = [
new Date(0000, 01, 00).toLocaleString(locale, options_months_short), new Date(0000, 01, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 02, 00).toLocaleString(locale, options_months_short), new Date(0000, 02, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 03, 00).toLocaleString(locale, options_months_short), new Date(0000, 03, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 04, 00).toLocaleString(locale, options_months_short), new Date(0000, 04, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 05, 00).toLocaleString(locale, options_months_short), new Date(0000, 05, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 06, 00).toLocaleString(locale, options_months_short), new Date(0000, 06, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 07, 00).toLocaleString(locale, options_months_short), new Date(0000, 07, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 08, 00).toLocaleString(locale, options_months_short), new Date(0000, 08, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 09, 00).toLocaleString(locale, options_months_short), new Date(0000, 09, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 10, 00).toLocaleString(locale, options_months_short), new Date(0000, 10, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 11, 00).toLocaleString(locale, options_months_short), new Date(0000, 11, 00).toLocaleString(wishthis.locale, options_months_short),
new Date(0000, 12, 00).toLocaleString(locale, options_months_short), new Date(0000, 12, 00).toLocaleString(wishthis.locale, options_months_short),
]; ];
$.fn.calendar.settings.text.today = text.calendar_today; $.fn.calendar.settings.text.today = wishthis.strings.calendar.today;
$.fn.calendar.settings.text.now = text.calendar_now; $.fn.calendar.settings.text.now = wishthis.strings.calendar.now;
$.fn.calendar.settings.text.am = text.calendar_am; $.fn.calendar.settings.text.am = wishthis.strings.calendar.am;
$.fn.calendar.settings.text.pm = text.calendar_pm; $.fn.calendar.settings.text.pm = wishthis.strings.calendar.pm;
$.fn.calendar.settings.text.weekNo = text.calendar_week_no; $.fn.calendar.settings.text.weekNo = wishthis.strings.calendar.week_no;
/** Dimmer */ /** Dimmer */
$.fn.dimmer.settings.closable = false; $.fn.dimmer.settings.closable = false;
@ -253,7 +253,7 @@ function showError(error) {
class : 'small', class : 'small',
actions : [ actions : [
{ {
text : text.modal_failure_approve, text : wishthis.strings.modal.failure.approve,
class : 'primary' class : 'primary'
} }
], ],
@ -272,7 +272,7 @@ function showWarning(warning) {
class : 'small', class : 'small',
actions : [ actions : [
{ {
text : text.modal_warning_approve, text : wishthis.strings.modal.warning.approve,
class : 'primary' class : 'primary'
} }
], ],

View file

@ -4,7 +4,7 @@ $(function() {
*/ */
const params_statistics = new URLSearchParams( const params_statistics = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'statistics', 'module' : 'statistics',
'page' : 'api', 'page' : 'api',
@ -68,7 +68,7 @@ $(function() {
*/ */
const params_news = new URLSearchParams( const params_news = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'blog', 'module' : 'blog',
'page' : 'api', 'page' : 'api',
} }

View file

@ -17,8 +17,8 @@ window.addEventListener("load", (event) => {
.then(canvas => { .then(canvas => {
var data = new URLSearchParams(); var data = new URLSearchParams();
data.append('preview', canvas.toDataURL()); data.append('preview', canvas.toDataURL());
data.append('api_token', api.token); data.append('api_token', wishthis.api.token);
data.append('page', $_GET.page); data.append('page', wishthis.$_GET.page);
/** Save page preview */ /** Save page preview */
fetch('/?page=api&module=save-preview', { fetch('/?page=api&module=save-preview', {

View file

@ -8,32 +8,15 @@ $(function () {
match : 'text', match : 'text',
fullTextSearch : true, fullTextSearch : true,
}) })
.dropdown('set selected', -1)
.api({ .api({
'action' : 'get wishlists with priority', 'action' : 'get wishlists by priority',
'urlData' : { 'urlData' : {
'apitoken' : api.token, 'apitoken' : wishthis.api.token,
}, },
beforeSend : function (settings) { beforeSend : function (settings) {
settings.urlData.style = $('input[name="style"]').val(); settings.urlData.style = $('input[name="style"]').val();
settings.urlData.priority = $('.ui.dropdown.filter.priority').dropdown('get value'); settings.urlData.priority = $('.ui.dropdown.filter.priority').dropdown('get value');
settings.urlData.wishlistid = wishthis.$_GET.id;
/** Wishlist ID */
var wistlist_cards_data = $('.wishlist-cards').attr('data-wishlist')
var dropdown_wishlists = $('.dropdown.wishlists');
if (dropdown_wishlists.length) {
var dropdown_wishlists_value = dropdown_wishlists.dropdown('get value');
if (dropdown_wishlists_value) {
settings.urlData.wishlistid = dropdown_wishlists_value;
}
}
if (typeof wistlist_cards_data !== 'undefined') {
settings.urlData.wishlistid = wistlist_cards_data;
}
/** */
return settings; return settings;
}, },
@ -41,10 +24,10 @@ $(function () {
var html = response.results ? response.results : ''; var html = response.results ? response.results : '';
$('.wishlist-cards').html(html); $('.wishlist-cards').html(html);
$('.ui.dropdown.options').dropdown(); $('.ui.dropdown.wish-options').dropdown().removeClass('disabled');
} }
}); })
.dropdown('set selected', -1);
/** /**
* Style * Style

View file

@ -1,11 +1,4 @@
$(function () { $(function () {
/**
* General
*/
var wishlist = {
'id' : $_GET.id
};
/** /**
* Progress * Progress
*/ */
@ -21,30 +14,26 @@ $(function () {
* Get Wishlists * Get Wishlists
*/ */
var wishlists = []; var wishlists = [];
var wishlists_api = {
$('.ui.dropdown.wishlists')
.dropdown()
.api({
'action' : 'get wishlists', 'action' : 'get wishlists',
'urlData' : { 'urlData' : {
'apitoken' : api.token, 'apitoken' : wishthis.api.token,
},
beforeSend : function (settings) {
settings.urlData.style = $('input[name="style"]').val();
return settings;
}, },
onSuccess : function(response, dropdown_wishlists, xhr) { onSuccess : function(response, dropdown_wishlists, xhr) {
/** Set wishlists */ /** Save response for later use */
wishlists = response.results; wishlists = response.results;
dropdown_wishlists.dropdown({ /** Setup and populate dropdown */
var dropdown_values = {
'values' : wishlists, 'values' : wishlists,
}) };
/** Select current/active wishlist */ dropdown_wishlists.dropdown('setup menu', dropdown_values);
if (wishlist.id) {
dropdown_wishlists.dropdown('set selected', wishlist.id); /** Select a dropdown item */
if (!dropdown_wishlists.dropdown('get value')) {
if (wishthis.$_GET.id) {
dropdown_wishlists.dropdown('set selected', wishthis.$_GET.id);
} else { } else {
if (Object.keys(wishlists).length >= 1) { if (Object.keys(wishlists).length >= 1) {
var first_wishlist_id = Object.keys(wishlists)[0]; var first_wishlist_id = Object.keys(wishlists)[0];
@ -52,13 +41,14 @@ $(function () {
dropdown_wishlists.dropdown('set selected', first_wishlist_id); dropdown_wishlists.dropdown('set selected', first_wishlist_id);
} }
} }
}
/** Open add wish modal */ /** Open add wish modal */
if ($_GET.wish_add) { if (wishthis.$_GET.wish_add) {
$('.button.wishlist-wish-add').trigger('click'); $('.button.wishlist-wish-add').trigger('click');
} }
/** Filter wishes */ /** Set wishlist style */
const orientationIsPortrait = window.matchMedia('(orientation: portrait)'); const orientationIsPortrait = window.matchMedia('(orientation: portrait)');
if (orientationIsPortrait.matches) { if (orientationIsPortrait.matches) {
@ -66,22 +56,41 @@ $(function () {
} else { } else {
$('.buttons.view .button[value="grid"]').trigger('click'); $('.buttons.view .button[value="grid"]').trigger('click');
} }
} },
}) };
.api('query');
$(document).on('change', '.ui.dropdown.wishlists', function () { $('.ui.dropdown.wishlists')
return; .dropdown({
onChange : function(wishlist_id, text, $choice) {
var wishlist_id = $('.ui.dropdown.wishlists').dropdown('get value'); wishthis.$_GET.id = wishlist_id;
if (wishlist_id) { if (wishlist_id) {
wishlist.id = wishlist_id; /** Get wishlist */
const get_wishlist = new URLSearchParams(
{
'api_token' : wishthis.api.token,
'module' : 'wishlists',
'page' : 'api',
$('.wishlist-share').attr('href', '/?page=wishlist&hash=' + wishlists[wishlist_id].hash); 'wishlist_id' : wishlist_id,
}
);
fetch('/?' + get_wishlist, { method: 'GET' })
.then(handleFetchError)
.then(handleFetchResponse)
.then(function(response) {
var wishlist;
/** Set current wishlist */
wishlist = response.results;
/** Set share link */
$('.wishlist-share').attr('href', '/?page=wishlist&hash=' + wishlist.hash);
/** Enable wishlist options buttons */
$('.button.wishlist-wish-add').removeClass('disabled'); $('.button.wishlist-wish-add').removeClass('disabled');
$('.button.wishlist-share').removeClass('disabled'); $('.button.wishlist-share').removeClass('disabled');
$('.button.wishlist-options').removeClass('disabled').dropdown();
$('.wishlist-rename').removeClass('disabled'); $('.wishlist-rename').removeClass('disabled');
$('.wishlist-delete').removeClass('disabled'); $('.wishlist-delete').removeClass('disabled');
@ -90,7 +99,7 @@ $(function () {
const params_url = new URLSearchParams( const params_url = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'url', 'module' : 'url',
'page' : 'api', 'page' : 'api',
@ -104,31 +113,81 @@ $(function () {
.then(handleFetchResponse) .then(handleFetchResponse)
.then(function(response) { .then(function(response) {
window.history.pushState(null, document.title, response.data.url_pretty); window.history.pushState(null, document.title, response.data.url_pretty);
$('.ui.dropdown.filter.priority')
.dropdown('restore default value')
.dropdown('restore default text')
.dropdown('set selected', -1);
}); });
} else {
$('.button.wishlist-wish-add').addClass('disabled'); /** Get wishlist cards/wishes */
$('.button.wishlist-share').addClass('disabled');
$('.wishlist-rename').addClass('disabled');
$('.wishlist-delete').addClass('disabled');
}
/** /**
* Cards * Trigger priorities dropdown
*/ */
if (wishlist.id) { // $('.ui.dropdown.filter.priority').api('query');
$('.wishlist-cards').html(wishlists[wishlist.id].cards); /** */
/*
const get_wishes = new URLSearchParams(
{
'api_token' : wishthis.api.token,
'module' : 'wishes',
'page' : 'api',
'wishlist_id' : wishlist.id,
'wishlist_style' : $('[name="style"]').val(),
'wish_priority' : -1,
}
);
fetch('/?' + get_wishes, { method: 'GET' })
.then(handleFetchError)
.then(handleFetchResponse)
.then(function(response) {
/** Cards *//*
var wishes = response.results;
var wishlist_cards = $('.wishlist-cards');
wishlist_cards.html('');
switch (get_wishes.wishlist_style) {
case 'list':
wishlist_cards.append('<div class="ui one column doubling stackable grid wishlist"></div>');
break;
default:
wishlist_cards.append('<div class="ui three column doubling stackable grid wishlist"></div>');
break;
}
if (wishes.length > 0) {
wishes.forEach(wish => {
$('.wishlist-cards > .wishlist.grid').append('<div class="column">' + wish.card + '</div>');
});
} else { } else {
$('.wishlist-cards').html(''); $('.wishlist-cards > .wishlist.grid').append(
'<div class="sixteen wide column">' +
'<div class="ui info icon message">' +
'<i class="info circle icon"></i> ' +
'<div class="content">' +
'<div class="header">' + wishthis.strings.message.wishlist.empty.header + '</div>' +
'<p>' + wishthis.strings.message.wishlist.empty.content + '</p>' +
'</div>' +
'</div>' +
'</div>'
);
}
$('.ui.dropdown.wish-options').removeClass('disabled').dropdown();
});
*/
});
} else {
/** Disable wishlist options buttons */
$('.button.wishlist-wish-add').removeClass('disabled');
$('.button.wishlist-share').removeClass('disabled');
$('.button.wishlist-options').removeClass('disabled');
$('.wishlist-rename').removeClass('disabled');
$('.wishlist-delete').removeClass('disabled');
} }
/** /**
* Generate cache * Generate cache
*/ *//*
var cards = $('.ui.card[data-cache="true"]'); var cards = $('.ui.card[data-cache="true"]');
if (cards.length > 0) { if (cards.length > 0) {
@ -166,8 +225,13 @@ $(function () {
}, 0); }, 0);
} }
}); });
}); */
},
})
.api(wishlists_api)
.api('query');
/*
function generateCacheCard(card) { function generateCacheCard(card) {
var href = card.find('.content [href]').prop('href'); var href = card.find('.content [href]').prop('href');
@ -183,7 +247,7 @@ $(function () {
const params_cache = new URLSearchParams( const params_cache = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'wishes', 'module' : 'wishes',
'page' : 'api', 'page' : 'api',
@ -213,6 +277,7 @@ $(function () {
$('.ui.dropdown.options').dropdown(); $('.ui.dropdown.options').dropdown();
}); });
} }
*/
/** /**
* Share Wishlist * Share Wishlist
@ -222,13 +287,17 @@ $(function () {
var wishlist_href = window.location.origin + $(event.currentTarget).attr('href'); var wishlist_href = window.location.origin + $(event.currentTarget).attr('href');
navigator.clipboard.writeText(wishlist_href).then(function() { navigator.clipboard
$('body').toast({ message: text.toast_clipboard_success }); .writeText(wishlist_href)
.then(function() {
$('body').toast({
'message' : wishthis.strings.toast.clipboard.success.content,
});
}, function() { }, function() {
$('body').toast({ $('body').toast({
class : 'error', 'class' : 'error',
title : text.toast_clipboard_error_title, 'title' : wishthis.strings.toast.clipboard.error.title,
message : text.toast_clipboard_error 'message' : wishthis.strings.toast.clipboard.error.content,
}); });
}); });
@ -244,7 +313,8 @@ $(function () {
var formRename = modalRename.find('.form.wishlist-rename'); var formRename = modalRename.find('.form.wishlist-rename');
var formData = new URLSearchParams(new FormData(formRename[0])); var formData = new URLSearchParams(new FormData(formRename[0]));
formData.append('api_token', api.token); formData.append('api_token', wishthis.api.token);
formData.append('wishlist_id', wishthis.$_GET.id);
fetch('/?page=api&module=wishlists', { fetch('/?page=api&module=wishlists', {
method : 'PUT', method : 'PUT',
@ -257,7 +327,7 @@ $(function () {
modalRename.modal('hide'); modalRename.modal('hide');
$('body').toast({ message: text.toast_wishlist_rename }); $('body').toast({ message: wishthis.strings.toast.wishlist.rename });
}) })
.catch(handleFetchCatch) .catch(handleFetchCatch)
.finally(function() { .finally(function() {
@ -275,7 +345,7 @@ $(function () {
wishlistRenameApprove(buttonApprove); wishlistRenameApprove(buttonApprove);
}); });
$(document).on('click', '.options .wishlist-rename', function() { $(document).on('click', '.wishlist-options .wishlist-rename', function() {
var modalRename = $('.modal.wishlist-rename'); var modalRename = $('.modal.wishlist-rename');
var inputID = modalRename.find('[name="wishlist_id"]'); var inputID = modalRename.find('[name="wishlist_id"]');
var inputTitle = modalRename.find('[name="wishlist_title"]'); var inputTitle = modalRename.find('[name="wishlist_title"]');
@ -306,16 +376,16 @@ $(function () {
modalDefault modalDefault
.modal({ .modal({
title : text.modal_wishlist_delete_title, title : wishthis.strings.wishlist.delete.title,
class : 'tiny', class : 'tiny',
content : text.modal_wishlist_delete.replace('WISHLIST_NAME', $('.ui.dropdown.wishlists').dropdown('get text')), content : wishthis.strings.wishlist.delete.content.replace('WISHLIST_NAME', $('.ui.dropdown.wishlists').dropdown('get text')),
actions : [ actions : [
{ {
text : text.modal_wishlist_delete_approve, text : wishthis.strings.wishlist.delete.approve,
class: 'approve red' class: 'approve red'
}, },
{ {
text : text.modal_wishlist_delete_deny, text : wishthis.strings.wishlist.delete.deny,
class: 'deny' class: 'deny'
}, },
], ],
@ -327,7 +397,7 @@ $(function () {
action: 'delete wishlist', action: 'delete wishlist',
method: 'DELETE', method: 'DELETE',
data: { data: {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wishlistID' : wishlist_id 'wishlistID' : wishlist_id
}, },
@ -339,7 +409,7 @@ $(function () {
urlParams.delete('id'); urlParams.delete('id');
$('body').toast({ message:text.toast_wishlist_delete }); $('body').toast({ message : wishthis.strings.toast.wishlist.delete });
modalDefault.modal('hide'); modalDefault.modal('hide');
@ -372,10 +442,10 @@ $(function () {
action : 'update wish status', action : 'update wish status',
method : 'PUT', method : 'PUT',
data : { data : {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wish_id' : card.attr('data-id'), 'wish_id' : card.attr('data-id'),
'wish_status' : wish_status_fulfilled, 'wish_status' : wishthis.strings.wish.status.fulfilled,
}, },
on : 'now', on : 'now',
onSuccess : function(response, element, xhr) { onSuccess : function(response, element, xhr) {
@ -415,7 +485,7 @@ $(function () {
var wishFormData = new URLSearchParams( var wishFormData = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'wishes', 'module' : 'wishes',
'page' : 'api', 'page' : 'api',
@ -481,16 +551,16 @@ $(function () {
modalDefault modalDefault
.modal({ .modal({
title : text.modal_wish_delete_title, title : wishthis.strings.wish.delete.title,
content : text.modal_wish_delete, content : wishthis.strings.wish.delete.content,
class : 'tiny', class : 'tiny',
actions : [ actions : [
{ {
text : text.modal_wish_delete_approve, text : wishthis.strings.wish.delete.approve,
class: 'approve primary' class: 'approve primary'
}, },
{ {
text: text.modal_wish_delete_deny text: wishthis.strings.wish.delete.deny
} }
], ],
autoShow : true, autoShow : true,
@ -504,7 +574,7 @@ $(function () {
action : 'delete wish', action : 'delete wish',
method : 'DELETE', method : 'DELETE',
data : { data : {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wish_id': card.attr('data-id'), 'wish_id': card.attr('data-id'),
}, },
@ -512,7 +582,7 @@ $(function () {
onSuccess : function () { onSuccess : function () {
column.fadeOut(800); column.fadeOut(800);
$('body').toast({ message: text.toast_wish_delete }); $('body').toast({ message: wishthis.strings.toast.wish.delete });
modalDefault.modal('hide'); modalDefault.modal('hide');
@ -570,7 +640,7 @@ $(function () {
onHide : function() { onHide : function() {
/** Ugly URL */ /** Ugly URL */
if (urlParams.has('wish_add')) { if (urlParams.has('wish_add')) {
delete($_GET.wish_add); delete(wishthis.$_GET.wish_add);
urlParams.delete('wish_add'); urlParams.delete('wish_add');
window.history.pushState(null, document.title, '?' + urlParams.toString()); window.history.pushState(null, document.title, '?' + urlParams.toString());
@ -608,7 +678,7 @@ $(function () {
buttonCreate.addClass('loading'); buttonCreate.addClass('loading');
var formData = new URLSearchParams(new FormData(formWishlistCreate[0])); var formData = new URLSearchParams(new FormData(formWishlistCreate[0]));
formData.append('api_token', api.token); formData.append('api_token', wishthis.api.token);
fetch('/?page=api&module=wishlists', { fetch('/?page=api&module=wishlists', {
method : 'POST', method : 'POST',
@ -621,7 +691,7 @@ $(function () {
urlParams.set('id', response.data.lastInsertId); urlParams.set('id', response.data.lastInsertId);
$('body').toast({ message: text.toast_wish_create }); $('body').toast({ message: wishthis.strings.toast.wish.create });
$('.ui.dropdown.wishlists').api('query'); $('.ui.dropdown.wishlists').api('query');
}) })
@ -665,7 +735,7 @@ $(function () {
if (wishURLCurrent) { if (wishURLCurrent) {
const params_url = new URLSearchParams( const params_url = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'wishes', 'module' : 'wishes',
'page' : 'api', 'page' : 'api',
@ -705,7 +775,7 @@ $(function () {
const formData = new URLSearchParams( const formData = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wish_url_current' : modalValidate.find('input.current').val(), 'wish_url_current' : modalValidate.find('input.current').val(),
'wish_url_proposed' : modalValidate.find('input.proposed').val(), 'wish_url_proposed' : modalValidate.find('input.proposed').val(),
@ -735,7 +805,8 @@ $(function () {
/** Save form edit fields */ /** Save form edit fields */
/** This code block is a duplicate, please refactor */ /** This code block is a duplicate, please refactor */
var formData = new URLSearchParams(new FormData(formAddOrEdit[0])); var formData = new URLSearchParams(new FormData(formAddOrEdit[0]));
formData.append('api_token', api.token); formData.append('api_token', wishthis.api.token);
formData.append('wishlist_id', wishthis.$_GET.id);
fetch('/?page=api&module=wishes', { fetch('/?page=api&module=wishes', {
method : 'POST', method : 'POST',
@ -748,7 +819,7 @@ $(function () {
return; return;
} }
$('body').toast({ message: text.toast_wish_update }); $('body').toast({ message: wishthis.strings.toast.wish.update });
$('.ui.dropdown.wishlists').api('query'); $('.ui.dropdown.wishlists').api('query');
@ -767,7 +838,8 @@ $(function () {
/** Save form edit fields */ /** Save form edit fields */
/** This code block is a duplicate, please refactor */ /** This code block is a duplicate, please refactor */
var formData = new URLSearchParams(new FormData(formAddOrEdit[0])); var formData = new URLSearchParams(new FormData(formAddOrEdit[0]));
formData.append('api_token', api.token); formData.append('api_token', wishthis.api.token);
formData.append('wishlist_id', wishthis.$_GET.id);
fetch('/?page=api&module=wishes', { fetch('/?page=api&module=wishes', {
method : 'POST', method : 'POST',
@ -780,7 +852,7 @@ $(function () {
return; return;
} }
$('body').toast({ message: text.toast_wish_update }); $('body').toast({ message: wishthis.strings.toast.wish.update });
$('.ui.dropdown.wishlists').api('query'); $('.ui.dropdown.wishlists').api('query');

View file

@ -22,7 +22,7 @@ $(function() {
rules : [ rules : [
{ {
type : 'match[user-password]', type : 'match[user-password]',
prompt : text.form_profile_password prompt : wishthis.strings.form.profile.password
} }
] ]
} }

View file

@ -14,11 +14,11 @@ $(function() {
closable: false, closable: false,
actions : [ actions : [
{ {
text : text.modal_wishlist_warning_approve, text : wishthis.strings.wishlist.warning.approve,
class: 'approve primary' class: 'approve primary'
}, },
{ {
text : text.modal_wishlist_warning_deny, text : wishthis.strings.wishlist.warning.deny,
class: 'deny' class: 'deny'
} }
], ],
@ -47,10 +47,10 @@ $(function() {
action : 'update wish status', action : 'update wish status',
method : 'PUT', method : 'PUT',
data : { data : {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wish_id' : card.attr('data-id'), 'wish_id' : card.attr('data-id'),
'wish_status' : wish_status_temporary, 'wish_status' : wishthis.wish.status.temporary,
}, },
on : 'now', on : 'now',
onSuccess : function(response, element, xhr) { onSuccess : function(response, element, xhr) {
@ -68,10 +68,10 @@ $(function() {
action : 'update wish status', action : 'update wish status',
method : 'PUT', method : 'PUT',
data : { data : {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wish_id' : card.attr('data-id'), 'wish_id' : card.attr('data-id'),
'wish_status' : wish_status_unavailable, 'wish_status' : wishthis.wish.status.unavailable,
}, },
on : 'now', on : 'now',
onSuccess : function(response, element, xhr) { onSuccess : function(response, element, xhr) {
@ -90,7 +90,7 @@ $(function() {
var formData = new URLSearchParams( var formData = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'wishlist' : $('[data-wishlist]').attr('data-wishlist'), 'wishlist' : $('[data-wishlist]').attr('data-wishlist'),
} }
@ -121,7 +121,7 @@ $(function() {
/** Determine if list is saved */ /** Determine if list is saved */
const params_ws_saved = new URLSearchParams( const params_ws_saved = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'module' : 'wishlists-saved', 'module' : 'wishlists-saved',
'page' : 'api', 'page' : 'api',
} }
@ -137,7 +137,7 @@ $(function() {
var buttonSave = $('.button.save'); var buttonSave = $('.button.save');
wishlists.forEach(wishlist => { wishlists.forEach(wishlist => {
if (wishlist.hash == $_GET.hash) { if (wishlist.hash == wishthis.$_GET.hash) {
button_set_saved_state(buttonSave); button_set_saved_state(buttonSave);
return; return;
} }
@ -149,13 +149,13 @@ $(function() {
/** Set default state */ /** Set default state */
function button_set_default_state(buttonSave) { function button_set_default_state(buttonSave) {
buttonSave.find('.icon').removeClass('red'); buttonSave.find('.icon').removeClass('red');
buttonSave.find('span').text(text.button_wishlist_remember); buttonSave.find('span').text(wishthis.strings.button.wishlist.remember);
} }
/** Set saved state */ /** Set saved state */
function button_set_saved_state(buttonSave) { function button_set_saved_state(buttonSave) {
buttonSave.find('.icon').addClass('red'); buttonSave.find('.icon').addClass('red');
buttonSave.find('span').text(text.button_wishlist_forget); buttonSave.find('span').text(wishthis.strings.button.wishlist.forget);
} }
/** /**
@ -168,7 +168,7 @@ $(function() {
var formData = new URLSearchParams( var formData = new URLSearchParams(
{ {
'api_token' : api.token, 'api_token' : wishthis.api.token,
'locale' : wishlist_locale, 'locale' : wishlist_locale,
'wishlist-id' : wishlist_id, 'wishlist-id' : wishlist_id,

View file

@ -343,86 +343,149 @@ class Page
global $options; global $options;
?> ?>
<script type="text/javascript"> <script type="text/javascript">
var locale = '<?= str_replace('_', '-', $this->language) ?>'; var wishthis = {};
var $_GET = JSON.parse('<?= isset($_GET) ? json_encode($_GET) : json_encode(array()) ?>');
var api = { /** General */
wishthis.version = '<?= VERSION ?>';
wishthis.locale = '<?= str_replace('_', '-', $this->language) ?>';
wishthis.$_GET = JSON.parse('<?= isset($_GET) ? json_encode($_GET) : json_encode(array()) ?>');
/** API */
wishthis.api = {
'token' : "<?= $options->getOption('api_token'); ?>", 'token' : "<?= $options->getOption('api_token'); ?>",
}; };
var version = '<?= VERSION ?>';
var wish_status_temporary = '<?= Wish::STATUS_TEMPORARY ?>';
var wish_status_unavailable = '<?= Wish::STATUS_UNAVAILABLE ?>';
var wish_status_fulfilled = '<?= Wish::STATUS_FULFILLED ?>';
var text = {
modal_error_title : '<?= __('Error') ?>',
modal_failure_title : '<?= __('Failure') ?>',
modal_failure_content : '<?= __('The server did not confirm that the action was successful.') ?>',
modal_failure_approve : '<?= __('Thanks for nothing') ?>',
modal_warning_approve : '<?= __('Understood') ?>',
modal_success_title : '<?= __('Success') ?>',
modal_wishlist_warning_approve : '<?= __('Close this tab') ?>', /** Wish */
modal_wishlist_warning_deny : '<?= __('Show wishlist anyway') ?>', wishthis.wish = {
modal_wishlist_delete_title : '<?= __('Really delete?') ?>', 'status' : {
modal_wishlist_delete : '<?= sprintf(__('Do you really want to delete the wishlist %s?'), '<strong>WISHLIST_NAME</strong>') ?>', 'temporary' : '<?= Wish::STATUS_TEMPORARY ?>',
modal_wishlist_delete_approve : '<?= __('Yes, delete') ?>', 'unavailable' : '<?= Wish::STATUS_UNAVAILABLE ?>',
modal_wishlist_delete_deny : '<?= __('No, keep') ?>', 'fulfilled' : '<?= Wish::STATUS_FULFILLED ?>',
}
}
modal_wish_delete_title : '<?= __('Really delete?') ?>', /** Strings */
modal_wish_delete : '<?= __('Would you really like to delete to this wish? It will be gone forever.') ?>', wishthis.strings = {
modal_wish_delete_approve : '<?= __('Yes, delete') ?>', 'modal' : {
modal_wish_delete_deny : '<?= __('No, keep') ?>', 'error' : {
'title' : '<?= __('Error') ?>',
},
'failure' : {
'title' : '<?= __('Failure') ?>',
'content' : '<?= __('The server did not confirm that the action was successful.') ?>',
'approve' : '<?= __('Thanks for nothing') ?>',
},
'warning' : {
'approve' : '<?= __('Understood') ?>',
},
'success' : {
'title' : '<?= __('Success') ?>',
},
form_profile_password : '<?= __('Passwords must match.') ?>', 'wishlist' : {
'warning' : {
'approve' : '<?= __('Close this tab') ?>',
'deny' : '<?= __('Show wishlist anyway') ?>',
},
'delete' : {
'title' : '<?= __('Really delete?') ?>',
'content' : '<?= sprintf(__('Do you really want to delete the wishlist %s?'), '<strong>WISHLIST_NAME</strong>') ?>',
'approve' : '<?= __('Yes, delete') ?>',
'deny' : '<?= __('No, keep') ?>',
},
},
toast_wishlist_rename : '<?= __('Wishlist successfully renamed.') ?>', 'wish' : {
toast_wishlist_delete : '<?= __('Wishlist successfully deleted.') ?>', 'delete' : {
'title' : '<?= __('Really delete?') ?>',
'content' : '<?= __('Would you really like to delete to this wish? It will be gone forever.') ?>',
'approve' : '<?= __('Yes, delete') ?>',
'deny' : '<?= __('No, keep') ?>',
}
}
},
toast_wish_create : '<?= __('Wish successfully created.') ?>', 'form' : {
toast_wish_add : '<?= __('Wish successfully added.') ?>', 'profile' : {
toast_wish_update : '<?= __('Wish information updated.') ?>', 'password' : '<?= __('Passwords must match.') ?>',
toast_wish_save : '<?= __("Don't forget to save your changes.") ?>', },
toast_wish_delete : '<?= __('Wish successfully deleted.') ?>', 'prompt' : {
'empty' : '<?= __('{name} must have a value') ?>',
'checked' : '<?= __('{name} must be checked') ?>',
'email' : '<?= __('{name} must be a valid e-mail') ?>',
'url' : '<?= __('{name} must be a valid URL') ?>',
'regExp' : '<?= __('{name} is not formatted correctly') ?>',
'integer' : '<?= __('{name} must be an integer') ?>',
'decimal' : '<?= __('{name} must be a decimal number') ?>',
'number' : '<?= __('{name} must be set to a number') ?>',
'is' : '<?= __('{name} must be "{ruleValue}"') ?>',
'isExactly' : '<?= __('{name} must be exactly "{ruleValue}"') ?>',
'not' : '<?= __('{name} cannot be set to "{ruleValue}"') ?>',
'notExactly' : '<?= __('{name} cannot be set to exactly "{ruleValue}"') ?>',
'contain' : '<?= __('{name} cannot contain "{ruleValue}"') ?>',
'containExactly' : '<?= __('{name} cannot contain exactly "{ruleValue}"') ?>',
'doesntContain' : '<?= __('{name} must contain "{ruleValue}"') ?>',
'doesntContainExactly' : '<?= __('{name} must contain exactly "{ruleValue}"') ?>',
'minLength' : '<?= __('{name} must be at least {ruleValue} characters') ?>',
'length' : '<?= __('{name} must be at least {ruleValue} characters') ?>',
'exactLength' : '<?= __('{name} must be exactly {ruleValue} characters') ?>',
'maxLength' : '<?= __('{name} cannot be longer than {ruleValue} characters') ?>',
'match' : '<?= __('{name} must match {ruleValue} field') ?>',
'different' : '<?= __('{name} must have a different value than {ruleValue} field') ?>',
'creditCard' : '<?= __('{name} must be a valid credit card number') ?>',
'minCount' : '<?= __('{name} must have at least {ruleValue} choices') ?>',
'exactCount' : '<?= __('{name} must have exactly {ruleValue} choices') ?>',
'maxCount' : '<?= __('{name} must have {ruleValue} or less choices') ?>',
}
},
toast_clipboard_error_title : '<?= __('Error') ?>', 'toast' : {
toast_clipboard_error : '<?= __('Unable to copy to clipboard. There is likely a permission issue.') ?>', 'wishlist' : {
toast_clipboard_success : '<?= __('Link copied to clipboard.') ?>', 'rename' : '<?= __('Wishlist successfully renamed.') ?>',
'delete' : '<?= __('Wishlist successfully deleted.') ?>',
},
form_prompt_empty : '<?= __('{name} must have a value') ?>', 'wish' : {
form_prompt_checked : '<?= __('{name} must be checked') ?>', 'create' : '<?= __('Wish successfully created.') ?>',
form_prompt_email : '<?= __('{name} must be a valid e-mail') ?>', 'update' : '<?= __('Wish information updated.') ?>',
form_prompt_url : '<?= __('{name} must be a valid URL') ?>', 'delete' : '<?= __('Wish successfully deleted.') ?>',
form_prompt_regExp : '<?= __('{name} is not formatted correctly') ?>', },
form_prompt_integer : '<?= __('{name} must be an integer') ?>',
form_prompt_decimal : '<?= __('{name} must be a decimal number') ?>',
form_prompt_number : '<?= __('{name} must be set to a number') ?>',
form_prompt_is : '<?= __('{name} must be "{ruleValue}"') ?>',
form_prompt_isExactly : '<?= __('{name} must be exactly "{ruleValue}"') ?>',
form_prompt_not : '<?= __('{name} cannot be set to "{ruleValue}"') ?>',
form_prompt_notExactly : '<?= __('{name} cannot be set to exactly "{ruleValue}"') ?>',
form_prompt_contain : '<?= __('{name} cannot contain "{ruleValue}"') ?>',
form_prompt_containExactly : '<?= __('{name} cannot contain exactly "{ruleValue}"') ?>',
form_prompt_doesntContain : '<?= __('{name} must contain "{ruleValue}"') ?>',
form_prompt_doesntContainExactly : '<?= __('{name} must contain exactly "{ruleValue}"') ?>',
form_prompt_minLength : '<?= __('{name} must be at least {ruleValue} characters') ?>',
form_prompt_length : '<?= __('{name} must be at least {ruleValue} characters') ?>',
form_prompt_exactLength : '<?= __('{name} must be exactly {ruleValue} characters') ?>',
form_prompt_maxLength : '<?= __('{name} cannot be longer than {ruleValue} characters') ?>',
form_prompt_match : '<?= __('{name} must match {ruleValue} field') ?>',
form_prompt_different : '<?= __('{name} must have a different value than {ruleValue} field') ?>',
form_prompt_creditCard : '<?= __('{name} must be a valid credit card number') ?>',
form_prompt_minCount : '<?= __('{name} must have at least {ruleValue} choices') ?>',
form_prompt_exactCount : '<?= __('{name} must have exactly {ruleValue} choices') ?>',
form_prompt_maxCount : '<?= __('{name} must have {ruleValue} or less choices') ?>',
calendar_today : '<?= _x('Today', 'Calendar') ?>', 'clipboard' : {
calendar_now : '<?= _x('Now', 'Calendar') ?>', 'error' : {
calendar_am : '<?= _x('AM', 'Calendar') ?>', 'title' : '<?= __('Error') ?>',
calendar_pm : '<?= _x('PM', 'Calendar') ?>', 'content' : '<?= __('Unable to copy to clipboard. There is likely a permission issue.') ?>',
calendar_week_no : '<?= _x('Week', 'Calendar') ?>', },
'success' : {
'content' : '<?= __('Link copied to clipboard.') ?>',
},
},
},
button_wishlist_remember : '<?= __('Remember list') ?>', 'calendar' : {
button_wishlist_forget : '<?= __('Forget list') ?>', 'today' : '<?= _x('Today', 'Calendar') ?>',
}; 'now' : '<?= _x('Now', 'Calendar') ?>',
'am' : '<?= _x('AM', 'Calendar') ?>',
'pm' : '<?= _x('PM', 'Calendar') ?>',
'week_no' : '<?= _x('Week', 'Calendar') ?>',
},
'button' : {
'wishlist' : {
'remember' : '<?= __('Remember list') ?>',
'forget' : '<?= __('Forget list') ?>',
}
},
'message' : {
'wishlist' : {
'empty' : {
'header' : '<?= __('Empty') ?>',
'content' : '<?= __('This wishlist seems to be empty.') ?>',
}
}
},
}
</script> </script>
<?php <?php

View file

@ -374,7 +374,7 @@ class Wish
<?php } ?> <?php } ?>
<?php if ($userIsCurrent) { ?> <?php if ($userIsCurrent) { ?>
<div class="ui small labeled icon top left pointing dropdown button options" <div class="ui small labeled icon top left pointing dropdown button wish-options disabled"
title="<?= __('Options') ?>" title="<?= __('Options') ?>"
> >
<i class="cog icon"></i> <i class="cog icon"></i>

View file

@ -51,10 +51,10 @@ class Wishlist
/** /**
* Get Wishes * Get Wishes
*/ */
$this->wishes = $this->getWishes(); // $this->wishes = $this->getWishes();
} }
private function getWishes($sql = array()): array public function getWishes($sql = array()): array
{ {
global $database; global $database;

View file

@ -12,7 +12,7 @@ $scripts = array(
); );
?> ?>
<?php foreach ($scripts as $script) { ?> <?php foreach ($scripts as $script) { ?>
<script defer src="<?= $script ?>?m=<?= filemtime(ROOT . $script) ?>"></script> <script defer src="<?= $script ?>?m=<?= filemtime(ROOT . $script) ?>" preload="preload"></script>
<?php } ?> <?php } ?>
<div> <div>
@ -115,8 +115,6 @@ $scripts = array(
<p><?= __('How would you like to name this wishlist?') ?></p> <p><?= __('How would you like to name this wishlist?') ?></p>
<form class="ui form wishlist-rename"> <form class="ui form wishlist-rename">
<input type="hidden" name="wishlist_id" />
<div class="field"> <div class="field">
<label><?= __('Title') ?></label> <label><?= __('Title') ?></label>
<input type="text" name="wishlist_title" maxlength="128" /> <input type="text" name="wishlist_title" maxlength="128" />
@ -143,8 +141,6 @@ $scripts = array(
<p><?= __('Fill the title and/or description to add your new wish. If you just fill out the URL, wishthis will attempt to auto fill all other fields.') ?></p> <p><?= __('Fill the title and/or description to add your new wish. If you just fill out the URL, wishthis will attempt to auto fill all other fields.') ?></p>
<form class="ui form wishlist-wish-add" method="POST"> <form class="ui form wishlist-wish-add" method="POST">
<input type="hidden" name="wishlist_id" />
<?php include 'wish-add.php' ?> <?php include 'wish-add.php' ?>
<div class="ui error message"></div> <div class="ui error message"></div>
@ -171,7 +167,6 @@ $scripts = array(
<p><?= __('If specified, wishthis will attempt to fetch all missing information from the URL.') ?></p> <p><?= __('If specified, wishthis will attempt to fetch all missing information from the URL.') ?></p>
<form class="ui form wishlist-wish-edit" method="POST"> <form class="ui form wishlist-wish-edit" method="POST">
<input type="hidden" name="wishlist_id" />
<input type="hidden" name="wish_id" /> <input type="hidden" name="wish_id" />
<?php include 'wish-add.php' ?> <?php include 'wish-add.php' ?>

View file

@ -60,7 +60,7 @@ $page->navigation();
<?= __('Share') ?> <?= __('Share') ?>
</a> </a>
<div class="ui labeled icon top left pointing dropdown button options" <div class="ui labeled icon top left pointing dropdown disabled button wishlist-options"
title="<?= __('Options') ?>" title="<?= __('Options') ?>"
> >
<i class="cog icon"></i> <i class="cog icon"></i>