// Main App js (function(W) { if(!W.SnapAppInstance || !W[W.SnapAppInstance]) { return; } var instance = W[W.SnapAppInstance],eventSubscribers = {},isDomLoaded = false,_modulesLoaded = []; if(!instance.rm || typeof instance.rm !== 'function') { // Something went wrong in head trigger return; } var SNAP = { version: '1.0.0', events: { ON_DOM_LOAD: 'onDomLoad', ON_MODULE_INIT: 'onModuleInit', SET_AS_FAVOURITE: 'setAsFavourite', REMOVE_AS_FAVOURITE: 'removeAsFavourite' }, rm: function(cb,fromQueue) { if(typeof cb !== 'function') { return; } try { cb.apply(null,[this]); } catch(e) { // Fail registering module. ignore. } }, setCookie: function(cName, value, expireSeconds) { var _cookie = cName+ "=" +escape(value); if (typeof expireSeconds != 'undefined') { var exdate=new Date(); exdate.setTime(exdate.getTime() + (expireSeconds * 1000)); _cookie += ";expires="+exdate.toGMTString(); } _cookie += ";path=/"; W.document.cookie = _cookie; }, getCookie: function(name) { var dc = W.document.cookie; if(typeof dc !== 'string') { dc = ''; } var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; var end = W.document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } } return decodeURI(dc.substring(begin + prefix.length, end)); }, hasModuleLoaded: function(moduleNames) { if(this.utils.isString(moduleNames)) { moduleNames = [moduleNames]; } var matched = 0; for(var i=0; i < moduleNames.length; i++) { var m = moduleNames[i].toUpperCase(); if(_modulesLoaded[m]) { matched++; } } return (matched === moduleNames.length); }, moduleInit: function(moduleName,moduleData) { if(!this.utils.isString(moduleName)) { return; } var moduleNameUpper = moduleName.toUpperCase(); if(!this.utils.isObject(moduleData)) { moduleData = {}; } moduleData.module = moduleName; _modulesLoaded[moduleNameUpper] = moduleData; var fn = 'on'+this.utils.ucFirst(moduleName)+'ModuleInit'; this.raiseEvent('onModuleInit',moduleData); this.raiseEvent(fn,moduleData); }, raiseEvent: function(eventName,eventData) { if(!eventSubscribers || !this.utils.isArray(eventSubscribers[eventName])) { return false; } for(var i=0;i') .attr('id','#'+this._elementId+'-forcecentre') .addClass('centre-name') .html(this.forceCentreName); htmlContainer = jQ('
').append(cn); jQ('#'+this._elementId,this._formHashId).val(this.forceCentreName); } else { jQ('#'+this._elementId,this._formHashId).attr('data-bind','companyName').addClass('sca-dynamic-centre-info'); var aLink = jQ('') .attr('href','javascript:openFindCentrePopup()') .attr('title','Find your nearest Centre') .attr('rel','nofollow') .addClass('find-a-centre-link').html('Find Nearest Centre'); var changeCentLink = jQ(aLink).clone(true) .attr('title','Change your nearest Centre') .addClass('change-centre').html('Change Centre'); var cn = jQ('') .attr('id','#'+this._elementId+'-span') .attr('data-bind','companyName') .addClass('sca-dynamic-centre-info') .addClass('centre-name'); var htmlNo = jQ('
').append(aLink); var htmlYes = jQ('
').append(cn).append(changeCentLink); var htmlLoad = jQ('').html('Loading Nearest Centre...'); htmlContainer = jQ('
').append(htmlNo).append(htmlYes).append(htmlLoad); } jQ('#'+this._elementId,this._formHashId).parent().prepend(htmlContainer); if(SNAP.isDomLoaded()) { jQ('#'+this._elementId,this._formHashId).parent().find('.form-centre-element-container').removeClass('loading'); } return true; }, setCentreName: function(companyName) { if(this.forceCentreName) { return; } this.showSubmit(true); if(!companyName) { jQ('#' + this._elementId,this._formHashId).parent().find('.sca-on-centre-notsel').removeClass('hide'); jQ('#' + this._elementId,this._formHashId).parent().find('sca-on-centre-sel').removeClass('show'); jQ('#' + this._elementId + '-span',this._formHashId).val(''); this.disableSubmit(); } else { jQ('#' + this._elementId,this._formHashId).parent().find('.sca-on-centre-notsel').addClass('hide'); jQ('#' + this._elementId,this._formHashId).parent().find('sca-on-centre-sel').addClass('show'); jQ('#' + this._elementId + '-span',this._formHashId).val(companyName); jQ('#' + this._elementId,this._formHashId).val(companyName); this.enableSubmit(); } }, disableSubmit: function() { if(this.forceCentreName || true) { return; } var submit = this.getSubmitBtn(); if(!submit) { return; } // Show select value if(submit.prevValue) { jQ(submit).val('Please select your nearest centre'); } jQ(submit).attr('disabled','disabled'); }, enableSubmit: function() { var submit = this.getSubmitBtn(); if(!submit) { return; } // Undo previous value if(submit.prevValue) { jQ(submit).val(submit.prevValue); } jQ(submit).removeAttr('disabled'); }, showSubmit: function(show) { if(this.forceCentreName || true) { return; } var submit = this.getSubmitBtn(); if(!submit) { return; } // Undo previous value if(show === false) { jQ(submit).hide(); } else { jQ(submit).show(); } }, getSubmitBtn: function() { var submit = jQ('#'+this._elementId,this._formHashId).parents('form').find('input[type="submit"]'); if(!submit.length) { return false; } if(!submit[0].prevValue) { submit[0].prevValue = submit[0].value; } return submit[0]; } } SNAP.subscribeEvent('onFavouriteModuleInit', function () { _renderInstances() }); SNAP.subscribeEvent(SNAP.events.SET_AS_FAVOURITE,function(){ _triggerCentreData(); }); SNAP.subscribeEvent(SNAP.events.REMOVE_AS_FAVOURITE,function(){ _triggerCentreData(); }); SNAP.subscribeEvent(SNAP.events.ON_DOM_LOAD,function(){ _renderInstances(); _triggerCentreData(); }); SNAP.moduleInit('centreFormElement'); }); })(window); // Popup module (function(W){ if(!W.SnapAppInstance || !W[W.SnapAppInstance] || !W[W.SnapAppInstance].rm) { return; } W[W.SnapAppInstance].rm(function(SNAP){ var jQ = SNAP.jQuery; function _initPoupupDialog() { if(SNAP.utils.isFunction(W.openFindCentrePopup)) { return; } W.openFindCentrePopup = function () { var findCentreModel = jQ('#findCentreModal'); if (!findCentreModel) { return; } //findCentreModel.modal(); var hasLoaded = findCentreModel.find('div.modal-body').find('div.loaded-popup').length; if (!hasLoaded) { findCentreModel.on('shown.bs.modal', function (event) { if (hasLoaded) { return; } SNAP.utils.xhrRequest('/snap/centre-locator/index?listTemplate=popup.html&ppw=1', {}, function (e, html) { html = jQ('
').html(html); var popupHtml = jQ('
').html(jQ(html).find('#findCentrePopupContainer').html()); findCentreModel.removeClass('loading-popup') findCentreModel.find('div.modal-body').html(popupHtml); if(typeof W.ga === 'function') { W.ga('send', 'pageview','/find-a-centre.html') } }, 'html'); findCentreModel.off('shown.bs.modal'); }); } findCentreModel.modal('show'); } } SNAP.subscribeEvent('onFavouriteModuleInit',function(){ _initPoupupDialog(); }); SNAP.subscribeEvent(SNAP.events.SET_AS_FAVOURITE,function(){ var findCentreModel = jQ('#findCentreModal'); if (findCentreModel) { findCentreModel.modal('hide'); } }); SNAP.subscribeEvent(SNAP.events.ON_DOM_LOAD,function(){ _initPoupupDialog(); }); }); })(window); // Avansar (function(W){ if(!W.SnapAppInstance || !W[W.SnapAppInstance] || !W[W.SnapAppInstance].rm) { return; } W[W.SnapAppInstance].rm(function(SNAP){ function _initAvansar() { var script = document.createElement('script'); script.src = 'https://adriano-au.avanser.com/tagmanager/6497-1.js'; script.id = 'SnapAvansarScript'; script.type = 'text/javascript'; var fs = W.document.getElementsByTagName('script')[0]; if(fs) { // Uncomment this after migration. fs.parentNode.insertBefore(script,fs); } } var favCentreId = SNAP.getFavouriteCenterId(); if(!favCentreId) { _initAvansar(); } }); })(window); // Send a file popup (function(W){ if(!W.SnapAppInstance || !W[W.SnapAppInstance] || !W[W.SnapAppInstance].rm) { return; } W[W.SnapAppInstance].rm(function(SNAP){ var jQ = SNAP.jQuery,attached = false; function __createDialog() { var dialogId = '__sendAFileDialog'; var dialogDiv = jQ('#'+dialogId); if(dialogDiv.length) { return dialogDiv; } dialogDiv = jQ('