Skip to content

Instantly share code, notes, and snippets.

@peterfschaadt
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save peterfschaadt/9a5ed44bc4347a54a419 to your computer and use it in GitHub Desktop.

Select an option

Save peterfschaadt/9a5ed44bc4347a54a419 to your computer and use it in GitHub Desktop.
supportscheduler - contact us TPA JS
var contactApp = (function (window, Wix, undefined) {
'use strict';
var basePath = 'http://dev-contact.apps.wix.com/',
buttonUrl = {
en: 'http://static.wix.com/media/7532433974faf66715759e54072a9990d923cdd4.png',
pt: 'http://static.wix.com/media/161001484b3648b07d21208277ed558d4b2ce1e55.png',
es: 'http://static.wix.com/media/44547837819ec7fceb4622732e06114447194e6b.png'
};
// Set the CTA
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('contact-cta').src = getButtonUrl();
});
/**
* Returns the button URL according to the user language
* @returns {string}
*/
function getButtonUrl() {
var lang = getLang();
if (!buttonUrl[lang]) {
return buttonUrl.en;
}
return buttonUrl[lang];
}
/**
* Returns the given cookie name value
* @param name
* @returns {string}
*/
function getCookie(name) {
var cookieString = new RegExp(name + "[^;]+").exec(document.cookie);
return decodeURI(!!cookieString ? cookieString.toString().replace(/^[^=]+./, '') : '');
}
/**
* Returns the current active Wix language
* @returns {string}
*/
function getLang() {
return getCookie('wixLanguage') || 'en';
}
/**
* Returns the contact us path
* @param baseUrl
* @returns {string}
*/
function getUrl(baseUrl) {
return baseUrl + '?lang=' + getLang() + '&wix=true';
}
return {
open: function() {
// Wix.openModal(getUrl(basePath), 862, 546);
Wix.openModal(getUrl(basePath), 862, 546);
}
};
}(window, window.Wix));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment