sopa.themePath = sopa.url + "/themes"; function transferFromSopa() { var $sopaContainer = $('#tabView\\:sopaContainer, #sopaContainer'); if ($sopaContainer.length) { try { var $sourceHtml = $sopaContainer.find('iframe').get(0).contentWindow.SOPA.compile(); var $target = $('#tabView\\:description_excludeFilter_input, #description_excludeFilter_input'); $target.val($sourceHtml); } catch (error) { console.error("SOPA access is not available right now.") } } } function addSopaThemeForSO() { var doc = $('#tabView\\:previewField_input, #previewField_input').data('cleditor').$frame.get(0).contentDocument; appendThemeStyle(doc); } function addSopaThemeForBO() { var doc = $('#productDetailIframe')[0].contentDocument; appendThemeStyle(doc); } function appendThemeStyle(doc) { var themeFileUrl = getThemeFilePath(doc); var el = ''; var $head = $(doc.head); $head.find("link").remove(); $head.append($(el)); } function getThemeFilePath(docToCheck) { var doc = docToCheck || window.document; var containers = $(doc).find(".sopa-designed"); if (containers.size() == 0) { console.info("No sopa-designed content in this page."); return null; } var classNames = $(containers.eq(0).attr("class").split(" ")); var themeId; for (var i = 0; i < classNames.length; i++) { if (classNames[i].indexOf("sopa-theme-") == 0) { themeId = classNames[i].replace(/^sopa-theme-(\d+)/, "$1"); break; } } if (!themeId) return null; return sopa.themePath + '/' + themeId + '.css' } function feedSOPA() { return $('