Refactor wishlists api
This commit is contained in:
parent
558b2a1249
commit
7ba0a2c784
16 changed files with 503 additions and 353 deletions
|
@ -41,6 +41,39 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
$response = array(
|
||||
'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;
|
||||
|
||||
|
@ -50,7 +83,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
* Save wish
|
||||
*/
|
||||
if (
|
||||
empty($_POST['wish_title'])
|
||||
empty($_POST['wish_title'])
|
||||
&& empty($_POST['wish_description'])
|
||||
&& empty($_POST['wish_url'])
|
||||
) {
|
||||
|
@ -97,7 +130,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
}
|
||||
|
||||
$response = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -124,8 +157,8 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
* Product
|
||||
*/
|
||||
$wish_price = empty($_POST['wish_price']) || 'false' === $wish_is_purchasable
|
||||
? 'NULL'
|
||||
: Sanitiser::getNumber($_POST['wish_price']);
|
||||
? 'NULL'
|
||||
: Sanitiser::getNumber($_POST['wish_price']);
|
||||
|
||||
$database
|
||||
->query(
|
||||
|
@ -169,7 +202,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
}
|
||||
|
||||
$response = array(
|
||||
'info' => $info,
|
||||
'info' => $info,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,13 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
$options['WHERE'] = '(' . implode(') AND (', $where) . ')';
|
||||
|
||||
$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)) {
|
||||
/**
|
||||
* Get user wishlists
|
||||
|
@ -136,9 +143,6 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
|||
'name' => $wishlist->name,
|
||||
'value' => $wishlist->id,
|
||||
'text' => $wishlist->name,
|
||||
|
||||
'cards' => $wishlist->getCards($options),
|
||||
'hash' => $wishlist->hash,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -523,7 +523,7 @@ body.pushable > .pusher {
|
|||
/**
|
||||
* Options
|
||||
*/
|
||||
.ui.dropdown.options {
|
||||
.ui.dropdown.wish-options {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ $(function() {
|
|||
/**
|
||||
* Tabs
|
||||
*/
|
||||
var current_version_tab = version.replaceAll('.', '-');
|
||||
var current_version_tab = wishthis.version.replaceAll('.', '-');
|
||||
|
||||
$('.menu .item').tab();
|
||||
$('.menu .item').tab('change tab', current_version_tab);
|
||||
|
|
|
@ -10,7 +10,7 @@ if ('serviceWorker' in navigator) {
|
|||
})
|
||||
}
|
||||
|
||||
const urlParams = new URLSearchParams($_GET);
|
||||
const urlParams = new URLSearchParams(wishthis.$_GET);
|
||||
|
||||
$(function() {
|
||||
/**
|
||||
|
@ -18,8 +18,8 @@ $(function() {
|
|||
*/
|
||||
/** API */
|
||||
$.fn.api.settings.api = {
|
||||
'get wishlists' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}',
|
||||
'get wishlists with priority' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}&wishlist_id={wishlistid}&priority={priority}',
|
||||
'get wishlists' : '/?page=api&module=wishlists&api_token={apitoken}',
|
||||
'get wishlists by priority' : '/?page=api&module=wishlists&api_token={apitoken}&style={style}&wishlist_id={wishlistid}&priority={priority}',
|
||||
'delete wishlist' : '/?page=api&module=wishlists',
|
||||
'update wish status' : '/?page=api&module=wishes',
|
||||
'delete wish' : '/?page=api&module=wishes',
|
||||
|
@ -40,8 +40,8 @@ $(function() {
|
|||
values : response.results
|
||||
})
|
||||
|
||||
if ($_GET.id) {
|
||||
element.dropdown('set selected', $_GET.id);
|
||||
if (wishthis.$_GET.id) {
|
||||
element.dropdown('set selected', wishthis.$_GET.id);
|
||||
} else {
|
||||
if (response.results[0]) {
|
||||
element.dropdown('set selected', response.results[0].value);
|
||||
|
@ -62,12 +62,12 @@ $(function() {
|
|||
$('body')
|
||||
.modal({
|
||||
autoShow : true,
|
||||
title : text.modal_failure_title,
|
||||
title : wishthis.strings.modal.failure.title,
|
||||
content : content,
|
||||
class : 'small',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_failure_approve,
|
||||
text : wishthis.strings.modal.failure.approve,
|
||||
class : 'primary'
|
||||
}
|
||||
]
|
||||
|
@ -80,12 +80,12 @@ $(function() {
|
|||
|
||||
$('body')
|
||||
.modal({
|
||||
title : text.modal_error_title,
|
||||
title : wishthis.strings.modal.error.title,
|
||||
content : response,
|
||||
class : 'small',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_failure_approve,
|
||||
text : wishthis.strings.modal.failure.approve,
|
||||
class: 'primary'
|
||||
}
|
||||
],
|
||||
|
@ -100,36 +100,36 @@ $(function() {
|
|||
$.fn.toast.settings.showProgress = 'bottom';
|
||||
$.fn.toast.settings.class = 'success';
|
||||
$.fn.toast.settings.showIcon = true;
|
||||
$.fn.toast.settings.title = text.modal_success_title;
|
||||
$.fn.toast.settings.title = wishthis.strings.modal.success.title;
|
||||
|
||||
/** Form Prompts */
|
||||
$.fn.form.settings.prompt = {
|
||||
empty : text.form_prompt_empty,
|
||||
checked : text.form_prompt_checked,
|
||||
email : text.form_prompt_email,
|
||||
url : text.form_prompt_url,
|
||||
regExp : text.form_prompt_regExp,
|
||||
integer : text.form_prompt_integer,
|
||||
decimal : text.form_prompt_decimal,
|
||||
number : text.form_prompt_number,
|
||||
is : text.form_prompt_is,
|
||||
isExactly : text.form_prompt_isExactly,
|
||||
not : text.form_prompt_not,
|
||||
notExactly : text.form_prompt_notExactly,
|
||||
contain : text.form_prompt_contain,
|
||||
containExactly : text.form_prompt_containExactly,
|
||||
doesntContain : text.form_prompt_doesntContain,
|
||||
doesntContainExactly : text.form_prompt_doesntContainExactly,
|
||||
minLength : text.form_prompt_minLength,
|
||||
length : text.form_prompt_length,
|
||||
exactLength : text.form_prompt_exactLength,
|
||||
maxLength : text.form_prompt_maxLength,
|
||||
match : text.form_prompt_match,
|
||||
different : text.form_prompt_different,
|
||||
creditCard : text.form_prompt_creditCard,
|
||||
minCount : text.form_prompt_minCount,
|
||||
exactCount : text.form_prompt_exactCount,
|
||||
maxCount : text.form_prompt_maxCount,
|
||||
empty : wishthis.strings.form.prompt.empty,
|
||||
checked : wishthis.strings.form.prompt.checked,
|
||||
email : wishthis.strings.form.prompt.email,
|
||||
url : wishthis.strings.form.prompt.url,
|
||||
regExp : wishthis.strings.form.prompt.regExp,
|
||||
integer : wishthis.strings.form.prompt.integer,
|
||||
decimal : wishthis.strings.form.prompt.decimal,
|
||||
number : wishthis.strings.form.prompt.number,
|
||||
is : wishthis.strings.form.prompt.is,
|
||||
isExactly : wishthis.strings.form.prompt.isExactly,
|
||||
not : wishthis.strings.form.prompt.not,
|
||||
notExactly : wishthis.strings.form.prompt.notExactly,
|
||||
contain : wishthis.strings.form.prompt.contain,
|
||||
containExactly : wishthis.strings.form.prompt.containExactly,
|
||||
doesntContain : wishthis.strings.form.prompt.doesntContain,
|
||||
doesntContainExactly : wishthis.strings.form.prompt.doesntContainExactly,
|
||||
minLength : wishthis.strings.form.prompt.minLength,
|
||||
length : wishthis.strings.form.prompt.length,
|
||||
exactLength : wishthis.strings.form.prompt.exactLength,
|
||||
maxLength : wishthis.strings.form.prompt.maxLength,
|
||||
match : wishthis.strings.form.prompt.match,
|
||||
different : wishthis.strings.form.prompt.different,
|
||||
creditCard : wishthis.strings.form.prompt.creditCard,
|
||||
minCount : wishthis.strings.form.prompt.minCount,
|
||||
exactCount : wishthis.strings.form.prompt.exactCount,
|
||||
maxCount : wishthis.strings.form.prompt.maxCount,
|
||||
};
|
||||
|
||||
/** Calendar Text */
|
||||
|
@ -147,47 +147,47 @@ $(function() {
|
|||
};
|
||||
|
||||
$.fn.calendar.settings.text.days = [
|
||||
new Date(2018, 00, 00).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 01).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 02).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 03).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 04).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 05).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 06).toLocaleString(locale, options_weekday),
|
||||
new Date(2018, 00, 00).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 01).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 02).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 03).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 04).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 05).toLocaleString(wishthis.locale, options_weekday),
|
||||
new Date(2018, 00, 06).toLocaleString(wishthis.locale, options_weekday),
|
||||
];
|
||||
$.fn.calendar.settings.text.months = [
|
||||
new Date(0000, 01, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 02, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 03, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 04, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 05, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 06, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 07, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 08, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 09, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 10, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 11, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 12, 00).toLocaleString(locale, options_months),
|
||||
new Date(0000, 01, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 02, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 03, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 04, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 05, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 06, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 07, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 08, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 09, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 10, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 11, 00).toLocaleString(wishthis.locale, options_months),
|
||||
new Date(0000, 12, 00).toLocaleString(wishthis.locale, options_months),
|
||||
];
|
||||
$.fn.calendar.settings.text.monthsShort = [
|
||||
new Date(0000, 01, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 02, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 03, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 04, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 05, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 06, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 07, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 08, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 09, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 10, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 11, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 12, 00).toLocaleString(locale, options_months_short),
|
||||
new Date(0000, 01, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 02, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 03, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 04, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 05, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 06, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 07, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 08, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 09, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 10, 00).toLocaleString(wishthis.locale, options_months_short),
|
||||
new Date(0000, 11, 00).toLocaleString(wishthis.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.now = text.calendar_now;
|
||||
$.fn.calendar.settings.text.am = text.calendar_am;
|
||||
$.fn.calendar.settings.text.pm = text.calendar_pm;
|
||||
$.fn.calendar.settings.text.weekNo = text.calendar_week_no;
|
||||
$.fn.calendar.settings.text.today = wishthis.strings.calendar.today;
|
||||
$.fn.calendar.settings.text.now = wishthis.strings.calendar.now;
|
||||
$.fn.calendar.settings.text.am = wishthis.strings.calendar.am;
|
||||
$.fn.calendar.settings.text.pm = wishthis.strings.calendar.pm;
|
||||
$.fn.calendar.settings.text.weekNo = wishthis.strings.calendar.week_no;
|
||||
|
||||
/** Dimmer */
|
||||
$.fn.dimmer.settings.closable = false;
|
||||
|
@ -253,7 +253,7 @@ function showError(error) {
|
|||
class : 'small',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_failure_approve,
|
||||
text : wishthis.strings.modal.failure.approve,
|
||||
class : 'primary'
|
||||
}
|
||||
],
|
||||
|
@ -272,7 +272,7 @@ function showWarning(warning) {
|
|||
class : 'small',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_warning_approve,
|
||||
text : wishthis.strings.modal.warning.approve,
|
||||
class : 'primary'
|
||||
}
|
||||
],
|
||||
|
|
|
@ -4,7 +4,7 @@ $(function() {
|
|||
*/
|
||||
const params_statistics = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'statistics',
|
||||
'page' : 'api',
|
||||
|
||||
|
@ -68,7 +68,7 @@ $(function() {
|
|||
*/
|
||||
const params_news = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'blog',
|
||||
'page' : 'api',
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ window.addEventListener("load", (event) => {
|
|||
.then(canvas => {
|
||||
var data = new URLSearchParams();
|
||||
data.append('preview', canvas.toDataURL());
|
||||
data.append('api_token', api.token);
|
||||
data.append('page', $_GET.page);
|
||||
data.append('api_token', wishthis.api.token);
|
||||
data.append('page', wishthis.$_GET.page);
|
||||
|
||||
/** Save page preview */
|
||||
fetch('/?page=api&module=save-preview', {
|
||||
|
|
|
@ -8,32 +8,15 @@ $(function () {
|
|||
match : 'text',
|
||||
fullTextSearch : true,
|
||||
})
|
||||
.dropdown('set selected', -1)
|
||||
.api({
|
||||
'action' : 'get wishlists with priority',
|
||||
'action' : 'get wishlists by priority',
|
||||
'urlData' : {
|
||||
'apitoken' : api.token,
|
||||
'apitoken' : wishthis.api.token,
|
||||
},
|
||||
beforeSend : function (settings) {
|
||||
settings.urlData.style = $('input[name="style"]').val();
|
||||
settings.urlData.priority = $('.ui.dropdown.filter.priority').dropdown('get value');
|
||||
|
||||
/** 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;
|
||||
}
|
||||
/** */
|
||||
settings.urlData.wishlistid = wishthis.$_GET.id;
|
||||
|
||||
return settings;
|
||||
},
|
||||
|
@ -41,10 +24,10 @@ $(function () {
|
|||
var html = response.results ? response.results : '';
|
||||
|
||||
$('.wishlist-cards').html(html);
|
||||
$('.ui.dropdown.options').dropdown();
|
||||
$('.ui.dropdown.wish-options').dropdown().removeClass('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
.dropdown('set selected', -1);
|
||||
|
||||
/**
|
||||
* Style
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
$(function () {
|
||||
/**
|
||||
* General
|
||||
*/
|
||||
var wishlist = {
|
||||
'id' : $_GET.id
|
||||
};
|
||||
|
||||
/**
|
||||
* Progress
|
||||
*/
|
||||
|
@ -20,45 +13,42 @@ $(function () {
|
|||
/**
|
||||
* Get Wishlists
|
||||
*/
|
||||
var wishlists = [];
|
||||
|
||||
$('.ui.dropdown.wishlists')
|
||||
.dropdown()
|
||||
.api({
|
||||
var wishlists = [];
|
||||
var wishlists_api = {
|
||||
'action' : 'get wishlists',
|
||||
'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) {
|
||||
/** Set wishlists */
|
||||
onSuccess : function(response, dropdown_wishlists, xhr) {
|
||||
/** Save response for later use */
|
||||
wishlists = response.results;
|
||||
|
||||
dropdown_wishlists.dropdown({
|
||||
/** Setup and populate dropdown */
|
||||
var dropdown_values = {
|
||||
'values' : wishlists,
|
||||
})
|
||||
};
|
||||
|
||||
/** Select current/active wishlist */
|
||||
if (wishlist.id) {
|
||||
dropdown_wishlists.dropdown('set selected', wishlist.id);
|
||||
} else {
|
||||
if (Object.keys(wishlists).length >= 1) {
|
||||
var first_wishlist_id = Object.keys(wishlists)[0];
|
||||
dropdown_wishlists.dropdown('setup menu', dropdown_values);
|
||||
|
||||
dropdown_wishlists.dropdown('set selected', first_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 {
|
||||
if (Object.keys(wishlists).length >= 1) {
|
||||
var first_wishlist_id = Object.keys(wishlists)[0];
|
||||
|
||||
dropdown_wishlists.dropdown('set selected', first_wishlist_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Open add wish modal */
|
||||
if ($_GET.wish_add) {
|
||||
if (wishthis.$_GET.wish_add) {
|
||||
$('.button.wishlist-wish-add').trigger('click');
|
||||
}
|
||||
|
||||
/** Filter wishes */
|
||||
/** Set wishlist style */
|
||||
const orientationIsPortrait = window.matchMedia('(orientation: portrait)');
|
||||
|
||||
if (orientationIsPortrait.matches) {
|
||||
|
@ -66,108 +56,182 @@ $(function () {
|
|||
} else {
|
||||
$('.buttons.view .button[value="grid"]').trigger('click');
|
||||
}
|
||||
}
|
||||
})
|
||||
.api('query');
|
||||
},
|
||||
};
|
||||
|
||||
$(document).on('change', '.ui.dropdown.wishlists', function () {
|
||||
return;
|
||||
$('.ui.dropdown.wishlists')
|
||||
.dropdown({
|
||||
onChange : function(wishlist_id, text, $choice) {
|
||||
wishthis.$_GET.id = wishlist_id;
|
||||
|
||||
var wishlist_id = $('.ui.dropdown.wishlists').dropdown('get value');
|
||||
if (wishlist_id) {
|
||||
/** Get wishlist */
|
||||
const get_wishlist = new URLSearchParams(
|
||||
{
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishlists',
|
||||
'page' : 'api',
|
||||
|
||||
if (wishlist_id) {
|
||||
wishlist.id = wishlist_id;
|
||||
'wishlist_id' : wishlist_id,
|
||||
}
|
||||
);
|
||||
fetch('/?' + get_wishlist, { method: 'GET' })
|
||||
.then(handleFetchError)
|
||||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
var wishlist;
|
||||
|
||||
$('.wishlist-share').attr('href', '/?page=wishlist&hash=' + wishlists[wishlist_id].hash);
|
||||
/** Set current wishlist */
|
||||
wishlist = response.results;
|
||||
|
||||
$('.button.wishlist-wish-add').removeClass('disabled');
|
||||
$('.button.wishlist-share').removeClass('disabled');
|
||||
$('.wishlist-rename').removeClass('disabled');
|
||||
$('.wishlist-delete').removeClass('disabled');
|
||||
/** Set share link */
|
||||
$('.wishlist-share').attr('href', '/?page=wishlist&hash=' + wishlist.hash);
|
||||
|
||||
/** Update URL */
|
||||
urlParams.set('id', wishlist_id);
|
||||
/** Enable wishlist options buttons */
|
||||
$('.button.wishlist-wish-add').removeClass('disabled');
|
||||
$('.button.wishlist-share').removeClass('disabled');
|
||||
$('.button.wishlist-options').removeClass('disabled').dropdown();
|
||||
$('.wishlist-rename').removeClass('disabled');
|
||||
$('.wishlist-delete').removeClass('disabled');
|
||||
|
||||
const params_url = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'module' : 'url',
|
||||
'page' : 'api',
|
||||
/** Update URL */
|
||||
urlParams.set('id', wishlist_id);
|
||||
|
||||
'url' : window.btoa(urlParams.toString()),
|
||||
}
|
||||
);
|
||||
fetch('/?' + params_url, {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(handleFetchError)
|
||||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
window.history.pushState(null, document.title, response.data.url_pretty);
|
||||
const params_url = new URLSearchParams(
|
||||
{
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'url',
|
||||
'page' : 'api',
|
||||
|
||||
$('.ui.dropdown.filter.priority')
|
||||
.dropdown('restore default value')
|
||||
.dropdown('restore default text')
|
||||
.dropdown('set selected', -1);
|
||||
});
|
||||
} else {
|
||||
$('.button.wishlist-wish-add').addClass('disabled');
|
||||
$('.button.wishlist-share').addClass('disabled');
|
||||
$('.wishlist-rename').addClass('disabled');
|
||||
$('.wishlist-delete').addClass('disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Cards
|
||||
*/
|
||||
if (wishlist.id) {
|
||||
$('.wishlist-cards').html(wishlists[wishlist.id].cards);
|
||||
} else {
|
||||
$('.wishlist-cards').html('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate cache
|
||||
*/
|
||||
var cards = $('.ui.card[data-cache="true"]');
|
||||
|
||||
if (cards.length > 0) {
|
||||
progress.slideDown();
|
||||
progress.progress('reset');
|
||||
progress.progress('set total', cards.length);
|
||||
}
|
||||
|
||||
var timerInterval = 1200;
|
||||
var timerCache = setTimeout(
|
||||
function generateCacheCards() {
|
||||
var cards = $('.ui.card[data-cache="true"]');
|
||||
|
||||
if (cards.length > 0) {
|
||||
cards.each(function (index, card) {
|
||||
generateCacheCard($(card));
|
||||
|
||||
if (index >= 0) {
|
||||
return false;
|
||||
'url' : window.btoa(urlParams.toString()),
|
||||
}
|
||||
);
|
||||
fetch('/?' + params_url, {
|
||||
method: 'GET'
|
||||
})
|
||||
.then(handleFetchError)
|
||||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
window.history.pushState(null, document.title, response.data.url_pretty);
|
||||
});
|
||||
|
||||
setTimeout(generateCacheCards, timerInterval);
|
||||
}
|
||||
},
|
||||
0
|
||||
);
|
||||
/** Get wishlist cards/wishes */
|
||||
|
||||
$('.ui.dropdown.options').dropdown({
|
||||
onChange: function(value, text, choice) {
|
||||
var dropdownOptions = $(this);
|
||||
/**
|
||||
* Trigger priorities dropdown
|
||||
*/
|
||||
// $('.ui.dropdown.filter.priority').api('query');
|
||||
/** */
|
||||
/*
|
||||
const get_wishes = new URLSearchParams(
|
||||
{
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishes',
|
||||
'page' : 'api',
|
||||
|
||||
setTimeout(function() {
|
||||
dropdownOptions.dropdown('restore defaults', true);
|
||||
}, 0);
|
||||
'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 {
|
||||
$('.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
|
||||
*//*
|
||||
var cards = $('.ui.card[data-cache="true"]');
|
||||
|
||||
if (cards.length > 0) {
|
||||
progress.slideDown();
|
||||
progress.progress('reset');
|
||||
progress.progress('set total', cards.length);
|
||||
}
|
||||
|
||||
var timerInterval = 1200;
|
||||
var timerCache = setTimeout(
|
||||
function generateCacheCards() {
|
||||
var cards = $('.ui.card[data-cache="true"]');
|
||||
|
||||
if (cards.length > 0) {
|
||||
cards.each(function (index, card) {
|
||||
generateCacheCard($(card));
|
||||
|
||||
if (index >= 0) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(generateCacheCards, timerInterval);
|
||||
}
|
||||
},
|
||||
0
|
||||
);
|
||||
|
||||
$('.ui.dropdown.options').dropdown({
|
||||
onChange: function(value, text, choice) {
|
||||
var dropdownOptions = $(this);
|
||||
|
||||
setTimeout(function() {
|
||||
dropdownOptions.dropdown('restore defaults', true);
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
*/
|
||||
},
|
||||
})
|
||||
.api(wishlists_api)
|
||||
.api('query');
|
||||
|
||||
/*
|
||||
function generateCacheCard(card) {
|
||||
var href = card.find('.content [href]').prop('href');
|
||||
|
||||
|
@ -183,7 +247,7 @@ $(function () {
|
|||
|
||||
const params_cache = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishes',
|
||||
'page' : 'api',
|
||||
|
||||
|
@ -213,6 +277,7 @@ $(function () {
|
|||
$('.ui.dropdown.options').dropdown();
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Share Wishlist
|
||||
|
@ -222,13 +287,17 @@ $(function () {
|
|||
|
||||
var wishlist_href = window.location.origin + $(event.currentTarget).attr('href');
|
||||
|
||||
navigator.clipboard.writeText(wishlist_href).then(function() {
|
||||
$('body').toast({ message: text.toast_clipboard_success });
|
||||
navigator.clipboard
|
||||
.writeText(wishlist_href)
|
||||
.then(function() {
|
||||
$('body').toast({
|
||||
'message' : wishthis.strings.toast.clipboard.success.content,
|
||||
});
|
||||
}, function() {
|
||||
$('body').toast({
|
||||
class : 'error',
|
||||
title : text.toast_clipboard_error_title,
|
||||
message : text.toast_clipboard_error
|
||||
'class' : 'error',
|
||||
'title' : wishthis.strings.toast.clipboard.error.title,
|
||||
'message' : wishthis.strings.toast.clipboard.error.content,
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -244,7 +313,8 @@ $(function () {
|
|||
|
||||
var formRename = modalRename.find('.form.wishlist-rename');
|
||||
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', {
|
||||
method : 'PUT',
|
||||
|
@ -257,7 +327,7 @@ $(function () {
|
|||
|
||||
modalRename.modal('hide');
|
||||
|
||||
$('body').toast({ message: text.toast_wishlist_rename });
|
||||
$('body').toast({ message: wishthis.strings.toast.wishlist.rename });
|
||||
})
|
||||
.catch(handleFetchCatch)
|
||||
.finally(function() {
|
||||
|
@ -275,7 +345,7 @@ $(function () {
|
|||
wishlistRenameApprove(buttonApprove);
|
||||
});
|
||||
|
||||
$(document).on('click', '.options .wishlist-rename', function() {
|
||||
$(document).on('click', '.wishlist-options .wishlist-rename', function() {
|
||||
var modalRename = $('.modal.wishlist-rename');
|
||||
var inputID = modalRename.find('[name="wishlist_id"]');
|
||||
var inputTitle = modalRename.find('[name="wishlist_title"]');
|
||||
|
@ -306,16 +376,16 @@ $(function () {
|
|||
|
||||
modalDefault
|
||||
.modal({
|
||||
title : text.modal_wishlist_delete_title,
|
||||
title : wishthis.strings.wishlist.delete.title,
|
||||
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 : [
|
||||
{
|
||||
text : text.modal_wishlist_delete_approve,
|
||||
text : wishthis.strings.wishlist.delete.approve,
|
||||
class: 'approve red'
|
||||
},
|
||||
{
|
||||
text : text.modal_wishlist_delete_deny,
|
||||
text : wishthis.strings.wishlist.delete.deny,
|
||||
class: 'deny'
|
||||
},
|
||||
],
|
||||
|
@ -327,7 +397,7 @@ $(function () {
|
|||
action: 'delete wishlist',
|
||||
method: 'DELETE',
|
||||
data: {
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wishlistID' : wishlist_id
|
||||
},
|
||||
|
@ -339,7 +409,7 @@ $(function () {
|
|||
|
||||
urlParams.delete('id');
|
||||
|
||||
$('body').toast({ message:text.toast_wishlist_delete });
|
||||
$('body').toast({ message : wishthis.strings.toast.wishlist.delete });
|
||||
|
||||
modalDefault.modal('hide');
|
||||
|
||||
|
@ -372,10 +442,10 @@ $(function () {
|
|||
action : 'update wish status',
|
||||
method : 'PUT',
|
||||
data : {
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wish_id' : card.attr('data-id'),
|
||||
'wish_status' : wish_status_fulfilled,
|
||||
'wish_status' : wishthis.strings.wish.status.fulfilled,
|
||||
},
|
||||
on : 'now',
|
||||
onSuccess : function(response, element, xhr) {
|
||||
|
@ -415,7 +485,7 @@ $(function () {
|
|||
|
||||
var wishFormData = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishes',
|
||||
'page' : 'api',
|
||||
|
||||
|
@ -481,16 +551,16 @@ $(function () {
|
|||
|
||||
modalDefault
|
||||
.modal({
|
||||
title : text.modal_wish_delete_title,
|
||||
content : text.modal_wish_delete,
|
||||
title : wishthis.strings.wish.delete.title,
|
||||
content : wishthis.strings.wish.delete.content,
|
||||
class : 'tiny',
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_wish_delete_approve,
|
||||
text : wishthis.strings.wish.delete.approve,
|
||||
class: 'approve primary'
|
||||
},
|
||||
{
|
||||
text: text.modal_wish_delete_deny
|
||||
text: wishthis.strings.wish.delete.deny
|
||||
}
|
||||
],
|
||||
autoShow : true,
|
||||
|
@ -504,7 +574,7 @@ $(function () {
|
|||
action : 'delete wish',
|
||||
method : 'DELETE',
|
||||
data : {
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wish_id': card.attr('data-id'),
|
||||
},
|
||||
|
@ -512,7 +582,7 @@ $(function () {
|
|||
onSuccess : function () {
|
||||
column.fadeOut(800);
|
||||
|
||||
$('body').toast({ message: text.toast_wish_delete });
|
||||
$('body').toast({ message: wishthis.strings.toast.wish.delete });
|
||||
|
||||
modalDefault.modal('hide');
|
||||
|
||||
|
@ -570,7 +640,7 @@ $(function () {
|
|||
onHide : function() {
|
||||
/** Ugly URL */
|
||||
if (urlParams.has('wish_add')) {
|
||||
delete($_GET.wish_add);
|
||||
delete(wishthis.$_GET.wish_add);
|
||||
urlParams.delete('wish_add');
|
||||
|
||||
window.history.pushState(null, document.title, '?' + urlParams.toString());
|
||||
|
@ -608,7 +678,7 @@ $(function () {
|
|||
buttonCreate.addClass('loading');
|
||||
|
||||
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', {
|
||||
method : 'POST',
|
||||
|
@ -621,7 +691,7 @@ $(function () {
|
|||
|
||||
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');
|
||||
})
|
||||
|
@ -665,7 +735,7 @@ $(function () {
|
|||
if (wishURLCurrent) {
|
||||
const params_url = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishes',
|
||||
'page' : 'api',
|
||||
|
||||
|
@ -705,7 +775,7 @@ $(function () {
|
|||
|
||||
const formData = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wish_url_current' : modalValidate.find('input.current').val(),
|
||||
'wish_url_proposed' : modalValidate.find('input.proposed').val(),
|
||||
|
@ -735,7 +805,8 @@ $(function () {
|
|||
/** Save form edit fields */
|
||||
/** This code block is a duplicate, please refactor */
|
||||
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', {
|
||||
method : 'POST',
|
||||
|
@ -748,7 +819,7 @@ $(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
$('body').toast({ message: text.toast_wish_update });
|
||||
$('body').toast({ message: wishthis.strings.toast.wish.update });
|
||||
|
||||
$('.ui.dropdown.wishlists').api('query');
|
||||
|
||||
|
@ -767,7 +838,8 @@ $(function () {
|
|||
/** Save form edit fields */
|
||||
/** This code block is a duplicate, please refactor */
|
||||
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', {
|
||||
method : 'POST',
|
||||
|
@ -780,7 +852,7 @@ $(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
$('body').toast({ message: text.toast_wish_update });
|
||||
$('body').toast({ message: wishthis.strings.toast.wish.update });
|
||||
|
||||
$('.ui.dropdown.wishlists').api('query');
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ $(function() {
|
|||
rules : [
|
||||
{
|
||||
type : 'match[user-password]',
|
||||
prompt : text.form_profile_password
|
||||
prompt : wishthis.strings.form.profile.password
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ $(function() {
|
|||
closable: false,
|
||||
actions : [
|
||||
{
|
||||
text : text.modal_wishlist_warning_approve,
|
||||
text : wishthis.strings.wishlist.warning.approve,
|
||||
class: 'approve primary'
|
||||
},
|
||||
{
|
||||
text : text.modal_wishlist_warning_deny,
|
||||
text : wishthis.strings.wishlist.warning.deny,
|
||||
class: 'deny'
|
||||
}
|
||||
],
|
||||
|
@ -47,10 +47,10 @@ $(function() {
|
|||
action : 'update wish status',
|
||||
method : 'PUT',
|
||||
data : {
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wish_id' : card.attr('data-id'),
|
||||
'wish_status' : wish_status_temporary,
|
||||
'wish_status' : wishthis.wish.status.temporary,
|
||||
},
|
||||
on : 'now',
|
||||
onSuccess : function(response, element, xhr) {
|
||||
|
@ -68,10 +68,10 @@ $(function() {
|
|||
action : 'update wish status',
|
||||
method : 'PUT',
|
||||
data : {
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wish_id' : card.attr('data-id'),
|
||||
'wish_status' : wish_status_unavailable,
|
||||
'wish_status' : wishthis.wish.status.unavailable,
|
||||
},
|
||||
on : 'now',
|
||||
onSuccess : function(response, element, xhr) {
|
||||
|
@ -90,7 +90,7 @@ $(function() {
|
|||
|
||||
var formData = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'wishlist' : $('[data-wishlist]').attr('data-wishlist'),
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ $(function() {
|
|||
/** Determine if list is saved */
|
||||
const params_ws_saved = new URLSearchParams(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
'module' : 'wishlists-saved',
|
||||
'page' : 'api',
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ $(function() {
|
|||
var buttonSave = $('.button.save');
|
||||
|
||||
wishlists.forEach(wishlist => {
|
||||
if (wishlist.hash == $_GET.hash) {
|
||||
if (wishlist.hash == wishthis.$_GET.hash) {
|
||||
button_set_saved_state(buttonSave);
|
||||
return;
|
||||
}
|
||||
|
@ -149,13 +149,13 @@ $(function() {
|
|||
/** Set default state */
|
||||
function button_set_default_state(buttonSave) {
|
||||
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 */
|
||||
function button_set_saved_state(buttonSave) {
|
||||
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(
|
||||
{
|
||||
'api_token' : api.token,
|
||||
'api_token' : wishthis.api.token,
|
||||
|
||||
'locale' : wishlist_locale,
|
||||
'wishlist-id' : wishlist_id,
|
||||
|
|
|
@ -343,86 +343,149 @@ class Page
|
|||
global $options;
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var locale = '<?= str_replace('_', '-', $this->language) ?>';
|
||||
var $_GET = JSON.parse('<?= isset($_GET) ? json_encode($_GET) : json_encode(array()) ?>');
|
||||
var api = {
|
||||
var wishthis = {};
|
||||
|
||||
/** 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'); ?>",
|
||||
};
|
||||
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') ?>',
|
||||
modal_wishlist_warning_deny : '<?= __('Show wishlist anyway') ?>',
|
||||
modal_wishlist_delete_title : '<?= __('Really delete?') ?>',
|
||||
modal_wishlist_delete : '<?= sprintf(__('Do you really want to delete the wishlist %s?'), '<strong>WISHLIST_NAME</strong>') ?>',
|
||||
modal_wishlist_delete_approve : '<?= __('Yes, delete') ?>',
|
||||
modal_wishlist_delete_deny : '<?= __('No, keep') ?>',
|
||||
/** Wish */
|
||||
wishthis.wish = {
|
||||
'status' : {
|
||||
'temporary' : '<?= Wish::STATUS_TEMPORARY ?>',
|
||||
'unavailable' : '<?= Wish::STATUS_UNAVAILABLE ?>',
|
||||
'fulfilled' : '<?= Wish::STATUS_FULFILLED ?>',
|
||||
}
|
||||
}
|
||||
|
||||
modal_wish_delete_title : '<?= __('Really delete?') ?>',
|
||||
modal_wish_delete : '<?= __('Would you really like to delete to this wish? It will be gone forever.') ?>',
|
||||
modal_wish_delete_approve : '<?= __('Yes, delete') ?>',
|
||||
modal_wish_delete_deny : '<?= __('No, keep') ?>',
|
||||
/** Strings */
|
||||
wishthis.strings = {
|
||||
'modal' : {
|
||||
'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.') ?>',
|
||||
toast_wishlist_delete : '<?= __('Wishlist successfully deleted.') ?>',
|
||||
'wish' : {
|
||||
'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.') ?>',
|
||||
toast_wish_add : '<?= __('Wish successfully added.') ?>',
|
||||
toast_wish_update : '<?= __('Wish information updated.') ?>',
|
||||
toast_wish_save : '<?= __("Don't forget to save your changes.") ?>',
|
||||
toast_wish_delete : '<?= __('Wish successfully deleted.') ?>',
|
||||
'form' : {
|
||||
'profile' : {
|
||||
'password' : '<?= __('Passwords must match.') ?>',
|
||||
},
|
||||
'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_clipboard_error : '<?= __('Unable to copy to clipboard. There is likely a permission issue.') ?>',
|
||||
toast_clipboard_success : '<?= __('Link copied to clipboard.') ?>',
|
||||
'toast' : {
|
||||
'wishlist' : {
|
||||
'rename' : '<?= __('Wishlist successfully renamed.') ?>',
|
||||
'delete' : '<?= __('Wishlist successfully deleted.') ?>',
|
||||
},
|
||||
|
||||
form_prompt_empty : '<?= __('{name} must have a value') ?>',
|
||||
form_prompt_checked : '<?= __('{name} must be checked') ?>',
|
||||
form_prompt_email : '<?= __('{name} must be a valid e-mail') ?>',
|
||||
form_prompt_url : '<?= __('{name} must be a valid URL') ?>',
|
||||
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') ?>',
|
||||
'wish' : {
|
||||
'create' : '<?= __('Wish successfully created.') ?>',
|
||||
'update' : '<?= __('Wish information updated.') ?>',
|
||||
'delete' : '<?= __('Wish successfully deleted.') ?>',
|
||||
},
|
||||
|
||||
calendar_today : '<?= _x('Today', 'Calendar') ?>',
|
||||
calendar_now : '<?= _x('Now', 'Calendar') ?>',
|
||||
calendar_am : '<?= _x('AM', 'Calendar') ?>',
|
||||
calendar_pm : '<?= _x('PM', 'Calendar') ?>',
|
||||
calendar_week_no : '<?= _x('Week', 'Calendar') ?>',
|
||||
'clipboard' : {
|
||||
'error' : {
|
||||
'title' : '<?= __('Error') ?>',
|
||||
'content' : '<?= __('Unable to copy to clipboard. There is likely a permission issue.') ?>',
|
||||
},
|
||||
'success' : {
|
||||
'content' : '<?= __('Link copied to clipboard.') ?>',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
button_wishlist_remember : '<?= __('Remember list') ?>',
|
||||
button_wishlist_forget : '<?= __('Forget list') ?>',
|
||||
};
|
||||
'calendar' : {
|
||||
'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>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -374,7 +374,7 @@ class Wish
|
|||
<?php } ?>
|
||||
|
||||
<?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') ?>"
|
||||
>
|
||||
<i class="cog icon"></i>
|
||||
|
|
|
@ -51,10 +51,10 @@ class Wishlist
|
|||
/**
|
||||
* Get Wishes
|
||||
*/
|
||||
$this->wishes = $this->getWishes();
|
||||
// $this->wishes = $this->getWishes();
|
||||
}
|
||||
|
||||
private function getWishes($sql = array()): array
|
||||
public function getWishes($sql = array()): array
|
||||
{
|
||||
global $database;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ $scripts = array(
|
|||
);
|
||||
?>
|
||||
<?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 } ?>
|
||||
|
||||
<div>
|
||||
|
@ -115,8 +115,6 @@ $scripts = array(
|
|||
<p><?= __('How would you like to name this wishlist?') ?></p>
|
||||
|
||||
<form class="ui form wishlist-rename">
|
||||
<input type="hidden" name="wishlist_id" />
|
||||
|
||||
<div class="field">
|
||||
<label><?= __('Title') ?></label>
|
||||
<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>
|
||||
|
||||
<form class="ui form wishlist-wish-add" method="POST">
|
||||
<input type="hidden" name="wishlist_id" />
|
||||
|
||||
<?php include 'wish-add.php' ?>
|
||||
|
||||
<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>
|
||||
|
||||
<form class="ui form wishlist-wish-edit" method="POST">
|
||||
<input type="hidden" name="wishlist_id" />
|
||||
<input type="hidden" name="wish_id" />
|
||||
|
||||
<?php include 'wish-add.php' ?>
|
||||
|
|
|
@ -60,7 +60,7 @@ $page->navigation();
|
|||
<?= __('Share') ?>
|
||||
</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') ?>"
|
||||
>
|
||||
<i class="cog icon"></i>
|
||||
|
|
Loading…
Reference in a new issue