var CmsTextManager = (function() { function CmsTextManager(){ var _this = this; _this.oTable = new CTable("data"); _this.oTable.loadTableData(); } CmsTextManager.prototype.oFileUpload = {}; CmsTextManager.prototype.oTinyMceController = {}; CTable.prototype.tableObjectCallback = function(jqObj){ // Bind link button clicks; jqObj.find("span.icon_link").click(function(){ var id = $(this).closest("ul").attr("id"); var specContainer = "
"; // If spec cnt. already exist remove it before appending a new one; var oSpec = jqObj.find("div.specContainer"); if(oSpec.length > 0) oSpec.remove(); // Append spec cnt, bind close button && link field; jqObj.find('.table-bactions').append(specContainer); jqObj.find('span.close').click(function(){ oSpec.remove(); }); oLink.click(function(){ $(this).select(); }); // Get link var oLink = $("div.specContainer #a_link"); $.get("text-manager/action:f_link/id:" + id, function(data){ data = cJSON.parse(data); if(data.title) $("div.specContainer #a_title").val(data.title).parent().show(); if(data.link) oLink.val(data.link).focus().select(); }); }); }; // Rewrite CBase form callback CBlank.prototype.viewCallback = function(jqObj){ var _this = this; jqObj.find(".settings").find("h3").click(function(){ var jqParent = $(this).parent(); if(jqParent.hasClass("load")) _this.loadBlankBlockSubContent(jqParent); else _this.showHideSubContentPanel(jqParent); }); this.oBtnPan.find("#fcancel").click(function(){ CBase.message.hide(); if(_this.isModiffied){ CBase.oTable.filterTableData(false); }else{ CBase.oTable.show(); } }); this.oBtnPan.find("#fsave").click(function(){ _this.saveBlankView(); }); _this.tabs = new Tabs($(jqObj).find(".tabs")); // Bind base fields; CBase.jsModule.baseFieldBinds(jqObj); // Add date picked to date field jqObj.find("#a_date").datepicker({dateFormat: 'dd/mm/yy'}); this.bindBlankActions(jqObj); }; // Ajax load view call back on object append - if needed then to rewrite CBlank.prototype.viewCallbackAfterAppend = function(jqObj, d){ CBase.oForm.disableShow = true; // Bind Image data handlers CBase.jsModule.oFileUpload = new FileUpload(jqObj, d.files, 10); // Bind Tiny Mce controller with custom templates CBase.jsModule.bindTinyMCE(jqObj); var og = jqObj.find("#a_type"); if(og.length){ // Select type by filter if(d && d.bNew){ jqObj.find("option[value='"+ $("#cl_name").val() +"']") .prop("selected", true) .trigger("chosen:updated"); } // Bind type change show/hide fields if(typeof CBase.dt.oShow != "undefined"){ // On type change show/hide fields CBase.jsModule.bindShowHideFields(og.val(), jqObj, false); og.change(function(){ CBase.jsModule.bindShowHideFields($(this).val(), $("#data"), true); }); } } }; // Bind TinyMCE with custom templates CmsTextManager.prototype.bindTinyMCE = function(jqObj) { let _this = this; let vAdditionalCfg = { toolbar: 'undo redo | formatselect pageTplMenu | fontsizeselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code | headingTpl sectionTpl tabsTpl numberIndexTpl infoCols3Tpl calloutTpl', extended_valid_elements: 'div[class|id|data-animate|data-bs-parent|style],section[class],a[class|href|data-bs-toggle|aria-expanded|target],button[type|class|data-video-id|data-bs-toggle|data-bs-target|aria-label|aria-expanded],span[class|style],i[class|style],img[src|class|alt|width|height],ul[class],li[class],p[class|style],h6[class],h5[class],h4[class],svg[aria-hidden|focusable|role|viewBox|viewbox|xmlns],circle[fill|stroke|stroke-width|cx|cy|r]', setup: function (editor) { _this.oTinyMceController.editor = editor; editor.ui.registry.addMenuButton('pageTplMenu', { text: 'Page Templates', tooltip: 'Insert page content template', fetch: function (callback) { callback([ { type: 'menuitem', text: 'Return Policy - Full', onAction: function () { var collapseGroupId = _this.oTinyMceController.buildUid('faqs-collapse-group'); var tab1Id = _this.oTinyMceController.buildUid('faqs-collapse-group1'); var tab2Id = _this.oTinyMceController.buildUid('faqs-collapse-group2'); var tab3Id = _this.oTinyMceController.buildUid('faqs-collapse-group3'); _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + // '
' + // '
' + // '

Return policy

' + // '
' + // '
' + '
' + '
Streamlined returns for easy solutions
' + '

Our return policy simplifies the process, ensuring fast and easy returns. Follow our clear steps for refunds, exchanges, or store credits.

' + 'Shop now' + '
' + '
' + '' + 'Refund process steps?' + '' + '' + '
' + '

Start your refund by logging into your account and following the return steps.

' + '
' + '
' + '
' + '
' + '' + '
' + '

Choose exchange during your return request and select the replacement product.

' + '
' + '
' + '
' + '
' + '' + '
' + '

Cancel orders before shipping, or create a return request after delivery.

' + '
' + '
' + '
' + '
Quality service shapes how we value returns
' + '

We focus on clear instructions and timely support so every return stays simple and stress-free.

' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'Payment Policy - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + //'

Payment terms

' + '
' + '
Secure transaction rules and payment process
' + '

Discover the steps to ensure safe and seamless payments on our platform.

' + '

Ensure easy and secure transactions.

' + '

Follow steps for seamless payments.

' + '
Top payment options
' + '

Visa: Secure Visa card payments processed quickly and easily.

' + '

Paypal: Handling payments through paypal for secure transactions.

' + 'Know more' + '
' + '
What payment methods can I use?
' + '

We accept major cards, digital wallets and bank transfers.

' + '
What should I do if my payment fails?
' + '

Retry the payment and check your details. Contact support if needed.

' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'Privacy Policy - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + //'

Privacy policy

' + '
' + '

We use secure methods to store and manage your sensitive information.

' + '

Your data is used only to improve your experience.

' + '

We do not share your details without your consent.

' + '
Liability
' + '

We protect your data with industry best practices.

' + '
' + '
Trusted ways
' + '

Visa: Secure Visa card payments processed quickly and easily.

' + '

Paypal: Secure digital wallet payments.

' + '
' + '
How do we handle your data?
' + '

Learn how we collect, secure and process your personal data.

' + 'Know more' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'Shipping Policy - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + //'

Shipping policy

' + '
' + '
Delivery
' + '

Orders are processed within 1-2 business days and shipped with tracking.

' + '

Standard shipping takes 5-7 business days.

' + '

Expedited shipping options are available.

' + '
Freight
' + '

Shipping costs vary by location and order weight.

' + '

Charges are shown during checkout.

' + '
Dispatch
' + '

You will receive a tracking number after dispatch.

' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'Terms & Conditions - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + //'

Terms & conditions

' + '
' + '
Restriction
' + '

Access to our site is granted for personal use only.

' + '

Unauthorized use may result in account restrictions.

' + '
' + '
Usage rights
' + '

Access and use of services are granted under specific conditions.

' + '
' + '
Liability limits
' + '

We are not liable for indirect damages to the extent permitted by law.

' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'Cookie Policy - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '' ); }, }, { type: 'menuitem', text: 'About Us - Full', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + '

About story

' + '
' + '
' + '
5000+ Happy customer

Absolutely delighted with the service and support.

' + '
29+ Awards won

Recognized for quality, innovation and customer care.

' + '
40+ years of experiences

Long-term expertise with a modern approach to growth.

' + '
' + '
' + '
' + '
' + '
' + '
Leading with innovation since 1982

We blend experience with modern solutions to deliver strong results.

' + '
Transforming ideas into success

We turn clear vision and integrity into meaningful outcomes.

' + '
' + '

Our team

' + '
' + '
' + '
' + '
' + '
' ); }, }, { type: 'menuitem', text: 'FAQ - Full', onAction: function () { var faqTopId = _this.oTinyMceController.buildUid('faqs-collapse'); var faqTop1 = _this.oTinyMceController.buildUid('faqs-collapse1'); var faqTop2 = _this.oTinyMceController.buildUid('faqs-collapse2'); var faqTop3 = _this.oTinyMceController.buildUid('faqs-collapse3'); var faqTop4 = _this.oTinyMceController.buildUid('faqs-collapse4'); var faqGroupId = _this.oTinyMceController.buildUid('faqs-collapse-group'); var faqGroup1 = _this.oTinyMceController.buildUid('faqs-collapse-group1'); var faqGroup2 = _this.oTinyMceController.buildUid('faqs-collapse-group2'); var faqGroup3 = _this.oTinyMceController.buildUid('faqs-collapse-group3'); _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + //'

Frequently asked questions

' + '
' + '
How do I track my order?

You can track your order in your account.

' + '

We accept returns within policy terms.

' + '

Yes, shipping options vary by country.

' + '

Contact support quickly after placing the order.

' + '
' + '
' + '
' + '
Call the team

Get in touch with our support crew anytime for assistance.

Help team crew

Support squad dedicated to assisting with any issue.

' + '

Common queries

' + '
How do I place an order?

Browse products, add to cart and proceed to checkout.

' + '

Use your tracking number in account or email link.

' + '

Standard, express and next-day options are available.

' + '
' ); }, }, ]); }, }); editor.ui.registry.addButton('headingTpl', { text: 'Heading', tooltip: 'Insert heading', onAction: function () { var padding = prompt("Add section top padding? (yes/no)", "yes").toLowerCase(); var addPadding = (padding === 'yes' || padding === 'y' || padding === '1'); _this.oTinyMceController.insertTopLevelBlock( '
\n' + '
\n' + '

Write your ection header here...

\n' + '
\n' + '
' ); }, }); editor.ui.registry.addButton('sectionTpl', { text: 'Section', tooltip: 'Insert section', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + '
' + '

Write section content here...

' + '
' + '
' + '
' ); }, }); editor.ui.registry.addButton('tabsTpl', { text: 'Tabs', tooltip: 'Insert tabs block', onAction: function () { var count = parseInt(prompt("How many tabs?", "3")); if(!count || count < 1 || count > 20) return; var openFirstRaw = prompt("Should first tab be open? (yes/no)", "yes"); if(openFirstRaw === null) return; var openFirst = openFirstRaw.toLowerCase(); var isFirstOpen = (openFirst === 'yes' || openFirst === 'y' || openFirst === '1'); let collapseId = _this.oTinyMceController.buildUid('collapse-tab'); var html = '
' + '
' + '
'; for(var i = 1; i <= count; i++) { let tabId = _this.oTinyMceController.buildUid('tab-' + i); let isFirst = (i === 1); let shouldBeOpen = (isFirst && isFirstOpen); html += '
' + '' + '

Tab ' + i + ' content goes here...

' + '
'; } html += '
'; _this.oTinyMceController.insertTopLevelBlock(html); }, }); // NUMBER-INDEX button editor.ui.registry.addButton('numberIndexTpl', { text: 'Numbered Index', tooltip: 'Insert numbered index block', onAction: function () { var count = parseInt(prompt("How many sections?", "2")); if(!count || count < 1 || count > 20) return; var html = '
'; for(var i = 1; i <= count; i++) { html += '
Section ' + i + '
' + '

Main paragraph text here...

' + '

Supporting paragraph or details...

'; if(i < count) html += '
'; } html += '
'; _this.oTinyMceController.insertTopLevelBlock(html); }, }); // INFO CARDS 3 COLUMNS button editor.ui.registry.addButton('infoCols3Tpl', { text: 'Info Cards', tooltip: 'Insert info cards', onAction: function () { var count = parseInt(prompt("How many cards? (2-6)", "3")); if(!count || count < 2 || count > 6) return; var colClass = count === 2 ? 'col-lg-6' : (count === 4 ? 'col-lg-3' : 'col-lg-4'); var html = '
' + '
'; for(var i = 1; i <= count; i++) { html += '
' + '
Card Title ' + i + '
' + '

Card description text goes here...

' + '
'; } html += '
'; _this.oTinyMceController.insertTopLevelBlock(html); }, }); // CALLOUT INFO BOX button editor.ui.registry.addButton('calloutTpl', { text: 'Callout Box', tooltip: 'Insert callout/info box', onAction: function () { _this.oTinyMceController.insertTopLevelBlock( '
' + '
' + '
' + '' + '' + '' + '
Callout Title
' + '

Callout description text goes here...

' + '
' + '
' + '
' ); }, }); }, }; _this.oTinyMceController = new TinyMceController(jqObj, vAdditionalCfg); }; // Save blank data check callback function CBlank.prototype.saveBlankDataCheckCallback = function(jqObj){ // Manipulate save data object if(jqObj && jqObj.article){ var jqObjArticle = $(""); for(var l in jqObj.article){ if(jqObj.article.hasOwnProperty(l)){ for(var k in jqObj.article[l]){ if(jqObj.article[l].hasOwnProperty(k)){ jqObjArticle = $("
" + jqObj.article[l][k] + "
"); jqObjArticle.find("a").each(function(){ if(!this.className.length) $(this).addClass("link"); }); jqObj.article[l][k] = jqObjArticle.html(); } } } } } return jqObj; }; // Rewrite Save error callback function CBlank.prototype.saveBlankErrorCallback = function(){ CBase.jsModule.showError(); }; // Update count classification selection availability CmsTextManager.prototype.showError = function(){ var err = $(".v-error:first"); if(err.length){ if(!err.is(":visible")){ var id = err.closest("div.sbox").attr("id").substr(1); $("#lang-" + id).trigger("click"); } $('html, body').animate({scrollTop:err.find("input,textarea").offset().top-20}, 400); } }; CmsTextManager.prototype.baseFieldBinds = function(jqObj){ var _this = this; // Replace spaces on blur jqObj.find("input[id^='a_link-seg-']").bind("blur", function(){ $(this).val(_this.removeSpecial($(this).val().trim())); }); // On title blur insert link segment based on title, if no segment entered jqObj.find("textarea[id^='a_title-']").bind("blur", function(){ var u = $(this).closest("ul").find("input[id^='a_link-seg-']"); if(u.val() == "" && $(this).val() != "") u.val(_this.removeSpecial($(this).val().trim())); }); }; CmsTextManager.prototype.bindShowHideFields = function(id, jqObj, bReset){ if(bReset) jqObj.find("#a_npk").val(""); // Hide all special fields li if(CBase.dt.oShow['all']){ jqObj.find(CBase.dt.oShow['all']).each(function(){ if($(this).is("input") || $(this).is("textarea") || $(this).is("select")){ $(this).addClass("skip").closest("li").hide(); if(bReset) $(this).val('') }else if($(this).is("div") || $(this).is("ul")){ $(this).hide().find("textarea, select").addClass("skip"); if(bReset) $(this).find("textarea, select").val(''); } }); } // Show all special fields we need to show for each type if(id && CBase.dt.oShow[id] != undefined){ if(CBase.dt.oShow[id]["s"]){ jqObj.find(CBase.dt.oShow[id]['s']).each(function(){ if($(this).is("input") || $(this).is("select") || $(this).is("textarea")) $(this).removeClass("skip").closest("li").fadeIn("normal"); else if($(this).is("div") || $(this).is("ul")) $(this).fadeIn("normal").find("textarea, select").removeClass("skip"); }); } } }; /** * Function to remove special characters from text, returns the result string * * @author Aivars Žukovskis * @category cmsTextmanager */ CmsTextManager.prototype.removeSpecial = function(text){ var specialChars = { "ā" : "a", "č" : "c", "ē" : "e", "ģ" : "g", "ī" : "i", "ķ" : "k", "ļ" : "l", "ņ" : "n", "ū" : "u", "š" : "s", "ž" : "z", " " : "-" }; if(text.length) { var lower = text.toLowerCase(); var result = ""; for(var i=0; i