File manager - Edit - /home/jardides/www/Jardi-design/old/administrator/components/com_templateck/assets/templateck_template.js
Back
/** * @name Template Creator CK 3 * @package com_templateck * @copyright Copyright (C) 2013. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @author Cedric Keiflin - http://www.template-creator.com - http://www.joomlack.fr */ var $ck = jQuery.noConflict(); var facktoload = false; function initInterface() { convertOldMaincontent(); $ck('.ckbloc, .ckrowcontainer', $ck('#body')).each(function(i, bloc) { addControlsOnHover(bloc); }); $ck('.alert-message > a.close').click(function() { $ck(this).parent().remove(); }); // checkModules(); // $ck('#body').removeClass('expert'); checkExpertModeOnPageload(); toggleBootstrap(); keepAlive(); initSortables(); addFixedTopbar(); convertOldBanner(); ckFixSources(); } /** * Method that will fix the path for elements when moving between domains/servers */ function ckFixSources() { $ck('[data-src]').each(function() { if ($ck(this).attr('src') != URIROOT + $ck(this).attr('data-src')) $ck(this).attr('src', URIROOT + $ck(this).attr('data-src')); }); } /* method introduced after the 3.4 version to update the old banners */ function convertOldBanner() { $ck('.ckrowcontainer > .bannerlogo').css('width','auto').find('.tab_blocstyles').attr('blocwidth', ''); } /* method introduced after the 3.4 version to update the old maincontent */ function convertOldMaincontent() { $ck('.column1,.column2').each(function() { if( ! $ck(this).find('.ckrowcontainer').length) { $ck(this).append('<div class="ckrowcontainer"></div>'); } }); } function addFixedTopbar(){ $ck(window).bind('scroll resize load', function() { if ($ck(window).scrollTop() > $ck('#leftpanel').offset().top) { $ck('#leftpanel') .addClass('floating') .css({'position' : 'fixed', 'top': '0', 'height': ''}) .before('<div id="leftpanel_tmp" style="height:0px;"></div>'); } else if ($ck('#leftpanel_tmp').length && $ck(window).scrollTop() < $ck('#leftpanel_tmp').offset().top){ $ck('#leftpanel_tmp').remove(); $ck('#leftpanel') .removeClass('floating') .css({'position' : 'absolute', 'top': '', height: ($ck(window).height() - $ck('#leftpanel').offset().top + $ck(window).scrollTop()) + 'px'}); } else if(! $ck('#leftpanel').hasClass('floating')) { $ck('#leftpanel') .css({'top': '', height: ($ck(window).height() - $ck('#leftpanel').offset().top + $ck(window).scrollTop()) + 'px'}); } }); /*$ck(window).bind('resize load', function() { if ($ck(window).width() < '768') { $ck('#leftpanel').addClass('reduced'); } else { $ck('#leftpanel').removeClass('reduced'); } });*/ } /* * Functions to manage colors conversion * */ function hexToR(h) { return parseInt((cutHex(h)).substring(0, 2), 16) } function hexToG(h) { return parseInt((cutHex(h)).substring(2, 4), 16) } function hexToB(h) { return parseInt((cutHex(h)).substring(4, 6), 16) } function cutHex(h) { return (h.charAt(0) == "#") ? h.substring(1, 7) : h } function hexToRGB(h) { return 'rgb(' + hexToR(h) + ',' + hexToG(h) + ',' + hexToB(h) + ')'; } function str_repeat(text, times){ var result=''; while (times > 0) { if (times&1) result+=text; times>>=1; text+=text; } return result; } function ckSetPaletteColors() { var colors = new Array(); $ck('#ckcolorspalette .colorPicker').each(function() { colors.push($ck(this).val().replace('#', '')); }); colors = colors.join(','); setPaletteOnColorPicker(colors, 'colpick_palette'); } function setPaletteOnColorPicker(colors, object) { CKBox.close(); colors = colors.split(','); $ck('span',$ck('#'+object)).each(function(i, el) { $ck(el).css('background-color', '#'+colors[i]); }); $ck('#body').attr('colorpalette', colors); } function initSortables() { $ck( "#body" ).sortable({ items: ".wrapper", axis: "y", handle: "> .editorck .controlMove", forcePlaceholderSize: true, forceHelperSize: true, dropOnEmpty: true, tolerance: "pointer", placeholder: "placeholder", zIndex: 9999, sort: function( event, ui ) { ui.helper.find('.editorck').hide(); }, receive: function( event, ui ) { var newblock = $ck(this).find('.blocselect'); if (ui.sender.hasClass('dragtoaddwrapper')) { newblock.css('float', 'none').addClass('ckwait'); createWrapperBloc(newblock); } else { newblock.remove(); } } }); $ck( ".wrapper > .inner" ).sortable({ items: "> .ckbloc", // containment: "parent", // axis: "y", connectWith: ".wrapper > .inner, .ckrowcontainer", tolerance: "pointer", handle: "> .editorck .controlMove", forceHelperSize: true, dropOnEmpty: true, forcePlaceholderSize: true, placeholder: "placeholder", zIndex: 9999, sort: function( event, ui ) { ui.helper.find('.editorck').hide(); }, start: function( event, ui ){ ui.placeholder.height(parseInt($ck('> .inner',ui.helper).height())); ui.placeholder.parent().trigger('mouseover'); }, receive: function( event, ui ) { var newblock = $ck(this).find('.blocselect'); if (ui.sender.hasClass('dragtoadd')) { newblock.css('float', 'none').addClass('ckwait'); createBloc(newblock, ui.sender.attr('data-type')); makeRowcontainerSortable($ck('.ckrowcontainer')); } else { newblock.remove(); } ui.placeholder.parent().trigger('mouseleave'); }, stop: function( event, ui ){ ui.placeholder.parent().trigger('mouseleave'); } }); $ck( ".wrapper > .inner .ckbloc" ).sortable({ items: "> .inner > .ckbloc", // containment: "parent", helper: "clone", handle: "> .editorck .controlMove", forcePlaceholderSize: true, tolerance: "pointer", placeholder: "placeholderchild", sort: function( event, ui ) { ui.helper.find('.editorck').hide(); }, start: function( event, ui ){ if (! ui.item.hasClass('ckrowcontainer')) { ui.placeholder.width(parseInt($ck('> .inner',ui.helper).width())); ui.placeholder.append('<div class="inner" />'); } else { ui.placeholder.width(ui.helper.width() - 2); ui.placeholder.append('<div class="inner" />'); } ui.placeholder.parent().trigger('mouseover'); }, stop: function( event, ui ) { ui.item.css('display', ''); ui.placeholder.parent().trigger('mouseleave'); } }); $ck( ".ckrowcontainer" ).each(function(i, item){ makeRowcontainerSortable(item); }); $ck( ".ckrow > .inner" ).sortable({ items: "> .ckrowcontainer", helper: "clone", handle: "> .editorck .controlMove", forcePlaceholderSize: true, tolerance: "pointer", placeholder: "placeholderchild", start: function( event, ui ){ if (! ui.item.hasClass('ckrowcontainer')) { ui.placeholder.width(parseInt($ck('> .inner',ui.helper).width())); ui.placeholder.append('<div class="inner" />'); } else { ui.placeholder.width(ui.helper.width() - 2); ui.placeholder.append('<div class="inner" />'); } } }); $ck( ".wrapper .main" ).sortable({ items: ".column2, .center", // containment: "parent", connectWith: ".main", helper: "clone", handle: "> .editorck .controlMove", forcePlaceholderSize: true, placeholder: "placeholderchild", sort: function( event, ui ) { ui.helper.find('.editorck').hide(); }, start: function( event, ui ){ ui.placeholder.width($ck('> .inner',ui.helper).width()); ui.placeholder.append('<div class="inner" />') }, change: function( event, ui ) { // moveBloc(ui); } }); addDraggableToBlocks(); $ck( ".dragtoadd.row, .dragtoadd.banner" ).draggable({ connectToSortable: ".wrapper > .inner", helper: "clone", tolerance: "pointer", appendTo: "body", scroll: false, start: function( event, ui ) { // $ck('#leftpanel').css('overflow', 'visible'); }, stop: function( event, ui ) { // $ck('#leftpanel').css('overflow', ''); } }); $ck( ".dragtoaddwrapper" ).draggable({ connectToSortable: "#body", helper: "clone", appendTo: "body", scroll: false, // revert: "invalid" start: function( event, ui ) { // $ck('#leftpanel').css('overflow', 'visible'); }, stop: function( event, ui ) { // $ck('#leftpanel').css('overflow', ''); } }); } function addDraggableToBlocks() { $ck( ".dragtoadd:not(.row):not(.banner)" ).draggable({ // connectToSortable: ".wrapper > .inner, .wrapper > .inner > .ckbloc > .inner, .wrapper > .inner > .ckbloc > .inner > .ckrowcontainer, .wrapper > .inner > .ckbloc > .inner > .ckrowcontainer > .ckbloc > .inner > .ckrowcontainer", connectToSortable: ".wrapper > .inner, .ckrowcontainer", helper: "clone", appendTo: "body", scroll: false, // cancel: '.ckrowcontainer' // revert: "invalid" // tolerance: "pointer", start: function( event, ui ){ // $ck('#leftpanel').css('overflow', 'visible'); $ck('.ckrowcontainer').each(function(i, item){ item = $ck(item); if (! item.find('*').length) { item.addClass('empty'); } }); }, stop: function( event, ui ){ // $ck('#leftpanel').css('overflow', ''); $ck('.ckrowcontainer.empty').removeClass('empty'); } }); } function makeRowcontainerSortable(item) { $ck(item).sortable({ items: ".ckbloc", // cancel: '.ckrow', // containment: "parent", helper: "clone", handle: "> .editorck .controlMove", forcePlaceholderSize: true, connectWith: ".ckrowcontainer, .wrapper > .inner", // tolerance: "pointer", placeholder: "placeholder", sort: function( event, ui ) { ui.helper.find('.editorck').hide(); if (ui.placeholder.parents('.ckrow').length > 1) { ui.helper.addClass('tocancel'); } }, start: function( event, ui ){ ui.placeholder.height(parseInt($ck('> .inner',ui.helper).height())); ui.placeholder.parent().trigger('mouseover'); }, stop: function( event, ui ){ ui.placeholder.parent().trigger('mouseleave'); }, receive: function( event, ui ) { if (ui.sender.find('*').length == 0) { ui.sender.html(ui.sender.html().trim()); } if (ui.sender.attr('data-type') == 'row' && ui.helper && ui.helper.hasClass('tocancel')) { ui.helper.remove(); ui.placeholder.remove(); $ck(this).find('.blocselect').remove(); alert('This is too much ! You can not use more than 2 levels of imbrication'); // return false; } else { var newblock = $ck(this).find('.blocselect'); if (ui.sender.hasClass('dragtoadd')) { newblock.css('float', 'none').addClass('ckwait'); createBloc(newblock, ui.sender.attr('data-type')); } else { newblock.remove(); } } ui.placeholder.parent().trigger('mouseleave'); } }); } /*function jInsertEditorText(text, editor) { var newEl = new Element('span').set('html', text); var valeur = newEl.getChildren()[0].getAttribute('src'); $(editor).value = valeur; $(editor).fireEvent('change'); $ck('#'+editor).trigger('change'); }*/ function ckSelectFile(file, field) { if (! field) { alert('ERROR : no field given in the function ckSelectFile'); return; } $ck('#'+field).val(file).trigger('change'); } /*function initTooltips() { new Tips($$('.hasTip'), {maxTitleChars: 50, fixed: false}); }*/ function setTooltip(el, attrib) { attrib = attrib || 'title'; el = el || document; $ck( el ).tooltip({ items: ".infotip", content: function() { return $ck(this).attr(attrib); }, close: function( event, ui ) { ui.tooltip.hide(); }, position: { my: "center bottom-20", at: "left top", using: function( position, feedback ) { $ck( this ).css( position ); } }, track: false, tooltipClass: "cktooltipinfo" }); } function initModalPopup() { CKBox.initialize({}); CKBox.assign($ck('a.modal'), { parse: 'rel' }); } function initAccordionStyles() { $ck('.menustylesblockaccordion').hide(); $ck('.ckproperty').each(function(i, tab) { tab = $ck(tab); $ck('.menustylesblockaccordion', tab).first().show(); $ck('.menustylesblocktitle', tab).first().addClass('open'); $ck('.menustylesblocktitle:not(.initiated)', tab).each(function() { $ck(this).addClass('initiated'); $ck(this).click(function() { if (!$ck(this).hasClass('open')) { // $ck('.menustylesblockaccordion', tab).slideUp('fast'); blocstyle = $ck(this).next('.menustylesblockaccordion'); // $ck('.menustylesblocktitle', tab).removeClass('open'); $ck(this).addClass('open'); blocstyle.slideDown('fast'); } else { $ck(this).next('.menustylesblockaccordion').slideUp('fast'); $ck(this).removeClass('open'); } }); }); }); } function initColorPickers() { var startcolor = ''; $ck('.colorPicker').each(function(i, picker) { picker = $ck(picker); picker.mousedown(function() { if (picker.val()) { startcolor = picker.val().replace('#',''); } else { startcolor = 'fff000'; } picker.colpick({ layout:'full', color: startcolor, livePreview: true, submitText: Joomla.JText._('CK_OK', 'OK'), cleanerText: Joomla.JText._('CK_CLEAR', 'Clear'), copyText: Joomla.JText._('CK_COPY', 'Copy'), pasteText: Joomla.JText._('CK_PASTE', 'Paste'), selectPalette: Joomla.JText._('CK_SELECT_PALETTE', 'Select a palette'), onChange:function(hsb,hex,rgb,el,bySetColor) { $ck(el).css('background-color','#'+hex); setpickercolor(picker); // force the # character if (picker.val().indexOf("#") == -1) { picker.val('#'+picker.val()); } // Fill the text box just if the color was set using the picker, and not the colpickSetColor function. if(!bySetColor) $ck(el).val('#' + hex); }, onSubmit:function(hsb,hex,rgb,el,bySetColor) { picker.trigger('change'); }, onClean: function(button, cal) { picker.val(''); picker.css('background', 'none'); picker.trigger('change'); }, onCopy: function(color, cal) { CLIPBOARDCOLORCK = picker.val(); }, onPaste: function(color, cal) { picker.val(CLIPBOARDCOLORCK); picker.css('background', CLIPBOARDCOLORCK); picker.trigger('change'); setpickercolor(picker); }, onPaletteColor: function(hsb,hex,rgb,el,bySetColor) { picker.val('#'+hex); picker.css('background','#'+hex); picker.trigger('change'); setpickercolor(picker); }, }).keyup(function(){ $ck(this).colpickSetColor(this.value); picker.trigger('change'); }); }); }); } /** * Method to give a black or white color to have a good contrast */ function setpickercolor(picker) { pickercolor = 0.213 * hexToR(picker.val()) / 100 + 0.715 * hexToG(picker.val()) / 100 + 0.072 * hexToB(picker.val()) / 100 < 1.5 ? '#FFF' : '#000'; picker.css('color', pickercolor); return pickercolor; } function createGradientPreview(prefix) { if (!$ck('#'+prefix + 'gradientpreview')) return; var area = $ck('#'+prefix + 'gradientpreview'); if ($ck('#'+prefix + 'backgroundcolorstart') && $ck('#'+prefix + 'backgroundcolorstart').val()) { $ck('#'+prefix + 'backgroundcolorend').removeAttr('disabled'); $ck('#'+prefix + 'backgroundpositionend').removeAttr('disabled'); } else { $ck('#'+prefix + 'backgroundcolorend').attr({'disabled': 'disabled', 'value': ''}); $ck('#'+prefix + 'backgroundcolorend').css('background-color', ''); $ck('#'+prefix + 'backgroundpositionend').attr({'disabled': 'disabled', 'value': '100'}); } if ($ck('#'+prefix + 'backgroundcolorend') && $ck('#'+prefix + 'backgroundcolorend').val()) { $ck('#'+prefix + 'backgroundcolorstop1').removeAttr('disabled'); $ck('#'+prefix + 'backgroundpositionstop1').removeAttr('disabled'); $ck('#'+prefix + 'backgroundopacity').attr({'disabled': 'disabled', 'value': ''}); } else { $ck('#'+prefix + 'backgroundcolorstop1').attr({'disabled': 'disabled', 'value': ''}); $ck('#'+prefix + 'backgroundcolorstop1').css('background-color', ''); $ck('#'+prefix + 'backgroundpositionstop1').attr({'disabled': 'disabled', 'value': ''}); $ck('#'+prefix + 'backgroundopacity').removeAttr('disabled'); } if ($ck('#'+prefix + 'backgroundcolorstop1') && $ck('#'+prefix + 'backgroundcolorstop1').val()) { $ck('#'+prefix + 'backgroundcolorstop2').removeAttr('disabled'); $ck('#'+prefix + 'backgroundpositionstop2').removeAttr('disabled'); } else { $ck('#'+prefix + 'backgroundcolorstop2').attr({'disabled': 'disabled', 'value': ''}); $ck('#'+prefix + 'backgroundcolorstop2').css('background-color', ''); $ck('#'+prefix + 'backgroundpositionstop2').attr({'disabled': 'disabled', 'value': ''}); } var gradientstop1 = ''; var gradientstop2 = ''; var gradientend = ''; var gradientpositionstop1 = ''; var gradientpositionstop2 = ''; var gradientpositionend = ''; if ($ck('#'+prefix + 'backgroundpositionstop1') && $ck('#'+prefix + 'backgroundpositionstop1').val()) gradientpositionstop1 = $ck('#'+prefix + 'backgroundpositionstop1').val() + '%'; if ($ck('#'+prefix + 'backgroundpositionstop2') && $ck('#'+prefix + 'backgroundpositionstop2').val()) gradientpositionstop2 = $ck('#'+prefix + 'backgroundpositionstop2').val() + '%'; if ($ck('#'+prefix + 'backgroundpositionstop3') && $ck('#'+prefix + 'backgroundpositionend').val()) gradientpositionend = $ck('#'+prefix + 'backgroundpositionend').val() + '%'; if ($ck('#'+prefix + 'backgroundcolorstop1') && $ck('#'+prefix + 'backgroundcolorstop1').val()) gradientstop1 = $ck('#'+prefix + 'backgroundcolorstop1').val() + ' ' + gradientpositionstop1 + ','; if ($ck('#'+prefix + 'backgroundcolorstop2') && $ck('#'+prefix + 'backgroundcolorstop2').val()) gradientstop2 = $ck('#'+prefix + 'backgroundcolorstop2').val() + ' ' + gradientpositionstop2 + ','; if ($ck('#'+prefix + 'backgroundcolorend') && $ck('#'+prefix + 'backgroundcolorend').val()) gradientend = $ck('#'+prefix + 'backgroundcolorend').val() + ' ' + gradientpositionend; var stylecode = '<style type="text/css">' + '#' + prefix + 'gradientpreview {' + 'background:' + $ck('#'+prefix + 'backgroundcolorstart').val() + ';' + 'background-image: -o-linear-gradient(top,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + 'background-image: -webkit-linear-gradient(top,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + 'background-image: -webkit-gradient(linear, left top, left bottom,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + 'background-image: -moz-linear-gradient(top,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + 'background-image: -ms-linear-gradient(top,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + 'background-image: linear-gradient(top,' + $ck('#'+prefix + 'backgroundcolorstart').val() + ',' + gradientstop1 + gradientstop2 + gradientend + ');' + '}' + '</style>'; area.find('.injectstyles').html(stylecode); } function ckShowColorsPalette() { // CKBox.open({url: \''+URIBASE+'/index.php?option=com_templateck&view=colors&tmpl=component&format=html&function=setPaletteOnColorPicker&returnName=colpick_palette\', handler: \'iframe\', size: {x: 700, y: 600}}); $boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSetPaletteColors();CKBox.close()">' + Joomla.JText._('CK_SAVE_CLOSE') + '</a>'; // CKBox.open({handler: 'iframe', style: {padding: '10px'}, footerHtml: $boxfooterhtml var myurl = URIBASE + '/index.php?option=com_templateck&view=template&layout=ajaxcolorspalette&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { // position: blockposition, // type: type, // blockid: blockid } }).done(function(code) { $ck('#ckcolorspalette').remove(); var colorspalette = $ck(code); $ck(document.body).append(colorspalette); colorspalette.hide(); CKBox.open({handler: 'inline', content: 'ckcolorspalette', footerHtml: $boxfooterhtml, style: {padding: '10px'}, size: {x: '600px', y: '400px'}}); var colors = $ck('#body').attr('colorpalette'); if (colors) { colors = colors.split(','); for (var i=0; i< colors.length; i++) { var field = $ck('#ckcolorspalette .colorPicker').eq(i); if (colors[i]) { // setpickercolor(field); field.attr('value', '#' + colors[i]).trigger('change'); field.css('background-color', field.attr('value')); setpickercolor(field); } } } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function toggleNoeditorMode(button) { if ($ck('#body').hasClass('noeditor')) { $ck('#body').addClass('editor'); $ck('#body').removeClass('noeditor'); $ck(button).removeClass('noeditor'); } else { $ck('#body').addClass('noeditor'); $ck('#body').removeClass('editor'); $ck(button).addClass('noeditor'); } } function toggleExpertMode(button) { if ($ck('#body').hasClass('expert')) { $ck('#body').removeClass('expert'); $ck(button).removeClass('expert'); } else { $ck('#body').addClass('expert'); $ck(button).addClass('expert'); } } function printPositions() { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); $ck('.controlfocus').removeClass('controlfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); $ck(document.body).append('<div id="ckwaitoverlay"></div>'); $ck('.ckbloc').each(function(i, el) { el = $ck(el); if (el.attr('ckmoduleposition')) { elpos = $ck('<div class="modulepositionpreview"><span class="modulepositionpreview_name">'+el.attr('ckmoduleposition')+'</span></div>') el.append(elpos); el.css('position', 'relative'); elpos.css('position', 'absolute') .css('top', 0) .css('left', 0) .css('right', 0) .css('bottom', 0) } }); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxprintpositions&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').val() } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); html2canvas($ck('#body'), { onrendered: function(canvas) { $ck('#ckwaitoverlay').remove(); // document.body.appendChild(canvas); $ck('#printpositionscontainer').empty().append(canvas); $ck('.modulepositionpreview').remove(); // $ck('#ckwaitoverlay').remove(); } }); // $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); // $ck('#ckwaitoverlay').remove(); }); } function checkExpertModeOnPageload() { if ($ck('#body').hasClass('expert')) { $ck('#mainmenuck .ckexpert').parent().addClass('expert'); } else { $ck('#mainmenuck .ckexpert').parent().removeClass('expert'); } } function showThemes() { $ck('.leftpanel').not($ck('#showthemes')).fadeOut(); $ck('#showthemes').fadeIn(); } function hideThemes() { $ck('#showthemes').fadeOut(); } function toggleThemes(button) { if ($ck(button).hasClass('active')) { // $ck('#showthemes').hide(); // $ck(button).removeClass('active'); $ck('#showthemes').fadeOut(); } else { // $ck('#showthemes').show().width(0).animate({'width': '250px'}); // $ck(button).addClass('active'); $ck('#showthemes').fadeIn(); } } function cksubmitbuttonsave() { $ck('.editorck').remove(); $ck('.paused').removeClass('paused'); // save the widgets data var widgets = Object(); $ck('#widgetsElements .widget').each(function(i) { var widget = new Object(); widget['name'] = $ck(this).attr('data-name'); widget['enabled'] = $ck(this).attr('data-enabled'); widget['data'] = $ck(this).find('.widgetdata').html(); widgets[$ck(this).attr('data-name')] = widget; }); jsonWidgets = JSON.stringify(widgets); $ck('#widgets').attr('value', jsonWidgets.replace(/"/g, "|qq|")); // save the module positions var modulepositions = new Array(); $ck('.ckbloc[isdisabled!=true]').each(function(i, el) { if ($ck(el).attr('ckmoduleposition')) modulepositions.push($ck(el).attr('ckmoduleposition')); }); modulepositions = modulepositions.join(','); $ck('#modules').attr('value', modulepositions); Joomla.submitbutton('template.save'); } function toggleBootstrap() { if ($ck('#body > .tab_blocstyles').length && $ck('#body > .tab_blocstyles').attr('blocloadboostrap') == '0' || $ck('#joomlaversion').attr('value') != 'j3') { // $ck('#body > .tab_blocstyles').attr('blocloadboostrap', '0'); $ck("#bootstrapload").empty(); $ck('#bootstrapload').append('<link rel="stylesheet" type="text/css" href="' + URIBASE + '/components/com_templateck/default.css">'); $ck("#bootstrapload").removeClass('bootstraploaded'); } else if ($ck('#body > .tab_blocstyles').length && $ck('#body > .tab_blocstyles').attr('blocloadboostrap') == '1') { $ck("#bootstrapload").empty(); $ck('#bootstrapload').append('<link rel="stylesheet" type="text/css" href="' + URIBASE + '/components/com_templateck/bootstrap.css">'); $ck("#bootstrapload").addClass('bootstraploaded'); } } function toogleWrapperFluid() { if (!$ck('#blocwrapperfluid').length && $ck('> .tab_blocstyles', $ck('#body')).length && !$ck('> .tab_blocstyles', $ck('#body')).attr('blocwrapperfluid').length) return; if ($ck('#blocwrapperfluid').length) { value = $ck('#blocwrapperfluid').attr('value'); } else { value = $ck('> .tab_blocstyles', $ck('#body')).attr('blocwrapperfluid'); } if (value == 'fluid') { $ck('.container').removeClass('container').addClass('container-fluid'); } else { $ck('.container-fluid').removeClass('container-fluid').addClass('container'); } } /* function ckaddtofavorite(button) { var editionarea = $ck('#popup_editionck'); fieldslist = new Object(); $ck('.inputbox', editionarea).each(function(i, el) { el = $ck(el); if (el.attr('type') != 'radio') { fieldslist[el.attr('id')] = el.attr('value'); } else { if (el.attr('checked')) { fieldslist[el.attr('id')] = 'checked'; } else { fieldslist[el.attr('id')] = ''; } } }); favorite = JSON.stringify(fieldslist); favorite = favorite.replace(/#/g, "|di|"); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsavefavorite&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { favorite: favorite, focusclass: $ck('.focus').attr('class') } }).done(function(code) { alert('ok'); }).fail(function(code) { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } */ function copytoclipboard(button) { // CLIPBOARDCK = document.getElements('.inputbox').getProperties('id', 'value'); CLIPBOARDCK = new Array(); $ck('.inputbox').each(function(i, el) { var tmp = new Object() CLIPBOARDCK[el.id] = el.value; if ($ck(el).attr('type') == 'radio') { if ($ck(el).attr('checked')) { CLIPBOARDCK[el.id] = 'checked'; } else { CLIPBOARDCK[el.id] = ''; } } }); alert(Joomla.JText._('CK_COPYTOCLIPBOARD', 'Current styles copied to clipboard !')); } function pastefromclipboard(button) { if (CLIPBOARDCK) { if (!confirm(Joomla.JText._('CK_COPYFROMCLIPBOARD', 'Apply styles from Clipboard ? This will replace all current existing styles.'))) return; for (var field in CLIPBOARDCK) { // CLIPBOARDCK.each(function(field) { // if ($(field.id)) { // $(field.id).value = field.value; // } // if (CLIPBOARDCK[field]) { $ck('#' + field).val(CLIPBOARDCK[field]); if ($ck('#' + field).attr('type') == 'radio') { if (CLIPBOARDCK[field] == 'checked') $ck('#' + field).attr('checked', CLIPBOARDCK[field]); } // } // }); } getPreviewAreastylescss('previewareabloc'); } else { alert(Joomla.JText._('CK_CLIPBOARDEMPTY', 'Clipboard is empty')); } } function validateTemplateName(input) { input = $ck(input); var name = input.attr('value').replace(/\s/g, ""); name = name.replace(/&/g, ""); name = name.toLowerCase(); input.attr('value', name); } /* * Show the window for global infos (name, date, author...) */ function editGlobalinfos() { $ck('#infos_code').toggle('fast'); } /* * Function to load the HTML modele in the page */ function loadModele(name) { var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=" + name + "&format=raw"; $ck.ajax({ type: "POST", url: myurl }).done(function(code) { $ck("#conteneur").html(code); if ($ck('#joomlaversion').attr('value') == 'j3') { $ck('#body > .tab_blocstyles').attr('blocloadboostrap', '1'); } checkModules(); loadTheme('default', 'no'); $ck("#leftpanel").removeClass('hiddenpanel'); initSortables(); }).fail(function(code) { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function loadTheme(themename, ask) { valid = '1'; valid = confirm(Joomla.JText._('CK_ERASE_WITH_NEW_THEME', 'WARNING : This will erase your data with the new theme, continue ?')); if (valid == null || valid == "") return; $ck(document.body).append('<div id="ckwaitoverlay"></div>'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxloadtheme&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: {themename: themename} }).done(function(code) { applyTheme(code); toggleBootstrap(); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function applyTheme(code) { code = code.replace(/\|di\|/g, "#"); theme = $ck.parseJSON(code); $ck('#body .ckstyle').empty(); $ck('#body .ckprops').remove(); for (i = 0; i < theme.length; i++) { bloc = theme[i]; if (!bloc) continue; focusblocs = $ck(bloc['type']); focusblocs.each(function(k, focusbloc) { j = 0; focusbloc = $ck(focusbloc); while (bloc['ckprops' + j]) { blocClass = $ck('<div ' + bloc['ckprops' + j] + ' />').removeClass('ckprops').attr('class'); $ck('> .' + blocClass, focusbloc).remove(); focusbloc.prepend('<div ' + bloc['ckprops' + j] + ' />'); j++; } if (bloc['style']) { blocstyle = bloc['style'].replace(/\|ID\|/g, focusbloc.attr('id')) .replace(/\|URIBASE\|/g, URIBASE + "/") .replace(/\|TCK_COMPONENT\|/g, "components/com_templateck") .replace(/\|TCK_ADMIN_COMPONENT\|/g, "administrator/components/com_templateck") ; $ck('> .ckstyle', focusbloc).empty().append('<style>' + blocstyle + '</style>'); } }); } toogleWrapperFluid(); } function getTheme() { var blocs = new Array(); var types = Array('.body', '.wrapper', '.mainbanner', '.bannerlogo', '.bannermenu', '.bannerlogodesc', '.banner', '.horiznav', '.singlemodule', '.flexiblemodules', '.flexiblemodules > .inner > .flexiblemodule:first-child', '.flexiblemodules > .inner > .flexiblemodule:first-child + .flexiblemodule', '.flexiblemodules > .inner > .flexiblemodule:first-child + .flexiblemodule + .flexiblemodule', '.flexiblemodules > .inner > .flexiblemodule:first-child + .flexiblemodule + .flexiblemodule + .flexiblemodule', '.flexiblemodules > .inner > .flexiblemodule:first-child + .flexiblemodule + .flexiblemodule + .flexiblemodule + .flexiblemodule', '.maincontent', '.column1', '.main', '.maintop', '.maincenter', '.mainbottom', '.center', '.column2', '.centertop', '.centerbottom', '.content'); for (i = 0; i < types.length; i++) { type = types[i]; if (!$ck(type).length) { alert('pas de ' + type + ' dans la page !'); continue; } bloc = $ck(type); var cssblocs = new Object(); cssblocs['type'] = type; blocstyle = ($ck('> .ckstyle', bloc).length && $ck('> .ckstyle', bloc).html()) ? $ck('> .ckstyle', bloc).html() : ''; if (blocstyle) { var id = new RegExp(bloc.attr('id'), "g"); blocstyle = blocstyle.replace(id, "|ID|"); var uri = new RegExp(URIBASE + "/", "g"); blocstyle = blocstyle.replace(uri, "|URIBASE|"); } cssblocs['style'] = blocstyle; $ck('> .ckprops', bloc).each(function(i, ckprops) { ckprops = $ck(ckprops); text = 'class="' + ckprops.attr('class') + '" '; fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); text += 'fieldslist="' + ckprops.attr('fieldslist') + '" '; fieldslist.each(function(fieldname) { text += fieldname + '="' + ckprops.attr(fieldname) + '" '; }); cssblocs['ckprops' + i] = text; }); blocs[i] = cssblocs; } return blocs; } function saveTheme() { var theme = getTheme(); theme = JSON.stringify(theme); theme = theme.replace(/#/g, "|di|"); themename = prompt('nom du theme ?'); if (themename == null || themename == '') return; var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsavetheme&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: {theme: theme, themename: themename} }).done(function(code) { $ck("#themefile").html(code); checkModules(); }).fail(function(code) { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function getFavorite() { var bloc = $ck('.cssfocus'); var cssbloc = new Object(); cssbloc['class'] = bloc.attr('class'); blocstyle = ($ck('> .ckstyle', bloc).length && $ck('> .ckstyle', bloc).html()) ? $ck('> .ckstyle', bloc).html() : ''; blocss = ''; if (blocstyle) { var id = new RegExp(bloc.attr('id'), "g"); blocstyle = blocstyle.replace(id, "|ID|"); blocss = blocstyle; var uri = new RegExp(URIBASE + "/", "g"); blocstyle = blocstyle.replace(uri, "|URIBASE|"); } cssbloc['css'] = blocss; cssbloc['style'] = blocstyle; $ck('> .ckprops', bloc).each(function(i, ckprops) { ckprops = $ck(ckprops); text = 'class="' + ckprops.attr('class') + '" '; fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); text += 'fieldslist="' + ckprops.attr('fieldslist') + '" '; // fieldslist.each(function(fieldname) { // text += fieldname + '="' + ckprops.attr(fieldname) + '" '; // }); for (var f = 0;f < fieldslist.length; f++ ) { text += fieldslist[f] + '="' + ckprops.attr(fieldslist[f]) + '" '; } cssbloc['ckprops' + i] = text; }); return cssbloc; } function savefavorite(id) { if (! id) id = -1; var favorite = getFavorite(); var favoriteStyle = favorite['style']; favoritestring = JSON.stringify(favorite); favoritestring = favoritestring.replace(/#/g, "|di|"); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsavefavorite&raw=1"; $ck.ajax({ type: "POST", url: myurl, data: { favorite: favoritestring, id: id, focusclass: $ck('.focus').attr('class') } }).done(function(code) { try { response = JSON.parse(code); if (response.status == '1') { if (id == -1) ckAddFavoriteToList(response.msg, favorite); // alert(Joomla.JText._('CK_SUCCESS_CREATING_FAVORITEFILE', 'Success !')); } else { alert(Joomla.JText._('CK_FAILED', 'Failed')); } } catch(err) { alert( 'ERROR : ' + err.message ); } // if (parseInt(code) == code) { // $ck('#showfavorites > div').append('<div class="favoritethumb" onmouseout="restoreBeforeFavorite()" onmouseover="previewFavoriteDirect(this)" onclick="loadFavorite(\'favorite' + code + '\', \'favorites\', 1)"><img src="'+URIBASE+'/components/com_templateck/images/favorite.png" style="height:32px;width:32px;margin:0;padding:0;" />' // + '<div class="favoritethumbstyles">'+favoriteStyle+'</div>' // + '</div>'); // alert(Joomla.JText._('CK_SUCCESS_CREATING_FAVORITEFILE', 'Success !')); // } else { // alert(Joomla.JText._('CK_FAILED', 'Failed')); // } }).fail(function(code) { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckAddFavoriteToList(i, favorite) { var name = 'favorite' + i; var html = '<div class="ckmyfavoriterow clearfix">' + '<div id="ckmyfavorite' + name + '" data-name="' + name + '" style="" class="favoritethumb ckmyfavorite" data-merge="0" onmouseout="restoreBeforeFavorite()" onmouseover="previewFavoriteDirect(this)" onclick="loadFavorite(\'' + name + '\', \'favorites\', 1, this)">' + '<div class="themeindice">' + i + '</div>' + '<div class="ckstyle">' + favorite['style'].replace(/\|di\|/g,'#').replace(/\|ID\|/g, 'ckmyfavorite' + name) + '</div>' + '<div class="inner">' + 'Lorem ipsum dolor sit amet' + '<div class="favoritethumbstyles">' + favorite['style'] + '</div>' + '</div>' + '</div>' + '<div class="ckbutton" onclick="ckEditFavorite(this);"><span class="fa fa-edit"></span> ' + Joomla.JText._('CK_EDIT') + '</div>' + '<div class="ckbutton" onclick="ckRemoveFavorite(this);"><span class="fa fa-remove" style="color:red;"></span> ' + Joomla.JText._('CK_DELETE') + '</div>' + '</div>'; $ck('#showfavorites > .inner').prepend(html); var newfavorite = $ck('#ckmyfavorite' + name); j = 0; while (favorite['ckprops' + j]) { blocClass = $ck('<div ' + favorite['ckprops' + j] + ' />', newfavorite).removeClass('ckprops').attr('class'); $ck('> .' + blocClass, newfavorite).remove(); newfavorite.prepend('<div ' + favorite['ckprops' + j] + ' />'); j++; } return html; } function loadFavorite(name, folder, apply, thumb) { FAVORITELOCKED = 1; valid = '1'; if (apply == 1) { valid = confirm(Joomla.JText._('CK_ERASE_WITH_NEW_FAVORITE', 'WARNING : This will erase your data with the new favorite, continue ?')); if (valid == null || valid == "") { FAVORITELOCKED = 0; restoreBeforeFavorite(); return; } } else { } $ck(document.body).append('<div id="ckwaitoverlay"></div>'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxloadfavorite"; $ck.ajax({ type: "POST", url: myurl, data: { name: name, folder: folder } }).done(function(code) { if (apply == 1) { applyFavorite(code, thumb); closeFavoritePopup(); } else { previewFavorite(code); } countdoaction(); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function restoreBeforeFavorite() { if ( FAVORITELOCKED == 1 ) return; if (BLOCCKSTYLESBACKUP != 'undefined') { focusbloc = $ck('.cssfocus'); $ck('> .ckstyle', focusbloc).empty().html(BLOCCKSTYLESBACKUP); } } function previewFavoriteDirect(thumb) { if ( FAVORITELOCKED == 1 ) return; thumb = $ck(thumb); focusbloc = $ck('.cssfocus'); //BLOCCKSTYLESBACKUP = $ck('> .ckstyle', focusbloc).html(); if (thumb.attr('data-merge') === '1') { var stylecode = thumb.find('.favoritethumbstyles').text(); // var re = /\/\*shadow start\*\/(.*?)\/\*shadow end\*\//gi; var re = /(\/\*shadow start\*\/([\s\S]*)?\/\*shadow end\*\/)/gi; stylecode = stylecode.replace(/\|di\|/g, "#"); stylecode = stylecode.replace(/\|ID\|/g, focusbloc.attr('id')).replace(/\|URIBASE\|/g, URIBASE + "/"); var focusblocstyle = $ck('> .ckstyle', focusbloc).text(); focusblocstyle = focusblocstyle.replace(re, ''); focusblocstyle = focusblocstyle + stylecode; $ck('> .ckstyle', focusbloc).empty().append('<style>' + focusblocstyle + '</style>'); } else { var stylecode = thumb.find('.favoritethumbstyles').html(); stylecode = stylecode.replace(/\|di\|/g, "#"); stylecode = stylecode.replace(/\|ID\|/g, focusbloc.attr('id')).replace(/\|URIBASE\|/g, URIBASE + "/"); $ck('> .ckstyle', focusbloc).empty().append(stylecode); } } function applyFavorite(code, thumb) { focusbloc = $ck('.cssfocus'); thumb = $ck(thumb); code = code.replace(/\|di\|/g, "#"); bloc = $ck.parseJSON(code); if (!bloc) return; j = 0; if (thumb.attr('data-merge') === '1') { while (bloc['ckprops' + j]) { blocClass = $ck('<div ' + bloc['ckprops' + j] + ' />', focusbloc).removeClass('ckprops').attr('class'); ckpropshtml = $ck('> .' + blocClass, focusbloc); var re = /(\/\*shadow start\*\/([\s\S]*)?\/\*shadow end\*\/)/gi; blocstyle = bloc['style'].replace(/\|ID\|/g, focusbloc.attr('id')).replace(/\|URIBASE\|/g, URIBASE + "/"); blocstyle = '/*shadow start*/' + blocstyle + '/*shadow end*/'; if ($ck('> .ckstyle', focusbloc).html().match(re)) { var blocstyle = $ck('> .ckstyle', focusbloc).html().replace(re, blocstyle); $ck('> .ckstyle', focusbloc).empty().append(blocstyle); } else { $ck('> .ckstyle', focusbloc).append(blocstyle); } if (ckpropshtml.length) { var blocmerge = $ck('<div ' + bloc['ckprops' + j] + ' />'); var fieldslistmerge = blocmerge.attr('fieldslist').split(','); for (k=0;k<fieldslistmerge.length;k++) { if (! ckpropshtml.attr(fieldslistmerge[k])) { ckpropshtml.attr('fieldslist', ckpropshtml.attr('fieldslist') + ',' + fieldslistmerge[k]); } ckpropshtml.attr(fieldslistmerge[k], blocmerge.attr(fieldslistmerge[k])); } } else { focusbloc.prepend('<div ' + bloc['ckprops' + j] + ' />'); } j++; } } else { $ck('> .ckstyle', focusbloc).empty(); $ck('> .ckprops', focusbloc).remove(); while (bloc['ckprops' + j]) { blocClass = $ck('<div ' + bloc['ckprops' + j] + ' />', focusbloc).removeClass('ckprops').attr('class'); $ck('> .' + blocClass, focusbloc).remove(); focusbloc.prepend('<div ' + bloc['ckprops' + j] + ' />'); j++; } if (bloc['style']) { blocstyle = bloc['style'].replace(/\|ID\|/g, focusbloc.attr('id')).replace(/\|URIBASE\|/g, URIBASE + "/"); $ck('> .ckstyle', focusbloc).empty().append('<style>' + blocstyle + '</style>'); } } FAVORITELOCKED = 0; } /* * Create the full template archive */ function templatePackage(task) { if ($ck('#name').attr('value') == '') { alert(Joomla.JText._('TEMPLATE_MUST_HAVE_NAME', 'You must give a name to the template')); return; } $ck('#packagestep1').empty(); $ck('#packagestepcss').empty(); $ck('#packagestepxml').empty(); $ck('.packagesteparchive').empty(); $ck('#joomla_code').fadeIn(); makeHtmlStep(task); } function checkModules(action, position) { if (!position) position = ''; $ck('#modules_code_inner').empty().addClass('ckwait'); $ck('.leftpanel').not($ck('#modules_code')).fadeOut(); $ck('#modules_code').fadeIn(); var modulepositions = new Array(); $ck('.ckbloc[isdisabled!=true]').each(function(i, el) { // if ($ck(el).attr('value') && $ck(el).attr('value') != 'default') modulepositions.push($ck(el).attr('ckmoduleposition')); }); modulepositions = modulepositions.join(','); if (!action) action = 'test'; var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxcheckmodules&format=raw"; // + "&positions=" + modulepositions // + "&action=" + action; $ck.ajax({ type: "POST", url: myurl, data: { positions: modulepositions, action: action, position: position } }).done(function(code) { $ck('#modules_code_inner').empty().removeClass('ckwait').append(code); setTooltip($ck('#modules_code_inner'), 'title'); // $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } /** * Method to return a message if some position have no module published */ function showcheckModules() { $ck('#modules_code').fadeIn(); checkModules(); } /* * Method to give a random unique ID */ function getUniqueid() { var now = new Date().getTime(); var id = 'ID' + parseInt(now, 10); if ($ck('#' + id).length) getUniqueid(); return id; } function createWrapperBloc(currentbloc) { // var blockid = prompt("Please enter a unique ID for the new wrapper (must be a text)", getWrapperProposal()); // if (blockid != null && blockid != "" && !$ck('#' + blockid).length) { // addBloc('wrapper', blockid, '', currentblocid); // } else if ($ck('#' + blockid).length) { // alert(Joomla.JText._('CK_INVALID_ID', 'ID invalid or already exist')); // } addBloc('wrapper', getWrapperProposal(), '', currentbloc); } function getWrapperProposal() { var i = 1; while ($ck('#wrapper' + i).length && i < 1000) { i++; } return 'wrapper' + i; } function createBloc(currentbloc, type) { idproposal = getIdProposal(type); positionsproposal = getPositionsProposal(type).join(); addBloc(type, idproposal, positionsproposal, currentbloc); } function getIdProposal(type) { var suggestion; switch (type) { case 'singlemodule': default: suggestion = 'block'; break; case 'module-slideshowck': suggestion = 'slideshow'; break; case 'flexiblemodules': suggestion = 'blocks'; break; case 'horizmenu': suggestion = 'nav'; break; case 'banner': suggestion = 'banner'; break; case 'custombloc': suggestion = 'custom'; break; case 'row': suggestion = 'row'; break; case 'logo': suggestion = 'logo'; break; } var i = 1; outer: for (i=1;i<1000;i++) { if (type == 'flexiblemodules') { var subs = Array('mod1', 'mod2', 'mod3', 'mod4', 'mod5'); var isValid = true; for (s=0;s<subs.length;s++) { var sub = subs[s]; if ($ck('#' + suggestion + i + sub).length) { isValid = false; continue outer; } } if (! isValid) { continue outer; } else { return suggestion + i; } } else { if (! $ck('#' + suggestion + i).length) return suggestion + i; } } return suggestion + i; } function getPositionsProposal(type) { var positions = new Array(); var suggestion = new Array(); $ck('.ckbloc').each(function(i, bloc) { bloc = $ck(bloc); if (bloc.attr('ckmoduleposition')) positions.push(bloc.attr('ckmoduleposition')); }); i = 0; found = 0; switch (type) { case 'row': n = 4; break; case 'flexiblemodules': n = 5; break; case 'banner': n = 2; break; default: n = 1; break; } while (found < n) { if ($ck.inArray("position-" + i, positions) == -1) { suggestion.push("position-" + i); found++; } i++; } return suggestion; } function showBlocSelection(currentblocid) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); $ck('.controlfocus').removeClass('controlfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxblocselection&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { currentblocid: currentblocid } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function addBloc(type, blockid, blockposition, currentbloc) { $ck('#popup_editionck').empty().hide(); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxcreatebloc&format=raw"; $ck.ajax({ type: "POST", url: myurl, async: false, data: { tmpl: 'component', blockid: blockid, blockposition: blockposition, fluid: $ck('#body > .tab_blocstyles').attr('blocwrapperfluid'), type: type } }).done(function(code) { // if (type == 'wrapper') { if (currentbloc) { $ck(currentbloc).fadeOut(500, function() { $ck(currentbloc).before(code); $ck(currentbloc).remove(); initSortables(); if (type.substring(0,7) == 'module-') { ckSearchExistingModules($ck('#'+blockid).attr('data-element'), blockposition, blockid) } }); } else { $ck('.cssfocus > .inner').append(code); if (type.substring(0,7) == 'module-') { ckSearchExistingModules($ck('#'+blockid).attr('data-element'), blockposition, blockid) } } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckSearchExistingModules(type, blockposition, blockid) { var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxSearchExistingModules&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { position: blockposition, type: type } }).done(function(code) { try { response = JSON.parse(code); if (response.status == '1') { // if (response.count > 0) { ckShowModulesList(type, blockposition, blockid); // } else { // ckAddModule(type, blockposition, blockid); // } } else { alert(response.message); } } catch(err) { alert( 'ERROR : ' + err.message ); } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckAddModule(type, blockposition, blockid) { if (! type) { ckShowModuleSelectList(blockposition, blockid); return; } var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxPublishModule&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { blockposition: blockposition, type: type, templateid: TEMPLATEID } }).done(function(code) { try { response = JSON.parse(code); if (response.status == '1') { $ck('#' + blockid).attr('data-moduleid', response.id); ckOpenModuleOptions(response.id, 1, type); // ckShowModulesList(type, blockposition, blockid); } else { alert(response.message); } } catch(err) { alert( 'ERROR : ' + err.message ); } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckShowModuleSelectList(blockposition, blockid) { var myurl = URIBASE + '/index.php?option=com_templateck&view=template&layout=ajaxmoduleselect&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { blockposition: blockposition, blockid: blockid } }).done(function(code) { $ck('#ckmodulesselectlist').remove(); var moduleslist = $ck(code); $ck(document.body).append(moduleslist); moduleslist.hide(); CKBox.open({handler: 'inline', content: 'ckmodulesselectlist', style: {padding: '10px'}}); // $ck('.ckboxmodal-back').attr('onclick', ''); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckShowModulesList(type, blockposition, blockid) { var myurl = URIBASE + '/index.php?option=com_templateck&view=template&layout=ajaxmoduleslist&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { position: blockposition, type: type, blockid: blockid } }).done(function(code) { $ck('#ckmoduleslist').remove(); var moduleslist = $ck(code); $ck(document.body).append(moduleslist); moduleslist.hide(); CKBox.open({handler: 'inline', content: 'ckmoduleslist', style: {padding: '10px'}, size: {x: '600px', y: '500px'}}); // $ck('.ckboxmodal-back').attr('onclick', ''); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckAssignModule(blockid, moduleid) { $ck('#'+blockid).attr('data-moduleid', moduleid); CKBox.close(); } function ckToggleModuleState(btn, id, state) { var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxToggleModuleState&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { moduleid: id, state: $ck(btn).attr('data-state') } }).done(function(code) {console.log(code); try { response = JSON.parse(code); if (response.status == '1') { if (response.state == 0) { $ck(btn).removeClass('ckbutton-success').addClass('ckbutton-danger').attr('data-state', response.state); $ck(btn).find('.fa').removeClass('fa-check').addClass('fa-times'); } else { $ck(btn).removeClass('ckbutton-danger').addClass('ckbutton-success').attr('data-state', response.state); $ck(btn).find('.fa').removeClass('fa-times').addClass('fa-check'); } } else { alert(response.message); } } catch(err) { alert( 'ERROR : ' + err.message ); } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckOpenModuleOptions(id, firstuse, type, blockposition, blockid) { if (! firstuse) { // var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxSearchExistingModule&' + cktoken + '=1'; // $ck.ajax({ // type: "POST", // url: myurl, // async: true, // data: { // position: blockposition, // moduleid: id, // type: type // } // }).done(function(code) { // try { // response = JSON.parse(code); // if (response.status == '1') { // if (response.count > 0) { // ckShowModuleOptions(id, 0); // } else { // ckShowModulesList(type, blockposition, blockid); // } // } else { // alert(response.message); // } // } // catch(err) { // alert( 'ERROR : ' + err.message ); // } // }).fail(function() { // alert(Joomla.JText._('CK_FAILED', 'Failed')); // }); ckShowModulesList(type, blockposition, blockid); } else { ckShowModuleOptions(id, firstuse); } } function ckShowModuleOptions(id, firstuse) { CKBox.close(); if (! firstuse) firstuse = false; $boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveIframe(this, \''+id+'\');CKBox.close(this, \'1\')">' + Joomla.JText._('CK_SAVE_CLOSE') + '</a>'; CKBox.open({handler: 'iframe', style: {padding: '10px'}, footerHtml: $boxfooterhtml, url: URIROOT + '/administrator/index.php?option=com_modules&client_id=0&task=module.edit&id='+id+'&tmpl=component&view=module&layout=modal'}); if (firstuse) { alert(Joomla.JText._('CK_SAVE_FIRST_USE_MODULE', 'Please save the module options to create it correctly the first time you use it.')); } } function ckSaveIframe(btn, id) { var iframe = $ck('iframe', $ck($ck(btn).parents('.ckboxmodal')[0])).contents(); if (iframe.find('#applyBtn').length) { iframe.find('#applyBtn').click(); } else { iframe.find('#saveBtn').click(); } } function addControlsOnHover(bloc) { bloc = $ck(bloc); if ($ck('> .editorck', bloc).length) return; var timeout; bloc.mouseenter(function() { addEdition(this); }); bloc.mouseleave(function() { el = $ck(this); // clearTimeout (el.timeout); // el.timeout = setTimeout (function() { removeEdition(el); // }, 200); }); // bloc.dblclick(function() { // if (bloc.hasClass('paused')) { // removeEdition(this); // bloc.removeClass('paused'); // } else { // addEdition(this); // bloc.addClass('paused'); // } // }); } function addEdition(bloc, i) { // if ($ck('.paused').length) return; if (!i) i = 0; bloc = $ck(bloc); if (bloc.hasClass('ui-sortable-helper')) return; if ($ck('> .editorck', bloc).length && i == 0) return; var leftpos = bloc.position().left; var toppos = bloc.position().top; bloc.css('position','relative'); var editorclass = ''; if (i == 0) editorclass = ' mainroot'; var editor = '<div class="editorck' + editorclass + '" id="' + bloc.prop('id') + '-edition"></div>'; editor = $ck(editor); editor.css({ // 'left': leftpos, // 'top': toppos, 'left': 0, 'top': 0, 'position': 'absolute', 'z-index': 100 + i, 'width': bloc.outerWidth() }); addEditionControls(editor, bloc); bloc.append(editor); editor.css('display', 'none').fadeIn('fast'); } function addEditionControls(editor, bloc) { var controlclass = 'innermodule'; var fadebloc = false; if (bloc.hasClass('flexiblemodules') || bloc.hasClass('singlemodule') || bloc.hasClass('maincontent') || bloc.hasClass('mainbanner') || bloc.hasClass('wrapper') ) { controlclass = 'mainleft'; fadebloc = true; } var controls = "<div class=\"ckfields " + controlclass + "\">" + "<div class=\"controlDel isControl\" onclick=\"deleteBloc('" + bloc.attr('id') + "');\"></div>" // + "<div class=\"controlUp isControl\" onclick=\"moveblocUp('" + bloc.attr('id') + "'," + fadebloc + ");\"></div>" // + "<div class=\"controlDown isControl\" onclick=\"moveblocDown('" + bloc.attr('id') + "'," + fadebloc + ");\"></div>" + "<div class=\"controlMove isControl infotip\" title=\"" + Joomla.JText._('CK_MOVE_TOOLTIP', 'Move the element with drag and drop') + "\"></div>" + "<div class=\"controlCss isControl infotip\" title=\"" + Joomla.JText._('CK_CSS_TOOLTIP', 'Edit the styles of the element') + "\" onclick=\"showEditionPopup('" + bloc.attr('id') + "');\"></div>" + "<div class=\"controlFavorite isControl infotip\" title=\"" + Joomla.JText._('CK_FAVORITE_TOOLTIP', 'Design suggestions') + "\" onclick=\"showFavoritePopup('" + bloc.attr('id') + "');\"></div>"; if (!bloc.hasClass('flexiblemodule') && !bloc.hasClass('maincontent') && !bloc.hasClass('column') && !bloc.hasClass('content') && !bloc.hasClass('maincenter')) { controls += "<div class=\"controlCopy isControl infotip\" title=\"" + Joomla.JText._('CK_COPY') + "\" onclick=\"ckDuplicateItem('" + bloc.attr('id') + "');\"></div>" } if (bloc.hasClass('flexiblemodules')) { controls += "<div class=\"controlModules isControl infotip\" title=\"" + Joomla.JText._('CK_MODULES_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"showModulesPopup('" + bloc.attr('id') + "')\"></div>"; controls += "<div class=\"controlEqualHeights isControl infotip\" title=\"" + Joomla.JText._('CK_EQUALHEIGHTS_TOOLTIP', 'Set equal height on all blocks') + "\" onclick=\"setEqualHeights('" + bloc.attr('id') + "')\"></div>"; } if (bloc.hasClass('ckrow')) controls += "<div class=\"controlRow isControl infotip\" title=\"" + Joomla.JText._('CK_ROW_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"showRowPopup('" + bloc.attr('id') + "')\">" + bloc.find('> .inner > .ckrowcontainer').length + "</div>"; if (bloc.hasClass('mainbanner')) controls += "<div class=\"controlBanner isControl infotip\" title=\"" + Joomla.JText._('CK_BANNER_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"showBannerPopup('" + bloc.attr('id') + "')\"></div>"; if (bloc.hasClass('maincontent')) { controls += "<div class=\"controlMaincontent isControl infotip\" title=\"" + Joomla.JText._('CK_MAINCONTENT_TOOLTIP', 'Edit the columns width and number') + "\" onclick=\"showMaincontentPopup('" + bloc.attr('id') + "')\"></div>"; // controls += "<div class=\"controlEqualHeights isControl infotip\" title=\"" + Joomla.JText._('CK_EQUALHEIGHTS_TOOLTIP', 'Edit the styles of the element') + "\" onclick=\"setEqualHeights('" + bloc.attr('id') + "')\"></div>"; } if (bloc.hasClass('wrapper')) { if ($ck('> .tab_blocstyles', bloc).attr('blocfullwidth') == 1) { var isFullwidth = ' ckactive'; } else { var isFullwidth = ''; } controls += '<div class="controlFullwidth isControl infotip' + isFullwidth + '" title="'+Joomla.JText._('CK_FULLWIDTH')+'" onclick="ckToggleFullwidth(\'' + bloc.attr('id') + '\');"></div>'; } if (bloc.hasClass('module') || bloc.attr('ckmoduleposition')) { var type = bloc.attr('data-element') ? bloc.attr('data-element') : ''; controls += "<div class=\"controlModule isControl infotip\" title=\"" + Joomla.JText._('CK_MODULE_EDITION_TOOLTIP', 'Edit the module options') + "\" onclick=\"ckShowModulesList('" + type + "', '" + bloc.attr('ckmoduleposition') + "', '" + bloc.attr('id') + "')\"></div>"; } controls += "<span class=\"editorcktitle infotip\" title=\"" + Joomla.JText._('CK_HTML_ID', 'Element ID') + "\" onclick=\"changeBlocId('" + bloc.attr('id') + "')\">" + bloc.attr('id') + "</span>"; if (bloc.attr('ckmoduleposition')) controls += "<span class=\"editorckposition infotip\" title=\"" + Joomla.JText._('CK_POSITION', 'Module position') + "\" onclick=\"changeBlocPosition('" + bloc.attr('id') + "')\">" + bloc.attr('ckmoduleposition') + "</span>"; controls += "</div>"; if (bloc.hasClass('ckrowcontainer')) { var controls = "<div class=\"ckfields " + controlclass + "\">" + "<div class=\"controlMove isControl\"></div>" + "</div>"; } editor.append(controls); setTooltip(editor, 'title'); } function ckToggleFullwidth(blocid) { var focus = $ck('#' + blocid); // check if the attributes already exists on the bloc, else create it tabid = 'tab_blocstyles'; if (!$ck('> .' + tabid, focus).length) { createFocusProperty(focus, tabid); } focusprop = $ck('> .' + tabid, focus); if (focusprop.attr('blocfullwidth') == '0' || !focusprop.attr('blocfullwidth')) { focusprop.attr('blocfullwidth', '1'); $ck('> .inner', focus).removeClass('container').removeClass('container-fluid'); focus.find('.controlFullwidth').addClass('ckactive'); } else if (focus.hasClass('wrapper')) { focusprop.attr('blocfullwidth', '0'); $ck('> .inner', focus).addClass('container'); focus.find('.controlFullwidth').removeClass('ckactive'); } } function ckDuplicateItem(blocid) { var bloc = $ck('#' + blocid); var bloccopy = bloc.clone(); var newid = getNewId(blocid); if (! newid) return; var position = bloc.attr('ckmoduleposition'); bloc.after(bloccopy); bloccopy.removeClass('editfocus'); bloccopy.find('> .editorck').remove(); replaceId(bloccopy, newid); if (position) { var newposition = getNewId(position); bloccopy.attr('ckmoduleposition', newposition); } initSortables(); addControlsOnHover(bloccopy); bloccopy.find('.ckbloc').each(function() { $this = $ck(this); $this.removeClass('editfocus'); newid = getNewId($this.attr('id')); if (! newid) return; position = $this.attr('ckmoduleposition'); if (position) { newposition = getNewId(position); $this.attr('ckmoduleposition', newposition); } replaceId($this, newid); initSortables(); addControlsOnHover($this); }); } function getNewId(id) { var newid = id + 'copy'; var i = 0; while (! validateBlocId(newid) && i < 1000) { newid = newid + 'copy'; i++; } if (i == 1000) { alert('Error when trying to give a new ID. Will exit copy.') return false; } return newid; } function setEqualHeights(blocid) { bloc = $ck('#' + blocid); if (bloc.attr('ckclass') && bloc.attr('ckclass').indexOf('equalheights') != -1) { bloc.attr('ckclass', bloc.attr('ckclass').replace('equalheights', '')); } else { ckclass = bloc.attr('ckclass') ? bloc.attr('ckclass') + ' equalheights' : 'equalheights'; bloc.attr('ckclass', ckclass.trim()); } } function removeEdition(bloc, all) { if (!all) all = false; bloc = $ck(bloc); // if (bloc.hasClass('paused')) return; if (all = true) { $ck('.editorck', bloc).remove(); } else { $ck('> .editorck', bloc).remove(); } } function deleteBloc(blocid) { bloc = $ck('#' + blocid); if (bloc.hasClass('module')) { if (confirm('Do you want to delete ?')) { // if (confirm('Do you want to also delete the module data from the Modules Maanger ?')) { // } bloc.remove(); } } else { if (confirm('Do you want to delete ?')) { bloc.remove(); } } } function moveblocUp(blocid, fadebloc) { bloc = $ck('#' + blocid); var myPrevious = bloc.prev(); if (myPrevious.length && myPrevious.hasClass('ckbloc')) { myPrevious.before(bloc); if (fadebloc == true) { bloc.css('display', 'none').fadeIn(); removeEdition($ck(document.body), true); } removeEdition($ck(document.body), true); } } function moveblocDown(blocid, fadebloc) { bloc = $ck('#' + blocid); var myNext = bloc.next(); if (myNext.length && myNext.hasClass('ckbloc')) { myNext.after(bloc); if (fadebloc == true) { bloc.css('display', 'none').fadeIn(); removeEdition($ck(document.body)); } removeEdition($ck(document.body)); } } function changeBlocId(blocid) { bloc = $ck('#' + blocid); if (bloc.attr('id') == 'wrapper') return; var result = prompt(Joomla.JText._('CK_ENTER_UNIQUE_ID', 'Please enter a unique ID (must be a text)'), bloc.attr('id')); if (!result) return; result = validateName(result); if (validateBlocId(result)) updateIdPosition(blocid, result, ''); } function changeBlocPosition(blocid) { bloc = $ck('#' + blocid); var result = prompt(Joomla.JText._('CK_ENTER_UNIQUE_POSITION', 'Please enter a unique Position (must be a text)'), bloc.attr('ckmoduleposition')); if (!result) return; result = validateName(result); if (validateBlocPosition(result)) updateIdPosition(blocid, '', result); } function validateBlocId(newid) { if (newid != null && newid != "" && !$ck('#' + newid).length) { return true; } else if ($ck('#' + newid).length) { alert(Joomla.JText._('CK_INVALID_ID', 'ID invalid or already exist')); return false; } else if (newid == null || newid == "") { alert(Joomla.JText._('CK_ENTER_VALID_ID', 'Please enter a valid ID')); return false; } return true; } function validateName(name) { var name = name.replace(/\s/g, ""); name = name.toLowerCase(); return name; } function validateBlocPosition(newposition) { if (newposition == null || newposition == "") { alert(Joomla.JText._('CK_ENTER_VALID_POSITION', 'Please enter a valid position')); return false; } var alreadyexists = false; $ck('.ckbloc').each(function(i, bloc) { bloc = $ck(bloc); if (bloc.attr('ckmoduleposition') == newposition && bloc.attr('isdisabled') != 'true') { alert(Joomla.JText._('CK_POSITION_ALREADY_USED', 'Position already used')); alreadyexists = true; } }); return !alreadyexists; } function updateIdPosition(blocid, newid, newposition) { bloc = $ck('#' + blocid); if (newposition) { $ck('.editorckposition', bloc).html(newposition); bloc.attr('ckmoduleposition', newposition); } if (newid) { $ck('.editorcktitle', bloc).html(newid); // bloc.attr('id', newid); replaceId(bloc, newid); } } function replaceId(el, newID) { var re = new RegExp(el.attr('id'), 'g'); el.find('> .ckstyle').html(el.find('> .ckstyle').html().replace(re,newID)); el.attr('id', newID); } function showFavoritePopup(blocid) { FAVORITELOCKED = 1; blocid = '#' + blocid; bloc = $ck(blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); BLOCCKSTYLESBACKUP = $ck('> .ckstyle', bloc).html(); // $ck('#popup_favoriteck').fadeIn().css('top', parseInt(bloc.position().top) + parseInt(bloc.height())); $ck('.leftpanel').not($ck('#popup_favoriteck')).fadeOut(); $ck('#popup_favoriteck').fadeIn(); // $ck('#html_code').animate({'left':'310px'}); $ck('#leftpanel').attr('data-reduced', $ck('#leftpanel').hasClass('reduced')).removeClass('reduced'); $ck('.objid', $ck('#popup_favoriteck')).text(bloc.attr('id')); FAVORITELOCKED = 0; } function closeFavoritePopup(force) { if (! force ) force = false; if ( $ck('#popup_favoriteck').hasClass('stick') && !force ) { BLOCCKSTYLESBACKUP = $ck('> .ckstyle', $ck('.cssfocus')).html(); return; } $ck('#popup_favoriteck').fadeOut(); // $ck('#html_code').animate({'left':'0'}); if ($ck('#leftpanel').attr('data-reduced') == 'true') $ck('#leftpanel').addClass('reduced').removeAttr('data-reduced'); } function showEditionPopup(blocid, savefunc) { if (! savefunc) savefunc = 'saveEditionPopup'; blocid = '#' + blocid; keepAlive(); $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck(blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxstylescss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { objclass: bloc.prop('class'), expertmode: $ck('#body').hasClass('expert'), savefunc: savefunc, element: bloc.attr('data-element'), ckobjid: bloc.prop('id') } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); fillEditionPopup(blocid); loadPreviewAreaStyles(blocid); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function loadPreviewAreaStyles(blocid, previewareabloc) { if (! previewareabloc) previewareabloc = 'previewareabloc'; bloc = $ck(blocid); var blocstyles = $ck('> .ckstyle', bloc).text(); var replacement = new RegExp(blocid, 'g'); var previewstyles = blocstyles.replace(replacement, '#'+previewareabloc); // /blue/g,"red" previewstyles = previewstyles.replace(/\|ID\|/g, '#'+previewareabloc); // replace id var editionarea = $ck('#popup_editionck'); $ck('> .ckstyle', $ck('#'+previewareabloc)).html('<style type="text/css">'+previewstyles+'</style>'); $ck('.inputbox', editionarea).change(function() { getPreviewAreastylescss(previewareabloc, editionarea, blocid); }); $ck('.colorPicker,.inputbox[type=radio]', editionarea).blur(function() { getPreviewAreastylescss(previewareabloc, editionarea, blocid); }); // if icon is found if ($ck('#popup_editionck').find('div[tab="tab_iconstyles"]').length && (bloc.hasClass('singlemodule') || bloc.hasClass('flexiblemodule'))) { $ck('#'+previewareabloc).find('h3').html(bloc.find('h3').html()); } } function forceColorPickerChanges(picker) { $ck(picker).trigger('blur'); } function showModulesPopup(blocid) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#' + blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxmodulesmanager&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function showRowPopup(blocid) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#' + blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxrowmanager&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function showBannerPopup(blocid) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#' + blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxbannermanager&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function showMaincontentPopup(blocid) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#' + blocid); $ck('.cssfocus').removeClass('cssfocus'); bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxmaincontentmanager&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function showParamsPopup(showtab) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#body'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxparams"; $ck.ajax({ type: "POST", url: myurl, data: { expertmode: $ck('#body').hasClass('expert'), joomlaversion: $ck('#joomlaversion').attr('value') } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); fillEditionPopup('#body'); loadPreviewAreaStyles('#body'); if (showtab) { $ck('.menulink[tab="' + showtab + '"]').click().mousedown(); } initBulletlist(); // to render the selected bullet style }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function showResponsivePopup() { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); blocs = getBlocks(); blocs = JSON.stringify(blocs); blocs = blocs.replace(/#/g, "|di|"); bloc = $ck('#body'); $ck('#popup_editionck').empty().fadeIn(); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxresponsive&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { blocs: blocs, htmlcode_responsive: $ck('#htmlcode_responsive').val(), templateid: TEMPLATEID } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); fillEditionPopup('#body'); setResponsiveValues(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function setResponsiveValues() { var values = $ck('#body').attr('responsivevalues'); if (! values) values = '524,758,950,1024'; values = values.split(','); $ck('.blocresolution .resolution-value input').each(function(i) { this.value = values[i]; $ck(this).attr('data-value', values[i]); }); } function fillEditionPopup(blocid) { bloc = $ck(blocid); $ck('> .ckprops', bloc).each(function(i, ckprops) { ckprops = $ck(ckprops); fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); // for (var fieldname of fieldslist) { for (j=0;j<fieldslist.length;j++) { fieldname = fieldslist[j]; if (!$ck('#' + fieldname).length) continue; cssvalue = ckprops.attr(fieldname); field = $ck('#' + fieldname); if (field.attr('type') == 'radio') { if (cssvalue == 'checked') { field.attr('checked', 'checked'); } else { field.removeAttr('checked'); } } else if (cssvalue) { field.attr('value', cssvalue); if (field.hasClass('colorPicker') && field.attr('value')) { setpickercolor(field); field.css('background-color', field.attr('value')); if (field.attr('id').indexOf('backgroundcolorend') != -1) { prefix = field.attr('id').replace("backgroundcolorend", ""); if (prefix && $ck('#blocbackgroundcolorstart').attr('value')) createGradientPreview(prefix); } if (field.attr('id').indexOf('backgroundcolorstart') != -1) { prefix = field.attr('id').replace("backgroundcolorstart", ""); if (prefix && $ck('#blocbackgroundcolorstart').attr('value')) createGradientPreview(prefix); } } } else { field.attr('value', ''); } } // retrocompatibilite banner if (!ckprops.attr('logowidth')) { $ck('#logowidth').attr('value', ckprops.attr('blocwidth')); $ck('#logoheight').attr('value', ckprops.attr('blocheight')); } // end retrocompatibilite }); } function saveEditionPopup(blocid, workspace, returnFunc, hide) { if (! hide && hide !== false) hide = true; if (! returnFunc) returnFunc = ''; if (!workspace) workspace = null; var editionarea = $ck('#popup_editionck'); var focus = blocid ? $ck('#' + blocid) : $ck('.cssfocus'); $ck('.ckproperty', editionarea).each(function(i, tab) { tab = $ck(tab); tabid = tab.attr('id'); (!$ck('> .' + tabid, focus).length) ? createFocusProperty(focus, tabid) : $ck('> .' + tabid, focus).empty(); focusprop = $ck('> .' + tabid, focus); savePopupfields(focusprop, tabid); fieldslist = getPopupFieldslist(focus, tabid); focusprop.attr('fieldslist', fieldslist); }); if (focus.hasClass('bannerlogo')) getPreviewlogo(focus); if (focus.hasClass('wrapper') && $ck('> .tab_blocstyles', focus).attr('blocfullwidth') == 1) { $ck('> .inner', focus).removeClass('container').removeClass('container-fluid'); } else if (focus.hasClass('wrapper')) { $ck('> .inner', focus).addClass('container'); } toogleWrapperFluid(); toggleBootstrap(); getPreviewstylescss(blocid, editionarea, workspace, returnFunc); if ($ck('#previewareabloc .fack').length) { focus.find('h3').html($ck('#previewareabloc h3').html()); } else if (focus.find('.fack').length && blocid != 'body' && !bloc.hasClass('wrapper')) { focus.find('h3 .fack').remove(); } if (blocid == 'body') { saveCustomCode(); saveCustomCss(); // saveCustomJs(); } if (hide) editionarea.empty().hide(); } function saveLayoutPopup(layout) { if (typeof(window['ckBeforeSaveLayoutPopup' + layout]) == 'function') window['ckBeforeSaveLayoutPopup' + layout](); saveEditionPopup('layout_' + layout + '_html', '', 'ckAfterSaveLayoutPopup' + layout); } function saveCustomCode() { if (!$ck('#customcode').length) return; editor_customcode.save(); // save the editor to the textarea editor_customcodeendbody.save(); // save the editor to the textarea var customcode = $ck('#customcode').attr('value'); var customcodeendbody = $ck('#customcodeendbody').attr('value'); // customcode = JSON.stringify(customcode); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsavecustomcode&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val(), customcode: customcode, customcodeendbody: customcodeendbody } }).done(function(code) { }).fail(function() { alert(Joomla.JText._('CK_FAILED_CUSTOMCODE', 'Failed to save Custom Code')); }); } function saveCustomCss() { if (!$ck('#customcss').length) return; editor_customcss.save(); // save the editor to the textarea var customcss = $ck('#customcss').attr('value'); // customcss = JSON.stringify(customcss); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsavecustomcss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val(), customcss: customcss } }).done(function(code) { }).fail(function() { alert(Joomla.JText._('CK_FAILED_CUSTOMCSS', 'Failed to save Custom CSS')); }); } function saveCustomJs() { if (!$ck('#customjs').length) return; editor_customjs.save(); // save the editor to the textarea var customjs = $ck('#customjs').attr('value'); // customcss = JSON.stringify(customcss); var myurl = URIBASE + "admin.php?page=templatecreatorck_edit&layout=ajaxsavecustomjs"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val(), customjs: customjs } }).done(function(code) { }).fail(function() { alert(Joomla.JText._('CK_FAILED_CUSTOMJS', 'Failed to save Custom JS')); }); } function saveCustomFunctions() { if (!$ck('#customfunctions').length) return; editor_customfunctions.save(); // save the editor to the textarea var customfunctions = $ck('#customfunctions').attr('value'); // customcss = JSON.stringify(customcss); var myurl = URIBASE + "admin.php?page=templatecreatorck_edit&layout=ajaxsavecustomfunctions"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val(), customfunctions: customfunctions } }).done(function(code) { }).fail(function() { alert(Joomla.JText._('Failed to save Custom Functions')); }); } function getPreviewlogo(focus) { var logoimg = $ck('img', focus); if ($ck('> .tab_blocstyles', focus).attr('logoheight')) logoimg.attr('height', $ck('> .tab_blocstyles', focus).attr('logoheight')); if ($ck('> .tab_blocstyles', focus).attr('logowidth')) logoimg.attr('width', $ck('> .tab_blocstyles', focus).attr('logowidth')); if ($ck('> .tab_blocstyles', focus).attr('blocbackgroundimageurl')) { focus.css('background', 'none'); logoimg.attr('src', URIROOT + '/' + $ck('> .tab_blocstyles', focus).attr('blocbackgroundimageurl')); logoimg.attr('data-src', '/' + $ck('> .tab_blocstyles', focus).attr('blocbackgroundimageurl').trim('/')); } if ($ck('> .tab_logodescstyles', focus).attr('uselogodescno') && $ck('> .tab_logodescstyles', focus).attr('uselogodescno') == 'checked') { focus.find('.bannerlogodesc').hide(); } else { focus.find('.bannerlogodesc').show(); if ($ck('> .tab_logodescstyles', focus).attr('logodesctext')) focus.find('.bannerlogodesc').find('> .inner div').text($ck('> .tab_logodescstyles', focus).attr('logodesctext')); } logofieldslist = $ck('> .tab_blocstyles', focus).attr('fieldslist'); if (logofieldslist.toLowerCase().indexOf('blocwidth') == -1) logofieldslist += ',blocwidth'; if (logofieldslist.toLowerCase().indexOf('blocheight') == -1) logofieldslist += ',blocheight'; $ck('> .tab_blocstyles', focus).attr('fieldslist', logofieldslist); setTemplateOptions(focus); } function setTemplateOptions(focus) { var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxSetTemplateOptions&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').attr('value'), blocid: focus.attr('id'), logoalt: $ck('#logoalt').attr('value'), logolink: $ck('#logolink').attr('value'), uselogodesc: $ck('[name="uselogodesc"]:checked').attr('id'), logodesctext: $ck('#logodesctext').attr('value'), logoimg: $ck('img', focus).attr('data-src'), logowidth: $ck('img', focus).attr('width'), logoheight: $ck('img', focus).attr('height') } }).done(function(code) { // do nothing here as there is no problem if the template options are not updated }).fail(function() { }); } function createFocusProperty(focus, tabid) { focus.prepend('<div class="' + tabid + ' ckprops" />') } function savePopupfields(focusprop, tabid) { $ck('.inputbox', $ck('#' + tabid)).each(function(i, field) { field = $ck(field); if (field.attr('type') != 'radio') { if (field.attr('value') && field.attr('value') != 'default') { focusprop.attr(field.attr('id'), field.attr('value')); } else { focusprop.removeAttr(field.attr('id')); } } else { if (field.attr('checked')) { focusprop.attr(field.attr('id'), 'checked'); } else { focusprop.removeAttr(field.attr('id')); } } }); } function getPopupFieldslist(focus, tabid) { fieldslist = new Array(); $ck('.inputbox', $ck('#' + tabid)).each(function(i, el) { if ($ck(el).attr('value') && $ck(el).attr('value') != 'default') fieldslist.push($ck(el).attr('id')); }); if (tabid == 'tab_blocstyles' && (focus.hasClass('bannerlogo') || focus.hasClass('banner') || focus.hasClass('bannermenu')) ) fieldslist.push('blocwidth'); return fieldslist.join(','); } function saveResponsivePopup() { $ck('.blocresolution').each(function(i, resolution) { attribute = $ck(resolution).attr('id'); $ck('.ckbloc', resolution).each(function(j, responsivebloc) { responsivebloc = $ck(responsivebloc); responsiveblocid = responsivebloc.attr('ckid'); $ck('#' + responsiveblocid).attr(attribute, responsivebloc.attr('ckmobile')); }); }); setReponsiveValues(); saveResponsiveCustomcode(); saveEditionPopup('body'); $ck('#popup_editionck').empty().hide(); // $ck('#popup_editionck').empty().hide(); } function setReponsiveValues() { var values = new Array(); $ck('.blocresolution .resolution-value input').each(function() { values.push(this.value); }); values = values.join(','); $ck('#body').attr('responsivevalues', values); } function saveResponsiveCustomcode() { if (!$ck('.responsiveCustomcode').length) return; // var customcode = new Object(); customcodes = ''; $ck('.responsiveCustomcode').each(function(i, csscode) { var code = $ck(csscode).attr('value').replace(/]/g, "|bbe|"); customcodes += '[resolution'+$ck(csscode).attr('data-resolution')+']=['+code+']'; }); // new method, store in the field to be save with the template $ck('#htmlcode_responsive').val(customcodes); // var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxsaveresponsivecustomcode&format=raw"; // $ck.ajax({ // type: "POST", // url: myurl, // data: { // templateid: TEMPLATEID, // customcodes: customcodes // } // }).done(function(code) { // $ck('#popup_editionck').empty().hide(); // }).fail(function() { // alert(Joomla.JText._('CK_FAILED_CUSTOMCSS', 'Failed to save Custom CSS')); // }); } function getdefaultwidth(nbmodules) { defaultwidths = new Array(); defaultwidth = 100 / parseInt(nbmodules); for (i = 0; i < nbmodules; i++) { defaultwidths.push(defaultwidth); } return defaultwidths; } function saveModulesPopup() { var editionarea = $ck('#popup_editionck'); var focus = $ck('.cssfocus'); numberofmodules = $ck('#modulenumberselect').attr('value'); focus.attr('numberofmodules', numberofmodules); var focusfieldslist = new Array(); $ck('.modulemanagercontainer').each(function(i, modulesrow) { modulesrow = $ck(modulesrow); nbmodules = modulesrow.attr('nbmodules'); moduleswidth = new Array(); $ck('.modulewidthselect', modulesrow).each(function(j, module) { module = $ck(module); moduleswidth.push(parseFloat(module.attr('value'))); }); focus.attr('moduleswidth' + (i + 2), moduleswidth.join(',')); focus.attr('isdisabledmodule' + (i + 2), modulesrow.hasClass('disabled')); focus.find('.flexiblemodule:eq(' + (i + 1) + ')').attr('isdisabled', modulesrow.hasClass('disabled')); }); moduleswidth = focus.attr('moduleswidth' + numberofmodules) ? focus.attr('moduleswidth' + numberofmodules).split(',') : getdefaultwidth(numberofmodules); $ck('.flexiblemodule', focus).each(function(i, module) { module = $ck(module); module.css('width', parseFloat(moduleswidth[i]) + '%'); focusfieldslist.push('moduleswidth' + (i + 2)); focusfieldslist.push('isdisabledmodule' + (i + 2)); }); focusfieldslist.push('numberofmodules'); focus.attr('paramslist', focusfieldslist.join(',')); editionarea.empty().hide(); } function saveRowPopup() { var editionarea = $ck('#popup_editionck'); var focus = $ck('.cssfocus'); numberofmodules = $ck('#blocnumberselect').attr('value'); focus.attr('numberofmodules', numberofmodules); var focusfieldslist = new Array(); if ($ck('> .inner > .ckrowcontainer', focus).length < numberofmodules) { nbexistingblocs = $ck('> .inner > .ckrowcontainer', focus).length; $ck(document.body).append('<div id="ckwaitoverlay"></div>'); for (var i=0; i < (numberofmodules - nbexistingblocs); i++) { // createEmptyBloc(focus); createRowContainer(focus); } $ck('#ckwaitoverlay').remove(); } $ck('> .inner > .ckrowcontainer', focus).each(function(i, bloc) { bloc = $ck(bloc); bloc.css('width', parseFloat($ck('.modulewidthselect').eq(i).val()) + '%'); bloc.attr('data-width', parseFloat($ck('.modulewidthselect').eq(i).val())); if (i >= numberofmodules) { if (bloc.find('.ckbloc').length) { bloc.prev().append(bloc.find('.ckbloc')); bloc.remove(); } else { bloc.remove(); } } }); focusfieldslist.push('numberofmodules'); focus.attr('paramslist', focusfieldslist.join(',')); editionarea.empty().hide(); } function createRowContainer(focus) { var newcontainer = $ck('<div class="ckrowcontainer"></div>'); focus.find('> .inner').append(newcontainer); makeRowcontainerSortable(newcontainer); addControlsOnHover(newcontainer); } function saveMaincontentPopup() { var editionarea = $ck('#popup_editionck'); var focus = $ck('.cssfocus'); $ck('.maincontentmanager').each(function(i, module) { module = $ck(module); var target = module.attr('target'); focus.attr('isdisabledmodule' + target, module.hasClass('disabled')); focus.find('.' + target).attr('isdisabled', module.hasClass('disabled')); }); if ((focus.find('.maintop').attr('isdisabled') == 'true' && focus.find('.mainbottom').attr('isdisabled') == 'true') // || focus.find('.column2').attr('isdisabled') == 'true' ) { focus.find('.maincenter').attr('ishidden', 'true'); } else { focus.find('.maincenter').attr('ishidden', 'false'); } if (focus.find('.centertop').attr('isdisabled') == 'true' && focus.find('.centerbottom').attr('isdisabled') == 'true') { focus.find('.content').attr('ishidden', 'true'); } else { focus.find('.content').attr('ishidden', 'false'); } if (focus.find('.column2').attr('isdisabled') == 'true') { focus.addClass('norightcol'); focus.find('.center').attr('ishidden', 'true'); } else { focus.removeClass('norightcol'); focus.find('.center').attr('ishidden', 'false'); } if (focus.find('.column1').attr('isdisabled') == 'true') { focus.addClass('noleftcol'); focus.find('.main').attr('ishidden', 'true'); } else { focus.removeClass('noleftcol'); focus.find('.main').attr('ishidden', 'false'); } focus.find('.column1').attr('blocwidth', $ck('#blocwidthselectleft').attr('value')); focus.find('.column2').attr('blocwidth', $ck('#blocwidthselectright').attr('value')); updateColumnsWidth(); editionarea.empty().hide(); } function updateColumnsWidth() { var focus = $ck('.cssfocus'); var column1width = focus.find('.column1').attr('blocwidth'); var mainwidth = focus.find('.column1').attr('isdisabled') == 'true' ? '100%' : (100 - parseFloat(column1width)) + '%'; var rightwidthratio = parseFloat((100 - parseFloat(column1width))/100); var column2width = (parseFloat(focus.find('.column2').attr('blocwidth')) / rightwidthratio) + '%'; var centerwidth = focus.find('.column2').attr('isdisabled') == 'true' ? '100%' : (100 - parseFloat(column2width)) + '%'; focus.find('.column1').css('width', column1width); focus.find('.main').css('width', mainwidth); focus.find('.column2').css('width', column2width); focus.find('.center').css('width', centerwidth); } function saveBannerPopup() { var editionarea = $ck('#popup_editionck'); var focus = $ck('.cssfocus'); $ck('.bannermanager').each(function(i, module) { module = $ck(module); var target = module.attr('target'); focus.attr('isdisabledmodule' + target, module.hasClass('disabled')); focus.find('.' + target).attr('isdisabled', module.hasClass('disabled')); }); logotabblocstyles = focus.find('.bannerlogo > .tab_blocstyles'); if (logotabblocstyles.length) { logofieldslist = logotabblocstyles.attr('fieldslist'); if (logofieldslist.toLowerCase().indexOf('blocwidth') == -1) logofieldslist += ',blocwidth'; logotabblocstyles.attr('fieldslist', logofieldslist); } moduletabblocstyles = focus.find('.banner > .tab_blocstyles'); if (moduletabblocstyles.length) { modulefieldslist = moduletabblocstyles.attr('fieldslist'); if (modulefieldslist.toLowerCase().indexOf('blocwidth') == -1) modulefieldslist += ',blocwidth'; moduletabblocstyles.attr('fieldslist', modulefieldslist); } menutabblocstyles = focus.find('.bannermenu > .tab_blocstyles'); if (menutabblocstyles.length) { menufieldslist = menutabblocstyles.attr('fieldslist'); if (menufieldslist.toLowerCase().indexOf('blocwidth') == -1) menufieldslist += ',blocwidth'; menutabblocstyles.attr('fieldslist', menufieldslist); } focus.find('.bannerlogo > .tab_blocstyles').attr('blocwidth', $ck('#blocwidthselectlogo').attr('value')); focus.find('.banner > .tab_blocstyles').attr('blocwidth', $ck('#blocwidthselectmodule').attr('value')); focus.find('.bannermenu > .tab_blocstyles').attr('blocwidth', $ck('#blocwidthselectmenu').attr('value')); focus.find('.bannerlogo').css('width', $ck('#blocwidthselectlogo').attr('value')); focus.find('.banner').css('width', $ck('#blocwidthselectmodule').attr('value')); focus.find('.bannermenu').css('width', $ck('#blocwidthselectmenu').attr('value')); editionarea.empty().hide(); } function getPreviewstylescss(blocid, editionarea, workspace, returnFunc) { if (!workspace) workspace = $ck('#workspaceck'); if (!editionarea) editionarea = document.body; var focus = blocid ? $ck('#' + blocid) : $ck('.cssfocus'); var fieldslist = new Array(); $ck('.inputbox', editionarea).each(function(i, el) { if ($ck(el).attr('value')) fieldslist.push($ck(el).attr('id')); }); fields = new Object(); $ck('> .ckprops', focus).each(function(i, ckprops) { ckprops = $ck(ckprops); fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); // fieldslist.each(function(fieldname) { // fields[fieldname] = ckprops.attr(fieldname); // }); for (j=0;j<fieldslist.length;j++) { fieldname = fieldslist[j]; // for (var fieldname of fieldslist) { fields[fieldname] = ckprops.attr(fieldname); } }); fields = JSON.stringify(fields); customstyles = new Object(); $ck('.menustylescustom').each(function() { $this = $ck(this); customstyles[$this.attr('data-prefix')] = $this.attr('data-rule'); }); customstyles = JSON.stringify(customstyles); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxrendercss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { objclass: focus.prop('class'), ckobjid: focus.prop('id'), action: 'preview', customstyles: customstyles, fields: fields } }).done(function(code) { $ck('> .ckstyle', focus).empty().append(code); if (BLOCCKSTYLESBACKUP != 'undefined') { BLOCCKSTYLESBACKUP = $ck('> .ckstyle', focus).html(); } if (typeof(window[returnFunc]) == 'function') window[returnFunc](); countdoaction(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function getPreviewAreastylescss(blocid, editionarea, focus) { if (!editionarea) editionarea = document.body; if (!focus) { focus = $ck('.cssfocus'); } else { focus = $ck(focus); } var fieldslist = new Array(); fields = new Object(); $ck('.inputbox', editionarea).each(function(i, el) { el = $ck(el); fields[el.attr('name')] = el.attr('value'); if (el.attr('type') == 'radio') { if (el.attr('checked')) { fields[el.attr('id')] = 'checked'; } else { fields[el.attr('id')] = ''; } } }); $ck('> .ckprops', focus).each(function(i, ckprops) { ckprops = $ck(ckprops); fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); // for (var fieldname of fieldslist) { for (j=0;j<fieldslist.length;j++) { fieldname = fieldslist[j]; if (typeof(fields[fieldname]) == 'null') fields[fieldname] = ckprops.attr(fieldname); } }); fields = JSON.stringify(fields); customstyles = new Object(); $ck('.menustylescustom').each(function() { $this = $ck(this); customstyles[$this.attr('data-prefix')] = $this.attr('data-rule'); }); customstyles = JSON.stringify(customstyles); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxrendercss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { objclass: focus.prop('class'), ckobjid: blocid, action: 'preview', fields: fields, customstyles: customstyles } }).done(function(code) { var csscode = code.replace(/\|ID\|/g, '#'+blocid); $ck('> .ckstyle', $ck('#' + blocid)).empty().append(csscode); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function loadTab_menustyles() { bloc = $ck('#tab_menustyles'); if (bloc.html()) return; bloc.append('<div id="ckwaitoverlay"></div>'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxtabmenustyles&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { objclass: bloc.prop('class'), ckobjid: bloc.prop('id') } }).done(function(code) { bloc.empty().append(code); fillEditionPopup('#' + $ck('.cssfocus').attr('id')); loadPreviewAreaStyles('#' + $ck('.cssfocus').attr('id')); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function loadTab_customcode() { bloc = $ck('#tab_customcode'); if (bloc.html()) return; bloc.append('<div id="ckwaitoverlay"></div>'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxtabcustomcode&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val() } }).done(function(code) { bloc.empty().append(code); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function loadTab_customcss() { bloc = $ck('#tab_customcss'); if (bloc.html()) return; bloc.append('<div id="ckwaitoverlay"></div>'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxtabcustomcss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val() } }).done(function(code) { bloc.empty().append(code); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function loadTab_customjs() { bloc = $ck('#tab_customjs'); if (bloc.html()) return; bloc.append('<div id="ckwaitoverlay"></div>'); var myurl = TEMPLATECREATORCK_ADMIN_URL + "&layout=ajaxtabcustomjs"; $ck.ajax({ type: "POST", url: myurl, data: { templateid: TEMPLATEID, templatename: $ck('#name').val() } }).done(function(code) { bloc.empty().append(code); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function showLayoutPopup(layout) { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); bloc = $ck('#body'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = TEMPLATECREATORCK_ADMIN_URL + "&view=template&layout=ajaxlayout" + layout; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').val() } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); fillEditionPopup('#layout_' + layout + '_html'); loadPreviewAreaStyles('#layout_' + layout + '_html', 'previewarealayout' + layout); if (typeof(window['ckUpdateLayoutPreview' + layout]) == 'function') window['ckUpdateLayoutPreview' + layout](); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } /* ---------------------------------------------------------------------------------------------------------------------------------------- TEMPLATE CREATION AND PREVIEW ---------------------------------------------------------------------------------------------------------------------------------------------*/ function getBlocks() { var blocs = new Array(); var cssblocs = new Object(); var i = 0; $ck('.ckbloc').each(function(j, bloc) { bloc = $ck(bloc); if (bloc.attr('isdisabled') != 'true') { var cssblocs = new Object(); var fieldslist = new Array(); cssblocs['class'] = bloc.attr('class'); cssblocs['ckid'] = bloc.attr('id'); if (bloc.attr('id') == "body" || bloc.attr('id') == "wrapper") cssblocs['ckid'] = bloc.attr('id'); cssblocs['ckclass'] = bloc.attr('ckclass'); cssblocs['ckmoduleposition'] = bloc.attr('ckmoduleposition'); cssblocs['ckmodulestyle'] = bloc.attr('ckmodulestyle'); cssblocs['ckresponsive1'] = bloc.attr('ckresponsive1'); cssblocs['ckresponsive2'] = bloc.attr('ckresponsive2'); cssblocs['ckresponsive3'] = bloc.attr('ckresponsive3'); cssblocs['ckresponsive4'] = bloc.attr('ckresponsive4'); cssblocs['ckresponsive5'] = bloc.attr('ckresponsive5'); cssblocs['isdisabled'] = bloc.attr('isdisabled'); cssblocs['ishidden'] = bloc.attr('ishidden'); if (bloc.hasClass('ckrow')) { cssblocs['children'] = new Array(); bloc.find('.ckbloc').each(function(i, el){ if (! $ck(el).hasClass('flexiblemodule')) cssblocs['children'].push($ck(el).attr('id')); }); } if (bloc.attr('fieldslist')) fieldslist = bloc.attr('fieldslist').split(","); paramslist = bloc.attr('paramslist') ? bloc.attr('paramslist').split(",") : Array(); $ck('> .ckprops', bloc).each(function(i, ckprops) { ckprops = $ck(ckprops); fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array(); // for (var fieldname of fieldslist) { for (j=0;j<fieldslist.length;j++) { fieldname = fieldslist[j]; cssblocs[fieldname] = ckprops.attr(fieldname); } }); // for (var fieldname of paramslist) { for (j=0;j<paramslist.length;j++) { fieldname = paramslist[j]; cssblocs[fieldname] = bloc.attr(fieldname); } blocs[i] = cssblocs; i++; } }); return blocs; } /** * * Function create htmlcode and folder structure and begin the process */ function makeHtmlStep(task) { blocs = getBlocks(); blocs = JSON.stringify(blocs); blocs = blocs.replace(/#/g, "|di|"); var htmlcode = makeHtmlOutput(); // get the widgets list // var widgets = Object(); // $ck('#widgetsElements .widget').each(function(i) { // widgets[$ck(this).attr('data-name')] = $ck(this).attr('data-enabled'); // }); var widgets = ckGetWidgetsData(); jsonWidgets = JSON.stringify(widgets); // jsonWidgets = jsonWidgets.replace(/"/g, "|qq|"); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxindex&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { bodycode: htmlcode["body"], headcode: htmlcode["head"], joomlaversion: $ck('#joomlaversion').attr('value'), templatename: $ck('#name').attr('value'), creationdate: $ck('#creationdate').attr('value'), author: $ck('#author').attr('value'), authorEmail: $ck('#authoremail').attr('value'), authorUrl: $ck('#authorurl').attr('value'), copyright: $ck('#copyright').attr('value'), license: $ck('#license').attr('value'), version: $ck('#version').attr('value'), description: $ck('#description').attr('value'), blocs: blocs, id: TEMPLATEID, makearchive: task, widgets: jsonWidgets, facktoload: facktoload } }).done(function(code) { $ck('#packagestep1').empty().append(code); $ck('#packagestep1').append(Joomla.JText._('CK_LOAD_SUCCESS_STEP1', 'Step 1 finished with success')); makeCssStep(task); }).fail(function() { $ck('#packagestep1').empty(); $ck('#packagestep1').append(Joomla.JText._('CK_LOAD_FAILURE_STEP1', 'Step 1 encounter some errors')); }); } /** * * Function to generate template.css file */ function makeCssStep(task) { blocs = getBlocks(); blocs = JSON.stringify(blocs); blocs = blocs.replace(/#/g, "|di|"); var layoutcommentscss = $ck('#layout_comments_html > .ckstyle').length ? $ck('#layout_comments_html > .ckstyle').text() : ''; var layouterror404custommessage = $ck('#layout_error404_html > .error404custommessage').length ? $ck('#layout_error404_html > .error404custommessage').html() : ''; var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxtemplatecss&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').attr('value'), joomlaversion: $ck('#joomlaversion').attr('value'), column1width: COLUMN1WIDTH, column2width: COLUMN2WIDTH, blocs: blocs, templateid: TEMPLATEID, htmlcode_responsive: $ck('#htmlcode_responsive').val(), responsivevalues: $ck('#body').attr('responsivevalues'), layoutcommentscss: layoutcommentscss, layouterror404custommessage: layouterror404custommessage } }).done(function(code) { $ck('#packagestepcss').empty().append(code); $ck('#packagestepcss').append(Joomla.JText._('CK_LOAD_SUCCESS_STEP_CSS', 'Next step finished with success')); makeXmlStep(task); }).fail(function() { $ck('#packagestepcss').empty(); $ck('#packagestepcss').append(Joomla.JText._('CK_LOAD_FAILURE_STEP_CSS', 'Next step encounter some errors')); }); } /** * * Function to generate XML file */ function makeXmlStep(task) { blocs = getBlocks(); blocs = JSON.stringify(blocs); blocs = blocs.replace(/#/g, "|di|"); var positions = []; $ck('.ckbloc').each(function(i, bloc) { bloc = $ck(bloc); if (bloc.attr('ckmoduleposition') && bloc.attr('isdisabled') != 'true') positions.push(bloc.attr('ckmoduleposition')); }); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxxml&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').attr('value'), joomlaversion: $ck('#joomlaversion').attr('value'), creationdate: $ck('#creationdate').attr('value'), author: $ck('#author').attr('value'), authorEmail: $ck('#authoremail').attr('value'), authorUrl: $ck('#authorurl').attr('value'), copyright: $ck('#copyright').attr('value'), license: $ck('#license').attr('value'), version: $ck('#version').attr('value'), description: $ck('#description').attr('value'), blocs: blocs, positions: positions, saveintemplate: task } }).done(function(code) { $ck('#packagestepxml').empty().append(code); $ck('#packagestepxml').append(Joomla.JText._('CK_LOAD_SUCCESS_STEP_XML', 'Next step finished with success')); if (task == 'package' || task == 'copy') { makeArchiveStep(task); } else if (task == 'install') { installTemplate(); } else { makePreviewStep(); } }).fail(function() { $ck('#packagestepxml').empty(); $ck('#packagestepxml').append(Joomla.JText._('CK_LOAD_FAILURE_STEP_XML', 'Next step encounter some errors')); }); } function ckAutoCreateThumbs() { // auto generate thumbnail if (!$ck('#body .tab_systemimagesstyles').attr('template_thumbnailsystemimageurl')) { html2canvas($ck('#body'), { onrendered: function(canvas) { var dataImage = canvas.toDataURL("image/png"); var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxAutoCreateThumbs&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, async: true, data: { data: dataImage, templatename: $ck('#name').attr('value'), } }); } }); } } /** * * Function to generate the preview button */ function makePreviewStep() { var myurl = URIROOT + "/index.php?option=com_content&templatename=" + $ck('#name').attr('value') + "&template=templatecreatorck&tmpl=preview"; var previewlink = '<p styles="padding:15px"><a class="ckpreview ckbuttonstyle" href="' + myurl + '" target="_blank">' + Joomla.JText._('CK_PREVIEW_TEMPLATE', 'Preview the template') + '</a></p>'; $ck('.packagesteparchive').append(previewlink); ckAutoCreateThumbs(); } /** * * Function to generate the ZIP archive */ function makeArchiveStep(task) { var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxarchive&format=raw"; $ck.ajax({ type: "POST", url: myurl, data: { templatename: $ck('#name').attr('value'), saveintemplate: task } }).done(function(code) { $ck('.packagesteparchive').empty().append(code); ckAutoCreateThumbs(); }).fail(function() { $ck('.packagesteparchive').empty(); $ck('.packagesteparchive').append(Joomla.JText._('CK_LOAD_FAILURE_STEP_ARCHIVE', 'Archive encounter some errors')); }); } function installTemplate() { var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxinstalltemplate"; $ck.ajax({ type: "POST", url: myurl, dataType: "json", data: { templatename: $ck('#name').val() } }).done(function(response) { if (response.type == 'error') { msg = '<p class="badgeck errorck">' + response.message + '</p>'; } else { msg = '<p class="badgeck successck">' + response.message + '</p>'; } $ck('.packagesteparchive').empty().append(msg); // mettre le message dans la fenetre avec toues les autres messages if (response.result == 'true') { // change the install button to copy $ck('.ck_button.install').hide(); $ck('.ck_button.copy').show(); } }).fail(function() { alert('Failed : Template installation'); }); } /** * * Function to generate final html code */ function makeHtmlOutput(task) { var code = new Array("head", "body"); var video = getVideoCode($ck('#body')); code["head"] = ''; code["body"] = '' + video["code"]; var j = 0; var customcode = ''; var wrappercondition = false; iW = 0; // index for wrappers $ck('.wrapper.ckbloc, .wrapper > .inner > .ckbloc').each(function(i, bloc) { bloc = $ck(bloc); var retrievecode = ''; // retrieve id for the block var blocid = ''; if (bloc.attr("id")) { blocid = ' id="' + bloc.attr("id") + '"'; } // retrieve id for the block var blocmoduleposition = ''; if (bloc.attr("ckmoduleposition")) { blocmoduleposition = bloc.attr("ckmoduleposition"); } // retrieve class for the bloc var blocclass = ''; if (bloc.attr("ckclass")) { // blocclass = ' class="' + bloc.attr("ckclass") + '"'; } else { blocclass = ''; } // retrieve style for the module var blocmodulestyle = ' style="htmlck"'; if (bloc.attr("ckmodulestyle")) { blocmodulestyle = ' style="' + bloc.attr("ckmodulestyle") + '"'; } // Begin the modules code construction codetmp = getBlockHtml(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, j, task, 0); code["body"] += codetmp["body"]; code["head"] += codetmp["head"]; // construct a wrapper if (bloc.hasClass('wrapper')) { retrievecode = makeWrapper(bloc, blocid, blocclass, iW, wrappercondition); code["body"] += retrievecode["body"]; code["head"] += retrievecode["head"]; wrappercondition = retrievecode["wrappercondition"]; iW++; } code["body"] += '|rr|'; j++; }); code['body'] += '|tab|</div>|rr|' + '</div>|rr|'; if (wrappercondition) { code['body'] += '<?php endif; ?>'; } return code; } function getBlockHtml(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, j, task, nbtabs) { if (! nbtabs) nbtabs = 0; var retrievecode = new Array("head", "body"); retrievecode["head"] = ''; retrievecode["body"] = ''; // var retrievecode = ''; // construct single module code if (bloc.hasClass('ckrow')) { retrievecode = makeHtmlRow(bloc, blocid, blocclass, blocmodulestyle, j, task, nbtabs); // code["body"] += retrievecode["body"]; } // construct single module code if (bloc.hasClass('logobloc')) { retrievecode = makeHtmlLogo(bloc, blocid, blocclass, task, nbtabs); // code["body"] += retrievecode["body"]; } // construct single module code if (bloc.hasClass('singlemodule') || bloc.hasClass('module')) { retrievecode = makeHtmlSingleModule(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, nbtabs); // code["body"] += retrievecode["body"]; } // construct flexible module code if (bloc.hasClass('flexiblemodules')) { retrievecode = makeHtmlFlexibleModules(bloc, blocid, blocclass, j, nbtabs); // code["body"] += retrievecode["body"]; // code["head"] += retrievecode["head"]; } // construct banner and logo block code if (bloc.hasClass('mainbanner') && !$ck('.bannermenu', bloc).length) { retrievecode = makeHtmlOldBanner(bloc, blocid, blocclass, task, nbtabs); // code["body"] += retrievecode["body"]; } else if (bloc.hasClass('mainbanner') && $ck('.bannermenu', bloc).length) { retrievecode = makeHtmlBanner(bloc, blocid, blocclass, task, nbtabs); // code["body"] += retrievecode["body"]; } // construct horizontal menu code if (bloc.hasClass('horiznav')) { retrievecode = makeHtmlHorizNav(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, nbtabs); // code["body"] += retrievecode["body"]; } // construct custom block code if (bloc.hasClass('custombloc')) { customcode = $ck('div.customcont', bloc).text().replace(/#/g, "|di|"); retrievecode["body"] += '|tab|<div' + blocid + blocclass + '>|rr|' + '|tab||tab|<div class="inner">' + customcode + '</div>|rr|' + '|tab|</div>|rr|'; } // construct complex component layout code if (bloc.hasClass('maincontent')) { retrievecode = makeHtmlMaincontent(bloc, blocid, blocclass, blocmodulestyle, j, task); } // code["body"] += retrievecode["body"]; // code["head"] += retrievecode["head"]; return retrievecode; } /*********************************************** * modules html creation * * *********************************************/ function addVideoBackground(bloc) { var webmurl = bloc.find('> .tab_videobgstyles').attr('blocvideourlwebm') ? bloc.find('> .tab_videobgstyles').attr('blocvideourlwebm') : ''; var mp4url = bloc.find('> .tab_videobgstyles').attr('blocvideourlmp4') ? bloc.find('> .tab_videobgstyles').attr('blocvideourlmp4') : ''; var ogvurl = bloc.find('> .tab_videobgstyles').attr('blocvideourlogv') ? bloc.find('> .tab_videobgstyles').attr('blocvideourlogv') : ''; var videocode = '|tab||tab|<video autoplay loop muted poster="" class="videobackground">|rr|' + (webmurl ? '|tab||tab||tab|<source src="'+webmurl+'" type="video/webm">|rr|' : '') +(mp4url ? '|tab||tab||tab|<source src="'+mp4url+'" type="video/mp4">|rr|' : '') +(ogvurl ? '|tab||tab||tab|<source src="'+ogvurl+'" type="video/ogg">|rr|' : '') +'|tab||tab|</video>|rr|'; return videocode; } function checkVideoBackground(bloc) { if (bloc.find('> .tab_videobgstyles').length && ( bloc.find('> .tab_videobgstyles').attr('blocvideourlmp4') || bloc.find('> .tab_videobgstyles').attr('blocvideourlwebm') || bloc.find('> .tab_videobgstyles').attr('blocvideourlogv') ) ) return true; return false; } function getVideoCode(bloc) { var video = new Array(); video["code"] = ''; video["class"] = ''; if (checkVideoBackground(bloc)) { video["code"] = addVideoBackground(bloc); video["class"] = " hasvideobackground"; } return video; } function getIconAttribs(bloc) { if (! bloc.find('.fack').length) return ''; var icon = ' icon="' + bloc.find('.fack').attr('data-type') + '"'; var iconpos = ' iconpos="' + bloc.find('.fack').attr('data-pos') + '"'; var iconsize = ' iconsize="' + bloc.find('.fack').attr('data-size') + '"'; var iconvpos = ' iconvpos="' + bloc.find('.fack').attr('data-vpos') + '"'; facktoload = true; return icon + iconpos + iconsize + iconvpos; } /** * Function to get all children bloc and get their module position * */ function getChildrenBlocksPositions(bloc) { var positions = bloc.find('.ckbloc').map(function() { return $ck(this).attr('ckmoduleposition'); }); return positions; } /** * Function to write the countModules condition for all blocks * */ function makeChildrenBlocksConditions(positions) { positions = $ck.makeArray(positions); // convert object to array var conditions = positions.join("') || $this->countModules('"); conditions = "$this->countModules('" + conditions + "')"; return conditions; } /** * Function to render a wrapper * */ function makeWrapper(bloc, blocid, blocclass, iW, wrappercondition) { var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; // code["wrappercondition"] = wrappercondition; var video = getVideoCode(bloc); if (bloc.attr('data-class')) { blocclass = ' class="' + bloc.attr('data-class') + '"'; } if (bloc.find('.ckbloc.singlemodule,.ckbloc.horiznav,.ckbloc.flexiblemodule').length && ! bloc.find('.maincontent').length && ! bloc.find('.logobloc').length && ! bloc.find('.customcont').length ) { // singlemodule, horiznav, flexiblemodule var childrenPositions = getChildrenBlocksPositions(bloc); var conditions = makeChildrenBlocksConditions(childrenPositions); code["wrappercondition"] = true; } else { code["wrappercondition"] = false; } if (iW == 0) { if (code["wrappercondition"] == true) { code["body"] += '<?php if(' + conditions + ') : ?>|rr|'; } code["body"] += '<div' + blocid + blocclass + '>|rr|' + '|tab|<div class="' + $ck('.inner', bloc).attr('class').replace('ui-sortable', '') + video["class"] +'">|rr|'; } else { code["body"] = '|tab|</div>|rr|' + '</div>|rr|'; if (wrappercondition == true) { code["body"] += '<?php endif; ?>|rr|'; } if (code["wrappercondition"] == true) { code["body"] += '<?php if(' + conditions + ') : ?>|rr|'; } code["body"] += '<div' + blocid + blocclass + '>|rr|' + '|tab|<div class="' + $ck('.inner', bloc).attr('class').replace('ui-sortable', '') + video["class"] +'">|rr|'; } code["body"] += video["code"]; return code; } /** * Function to render some flexible modules * */ function makeHtmlRow(bloc, blocid, blocclass, blocmodulestyle, j, task) { // initialisation bloc = $ck(bloc); var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var video = getVideoCode(bloc); var blocclass = bloc.attr("data-class") ? ' class="clearfix ' + bloc.attr("data-class") + '"' : ' class="clearfix"'; code["body"] += '|tab|<section' + blocid + blocclass + '>|rr|' + '|tab||tab|<div class="inner clearfix' + video["class"] +'">|rr|'; code["body"] += video["code"]; // code["head"] += '<?php|rr|' // + '$nbmodules' + j + ' = '; $ck('.ckrowcontainer', bloc).each(function(i, container) { container = $ck(container); code["body"] += '|tab||tab||tab|<div class="flexiblecolumn" style="width:' + container.attr('data-width') + '%;">|rr|'; $ck('.ckbloc', container).each(function(i, module) { module = $ck(module); module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; var tmpcode = getBlockHtml(module, module.jdocposition, module.ckid, module.classe, blocmodulestyle, j+'r'+i, task, 3); code["head"] += tmpcode["head"]; code["body"] += tmpcode["body"]; }); code["body"] += '|tab||tab||tab|</div>|rr|'; }); code["body"] += '|tab||tab||tab|<div class="clr"></div>|rr|' + '|tab||tab|</div>|rr|' + '|tab|</section>|rr|'; return code; } /** * Function to render a single module * */ function makeHtmlSingleModule(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, nbtabs) { var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var video = getVideoCode(bloc); var offsettabs = str_repeat('|tab|', nbtabs); bloctag = (bloc[0] == $ck('.ckbloc').last()[0] ? 'footer' : 'div'); code["body"] = offsettabs + '|tab|<?php if ($this->countModules(\'' + blocmoduleposition + '\')) : ?>|rr|' + offsettabs + '|tab|<'+bloctag+'' + blocid + blocclass + '>|rr|' + offsettabs + '|tab||tab|<div class="inner clearfix' + video["class"] + '">|rr|' + offsettabs + video["code"] + offsettabs + '|tab||tab||tab|<jdoc:include type="modules" name="' + blocmoduleposition + '"' + blocmodulestyle + getIconAttribs(bloc) + ' />|rr|' + offsettabs + '|tab||tab|</div>|rr|' + offsettabs + '|tab|</'+bloctag+'>|rr|' + offsettabs + '|tab|<?php endif; ?>|rr|'; return code; } /** * Function to render some flexible modules * */ function makeHtmlFlexibleModules(bloc, blocid, blocclass, j, nbtabs) { // initialisation bloc = $ck(bloc); var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var video = getVideoCode(bloc); var offsettabs = str_repeat('|tab|', nbtabs); var blocclass = bloc.attr("ckclass") ? ' class="clearfix ' + bloc.attr("ckclass") + '"' : ' class="clearfix"'; code["body"] += offsettabs + '|tab|<?php if ($nbmodules' + j + ') : ?>|rr|' + offsettabs + '|tab|<section' + blocid + blocclass + '>|rr|' + offsettabs + '|tab||tab|<div class="inner clearfix' + video["class"] + ' <?php echo \'n\'.$nbmodules' + j + ' ?>">|rr|' + offsettabs + video["code"]; code["head"] += '<?php|rr|' + '$nbmodules' + j + ' = '; $ck('.flexiblemodule', bloc).each(function(i, module) { module = $ck(module); if (module.attr('isdisabled') != 'true') { if (i > 0) code["head"] += ' + '; video = getVideoCode(module); // retrieve data for the block module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? module.attr("ckclass") : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; code["body"] += offsettabs + '|tab||tab||tab|<?php if ($this->countModules(\'' + module.jdocposition + '\')) : ?>|rr|' + offsettabs + '|tab||tab||tab|<div' + module.ckid + ' class="flexiblemodule ' + module.classe + '">|rr|' + offsettabs + '|tab||tab||tab||tab|<div class="inner clearfix' + video["class"] + '">|rr|' + offsettabs + video["code"] + offsettabs + '|tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + module.jdocposition + '"' + module.jdocstyle + getIconAttribs(module) + ' />|rr|' + offsettabs + '|tab||tab||tab||tab|</div>|rr|' + offsettabs + '|tab||tab||tab|</div>|rr|' + offsettabs + '|tab||tab||tab|<?php endif; ?>|rr|'; code["head"] += '(bool)$this->countModules(\'' + module.jdocposition + '\')'; } }); code["body"] += offsettabs + '|tab||tab||tab|<div class="clr"></div>|rr|' + offsettabs + '|tab||tab|</div>|rr|' + offsettabs + '|tab|</section>|rr|' + offsettabs + '|tab|<?php endif; ?>|rr||rr|'; code["head"] += ';|rr|' + '?>|rr|'; return code; } /** * Function to render a banner with logo * */ function makeHtmlLogo(bloc, blocid, blocclass, task, nbtabs) { // initialisation var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var offsettabs = str_repeat('|tab|', nbtabs); // retrieve data for the block bloc.ckid = bloc.attr("id") ? ' id="' + bloc.attr("id") + '"' : ''; bloc.classe = bloc.attr("ckclass") ? ' class="' + bloc.attr("ckclass") + '"' : ' class="logo"'; bloc.logoimage = $ck('img', bloc) ? $ck('img', bloc).attr('src').split("/").reverse()[0] : ''; bloc.logowidth = $ck('.tab_blocstyles', bloc).attr("logowidth") ? ' width="<?php echo $this->params->get(\''+bloc.attr("id")+'_logowidth\', \'' + testUnit($ck('.tab_blocstyles', bloc).attr("logowidth")) + '\') ?>"' : ''; bloc.logoheight = $ck('.tab_blocstyles', bloc).attr("logoheight") ? ' height="<?php echo $this->params->get(\''+bloc.attr("id")+'_logoheight\', \'' + testUnit($ck('.tab_blocstyles', bloc).attr("logoheight")) + '\') ?>"' : ''; logodesc = $ck('> .inner > .bannerlogodesc', bloc); logodesccode = ''; if (logodesc.length) { logodesccode = offsettabs + '|tab||tab||tab|<?php if ($this->params->get(\''+bloc.attr("id")+'_logodescription\')) { ?>|rr|' + offsettabs + '|tab||tab||tab|<div class="bannerlogodesc">|rr|' + offsettabs + '|tab||tab||tab||tab|<div class="inner clearfix"><?php echo htmlspecialchars($this->params->get(\''+bloc.attr("id")+'_logodescription\'));?></div>|rr|' + offsettabs + '|tab||tab||tab|</div>|rr|' + offsettabs + '|tab||tab||tab|<?php } ?>|rr|'; } code["body"] += offsettabs + '|tab|<div' + bloc.ckid + bloc.classe + '>|rr|' + offsettabs + '|tab||tab|<div class="inner clearfix">|rr|' + offsettabs + '|tab||tab||tab|<?php if ($this->params->get(\''+bloc.attr("id")+'_logolink\')) { ?>|rr|' + offsettabs + '|tab||tab||tab|<a href="<?php echo htmlspecialchars($this->params->get(\''+bloc.attr("id")+'_logolink\')); ?>">|rr|' + offsettabs + '|tab||tab||tab|<?php } ?>|rr|' + ( task == 'preview' ? offsettabs + '|tab||tab||tab||tab|<img src="'+$ck('img', bloc).attr('src')+'"' + bloc.logowidth + bloc.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+bloc.attr("id")+'_logotitle\',\'\'));?>" />|rr|' : offsettabs + '|tab||tab||tab||tab|<img src="<?php echo $this->params->get(\''+bloc.attr("id")+'_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + bloc.logoimage + '\') ?>"' + bloc.logowidth + bloc.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+bloc.attr("id")+'_logotitle\',\'\'));?>" />|rr|') + offsettabs + '|tab||tab||tab|<?php if ($this->params->get(\''+bloc.attr("id")+'_logolink\')) { ?>|rr|' + offsettabs + '|tab||tab||tab|</a>|rr|' + offsettabs + '|tab||tab||tab|<?php } ?>|rr|' + logodesccode + offsettabs + '|tab||tab|</div>|rr|' + offsettabs + '|tab|</div>|rr|'; return code; } /** * Function to render a banner with logo * */ function makeHtmlBanner(bloc, blocid, blocclass, task, nbtabs) { // initialisation var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var video = getVideoCode(bloc); code["body"] += '|tab|<header' + blocid + blocclass + '>|rr|' + '|tab||tab|<div class="inner clearfix' + video["class"] + '">|rr|' + '|tab||tab|' + video["code"]; $ck('.ckbloc', bloc).each(function(i, module) { module = $ck(module); // retrieve data for the block module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ' class="logobloc"'; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; if (module.hasClass('bannerlogo')) { module.logoimage = $ck('img', module) ? $ck('img', module).attr('src').split("/").reverse()[0] : ''; module.logowidth = $ck('.tab_blocstyles', module).attr("logowidth") ? ' width="<?php echo $this->params->get(\''+module.attr("id")+'_logowidth\', \'' + testUnit($ck('.tab_blocstyles', module).attr("logowidth")) + '\') ?>"' : ''; module.logoheight = $ck('.tab_blocstyles', module).attr("logoheight") ? ' height="<?php echo $this->params->get(\''+module.attr("id")+'_logoheight\', \'' + testUnit($ck('.tab_blocstyles', module).attr("logoheight")) + '\') ?>"' : ''; logodesc = $ck('> .inner > .bannerlogodesc', module); logodesccode = ''; if (logodesc.length) { logodesccode = '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\''+module.attr("id")+'_logodescription\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|<div class="bannerlogodesc">|rr|' + '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix"><?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logodescription\'));?></div>|rr|' + '|tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|'; } code["body"] += '|tab||tab||tab|<div' + module.ckid + module.classe + '>|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\''+module.attr("id")+'_logolink\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|<a href="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logolink\')); ?>">|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|' + ( task == 'preview' ? '|tab||tab||tab||tab||tab||tab|<img src="'+$ck('img', module).attr('src')+'"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logotitle\',\'\'));?>" />|rr|' : '|tab||tab||tab||tab||tab||tab|<img src="<?php echo $this->params->get(\''+module.attr("id")+'_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + module.logoimage + '\') ?>"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logotitle\',\'\'));?>" />|rr|') + '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\''+module.attr("id")+'_logolink\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|</a>|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|' + logodesccode + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab|</div>|rr|'; } else if (!module.hasClass('bannerlogodesc') && (module.attr('isdisabled') == 'false' || !module.attr('isdisabled'))) { code["body"] += '|tab||tab||tab|<?php if ($this->countModules(\'' + module.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab|<div' + module.ckid + module.classe + '>|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|'; if (module.hasClass('bannermenu')) { code["body"] += '|tab||tab||tab||tab|<label for="' + module.attr("id") + '-mobileck" class="mobileckhambuger_togglerlabel" style="display:none;">≡</label>|rr|' + '|tab||tab||tab||tab|<input id="' + module.attr("id") + '-mobileck" class="mobileckhambuger_toggler" type="checkbox" style="display:none;"/>|rr|' } code["body"] += '|tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + module.jdocposition + '"' + module.jdocstyle + getIconAttribs(module) + ' />|rr|' + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab|</div>|rr|' + '|tab||tab||tab|<?php endif; ?>|rr|'; } }); code["body"] += '|tab||tab|<div class="clr"></div>|rr|' + '|tab||tab|</div>|rr|' + '|tab|</header>|rr|'; return code; } /** * Function to render a banner with logo (old method) * */ function makeHtmlOldBanner(bloc, blocid, blocclass, task) { // initialisation var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; code["body"] += '|tab|<header' + blocid + blocclass + '>|rr|' + '|tab||tab|<div class="inner clearfix">|rr|'; $ck('.ckbloc', bloc).each(function(i, module) { module = $ck(module); // retrieve data for the block module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ' class="logobloc"'; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; if (module.hasClass('bannerlogo')) { module.logoimage = $ck('img', module) ? $ck('img', module).attr('src').split("/").reverse()[0] : ''; module.logowidth = $ck('.tab_blocstyles', module).attr("logowidth") ? ' width="<?php echo $this->params->get(\''+module.attr("id")+'_logowidth\', \'' + testUnit($ck('.tab_blocstyles', module).attr("logowidth")) + '\') ?>"' : ''; module.logoheight = $ck('.tab_blocstyles', module).attr("logoheight") ? ' height="<?php echo $this->params->get(\''+module.attr("id")+'_logoheight\', \'' + testUnit($ck('.tab_blocstyles', module).attr("logoheight")) + '\') ?>"' : ''; logodesc = $ck('> .inner > .bannerlogodesc', module); logodesccode = ''; if (logodesc.length) { logodesccode = '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\'logodescription\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|<div class="bannerlogodesc">|rr|' + '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix"><?php echo htmlspecialchars($this->params->get(\'logodescription\'));?></div>|rr|' + '|tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|'; } code["body"] += '|tab||tab||tab|<div' + module.ckid + module.classe + '>|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\''+module.attr("id")+'_logolink\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|<a href="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logolink\')); ?>">|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|' + ( task == 'preview' ? '|tab||tab||tab||tab||tab||tab|<img src="'+$ck('img', module).attr('src')+'"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logotitle\',\'\'));?>" />|rr|' : '|tab||tab||tab||tab||tab||tab|<img src="<?php echo $this->params->get(\''+module.attr("id")+'_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + module.logoimage + '\') ?>"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars($this->params->get(\''+module.attr("id")+'_logotitle\',\'\'));?>" />|rr|') + '|tab||tab||tab||tab||tab|<?php if ($this->params->get(\''+module.attr("id")+'_logolink\')) { ?>|rr|' + '|tab||tab||tab||tab||tab|</a>|rr|' + '|tab||tab||tab||tab||tab|<?php } ?>|rr|' + logodesccode + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab|</div>|rr|'; } else if (!module.hasClass('bannerlogodesc')) { code["body"] += '|tab||tab||tab|<?php if ($this->countModules(\'' + module.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab|<div' + module.ckid + module.classe + '>|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + module.jdocposition + '"' + module.jdocstyle + getIconAttribs(module) + ' />|rr|' + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab|</div>|rr|' + '|tab||tab||tab|<?php endif; ?>|rr|'; } }); code["body"] += '|tab||tab|<div class="clr"></div>|rr|' + '|tab||tab|</div>|rr|' + '|tab|</header>|rr|'; return code; } /** * Function to render a horizontal menu * */ function makeHtmlHorizNav(bloc, blocmoduleposition, blocid, blocclass, blocmodulestyle, nbtabs) { // initialisation var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; var offsettabs = str_repeat('|tab|', nbtabs); code["body"] = offsettabs + '|tab|<?php if ($this->countModules(\'' + blocmoduleposition + '\')) : ?>|rr|' + offsettabs + '|tab|<nav' + blocid + blocclass + '>|rr|' + offsettabs + '|tab||tab|<div class="inner clearfix">|rr|' + offsettabs + '|tab||tab||tab|<label for="' + blocmoduleposition + '-mobileck" class="mobileckhambuger_togglerlabel" style="display:none;">≡</label>|rr|' + offsettabs + '|tab||tab||tab|<input id="' + blocmoduleposition + '-mobileck" class="mobileckhambuger_toggler" type="checkbox" style="display:none;"/>|rr|' + offsettabs + '|tab||tab||tab|<jdoc:include type="modules" name="' + blocmoduleposition + '"' + getIconAttribs(bloc) + ' />|rr|' + offsettabs + '|tab||tab|</div>|rr|' + offsettabs + '|tab|</nav>|rr|' + offsettabs + '|tab|<?php endif; ?>|rr|'; return code; } /* * Function to render a complex component layout * */ function makeHtmlMaincontent(bloc, blocid, blocclass, blocmodulestyle, j, task, nbtabs) { var code = new Array("head", "body"); code["head"] = ''; code["body"] = ''; column1width = 0; column2width = 0; var jj = 1; // internal var used for additionnal blocks conditions // begin the global container code["body"] += '|tab|<div' + blocid + ' class="maincontent ' + (bloc.attr("ckclass") ? bloc.attr("ckclass") + ' ' : '') + '<?php echo $mainclass ?>">|rr|' + '|tab||tab|<div class="inner clearfix">|rr|'; column1enabled = 1; column1 = ''; column2enabled = 1; column2 = ''; $ck('.ckbloc', bloc).each(function(i, column) { column = $ck(column); column.ckid = column.attr("id") ? ' id="' + column.attr("id") + '"' : ''; column.classe = column.attr("ckclass") ? column.attr("ckclass") : ''; column.jdocstyle = column.attr("ckmodulestyle") ? ' style="' + column.attr("ckmodulestyle") + '"' : ' style="htmlck"'; column.jdocposition = column.attr("ckmoduleposition") ? column.attr("ckmoduleposition") : ''; // if the first big column if (column.hasClass('column1') && column.attr('isdisabled') != "true") { // column1 = column.jdocposition; column1width = column.attr('blocwidth') ? column.attr('blocwidth') : '200'; var column1positions = $ck('.ckbloc', column).map(function() {return $ck(this).attr("ckmoduleposition"); }); column1positions.push(column.attr("ckmoduleposition")); column1 = $ck.makeArray(column1positions); code["body"] += '|tab||tab||tab|<?php if ($this->countModules(\'' + column1.join('\') || $this->countModules(\'') + '\')) : ?>|rr|' + '|tab||tab||tab|<aside' + column.ckid + ' class="column column1' + column.classe + '">|rr|' + '|tab||tab||tab||tab|<?php if ($this->countModules(\'' + column.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + column.jdocposition + '"' + column.jdocstyle + getIconAttribs(column) + ' />|rr|' + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab|<?php endif; ?>|rr|';; $ck('.ckbloc', column).each(function(i, module) { module = $ck(module); module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; var tmpcode = getBlockHtml(module, module.jdocposition, module.ckid, module.classe, module.jdocstyle, j + 'mc' + jj, task, 3); jj++; code["head"] += tmpcode["head"]; code["body"] += tmpcode["body"]; }); code["body"] += '|tab||tab||tab|</aside>|rr|' + '|tab||tab||tab|<?php endif; ?>|rr|'; } else if (column.hasClass('column1') && column.attr('isdisabled') == "true") { column1enabled = 0; } // if the main container column - look into to search for other blocks if (column.hasClass('main')) { if (column.attr('ishidden') != "true") code["body"] += '|tab||tab||tab|<div' + column.ckid + ' class="column main row-fluid' + column.classe + '">|rr|' + '|tab||tab||tab||tab|<div class="inner clearfix">|rr|'; // look for sub columns $ck('.ckbloc', column).each(function(h, subcolumn) { subcolumn = $ck(subcolumn); subcolumn.ckid = subcolumn.attr("id") ? ' id="' + subcolumn.attr("id") + '"' : ''; subcolumn.classe = subcolumn.attr("ckclass") ? subcolumn.attr("ckclass") : ''; subcolumn.jdocstyle = subcolumn.attr("ckmodulestyle") ? ' style="' + subcolumn.attr("ckmodulestyle") + '"' : ' style="htmlck"'; subcolumn.jdocposition = subcolumn.attr("ckmoduleposition") ? subcolumn.attr("ckmoduleposition") : ''; if ((subcolumn.hasClass('maintop') || subcolumn.hasClass('mainbottom')) && subcolumn.attr('isdisabled') != "true") { // subcolumn.classe = (subcolumn.classe) ? 'class="' + subcolumn.classe + '"' : ''; // code["body"] += '|tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + subcolumn.jdocposition + '\')) : ?>|rr|' // + '|tab||tab||tab||tab||tab|<div' + subcolumn.ckid + subcolumn.classe + '>|rr|' // + '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|' // + '|tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + subcolumn.jdocposition + '"' + subcolumn.jdocstyle + ' />|rr|' // + '|tab||tab||tab||tab||tab||tab|</div>|rr|' // + '|tab||tab||tab||tab||tab|</div>|rr|' // + '|tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; if (subcolumn.find('.ckrowcontainer').length) { $ck('.ckbloc', subcolumn).each(function(i, module) { module = $ck(module); module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; var tmpcode = getBlockHtml(module, module.jdocposition, module.ckid, module.classe, module.jdocstyle, j + 'mc' + jj, task, 4); jj++; code["head"] += tmpcode["head"]; code["body"] += tmpcode["body"]; }); } else { // retrocompatibility before 3.4 subcolumn.classe = (subcolumn.classe) ? 'class="' + subcolumn.classe + '"' : ''; code["body"] += '|tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + subcolumn.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab||tab||tab|<div' + subcolumn.ckid + subcolumn.classe + '>|rr|' + '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + subcolumn.jdocposition + '"' + subcolumn.jdocstyle + getIconAttribs(subcolumn) + ' />|rr|' + '|tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; } } if (subcolumn.hasClass('maincenter')) { // begin the center container if (subcolumn.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab|<div' + subcolumn.ckid + ' class="maincenter ' + column.classe + '">|rr|' + '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|'; $ck('.ckbloc', subcolumn).each(function(g, centercolumn) { centercolumn = $ck(centercolumn); centercolumn.ckid = centercolumn.attr("id") ? ' id="' + centercolumn.attr("id") + '"' : ''; centercolumn.classe = centercolumn.attr("ckclass") ? centercolumn.attr("ckclass") : ''; centercolumn.jdocstyle = centercolumn.attr("ckmodulestyle") ? ' style="' + centercolumn.attr("ckmodulestyle") + '"' : ' style="htmlck"'; centercolumn.jdocposition = centercolumn.attr("ckmoduleposition") ? centercolumn.attr("ckmoduleposition") : ''; if (centercolumn.hasClass('column2') && centercolumn.attr('isdisabled') != "true") { // column2 = centercolumn.jdocposition; column2width = centercolumn.attr('blocwidth') ? centercolumn.attr('blocwidth') : '200'; var column2positions = $ck('.ckbloc', centercolumn).map(function() {return $ck(this).attr("ckmoduleposition"); }); column2positions.push(centercolumn.attr("ckmoduleposition")); column2 = $ck.makeArray(column2positions); code["body"] += '|tab||tab||tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + column2.join('\') || $this->countModules(\'') + '\')) : ?>|rr|' + '|tab||tab||tab||tab||tab||tab||tab|<aside' + centercolumn.ckid + ' class="column column2' + centercolumn.classe + '">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + centercolumn.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + centercolumn.jdocposition + '"' + centercolumn.jdocstyle + getIconAttribs(centercolumn) + ' />|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; $ck('.ckbloc', centercolumn).each(function(i, module) { module = $ck(module); module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; var tmpcode = getBlockHtml(module, module.jdocposition, module.ckid, module.classe, module.jdocstyle, j + 'mc' + jj, task, 7); jj++; code["head"] += tmpcode["head"]; code["body"] += tmpcode["body"]; }); code["body"] += '|tab||tab||tab||tab||tab||tab||tab|</aside>|rr|' + '|tab||tab||tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; } else if (centercolumn.hasClass('column2') && centercolumn.attr('isdisabled') == "true") { column2enabled = 0; } if (centercolumn.hasClass('center')) { if (centercolumn.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab||tab||tab|<main' + centercolumn.ckid + ' class="column center ' + centercolumn.classe + '">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner">|rr|'; // look for sub blocks $ck('.ckbloc', centercolumn).each(function(f, centerbloc) { centerbloc = $ck(centerbloc); centerbloc.ckid = centerbloc.attr("id") ? ' id="' + centerbloc.attr("id") + '"' : ''; centerbloc.classe = centerbloc.attr("ckclass") ? centerbloc.attr("ckclass") : ''; centerbloc.jdocstyle = centerbloc.attr("ckmodulestyle") ? ' style="' + centerbloc.attr("ckmodulestyle") + '"' : ' style="htmlck"'; centerbloc.jdocposition = centerbloc.attr("ckmoduleposition") ? centerbloc.attr("ckmoduleposition") : ''; if ((centerbloc.hasClass('centertop') || centerbloc.hasClass('centerbottom')) && centerbloc.attr('isdisabled') != "true") { // code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + centerbloc.jdocposition + '\')) : ?>|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<div' + centerbloc.ckid + ' class="' + centerbloc.classe + '">|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + centerbloc.jdocposition + '"' + centerbloc.jdocstyle + ' />|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' // + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; if (centerbloc.find('.ckrowcontainer').length) { $ck('.ckbloc', centerbloc).each(function(i, module) { module = $ck(module); module.ckid = module.attr("id") ? ' id="' + module.attr("id") + '"' : ''; module.classe = module.attr("ckclass") ? ' class="' + module.attr("ckclass") + '"' : ''; module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ' style="htmlck"'; module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : ''; var tmpcode = getBlockHtml(module, module.jdocposition, module.ckid, module.classe, module.jdocstyle, j + 'mc' + jj, task, 7); jj++; code["head"] += tmpcode["head"]; code["body"] += tmpcode["body"]; }); } else { // retrocompatibility before 3.4 code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<?php if ($this->countModules(\'' + centerbloc.jdocposition + '\')) : ?>|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<div' + centerbloc.ckid + ' class="' + centerbloc.classe + '">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="modules" name="' + centerbloc.jdocposition + '"' + centerbloc.jdocstyle + getIconAttribs(centerbloc) + ' />|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<?php endif; ?>|rr|'; } } if (centerbloc.hasClass('content')) { if (centerbloc.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<div' + centerbloc.ckid + ' class="' + centerbloc.classe + '">|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix">|rr|'; code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="message" />|rr|' + '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<jdoc:include type="component" />|rr|'; if (centerbloc.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' +'|tab||tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|'; } }); if (centercolumn.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab||tab||tab|</main>|rr|'; } }); // close the center container if (subcolumn.attr('ishidden') != "true") code["body"] += '|tab||tab||tab||tab||tab||tab||tab|<div class="clr"></div>|rr|' + '|tab||tab||tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab||tab||tab|</div>|rr|'; } }); // close main container column if (column.attr('ishidden') != "true") code["body"] += '|rr|' + '|tab||tab||tab||tab|</div>|rr|' + '|tab||tab||tab|</div>|rr|'; } }); // end floating and close the global container code["body"] += '|tab||tab||tab|<div class="clr"></div>|rr|' + '|tab||tab|</div>|rr|' + '|tab|</div>|rr|'; code["head"] += '<?php|rr|' + '$mainclass = "";|rr|'; if (column1enabled == 1) { code["head"] += 'if (!$this->countModules(\'' + column1.join('\') && !$this->countModules(\'') + '\')) { $mainclass .= " noleft";}|rr|'; } else { code["head"] += '$mainclass .= " noleft";|rr|'; } if (column2enabled == 1) { code["head"] += 'if (!$this->countModules(\'' + column2.join('\') && !$this->countModules(\'') + '\')) { $mainclass .= " noright";}|rr|'; } else { code["head"] += '$mainclass .= " noright";|rr|'; } code["head"] += '$mainclass = trim($mainclass); ?>|rr||rr|'; window['COLUMN1WIDTH'] = column1width; window['COLUMN2WIDTH'] = column2width; return code; } function testUnit(value, defaultunit) { if (!defaultunit) defaultunit = "px"; if (value.toLowerCase().indexOf('px') > -1 || value.toLowerCase().indexOf('em') > -1 || value.toLowerCase().indexOf('%') > -1) return value; return value + defaultunit; } function selectFaIcon(iconclass) { setFaIconPosition(iconclass); setFaIconSize(); // $ck('#previewareabloc .iconck span.fack').css('vertical-align', $ck('#iconicon-position button.active').attr('data-position')) // .addClass($ck('#iconicon-size button.active').attr('data-width')); // ck_set_icon_margin('#previewareabloc .iconck i.fa', '#iconicon_margin'); } function setFaIconPosition(iconclass) { if (! $ck('#previewareabloc').find('span.fack').length && ! iconclass) return; if (! iconclass) iconclass = $ck('#previewareabloc').find('span.fack .fa').attr('class').replace('fack', ''); $ck('#previewareabloc').find('span.fack').remove(); switch ($ck('input[name="iconiconposition"]:checked').val()) { default: case 'left': $ck('#previewareabloc h3').prepend('<span class="fack" data-pos="left" data-type="' + iconclass + '" style="display:inline-block;"><span class="' + iconclass + '"></span></span>'); break; case 'top': $ck('#previewareabloc h3').prepend('<span class="fack" data-pos="top" data-type="' + iconclass + '" style="display:block;"><span class="' + iconclass + '"></span></span>'); break; case 'right': $ck('#previewareabloc h3').append('<span class="fack" data-pos="right" data-type="' + iconclass + '" style="display:inline-block;"><span class="' + iconclass + '"></span></span>'); break; case 'bottom': $ck('#previewareabloc h3').append('<span class="fack" data-pos="bottom" data-type="' + iconclass + '" style="display:block;"><span class="' + iconclass + '"></span></span>'); break; } } function setFaIconSize() { if (! $ck('#previewareabloc').find('span.fack').length) return; var icon = $ck('#previewareabloc').find('span.fack .fa'); icon.removeClass('fa-lg') .removeClass('fa-2x') .removeClass('fa-3x') .removeClass('fa-4x') .removeClass('fa-5x'); var iconsize = $ck('input[name="iconiconsize"]:checked').val(); if (iconsize != 'default') { icon.addClass(iconsize); $ck('#previewareabloc').find('span.fack').attr('data-size', iconsize); } } function setFaIconVPosition() { if (! $ck('#previewareabloc').find('span.fack').length) return; var icon = $ck('#previewareabloc').find('span.fack .fa'); var iconVPos = $ck('input[name="iconiconvposition"]:checked').val(); icon.css('vertical-align', ''); if (iconVPos != 'default') { icon.css('vertical-align', iconVPos); $ck('#previewareabloc').find('span.fack').attr('data-vpos', iconVPos); } } function previewVideoBackground() { var webmurl = $ck('#blocvideourlwebm').val().replace(URIROOT,''); var mp4url = $ck('#blocvideourlmp4').val().replace(URIROOT,''); var ogvurl = $ck('#blocvideourlogv').val().replace(URIROOT,''); var videocode = '<video autoplay loop muted poster="" class="videobackground">' +'<source src="'+URIROOT+'/'+webmurl+'" type="video/webm">' +'<source src="'+URIROOT+'/'+mp4url+'" type="video/mp4">' +'<source src="'+URIROOT+'/'+ogvurl+'" type="video/ogg">' +'</video>'; var previewarea = $ck('#previewareabloc'); if (previewarea.find('video').length) previewarea.find('video').remove(); previewarea.css('position', 'relative').css('overflow','hidden').prepend(videocode); } function iObject() { this.i; return this; } var myObject=new iObject(); myObject.i=0; var myObject2=new iObject(); myObject2.i=0; store_text=new Array(); //store_text[0] store initial textarea value store_text[0]=""; function countdoaction() { myObject.i++; var y=myObject.i; var x=document.getElementById('conteneur').innerHTML; store_text[y]=x; } function undo() { if ((myObject2.i)<(myObject.i)) { myObject2.i++; } else { alert(Joomla.JText._('CK_NO_MORE_UNDO', 'There is no more Undo action')); } var z=store_text.length; z=z-myObject2.i-1; if (store_text[z]) { document.getElementById('conteneur').innerHTML=store_text[z]; } else { document.getElementById('conteneur').innerHTML=store_text[0]; } initInterface(); } function redo() { if((myObject2.i)>=1) { myObject2.i--; } else { alert(Joomla.JText._('CK_NO_MORE_REDO', 'There is no more Redo action')); } var z=store_text.length; z=z-myObject2.i-1; if (store_text[z]) { document.getElementById('conteneur').innerHTML=store_text[z]; } else { document.getElementById('conteneur').innerHTML=store_text[0]; } initInterface(); } function toggleSubmenuck(el) { el = $ck(el); if ($ck('#ck_modelewrapper').length) return; var submenu = el.next('.submenuck'); $ck('.submenuck').not(submenu).hide('fast').removeClass('opened'); if (! submenu.hasClass('opened')) { submenu.addClass('opened').show('fast', function() {hideSubmenuckOutsideClick(submenu)} ); } else { submenu.hide('fast').removeClass('opened'); } if (! submenu.hasClass('eventadded')) { submenu.addClass('eventadded').find('> a').on('click', function() { submenu.hide().removeClass('opened'); }); } } function hideSubmenuckOutsideClick(submenu) { $ck(window).one("click", function(event){ if ( submenu.hasClass('opened') && submenu.has(event.target).length == 0 //checks if descendants of submenu was clicked && !submenu.is(event.target) //checks if the submenu itself was clicked ){ // is outside submenu.hide('fast').removeClass('opened'); } else { // is inside, do nothing } }); } /*=================================*/ /* Favorite management /*=================================*/ function ckRemoveFavorite(btn) { if (!confirm(Joomla.JText._('CK_CONFIRM_DELETE','Are you sure that you want to delete ?'))) return; var favorite = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('> .ckmyfavorite'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxRemoveFavorite"; var name = favorite.attr('data-name'); $ck.ajax({ type: "POST", url: myurl, data: { name: name, } }).done(function(code) { try { response = JSON.parse(code); if (response.status == '1') { $ck('#ckmyfavorite' + name).parent().remove(); alert(Joomla.JText._('CK_SUCCESS', 'Success !')); } else { alert(Joomla.JText._('CK_FAILED', 'Failed')); } } catch(err) { alert( 'ERROR : ' + err.message ); } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function ckEditFavorite(btn) { var bloc = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('> .ckmyfavorite'); showEditionPopup(bloc.attr('id'), 'ckSaveFavoritePopup'); } function ckSaveFavoritePopup(blocid, workspace) { saveEditionPopup(blocid, workspace, 'ckAfterSaveFavoritePopup'); } function ckAfterSaveFavoritePopup() { var favorite = $ck('.cssfocus'); var stylecode = favorite.find('> .ckstyle').html(); var id = new RegExp(favorite.attr('id'), "g"); stylecode = stylecode.replace(id, "|ID|"); var uri = new RegExp(URIBASE + "/", "g"); stylecode = stylecode.replace(uri, "|URIBASE|"); stylecode = stylecode.replace(/#/g, "|di|"); favorite.find('.favoritethumbstyles').html(stylecode); savefavorite(favorite.attr('data-name').replace('favorite', '')); // show the favorite panel again for interaction with the user showFavoritePopup(); } function showRestorePopup() { CKBox.open({handler: 'inline', content: 'restoreModalck', style: {padding: '10px'}, size: {x: '600px', y: '400px'}}); } function showReplaceColorsPopup() { CKBox.open({handler: 'inline', content: 'replaceColorsModalck', style: {padding: '10px'}, size: {x: '600px', y: '350px'}}); } function replaceColors() { countdoaction(); for (var i=0; i<5; i++) { var oldColor = $ck('#replacecolorold' + i).val(); var newColor = $ck('#replacecolornew' + i).val(); if (! oldColor || ! newColor) continue; var regEx = new RegExp(oldColor, "ig"); $ck('#body .ckstyle').each(function() { var $st = $ck(this); $st.html($st.html().replace(regEx, newColor)); }); $ck('#body .ckprops').each(function() { this.outerHTML = this.outerHTML.replace(regEx, newColor); }); } countdoaction(); CKBox.close(); } /* load the .pbck backup file and load it in the page */ function ckDoRestoration(id, name, index) { jQuery('.restoreline' + index + ' .processing').addClass('ckwait'); var isLocked = parseInt(jQuery('.restoreline' + index + ' .locked').attr('data-locked')); var myurl = URIBASE + "/index.php?option=com_templateck&task=ajaxDoRestoration"; $ck.ajax({ type: "POST", url: myurl, data: { id: id, name: name, isLocked: isLocked } }).done(function(code) { countdoaction(); $ck('#conteneur').html(code); CKBox.close(); jQuery('.restoreline' + index + ' .processing').removeClass('ckwait'); initInterface(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } function showWidgetsPopup() { $ck(document.body).append('<div id="ckwaitoverlay"></div>'); // bloc = $ck('#' + blocid); $ck('.cssfocus').removeClass('cssfocus'); // bloc.addClass('cssfocus'); $ck('#popup_editionck').empty().fadeIn(); $ck('html, body').animate({scrollTop: 0}, 'slow'); var myurl = URIBASE + "/index.php?option=com_templateck&view=template&layout=ajaxwidgetsmanager&raw=1"; $ck.ajax({ type: "POST", url: myurl, data: { } }).done(function(code) { $ck('#popup_editionck').append(code); $ck('#ckwaitoverlay').remove(); ckCheckEnabledWidgets(); ckCheckWidgetsVersions(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); $ck('#ckwaitoverlay').remove(); }); } function ckCheckEnabledWidgets() { $ck('#popup_editionck .widgetrow').each(function() { $ck(this).attr('data-enabled', $ck('#widgetsElements .widget[data-name="' + $ck(this).attr('data-name') + '"]').attr('data-enabled')); }); } function ckGetWidgetData(btn) { var widgetData = $ck($ck(btn).parents('.widgetrow')[0]); return widgetData; } function ckInstallWidget(btn, isupdate) { if (!isupdate) isupdate = false; $ck(btn).find('> .fa').attr('class', 'ckwait'); var widgetData = ckGetWidgetData(btn); var myurl = URIBASE + "/index.php?option=com_templateck&task=ajaxInstallWidget"; $ck.ajax({ type: "POST", url: myurl, data: { url: widgetData.attr('data-url'), name: widgetData.attr('data-name') // type: widgetData.attr('data-type') } }).done(function(code) { if (code == '1') { $ck('#widgetsElements').append('<script src="' + URIROOT + '/administrator/components/com_templateck/widgets/' + widgetData.attr('data-name') + '/interface.js" type="text/javascript"></script>'); widgetData.attr('data-installed', '1'); widgetData.attr('data-update', '0'); $ck(btn).parent().find('.widgetupdate').find('> .ckwait').attr('class', 'fa fa-refresh'); if (!isupdate) ckEnableWidget(btn); if (! $ck('#widgetsElements .widget[data-name="' + widgetData.attr('data-name') + '"]').length) { $ck('#widgetsElements').append('<div class="widget" data-name="' + widgetData.attr('data-name') + '" data-enabled="0"></div>'); } } else { alert(Joomla.JText._('CK_WIDGET_INSTALL_FAILED', 'Widget installation failed')); } // $ck('#popup_editionck').append(code); // $ck('#ckwaitoverlay').remove(); }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); // $ck('#ckwaitoverlay').remove(); }); } function ckEnableWidget(btn) { var widgetData = ckGetWidgetData(btn); var funcName = 'TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Enable'; if (typeof(window[funcName]) == 'function') { window[funcName](); $ck('#widgetsElements .widget[data-name="' + widgetData.attr('data-name') + '"]').attr('data-enabled', '1'); } else { alert('Error : Function TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Enable is not found. Is the widget installed ?') } } function ckDisableWidget(btn) { var widgetData = ckGetWidgetData(btn); var funcName = 'TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Disable'; if (typeof(window[funcName]) == 'function') { window[funcName](); // $ck('#widgetsElements .widget[data-name="' + widgetData.attr('data-name') + '"]').attr('data-enabled', '0'); } else { alert('Error : Function TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Enable is not found. Is the widget installed ?') } } function ckEditWidget(btn) { $ck('#widgetsmanager').hide(); $ck('#widgetedition').fadeIn(); var widgetData = ckGetWidgetData(btn); var funcName = 'TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Edit'; if (typeof(window[funcName]) == 'function') { window[funcName](btn); } else { alert('Error : Function TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Enable is not found. Is the widget installed ?') } } function ckCapitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } function ckAfterWidgetEditionDisplay() { $ck('#widgetedition').prepend('<div id="widgeteditionbackbutton" onclick="ckCloseWidgetEdition()" class="ckbutton"><span class="fa fa-arrow-left"></span> ' + Joomla.JText._('CK_BACK_TO_WIDGETS_LIST', 'Back to Widgets List') + '</div><p></p>'); // $ck('#widgetedition').prepend('<div id="widgeteditiontitle">' + Joomla.JText._('CK_BACK_TO_WIDGETS_LIST', 'Back to Widgets List') + '</div><p></p>'); } function ckCloseWidgetEdition() { $ck('#widgetsmanager').fadeIn(); $ck('#widgetedition').hide().empty(); } function ckCheckWidgetsVersions() { var myurl = URIBASE + "/index.php?option=com_templateck&task=ajaxCheckWidgetUpdate"; $ck.ajax({ type: "POST", url: myurl, dataType: 'json', data: { } }).done(function(response) { for(var name in response) { $ck('.widgetrow[data-name="' + name + '"]').attr('data-update', response[name]); } }).fail(function() { alert(Joomla.JText._('CK_FAILED_CHECK_VERSION', 'Failed to check the widgets versions')); }); } function ckGetWidgetsData() { var widgets = Object(); $ck('#widgetsElements .widget').each(function(i) { var widget = new Object(); widget['name'] = $ck(this).attr('data-name'); widget['enabled'] = $ck(this).attr('data-enabled'); widget['data'] = $ck(this).find('.widgetdata').html(); widgets[$ck(this).attr('data-name')] = widget; }); // jsonWidgets = JSON.stringify(widgets); // $ck('#widgets').attr('value', jsonWidgets.replace(/"/g, "|qq|")); return widgets; } function ckInstallWidgetManually() { var files = document.getElementById('tck_file_upload').files; var formData = !!window.FormData ? new FormData() : null; for (var i = 0; i < files.length; i++) { if (!files[i].name.match(/.zip$/)) { alert('The file must be a ZIP : ' + files[i].name) ; continue ; } if (!!window.FormData) formData.append('file', files[i]); var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxAddWidgetManually&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, // async: false, data: formData, // data: { // file: files[i] // } dataType: 'json', processData: false, // indique ? jQuery de ne pas traiter les donnĂ©es contentType: false, // indique ? jQuery de ne pas configurer le contentType }).done(function(response) { if (response && response.success == '1') { alert(Joomla.JText._('CK_WIDGET_INSTALL_SUCCESS', 'Widget installed correctly')); $ck('#widgetsElements').append('<script src="' + URIROOT + '/administrator/components/com_templateck/widgets/' + response.name + '/interface.js" type="text/javascript"></script>'); var btn = $ck('.widgetrow[data-name="' + response.name + '"] .ckbutton'); var widgetData = ckGetWidgetData(btn); widgetData.attr('data-installed', '1'); widgetData.attr('data-update', '0'); $ck(btn).parent().find('.widgetupdate').find('> .ckwait').attr('class', 'fa fa-refresh'); // if (!isupdate) ckEnableWidget(btn); if (! $ck('#widgetsElements .widget[data-name="' + response.name + '"]').length) { $ck('#widgetsElements').append('<div class="widget" data-name="' + response.name + '" data-enabled="0"></div>'); } } else { alert(Joomla.JText._('CK_WIDGET_INSTALL_FAILED', 'Widget installation failed')); } }).fail(function() { // alert(Joomla.JText._('CK_FAILED', 'Failed')); }); } } /*=================================*/ /* Modules management /*=================================*/ function ckInstallModule(name) { $ck('.blocselect.'+name).find('.fa').attr('class', 'fa fa-spinner fa-spin'); var myurl = URIBASE + '/index.php?option=com_templateck&task=ajaxInstallModule&' + cktoken + '=1'; $ck.ajax({ type: "POST", url: myurl, data: { // url: url, name: name } }).done(function(code) { if (code == '1') { alert(Joomla.JText._('CK_MODULE_INSTALL_SUCCESS', 'Widget installation successful !')); $ck('.blocselect.'+name).removeClass('notinstalled').addClass('dragtoadd').find('.installbutton').remove(); addDraggableToBlocks(); } else { alert(Joomla.JText._('CK_MODULE_INSTALL_FAILED', 'Widget installation failed')); } }).fail(function() { alert(Joomla.JText._('CK_FAILED', 'Failed')); // $ck('#ckwaitoverlay').remove(); }); }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.06 |
proxy
|
phpinfo
|
Settings