wishthis/src/assets/js/profile.js

92 lines
2.5 KiB
JavaScript
Raw Normal View History

2022-03-15 09:43:53 +00:00
$(function() {
2022-04-05 18:01:56 +00:00
$('.menu.profile .item').tab();
2022-03-15 09:43:53 +00:00
$('.ui.calendar').calendar({
2022-03-23 09:33:04 +00:00
type : 'date',
firstDayOfWeek : 1,
startMode : 'year'
2022-03-15 09:43:53 +00:00
});
$('.ui.form').form({
fields: {
2022-04-07 09:37:44 +00:00
'user-email' : 'email',
'user-password' : ['minLength[8]', 'empty'],
'user-password-repeat' : ['minLength[8]', 'empty'],
match : {
2022-03-15 12:07:05 +00:00
identifier : 'user-password-repeat',
depends : 'user-password',
rules : [
2022-03-15 09:43:53 +00:00
{
2022-03-23 09:52:34 +00:00
type : 'match[user-password]',
2022-03-22 15:15:56 +00:00
prompt : text.form_profile_password
2022-03-15 09:43:53 +00:00
}
]
2022-04-07 09:37:44 +00:00
}
2022-03-15 09:43:53 +00:00
}
});
2022-03-25 09:30:38 +00:00
2022-04-08 12:18:59 +00:00
$(document).on('change', '[name="user-password"]', function() {
var password = $(this).val();
if (password.length > 8) {
$('.step.long')
.removeClass('disabled')
.addClass('completed');
} else {
$('.step.long')
.removeClass('completed')
.addClass('disabled');
}
var hasSpecialCharacter = false;
password.split('').forEach(character => {
if (character.match(/\W/)) {
hasSpecialCharacter = true;
return;
}
});
if (hasSpecialCharacter) {
$('.step.special')
.addClass('completed')
.removeClass('disabled');
} else {
$('.step.special')
.removeClass('completed')
.addClass('disabled');
}
});
2022-06-16 12:45:12 +00:00
$('.ui.progress').progress();
/**
* Preferences
*/
/** Language */
2022-04-07 09:14:32 +00:00
$('.ui.dropdown.locale').dropdown({
2022-06-16 12:45:12 +00:00
sortSelect : 'natural',
fullTextSearch : true,
2022-03-25 12:41:17 +00:00
});
2022-06-16 12:45:12 +00:00
/** Channel */
$('.ui.dropdown.channel').dropdown();
2022-04-07 17:03:32 +00:00
2022-04-07 18:10:34 +00:00
var isPWA = navigator.standalone || window.matchMedia('(display-mode: standalone)').matches;
2022-04-07 17:03:32 +00:00
if (isPWA) {
$('.ui.dropdown.channel').dropdown('set selected', 'stable');
$('.ui.dropdown.channel').addClass('disabled');
$('.ui.dropdown.channel').find('select').removeAttr('name');
if ('undefined' !== typeof CHANNELS) {
CHANNELS.forEach(channel => {
if (channel.host === location.host) {
$('.ui.dropdown.channel').dropdown('set selected', channel.branch);
}
});
}
}
2022-03-15 09:43:53 +00:00
});