PATH:
home
/
lab2454c
/
keebchat.com
/
themes
/
default
/
apps
/
settings
/
scripts
<script> "use strict"; $(document).ready(function($) { Vue.use(window.vuelidate.default); var VueValids = window.validators; var CLSettings = Object({ open: function(win = false) { $('[data-app="cl-{0}"]'.format(win)).modal("show"); }, close: function(win = false) { $('[data-app="cl-{0}"]'.format(win)).modal("hide"); } }); window.CLSettings = CLSettings; var CLNameSettings = new Vue({ el: "#cl-name-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_fname: "", invalid_feedback_lname: "", invalid_feedback_uname: "", fname: "<?php echo($me["fname"]) ?>", lname: "<?php echo($me["lname"]) ?>", uname: "<?php echo($me["raw_uname"]) ?>", uname_taken: false }, computed: { is_valid_fname: function() { if (this.$v.fname.required == true && this.$v.fname.$error) { this.invalid_feedback_fname = "<?php echo cl_translate("Please enter your first name, which is from 3 to 25 characters"); ?>"; return true; } else { this.invalid_feedback_fname = ""; return false; } }, is_valid_lname: function() { if(this.$v.lname.required == true && this.$v.lname.$error) { this.invalid_feedback_lname = "<?php echo cl_translate("Please enter your last name, which is from 3 to 25 characters"); ?>"; return true; } else { this.invalid_feedback_lname = ""; return false; } }, is_valid_uname: function() { if(this.$v.uname.required == true && this.$v.uname.$error) { this.invalid_feedback_uname = "<?php echo cl_translate("This username does not match the valid format. Please select a username of no more than 25 characters using only letters (a-z) numbers and underscores"); ?>"; return true; } else if(this.uname_taken == true) { this.invalid_feedback_uname = "<?php echo cl_translate("This username is already taken, please select another"); ?>"; return true; } else { this.invalid_feedback_uname = ""; return false; } } }, validations: { fname: { required: VueValids.required, min_length: VueValids.minLength(3), max_length: VueValids.maxLength(25), }, lname: { required: VueValids.required, min_length: VueValids.minLength(3), max_length: VueValids.maxLength(25), }, uname: { required: VueValids.required, min_length: VueValids.minLength(3), max_length: VueValids.maxLength(25), is_alpha_num: cl_uname_valid } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_name"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.uname_taken = false; }, success: function(data) { if (data.status == 200) { CLSettings.close("name-settings"); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else if(data.err_code && data.err_code == 'doubling_uname') { _app_.uname_taken = true; delay(function() { _app_.uname_taken = false; }, 5000); } else { _app_.unsuccessful_attempt = true; } }, complete: function() { _app_.submitting = false; } }); } } }); var CLEmailSettings = new Vue({ el: "#cl-email-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_email: "", email: "<?php echo($me["email"]) ?>", doubling_email: false }, computed: { is_valid_email: function() { if (this.$v.email.required == true && this.$v.email.$error) { this.invalid_feedback_email = "<?php echo cl_translate("The email address you entered does not match the valid format."); ?>"; return true; } else if(this.doubling_email == true) { this.invalid_feedback_email = "<?php echo cl_translate("This email address is already taken"); ?>"; return true; } else { this.invalid_feedback_email = ""; return false; } } }, validations: { email: { required: VueValids.required, email: VueValids.email, min_length: VueValids.minLength(8), max_length: VueValids.maxLength(55), } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_email"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; _app_.doubling_email = false; }, success: function(data) { if (data.status == 200) { CLSettings.close("email-settings"); setTimeout(function() { SMColibri.spa_load("<?php echo cl_link('confirm_email'); ?>"); }, 1000); } else if(data.err_code == "doubling_email") { _app_.doubling_email = true; _app_.submitting = false; } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); } } }); var CLURLSettings = new Vue({ el: "#cl-url-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_website: "", website: "<?php echo($me["website"]) ?>", }, computed: { is_valid_url: function() { if (this.$v.website.$error) { this.invalid_feedback_website = "<?php echo cl_translate("The URL address you entered does not match the valid format."); ?>"; return true; } else { this.invalid_feedback_website = ""; return false; } } }, validations: { website: { url: VueValids.url, max_length: VueValids.maxLength(115), } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_url"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('url-settings'); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); } } }); var CLBioSettings = new Vue({ el: "#cl-bio-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_bio: "", bio: "<?php echo addslashes($me["about"]) ?>", }, computed: { is_valid_bio: function() { if (this.$v.bio.$error) { this.invalid_feedback_bio = "<?php echo cl_translate("The text you entered is too long, the maximum length is 140 characters"); ?>"; return true; } else { this.invalid_feedback_bio = ""; return false; } } }, validations: { bio: { max_length: VueValids.maxLength(140) } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_bio"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('bio-settings'); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); } } }); var CLGenderSettings = new Vue({ el: "#cl-gender-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, gender: "<?php echo($me['gender']); ?>", dropdowns: { gender: "<?php echo cl_translate("Select your gender"); ?>" } }, validations: { gender: { required: VueValids.required } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_gender"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('gender-settings'); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); }, dropdown_select: function(key = "none", val = false, e = false, on_change = false) { var _app_ = this; _app_.$v[key].$model = val; _app_.dropdowns[key] = $.trim($(e.target).text()); if (on_change) { on_change(); } } }, mounted: function() { if (this.gender == 'F') { this.dropdowns.gender = "<?php echo cl_translate("Female"); ?>"; } else { this.dropdowns.gender = "<?php echo cl_translate("Male"); ?>"; } } }); var CLPasswordSettings = new Vue({ el: "#cl-password-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_pass1: "", invalid_feedback_pass2: "", invalid_feedback_pass3: "", password1: "", password2: "", password3: "", invalid_curr_pass: false }, computed: { is_valid_password1: function() { if (this.$v.password1.required == true && this.$v.password1.$error) { this.invalid_feedback_pass1 = "<?php echo cl_translate("Please enter your current password!"); ?>"; return true; } else if(this.invalid_curr_pass == true) { this.invalid_feedback_pass1 = "<?php echo cl_translate("The current password you entered is not correct, please check your details and try again!"); ?>"; return true; } else { this.invalid_feedback_pass1 = ""; return false; } }, is_valid_password2: function() { if(this.$v.password2.required == true && this.$v.password2.$error) { this.invalid_feedback_pass2 = "<?php echo cl_translate("Please enter your new password, from 6 to 20 characters!"); ?>"; return true; } else { this.invalid_feedback_pass2 = ""; return false; } }, is_valid_password3: function() { if(this.$v.password3.required == true && this.$v.password3.$error) { this.invalid_feedback_pass3 = "<?php echo cl_translate("Passwords do not mutch!"); ?>"; return true; } else { this.invalid_feedback_pass3 = ""; return false; } } }, validations: { password1: { required: VueValids.required, min_length: VueValids.minLength(6), max_length: VueValids.maxLength(20) }, password2: { required: VueValids.required, min_length: VueValids.minLength(6), max_length: VueValids.maxLength(20) }, password3: { required: VueValids.required, sameAs: VueValids.sameAs('password2') } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_pass"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; _app_.invalid_curr_pass = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('password-settings'); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else if(data.err_code == "invalid_curr_pass") { _app_.invalid_curr_pass = true; _app_.submitting = false; } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); } } }); var CLDislangSettings = new Vue({ el: "#cl-language-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, language: "<?php fetch_or_get($me['language'], 'english'); ?>", langs: <?php echo cl_minify_js(json($cl["languages"], 1)); ?> }, validations: { language: { required: VueValids.required } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_lang"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('language-settings'); $(window).reloadPage(1200); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); }, dropdown_select: function(key = "none") { var _app_ = this; _app_.language = key; } } }); var CLCountrySettings = new Vue({ el: "#cl-country-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, country: "<?php echo($me["country_id"]); ?>", countries: <?php echo cl_minify_js(json($cl['countries'], true)); ?>, dropdowns: { country: "<?php echo cl_translate("Select your country"); ?>" } }, validations: { country: { required: VueValids.required } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_profile_country"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('country-settings'); setTimeout(function() { SMColibri.spa_reload(); }, 1000); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); }, dropdown_select: function(key = "none") { var _app_ = this; _app_.country = key; } } }); var CLVerificationSettings = new Vue({ el: "#cl-verif-settings-vue-app", data: { verification_status: "<?php echo fetch_or_get($me['verified'], 0); ?>", submitting: false, unsuccessful_attempt: false, invalid_feedback_full_name: "", invalid_feedback_text_message: "", full_name: "", text_message: "", is_file_selected: false, selected_file_name: "<?php echo cl_translate("Please select a video appeal to the reviewer!"); ?>" }, computed: { is_valid_full_name: function() { if (this.$v.full_name.required == true && this.$v.full_name.$error) { this.invalid_feedback_full_name = "<?php echo cl_translate("Please enter your full name between 3 and 60 characters long!"); ?>"; return true; } else { return false; } }, is_valid_text_message: function() { if (this.$v.text_message.required == true && this.$v.text_message.$error) { this.invalid_feedback_text_message = "<?php echo cl_translate("Please enter a message for the reviewer, no more than 1200 characters in length!"); ?>"; return true; } else { return false; } }, is_valid_form: function() { if(this.$v.$invalid == true || this.is_file_selected != true) { return false; } else { return true; } } }, validations: { full_name: { required: VueValids.required, min_length: VueValids.minLength(3), max_length: VueValids.maxLength(60) }, text_message: { required: VueValids.required, min_length: VueValids.minLength(1), max_length: VueValids.maxLength(1200) } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/verify_account"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { _app_.verification_status = 2; } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); }, select_video: function() { var _app = $(this.$el); _app.find('[data-an="video-message-input"]').trigger('click'); }, display_filename: function(e = false) { var _app_ = this; if (SMColibri.max_upload(e.target.files[0].size)) { _app_.selected_file_name = e.target.files[0].name; _app_.is_file_selected = true; } else { $(_app_.$el).find('[data-an="video-message-input"]').val(''); } } } }); var CLDeleteSettings = new Vue({ el: "#cl-delete-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, invalid_feedback_pass: "", password: "", invalid_pass: false }, computed: { is_valid_password: function() { if (this.$v.password.required == true && this.$v.password.$error) { this.invalid_feedback_pass = "<?php echo cl_translate("Please enter your current password!"); ?>"; return true; } else if(this.invalid_pass == true) { this.invalid_feedback_pass = "<?php echo cl_translate("The current password you entered is not correct, please check your details and try again!"); ?>"; return true; } else { this.invalid_feedback_pass = ""; return false; } } }, validations: { password: { required: VueValids.required, min_length: VueValids.minLength(6), max_length: VueValids.maxLength(20) } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/delete_account"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; _app_.invalid_pass = false; }, success: function(data) { if (data.status == 200) { setTimeout(function() { cl_redirect("<?php echo cl_link('guest'); ?>"); }, 1000); } else if(data.err_code == "invalid_pass") { _app_.invalid_pass = true; _app_.submitting = false; } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); } } }); var CLPrivacySettings = new Vue({ el: "#cl-privacy-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false, profile_privacy: "<?php echo($me['profile_privacy']); ?>", follow_privacy: "<?php echo($me['follow_privacy']); ?>", contact_privacy: "<?php echo($me['contact_privacy']); ?>", index_privacy: "<?php echo($me['index_privacy']); ?>", sdds: { profile_privacy: { everyone: "<?php echo cl_translate("Everyone"); ?>", followers: "<?php echo cl_translate("My followers"); ?>" }, follow_privacy: { everyone: "<?php echo cl_translate("Everyone"); ?>", approved: "<?php echo cl_translate("Approved users only"); ?>" }, contact_privacy: { everyone: "<?php echo cl_translate("Everyone"); ?>", followed: "<?php echo cl_translate("The people I follow"); ?>" }, index_privacy: { Y: "<?php echo cl_translate("Yes"); ?>", N: "<?php echo cl_translate("No"); ?>" } } }, validations: { profile_privacy: { profile_privacy: VueValids.required }, follow_privacy: { profile_privacy: VueValids.required }, contact_privacy: { contact_privacy: VueValids.required }, index_privacy: { index_privacy: VueValids.required } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; var payload = _app_.form_data(); $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_privacy_settings"); ?>", type: 'POST', dataType: 'json', data: payload, beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('privacy-settings'); cl_bs_notify("<?php echo cl_translate("Your changes has been successfully saved!"); ?>"); } else { _app_.unsuccessful_attempt = true; } }, complete: function() { _app_.submitting = false; } }); }, form_data: function() { var _app_ = this; return Object({ profile_privacy: _app_.profile_privacy, follow_privacy: _app_.follow_privacy, contact_privacy: _app_.contact_privacy, index_privacy: _app_.index_privacy }); } } }); var CLNotifsSettings = new Vue({ el: "#cl-notifs-settings-vue-app", data: { submitting: false, unsuccessful_attempt: false }, validations: { }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/save_notif_settings"); ?>", type: 'POST', dataType: 'json', beforeSend: function() { _app_.submitting = true; _app_.unsuccessful_attempt = false; }, success: function(data) { if (data.status == 200) { CLSettings.close('notifs-settings'); } else { _app_.unsuccessful_attempt = true; } }, complete: function() { _app_.submitting = false; } }); } } }); var CLAccountInfo = new Vue({ el: "#cl-account-info-vue-app", data: { submitting: false, unsuccessful_attempt: false, form_data: { my_info: false, following: false, followers: false, posts: false, bookmarks: false } }, computed: { is_invalid_form: function() { var _app_ = this; var fields = Object.values(_app_.form_data); return ((fields.contains(true)) ? false : true); } }, methods: { submit_form: function(_self = null) { _self.preventDefault(); var _app_ = this; $(_self.target).ajaxSubmit({ url: "<?php echo cl_link("native_api/settings/download_profile_info"); ?>", type: 'POST', dataType: 'json', data: { my_info: ((_app_.form_data.my_info == true) ? "Y" : "N"), following: ((_app_.form_data.following == true) ? "Y" : "N"), followers: ((_app_.form_data.followers == true) ? "Y" : "N"), posts: ((_app_.form_data.posts == true) ? "Y" : "N"), bookmarks: ((_app_.form_data.bookmarks == true) ? "Y" : "N") }, beforeSend: function() { _app_.submitting = true; }, success: function(data) { if (data.status == 200) { _app_.reset_form(); cl_redirect(data.url, true); } else { _app_.unsuccessful_attempt = true; _app_.submitting = false; } } }); }, reset_form: function() { var _app_ = this; _app_.submitting = false; _app_.unsuccessful_attempt = false; _app_.form_data = Object({ my_info: false, following: false, followers: false, posts: false, bookmarks: false }); CLSettings.close("account-info"); } } }); <?php if (not_empty($cl["settings_app"])): ?> CLSettings.open("<?php echo($cl["settings_app"]); ?>"); <?php endif; ?> }); </script>
[+]
..
[-] app_master_script.phtml
[edit]