| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/themes/Honeygrid/javascripts/source/widgets/ |
Upload File : |
/* --------------------------------------------------------------
zones_handler.js 2017-06-01
Gambio GmbH
http://www.gambio.de
Copyright (c) 2017 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
/**
* The Component for handling the federal state dropdown depending on the country.
* The field will be blacked out if there are no federal states for the selected
* country.
*/
gambio.widgets.module(
'zones_handler',
[
'form',
'xhr'
],
function (data) {
'use strict';
// ########## VARIABLE INITIALIZATION ##########
var $this = $(this),
$states = $('select#state.form-control'),
$selectedState = $('input[name=selected_zone_id]'),
$statesFormGroup = $('select#state.form-control').closest('div.form-group'),
defaults = {
loadStates: 'shop.php?do=Zones',
country: 'select#country.form-control',
}, options = $.extend(true, {}, defaults, data),
module = {};
var _changeHandler = function () {
var dataset = jse.libs.form.getData($this);
jse.libs.xhr.ajax({url: options.loadStates, data: dataset}, true).done(function (result) {
if (result.success) {
$states.children('option').remove();
$selectedState.prop("disabled", false);
$states.prop("disabled", false);
$.each(result.data, function (key, value) {
if (value.selected) {
$states.append($("<option selected/>").val(value.id).text(value.name));
} else {
$states.append($("<option />").val(value.id).text(value.name));
}
});
$statesFormGroup.removeClass('hidden').show();
} else {
$statesFormGroup.hide();
$selectedState.prop("disabled", true);
$states.prop("disabled", true);
}
}).always(function() {
setDisabledAttributeForSubmitButton(false);
});
};
let setDisabledAttributeForSubmitButton = function(newValue) {
let submitButton = $('form#account_edit button[type="submit"].btn');
if(submitButton.length){
submitButton.get(0).disabled = newValue;
}
};
// ########## INITIALIZATION ##########
/**
* Init function of the widget
* @constructor
*/
module.init = function (done) {
_changeHandler();
$this.on('change', options.country, _changeHandler);
done();
};
// Return data to widget engine
return module;
});