/*
* Note that this is atoastr v2.1.3, the "latest" version in url has no more maintenance,
* please go to https://cdnjs.com/libraries/atoastr.js and pick a certain version you want to use,
* make sure you copy the url from the website since the url may change between versions.
* */
window.atoastr=function(h){var v,t,C,w=0,n="error",o="info",i="success",a="warning",e={clear:function(e,t){var s=b();v||T(s);r(e,s,t)||function(e){for(var t=v.children(),s=t.length-1;0<=s;s--)r(h(t[s]),e)}(s)},remove:function(e){var t=b();v||T(t);if(e&&0===h(":focus",e).length)return void D(e);v.children().length&&v.remove()},error:function(e,t,s){return l({type:n,iconClass:b().iconClasses.error,message:e,optionsOverride:s,title:t})},getContainer:T,info:function(e,t,s){return l({type:o,iconClass:b().iconClasses.info,message:e,optionsOverride:s,title:t})},options:{},subscribe:function(e){t=e},success:function(e,t,s){return l({type:i,iconClass:b().iconClasses.success,message:e,optionsOverride:s,title:t})},version:"2.1.4",warning:function(e,t,s){return l({type:a,iconClass:b().iconClasses.warning,message:e,optionsOverride:s,title:t})}};return e;function T(e,t){return e||(e=b()),(v=h("#"+e.containerId)).length||t&&(s=e,(v=h("
").attr("id",s.containerId).addClass(s.positionClass)).appendTo(h(s.target)),v=v),v;var s}function r(e,t,s){var n=!(!s||!s.force)&&s.force;return!(!e||!n&&0!==h(":focus",e).length)&&(e[t.hideMethod]({duration:t.hideDuration,easing:t.hideEasing,complete:function(){D(e)}}),!0)}function O(e){t&&t(e)}function l(t){var o=b(),e=t.iconClass||o.iconClass;if(void 0!==t.optionsOverride&&(o=h.extend(o,t.optionsOverride),e=t.optionsOverride.iconClass||e),!function(e,t){if(e.preventDuplicates){if(t.message===C)return!0;C=t.message}return!1}(o,t)){w++,v=T(o,!0);var i=null,a=h(""),s=h(""),n=h(""),r=h(""),l=h(o.closeHtml),c={intervalId:null,hideEta:null,maxHideTime:null},d={atoastId:w,state:"visible",startTime:new Date,options:o,map:t};return t.iconClass&&a.addClass(o.atoastClass).addClass(e),function(){if(t.title){var e=t.title;o.escapeHtml&&(e=u(t.title)),s.append(e).addClass(o.titleClass),a.append(s)}}(),function(){if(t.message){var e=t.message;o.escapeHtml&&(e=u(t.message)),n.append(e).addClass(o.messageClass),a.append(n)}}(),o.closeButton&&(l.addClass(o.closeClass).attr("role","button"),a.prepend(l)),o.progressBar&&(r.addClass(o.progressClass),a.prepend(r)),o.rtl&&a.addClass("rtl"),o.newestOnTop?v.prepend(a):v.append(a),function(){var e="";switch(t.iconClass){case"atoast-success":case"atoast-info":e="polite";break;default:e="assertive"}a.attr("aria-live",e)}(),a.hide(),a[o.showMethod]({duration:o.showDuration,easing:o.showEasing,complete:o.onShown}),0/g,">")}function p(e){var t=e&&!1!==o.closeMethod?o.closeMethod:o.hideMethod,s=e&&!1!==o.closeDuration?o.closeDuration:o.hideDuration,n=e&&!1!==o.closeEasing?o.closeEasing:o.hideEasing;if(!h(":focus",a).length||e)return clearTimeout(c.intervalId),a[t]({duration:s,easing:n,complete:function(){D(a),clearTimeout(i),o.onHidden&&"hidden"!==d.state&&o.onHidden(),d.state="hidden",d.endTime=new Date,O(d)}})}function g(){(0×',closeClass:"atoast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"atoast-progress",rtl:!1},e.options)}function D(e){v||(v=T()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),C=void 0))}}(window.jQuery);
(function($) {
var container = document.querySelector('#sl-frm.asl-form');
// Main container is missing!
if(!container) {
return;
}
/**
* [asl_register_store_changed Responsible to update the lat/lng fields]
* @param {[type]} _location [description]
* @return {[type]} [description]
*/
function asl_register_store_changed(_location) {
document.querySelector('#sl-frm.asl-form #sl-lat').value = _location[0];
document.querySelector('#sl-frm.asl-form #sl-lng').value = _location[1];
};
/**
* [isEmpty description]
* @param {[type]} obj [description]
* @return {Boolean} [description]
*/
function isEmpty(obj) {
if (obj == null) return true;
if (typeof(obj) == 'string' && obj == '') return true;
return Object.keys(obj).length === 0;
};
///////////////////////
// Asynchronous Maps //
///////////////////////
var map,
map_object = {
is_loaded: true,
marker: null,
changed: false,
store_location: null,
map_marker: null,
/**
* [intialize description]
* @param {[type]} _callback [description]
* @return {[type]} [description]
*/
intialize: function(_callback) {
var API_KEY = '';
if (asl_form_configuration && asl_form_configuration.api_key) {
API_KEY = '&key=' + asl_form_configuration.api_key;
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '//maps.googleapis.com/maps/api/js?libraries=places,drawing&' +
'callback=asl_map_intialized' + API_KEY;
//+'callback=asl_map_intialized';
document.body.appendChild(script);
this.cb = _callback;
},
/**
* [render_a_map description]
* @param {[type]} _lat [description]
* @param {[type]} _lng [description]
* @return {[type]} [description]
*/
render_a_map: function(_lat, _lng) {
var hdlr = this,
map_div = document.getElementById('asl-register-map'),
_draggable = true;
hdlr.store_location = (_lat && _lng) ? [parseFloat(_lat), parseFloat(_lng)] : [-37.815, 144.965];
var latlng = new google.maps.LatLng(hdlr.store_location[0], hdlr.store_location[1]);
if (!map_div) return false;
var mapOptions = {
zoom: 5,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: [{ "stylers": [{ "saturation": -100 }, { "gamma": 1 }] }, { "elementType": "labels.text.stroke", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.business", "elementType": "labels.text", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.business", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.place_of_worship", "elementType": "labels.text", "stylers": [{ "visibility": "off" }] }, { "featureType": "poi.place_of_worship", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "visibility": "simplified" }] }, { "featureType": "water", "stylers": [{ "visibility": "on" }, { "saturation": 50 }, { "gamma": 0 }, { "hue": "#50a5d1" }] }, { "featureType": "administrative.neighborhood", "elementType": "labels.text.fill", "stylers": [{ "color": "#333333" }] }, { "featureType": "road.local", "elementType": "labels.text", "stylers": [{ "weight": 0.5 }, { "color": "#333333" }] }, { "featureType": "transit.station", "elementType": "labels.icon", "stylers": [{ "gamma": 1 }, { "saturation": 50 }] }]
};
hdlr.map_instance = map = new google.maps.Map(map_div, mapOptions);
// && navigator.geolocation && _draggable
if (!hdlr.store_location) {
hdlr.add_marker(latlng);
}
else if (hdlr.store_location) {
if (isNaN(hdlr.store_location[0]) || isNaN(hdlr.store_location[1])) return;
//var loc = new google.maps.LatLng(hdlr.store_location[0], hdlr.store_location[1]);
hdlr.add_marker(latlng);
map.panTo(latlng);
}
},
/**
* [add_marker description]
* @param {[type]} _loc [description]
*/
add_marker: function(_loc) {
var hdlr = this;
hdlr.map_marker = new google.maps.Marker({
draggable: true,
position: _loc,
map: map
});
var marker_icon = new google.maps.MarkerImage(asl_form_configuration.URL + 'icon/default.png');
//marker_icon.size = new google.maps.Size(24, 39);
//marker_icon.anchor = new google.maps.Point(24, 39);
hdlr.map_marker.setIcon(marker_icon);
hdlr.map_instance.panTo(_loc);
google.maps.event.addListener(
hdlr.map_marker,
'dragend',
function() {
hdlr.store_location = [hdlr.map_marker.position.lat(), hdlr.map_marker.position.lng()];
hdlr.changed = true;
var loc = new google.maps.LatLng(hdlr.map_marker.position.lat(), hdlr.map_marker.position.lng());
//map.setPosition(loc);
map.panTo(loc);
asl_register_store_changed(hdlr.store_location);
});
}
};
/**
* [codeAddress description]
* @param {[type]} _address [description]
* @param {[type]} _callback [description]
* @return {[type]} [description]
*/
function codeAddress(_address, _callback) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': _address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
_callback(results[0].geometry);
}
//else atoastr.error(ASL_REMOTE.LANG.geocode_fail + status);
});
};
/**
* [bState Change Button State]
* @param {[type]} _state [description]
* @return {[type]} [description]
*/
jQuery.fn.bootButton = function(_state) {
// Empty
if(!this[0])return;
if(_state == 'loading')
this.attr('data-reset-text',this.html());
if(_state == 'loading') {
if(!this[0].dataset.resetText) {
this[0].dataset.resetText = this.html();
}
this.addClass('disabled').attr('disabled','disabled').html(' ' + this[0].dataset.loadingText);
}
else if(_state == 'reset')
this.removeClass('disabled').removeAttr('disabled').html(this[0].dataset.resetText);
else if(_state == 'update')
this.removeClass('disabled').removeAttr('disabled').html(this[0].dataset.updateText);
else
this.addClass('disabled').attr('disabled','disabled').html(this[0].dataset[_state+'Text']);
};
// Serialize the Form
jQuery.fn.ASLSerializeObject = function(){var o={};var a=this.serializeArray();jQuery.each(a,function(){if(o[this.name]!==undefined){if(!o[this.name].push){o[this.name]=[o[this.name]];}o[this.name].push(this.value||'');}else{o[this.name]=this.value||'';}});return o;};
//http://getbootstrap.com/customize/?id=23dc7cc41297275c7297bb237a95bbd7
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(t){"use strict";var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>3){}}(jQuery),+function(t){"use strict";function e(e){var n=e.attr("data-target");n||(n=e.attr("href"),n=n&&/#[A-Za-z]/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,""));var i=n&&t(n);return i&&i.length?i:e.parent()}function n(n){n&&3===n.which||(t(a).remove(),t(o).each(function(){var i=t(this),a=e(i),o={relatedTarget:this};a.hasClass("open")&&(n&&"click"==n.type&&/input|textarea/i.test(n.target.tagName)&&t.contains(a[0],n.target)||(a.trigger(n=t.Event("hide.bs.adropdown",o)),n.isDefaultPrevented()||(i.attr("aria-expanded","false"),a.removeClass("open").trigger(t.Event("hidden.bs.adropdown",o)))))}))}function i(e){return this.each(function(){var n=t(this),i=n.data("bs.adropdown");i||n.data("bs.adropdown",i=new r(this)),"string"==typeof e&&i[e].call(n)})}var a=".adropdown-backdrop",o='[data-toggle="adropdown"]',r=function(e){t(e).on("click.bs.adropdown",this.toggle)};r.VERSION="3.3.7",r.prototype.toggle=function(i){var a=t(this);if(!a.is(".disabled, :disabled")){var o=e(a),r=o.hasClass("open");if(n(),!r){"ontouchstart"in document.documentElement&&!o.closest(".navbar-nav").length&&t(document.createElement("div")).addClass("adropdown-backdrop").insertAfter(t(this)).on("click",n);var s={relatedTarget:this};if(o.trigger(i=t.Event("show.bs.adropdown",s)),i.isDefaultPrevented())return;a.trigger("focus").attr("aria-expanded","true"),o.toggleClass("open").trigger(t.Event("shown.bs.adropdown",s))}return!1}},r.prototype.keydown=function(n){if(/(38|40|27|32)/.test(n.which)&&!/input|textarea/i.test(n.target.tagName)){var i=t(this);if(n.preventDefault(),n.stopPropagation(),!i.is(".disabled, :disabled")){var a=e(i),r=a.hasClass("open");if(!r&&27!=n.which||r&&27==n.which)return 27==n.which&&a.find(o).trigger("focus"),i.trigger("click");var s=" li:not(.disabled):visible a",l=a.find(".adropdown-menu"+s);if(l.length){var d=l.index(n.target);38==n.which&&d>0&&d--,40==n.which&&d 0) {
form_data[_field] = form_data[_field].join(',');
}
}
////////////////////////////
// Validate these fields //
////////////////////////////
var validation_fields = [];
Array.prototype.filter.call(inputs, function(_input) {
if(_input.required || $(_input).hasClass('validate[required]')) {
validation_fields.push(_input.name);
}
});
Array.prototype.filter.call(inputs, function(_input) {
// Radio
if(_input.type == 'radio') {
// Only the check valued
if(_input.checked) {
form_data[_input.name] =_input.value;
}
}
// checkbox
else if(_input.type == 'checkbox') {
form_data[_input.name] = (_input.checked)? _input.value: false;
}
else {
form_data[_input.name] = _input.value;
}
if(validation_fields.indexOf(_input.name) != -1 && !$.trim(_input.value)) {
_input.parentNode.classList.add('has-error');
is_valid = false;
}
});
// Validate the Data
if(!is_valid) {
atoastr.error((asl_form_configuration.words.fill_form || 'Please fill up the form.'));
return;
}
$reg_btn.bootButton('loading');
// Add the nounce
$.ajax({
url: ASL_FORM.ajax_url,
data: {action: 'asl_reg_store', form_params: form_data, vkey: ASL_FORM.vkey},
type: 'POST',
dataType: 'json',
/**
* [success description]
* @param {[type]} _data [description]
* @return {[type]} [description]
*/
success: function(_response) {
// Reset the button
$reg_btn.bootButton('reset');
if (_response.success) {
atoastr.success(_response.message);
resetRegisterForm();
// When there is a redirect URL
if(asl_form_configuration.redirect) {
window.location = asl_form_configuration.redirect;
}
} else {
atoastr.error((_response.message || 'Error in registering the form.'));
}
},
/**
* [error description]
* @param {[type]} _data [description]
* @return {[type]} [description]
*/
error: function(_data) {}
});
});
})(jQuery);