/** * Cart Embedding Toolkit * This is a toolset to use the cart part of Triscovery inside any partner website * You must request the access to thi toolkit at help@triscovery.it */ var triscoveryToolset = { fwPh: null, token: null, modules: { sidebar: { base: "https://www.triscovery.com//embed/sidebar.js" } } }; /** * Framework Initialization Procedure */ triscoveryToolset.init = function() { //Find For Triscovery Toolkit Placeholder triscoveryToolset.fwPh = jQuery('div#triscovery-ph'); //No Placeholder No Party if(!triscoveryToolset.fwPh) return false; //This is the toolkit token to access all functions triscoveryToolset.token = triscoveryToolset.fwPh.data('token'); //Token Valid? if(!triscoveryToolset.validateToken()) return false; //Lookup for widgets and components to initialize triscoveryToolset.lookup(); }; /** * Lookup for triscovery widgets and initialize them */ triscoveryToolset.lookup = function() { //This contains all widgets we may need to initialize var widgetsLookingTriscovery = jQuery('.triscovery-widget'); //Parse widgets and operate with them widgetsLookingTriscovery.each(function(key, widget) { var type = jQuery(this).data('type'); var module = triscoveryToolset.modules[type]; if(type && typeof module != 'undefined' && !module['instance']) { //Lock Instance module.instance = true; //Store All Datas into Widget Params module.params = jQuery(this).data(); (function(e, module, invoker) { e.src = module.base; e.onload = function() { module.instance = module.init(invoker); }; document.head.appendChild(e); })(document.createElement('script'), module, this) } }); }; /** * Validate token for triscovery toolkit */ triscoveryToolset.validateToken = function(key) { return triscoveryToolset.token; }; /** * jQuery Lib Injection If Not Already Loaded * Then trigger FW Init */ (function(e, s) { e.src = s; e.onload = function() { jQuery.noConflict(); triscoveryToolset.init(); }; //Append jQuery Lib or Init FW if(typeof jQuery == 'undefined') { document.head.appendChild(e); } else { jQuery(document).ready(function() { triscoveryToolset.init(); }); } })(document.createElement('script'), 'https://www.triscovery.com/assets/fbae41de/jquery.min.js');