| Current Path : /home/giteleslfp/www/administrator/components/com_templateck/assets/ |
| Current File : /home/giteleslfp/www/administrator/components/com_templateck/assets/templateck_template.js |
/**
* @name Template Creator CK
* @copyright Copyright (C) since 2011. 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;
var editor_customcss_responsive = new Array();
// Only define the TCK namespace if not defined.
TCK = window.TCK || {};
TCK.Text = {
strings: {},
'_': function(key, def) {
return typeof this.strings[key.toUpperCase()] !== 'undefined' ? this.strings[key.toUpperCase()] : def;
},
load: function(object) {
for (var key in object) {
this.strings[key.toUpperCase()] = object[key];
}
return this;
}
};
function ckInitInterface() {
ckConvertOldMaincontent();
$ck('.ckbloc, .ckrowcontainer', $ck('#body')).each(function(i, bloc) {
ckAddControlsOnHover(bloc);
});
$ck('.alert-message > a.close').click(function() {
$ck(this).parent().remove();
});
ckFixBC();
ckCheckExpertModeOnPageload();
ckToggleBootstrap(); // Bootstrap fait chier
ckInitSortables();
ckAddFixedTopbar();
ckConvertOldBanner();
ckFixSources();
ckFixRowContainerBC();
ckInitTooltip();
ckInitOptionsSliders();
ckSeparateStylesForBlocks(); // for B/C, convert the existing blocks
ckaddEventOnInfos();
ckInitOptionsSliders($ck('#cklibraryelements'));
ckInitGoogleFonts();
}
function ckFixBC() {
$ck('#body').addClass('body');
$ck('.moduletable').addClass('tck-module');
$ck('.widget').addClass('tck-module');
// if ($ck('.container').length || $ck('.container-fluid').length) ckRenderCss('body');
$ck('.container').addClass('tck-container');
// .removeClass('container');
$ck('.container-fluid').addClass('tck-container-fluid');
// since 4.0.19
// $ck('.tck-container-fluid').addClass('tck-container').removeClass('tck-container-fluid');
var patt = new RegExp("\<h3\>Module\<\/h3\>");
if (
$ck('.mainbanner').length
||
patt.test($ck('#body').html())
) {
alert('Warning : An old version has been detected. Your template will be automatically converted.');
// return;
$ck('#body h3').text('Title');
$ck('.ckstyle > style').each(function() {
$ck(this).html($ck(this).html().replace('url(/images', 'url(' + URIROOT + '/images'));
});
// replace the maincontent
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxbcmaincontent&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl
}).done(function(code) {
$ck('#body .maincontent').after(code).remove();
$ck('#body .maincontent, #body .maincontent .ckbloc, #body .maincontent .ckrowcontainer').each(function(i, bloc) {
ckAddControlsOnHover(bloc);
});
}).fail(function(code) {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
// replace the banner
var oldbanner = $ck('#body .mainbanner');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxbcbanner&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
blockid : oldbanner.attr('id') + 'new'
}
}).done(function(code) {
// oldbanner.after(code);
// oldbanner.find('> .inner > div:not(.clr)').each(function(i) {
// $ck(this).css('width', '');
// $ck('#' + oldbanner.attr('id') + 'new').find('.ckrowcontainer').eq(i).append($ck(this));
// });
// oldbanner.remove();
// $ck('#body .maincontent, #body .maincontent .ckbloc, #body .maincontent .ckrowcontainer').each(function(i, bloc) {
// ckAddControlsOnHover(bloc);
// });
}).fail(function(code) {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
}
function ckInitGoogleFonts() {
var bodyfontsprops = ckGetPropsForBloc('body', 'googlefonts');
var fontslist = bodyfontsprops.attr('fontslist') ? bodyfontsprops.attr('fontslist') : '';
fontslist = fontslist ? fontslist.split(',') : new Array();
for (var i=0; i < fontslist.length; i++) {
ckAddGooglefontStylesheet(fontslist[i]);
}
}
function ckaddEventOnInfos() {
$ck('#ckinfospopup input, #ckinfospopup textarea').change(function() {
this.value = this.value.replace('&', '');
});
}
/* 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 ckConvertOldBanner() {
$ck('.ckrowcontainer > .bannerlogo').css('width','auto').find('.tab_blocstyles').attr('blocwidth', '');
}
/* Method introduced after the 3.4 version to update the old maincontent */
function ckConvertOldMaincontent() {
$ck('.column1,.column2').each(function() {
if( ! $ck(this).find('.ckrowcontainer').length) {
$ck(this).append('<div class="ckrowcontainer"></div>');
}
});
}
function ckSeparateStylesForBlocks() {
$ck('#cktemplatecontainer .ckbloc').each(function() {
var block = $ck(this);
if (block.find('> .ckstyle').length || block.find('> .ckprops').length) {
ckSeparateStylesForBlock(this.id);
}
});
}
/* separate the styles elements in the page
* NOTE : must use block and not blockid to get the reference of the element when using ckAddBlock
* isinstance : true to set if we pass a jQuery instance of the object or only the ID
* */
function ckSeparateStylesForBlock(blocid, isinstance) {
if (! isinstance) isinstance = false;
var block = isinstance ? blocid : $ck('#' +blocid);
blocid = !isinstance ? blocid : block.attr('id');
// if no styles to separate, exit
if (! block.find('> .ckstyle').length && ! block.find('> .ckprops').length) return;
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
// add ckstyle
if (block.find('> .ckstyle').length) {
var blockckstyle = block.find('> .ckstyle');
ckSetStyleForBloc(blocid, blockckstyle.html());
blockckstyle.remove();
}
// add properties
if (block.find('> .ckprops').length) {
var blockckprops = block.find('> .ckprops');
styleswrapper.find('> .ckprops').remove();
blockckprops.each(function() {
styleswrapper.append($ck(this));
// $ck(this).remove();
});
}
}
/* return the wrapper for ckstyle and ckprops for the bloc ID */
function ckGetStylesWrapperForBlock(blocid) {
if (! $ck('.ckstylecontainer[data-id="' + blocid + '"]', $ck('#ckstylescontainer')).length) $ck('#ckstylescontainer').append('<div class="ckstylecontainer" data-id="' + blocid + '"></div>');
return $ck('.ckstylecontainer[data-id="' + blocid + '"]', $ck('#ckstylescontainer'));
}
/* create the div that wraps the ckstyle and ckprops for the bloc ID */
//function ckCreateStylesWrapperForBlock(block) {
// var blocid = block.attr('id');
// var ckstylescontainer = $ck('#ckstylescontainer');
// var blockstylecontainer = $ck('<div class="ckstylecontainer" data-id="' + blocid + '"></div>');
// ckstylescontainer.append(blockstylecontainer);
//}
/* create new styles elements for the new block */
function ckDuplicateStylesForBlock(blocid, newid) {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
var copy = styleswrapper.clone();
copy.attr('data-id', newid);
$ck('#ckstylescontainer').append(copy);
var newstyleswrapper = ckGetStylesWrapperForBlock(newid);
ckReplaceStyleId(newstyleswrapper, blocid, newid);
}
function ckReplaceStyleId(wrapper, oldID, newID) {
var re = new RegExp(oldID, 'g');
var stylecontainer = ckGetStyleForBloc(newID);
stylecontainer.html(stylecontainer.html().replace(re,newID));
wrapper.attr('data-id', newID);
}
/* remove the wrapper and all inside */
function ckRemoveStylesForBlock(blocid) {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.remove();
}
/* return the ckstyle element for the bloc ID */
function ckGetStyleForBloc(blocid) {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
if (! styleswrapper.find('> .ckstyle').length) styleswrapper.append('<div class="ckstyle"></div>');
return styleswrapper.find('> .ckstyle');
}
/* set the css code in the ckstyle element for the bloc ID */
function ckSetStyleForBloc(blocid, csscode, merge) {
if (!merge) merge = false;
var stylecontainer = ckGetStyleForBloc(blocid);
if (merge == true) {
stylecontainer.append(csscode);
} else {
stylecontainer.empty().append(csscode);
}
}
/* return the ckprops element for the bloc ID */
function ckGetPropsForBloc(blocid, tabid) {
var styleswrapper = ckGetStylesWrapperForBlock(blocid)
if (! styleswrapper.find('> .ckprops.' + tabid).length) styleswrapper.append('<div class="' + tabid + ' ckprops" />');
return styleswrapper.find('> .ckprops.' + tabid);
}
/* fill the ckprops element with the options values, remove the unused */
function ckSaveEditionFields(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'));
}
}
});
ckSaveAction();
}
/* create the list of fields that are used in the edition to store on the ckprops element */
function ckGetEditionFieldslist(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(',');
}
/* set the css properties on the ckprops element for the bloc ID */
//function ckSetPropsForBloc(blocid, csscode) {
// var stylecontainer = ckGetStyleForBloc(blocid, csscode);
// stylecontainer.empty().append(csscode);
//}
/*function ckSeparateStyles(block) {
block = block ? block : $ck('#cktemplatecontainer');
var blocid = block.attr('id');
if (! $ck('#ckstylescontainer').length) {
$ck('#cktemplatecontainer').prepend('<div id="ckstylescontainer"></div>');
}
var ckstylescontainer = $ck('#ckstylescontainer');
var ckstylecontainer = $ck('<div class="ckstylecontainer" data-id="' + blocid + '"></div>');
ckstylescontainer.append($ck(this));
// create css rules
block.find(' .ckstyle').each(function() {
var blocid = $ck(this).parent().attr('id');
if ($ck('#ckstylescontainer').find('.ckstyle[data-id="' + blocid + '"]').length) $ck('#ckstylescontainer').find('.ckstyle[data-id="' + blocid + '"]').remove();
$ck(this).attr('data-id', blocid);
ckstylecontainer.append($ck(this));
});
// create properties
block.find(' .ckprops').each(function() {
var blocid = $ck(this).parent().attr('id');
var blocclass = $ck(this).attr('class').replace('ckprops').trim();
if ($ck('#ckstylescontainer').find('[data-id="' + blocid + '"].' + blocclass).length) $ck('#ckstylescontainer').find('.ckprops[data-id="' + blocid + '"]' + blocclass).remove();
$ck(this).attr('data-id', blocid);
ckstylecontainer.append($ck(this));
});
}*/
function ckAddFixedTopbar(){
$ck(window).bind('scroll resize load', function() {
if ($ck(window).scrollTop() > $ck('#ckleftpanel').offset().top) {
$ck('#ckleftpanel')
.addClass('floating')
.css({'position' : 'fixed', 'top': '0', 'height': ''})
.before('<div id="ckleftpanel_tmp" style="height:0px;"></div>');
} else if ($ck('#ckleftpanel_tmp').length && $ck(window).scrollTop() < $ck('#ckleftpanel_tmp').offset().top){
$ck('#ckleftpanel_tmp').remove();
$ck('#ckleftpanel')
.removeClass('floating')
.css({'position' : 'absolute', 'top': '', height: ($ck(window).height() - $ck('#ckleftpanel').offset().top + $ck(window).scrollTop()) + 'px'});
} else if(! $ck('#ckleftpanel').hasClass('floating')) {
$ck('#ckleftpanel')
.css({'top': '', height: ($ck(window).height() - $ck('#ckleftpanel').offset().top + $ck(window).scrollTop()) + 'px'});
}
});
}
/* Functions to manage colors conversion */
function ckHexToR(h) {
return parseInt((ckCutHex(h)).substring(0, 2), 16)
}
function ckHexToG(h) {
return parseInt((ckCutHex(h)).substring(2, 4), 16)
}
function ckHexToB(h) {
return parseInt((ckCutHex(h)).substring(4, 6), 16)
}
function ckCutHex(h) {
return (h.charAt(0) == "#") ? h.substring(1, 7) : h
}
function ckHexToRGB(h) {
return 'rgb(' + ckHexToR(h) + ',' + ckHexToG(h) + ',' + ckHexToB(h) + ')';
}
/* Repeat the strings n times */
function ckStrRepeat(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(',');
ckSetPaletteOnColorPicker(colors, 'colpick_palette');
}
function ckSetPaletteOnColorPicker(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 ckOnSortStart(ui) {
ui.helper.find('.editorck').hide();
ui.helper.addClass('cksorting');
// reduce the big elements for better visibility
if (ui.item.hasClass('maincontent') || ui.item.hasClass('wrapper')) {
ui.placeholder.addClass('cksorting');
}
if (ui.item.hasClass('wrapper') || ui.item.hasClass('cklibraryitemwrapper')) {
$ck('.wrapper:not(.blocselect)').addClass('cksorting');
}
}
function ckOnSortStop(ui) {
ui.item.removeClass('cksorting');
$ck('.cksorting').removeClass('cksorting');
ckSaveAction();
}
function ckInitSortables() {
$ck("#body").sortable({
items: ".wrapper",
axis: "y",
handle: "> .editorck .controlMove",
forcePlaceholderSize: true,
forceHelperSize: true,
dropOnEmpty: true,
// tolerance: "pointer",
placeholder: "ckplaceholder",
zIndex: 999999,
sort: function( event, ui ) {
$ck("#body").sortable('refreshPositions');
// ckOnSortStart(ui);
},
receive: function( event, ui ) {
var newblock = $ck(this).find('.blocselect');
if (ui.sender.hasClass('dragtoaddwrapper')) {
newblock.css('float', 'none').addClass('ckwait');
ckCreateWrapperBloc(newblock);
} else if (ui.sender.hasClass('ckdragtoaddelement')) {
var newblock = $ck(this).find('.ckdragtoaddelement');
newblock.css('float', 'none').addClass('ckwait');
ckLoadLibraryElement(newblock);
} else {
newblock.remove();
}
},
stop: function( event, ui ) {
// ckOnSortStop(ui);
},
out: function( event, ui ) {
// ckOnSortStop(ui);
}
});
$ck( ".wrapper > .inner" ).sortable({
items: "> .ckbloc",
// containment: "parent",
// axis: "y",
connectWith: ".wrapper > .inner",
// connectWith: ".wrapper > .inner, .ckrowcontainer",
tolerance: "pointer",
handle: "> .editorck .controlMove",
forceHelperSize: true,
dropOnEmpty: true,
forcePlaceholderSize: true,
placeholder: "ckplaceholder",
zIndex: 9999,
sort: function( event, ui ) {
// ckOnSortStart(ui);
},
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'));
ckMakeRowcontainerSortable($ck('.ckrowcontainer'));
} else if (ui.sender.hasClass('ckdragtoaddelement')) {
var newblock = $ck(this).find('.ckdragtoaddelement');
newblock.css('float', 'none').addClass('ckwait');
ckLoadLibraryElement(newblock);
} else {
newblock.remove();
}
ui.placeholder.parent().trigger('mouseleave');
},
stop: function( event, ui ){
// ckOnSortStop(ui);
ui.placeholder.parent().trigger('mouseleave');
if (! $ck(ui.item).hasClass('blocselect')) {
ckSaveAction(); // only save action if not from left menu
}
},
out: function( event, ui ) {
// ckOnSortStop(ui);
}
});
$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 ) {
ckOnSortStart(ui);
},
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 ) {
ckOnSortStop(ui);
ui.item.css('display', '');
ui.placeholder.parent().trigger('mouseleave');
ckSaveAction();
},
out: function( event, ui ) {
ckOnSortStop(ui);
}
});
$ck( ".ckrowcontainer" ).each(function(i, item){
ckMakeRowcontainerSortable(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" />');
}
},
stop: function( event, ui ) {
ckOnSortStop(ui);
ckSaveAction();
},
out: function( event, ui ) {
ckOnSortStop(ui);
}
});
$ck( ".wrapper .main" ).sortable({
items: ".column2, .center",
// containment: "parent",
connectWith: ".main",
helper: "clone",
handle: "> .editorck .controlMove",
forcePlaceholderSize: true,
placeholder: "placeholderchild",
sort: function( event, ui ) {
ckOnSortStart(ui);
},
start: function( event, ui ){
ui.placeholder.width($ck('> .inner',ui.helper).width());
ui.placeholder.append('<div class="inner" />')
},
change: function( event, ui ) {
// moveBloc(ui);
},
stop: function( event, ui ) {
ckOnSortStop(ui);
ckSaveAction();
},
out: function( event, ui ) {
ckOnSortStop(ui);
}
});
ckAddDraggableToBlocks();
$ck( ".dragtoadd.row, .dragtoadd.banner" ).draggable({
connectToSortable: ".wrapper > .inner",
helper: "clone",
tolerance: "pointer",
appendTo: "body",
scroll: false,
start: function( event, ui ) {
// $ck('#ckleftpanel').css('overflow', 'visible');
},
stop: function( event, ui ) {
// $ck('#ckleftpanel').css('overflow', '');
}
});
$ck( ".dragtoaddwrapper" ).draggable({
connectToSortable: "#body",
helper: "clone",
appendTo: "body",
scroll: false,
// revert: "invalid"
start: function( event, ui ) {
// $ck('#ckleftpanel').css('overflow', 'visible');
},
stop: function( event, ui ) {
// $ck('#ckleftpanel').css('overflow', '');
}
});
}
function ckAddDraggableToBlocks() {
$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('#ckleftpanel').css('overflow', 'visible');
$ck('.ckrowcontainer').each(function(i, item){
item = $ck(item);
if (! item.find('*').length) {
item.addClass('empty');
}
});
},
stop: function( event, ui ){
// $ck('#ckleftpanel').css('overflow', '');
$ck('.ckrowcontainer.empty').removeClass('empty');
}
});
}
function ckAddDraggableToLibraryElements() {
$ck('.ckdragtoaddelement.cklibraryitemwrapper').draggable({
connectToSortable: '#body',
helper: 'clone',
appendTo: 'body',
scroll: false,
start: function( event, ui ) {
ui.helper.addClass('ckdraggingelement');
},
stop: function( event, ui ) {
}
});
$ck('.ckdragtoaddelement:not(.cklibraryitemwrapper)').draggable({
connectToSortable: '.wrapper > .inner',
helper: 'clone',
appendTo: 'body',
scroll: false,
start: function( event, ui ) {
ui.helper.addClass('ckdraggingelement');
},
stop: function( event, ui ) {
}
});
}
function ckMakeRowcontainerSortable(item) {
$ck(item).sortable({
items: ".ckbloc",
// cancel: '.ckrow',
// containment: "parent",
helper: "clone",
handle: "> .editorck .controlMove",
forcePlaceholderSize: true,
connectWith: ".ckrowcontainer, .wrapper > .inner",
// tolerance: "pointer",
placeholder: "ckplaceholder",
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');
ckSaveAction();
},
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 if (ui.sender.hasClass('ckdragtoaddelement')) {
var newblock = $ck(this).find('.ckdragtoaddelement');
newblock.css('float', 'none').addClass('ckwait');
ckLoadLibraryElement(newblock);
} 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');
// CKBox.close();
}
function ckInitTooltip(el, attrib) {
attrib = attrib || 'title';
el = el || document;
$ck( el ).tooltip({
items: ".ckhastip",
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 ckInitModalPopup() {
CKBox.initialize({});
CKBox.assign($ck('a.modal'), {
parse: 'rel'
});
}
function initModalPopup() {
// for B/C in widgets
ckInitModalPopup();
}
function ckInitOptionsAccordions(wrap) {
wrap = wrap ? wrap : $ck('#ckedition');
$ck('.ckinterfaceblockaccordion', wrap).hide();
$ck('.ckproperty', wrap).each(function(i, tab) {
tab = $ck(tab);
$ck('.ckinterfaceblocktitle:not(.ckinitiated)', tab).each(function() {
$ck(this).addClass('ckinitiated');
$ck(this).click(function() {
if (!$ck(this).hasClass('ckopen')) {
blocstyle = $ck(this).next('.ckinterfaceblockaccordion');
$ck(this).addClass('ckopen');
blocstyle.slideDown('fast');
} else {
$ck(this).next('.ckinterfaceblockaccordion').slideUp('fast');
$ck(this).removeClass('ckopen');
}
});
});
});
}
function ckInitOptionsTabs(wrap) {
wrap = wrap ? wrap : $ck('#ckelementscontainer');
$ck('.ckinterfacetab:not(.ckcurrent)', wrap).hide();
$ck('.ckinterfacetablink', wrap).each(function(i, tab) {
tab = $ck(tab);
tab.click(function() {
if (!$ck(this).hasClass('ckopen') && !$ck(this).hasClass('ckcurrent')) {
$ck(this).addClass('ckopen');
$ck('#ckleftpanel .ckinterfacetab.ckinterfacetab_fullscreen').fadeOut('fast');
$ck('#' + tab.attr('tab')).slideDown('fast');
} else {
$ck('#' + tab.attr('tab')).slideUp('fast');
$ck(this).removeClass('ckopen');
}
$ck(this).removeClass('ckcurrent');
$ck('#' + tab.attr('tab')).removeClass('ckcurrent');
});
});
}
function ckInitOptionsSliders(wrap) {
wrap = wrap ? wrap : $ck('#ckelementscontainer');
$ck('.ckinterfaceslider', wrap).hide();
$ck('.ckinterfacesliderlink', wrap).each(function(i, tab) {
tab = $ck(tab);
tab.click(function() {
$ck('#' + tab.attr('tab')).show();
wrap.stop().animate({'margin-left': '-300px'});
});
$ck('.ckinterfacesliderback').click(function() {
wrap.stop().animate({'margin-left': '0'});
$ck('.ckinterfaceslider', wrap).hide();
$ck('.ckinterfacesliderlink', wrap);
});
});
}
function ckInitColorPickers() {
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: TCK.Text._('CK_OK', 'OK'),
cleanerText: TCK.Text._('CK_CLEAR', 'Clear'),
copyText: TCK.Text._('CK_COPY', 'Copy'),
pasteText: TCK.Text._('CK_PASTE', 'Paste'),
selectPalette: TCK.Text._('CK_SELECT_PALETTE', 'Select a palette'),
onChange:function(hsb,hex,rgb,el,bySetColor) {
if (picker.val()
&& picker.val().indexOf("r") == -1
&& picker.val().indexOf("t") == -1) {
$ck(el).css('background-color','#'+hex);
ckSetPickercolor(picker);
// force the # character
if (picker.val().indexOf("#") == -1) picker.val('#'+picker.val());
} else {
$ck(el).css('background-color','');
}
// Fill the text box just if the color was set using the picker, and not the colpickSetColor function.
if (picker.val().indexOf("r") == -1
&& picker.val().indexOf("t") == -1) {
if(!bySetColor) $ck(el).val('#' + hex);
}
},
onSubmit:function(hsb,hex,rgb,el,bySetColor) {
// picker.trigger('change');
ckRenderCss();
},
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');
ckSetPickercolor(picker);
},
onPaletteColor: function(hsb,hex,rgb,el,bySetColor) {
picker.val('#'+hex);
picker.css('background','#'+hex);
// picker.trigger('change');
ckSetPickercolor(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 ckSetPickercolor(picker) {
// if (picker.val().indexOf("#") == -1) {
// picker.css('color', '').css('background', '');
// return;
// }
pickercolor =
0.213 * ckHexToR(picker.val()) / 100 +
0.715 * ckHexToG(picker.val()) / 100 +
0.072 * ckHexToB(picker.val()) / 100
< 1.5 ? '#FFF' : '#000';
picker.css('color', pickercolor);
return pickercolor;
}
function ckCreateGradientPreview(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() {
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSetPaletteColors();CKBox.close()">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxcolorspalette&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
async: true,
data: {
}
}).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]) {
field.attr('value', '#' + colors[i]).trigger('change');
field.css('background-color', field.attr('value'));
ckSetPickercolor(field);
}
}
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckToggleExpertMode(button) {
button = $ck(button);
if ($ck('#body').hasClass('expert')) {
$ck('#body').removeClass('expert');
$ck(button).removeClass('ckexpertmode');
} else {
$ck('#body').addClass('expert');
$ck(button).addClass('ckexpertmode');
}
}
function ckPrintPositions() {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
$ck('.controlfocus').removeClass('controlfocus');
// $ck('#ckedition').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="ckmodulepositionpreview"><span class="ckmodulepositionpreview_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 = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxprintpositions&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templatename: $ck('#name').val()
}
}).done(function(code) {
$ck(document.body).append('<div id="ckprintpositionresult">' + code + '</div>');
$ck('#ckwaitoverlay').remove();
html2canvas($ck('#body'), {
onrendered: function(canvas) {
$ck('#ckwaitoverlay').remove();
// document.body.appendChild(canvas);
$ck('#ckprintpositionscontainer').empty().append(canvas);
$ck('.ckmodulepositionpreview').remove();
}
});
CKBox.open({'handler': 'inline', 'content': 'ckprintpositionresult', style: {padding: '10px'}});
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckCheckExpertModeOnPageload() {
if ($ck('#body').hasClass('expert')) {
$ck('#ckheader .ckexpert').addClass('ckexpertmode');
} else {
$ck('#ckheader .ckexpert').removeClass('ckexpertmode');
}
}
//function showThemes() {
// $ck('.ckleftpanel').not($ck('#showthemes')).fadeOut();
// $ck('#showthemes').fadeIn();
//}
//function hideThemes() {
// $ck('#showthemes').fadeOut();
//}
function ckSubmitButtonSave() {
if (! $ck('#name').val()) {
$ck('#name').addClass('invalid').focus();
alert(TCK.Text._('CK_TEMPLATE_MUST_HAVE_NAME', 'You must give a name to the template'));
ckEditGlobalinfos()
return;
}
ckCleanTemplateName();
$ck('#name').removeClass('invalid');
// clean the interface
$ck('.editorck').remove();
$ck('.ckhover').removeClass('ckhover');
ckRemoveColumnEdition();
ckRemoveWorkspaceWidth();
// $ck('#body').removeClass('ckresponsiveactive');
// 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;
});
var 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);
$ck('.layoutfield').each(function() {
var type = $ck(this).attr('data-type');
$ck(this).attr('value',$ck('#layout_' + type + '_html').html());
});
// save the template code
$ck('#htmlcode').attr('value', $ck('#ckhtmlcontainer').html().trim());
$ck('#stylecode').attr('value', $ck('#ckstylescontainer').html().trim());
ckSubmitButton('template.save');
}
function ckSubmitButton(task, form) {
if (!form) {
form = document.getElementById('adminForm');
}
if (task) {
form.task.value = task;
}
// Submit the form.
// Create the input type="submit"
var button = document.createElement('input');
button.style.display = 'none';
button.type = 'submit';
// Append it and click it
form.appendChild(button).click();
// If "submit" was prevented, make sure we don't get a build up of buttons
form.removeChild(button);
}
function ckToggleBootstrap() {
var bodyProps = ckGetPropsForBloc('body', 'tab_blocstyles');
if (bodyProps.length && bodyProps.attr('blocloadboostrap') == '0' || $ck('#joomlaversion').attr('value') != 'j3') {
$ck("#bootstrapload").empty();
$ck('#bootstrapload').append('<link rel="stylesheet" type="text/css" href="' + TEMPLATECREATORCK_MEDIA_URI + '/default.css">');
$ck("#bootstrapload").removeClass('bootstraploaded');
} else if (bodyProps.length && bodyProps.attr('blocloadboostrap') == '1' && !$ck("#bootstrapload").hasClass('bootstraploaded')) {
$ck("#bootstrapload").empty();
$ck('#bootstrapload').append('<link rel="stylesheet" type="text/css" href="' + TEMPLATECREATORCK_MEDIA_URI + '/bootstrap.css">');
$ck("#bootstrapload").addClass('bootstraploaded');
}
}
function ckToogleWrapperFluid() {
var styleswrapper = ckGetStylesWrapperForBlock('body');
if (!$ck('#blocwrapperfluid').length && $ck('> .tab_blocstyles', styleswrapper).length && !$ck('> .tab_blocstyles', styleswrapper).attr('blocwrapperfluid'))
return;
if ($ck('#blocwrapperfluid').length) {
value = $ck('#blocwrapperfluid').attr('value');
} else {
value = $ck('> .tab_blocstyles', styleswrapper).attr('blocwrapperfluid');
}
if (value == 'fluid') {
$ck('.tck-container').removeClass('tck-container').addClass('tck-container-fluid');
} else {
$ck('.tck-container-fluid').removeClass('tck-container-fluid').addClass('tck-container');
}
}
function ckCopyToClipboard(button) {
CKCLIPBOARD = new Array();
$ck('.inputbox').each(function(i, el) {
var tmp = new Object()
CKCLIPBOARD[el.id] = el.value;
if ($ck(el).attr('type') == 'radio') {
if ($ck(el).attr('checked')) {
CKCLIPBOARD[el.id] = 'checked';
} else {
CKCLIPBOARD[el.id] = '';
}
}
});
alert(TCK.Text._('CK_COPYTOCLIPBOARD', 'Current styles copied to clipboard !'));
}
function ckPasteFromClipboard(button) {
if (CKCLIPBOARD) {
if (!confirm(TCK.Text._('CK_COPYFROMCLIPBOARD', 'Apply styles from Clipboard ? This will replace all current existing styles.')))
return;
for (var field in CKCLIPBOARD) {
$ck('#' + field).val(CKCLIPBOARD[field]);
if ($ck('#' + field).attr('type') == 'radio') {
if (CKCLIPBOARD[field] == 'checked') $ck('#' + field).attr('checked', CKCLIPBOARD[field]);
}
if ($ck('#' + field).hasClass('colorPicker')) ckSetPickercolor($ck('#' + field));
}
ckRenderCss();
} else {
alert(TCK.Text._('CK_CLIPBOARDEMPTY', 'Clipboard is empty'));
}
}
function ckResetCss(button) {
if (!confirm(TCK.Text._('CK_CONFIRM_RESET_STYLES', 'Are you sure to reset ? This will remove all existing styles.')))
return;
$ck('#ckedition .inputbox').each(function() {
var field = $ck(this);
field.val('');
if (field.attr('type') == 'radio') {
field.removeAttr('checked');
}
if (field.hasClass('colorPicker')) ckSetPickercolor(field);
});
ckRenderCss();
}
function ckCleanTemplateName() {
var input = $ck('#name');
var name = input.val();
name = ckAlphaNumeric(name);
name = name.toLowerCase();
input.val(name);
}
function ckAlphaNumeric(s, allowspace) {
if (!allowspace) allowspace = false;
if (allowspace) {
return s.replace(/[^a-z0-9-_? ]/gi,'');
} else {
return s.replace(/[^a-z0-9-_?]/gi,'');
}
}
/*
* Show the window for global infos (name, date, author...)
*/
function ckEditGlobalinfos() {
CKBox.open({'handler': 'inline', 'content': 'ckinfospopup', 'size': {x: '700px', y: '500px'}});
}
/*
* Function to load the HTML modele in the page
*/
function ckLoadLayout(name) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=" + name + "&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl
}).done(function(code) {
$ck("#ckhtmlcontainer").html(code);
if ($ck('#joomlaversion').attr('value') == 'j3') {
$ck('#body > .tab_blocstyles').attr('blocloadboostrap', '1');
}
ckLoadTheme('default');
$ck("#ckleftpanel").removeClass('hiddenpanel');
ckInitInterface();
$ck('body').removeClass('ckfirststep');
CKBox.close();
}).fail(function(code) {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckLoadTheme(themename) {
// valid = '1';
// valid = confirm(TCK.Text._('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 = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxloadtheme&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {themename: themename}
}).done(function(code) {
ckApplyTheme(code);
ckToggleBootstrap();
$ck('#ckwaitoverlay').remove();
ckShowWizard();
ckSaveAction();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckApplyTheme(code) {
code = code.replace(/\|di\|/g, "#");
theme = JSON.parse(code);
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]) {
var blocClass = $ck('<div ' + bloc['ckprops' + j] + ' />').removeClass('ckprops').attr('class');
var blocid = focusbloc.attr('id');
$ck('> .' + blocClass, focusbloc).remove();
// $ck('#ckstylescontainer').find('.ckstyle[data-id="' + focusbloc.attr('id') + '"].' + blocClass).remove();
// $ck('#ckstylescontainer').prepend('<div ' + bloc['ckprops' + j] + ' data-id="' + focusbloc.attr('id') + '" />');
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.append('<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")
;
ckSetStyleForBloc(blocid, '<style>' + blocstyle + '</style>');
focusbloc.find('> .ckstyle').remove();
// $ck('#ckstylescontainer').prepend('<div class="ckstyle" data-id="' + focusbloc.attr('id') + '" ><style>' + blocstyle + '</style></div>');
// $ck('#ckstylescontainer').find('.ckstyle[data-id="' + focusbloc.attr('id') + '"]').empty().append('<style>' + blocstyle + '</style>');
}
});
}
ckSeparateStylesForBlocks();
ckToogleWrapperFluid();
}
function ckGetTheme() {
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;
var blocid = bloc.attr('id');
blocstyle = ($ck('#ckstylescontainer').find('.ckstylecontainer[data-id="' + blocid + '"] .ckstyle').length && $ck('#ckstylescontainer').find('.ckstylecontainer[data-id="' + blocid + '"] .ckstyle').html()) ? $ck('#ckstylescontainer').find('.ckstylecontainer[data-id="' + blocid + '"] .ckstyle').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('#ckstylescontainer').find('.ckstylecontainer[data-id="' + blocid + '"] .ckprops').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') + '" ';
for (var f=0; f<fieldslist.length; f++) {
var fieldname = fieldslist[f];
text += fieldname + '="' + ckprops.attr(fieldname) + '" ';
}
cssblocs['ckprops' + i] = text;
});
blocs[i] = cssblocs;
}
return blocs;
}
function ckSaveTheme() {
var theme = ckGetTheme();
theme = JSON.stringify(theme);
theme = theme.replace(/#/g, "|di|");
var themename = prompt('nom du theme ?');
if (themename == null || themename == '')
return;
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxsavetheme&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
theme: theme,
themename: themename
}
}).done(function(code) {
$ck("#themefile").html(code);
// checkModules();
}).fail(function(code) {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
/*=================================*/
/* Favorite management
/*=================================*/
function ckRemoveFavorite(btn) {
if (!confirm(TCK.Text._('CK_CONFIRM_DELETE','Are you sure that you want to delete ?'))) return;
var favorite = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('> .ckmyfavorite');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxRemoveFavorite&" + CKTOKEN;
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();
ckRemoveStylesForBlock('ckmyfavorite' + name);
alert(TCK.Text._('CK_SUCCESS', 'Success !'));
} else {
alert(TCK.Text._('CK_FAILED', 'Failed'));
}
}
catch(err) {
alert( 'ERROR : ' + err.message );
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckEditFavorite(btn) {
var bloc = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('> .ckmyfavorite');
$ck('.ckfocusfavorite').removeClass('ckfocusfavorite'); // needed because focus is removed on panel close
bloc.addClass('ckfocusfavorite'); // needed because focus is removed on panel close
ckShowEdition(bloc.attr('id'), 'ckSaveFavoritePopup');
}
function ckSaveFavoritePopup(blocid, workspace) {
// ckSaveEdition(blocid, workspace, 'ckAfterSaveFavoritePopup');
ckRenderCss(blocid, workspace, $ck('.ckfocus'), false, 'ckAfterSaveFavoritePopup'); //blocid, editionarea, focus, forpreviewarea, returnFunc
}
function ckAfterSaveFavoritePopup() {
var favorite = $ck('.ckfocusfavorite');
var blocid = favorite.attr('id');
var stylecode = ckGetStyleForBloc(blocid).html();
var id = new RegExp(blocid, "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);
ckSaveFavorite(favorite, favorite.attr('data-name').replace('favorite', ''));
$ck('.ckfocusfavorite').removeClass('ckfocusfavorite');
}
function ckGetFavorite(focus) {
// var bloc = $ck('.ckfocusfavorite');
var bloc = focus;
var blocid = bloc.attr('id');
var cssbloc = new Object();
cssbloc['class'] = bloc.attr('class');
var blocstyle = ckGetStyleForBloc(blocid);
blocstyle = (blocstyle.length && blocstyle.html()) ? blocstyle.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;
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.find('> .ckprops').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') + '" ';
for (var f = 0;f < fieldslist.length; f++ ) {
text += fieldslist[f] + '="' + ckprops.attr(fieldslist[f]) + '" ';
}
cssbloc['ckprops' + i] = text;
});
return cssbloc;
}
function ckSaveFavorite(focus, id) {
if (! id) id = -1;
var favorite = ckGetFavorite(focus);
var favoriteStyle = favorite['style'];
favoritestring = JSON.stringify(favorite);
favoritestring = favoritestring.replace(/#/g, "|di|");
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxsavefavorite&" + CKTOKEN;
$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);
ckSeparateStylesForBlock('ckmyfavoritefavorite' + response.msg);
// alert(TCK.Text._('CK_SUCCESS_CREATING_FAVORITEFILE', 'Success !'));
} else {
alert(TCK.Text._('CK_FAILED', 'Failed'));
}
}
catch(err) {
alert( 'ERROR : ' + err.message );
}
// if (parseInt(code) == code) {
// $ck('#showfavorites > div').append('<div class="favoritethumb" onmouseout="ckRestoreBeforeFavorite()" onmouseover="ckPreviewFavoriteDirect(this)" onclick="ckLoadFavorite(\'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(TCK.Text._('CK_SUCCESS_CREATING_FAVORITEFILE', 'Success !'));
// } else {
// alert(TCK.Text._('CK_FAILED', 'Failed'));
// }
}).fail(function(code) {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckAddFavoriteToList(i, favorite) {
var name = 'favorite' + i;
var html = '<div class="ckmyfavoriterow clearfix">'
+ '<div class="ckmyfavoritename">'
+ '<span class="ckmyfavoritenamevalue">' + name + '</span>'
+ '<div class="ckbutton ckedit" style="padding: 1px 4px;margin: 0 10px;" onclick="ckEditFavoriteName(this)"><span class="fa fa-edit"></span></div><div class="ckbutton ckvalidate" style="padding: 1px 4px;margin: 0 10px;" onclick="ckSaveFavoriteName(this)"><span class="fa fa-check"></span></div>'
+ '</div>'
+ '<div id="ckmyfavorite' + name + '" data-name="' + name + '" style="" class="favoritethumb ckmyfavorite" data-merge="0" onmouseout="ckRestoreBeforeFavorite()" onmouseover="ckPreviewFavoriteDirect(this)" onclick="ckLoadFavorite(\'' + name + '\', \'favorites\', 1, this)">'
+ '<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> ' + TCK.Text._('CK_EDIT') + '</div>'
+ '<div class="ckbutton" onclick="ckRemoveFavorite(this);"><span class="fa fa-remove" style="color:red;"></span> ' + TCK.Text._('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 ckLoadFavorite(name, folder, apply, thumb) {
CKFAVORITELOCKED = 1;
var valid = '1';
if (apply == 1) {
valid = confirm(TCK.Text._('CK_ERASE_WITH_NEW_FAVORITE', 'WARNING : This will erase your data with the new favorite, continue ?'));
if (valid == null || valid == "") {
CKFAVORITELOCKED = 0;
ckRestoreBeforeFavorite();
return;
}
} else {
}
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxloadfavorite&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
name: name,
folder: folder
}
}).done(function(code) {
if (apply == 1) {
ckApplyFavorite(code, thumb);
ckCloseEdition();
ckSaveAction();
} else {
previewFavorite(code);
}
ckSaveAction();
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckRestoreBeforeFavorite() {
if ( CKFAVORITELOCKED == 1 )
return;
if (CKBLOCCKSTYLESBACKUP != 'undefined') {
focusbloc = $ck('.ckfocus');
// $ck('> .ckstyle', focusbloc).empty().html(CKBLOCCKSTYLESBACKUP);
ckSetStyleForBloc(focusbloc.attr('id'), CKBLOCCKSTYLESBACKUP)
}
}
function ckPreviewFavoriteDirect(thumb) {
if ( CKFAVORITELOCKED == 1 )
return;
thumb = $ck(thumb);
var focusbloc = $ck('.ckfocus');
if (! focusbloc.length) return;
// CKBLOCCKSTYLESBACKUP = $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 = ckGetStyleForBloc(focusbloc.attr('id')).find('style').text();
focusblocstyle = focusblocstyle.replace(re, '');
focusblocstyle = focusblocstyle + stylecode;
ckSetStyleForBloc(focusbloc.attr('id'), '<style>' + focusblocstyle + '</style>');
// $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);
ckSetStyleForBloc(focusbloc.attr('id'), stylecode);
}
}
function ckApplyFavorite(code, thumb) {
var focusbloc = $ck('.ckfocus');
var blocid = focusbloc.attr('id');
thumb = $ck(thumb);
code = code.replace(/\|di\|/g, "#");
bloc = JSON.parse(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 = ckGetPropsForBloc(blocid, blocClass);
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*/';
var focusstyle = ckGetStyleForBloc(blocid);
if (focusstyle.html().match(re)) {
var blocstyle = focusstyle.html().replace(re, blocstyle);
ckSetStyleForBloc(blocid, blocstyle);
// $ck('> .ckstyle', focusbloc).empty().append(blocstyle);
} else {
// $ck('> .ckstyle', focusbloc).append(blocstyle);
ckSetStyleForBloc(blocid, blocstyle, true);
}
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 {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.prepend('<div ' + bloc['ckprops' + j] + ' />');
// focusbloc.prepend('<div ' + bloc['ckprops' + j] + ' />');
}
j++;
}
} else {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
$ck('> .ckstyle', styleswrapper).empty();
$ck('> .ckprops', styleswrapper).remove();
while (bloc['ckprops' + j]) {
blocClass = $ck('<div ' + bloc['ckprops' + j] + ' />', focusbloc).removeClass('ckprops').attr('class');
$ck('> .' + blocClass, focusbloc).remove();
styleswrapper.prepend('<div ' + bloc['ckprops' + j] + ' />');
j++;
}
if (bloc['style']) {
blocstyle = bloc['style'].replace(/\|ID\|/g, focusbloc.attr('id')).replace(/\|URIBASE\|/g, URIBASE + "/");
$ck('> .ckstyle', styleswrapper).empty().append('<style>' + blocstyle + '</style>');
}
}
CKFAVORITELOCKED = 0;
}
function ckShowFavoritesPanel(blocid) {
CKFAVORITELOCKED = 1;
bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
CKBLOCCKSTYLESBACKUP = ckGetStyleForBloc(blocid).html();
$ck('#ckfavoritespanel').fadeIn();
// if the favorite panel is already opened
// if ($ck('#ckfavoritespanel').length) {
$ck('.objid', $ck('#ckfavoritespanel')).text(bloc.attr('id'));
CKFAVORITELOCKED = 0;
// return;
// }
/*var editionarea = $ck('#ckedition').addClass('ckwait');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxfavorites&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl
}).done(function(code) {
editionarea.empty().append(code).removeClass('ckwait').fadeIn();
$ck('.objid', $ck('#ckfavoritespanel')).text(bloc.attr('id'));
CKFAVORITELOCKED = 0;
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});*/
}
function ckCloseFavoritePanel(force) {
if (! force ) force = false;
if ( $ck('#ckfavoritespanel').hasClass('cksticked') && !force ) {
// CKBLOCCKSTYLESBACKUP = $ck('> .ckstyle', $ck('.ckfocus')).html();
CKBLOCCKSTYLESBACKUP = ckGetStyleForBloc($ck('.ckfocus').attr('id')).html();
return;
}
$ck('#ckfavoritespanel').fadeOut();
if ($ck('#ckleftpanel').attr('data-reduced') == 'true') $ck('#ckleftpanel').addClass('reduced').removeAttr('data-reduced');
}
function ckEditFavoriteName(btn) {
var namefield = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('.ckmyfavoritename');
var namevalue = namefield.find('.ckmyfavoritenamevalue').hide().text();
namefield.find('.ckedit').hide();
namefield.find('.ckvalidate').css('display', 'inline-block');
namefield.prepend('<input type="text" class="ckmyfavoritenameedition" value="' + namevalue + '"/>');
}
function ckSaveFavoriteName(btn) {
var namefield = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('.ckmyfavoritename');
var newname = ckAlphaNumeric(namefield.find('.ckmyfavoritenameedition').val(), true);
namefield.find('.ckmyfavoritenamevalue').text(newname);
namefield.find('input.ckmyfavoritenameedition').remove();
namefield.find('.ckedit').show();
namefield.find('.ckvalidate').hide();
namefield.find('.ckmyfavoritenamevalue').show();
var filename = $ck($ck(btn).parents('.ckmyfavoriterow')[0]).find('.ckmyfavorite').attr('data-name');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxrenamefavorite&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
filename: filename,
name: newname,
}
}).done(function(code) {
try {
response = JSON.parse(code);
if (response.status == '1') {
// $ck('#ckmyfavorite' + name).parent().remove();
// alert(TCK.Text._('CK_SUCCESS', 'Success !'));
} else {
alert(TCK.Text._('CK_FAILED', 'Failed'));
}
}
catch(err) {
alert( 'ERROR : ' + err.message );
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
/*
function checkModules(action, position) {
if (!position) position = '';
$ck('#modules_code_inner').empty().addClass('ckwait');
$ck('.ckleftpanel').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);
ckInitTooltip($ck('#modules_code_inner'), 'title');
// $ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('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 ckCreateWrapperBloc(currentbloc) {
ckAddBlock('wrapper', ckGetWrapperProposal(), '', currentbloc);
}
function ckGetWrapperProposal() {
var i = 1;
while ($ck('#wrapper' + i).length && i < 1000) {
i++;
}
return 'wrapper' + i;
}
function createBloc(currentbloc, type) {
idproposal = ckGetIdProposal(type);
positionsproposal = ckGetPositionsProposal(type).join();
ckAddBlock(type, idproposal, positionsproposal, currentbloc);
}
function ckGetIdProposal(type, id) {
if (!id) id = '';
var suggestion;
switch (type) {
case 'singlemodule':
default:
suggestion = 'block';
break;
case 'module-slideshowck':
suggestion = 'slideshow';
break;
case 'flexiblemodules':
suggestion = 'blocks';
break;
case 'rowcontainer':
suggestion = id;
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 (type == 'rowcontainer') {
if (! $ck('#' + suggestion + 'column' + i).length)
return suggestion + 'column' + i;
} else {
if (! $ck('#' + suggestion + i).length)
return suggestion + i;
}
}
return suggestion + i;
}
function ckGetPositionsProposal(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('#ckedition').empty().fadeIn();
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxblocselection&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
currentblocid: currentblocid
}
}).done(function(code) {
$ck('#ckedition').append(code);
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}*/
function ckAddBlock(type, blockid, blockposition, currentbloc) {
$ck('#ckedition').empty().hide();
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxcreatebloc&" + CKTOKEN;
$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') {
var newblock = $ck(code);
if (currentbloc) {
$ck(currentbloc).fadeOut(500, function() {
$ck(currentbloc).before(newblock);
$ck(currentbloc).remove();
ckInitSortables();
if (type.substring(0,7) == 'module-') {
ckSearchExistingModules($ck('#'+blockid).attr('data-element'), blockposition, blockid)
}
});
ckSeparateStylesForBlock(newblock, true);
} else {
$ck('.ckfocus > .inner').append(newblock);
if (type.substring(0,7) == 'module-') {
ckSearchExistingModules($ck('#'+blockid).attr('data-element'), blockposition, blockid)
}
ckSeparateStylesForBlock(newblock, true);
}
newblock.find('.ckrowcontainer, .flexiblemodule').each(function() {
ckAddControlsOnHover($ck(this));
});
ckAddControlsOnHover(newblock);
ckSaveAction();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckSearchExistingModules(type, blockposition, blockid) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + '&task=ajaxSearchExistingModules&' + CKTOKEN;
$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(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckAddModule(type, blockposition, blockid) {
if (! type) {
ckShowModuleSelectList(blockposition, blockid);
return;
}
var myurl = TEMPLATECREATORCK_ADMIN_URL + '&task=ajaxPublishModule&' + CKTOKEN;
$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);
}
ckSaveAction();
}
catch(err) {
alert( 'ERROR : ' + err.message );
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckShowModuleSelectList(blockposition, blockid) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxmoduleselect&" + CKTOKEN;
$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(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckShowModulesList(type, blockposition, blockid) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxmoduleslist&" + CKTOKEN;
$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(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckAssignModule(blockid, moduleid) {
$ck('#'+blockid).attr('data-moduleid', moduleid);
CKBox.close();
}
function ckToggleModuleState(btn, id, state) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxToggleModuleState&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
async: true,
data: {
moduleid: id,
state: $ck(btn).attr('data-state')
}
}).done(function(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(TCK.Text._('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(TCK.Text._('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\')">' + TCK.Text._('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(TCK.Text._('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();
}
}
// needed for B/C
function addControlsOnHover(bloc) {
ckAddControlsOnHover(bloc);
}
function ckAddControlsOnHover(bloc) {
bloc = $ck(bloc);
if ($ck('> .editorck', bloc).length)
return;
var timeout;
bloc.mouseenter(function() {
if (! $ck('#cktemplatecontainer').hasClass('ckcssmanager')
&& ! $ck('#body').hasClass('ckresponsiveactive')) {
ckAddEdition(this);
}
});
bloc.mouseleave(function() {
el = $ck(this);
// clearTimeout (el.timeout);
// el.timeout = setTimeout (function() {
if (! $ck('#cktemplatecontainer').hasClass('ckcssmanager')
&& ! $ck('#body').hasClass('ckresponsiveactive')
) {
ckRemoveEdition(el);
}
// }, 200);
});
}
function ckAddEdition(bloc, i) {
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');
bloc.addClass('ckhover');
var editorclass = '';
if (i == 0)
editorclass = ' mainroot';
var editor = '<div class="editorck' + editorclass + '" id="' + bloc.attr('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()
});
ckAddEditionControls(editor, bloc);
bloc.append(editor);
editor.css('display', 'none').fadeIn('fast');
}
function ckAddEditionControls(editor, bloc) {
var blocid = bloc.attr('id');
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=\"ckDeleteBloc('" + 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 ckhastip\" title=\"" + TCK.Text._('CK_MOVE_TOOLTIP', 'Move the element with drag and drop') + "\"></div>"
+ "<div class=\"controlCss isControl ckhastip\" title=\"" + TCK.Text._('CK_CSS_TOOLTIP', 'Edit the styles of the element') + "\" onclick=\"ckShowEdition('" + bloc.attr('id') + "');\"></div>"
+ "<div class=\"controlFavorite isControl ckhastip\" title=\"" + TCK.Text._('CK_FAVORITE_TOOLTIP', 'Design suggestions') + "\" onclick=\"ckShowFavoritesPanel('" + bloc.attr('id') + "');\"></div>";
// for responsive
if (!bloc.hasClass('content') && !bloc.hasClass('main') && !bloc.hasClass('center') && bloc.attr('id') != 'wrapper') {
if (bloc.hasClass('ckrow') || bloc.hasClass('flexiblemodules')
|| bloc.hasClass('maincontent') || bloc.hasClass('maincenter')
|| bloc.hasClass('horiznav')
) {
controls += '<div class="isControlResponsive isControl ckhastip" data-class="ckalign" data-mobile="mobile_default" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_ALIGNED') + '" onclick="ckToggleResponsive(this);" ></div>'
+ '<div class="isControlResponsive isControl ckhastip" data-class="ckstack" data-mobile="mobile_notaligned" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_STACKED') + '" onclick="ckToggleResponsive(this);" ></div>';
} else {
controls += '<div class="isControl isControlResponsive ckhastip" data-class="ckshow" data-mobile="mobile_default" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_SHOWN', 'Show') + '" onclick="ckToggleResponsive(this)"><span class="fa fa-eye"></span></div>'
}
if (!bloc.hasClass('maincontent') && !bloc.hasClass('maincenter') && !bloc.hasClass('center') && !bloc.hasClass('main')) {
controls += '<div class="isControl isControlResponsive ckhastip" data-class="ckhide" data-mobile="mobile_hide" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_HIDDEN', 'Hide') + '" onclick="ckToggleResponsive(this)"><span class="fa fa-eye-slash"></span></div>'
}
if (bloc.hasClass('horiznav')) {
controls += '<div class="isControl isControlResponsive ckhastip" data-class="ckhamburger" data-mobile="mobile_hamburger" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_HAMBURGER', 'Hamburger icon') + '" onclick="ckToggleResponsive(this)"><span class="fa fa-bars"></span></div>'
}
// mobile menu ck activation, check if the widget and plugin activated
if (bloc.hasClass('horiznav')) {
var mobilemenuenabled = '0';
var widgetsettings = $ck('#widgetsElements').find('[data-name="mobilemenu"] [data-id="' + bloc.attr('id') + '"]');
if (widgetsettings.length) {
if (widgetsettings.attr('data-mobilemenuck_enable') == '1') {
mobilemenuenabled = '1';
}
}
var displaymobilebutton = $ck('#widgetsElements').find('[data-name="mobilemenu"]').length && $ck('#widgetsElements').find('[data-name="mobilemenu"]').attr('data-enabled') == '1' ? 'block' : 'none';
controls += '<div class="isControl isControlResponsive ckhastip" style="display:' + displaymobilebutton + '" data-class="ckmobilemenu" data-enabled="' + mobilemenuenabled + '" data-mobile="mobile_mobilemenuck" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_MOBILEMENU', 'Mobile Menu CK') + '" onclick="ckLoadWidgetMobilemenuck(this);"><span class="fa fa-mobile fa-lg"></span></div>'
}
}
if (TEMPLATECREATORCK_ENABLE_SAVE_ELEMENTS == '1') {
controls += "<div class=\"controlSave isControl ckhastip\" title=\"" + TCK.Text._('CK_SAVE') + "\" onclick=\"ckSaveItem('" + 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 ckhastip\" title=\"" + TCK.Text._('CK_COPY') + "\" onclick=\"ckDuplicateItem('" + bloc.attr('id') + "');\"></div>"
}
if (bloc.hasClass('flexiblemodules')) {
controls += "<div class=\"controlModules isControl ckhastip\" title=\"" + TCK.Text._('CK_MODULES_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"ckShowModulesPopup('" + bloc.attr('id') + "')\"></div>";
// controls += "<div class=\"controlEqualHeights isControl ckhastip\" title=\"" + TCK.Text._('CK_EQUALHEIGHTS_TOOLTIP', 'Set equal height on all blocks') + "\" onclick=\"setEqualHeights('" + bloc.attr('id') + "')\"></div>";
}
if (bloc.hasClass('ckrow'))
controls += "<div class=\"controlRow isControl ckhastip\" title=\"" + TCK.Text._('CK_ROW_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"ckShowColumnsEdition('" + bloc.attr('id') + "')\">" + bloc.find('> .inner > .ckrowcontainer').length + "</div>";
// if (bloc.hasClass('mainbanner'))
// controls += "<div class=\"controlBanner isControl ckhastip\" title=\"" + TCK.Text._('CK_BANNER_TOOLTIP', 'Edit the blocks width and number') + "\" onclick=\"showBannerPopup('" + bloc.attr('id') + "')\"></div>";
if (bloc.hasClass('maincontent')) {
controls += "<div class=\"controlMaincontent isControl ckhastip\" title=\"" + TCK.Text._('CK_MAINCONTENT_TOOLTIP', 'Edit the columns width and number') + "\" onclick=\"ckShowMaincontentPopup('" + bloc.attr('id') + "')\"></div>";
// controls += "<div class=\"controlEqualHeights isControl ckhastip\" title=\"" + TCK.Text._('CK_EQUALHEIGHTS_TOOLTIP', 'Edit the styles of the element') + "\" onclick=\"setEqualHeights('" + bloc.attr('id') + "')\"></div>";
}
if (bloc.hasClass('wrapper')) {
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
if ($ck('> .tab_blocstyles', styleswrapper).attr('blocfullwidth') == 1) {
var isFullwidth = ' ckactive';
} else {
var isFullwidth = '';
}
controls += '<div class="controlFullwidth isControl ckhastip' + isFullwidth + '" title="'+TCK.Text._('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 ckhastip\" title=\"" + TCK.Text._('CK_MODULE_EDITION_TOOLTIP', 'Edit the module options') + "\" onclick=\"ckShowModulesList('" + type + "', '" + bloc.attr('ckmoduleposition') + "', '" + bloc.attr('id') + "')\"></div>";
}
var blocclass = bloc.find('> .inner').attr('data-class') ? bloc.find('> .inner').attr('data-class') : '';
controls += "<span class=\"editorcktitle ckhastip\" title=\"" + TCK.Text._('CK_HTML_ID', 'Element ID') + "\" onclick=\"ckChangeBlocId(this)\">" + bloc.attr('id') + "</span>";
controls += "<span class=\"editorckclass ckhastip\" title=\"" + TCK.Text._('CK_CSS_CLASS', 'CSS Class') + "\" onclick=\"ckChangeBlocClass(this)\">" + blocclass + "</span>";
if (bloc.attr('ckmoduleposition'))
controls += "<span class=\"editorckposition ckhastip\" title=\"" + TCK.Text._('CK_POSITION', 'Module position') + "\" onclick=\"changeBlocPosition(this)\">" + bloc.attr('ckmoduleposition') + "</span>";
controls += "</div>";
if (bloc.hasClass('ckrowcontainer')) {
var blocclass = bloc.attr('ckclass') ? bloc.attr('ckclass') : '';
var controls = "<div class=\"ckfields " + controlclass + "\">"
+ '<div class="isControl isControlResponsive ckhastip" data-class="ckshow" data-mobile="mobile_default" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_SHOWN', 'Show') + '" onclick="ckToggleResponsive(this)"><span class="fa fa-eye"></span></div>'
+ '<div class="isControl isControlResponsive ckhastip" data-class="ckhide" data-mobile="mobile_hide" title="' + TCK.Text._('CK_RESPONSIVE_SETTINGS_HIDDEN', 'Hide') + '" onclick="ckToggleResponsive(this)"><span class="fa fa-eye-slash"></span></div>'
+ "<div class=\"controlMove isControl\"></div>"
+ "<div class=\"controlCss isControl ckhastip\" title=\"" + TCK.Text._('CK_CSS_TOOLTIP', 'Edit the styles of the element') + "\" onclick=\"ckShowEdition('" + bloc.attr('id') + "');\"></div>"
+ "<div class=\"controlValignDefault isControl ckhastip" + (blocclass == '' ? ' active' : '') + "\" title=\"" + TCK.Text._('CK_VALIGN_DEFAULT', 'Default vertical alignment') + "\" onclick=\"ckToggleVerticalAlign('" + bloc.attr('id') + "', 'default', this);\"></div>"
+ "<div class=\"controlValignTop isControl ckhastip" + (blocclass == 'valign-top' ? ' active' : '') + "\" title=\"" + TCK.Text._('CK_VALIGN_TOP', 'Top vertical alignment') + "\" onclick=\"ckToggleVerticalAlign('" + bloc.attr('id') + "', 'top', this);\"></div>"
+ "<div class=\"controlValignCenter isControl ckhastip" + (blocclass == 'valign-center' ? ' active' : '') + "\" title=\"" + TCK.Text._('CK_VALIGN_CENTER', 'Center vertical alignment') + "\" onclick=\"ckToggleVerticalAlign('" + bloc.attr('id') + "', 'center', this);\"></div>"
+ "<div class=\"controlValignBottom isControl ckhastip" + (blocclass == 'valign-bottom' ? ' active' : '') + "\" title=\"" + TCK.Text._('CK_VALIGN_BOTTOM', 'Bottom vertical alignment') + "\" onclick=\"ckToggleVerticalAlign('" + bloc.attr('id') + "', 'bottom', this);\"></div>"
+ "</div>";
}
editor.append(controls);
ckInitTooltip(editor, 'title');
}
function ckLoadWidgetMobilemenuck(btn) {
var btn = $ck(btn);
var bloc = $ck(btn.parents('.editorck')[0]).parent();
TCK_WidgetMobilemenuEditPluginOptions(bloc);
}
function ckToggleVerticalAlign(blocid, pos, btn) {
var focus = $ck('#' + blocid);
focus.removeClass('valign-top').removeClass('valign-center').removeClass('valign-bottom');
if (pos != 'default') {
focus.addClass('valign-' + pos);
focus.attr('ckclass', 'valign-' + pos);
} else {
focus.attr('ckclass', '');
}
$ck(btn).parent().find('[class*="controlValign"]').removeClass('active');
$ck(btn).addClass('active');
}
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) {
// ckCreatePropsForBloc(focus, tabid);
// }
focusprop = ckGetPropsForBloc(blocid, tabid);
if (focusprop.attr('blocfullwidth') == '0' || !focusprop.attr('blocfullwidth')) {
focusprop.attr('blocfullwidth', '1');
$ck('> .inner', focus).removeClass('tck-container').removeClass('tck-container-fluid')
.removeClass('container').removeClass('container-fluid');
focus.find('.controlFullwidth').addClass('ckactive');
} else if (focus.hasClass('wrapper')) {
focusprop.attr('blocfullwidth', '0');
$ck('> .inner', focus).addClass('tck-container');
focus.find('.controlFullwidth').removeClass('ckactive');
}
ckSaveAction();
}
function ckDuplicateItem(blocid) {
var bloc = $ck('#' + blocid);
var bloccopy = bloc.clone();
var type = ckGetBlockType(bloc);
var newid = (type == 'wrapper' ? ckGetWrapperProposal() : ckGetIdProposal(type));
// var newid = getNewId(blocid);
if (! newid) return;
var position = bloc.attr('ckmoduleposition');
bloc.after(bloccopy);
bloccopy.removeClass('editfocus');
bloccopy.find('> .editorck').remove();
// ckReplaceId(bloccopy, newid);
bloccopy.attr('id', newid);
ckDuplicateStylesForBlock(blocid, newid);
if (position) {
var newposition = ckGetPositionsProposal('block');
bloccopy.attr('ckmoduleposition', newposition);
}
ckInitSortables();
ckAddControlsOnHover(bloccopy);
bloccopy.find('.ckbloc, .ckrowcontainer').each(function() {
$this = $ck(this);
var blocid = $this.attr('id');
$this.removeClass('editfocus');
var type = ckGetBlockType($this);
var parentid = '';
if ($this.hasClass('ckrowcontainer')) {
parentid = $ck($this.parents('.ckrow')[0]).attr('id');
}
var newid = (type == 'wrapper' ? ckGetWrapperProposal() : ckGetIdProposal(type, parentid));
// newid = getNewId($this.attr('id'));
if (! newid) return;
position = $this.attr('ckmoduleposition');
if (position) {
newposition = ckGetPositionsProposal('block');
$this.attr('ckmoduleposition', newposition);
}
// ckReplaceId($this, newid);
$this.attr('id', newid);
ckDuplicateStylesForBlock(blocid, newid);
ckInitSortables();
ckAddControlsOnHover($this);
});
ckSaveAction();
}
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());
}
ckSaveAction();
}
function ckRemoveEdition(bloc, all) {
if (!all)
all = false;
bloc = $ck(bloc);
bloc.removeClass('ckhover');
if (all = true) {
$ck('.editorck', bloc).remove();
} else {
$ck('> .editorck', bloc).remove();
}
}
function ckDeleteBloc(blocid) {
bloc = $ck('#' + blocid);
if (confirm('Do you want to delete ?')) {
ckRemoveStylesForBlock(blocid);
bloc.find('.ckbloc, .ckrowcontainer').each(function() {
ckRemoveStylesForBlock($ck(this).attr('id'));
})
bloc.remove();
}
ckSaveAction();
}
/*
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();
ckRemoveEdition($ck(document.body), true);
}
ckRemoveEdition($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();
ckRemoveEdition($ck(document.body));
}
ckRemoveEdition($ck(document.body));
}
}*/
function ckChangeBlocId(btn) {
if ($ck('#body').hasClass('ckresponsiveactive')) {
alert(TCK.Text._('CK_EXIT_RESPONSIVE_FIRST'));
return;
}
var bloc = ckGetBlockFromBtn(btn);
blocid = bloc.attr('id');
if (bloc.attr('id') == 'wrapper' || bloc.attr('id') == 'body')
return;
var result = prompt(TCK.Text._('CK_ENTER_UNIQUE_ID', 'Please enter a unique ID (must be a text)'), bloc.attr('id'));
if (!result)
return;
result = ckValidateName(result);
if (validateBlocId(result))
ckUpdateIdPosition(blocid, result, '');
ckSaveAction();
}
function ckGetBlockFromBtn(btn) {
return $ck($ck(btn).parents('.ckbloc')[0]);
}
function changeBlocPosition(btn) {
if ($ck('#body').hasClass('ckresponsiveactive')) {
alert(TCK.Text._('CK_EXIT_RESPONSIVE_FIRST'));
return;
}
var bloc = ckGetBlockFromBtn(btn);
blocid = bloc.attr('id');
var result = prompt(TCK.Text._('CK_ENTER_UNIQUE_POSITION', 'Please enter a unique Position (must be a text)'), bloc.attr('ckmoduleposition'));
if (!result)
return;
if (TEMPLATECREATORCK_ENABLE_SAVE_ELEMENTS == '1') {
ckUpdateIdPosition(blocid, '', result);
} else {
result = ckValidatePositionName(result);
if (validateBlocPosition(result))
ckUpdateIdPosition(blocid, '', result);
ckSaveAction();
}
}
function validateBlocId(newid) {
if (newid != null && newid != "" && !$ck('#' + newid).length) {
return true;
} else if ($ck('#' + newid).length) {
alert(TCK.Text._('CK_INVALID_ID', 'ID invalid or already exist'));
return false;
} else if (newid == null || newid == "") {
alert(TCK.Text._('CK_ENTER_VALID_ID', 'Please enter a valid ID'));
return false;
}
return true;
}
function ckValidateName(name) {
var name = name.replace(/[^a-z0-9-_?]/gi,'');
name = name.toLowerCase();
return name;
}
function ckValidatePositionName(name) {
var name = name.replace(/[^a-z0-9?-]/gi,'');
name = name.toLowerCase();
return name;
}
function validateBlocPosition(newposition) {
if (newposition == null || newposition == "") {
alert(TCK.Text._('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(TCK.Text._('CK_POSITION_ALREADY_USED', 'Position already used'));
alreadyexists = true;
}
});
return !alreadyexists;
}
function ckUpdateIdPosition(blocid, newid, newposition) {
bloc = $ck('#' + blocid);
if (newposition) {
$ck('.editorckposition', bloc).html(newposition);
bloc.attr('ckmoduleposition', newposition);
}
if (newid) {
$ck('.editorcktitle', bloc).html(newid);
ckReplaceId(bloc, newid);
bloc.find('.ckrowcontainer').each(function() {
var column = $ck(this);
// fix for columns not having ID, example maincontent
if (! column.attr('id')) {
var columnid = ckGetIdProposal('rowcontainer', blocid);
column.attr('id', columnid);
}
var newcolumnid = ckGetIdProposal('rowcontainer', newid);
ckReplaceId(column, newcolumnid);
});
}
ckSaveAction();
}
function ckReplaceId(el, newid) {
var blocid = el.attr('id');
var re = new RegExp(blocid, 'g');
var blocstyles = ckGetStyleForBloc(blocid);
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
blocstyles.html(blocstyles.html().replace(re,newid));
styleswrapper.attr('data-id', newid);
el.attr('id', newid);
}
function ckCallImageManagerPopup(id, type) {
if (! type) type = 'image';
CKBox.open({id: 'ckmediamanager', handler: 'iframe', url: TEMPLATECREATORCK_ADMIN_URL + '&view=browse&type=' + type + '&func=ckSelectFile&field='+id+'&tmpl=component'});
}
function ckShowMediaManager(id) {
ckCallImageManagerPopup(id);
}
function ckCloseMediaManager() {
CKBox.close('#ckmediamanager .ckboxmodal-button');
}
function ckCallGoogleFontPopup(prefix) {
CKBox.open({url: TEMPLATECREATORCK_ADMIN_URL + '&view=fontselect&tmpl=component&prefix=' + prefix})
}
function ckSetGoogleFont(prefix, fonturl, fontname, fontweight) {
if (! fontname) return;
fontname = ckCapitalize(fontname).trim("'");
if (! fonturl) fonturl = "//fonts.googleapis.com/css?family="+fontname.replace(' ', '+');
if (! fontweight) fontweight = $ck('#' + prefix + 'fontweight').val();
// check if the google font exists
jQuery.ajax({
url: fonturl,
})
.done(function( data ) {
if (data) {
if (prefix) {
$ck('#' + prefix + 'googlefont').removeClass('invalid');
$ck('#' + prefix + 'googlefont').val(fontname);
$ck('#' + prefix + 'fontweight').val(fontweight);
$ck('#' + prefix + 'fontfamily').val('googlefont').trigger('change');
}
ckAddGooglefontStylesheet(fontname, fonturl);
} else {
$ck('#' + prefix + 'googlefont').addClass('invalid');
}
})
.fail(function() {
$ck('#' + prefix + 'googlefont').addClass('invalid');
});
}
function ckAddGooglefontStylesheet(fontname, fonturl) {
if (! fonturl) fonturl = "//fonts.googleapis.com/css?family="+fontname.replace(' ', '+');
var exist = false;
$ck('#googlefontscall link').each(function(i, sheet) {
if ($ck(sheet).attr('href') == fonturl) exist = true;
});
if (exist == false ) {
$ck('#googlefontscall').append("<link href='"+fonturl+"' rel='stylesheet' type='text/css'>");
}
// extract the real font name for the url
var re = /family=(.*?)$/;
var fontName = fonturl.match(re);
if (typeof(fontName[1]) == 'undefined') {
alert('Font name not found');
return '';
}
var fullfontname = fontName[1].trim().trim("'");
var bodyfontsprops = ckGetPropsForBloc('body', 'googlefonts');
var fontslist = bodyfontsprops.attr('fontslist') ? bodyfontsprops.attr('fontslist') : '';
fontslist = fontslist ? fontslist.split(',') : new Array();
if (fontslist.indexOf(fullfontname) == -1) {
fontslist.push(fullfontname);
}
fontslist = fontslist.join(',');
bodyfontsprops.attr('fontslist', fontslist);
}
function ckAddGoogleFontsToList() {
var bodyfontsprops = ckGetPropsForBloc('body', 'googlefonts');
var fontslist = bodyfontsprops.attr('fontslist') ? bodyfontsprops.attr('fontslist') : '';
if (! fontslist) return;
fontslist = fontslist ? fontslist.split(',') : new Array();
$ck('#ckedition select[id$="fontfamily"]').each(function() {
for (var i=0; i < fontslist.length; i++) {
$ck(this)
.append($ck('<option>', { value : fontslist[i] })
.text(fontslist[i]));
}
});
}
function ckShowEdition(blocid, savefunc, onAfterLoaded) {
if (! savefunc) savefunc = '';
if (! onAfterLoaded) onAfterLoaded = '';
// blocid = '#' + blocid;
// ckKeepAlive();
// $ck(document.body).append('<div id="ckwaitoverlay"></div>');
var bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
$ck('#ckedition').empty().fadeIn().addClass('ckwait');
var editionarea = $ck('#ckedition');
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxstylescss&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
objclass: bloc.attr('class'),
expertmode: $ck('#body').hasClass('expert'),
savefunc: savefunc,
element: bloc.attr('data-element'),
ckobjid: bloc.attr('id')
}
}).done(function(code) {
$ck('#ckedition').empty().append(code).removeClass('ckwait');
// $ck('#ckwaitoverlay').remove();
ckFillEdition(blocid);
ckAddEventOnFields(editionarea, blocid);
if (onAfterLoaded && typeof(window[onAfterLoaded]) == 'function') window[onAfterLoaded]();
// loadPreviewAreaStyles(blocid);
ckAddGoogleFontsToList();
}).fail(function() {
alert(TCK.Text._('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('#ckedition');
$ck('> .ckstyle', $ck('#'+previewareabloc)).html('<style type="text/css">'+previewstyles+'</style>');
ckAddEventOnFields(editionarea, blocid);
// if icon is found
if ($ck('#ckedition').find('div[tab="tab_iconstyles"]').length && (bloc.hasClass('singlemodule') || bloc.hasClass('flexiblemodule'))) {
$ck('#'+previewareabloc).find('h3').html(bloc.find('h3').html());
}
}*/
function ckAddEventOnFields(editionarea, blocid, fieldscontainer) {
if (! fieldscontainer) fieldscontainer = editionarea;
$ck('.inputbox:not(.colorPicker)', fieldscontainer).change(function() {
ckRenderCss(blocid, editionarea);
});
$ck('.colorPicker,.inputbox[type=radio]', fieldscontainer).blur(function() {
ckRenderCss(blocid, editionarea);
});
}
function forceColorPickerChanges(picker) {
$ck(picker).trigger('blur');
}
function ckShowModulesPopup(blocid) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
// $ck('#ckedition').empty().fadeIn();
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxmodulesmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
}
}).done(function(code) {
$ck('#ckpopup').empty().append(code);
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveModulesPopup();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
CKBox.open({handler: 'inline', content: 'ckpopup', style: {padding: '10px'}, size: {x: '1150px', y: '550px'}, footerHtml: $boxfooterhtml});
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckShowRowPopup(blocid) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxrowmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
}
}).done(function(code) {
$ck('#ckpopup').empty().append(code);
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveRowPopup();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
CKBox.open({handler: 'inline', content: 'ckpopup', size: {x: '1100px', y: '300px'}, style: {padding: '10px'}, footerHtml: $boxfooterhtml});
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckRemoveColumnEdition() {
$ck('.ckcolwidthedition').remove();
$ck('.ckcolwidthediting').removeClass('ckcolwidthediting');
}
function ckShowColumnsEdition(blocid) {
ckCloseEdition();
ckRemoveColumnEdition()
var row = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
row.addClass('ckfocus');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxcolumnsmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
}
}).done(function(code) {
$ck('#ckedition').empty().append(code).fadeIn();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
// $ck('#ckwaitoverlay').remove();
});
}
/*function showBannerPopup(blocid) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
$ck('#ckedition').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('#ckedition').append(code);
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}*/
function ckShowMaincontentPopup(blocid) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
bloc = $ck('#' + blocid);
$ck('.ckfocus').removeClass('ckfocus');
bloc.addClass('ckfocus');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxmaincontentmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
}
}).done(function(code) {
$ck('#ckpopup').empty().append(code);
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="saveMaincontentPopup();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
CKBox.open({handler: 'inline', content: 'ckpopup', style: {padding: '10px'}, size: {x: '900px', y: '550px'}, footerHtml: $boxfooterhtml});
$ck('#ckwaitoverlay').remove();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckShowParamsPopup(showtab) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
bloc = $ck('#body');
bloc.addClass('ckfocus');
var editionarea = $ck('#ckedition');
editionarea.empty().fadeIn();
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxparams&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
expertmode: $ck('#body').hasClass('expert'),
joomlaversion: $ck('#joomlaversion').attr('value')
}
}).done(function(code) {
$ck('#ckedition').append(code);
$ck('#ckwaitoverlay').remove();
ckFillEdition('body');
// loadPreviewAreaStyles('#body');
ckAddEventOnFields(editionarea, 'body');
if (showtab) {
$ck('.ckinterfacesliderlink[tab="' + showtab + '"]').click().mousedown();
}
initBulletlist(); // to render the selected bullet style
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckShowResponsiveEdition() {
// $ck(document.body).append('<div id="ckwaitoverlay"></div>');
blocs = ckGetBlocks();
blocs = JSON.stringify(blocs);
blocs = blocs.replace(/#/g, "|di|");
bloc = $ck('#body');
$ck('#ckedition').empty().fadeIn().addClass('ckwait');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxresponsive&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
blocs: blocs,
htmlcode_responsive: $ck('#htmlcode_responsive').val(),
templateid: TEMPLATEID
}
}).done(function(code) {
// $ck('#ckedition').empty().append(code);
$ck('#ckedition').empty().fadeIn().removeClass('ckwait').append(code);
// $boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveResponsivePopup(\'error404\');CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
// CKBox.open({handler: 'inline', content: 'ckpopup', style: {padding: '10px'}, footerHtml: $boxfooterhtml});
// $ck('#ckwaitoverlay').remove();
ckFillEdition('body');
ckSetResponsiveValues();
ckSwitchResponsive('5', true);
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckSetResponsiveValues() {
var values = $ck('#body').attr('responsivevalues');
if (! values) values = '524,758,950,1024';
values = values.split(',');
$ck('#cktoolbarResponsive .inputbox').each(function(i) {
this.value = values[i];
$ck(this).attr('data-value', values[i]);
});
}
function ckFillEdition(blocid) {
// bloc = $ck(blocid);
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.find('.ckprops').each(function(i, ckprops) {
ckprops = $ck(ckprops);
fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array();
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')) {
ckSetPickercolor(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'))
ckCreateGradientPreview(prefix);
}
if (field.attr('id').indexOf('backgroundcolorstart') != -1) {
prefix = field.attr('id').replace("backgroundcolorstart", "");
if (prefix && $ck('#blocbackgroundcolorstart').attr('value'))
ckCreateGradientPreview(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) {
// for B/C in widgets
ckSaveEdition(blocid, workspace, returnFunc, hide, false, $ck('#popup_editionck'));
}
function ckSaveEdition(blocid, workspace, returnFunc, hide, genCss, editionarea) {
if (! hide) hide = false;
if (! returnFunc) returnFunc = '';
if (! genCss) genCss = ''; // needed for element like table where we have a preview area in the edition
if (!workspace) workspace = null;
editionarea = editionarea ? editionarea : $ck('#ckedition');
var focus = blocid ? $ck('#' + blocid) : $ck('.ckfocus');
$ck('.ckproperty', editionarea).each(function(i, tab) {
tab = $ck(tab);
tabid = tab.attr('id');
// (!$ck('> .' + tabid, focus).length) ? ckCreatePropsForBloc(focus, tabid) : $ck('> .' + tabid, focus).empty();
// focusprop = $ck('> .' + tabid, focus);
// focusprop = $ck('#ckstylescontainer').find('.ckprops[data-id="' + blocid + '"].' + tabid);
var focusprop = ckGetPropsForBloc(blocid, tabid)
ckSaveEditionFields(focusprop, tabid);
fieldslist = ckGetEditionFieldslist(focus, tabid);
focusprop.attr('fieldslist', fieldslist);
});
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
if (focus.hasClass('bannerlogo'))
ckGetPreviewlogo(focus);
if (focus.hasClass('wrapper') && $ck('> .tab_blocstyles', styleswrapper).attr('blocfullwidth') == 1) {
$ck('> .inner', focus).removeClass('tck-container').removeClass('tck-container-fluid');
} else if (focus.hasClass('wrapper')) {
$ck('> .inner', focus).addClass('tck-container');
}
ckToogleWrapperFluid();
ckToggleBootstrap();
// if (genCss) 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();
ckSaveAction();
}
function ckSaveLayoutPopup(layout) {
if (typeof(window['ckBeforeSaveLayoutPopup' + layout]) == 'function') window['ckBeforeSaveLayoutPopup' + layout]();
ckSaveEdition('layout_' + layout + '_html', '', 'ckAfterSaveLayoutPopup' + layout, '', '', $ck('#ckpopup'));
}
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');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxsavecustomcode&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templateid: TEMPLATEID,
templatename: $ck('#name').val(),
customcode: customcode,
customcodeendbody: customcodeendbody
}
}).done(function(code) {
}).fail(function() {
alert(TCK.Text._('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');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxsavecustomcss&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templateid: TEMPLATEID,
templatename: $ck('#name').val(),
customcss: customcss
}
}).done(function(code) {
}).fail(function() {
alert(TCK.Text._('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 = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxsavecustomjs&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templateid: TEMPLATEID,
templatename: $ck('#name').val(),
customjs: customjs
}
}).done(function(code) {
}).fail(function() {
alert(TCK.Text._('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(TCK.Text._('Failed to save Custom Functions'));
});
}*/
function ckGetImageSrc(src) {
if (src.indexOf('http')!= -1) return src;
return URIROOT + '/' + src;
}
function ckGetPreviewlogo(focus) {
var logoimg = $ck('img', focus);
var styleswrapper = ckGetStylesWrapperForBlock(focus.attr('id'));
if ($ck('> .tab_blocstyles', styleswrapper).attr('logoheight'))
logoimg.attr('height', $ck('> .tab_blocstyles', styleswrapper).attr('logoheight'));
if ($ck('> .tab_blocstyles', styleswrapper).attr('logowidth'))
logoimg.attr('width', $ck('> .tab_blocstyles', styleswrapper).attr('logowidth'));
if ($ck('> .tab_blocstyles', styleswrapper).attr('blocbackgroundimageurl')) {
focus.css('background', 'none');
var logosrc = ckGetImageSrc($ck('> .tab_blocstyles', styleswrapper).attr('blocbackgroundimageurl'))
logoimg.attr('src', logosrc);
logoimg.attr('data-src', '/' + $ck('> .tab_blocstyles', styleswrapper).attr('blocbackgroundimageurl').trim('/'));
}
if ($ck('> .tab_logodescstyles', styleswrapper).attr('uselogodescno') && $ck('> .tab_logodescstyles', styleswrapper).attr('uselogodescno') == 'checked') {
focus.find('.bannerlogodesc').hide();
} else {
focus.find('.bannerlogodesc').show();
if ($ck('> .tab_logodescstyles', styleswrapper).attr('logodesctext')) focus.find('.bannerlogodesc').find('> .inner div').text($ck('> .tab_logodescstyles', styleswrapper).attr('logodesctext'));
}
if ($ck('> .tab_blocstyles', styleswrapper).attr('logoaligncenter') && $ck('> .tab_blocstyles', styleswrapper).attr('logoaligncenter') == 'checked') {
focus.attr('ckclass', 'tck-logo-center');
} else if ($ck('> .tab_blocstyles', styleswrapper).attr('logoalignright') && $ck('> .tab_blocstyles', styleswrapper).attr('logoalignright') == 'checked') {
focus.attr('ckclass', 'tck-logo-right');
} else {
focus.attr('ckclass', '');
}
logofieldslist = $ck('> .tab_blocstyles', styleswrapper).attr('fieldslist');
if (logofieldslist.toLowerCase().indexOf('blocwidth') == -1)
logofieldslist += ',blocwidth';
if (logofieldslist.toLowerCase().indexOf('blocheight') == -1)
logofieldslist += ',blocheight';
$ck('> .tab_blocstyles', styleswrapper).attr('fieldslist', logofieldslist);
ckSetTemplateOptions(focus);
ckSaveAction();
}
function ckSetTemplateOptions(focus) {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxSetTemplateOptions&" + CKTOKEN;
$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 ckSaveResponsivePopup() {
ckAddSpinnerIcon($ck('.ckleftpanelheadericon.cksave'));
$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'));
});
});
ckSetReponsiveValues();
ckSaveResponsiveCustomcode();
$ck('#body .ckbloc').each(function() {
$bloc = $ck(this);
$bloc.removeClass('ckmobileediting');
$bloc.find('.ckmobileoverlay').remove();
});
$ck('.ckbloc, .ckrowcontainer', $ck('#body')).each(function(i, bloc) {
ckRemoveEdition(bloc);
});
// $ck('#cktoolbarResponsive').fadeOut();
ckRemoveWorkspaceWidth();
// $ck('.ckcolwidthedition').remove();
$ck('.editorckresponsive').remove();
ckSaveEdition('body');
// $ck('#ckedition').empty().hide();
ckSaveAction();
// $ck('#ckedition').empty().hide();
ckRemoveSpinnerIcon($ck('.ckleftpanelheadericon.cksave'));
}
function ckSetReponsiveValues() {
var values = new Array();
$ck('#cktoolbarResponsive .inputbox').each(function() {
values.push(this.value);
});
values = values.join(',');
$ck('#body').attr('responsivevalues', values);
}
function ckToggleResponsiveCustomCss() {
$ck('#ckresponsivecustomcss').fadeToggle();
}
function ckSaveResponsiveCustomcode() {
if (!$ck('.responsiveCustomcode').length) return;
customcodes = '';
var j = 1;
$ck('.responsiveCustomcode').each(function(i, csscode) {
// editor_customcss_responsive[j].save(); // save the editor to the textarea
var code = $ck(csscode).attr('value').replace(/]/g, "|bbe|");
customcodes += '[resolution'+$ck(csscode).attr('data-resolution')+']=['+code+']';
j++;
});
// new method, store in the field to be saved with the template
$ck('#htmlcode_responsive').val(customcodes);
}
function ckSwitchResponsive(responsiverange, force) {
// var responsiverange = ckGetResponsiveRange();
if (! force) force = false;
// var resolution = parseFloat($ck('#ckresponsive' + responsiverange + 'value').val());
var button = $ck('#ckresponsive' + responsiverange + 'button');
// do nothing if click on the active button
if (button.hasClass('active')) return;
if (button.hasClass('active') && !force) {
ckRemoveWorkspaceWidth();
} else {
$ck('#cktoolbarResponsive .ckbutton').removeClass('active').removeClass('ckbutton-warning');
button.addClass('active').addClass('ckbutton-warning');
ckSetWorkspaceWidth(responsiverange);
}
$ck('.ckbloc, .ckrowcontainer', $ck('#body')).each(function(i, bloc) {
ckAddEdition(bloc);
$ck('> .editorck .isControlResponsive', $ck(bloc)).removeClass('active');
var mobilevalue = $ck(bloc).attr('ckresponsive' + responsiverange) ? $ck(bloc).attr('ckresponsive' + responsiverange) : 'mobile_default';
$ck('> .editorck .isControlResponsive[data-mobile="' + mobilevalue + '"]', $ck(bloc)).addClass('active');
});
}
function ckSetWorkspaceWidth(range) {
var resolution = parseFloat($ck('#responsivevalue' + (range - 1)).val());
var workspace = $ck('#body');
workspace.css('width', resolution + 'px').attr('ckresponsiverange', range).addClass('ckresponsiveactive');
if (range == '5') {
workspace.css('width', '');
}
$ck('#menuck').attr('ckresponsiverange', range).addClass('ckresponsiveactive');
}
function ckRemoveWorkspaceWidth() {
$ck('#cktoolbarResponsive .ckbutton').removeClass('active');
var workspace = $ck('#body');
workspace.css('width','').attr('ckresponsiverange', '').removeClass('ckresponsiveactive');
$ck('#menuck').attr('ckresponsiverange', '').removeClass('ckresponsiveactive');
}
function ckGetResponsiveRange() {
var responsiverange = $ck('#body').attr('ckresponsiverange') ? $ck('#body').attr('ckresponsiverange') : '5';
return responsiverange;
}
function ckToggleResponsive(btn) {
var btn = $ck(btn);
var ckbloc = $ck(btn.parents('.editorck')[0]).parent();
var ckresponsiverange = ckGetResponsiveRange();
$ck('> .editorck .isControlResponsive', ckbloc).removeClass('active');
btn.addClass('active');
ckbloc.attr('ckresponsive' + ckresponsiverange, btn.attr('data-mobile'))
}
function ckGetdefaultwidth(nbmodules) {
var defaultwidths = new Array();
defaultwidth = 100 / parseInt(nbmodules);
for (i = 0; i < nbmodules; i++) {
defaultwidths.push(defaultwidth);
}
return defaultwidths;
}
function ckSaveModulesPopup() {
var editionarea = $ck('#ckedition');
var focus = $ck('.ckfocus');
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(',') : ckGetdefaultwidth(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 ckSaveRowPopup() {
var editionarea = $ck('#ckedition');
var focus = $ck('.ckfocus');
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);
ckCreateRowContainer(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();
ckSaveAction();
}
function ckCreateRowContainer(focus) {
var idbase = focus.attr('id') + 'column';
var containerid = ckGetNewStyleId(idbase);
var newcontainer = $ck('<div class="ckrowcontainer" id="' + idbase + containerid + '"></div>');
focus.find('> .inner').append(newcontainer);
ckMakeRowcontainerSortable(newcontainer);
ckAddControlsOnHover(newcontainer);
}
function ckFixRowContainerBC() {
$ck('.ckrow').each(function() {
$row = $ck(this);
var idbase = $row.attr('id') + 'column';
$row.find('.ckrowcontainer').each(function() {
$col = $ck(this);
if (! $col.attr('id')) {
var containerid = ckGetNewStyleId(idbase);
$col.attr('id', idbase + containerid);
}
});
});
}
function saveMaincontentPopup() {
var editionarea = $ck('#ckedition');
var focus = $ck('.ckfocus');
$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();
ckSaveAction();
}
function updateColumnsWidth() {
var focus = $ck('.ckfocus');
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('#ckedition');
var focus = $ck('.ckfocus');
$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();
ckSaveAction();
}
/*
function getPreviewstylescss(blocid, editionarea, workspace, returnFunc) {
if (!workspace) workspace = $ck('#workspaceck');
if (!editionarea) editionarea = document.body;
var focus = blocid ? $ck('#' + blocid) : $ck('.ckfocus');
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: {
templatename: $ck('#name').attr('value'),
objclass: focus.attr('class'),
ckobjid: focus.attr('id'),
action: 'preview',
customstyles: customstyles,
fields: fields
}
}).done(function(code) {
$ck('> .ckstyle', focus).empty().append(code);
if (CKBLOCCKSTYLESBACKUP != 'undefined') {
CKBLOCCKSTYLESBACKUP = $ck('> .ckstyle', focus).html();
}
if (typeof(window[returnFunc]) == 'function') window[returnFunc]();
ckSaveAction();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}*/
function ckRenderCss(blocid, editionarea, focus, forpreviewarea, returnFunc) {
ckAddSpinnerIcon($ck('.ckleftpanelheadericon.cksave'));
editionarea = editionarea ? editionarea : $ck('#ckedition');
focus = focus ? $ck(focus) : $ck('.ckfocus');
forpreviewarea = forpreviewarea ? forpreviewarea : false; // TODO check if needed
returnFunc = returnFunc ? returnFunc : '';
blocid = blocid ? blocid : focus.attr('id');
if (forpreviewarea) {
blocid = focus.attr('id');
}
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')] = '';
}
}
});
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
$ck('> .ckprops', styleswrapper).each(function(i, ckprops) {
ckprops = $ck(ckprops);
fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array();
for (j=0;j<fieldslist.length;j++) {
fieldname = fieldslist[j];
if (typeof(fields[fieldname]) == 'null' || typeof(fields[fieldname]) == 'undefined')
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);
ckSaveEdition(blocid, '', '', false, false, editionarea);
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxrendercss&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templatename: $ck('#name').attr('value'),
objclass: focus.attr('class'),
ckobjid: blocid,
action: 'preview',
fields: fields,
customstyles: customstyles
}
}).done(function(code) {
if (forpreviewarea) $ck('> .ckstyle', $ck('#' + blocid)).empty().append(code);
// var csscode = code.replace(/\|ID\|/g, '#'+blocid);
// $ck('> .ckstyle', $ck('#' + blocid)).empty().append(csscode);
ckSetStyleForBloc(blocid, code);
if (CKBLOCCKSTYLESBACKUP != 'undefined') {
CKBLOCCKSTYLESBACKUP = code;
}
// $ck('.ckstyle[data-id="' + blocid + '"]', $ck('#ckstylescontainer, #ckelementscontentfavorites #' + blocid)).empty().append(code);
ckRemoveSpinnerIcon($ck('.ckleftpanelheadericon.cksave'));
$ck('#ckparamsfake').empty();
if (typeof(window[returnFunc]) == 'function') window[returnFunc]();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
//function ckCreatePropsForBloc(bloc, tabid) {
// $ck('#ckstylescontainer').prepend('<div class="' + tabid + ' ckprops" />')
//}
//function ckSetPropsForBloc(blocid, csscode) {
// var stylecontainer = ckGetStyleForBloc(blocid, csscode);
// stylecontainer.empty().append(csscode);
//}
function ckAddSpinnerIcon(btn) {
if (! btn.attr('data-class')) var icon = btn.find('.fa').attr('class');
btn.attr('data-class', icon).find('.fa').attr('class', 'fa fa-spinner fa-pulse');
}
function ckRemoveSpinnerIcon(btn) {
btn.find('.fa').attr('class', btn.attr('data-class'));
}
function ckCloseEdition(keepopen) {
if (! keepopen) keepopen = $ck('.ckleftpanel').hasClass('cksticked');
if (typeof ckBeforeCloseEditionPopup == 'function') { ckBeforeCloseEditionPopup(); }
if (! keepopen) $ck('#ckedition').empty().fadeOut();
$ck('.ckfocus').removeClass('ckfocus');
}
function ckLoadTab_menustyles() {
bloc = $ck('#tab_menustyles');
if (bloc.html())
return;
bloc.append('<div id="ckwaitoverlay"></div>');
var blocid = $ck('.ckfocus').attr('id');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxtabmenustyles&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
objclass: bloc.attr('class'),
expertmode: $ck('#body').hasClass('expert')
}
}).done(function(code) {
bloc.empty().append(code);
ckFillEdition(blocid);
ckAddEventOnFields($ck('#ckedition'), blocid, bloc);
// loadPreviewAreaStyles('#' + $ck('.ckfocus').attr('id'));
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckLoadTab_customcode() {
bloc = $ck('#tab_customcode');
var boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="saveCustomCode();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
if (bloc.html()) {
CKBox.open({handler: 'inline', content: 'tab_customcode', footerHtml: boxfooterhtml});
return;
}
bloc.append('<div id="ckwaitoverlay"></div>');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxtabcustomcode&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templateid: TEMPLATEID,
templatename: $ck('#name').val()
}
}).done(function(code) {
bloc.empty().append(code);
CKBox.open({handler: 'inline', content: 'tab_customcode', footerHtml: boxfooterhtml});
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckLoadTab_customcss() {
bloc = $ck('#tab_customcss');
var boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="saveCustomCss();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
if (bloc.html()) {
CKBox.open({handler: 'inline', content: 'tab_customcss', footerHtml: boxfooterhtml});
return;
}
bloc.append('<div id="ckwaitoverlay"></div>');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxtabcustomcss&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templateid: TEMPLATEID,
templatename: $ck('#name').val()
}
}).done(function(code) {
bloc.empty().append(code);
CKBox.open({handler: 'inline', content: 'tab_customcss', footerHtml: boxfooterhtml});
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
/*function ckLoadTab_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(TCK.Text._('CK_FAILED', 'Failed'));
});
}*/
function ckShowLayoutPopup(layout) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxlayout" + layout + "&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templatename: $ck('#name').val()
}
}).done(function(code) {
$ck('#ckpopup').empty().append(code);
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveLayoutPopup(\'error404\');CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
CKBox.open({handler: 'inline', content: 'ckpopup', style: {padding: '10px'}, footerHtml: $boxfooterhtml});
$ck('#ckwaitoverlay').remove();
ckFillEdition('layout_' + layout + '_html');
// loadPreviewAreaStyles('#layout_' + layout + '_html', 'previewarealayout' + layout);
if (typeof(window['ckUpdateLayoutPreview' + layout]) == 'function') window['ckUpdateLayoutPreview' + layout]();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
/* ----------------------------------------------------------------------------------------------------------------------------------------
TEMPLATE CREATION AND PREVIEW
---------------------------------------------------------------------------------------------------------------------------------------------*/
/*
* Create the full template archive
*/
function ckCreateTemplate(action) {
if ($ck('#name').attr('value') == '') {
alert(TCK.Text._('TEMPLATE_MUST_HAVE_NAME', 'You must give a name to the template'));
ckEditGlobalinfos();
$ck('#name').focus();
return;
}
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
var blocs = ckGetBlocks();
blocs = JSON.stringify(blocs);
blocs = blocs.replace(/#/g, "|di|");
var htmlcode = ckMakeHtmlOutput();
// get the widgets list
var widgets = ckGetWidgetsData();
jsonWidgets = JSON.stringify(widgets);
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 positions = [];
$ck('.ckbloc').each(function(i, bloc) {
bloc = $ck(bloc);
if (bloc.attr('isdisabled') == 'true') {
bloc.find('.ckbloc').attr('isdisabled' , 'true');
} else if (bloc.attr('isdisabled') == 'false'){
// bloc.find('.ckbloc').attr('isdisabled' , 'false'); // don't do that else it will force to enable all blocks
}
if (bloc.attr('ckmoduleposition') && bloc.attr('isdisabled') != 'true')
positions.push(bloc.attr('ckmoduleposition'));
});
var customstyles = new Object();
$ck('#ckstylescontainer [data-id^="ckcustomstyle"]').each(function() {
$this = $ck(this);
customstyles[$this.attr('data-id')] = $this.attr('data-cssselector') ? '.' + $this.attr('data-cssselector') : '.' + $this.attr('data-id');
});
customstyles = JSON.stringify(customstyles);
var customslayoutcss = '';
$ck('#ckstylescontainer [data-id^="ckcustomlayout"]').each(function() {
$this = $ck(this);
customslayoutcss += $this.find('style').html();
});
var bodyfontsprops = ckGetPropsForBloc('body', 'googlefonts');
var googlefonts = bodyfontsprops.attr('fontslist') ? bodyfontsprops.attr('fontslist') : '';
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxcreatetemplate&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
bodycode: htmlcode["body"],
headcode: htmlcode["head"].replace(/<\?/g, '|ot|').replace(/\?>/g, '|ct|'),
csscode: htmlcode["css"],
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,
action: action,
widgets: jsonWidgets,
facktoload: facktoload,
column1width: COLUMN1WIDTH,
column2width: COLUMN2WIDTH,
templateid: TEMPLATEID,
templateidentifier: TEMPLATEIDENTIFIER,
htmlcode_responsive: $ck('#htmlcode_responsive').val(),
responsivevalues: $ck('#body').attr('responsivevalues'),
layoutcommentscss: layoutcommentscss,
layouterror404custommessage: layouterror404custommessage,
customstyles: customstyles,
customslayoutcss: customslayoutcss,
positions: positions,
colors: $ck('#body').attr('colorpalette'),
googlefonts: googlefonts
}
}).done(function(code) {
$ck('#ckwaitoverlay').remove();
$ck('#ckpopup').empty().append(code);
CKBox.open({handler: 'inline', content: 'ckpopup', size: {x: '700px'}, style: {padding: '10px'} });
ckAutoCreateThumbs();
if (action == 'install') {
ckInstallTemplate();
}
}).fail(function() {
$ck('#ckwaitoverlay').remove();
$ck('#ckpopup').empty().append(TCK.Text._('CK_LOAD_FAILURE_TEMPLATE_CREATION', 'The template creation encountered some errors'));
});
}
function ckGetBlocks() {
var blocs = new Array();
var cssblocs = new Object();
var i = 0;
$ck('.ckbloc, .ckrowcontainer').each(function(j, bloc) {
bloc = $ck(bloc);
var blocid = bloc.attr('id') ? bloc.attr('id') : bloc.attr('data-id');
if (bloc.attr('isdisabled') == 'true') {
bloc.find('.ckbloc').attr('isdisabled' , 'true');
} else if (bloc.attr('isdisabled') == 'false'){
// bloc.find('.ckbloc').attr('isdisabled' , 'false');
}
if (bloc.attr('isdisabled') != 'true' && blocid) {
var cssblocs = ckGetBlock(bloc, j)
blocs[i] = cssblocs;
i++;
}
});
$ck('#ckstylescontainer [data-id^="ckcustomstyle"], #ckstylescontainer [data-id^="ckcustomlayout"]').each(function(j, bloc) {
bloc = $ck(bloc);
var blocid = bloc.attr('id') ? bloc.attr('id') : bloc.attr('data-id');
if (bloc.attr('isdisabled') != 'true' && blocid) {
var cssblocs = ckGetBlock(bloc, j)
blocs[i] = cssblocs;
i++;
}
});
return blocs;
}
function ckGetBlock(bloc, j) {
var blocid = bloc.attr('id') ? bloc.attr('id') : bloc.attr('data-id');
var cssblocs = new Object();
var fieldslist = new Array();
cssblocs['class'] = bloc.attr('class');
cssblocs['ckid'] = blocid;
// if (bloc.attr('id') == "body" || bloc.attr('id') == "wrapper")
// cssblocs['ckid'] = bloc.attr('id');
cssblocs['ckclass'] = bloc.attr('ckclass') ? bloc.attr('ckclass') : '';
cssblocs['data-class'] = bloc.find('> .inner').attr('data-class') ? bloc.find('> .inner').attr('data-class') : '';
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');
cssblocs['icon'] = bloc.find('.fack').attr('data-type');
cssblocs['iconpos'] = (bloc.find('.fack').attr('data-pos') ? bloc.find('.fack').attr('data-pos') : '');
cssblocs['iconsize'] = (bloc.find('.fack').attr('data-size') ? bloc.find('.fack').attr('data-size') : '');
cssblocs['iconvpos'] = (bloc.find('.fack').attr('data-vpos') ? bloc.find('.fack').attr('data-vpos') : '');
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(",");
var paramslist = bloc.attr('paramslist') ? bloc.attr('paramslist').split(",") : Array();
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
styleswrapper.find('> .ckprops').each(function(i, ckprops) {
ckprops = $ck(ckprops);
fieldslist = ckprops.attr('fieldslist') ? ckprops.attr('fieldslist').split(',') : Array();
for (j=0;j<fieldslist.length;j++) {
fieldname = fieldslist[j];
cssblocs[fieldname] = ckprops.attr(fieldname);
}
});
for (j=0;j<paramslist.length;j++) {
fieldname = paramslist[j];
cssblocs[fieldname] = bloc.attr(fieldname);
}
return cssblocs;
}
/**
*
* Function create htmlcode and folder structure and begin the process
*/
/*
function makeHtmlStep(task) {
blocs = ckGetBlocks();
blocs = JSON.stringify(blocs);
blocs = blocs.replace(/#/g, "|di|");
var htmlcode = ckMakeHtmlOutput();
// 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(TCK.Text._('CK_LOAD_SUCCESS_STEP1', 'Step 1 finished with success'));
makeCssStep(task);
}).fail(function() {
$ck('#packagestep1').empty();
$ck('#packagestep1').append(TCK.Text._('CK_LOAD_FAILURE_STEP1', 'Step 1 encounter some errors'));
});
}*/
/**
*
* Function to generate template.css file
*/
/*function makeCssStep(task) {
blocs = ckGetBlocks();
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(TCK.Text._('CK_LOAD_SUCCESS_STEP_CSS', 'Next step finished with success'));
makeXmlStep(task);
}).fail(function() {
$ck('#packagestepcss').empty();
$ck('#packagestepcss').append(TCK.Text._('CK_LOAD_FAILURE_STEP_CSS', 'Next step encounter some errors'));
});
}*/
/**
*
* Function to generate XML file
*/
/*function makeXmlStep(task) {
blocs = ckGetBlocks();
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(TCK.Text._('CK_LOAD_SUCCESS_STEP_XML', 'Next step finished with success'));
if (task == 'package' || task == 'copy') {
makeArchiveStep(task);
} else if (task == 'install') {
ckInstallTemplate();
} else {
makePreviewStep();
}
}).fail(function() {
$ck('#packagestepxml').empty();
$ck('#packagestepxml').append(TCK.Text._('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 = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxAutoCreateThumbs&" + CKTOKEN;
$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">' + TCK.Text._('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(TCK.Text._('CK_LOAD_FAILURE_STEP_ARCHIVE', 'Archive encounter some errors'));
});
}*/
function ckInstallTemplate() {
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxinstalltemplate&" + CKTOKEN;
$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('#ckpopup').prepend(msg); // mettre le message dans la fenetre avec toues les autres messages
if (response.result == 'true') {
// change the install button to copy
$ck('#ckmenuinstalltemplate').hide();
$ck('#ckmenucopytemplate').show();
}
}).fail(function() {
alert('Failed : Template installation');
});
}
/**
*
* Function to generate final html code
*/
function ckMakeHtmlOutput() {
var code = new Array('head', 'body');
var video = ckGetVideoCode($ck('#body'));
code['head'] = '';
code['body'] = '' + video["code"];
code['css'] = '';
var j = 0;
var wrappercondition = false;
iW = 0; // index for wrappers
$ck('.wrapper.ckbloc, .wrapper > .inner > .ckbloc').each(function(i, bloc) {
bloc = $ck(bloc);
var retrievecode = '';
// Begin the modules code construction
codetmp = ckGetBlockHtml(bloc, j, 0);
code['body'] += codetmp['body'];
code['head'] += codetmp['head'];
code['css'] += codetmp['css'];
// construct a wrapper
if (bloc.hasClass('wrapper')) {
retrievecode = ckMakeWrapper(bloc, 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 ckGetBlockHtml(bloc, j, nbtabs) {
if (! nbtabs) nbtabs = 0;
var retrievecode = new Array('head', 'body', 'css');
retrievecode['head'] = '';
retrievecode['body'] = '';
retrievecode['css'] = '';
// construct single module code
if (bloc.hasClass('singlemodule') || bloc.hasClass('module')) {
retrievecode = ckMakeHtmlSingleModule(bloc, nbtabs);
}
// construct row code
if (bloc.hasClass('ckrow')) {
retrievecode = ckMakeHtmlRow(bloc, j, nbtabs);
}
// construct logo code
if (bloc.hasClass('logobloc')) {
retrievecode = ckMakeHtmlLogo(bloc, nbtabs);
}
// construct flexible module code
if (bloc.hasClass('flexiblemodules')) {
retrievecode = ckMakeHtmlFlexibleModules(bloc, j, nbtabs);
}
// construct banner and logo block code
if (bloc.hasClass('mainbanner') && !$ck('.bannermenu', bloc).length) {
retrievecode = ckMakeHtmlOldBanner(bloc, nbtabs);
} else if (bloc.hasClass('mainbanner') && $ck('.bannermenu', bloc).length) {
retrievecode = ckMakeHtmlBanner(bloc, nbtabs);
}
// construct horizontal menu code
if (bloc.hasClass('horiznav')) {
retrievecode = ckMakeHtmlHorizNav(bloc, nbtabs);
}
// construct custom block code
if (bloc.hasClass('custombloc')) {
var customcode = $ck('div.customcont', bloc).text().replace(/#/g, "|di|");
retrievecode['body'] += '|tab|<div id="' + bloc.attr('id') + '" class="' + bloc.attr('ckclass') + '">|rr|'
+ '|tab||tab|<div class="inner">' + customcode + '</div>|rr|'
+ '|tab|</div>|rr|';
}
if (bloc.hasClass('emptybloc')) {
retrievecode['body'] += '|tab|<div id="' + bloc.attr('id') + '" class="' + bloc.attr('ckclass') + '">|rr|'
+ '|tab|</div>|rr|';
}
// construct complex component layout code
var hidemaincontent = ckGetPropsForBloc('body', 'tab_blocstyles');
hidemaincontent = hidemaincontent.attr('blochidefrontpage') ? hidemaincontent.attr('blochidefrontpage') : '0';
if (bloc.hasClass('maincontent')) {
retrievecode = ckMakeHtmlMaincontent(bloc, j, nbtabs);
if (hidemaincontent == '1') {
retrievecode['body'] = '|tab|<?php if(! $siteHome) { ?>|rr|' + retrievecode['body'] + '|tab|<?php } ?>|rr|';
}
}
if (! retrievecode['css']) retrievecode['css'] = '';
return retrievecode;
}
/***********************************************
* modules html creation *
* *********************************************/
function ckAddVideoBackground(bloc) {
var blocprops = ckGetPropsForBloc(bloc.attr('id'), 'tab_videobgstyles');
var webmurl = blocprops.attr('blocvideourlwebm') ? blocprops.attr('blocvideourlwebm') : '';
var mp4url = blocprops.attr('blocvideourlmp4') ? blocprops.attr('blocvideourlmp4') : '';
var ogvurl = blocprops.attr('blocvideourlogv') ? blocprops.attr('blocvideourlogv') : '';
var muted = (blocprops.attr('blocvideomuted1') && blocprops.attr('blocvideomuted1') == 'checked') ? '' : ' muted';
var videocode = '|tab||tab|<video autoplay playsinline 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 ckCheckVideoBackground(bloc) {
var blocprops = ckGetPropsForBloc(bloc.attr('id'), 'tab_videobgstyles');
if (blocprops.length
&& (
blocprops.attr('blocvideourlmp4')
|| blocprops.attr('blocvideourlwebm')
|| blocprops.attr('blocvideourlogv')
)
)
return true;
return false;
}
function ckGetVideoCode(bloc) {
var video = new Array();
video['code'] = '';
video['class'] = '';
if (ckCheckVideoBackground(bloc)) {
video['code'] = ckAddVideoBackground(bloc);
video['class'] = ' hasvideobackground';
}
return video;
}
function ckGetIconAttribs(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') ? bloc.find('.fack').attr('data-pos') : '') + '"';
var iconsize = ' iconsize="' + (bloc.find('.fack').attr('data-size') ? bloc.find('.fack').attr('data-size') : '') + '"';
var iconvpos = ' iconvpos="' + (bloc.find('.fack').attr('data-vpos') ? 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("') || CKCOUNTMODULE('");
conditions = "CKCOUNTMODULE('" + conditions + "') || $tckedition";
return conditions;
}
function ckGetShapeDividerHtml(bloc) {
var html = '';
bloc.find('> .tck-divider-container').each(function() {
html += $ck(this)[0].outerHTML;
});
return html;
}
/**
* Function to render a wrapper
*
*/
function ckMakeWrapper(bloc,iW, wrappercondition) {
var code = new Array("head", "body");
code['head'] = '';
code['body'] = '';
// code["wrappercondition"] = wrappercondition;
var video = ckGetVideoCode(bloc);
var blocid = bloc.attr('id');
var blocclass = ckGetBlocClass(bloc, true);
blocclass += video["class"];
blocclass = blocclass ? ' class="tck-wrapper ' + blocclass + '"' : ' class="tck-wrapper"';
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;
}
var wrapperinnerclass = $ck('.inner', bloc).hasClass('tck-container') || $ck('.inner', bloc).hasClass('tck-container-fluid') ? $ck('.inner', bloc).attr('class').replace('ui-sortable', '') : $ck('.inner', bloc).attr('class').replace('ui-sortable', '').replace('container', 'tck-container');
// since 4.0.19
wrapperinnerclass = wrapperinnerclass.replace('tck-container-fluid', 'tck-container');
// fix problems
$ck('.inner', bloc).removeClass('tck-').removeClass('-fluid');
wrapperinnerclasses = wrapperinnerclass.split(' ');
for(var i = 0; i < wrapperinnerclasses.length; i++) {
if (wrapperinnerclasses[i] === 'container'
|| wrapperinnerclasses[i] === 'container-fluid'
) {
wrapperinnerclasses.splice(i, 1);
}
}
wrapperinnerclass = wrapperinnerclasses.join(' ');
// var shapedivider = bloc.find('> .tck-divider-container').length ? bloc.find('> .tck-divider-container')[0].outerHTML : '';
var shapedivider = ckGetShapeDividerHtml(bloc);
if (iW == 0) {
if (code['wrappercondition'] == true) {
code['body'] += '<?php if(' + conditions + ') : ?>|rr|';
}
code['body'] += '<div id="' + blocid + '"' + blocclass + '>|rr|'
+ shapedivider
+ video['code']
+ '|tab|<div class="' + wrapperinnerclass +'">|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 id="' + blocid +'"' + blocclass + '>|rr|'
+ shapedivider
+ video['code']
+ '|tab|<div class="' + wrapperinnerclass + video["class"] +'">|rr|';
}
// code['body'] += video['code'];
return code;
}
/**
* Function to render some flexible modules
*
*/
function ckMakeHtmlRow(bloc, j, nbtabs) {
// initialisation
bloc = $ck(bloc);
var code = new Array('head', 'body', 'css');
code['head'] = '';
code['body'] = '';
code['css'] = '';
var video = ckGetVideoCode(bloc);
// var blocclass = bloc.attr('data-class') ? ' class="clearfix ' + bloc.attr("data-class") + '"' : ' class="clearfix"';
var rowclass = ckGetBlocClass(bloc, false, 'tck-row');
var rowinnerclass = ckGetBlocInnerClass(bloc, true);
// var shapedivider = bloc.find('> .tck-divider-container').length ? bloc.find('> .tck-divider-container')[0].outerHTML : '';
var shapedivider = ckGetShapeDividerHtml(bloc);
// singlemodule, horiznav, flexiblemodule
var conditions = false;
if (! bloc.find('.logobloc, .emptybloc, .custombloc').length) {
var childrenPositions = getChildrenBlocksPositions(bloc);
if (childrenPositions.length) {
conditions = makeChildrenBlocksConditions(childrenPositions);
}
}
if (conditions !== false) code['body'] += '|tab|<?php if (' + conditions + ') : ?>|rr|'
code['body'] += '|tab|<section id="' + bloc.attr('id') + '" ' + rowclass + '>|rr|'
+ shapedivider
+ '|tab||tab|<div class="inner clearfix' + rowinnerclass + video["class"] +'">|rr|';
code['body'] += video['code'];
$ck('.ckrowcontainer', bloc).each(function(i, container) {
container = $ck(container);
var columnid = container.attr('id') ? ' id="' + container.attr('id') + '"' : '';
var columnclass = ckGetBlocClass(container, true);
var columnwidth = container.attr('data-real-width') ? container.attr('data-real-width') : container.attr('data-width') + '%';
code['css'] += '#' + container.attr('id') + ' { width: ' + columnwidth + '; }' + "\n\n";
code['body'] += '|tab||tab||tab|<div class="flexiblecolumn ' + columnclass + '"' + columnid + '>|rr|';
$ck('.ckbloc', container).each(function(i, module) {
module = $ck(module);
// var modulemoduleposition = ckGetBlocModulePosition(module);
// var moduleclass = ckGetBlocClass(bloc);
// var moduleinnerclass = ckGetBlocInnerClass(bloc, true);
// 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") + '"' : ',';
// module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : '';
var tmpcode = ckGetBlockHtml(module, j+'r'+i, 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|'
if (conditions !== false) code['body'] += '|tab|<?php endif; ?>|rr||rr|';
return code;
}
function ckGetBlocModulePosition(bloc) {
return bloc.attr('ckmoduleposition') ? bloc.attr('ckmoduleposition') : '';
}
function ckGetBlocClass(bloc, withouthtml, additionalclass) {
if (! withouthtml) withouthtml = false;
if (! additionalclass) additionalclass = '';
var blocclass = bloc.attr('ckclass') ? bloc.attr('ckclass') : '';
if (withouthtml) {
return blocclass + ((additionalclass && blocclass) ? ' ' + additionalclass : additionalclass);
} else {
if (blocclass || additionalclass) blocclass = ' class="' + blocclass + ((additionalclass && blocclass) ? ' ' + additionalclass : additionalclass) + '"';
}
return blocclass;
}
function ckGetBlocInnerClass(bloc, withouthtml) {
if (! withouthtml) withouthtml = false;
var blocclass = bloc.find('> .inner').attr('data-class') ? bloc.find('> .inner').attr('data-class') : '';
if (withouthtml) {
return blocclass ? ' ' + blocclass : '';
} else {
if (blocclass) blocclass = ' class="' + blocclass + '"';
}
return blocclass;
}
/**
* Render a single module
*
*/
function ckMakeHtmlSingleModule(bloc, nbtabs) {
var code = new Array('head', 'body');
code['head'] = '';
code['body'] = '';
var video = ckGetVideoCode(bloc);
var offsettabs = ckStrRepeat('|tab|', nbtabs);
var bloctag = (bloc[0] == $ck('.ckbloc').last()[0] ? 'footer' : 'div');
var blocmoduleposition = ckGetBlocModulePosition(bloc);
var blocclass = ckGetBlocClass(bloc, false, '');
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
code['body'] = offsettabs + '|tab|<?php if (CKCOUNTMODULE(\'' + blocmoduleposition + '\') || $tckedition) : ?>|rr|'
+ offsettabs + '|tab|<'+bloctag+' id="' + bloc.attr('id') + '" ' + blocclass + '>|rr|'
+ offsettabs + '|tab||tab|<div class="inner clearfix' + video['class'] + blocinnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + blocmoduleposition + '">|rr|'
+ offsettabs + video['code']
+ offsettabs + '|tab||tab||tab|CKLOADMODULE(' + blocmoduleposition + ',' + ckGetIconAttribs(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 ckMakeHtmlFlexibleModules(bloc, j, nbtabs) {
// initialisation
bloc = $ck(bloc);
var code = new Array('head', 'body');
code['head'] = '';
code['body'] = '';
var video = ckGetVideoCode(bloc);
var offsettabs = ckStrRepeat('|tab|', nbtabs);
var blocclass = ckGetBlocClass(bloc, false, 'tck-modules');
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
code['body'] += offsettabs + '|tab|<?php if ($nbmodules' + j + ' || $tckedition) : ?>|rr|'
+ offsettabs + '|tab|<section id="' + bloc.attr('id') + '" ' + blocclass + '>|rr|'
+ offsettabs + '|tab||tab|<div class="inner clearfix' + blocinnerclass + 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 = ckGetVideoCode(module);
// retrieve data for the block
var modulemoduleposition = ckGetBlocModulePosition(module);
var moduleclass = ckGetBlocClass(module, true);
var moduleinnerclass = ckGetBlocInnerClass(module, true);
code['body'] += offsettabs + '|tab||tab||tab|<?php if (CKCOUNTMODULE(\'' + modulemoduleposition + '\') || $tckedition) : ?>|rr|'
+ offsettabs + '|tab||tab||tab|<div id="' + module.attr('id') + '"' + ' class="flexiblemodule ' + moduleclass + '">|rr|'
+ offsettabs + '|tab||tab||tab||tab|<div class="inner clearfix' + moduleinnerclass + video['class'] + ' <?php echo $tckeditionclass ?>" data-position="' + modulemoduleposition + '">|rr|'
+ offsettabs + video['code']
+ offsettabs + '|tab||tab||tab||tab||tab|CKLOADMODULE(' + modulemoduleposition + ',' + ckGetIconAttribs(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)CKCOUNTMODULE(\'' + modulemoduleposition + '\')';
}
});
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 ckMakeHtmlLogo(bloc, nbtabs) {
// initialisation
var code = new Array('head', 'body');
code['head'] = '';
code['body'] = '';
var offsettabs = ckStrRepeat('|tab|', nbtabs);
// retrieve data for the block
var blocid = bloc.attr('id');
var blocclass = ckGetBlocClass(bloc, false, 'tck-logo');
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
var blocprops = ckGetPropsForBloc(blocid, 'tab_blocstyles')
bloc.logoimage = $ck('img', bloc) ? $ck('img', bloc).attr('src').split("/").reverse()[0] : '';
bloc.logowidth = blocprops.attr("logowidth") ? ' width="<?php echo CKGETOPTION(\''+bloc.attr("id")+'_logowidth\', \'' + ckTestUnit(blocprops.attr("logowidth")) + '\') ?>"' : '';
bloc.logoheight = blocprops.attr("logoheight") ? ' height="<?php echo CKGETOPTION(\''+bloc.attr("id")+'_logoheight\', \'' + ckTestUnit(blocprops.attr("logoheight")) + '\') ?>"' : '';
var logodesc = $ck('> .inner > .bannerlogodesc', bloc);
var logodesccode = '';
if (logodesc.length) {
logodesccode = offsettabs + '|tab||tab||tab|<?php if (CKGETOPTION(\'' + blocid + '_logodescription\')) { ?>|rr|'
+ offsettabs + '|tab||tab||tab|<div class="bannerlogodesc">|rr|'
+ offsettabs + '|tab||tab||tab||tab|<div class="inner clearfix"><?php echo htmlspecialchars(CKGETOPTION(\'' + blocid + '_logodescription\'));?></div>|rr|'
+ offsettabs + '|tab||tab||tab|</div>|rr|'
+ offsettabs + '|tab||tab||tab|<?php } ?>|rr|';
}
code['body'] += offsettabs + '|tab|<div id="' + blocid + '"' + blocclass + '>|rr|'
+ offsettabs + '|tab||tab|<div class="inner clearfix' + blocinnerclass + '">|rr|'
+ offsettabs + '|tab||tab||tab|<?php if (CKGETOPTION(\'' + blocid + '_logolink\')) { ?>|rr|'
+ offsettabs + '|tab||tab||tab|<a href="<?php echo htmlspecialchars(CKGETOPTION(\'' + blocid + '_logolink\')); ?>">|rr|'
+ offsettabs + '|tab||tab||tab|<?php } ?>|rr|'
+ offsettabs + '|tab||tab||tab||tab|<img class="tck-logo-img" src="<?php echo CKGETOPTION(\'' + blocid + '_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + bloc.logoimage + '\') ?>"' + bloc.logowidth + bloc.logoheight + ' alt="<?php echo htmlspecialchars(CKGETOPTION(\'' + blocid + '_logotitle\',\'\'));?>" />|rr|'
+ offsettabs + '|tab||tab||tab|<?php if (CKGETOPTION(\'' + blocid + '_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 ckMakeHtmlBanner(bloc, blocid, blocclass, task, nbtabs) {
// initialisation
var code = new Array("head", "body");
code['head'] = '';
code['body'] = '';
var video = ckGetVideoCode(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
var modulemoduleposition = ckGetBlocModulePosition(module);
var moduleid = module.attr('id');
var moduleclass = ckGetBlocClass(module);
var moduleinnerclass = ckGetBlocInnerClass(module, true);
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 CKGETOPTION(\''+module.attr("id")+'_logowidth\', \'' + ckTestUnit($ck('.tab_blocstyles', module).attr("logowidth")) + '\') ?>"' : '';
module.logoheight = $ck('.tab_blocstyles', module).attr("logoheight") ? ' height="<?php echo CKGETOPTION(\''+module.attr("id")+'_logoheight\', \'' + ckTestUnit($ck('.tab_blocstyles', module).attr("logoheight")) + '\') ?>"' : '';
logodesc = $ck('> .inner > .bannerlogodesc', module);
logodesccode = '';
if (logodesc.length) {
logodesccode = '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\''+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(CKGETOPTION(\''+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' + moduleid + moduleclass + '>|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix' + moduleinnerclass + '">|rr|'
+ '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\''+ moduleid +'_logolink\')) { ?>|rr|'
+ '|tab||tab||tab||tab||tab|<a href="<?php echo htmlspecialchars(CKGETOPTION(\''+moduleid+'_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(CKGETOPTION(\''+moduleid+'_logotitle\',\'\'));?>" />|rr|' : '|tab||tab||tab||tab||tab||tab|<img src="<?php echo CKGETOPTION(\''+moduleid+'_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + module.logoimage + '\') ?>"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars(CKGETOPTION(\''+moduleid+'_logotitle\',\'\'));?>" />|rr|')
+ '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\''+moduleid+'_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 (CKCOUNTMODULE(\'' + modulemoduleposition + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab|<div' + moduleid + moduleclass + '>|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix' + moduleinnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + modulemoduleposition + '">|rr|';
if (module.hasClass('bannermenu')) {
code['body'] += '|tab||tab||tab||tab|<label for="' + moduleid + '-mobileck" class="mobileckhambuger_togglerlabel" style="display:none;">≡</label>|rr|'
+ '|tab||tab||tab||tab|<input id="' + moduleid + '-mobileck" class="mobileckhambuger_toggler" type="checkbox" style="display:none;"/>|rr|'
}
code['body'] += '|tab||tab||tab||tab||tab|CKLOADMODULE(' + modulemoduleposition + ',' + ckGetIconAttribs(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 ckMakeHtmlOldBanner(bloc, task) {
// initialisation
var code = new Array('head', 'body');
code['head'] = '';
code['body'] = '';
var blocclass = ckGetBlocClass(bloc);
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
code['body'] += '|tab|<header' + blocid + blocclass + '>|rr|'
+ '|tab||tab|<div class="inner clearfix' + blocinnerclass + '">|rr|';
$ck('.ckbloc', bloc).each(function(i, module) {
module = $ck(module);
// retrieve data for the block
var modulemoduleposition = ckGetBlocModulePosition(module);
var moduleid = module.attr('id');
var moduleclass = ckGetBlocClass(module);
var moduleinnerclass = ckGetBlocInnerClass(module, true);
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 CKGETOPTION(\''+module.attr("id")+'_logowidth\', \'' + ckTestUnit($ck('.tab_blocstyles', module).attr("logowidth")) + '\') ?>"' : '';
module.logoheight = $ck('.tab_blocstyles', module).attr("logoheight") ? ' height="<?php echo CKGETOPTION(\''+module.attr("id")+'_logoheight\', \'' + ckTestUnit($ck('.tab_blocstyles', module).attr("logoheight")) + '\') ?>"' : '';
logodesc = $ck('> .inner > .bannerlogodesc', module);
logodesccode = '';
if (logodesc.length) {
logodesccode = '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\'logodescription\')) { ?>|rr|'
+ '|tab||tab||tab||tab||tab|<div class="bannerlogodesc">|rr|'
+ '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix"><?php echo htmlspecialchars(CKGETOPTION(\'logodescription\'));?></div>|rr|'
+ '|tab||tab||tab||tab||tab|</div>|rr|'
+ '|tab||tab||tab||tab||tab|<?php } ?>|rr|';
}
code['body'] += '|tab||tab||tab|<div id="' + moduleid + '" ' + moduleclass + '>|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix' + moduleinnerclass + '">|rr|'
+ '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\'' + moduleid + '_logolink\')) { ?>|rr|'
+ '|tab||tab||tab||tab||tab|<a href="<?php echo htmlspecialchars(CKGETOPTION(\''+ moduleid +'_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(CKGETOPTION(\''+ moduleid +'_logotitle\',\'\'));?>" />|rr|' : '|tab||tab||tab||tab||tab||tab|<img src="<?php echo CKGETOPTION(\''+ moduleid +'_logoimgsrc\', $this->baseurl . \'/templates/\' . $this->template . \'/images/' + module.logoimage + '\') ?>"' + module.logowidth + module.logoheight + ' alt="<?php echo htmlspecialchars(CKGETOPTION(\''+ moduleid +'_logotitle\',\'\'));?>" />|rr|')
+ '|tab||tab||tab||tab||tab|<?php if (CKGETOPTION(\''+ moduleid +'_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 (CKCOUNTMODULE(\'' + modulemoduleposition + '\')) : ?>|rr|'
+ '|tab||tab||tab|<div' + moduleid + moduleclass + '>|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix">|rr|'
+ '|tab||tab||tab||tab||tab|CKLOADMODULE(' + modulemoduleposition + ',' + ckGetIconAttribs(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 ckMakeHtmlHorizNav(bloc, nbtabs) {
// initialisation
var code = new Array('head', 'body');
code['head'] = '';
code['body'] = '';
var blocmoduleposition = ckGetBlocModulePosition(bloc);
var blocclass = ckGetBlocClass(bloc);
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
var needHamburger =false;
for (var i = 1; i <= 5; i++) {
if (bloc.attr('ckresponsive' + i) == 'mobile_hamburger')
needHamburger = true;
}
var offsettabs = ckStrRepeat('|tab|', nbtabs);
code['body'] = offsettabs + '|tab|<?php if (CKCOUNTMODULEMENU(\'' + blocmoduleposition + '\') || $tckedition) : ?>|rr|'
+ offsettabs + '|tab|<nav id="' + bloc.attr('id') + '"' + blocclass + '>|rr|'
+ offsettabs + '|tab||tab|<div class="inner clearfix' + blocinnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + blocmoduleposition + '">|rr|';
if (needHamburger) {
code['body'] += 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|';
}
code['body'] += offsettabs + '|tab||tab||tab|CKLOADMODULEMENU(' + blocmoduleposition + ',' + ckGetIconAttribs(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 ckMakeHtmlMaincontent(bloc, j, 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
var blocclass = ckGetBlocClass(bloc, true);
var blocinnerclass = ckGetBlocInnerClass(bloc, true);
// begin the global container
code['body'] += '|tab|<div id="' + bloc.attr('id') + '" class="maincontent ' + blocclass + '<?php echo $mainclass ?>">|rr|'
+ '|tab||tab|<div class="inner clearfix' + blocinnerclass + '">|rr|';
column1enabled = 1;
column1 = '';
column2enabled = 1;
column2 = '';
$ck('.ckbloc', bloc).each(function(i, column) {
column = $ck(column);
var columnid = column.attr('id');
var columnmoduleposition = ckGetBlocModulePosition(column);
var columnclass = ckGetBlocClass(column, true);
var columninnerclass = ckGetBlocInnerClass(column, true);
// 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") + '"' : ',';
// 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 (CKCOUNTMODULE(\'' + column1.join('\') || CKCOUNTMODULE(\'') + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab|<aside id="' + columnid + '" class="column column1' + columnclass + '">|rr|'
+ '|tab||tab||tab||tab|<?php if (CKCOUNTMODULE(\'' + columnmoduleposition + '\')) : ?>|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix' + columninnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + columnmoduleposition + '">|rr|'
+ '|tab||tab||tab||tab||tab|CKLOADMODULE(' + columnmoduleposition + ',' + ckGetIconAttribs(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);
// var moduleid = module.attr('id');
// var modulemoduleposition = ckGetBlocModulePosition(module);
// var moduleclass = ckGetBlocClass(module, true);
// var moduleinnerclass = ckGetBlocInnerClass(module, true);
// 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") + '"' : ',';
// module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : '';
var tmpcode = ckGetBlockHtml(module,j + 'mc' + jj, 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 id="' + columnid + '" class="column main row-fluid' + columnclass + '">|rr|'
+ '|tab||tab||tab||tab|<div class="inner clearfix' + columninnerclass + '">|rr|';
// look for sub columns
$ck('.ckbloc', column).each(function(h, subcolumn) {
subcolumn = $ck(subcolumn);
var subcolumnid = subcolumn.attr('id');
var subcolumnmoduleposition = ckGetBlocModulePosition(subcolumn);
var subcolumnclass = ckGetBlocClass(subcolumn);
var subcolumninnerclass = ckGetBlocInnerClass(subcolumn, true);
// 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") + '"' : ',';
// 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 (CKCOUNTMODULE(\'' + 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|CKLOADMODULE(' + 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") + '"' : ',';
// module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : '';
// module.jdocstyle = module.attr("ckmodulestyle") ? ' style="' + module.attr("ckmodulestyle") + '"' : ',';
var tmpcode = ckGetBlockHtml(module, j + 'mc' + jj, 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 (CKCOUNTMODULE(\'' + subcolumnmoduleposition + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab||tab||tab|<div id="' + subcolumnid + '" ' + subcolumnclass + '>|rr|'
+ '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix' + subcolumninnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + subcolumnmoduleposition + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab|CKLOADMODULE(' + subcolumnmoduleposition + ',' + ckGetIconAttribs(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 id="' + subcolumnid + '" class="maincenter ' + columnclass + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab|<div class="inner clearfix' + subcolumninnerclass + '">|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") + '"' : ',';
// centercolumn.jdocposition = centercolumn.attr("ckmoduleposition") ? centercolumn.attr("ckmoduleposition") : '';
var centercolumnid = centercolumn.attr('id');
var centercolumnmoduleposition = ckGetBlocModulePosition(centercolumn);
var centercolumnclass = ckGetBlocClass(centercolumn, true);
var centercolumninnerclass = ckGetBlocInnerClass(centercolumn, true);
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 (CKCOUNTMODULE(\'' + column2.join('\') || CKCOUNTMODULE(\'') + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab|<aside id="' + centercolumn.attr('id') + '" class="column column2' + centercolumnclass + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab|<?php if (CKCOUNTMODULE(\'' + centercolumnmoduleposition + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix' + centercolumninnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + centercolumnmoduleposition + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab||tab|CKLOADMODULE(' + centercolumnmoduleposition + ',' + ckGetIconAttribs(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") + '"' : ',';
// module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : '';
var tmpcode = ckGetBlockHtml(module, j + 'mc' + jj, 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 id="' + centercolumnid + '" class="column center ' + centercolumnclass + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner' + centercolumninnerclass + '">|rr|';
// look for sub blocks
$ck('.ckbloc', centercolumn).each(function(f, centerbloc) {
centerbloc = $ck(centerbloc);
var centerblocid = centerbloc.attr('id');
var centerblocmoduleposition = ckGetBlocModulePosition(centerbloc);
var centerblocclass = ckGetBlocClass(centerbloc);
var centerblocinnerclass = ckGetBlocInnerClass(centerbloc, true);
// 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") + '"' : ',';
// 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 (CKCOUNTMODULE(\'' + 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|CKLOADMODULE(' + 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") + '"' : ',';
// module.jdocposition = module.attr("ckmoduleposition") ? module.attr("ckmoduleposition") : '';
var tmpcode = ckGetBlockHtml(module, j + 'mc' + jj, 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 (CKCOUNTMODULE(\'' + centerblocmoduleposition + '\') || $tckedition) : ?>|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab||tab|<div id="' + centerblocid + '" class="' + centerblocclass + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix' + centerblocinnerclass + ' <?php echo $tckeditionclass ?>" data-position="' + centerblocmoduleposition + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|CKLOADMODULE(' + centerblocmoduleposition + ',' + ckGetIconAttribs(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 id="' + centerblocid + '" class="' + centerblocclass + '">|rr|'
+ '|tab||tab||tab||tab||tab||tab||tab||tab||tab||tab|<div class="inner clearfix' + centerblocinnerclass + '">|rr|';
code["body"] += '|BODYCODE|';
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 (!CKCOUNTMODULE(\'' + column1.join('\') && !CKCOUNTMODULE(\'') + '\') && ! $tckedition) { $mainclass .= " noleft";}|rr|';
} else {
code["head"] += '$mainclass .= " noleft";|rr|';
}
if (column2enabled == 1) {
code["head"] += 'if (!CKCOUNTMODULE(\'' + column2.join('\') && !CKCOUNTMODULE(\'') + '\') && ! $tckedition) { $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 ckTestUnit(value, defaultunit) {
if (!defaultunit) defaultunit = "px";
if (value.toLowerCase().indexOf('px') > -1
|| value.toLowerCase().indexOf('em') > -1
|| value.toLowerCase().indexOf('%') > -1
|| value.toLowerCase().indexOf('rem') > -1
|| value.toLowerCase().indexOf('vh') > -1
|| value.toLowerCase().indexOf('vw') > -1
)
return value;
return value + defaultunit;
}
function ckSelectFaIcon(iconclass) {
ckSetFaIconPosition(iconclass);
ckSetFaIconSize();
// $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 ckRemoveFaIcon(fromicon) {
$ck(fromicon).remove();
}
function ckSetFaIconPosition(iconclass) {
var focus = $ck('.ckfocus');
if (! focus.find('span.fack').length && ! iconclass) return;
if (! iconclass) iconclass = focus.find('span.fack .fa').attr('class').replace('fack', '');
focus.find('span.fack').remove();
switch ($ck('input[name="iconiconposition"]:checked').val()) {
default:
case 'left':
focus.find('h3').prepend('<span class="fack" data-pos="left" data-type="' + iconclass + '" style="display:inline-block;"><span class="' + iconclass + '"></span></span>');
break;
case 'top':
focus.find('h3').prepend('<span class="fack" data-pos="top" data-type="' + iconclass + '" style="display:block;"><span class="' + iconclass + '"></span></span>');
break;
case 'right':
focus.find('h3').append('<span class="fack" data-pos="right" data-type="' + iconclass + '" style="display:inline-block;"><span class="' + iconclass + '"></span></span>');
break;
case 'bottom':
focus.find('h3').append('<span class="fack" data-pos="bottom" data-type="' + iconclass + '" style="display:block;"><span class="' + iconclass + '"></span></span>');
break;
}
}
function ckSetFaIconSize() {
var focus = $ck('.ckfocus');
if (! focus.find('span.fack').length) return;
var icon = focus.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);
focus.find('span.fack').attr('data-size', iconsize);
}
}
function ckSetFaIconVPosition() {
var focus = $ck('.ckfocus');
if (! focus.find('span.fack').length) return;
var icon = focus.find('span.fack .fa');
var iconVPos = $ck('input[name="iconiconvposition"]:checked').val();
icon.css('vertical-align', '');
if (iconVPos != 'default') {
icon.css('vertical-align', iconVPos);
focus.find('span.fack').attr('data-vpos', iconVPos);
} else {
focus.find('span.fack').attr('data-vpos', '');
}
}
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 ckSaveAction() {
myObject.i++;
var y=myObject.i;
var x=document.getElementById('ckhtmlcontainer').innerHTML;
store_text[y]=x;
}
function undo() {
if ((myObject2.i)<(myObject.i)) {
myObject2.i++;
} else {
alert(TCK.Text._('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('ckhtmlcontainer').innerHTML=store_text[z];
} else {
document.getElementById('ckhtmlcontainer').innerHTML=store_text[0];
}
ckInitInterface();
}
function redo() {
if((myObject2.i)>=1) {
myObject2.i--;
} else {
alert(TCK.Text._('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('ckhtmlcontainer').innerHTML=store_text[z];
} else {
document.getElementById('ckhtmlcontainer').innerHTML=store_text[0];
}
ckInitInterface();
}*/
/******* Undo and Redo actions *************/
var ckActionsCounter=new Object();
ckActionsCounter=0;
var ckActionsPointer=new Object();
ckActionsPointer=0;
var ckDoActionsList=new Array();
//ckDoActionsList[0] store initial textarea value
//ckDoActionsList[0]="";
function ckSaveAction() {
ckActionsCounter++;
var y=ckActionsCounter;
var x=document.getElementById('ckhtmlcontainer').innerHTML;
ckDoActionsList[y]=x;
$ck('#ckundo').removeClass('ckdisabled');
}
function ckUndo() {
if ((ckActionsPointer)<(ckActionsCounter)) {
ckActionsPointer++;
$ck('#ckredo').removeClass('ckdisabled');
} else {
$ck('#ckundo').addClass('ckdisabled');
return;
// alert(TCK.Text._('CK_NO_MORE_UNDO', 'There is no more Undo action'));
}
var z=ckDoActionsList.length;
z=z-ckActionsPointer-1;
if (ckDoActionsList[z]) {
document.getElementById('ckhtmlcontainer').innerHTML=ckDoActionsList[z];
} else {
document.getElementById('ckhtmlcontainer').innerHTML=ckDoActionsList[0];
}
ckInitInterface();
}
function ckRedo() {
if((ckActionsPointer)>=1) {
ckActionsPointer--;
$ck('#ckundo').removeClass('ckdisabled');
} else {
$ck('#ckredo').addClass('ckdisabled');
return;
// alert(TCK.Text._('CK_NO_MORE_REDO', 'There is no more Redo action'));
}
var z=ckDoActionsList.length;
z=z-ckActionsPointer-1;
if (ckDoActionsList[z]) {
document.getElementById('ckhtmlcontainer').innerHTML=ckDoActionsList[z];
} else {
document.getElementById('ckhtmlcontainer').innerHTML=ckDoActionsList[0];
}
ckInitInterface();
}
function ckToggleSubmenu(el) {
el = $ck(el);
if ($ck('#ckmodelewrapper').length) return;
var submenu = el.next('.cksubmenu');
$ck('.cksubmenu').not(submenu).hide('fast').removeClass('opened');
if (! submenu.hasClass('opened')) {
submenu.addClass('opened').show('fast', function() {hideSubmenuckOutsideClick(submenu), ckCheckSubmenuHeight(submenu); } );
} else {
submenu.hide('fast').removeClass('opened');
}
if (! submenu.hasClass('eventadded')) {
submenu.addClass('eventadded').find('> a').on('click', function() {
submenu.hide().removeClass('opened');
});
}
}
function ckCheckSubmenuHeight(submenu) {
var top = submenu.position().top;
var h = submenu.height();
var winh = $ck(window).height();
if (top + h > winh) {
submenu.height(winh - top - 5);
} else {
submenu.height('auto');
}
}
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
}
});
}
function ckShowRestorePopup() {
CKBox.open({handler: 'inline', content: 'restoreModalck', style: {padding: '10px'}, size: {x: '600px', y: '400px'}});
}
function ckShowReplaceColorsPopup() {
CKBox.open({handler: 'inline', content: 'replaceColorsModalck', style: {padding: '10px'}, size: {x: '600px', y: '350px'}});
}
function ckReplaceColors() {
ckSaveAction();
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, #ckstylescontainer .ckstyle').each(function() {
var $st = $ck(this);
$st.html($st.html().replace(regEx, newColor));
});
$ck('#body .ckprops, #ckstylescontainer .ckprops').each(function() {
this.outerHTML = this.outerHTML.replace(regEx, newColor);
});
}
ckSaveAction();
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 = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxDoRestoration&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
id: id,
name: name,
isLocked: isLocked
}
}).done(function(code) {
ckSaveAction();
var result = JSON.parse(code);
$ck('#ckhtmlcontainer').html(result.htmlcode);
$ck('#ckstylescontainer').html(result.stylecode);
CKBox.close();
jQuery('.restoreline' + index + ' .processing').removeClass('ckwait');
ckInitInterface();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckAddWaitOverlay() {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
}
function ckRemoveWaitOverlay() {
$ck('#ckwaitoverlay').remove();
}
function ckShowWidgetsPopup() {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
ckCloseEdition();
$ck('.ckfocus').removeClass('ckfocus');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxwidgetsmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
}
}).done(function(code) {
$ck('#ckpopup').empty().append(code);
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveWizard();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
CKBox.open({handler: 'inline', content: 'ckpopup', style: {padding: '10px'}});
$ck('#ckwaitoverlay').remove();
ckCheckEnabledWidgets();
ckCheckWidgetsVersions();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckCheckEnabledWidgets() {
$ck('#widgetsmanager .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;
ckAddSpinnerIcon($ck(btn));
var widgetData = ckGetWidgetData(btn);
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxInstallWidget&" + CKTOKEN;
$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="' + TEMPLATECREATORCK_URI + '/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(TCK.Text._('CK_WIDGET_INSTALL_FAILED', 'Widget installation failed'));
}
ckRemoveSpinnerIcon($ck(btn));
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
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]();
} else {
alert('Error : Function TCK_Widget' + ckCapitalizeFirstLetter(widgetData.attr('data-name')) +'Disable 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')) +'Edit is not found. Is the widget installed ?')
}
}
function ckCapitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function ckCapitalize(string) {
return ckCapitalizeFirstLetter(string);
}
function ckAfterWidgetEditionDisplay() {
$ck('#widgetedition').prepend('<div id="widgeteditionbackbutton" onclick="ckCloseWidgetEdition()" class="ckbutton"><span class="fa fa-arrow-left"></span> ' + TCK.Text._('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 = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxCheckWidgetUpdate&" + CKTOKEN;
$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(TCK.Text._('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();
if (typeof(window['ckAfterWidgetData' + widget['name']]) == 'function' && widget['enabled'] == '1') window['ckAfterWidgetData' + widget['name']](widget);
widgets[$ck(this).attr('data-name')] = widget;
});
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 = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxAddWidgetManually&" + CKTOKEN;
$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(TCK.Text._('CK_WIDGET_INSTALL_SUCCESS', 'Widget installed correctly'));
$ck('#widgetsElements').append('<script src="' + TEMPLATECREATORCK_URI + '/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(TCK.Text._('CK_WIDGET_INSTALL_FAILED', 'Widget installation failed'));
}
}).fail(function() {
// alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
}
/*=================================*/
/* Modules management
/*=================================*/
function ckInstallModule(name) {
$ck('.blocselect.'+name).find('.fa').attr('class', 'fa fa-spinner fa-spin');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxInstallModule&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
// url: url,
name: name
}
}).done(function(code) {
if (code == '1') {
alert(TCK.Text._('CK_MODULE_INSTALL_SUCCESS', 'Widget installation successful !'));
$ck('.blocselect.'+name).removeClass('notinstalled').addClass('dragtoadd').find('.installbutton').remove();
ckAddDraggableToBlocks();
} else {
alert(TCK.Text._('CK_MODULE_INSTALL_FAILED', 'Widget installation failed'));
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
// $ck('#ckwaitoverlay').remove();
});
}
/*--------------------------------------------
--- Script for V4 --
----------------------------------------------*/
function ckCapitalize(s) {
return s[0].toUpperCase() + s.slice(1);
}
function ckShowLayouts() {
CKBox.open({'handler': 'inline', 'content': 'cklayoutslist', size: {x:'950px', y:'370px'}});
}
function ckGetLibraryTemplates() {
$ck('#ckmodelslist').addClass('ckwait');
var debug = true;
// sessionStorage.setItem('templatecreatorck_library_templates','');
if (!debug && window.sessionStorage && sessionStorage.getItem('templatecreatorck_library_templates')) {
var categorieshtml = sessionStorage.getItem('templatecreatorck_library_templates');
$ck('#ckmodelslist').empty().append(categorieshtml);
$ck('#ckmodelslist').removeClass('ckwait');
ckGetLibraryTemplatesRange(1);
} else {
var url = 'https://media.joomlack.fr/api/templatecreatorck/templates';
// var url = 'http://localhost/media.joomlack.fr/api/templatecreatorck/templates';
jQuery.ajax({
url: url,
dataType: 'jsonp',
cache: false,
jsonpCallback: "joomlack_jsonpcallback",
timeout: 20000,
success: function (response) {
// convert the response object in array of keys sorted descending (=date)
keysSorted = Object.keys(response).sort(function(a,b){return b - a})
$ck('#ckmodelslist').removeClass('ckwait');
var sectionhtml = '';
sectionhtml += '<div class="ckgallerywrap">';
var nbitems = 0;
var nbitemsperpage = 8;
// var i = 0;
// for (var cat in response) {
for (var i=0;i<keysSorted.length;i++) {
// for (var i in response) {
// var item = response[i];
var item = response[keysSorted[i]];
var dataid = item['infos']['category'].toLowerCase() + '-' + item['name'].toLowerCase();
sectionhtml += '<div class="ckgalleryitem" data-id="' + dataid + '" data-category="' + item['infos']['category'].toLowerCase() + '" style="display:none;">'
+ '<div class="ckgalleryiteminner">'
+ '<div class="ckgalleryitemimage">'
+ '<img src="" data-src="' + item['thumb'] + '" />'
+ '</div>'
+ '<div class="ckgalleryiteminfos">'
+ '<div class="ckgalleryitemtitle">' + ckCapitalize(item['name']) + '</div>'
+ '<div class="ckgalleryitempreviewbtn"><button class="ckbutton" onclick="ckPreviewGalleryItem(this)"><span class="fa fa-info"></span> ' + TCK.Text._('CK_DETAILS') + '</button></div>'
+ '<div class="ckgalleryitemloadbtn"><button class="ckbutton" onclick="ckLoadTemplateFile(\'' + item['file'] + '\')"><span class="fa fa-download"></span> ' + TCK.Text._('CK_LOAD') + '</button></div>'
+ '</div>'
+ '<div class="ckgalleryitemdetails">'
+ '<img src="" data-src="' + item['preview'] + '" />'
+ '<div class="ckgalleryitemdetailsinfos">'
+ '<div><span data-info="name">' + item['name'] + '</span></div>'
+ '<div><span data-info="detaillabel">' + TCK.Text._('CK_DESCRIPTION') + '</span> <span>' + item['infos']['description'] + '</span></div>'
+ '<div><span data-info="detaillabel">' + TCK.Text._('CK_AUTHOR') + '</span> <a href="' + item['infos']['authorurl'] + '" target="_blank"><span>' + item['infos']['author'] + '</span></a></div>'
+ '<div><span data-info="detaillabel">' + TCK.Text._('CK_PRICE') + '</span> <span class="ckbadge">' + (item['infos']['free'] ? TCK.Text._('CK_FREE') : item['infos']['price']) + '</span></div>'
+ '<div class="ckgalleryitemdetailsactions">'
+ (item['infos']['demourl'] ? '<a class="ckbutton ckbutton-primary ckbutton-big" href="' + item['infos']['demourl'] + '" target="_blank"><span class="fa fa-desktop"></span> <span>' + TCK.Text._('CK_DEMO') + '</span></a>' : '<div class="ckalert">' + TCK.Text._('CK_DEMO_NOT_AVAILABLE') + '</div>')
+ (item['infos']['documentationurl'] ? '<a class="ckbutton ckbutton-big" href="' + item['infos']['documentationurl'] + '" target="_blank"><span class="fa fa-file-text-o"></span> <span>' + TCK.Text._('CK_DOCUMENTATION') + '</span></a>' : '')
+ '<div class="ckbutton ckbutton-danger ckbutton-big" onclick="ckLoadTemplateFile(\'' + item['file'] + '\')"><span class="fa fa-download"></span> <span>' + TCK.Text._('CK_LOAD') + '</span></div>'
+ '<a class="ckgalleryitemdetailmanualdownload" href="' + item['file'] + '"><span>' + TCK.Text._('CK_MANUAL_DOWNLOAD') + '</span></a>'
+ '</div>'
+ '</div>'
for (var d=0;d<item.length;d++) {
sectionhtml += ' | info : ' + item[d];
}
sectionhtml += '</div>'
+ '</div>'
+ '</div>';
nbitems++;
// i++;
// if (i == 3) i = 0;
}
// }
var categorieshtml = sectionhtml
+ '<div style="clear:both;"></div>';
var nbpages = parseInt((nbitems -1) / nbitemsperpage) + 1;
var pagination = '<div class="ckgallerypagination"><span class="">' + TCK.Text._('CK_PAGES') + '</span><div class="ckbutton-group">';
for (var page=1; page <= nbpages; page++) {
pagination += '<div class="ckgallerypaginationindex ckbutton" onclick="ckGetLibraryTemplatesRange(' + page + ', this)">' + page + '</div>';
}
pagination += '</div></div>';
categorieshtml = pagination + categorieshtml;
$ck('#ckmodelslist').append(categorieshtml);
$ck('#ckmodelslist').removeClass('ckwait');
ckGetLibraryTemplatesRange(1);
sessionStorage.setItem('templatecreatorck_library_templates', categorieshtml);
},
fail: function() {
alert('Error : Unable to connect to the library. Please contact an administrator');
},
complete: function() {
},
error: function(request, status, error) {
}
});
}
}
function ckGetLibraryTemplatesRange(page, btn) {
var start = 8 * (page -1);
var end = 8 * page;
$ck('#ckmodelslist').find('.ckgalleryitem').hide();
$ck('#ckmodelslist').find('.ckgalleryitem').slice(start, end).each(function() {
var image = $ck(this).find('.ckgalleryitemimage img');
image.attr('src', image.attr('data-src'));
$ck(this).fadeIn();
});
$ck('.ckgallerypagination').find('.active').removeClass('active');
$ck('.ckgallerypaginationindex').eq(page-1).addClass('active');
}
function ckPreviewGalleryItem(btn) {
var item = $ck($ck(btn).parents('.ckgalleryitem')[0]);
$ck('#ckgalleryitemdetail').removeAttr('id');
var details = item.find('.ckgalleryitemdetails').attr('id', 'ckgalleryitemdetail');
var image = details.find('img');
image.attr('src', image.attr('data-src'));
CKBox.open({handler: 'inline', content: 'ckgalleryitemdetail', style: {padding: '10px'}});
}
function ckLoadTemplateFile(file) {
ckAddWaitOverlay();
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=template.ajaxImport&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
dataType: "json",
data: {
gabariturl: file
}
}).done(function(response) {
if (response.status == '1') {
window.location.href = TEMPLATECREATORCK_ADMIN_URL + '&view=template&layout=edit&quickdata=1&id=' + response.id;
} else {
ckShowManualLoadTemplateFile(file);
ckRemoveWaitOverlay();
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
ckRemoveWaitOverlay();
});
}
function ckShowManualLoadTemplateFile(file) {
$ck('#ckmanualtemplateinstuctions').remove();
$ck(document.body).append('<div id="ckmanualtemplateinstuctions"><p>' + TCK.Text._('CK_MANUAL_TEMPLATE_INSTALL_INFOS') + '</p><p><a class="" href="https://www.template-creator.com/fr/documentation-category/15-miscellaneous/58-manual-library-installation" target="_blank">' + TCK.Text._('CK_READ_DOCUMENTATION') + '</a></p><p></p><p style="text-align:center;"><a class="ckbutton" href="' + file + '" target="_blank">' + TCK.Text._('CK_DOWNLOAD') + '</a></p></div>');
CKBox.open({handler: 'inline', content: 'ckmanualtemplateinstuctions', style: {padding: '10px'}, size: {x: '400px', y: '200px'}});
}
function ckShowWizard() {
bloc = $ck('#body');
$ck('#ckwizardmodal').addClass('ckwait');
$ck('#ckwizardmodal .ckinterface').hide();
// $ck('html, body').animate({scrollTop: 0}, 'slow');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxparams&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
expertmode: $ck('#body').hasClass('expert'),
joomlaversion: $ck('#joomlaversion').attr('value')
}
}).done(function(code) {
$ck('#ckwizardmodal').removeClass('ckwait');
$ck('#ckparamsfake').empty().append(code);
$ck('#ckwizardmodal .ckinterface').fadeIn();
ckFillEdition('body');
ckFillWizard();
ckInitTooltip($ck('#ckwizardmodal'));
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
// $ck('#ckwaitoverlay').remove();
});
$boxfooterhtml = '<a class="ckboxmodal-button" href="javascript:void(0);" onclick="ckSaveWizard();CKBox.close();">' + TCK.Text._('CK_SAVE_CLOSE') + '</a>';
// $ck('#ckwizardmodal').show();
CKBox.open({handler: 'inline', content: 'ckwizardmodal', style: {padding: '10px'}, size: {x: '600px', y: '400px'}, footerHtml: $boxfooterhtml});
}
function ckFillWizard() {
$ck('#ckwizardmodal [data-id="name"]').val($ck('#name').val());
$ck('.inputbox', $ck('#ckwizardmodal .ckinterface')).each(function(i, field) {
var $field = $ck(field);
var fieldid = $field.attr('data-id');
var cssvalue = $ck('#' + fieldid).val();
if ($field.attr('type') == 'radio') {
} else if (cssvalue) {
$field.attr('value', cssvalue);
if ($field.hasClass('colorPicker') && $field.attr('value')) {
ckSetPickercolor($field);
$field.css('background-color', $field.attr('value'));
}
} else {
$field.attr('value', '');
}
});
}
function ckSaveWizard() {
$ck('#name').val($ck('#ckwizardmodal [data-id="name"]').val());
$ck('.inputbox', $ck('#ckwizardmodal .ckinterface')).each(function(i, field) {
var $field = $ck(field);
var fieldid = $field.attr('data-id');
var cssvalue = $field.val();
if ($field.attr('type') == 'radio') {
} else if (cssvalue) {
$ck('#' + fieldid).val(cssvalue);
} else {
$ck('#' + fieldid).val('');
}
});
ckRenderCss('body', $ck('#ckwizardmodal'), $ck('#body'), false);
}
function ckLoadEmptyLeftPanel() {
$ck('#ckedition').append('<div class="ckleftpanelheader">'
+'<span class="ckleftpanelheadericon ckclose" onclick="ckCloseEdition();">×</span>'
+'</div>').show();
}
/*--------------------------------
-- Custom Styles Creator --
-------------------------------- */
function ckShowCustomStyleInterface() {
// only show the main part if no style loaded
$ck('#ckcustomstylepreviewwrap').fadeIn();
$ck('#ckstylescontainer .ckstylecontainer[data-id^="ckcustomstyle"]').each(function() {
var prefix = $ck(this).attr('data-id');
var index = prefix.replace('ckcustomstyle', '');
var text = $ck(this).attr('data-name') ? $ck(this).attr('data-name') : 'style' + index;
if (! $ck('#' + prefix).length) ckCreateNewCustomStylesFields(prefix, text, true);
});
ckMakeCustomStyleButtonsSortable();
ckLoadEmptyLeftPanel();
$ck('#ckcustomstylesbuttons > .ckbutton').first().trigger('click');
}
function ckShowLayoutEdition(layout) {
$ck(document.body).append('<div id="ckwaitoverlay"></div>');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxlayout" + layout + "&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
templatename: $ck('#name').val()
}
}).done(function(code) {
$ck('#ckedition').empty().append(code).fadeIn();
$ck('#ckwaitoverlay').remove();
ckFillEdition('ckcustomlayout' + layout);
ckAddEventOnFields($ck('#ckedition'), 'ckcustomlayout' + layout);
if (typeof(window['ckUpdateLayoutPreview' + layout]) == 'function') window['ckUpdateLayoutPreview' + layout]();
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
$ck('#ckwaitoverlay').remove();
});
}
function ckMakeCustomStyleButtonsSortable() {
$ck('#ckcustomstylesbuttons').sortable({
items: ".ckbutton",
helper: "clone",
// handle: ".tableck-controlMove",
forcePlaceholderSize: true,
tolerance: "intersect",
// placeholder: "ckplaceholder",
start: function(e, ui){
},
stop: function( event, ui ) {
},
});
}
function ckShowCustomStyleEdition(prefix, btn) {
prefix = prefix ? prefix : '';
btn = btn ? btn : false;
// only show the main part if no style loaded
$ck('#ckcustomstylepreviewwrap').fadeIn();
if (! prefix) return;
btn = $ck(btn);
$ck('#ckcustomstylesbuttons .active').removeClass('active');
$ck('#ckcustomstylesbuttons .menustylescustom').removeClass('menustylescustom');
btn.addClass('active');
var styleswrapper = ckGetStylesWrapperForBlock(btn.attr('id'));
var cssclass = styleswrapper.attr('data-cssselector') ? styleswrapper.attr('data-cssselector') : btn.attr('data-class');
$ck('#ckcustomstylepreview > .inner').attr('class', 'inner ' + cssclass);
btn.attr('class', 'active ckbutton menustylescustom').attr('data-rule', '.' + cssclass);
ckShowEdition(btn.attr('id'), '', 'ckAfterShowCustomStyleEdition');
}
function ckAfterShowCustomStyleEdition() {
var btn = $ck('#ckcustomstylesbuttons .ckfocus');
var styleswrapper = ckGetStylesWrapperForBlock(btn.attr('id'));
var name = styleswrapper.attr('data-name') ? styleswrapper.attr('data-name') : btn.text();
var cssclass = styleswrapper.attr('data-cssselector') ? styleswrapper.attr('data-cssselector') : btn.attr('data-prefix');
$ck('#ckcustomstylename').val(name);
$ck('#ckcustomstylecssselector').val(cssclass);
}
function ckUpdateCustomStyleData() {
var btn = $ck('#ckcustomstylesbuttons .ckfocus');
var name = $ck('#ckcustomstylename').val().replace('"', '');
$ck('#ckcustomstylename').val(name);
var cssclass = ckAlphaNumeric($ck('#ckcustomstylecssselector').val());
$ck('#ckcustomstylecssselector').val(cssclass)
btn.text(name).attr('data-rule', '.' + cssclass);
var styleswrapper = ckGetStylesWrapperForBlock(btn.attr('id'));
styleswrapper.attr('data-name', name);
styleswrapper.attr('data-cssselector', cssclass);
$ck('#ckcustomstylepreview > .inner').attr('class', 'inner ' + cssclass);
ckRenderCss();
}
function ckRemoveCustomStyle() {
if (!confirm(TCK.Text._('CK_CONFIRM_DELETE','Are you sure that you want to delete ?'))) return;
var btn = $ck('#ckcustomstylesbuttons .ckfocus');
var styleswrapper = ckGetStylesWrapperForBlock(btn.attr('id'));
styleswrapper.remove();
btn.remove();
$ck('#ckedition').fadeOut();
}
function ckBeforeCloseEditionPopup() {
$ck('#ckcustomstylesbuttons .active').removeClass('active');
$ck('#ckcustomstylepreviewwrap').fadeOut();
if ($ck('#cktemplatecontainer').hasClass('ckcssmanager')) {
ckManageHtmlCss();
}
}
function ckCreateNewCustomStylesFields(prefix, text, notshowedition) {
notshowedition = notshowedition ? notshowedition : false;
if (! prefix) {
var index = ckGetNewStyleId();
var prefix = 'ckcustomstyle' + index;
var text = 'style' + index;
}
var styleswrapper = ckGetStylesWrapperForBlock(prefix);
var cssclass = styleswrapper.attr('data-cssselector') ? styleswrapper.attr('data-cssselector') : prefix;
var newbutton = '<div id="' + prefix + '" data-prefix="' + prefix + '" data-rule=".' + cssclass + '" data-class="' + prefix + '" data-element="customstyle" onclick="ckShowCustomStyleEdition(\'' + prefix + '\', this)" class="ckbutton">'+text+'</div>';
$ck('#ckcustomstylesbuttons').append(newbutton);
if (! notshowedition) ckShowCustomStyleEdition(prefix, newbutton);
}
function ckGetNewStyleId(idbase) {
if (!idbase) idbase = 'ckcustomstyle';
var i = 1;
while ($ck('#' + idbase + i).length && i < 1000) {
i++;
}
return i;
}
function ckManageHtmlCss() {
if ($ck('#cktemplatecontainer').hasClass('ckcssmanager')) {
$ck('#cktemplatecontainer').removeClass('ckcssmanager');
$ck('.ckbloc').each(function() {
ckRemoveEdition($ck(this));
});
ckCloseEdition();
} else {
ckLoadEmptyLeftPanel();
$ck('#cktemplatecontainer').addClass('ckcssmanager');
$ck('.ckbloc:not(.ckbloclayout)').each(function(i, bloc) {
ckAddEdition(bloc);
});
}
}
function ckChangeBlocClass(btn) {
var bloc = ckGetBlockFromBtn(btn);
// blocid = bloc.attr('id');
var blocinner = bloc.find('> .inner');
var oldclass = blocinner.attr('data-class') ? blocinner.attr('data-class') : '';
var newclass = prompt(TCK.Text._('CK_ENTER_CSS_CLASS', 'Enter a CSS Class'), oldclass);
if (newclass) newclass = ckAlphaNumeric(newclass, true);
$ck('> .editorck > .ckfields .editorckclass', bloc).html(newclass);
blocinner.removeClass(oldclass);
blocinner.addClass(newclass);
blocinner.attr('data-class', newclass);
}
/*--------------------------------
-- Elements library --
-------------------------------- */
function ckSaveItem(blocid) {
var name = prompt('Name to save the element');
if (! name) return;
var styleswrapper = ckGetStylesWrapperForBlock(blocid);
var saveditem = $ck('#' + blocid).clone();
ckRemoveEdition(saveditem, true);
saveditem.prepend(styleswrapper.find('> .ckstyle').clone()).prepend(styleswrapper.find('> .ckprops').clone());
saveditem.find('.ckbloc, .ckrowcontainer').each(function() {
var $this = $ck(this);
styleswrapper = ckGetStylesWrapperForBlock(this.id);
$this.prepend(styleswrapper.find('> .ckstyle').clone()).prepend(styleswrapper.find('> .ckprops').clone());
});
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=ajaxSaveElement&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
data: {
name : name,
html : saveditem[0].outerHTML
}
}).done(function(code) {
alert(TCK.Text._('CK_SAVED', 'Saved'));
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckLoadLibraryElements() {
// ckGetLibraryTemplates à appeler par la suite pour charger les éléments
$ck('#ckaddblockmanager').stop().animate({'margin-left': '-300px'});
$ck('#ckleftpanel').animate({scrollTop: 0}, 0);
}
function ckCloseLibraryElements() {
$ck('#ckaddblockmanager').stop().animate({'margin-left': '0'});
}
function ckGetLibraryElements(type) {
$ck('#cklibraryelements #tab_library_' + type + ' > .inner').addClass('ckwait');
var debug = true;
// sessionStorage.setItem('templatecreatorck_library_elements_' + type,'');
if (!debug && window.sessionStorage && sessionStorage.getItem('templatecreatorck_library_elements_' + type)) {
var libraryhtml = sessionStorage.getItem('templatecreatorck_library_elements_' + type);
$ck('#cklibraryelements #tab_library_' + type + ' > .inner').empty().append(libraryhtml);
$ck('#cklibraryelements #tab_library_' + type + ' > .inner').removeClass('ckwait');3
ckAddDraggableToLibraryElements();
} else {
var dev = 0;
if (dev) {
var url = 'http://localhost/media.joomlack.fr/api/templatecreatorck/elements/' + type;
} else {
var url = 'https://media.joomlack.fr/api/templatecreatorck/elements/' + type;
}
jQuery.ajax({
url: url,
dataType: 'jsonp',
cache: false,
jsonpCallback: "joomlack_jsonpcallback",
timeout: 20000,
success: function (response) {
$ck('#cklibraryelements').removeClass('ckwait');
var libraryhtml = '';
// for (var i=0;i<response.length;i++) {
for (var i in response) {
var item = response[i];
var dataid = type + '/' + item['name'].toLowerCase();
var suffix = type;
if (type == 'section' || type == 'header') suffix = 'wrapper';
libraryhtml += '<div class="cklibraryitem cklibraryitem' + suffix + ' ckdragtoaddelement" data-id="' + dataid + '">'
+ '<img src="' + item['thumb'] + '" />'
+ '</div>'
;
}
sessionStorage.setItem('templatecreatorck_library_elements_' + type, libraryhtml);
$ck('#cklibraryelements #tab_library_' + type + ' > .inner').empty().append(libraryhtml);
$ck('#cklibraryelements #tab_library_' + type + ' > .inner').removeClass('ckwait');
ckAddDraggableToLibraryElements();
},
fail: function() {
alert('Error : Unable to connect to the library. Please contact an administrator');
},
complete: function() {
},
error: function(request, status, error) {
}
});
}
}
function ckLoadLibraryElement(block) {
// ex id = modules/module1
// var myurl = 'https://media.joomlack.fr/api/templatecreatorck/element/' + block.attr('data-id');
var dev = 0;
if (dev) {
var myurl = 'http://localhost/media.joomlack.fr/api/templatecreatorck/element/' + block.attr('data-id');
} else {
var myurl = 'https://media.joomlack.fr/api/templatecreatorck/element/' + block.attr('data-id');
}
$ck.ajax({
url: myurl,
dataType: 'jsonp',
cache: false,
jsonpCallback: "joomlack_jsonpcallback",
timeout: 20000,
}).done(function(code) {
if (code != 'error') {
// var newcode = $ck(code['htmlcode'].trim());
var newelement = $ck(code);
$ck(block).before(newelement);
newelement.hide();
$ck(block).fadeOut(500, function() {
$ck(block).remove();
ckInitSortables();
newelement.fadeIn('slow');
});
newelement.attr('data-oldid', newelement.attr('id')).removeAttr('id');;
ckReplaceIdPositionInBlock(newelement);
ckSeparateStylesForBlock(newelement, true);
// newelement.find('.ckbloc').each(function() {
// var $this = $ck(this);
// $this.attr('data-oldid', $this.attr('id'));
// $this.attr('id', '');
// $this.attr('ckmoduleposition', '');
// });
// $ck('#body').prepend(newelement);
newelement.find('.ckbloc, .ckrowcontainer').each(function() {
var $this = $ck(this);
$this.attr('data-oldid', $this.attr('id')).removeAttr('id');;
ckReplaceIdPositionInBlock($this);
ckAddControlsOnHover($this);
ckSeparateStylesForBlock($this, true);
});
// ckInitSortables();
ckAddControlsOnHover(newelement);
ckSaveAction();
} else {
alert(TCK.Text._('Error : Can not get the element. Please retry and contact the developer.'));
}
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckReplaceIdPositionInBlock(block) {
// .attr('data-type')
var type = ckGetBlockType(block);
var parentid = '';
if (block.hasClass('ckrowcontainer')) {
parentid = $ck(block.parents('.ckrow')[0]).attr('id');
}
var newid = (type == 'wrapper' ? ckGetWrapperProposal() : ckGetIdProposal(type, parentid));
// ckReplaceId(block, newid);
var re = new RegExp(block.attr('data-oldid'), 'g');
if (block.find('> .ckstyle').length) block.find('> .ckstyle').html(block.find('> .ckstyle').html().replace(re,newid));
block.attr('id', newid).removeAttr('data-oldid');
if (block.attr('ckmoduleposition')) {
var newposition = ckGetPositionsProposal('block').join();
block.attr('ckmoduleposition', newposition);
}
}
function ckGetBlockType(block) {
var classes = Array('wrapper', 'logobloc', 'rowcontainer', 'row', 'horiznav', 'singlemodule', 'flexiblemodules', 'flexiblemodule', 'custombloc', 'module');
var blockclass = block.attr('class');
var type = 'block';
for (var i=0; i<classes.length; i++) {
if (blockclass.indexOf(classes[i]) !== -1) {
type = classes[i];
if (type == 'flexiblemodules') type = 'block';
return type;
break;
}
}
return type;
}
function ckShowGoogleFontsManager() {
var bodyprops = ckGetPropsForBloc('body', 'googlefonts');
var fontslist = bodyprops.attr('fontslist');
var myurl = TEMPLATECREATORCK_ADMIN_URL + "&task=interface.load&layout=ajaxgfontsmanager&" + CKTOKEN;
$ck.ajax({
type: "POST",
url: myurl,
async: true,
data: {
fontslist : fontslist
}
}).done(function(code) {
$ck('#ckgfontsmanager').remove();
var ckgfontsmanager = $ck(code);
$ck(document.body).append(ckgfontsmanager);
ckgfontsmanager.hide();
CKBox.open({handler: 'inline', content: 'ckgfontsmanager', style: {padding: '10px'}, size: {x: '600px', y: '300px'}});
}).fail(function() {
alert(TCK.Text._('CK_FAILED', 'Failed'));
});
}
function ckRemoveGoogleFont(font) {
if (!confirm(TCK.Text._('CK_CONFIRM_DELETE','Are you sure that you want to delete ?'))) return;
var bodyprops = ckGetPropsForBloc('body', 'googlefonts');
var fontslist = bodyprops.attr('fontslist');
fontslist = fontslist.split(',');
fontslist.splice( fontslist.indexOf(font), 1 );
bodyprops.attr('fontslist', fontslist);
// remove the line in the interface
$ck('#ckgfontsmanager tr[data-font="' + font + '"]').remove();
// remove the stylesheet
$ck('#googlefontscall link[href*="fonts.googleapis.com/css?family=' + font.replace(' ', '+') + '"]').remove();
// remove the properties on all blocks
$ck('.ckprops[blocgooglefont="' + font + '"]').removeAttr('blocgooglefont').removeAttr('blocfontfamily');
$ck('.ckprops[moduletitlegooglefont="' + font + '"]').removeAttr('blocgooglefont').removeAttr('blocfontfamily');
$ck('.ckprops[moduletextgooglefont="' + font + '"]').removeAttr('blocgooglefont').removeAttr('blocfontfamily');
}
function ckUpdateShapeDivider(prefix) {
var focus = $ck('.ckfocus');
if (prefix == 'divider') {
focus.find('.tck-divider1-container').remove();
switch ($ck('#' + prefix + 'shape').val()) {
case 'multiclouds' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 86.47" preserveAspectRatio="none"><g style="opacity:0.33"><path d="M823,15.52l.24-.07A27.72,27.72,0,0,0,864.3,30.53a46.9,46.9,0,0,0,51.9,28A55,55,0,0,0,1000,73.07V0H792C795.79,12,809.32,18.85,823,15.52Z"></path><path d="M23.71,83.4A50,50,0,0,0,85.39,48.77v-.05a25.19,25.19,0,0,0,20.89-4.31,32.67,32.67,0,0,0,12.82,7A32.88,32.88,0,0,0,154.31,0H0V68.64A49.74,49.74,0,0,0,23.71,83.4Z"></path></g><g style="opacity:0.66"><path d="M499.63,19.13h.08a8.91,8.91,0,0,0,12.64,6.15A15.07,15.07,0,0,0,528,35.9a17.67,17.67,0,0,0,33.67-9.55v0A8.9,8.9,0,0,0,567.86,22a11.61,11.61,0,0,0,7.48-22H503.08a11.65,11.65,0,0,0-1.71,4.21,9.2,9.2,0,0,0-3.85-.28c-4.65.65-8,4.58-7.37,8.77S495,19.78,499.63,19.13Z"></path><path d="M631.55,20.67c1,7.6,8.68,12.87,17.22,11.78a16.35,16.35,0,0,0,11.45-6.74,16.34,16.34,0,0,0,7.07,2.14A10.86,10.86,0,0,0,686.86,35a10.82,10.82,0,0,0,8.1-1c1.68,6.83,9,11.4,17,10.38a16,16,0,0,0,12.48-8.49,19.56,19.56,0,0,0,10.37,1.45,19.24,19.24,0,0,0,11.72-5.89,10.85,10.85,0,0,0,17.33-.92A10.81,10.81,0,0,0,776,31.2a17.64,17.64,0,0,0,3.38,1,18.52,18.52,0,0,0,16.52,6A18.82,18.82,0,0,0,809.34,30c2.67,10,12.75,17.44,24.8,17.44,9.38,0,17.57-4.5,22-11.2a32,32,0,0,0,16.53,4.5,31.47,31.47,0,0,0,20.23-7.14,17.75,17.75,0,0,0,28.32,2.09,17.74,17.74,0,0,0,22.71,1.75c4.13,10.05,15,17.22,27.72,17.22,13.43,0,24.75-8,28.33-18.88V0H599.32C607.84,23.13,631.55,20.67,631.55,20.67Z"></path><path d="M.74,30.73c0,12.33,11.21,22.33,25.08,22.36,10.84,0,20.08-6.07,23.61-14.62A15.09,15.09,0,0,0,68.74,37a15.1,15.1,0,0,0,24.1-1.74,26.76,26.76,0,0,0,17.2,6.1,27.24,27.24,0,0,0,14.07-3.81,22.33,22.33,0,0,0,18.71,9.56c11.24,0,20.49-7.56,21.62-17.28a14.92,14.92,0,0,0,10.72.18c3.29,7.35,12.1,11.63,21.28,9.81a20.31,20.31,0,0,0,13.62-9.33A20.31,20.31,0,0,0,219,32.56a13.49,13.49,0,0,0,24.86,7.25,13.43,13.43,0,0,0,10-1.91c2.66,8.32,12.06,13.37,21.9,11.42a19.93,19.93,0,0,0,14.75-11.58,24.3,24.3,0,0,0,13,.92,23.88,23.88,0,0,0,14-8.3,13.47,13.47,0,0,0,21.4-2.61,13.46,13.46,0,0,0,17.17-2c4.56,6.88,13.69,10.63,23.18,8.76,12.14-2.4,20.26-13.09,18.13-23.88A73.93,73.93,0,0,0,400.48,0H0V29.49C.24,29.91.48,30.32.74,30.73Z"></path></g><path d="M16.3,13.9c10.2,2.5,20.3-1.1,25.5-8.3a14.66,14.66,0,0,0,18.5,3A14.6,14.6,0,0,0,80,14.9a13.14,13.14,0,0,0,3.4-2.4,25.71,25.71,0,0,0,14.8,9.7,26,26,0,0,0,14.1-.4,21.75,21.75,0,0,0,15.4,13.3c10.6,2.6,21-2.4,24.3-11.3a15,15,0,0,0,10.7,2.6,17.69,17.69,0,0,0,1.6,2.2,14.69,14.69,0,0,0,17.6,3.5,7.46,7.46,0,0,0,1.2-.7,14.54,14.54,0,0,0,6.4-8.9,12.61,12.61,0,0,0,.4-2.8,20.63,20.63,0,0,0,9.8-1.8,11.35,11.35,0,0,0,1.5,2.3A22.35,22.35,0,0,0,214,28.6c11.2,2.8,22.4-3.1,24.8-13.1a24.63,24.63,0,0,0,16.3,11.6c9.8,2.1,19.4-1.7,24.2-8.7a14,14,0,0,0,17.8,2.4,14.07,14.07,0,0,0,19.1,5.4,12.25,12.25,0,0,0,3.1-2.4,22.5,22.5,0,0,0,5.8,5.3,25.42,25.42,0,0,0,16.1,4,30.38,30.38,0,0,0,6-1.2c.2.4.4.9.6,1.3a20.81,20.81,0,0,0,14.6,11c10.2,2.2,20-2.9,22.9-11.5a13.84,13.84,0,0,0,10.3,2.1,14,14,0,0,0,19.3,4.6,14.17,14.17,0,0,0,6.7-11.8,20,20,0,0,0,9.3-2,21.31,21.31,0,0,0,14,9.9c10.6,2.3,20.9-3.4,23.2-12.7a28.46,28.46,0,0,0,37.2,7.1,23.54,23.54,0,0,0,7.3-7.1,15.79,15.79,0,0,0,20.1,2.1,15.69,15.69,0,0,0,21.6,5.5,13.88,13.88,0,0,0,3.5-2.9,26.66,26.66,0,0,0,9.5,7.2,28.5,28.5,0,0,0,7,2.2,29.16,29.16,0,0,0,15.2-1.3c2.8,6.6,9.3,11.8,17.5,13.3,11.4,2.1,22.2-3.8,25.3-13.4,0-.1.1-.2.1-.4.3.2.7.4,1,.6a15.93,15.93,0,0,0,10.7,1.5,15.79,15.79,0,0,0,28.7-6c.1-.4.1-.8.2-1.2a10.87,10.87,0,0,0,.1-1.8,22.26,22.26,0,0,0,10.4-2.6,25,25,0,0,0,3.9,4.7,24.65,24.65,0,0,0,12.2,6A24.5,24.5,0,0,0,715.3,34a19.09,19.09,0,0,0,10.2-13.4h.5a21.68,21.68,0,0,0,21.1,13,13.67,13.67,0,0,0,1.9-.2,22.1,22.1,0,0,0,13.8-7.7,24.79,24.79,0,0,0,11.9,8.5,25.09,25.09,0,0,0,8.1,1.4,25.86,25.86,0,0,0,18.5-6.7,21.77,21.77,0,0,0,5.2-7.2,15,15,0,0,0,19.1-1,15,15,0,0,0,21,2,13.81,13.81,0,0,0,2.8-3.1A26.84,26.84,0,0,0,866.3,26a27.39,27.39,0,0,0,14-3.4,22.36,22.36,0,0,0,18.3,9.9c11.1.3,20.4-7,21.8-16.6a15,15,0,0,0,11.2.2,15,15,0,0,0,21.1,1,15.16,15.16,0,0,0,4.7-13.5A22.32,22.32,0,0,0,966.3,0H0V1.6A25.29,25.29,0,0,0,16.3,13.9Z"></path><path d="M983.6,7.3A22.61,22.61,0,0,0,1000,1.1V0H967.3A22.52,22.52,0,0,0,983.6,7.3Z"></path></svg>';
break;
case 'clouds' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 63.67" preserveAspectRatio="none"><path d="M916.2,58.53a46.9,46.9,0,0,1-46.1-17.89,32,32,0,0,1-14-4.4c-4.43,6.7-12.62,11.2-22,11.2-12,0-22.13-7.44-24.8-17.44a18.82,18.82,0,0,1-13.44,8.2,18.51,18.51,0,0,1-12.45-2.59h-.65a25.09,25.09,0,0,1-8.1-1.4,24.79,24.79,0,0,1-3.52-1.48,10.8,10.8,0,0,1-7.32-2.19,10.84,10.84,0,0,1-15.13,2.91,13.67,13.67,0,0,1-1.63.16,21.69,21.69,0,0,1-2.93,0,19.23,19.23,0,0,1-9.36,3.78,19.56,19.56,0,0,1-10.37-1.45A16,16,0,0,1,712,44.38c-7.56,1-14.51-3.07-16.67-9.28q-.71-.27-1.41-.58a10.82,10.82,0,0,1-7,.48,10.85,10.85,0,0,1-16.07,1.54,15.75,15.75,0,0,1-26.69.66,15.93,15.93,0,0,1-10.7-1.5c-.3-.2-.7-.4-1-.6,0,.2-.1.3-.1.4C629.2,45.1,618.4,51,607,48.9c-8.2-1.5-14.7-6.7-17.5-13.3a29.16,29.16,0,0,1-15.2,1.3,28.5,28.5,0,0,1-7-2.2,26.65,26.65,0,0,1-5.65-3.46A17.66,17.66,0,0,1,528,35.9a15.07,15.07,0,0,1-15.65-10.62,8.91,8.91,0,0,1-2.07.72L510,26a23.53,23.53,0,0,1-4.73,3.86,28.46,28.46,0,0,1-37.2-7.1c-2.3,9.3-12.6,15-23.2,12.7a21.31,21.31,0,0,1-14-9.9,20,20,0,0,1-9.3,2,14.17,14.17,0,0,1-6.7,11.8l-.05,0A14,14,0,0,1,395.6,34.8a13.84,13.84,0,0,1-10.3-2.1c-2.9,8.6-12.7,13.7-22.9,11.5a20.81,20.81,0,0,1-14.6-11c-.2-.4-.4-.9-.6-1.3a30.38,30.38,0,0,1-6,1.2,25.39,25.39,0,0,1-7.23-.41,13.46,13.46,0,0,1-16.46-2.33,23.88,23.88,0,0,1-14,8.3,24.3,24.3,0,0,1-13-.92,19.93,19.93,0,0,1-14.75,11.58c-9.84,2-19.24-3.1-21.9-11.42a13.43,13.43,0,0,1-10,1.91A13.49,13.49,0,0,1,219,32.56a20.31,20.31,0,0,1-8.94-2.07,20.31,20.31,0,0,1-13.62,9.33c-7.6,1.51-14.95-1.18-19.11-6.32a14.7,14.7,0,0,1-11.15-3.1,14.89,14.89,0,0,1-1.74-.57c-1,8.55-8.28,15.43-17.67,17a32.85,32.85,0,0,1-40.49-2.38,25.19,25.19,0,0,1-20.89,4.31v.09A50,50,0,0,1,0,68.64V86.47H1000V73.07a55,55,0,0,1-83.8-14.54Z" transform="translate(0 -22.8)"></path></svg>';
break;
case 'papertorn' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 80" preserveAspectRatio="none"><path d="M0,0V71.07l.22.05c2.83,1,7.45-4.57,7.45-4.57s13.36,6.34,14.9,6.6S30,76.45,30,76.45L36.7,71.5s5.4,6,8,4.95,16.19-8.88,17.73-3.55S64.2,80,65,80s5.4-5.59,6.42-5.59,11,2.79,11.82,2.79,7.71-5.84,9.25-6.6,18.24.51,22.1,2.66,14.13.13,19.79,0,25.18,1.9,25.18,1.9l8.48-1.9s0-5.46,1.8-5.2,9.25.51,9.25.51L180.34,65s20.81,2,22.1,2,2.31-3.81,4.37-3.81,14.13,3.81,15.42,3.81,9.25-3.55,11.56-3.81,8.48,5.08,10.28,5.58,55-6.6,55-6.6-.26-5.33,4.88-3.55,15.16,1.27,19.53,2,3.34,6.34,7.71,2.54,5.65-7.36,8.22-6.09,10.28,2.28,11,2.28,4.37-8.12,7.19-6.6,21.59,12.5,30.06,13.48,13.1-10.44,13.1-10.44l13.1,2.54s7.71,10.15,16.19,11.17,11,6.34,19.27,3.55,17.73-9.39,20-8.38,17.47-6.6,18.24-6.85,8.74.76,16.44.25,9.51-5.52,9.51-5.52,25.69-1.08,28.78,1.21,3.6,4.31,6.68,4.31,12.33-5.84,22.35-3.55,26,6.34,27.49,7.11,10.28-5.58,10.28-5.58,5.14,4.57,6.42,5.84,6.17.76,9.25,0,3.85-9.14,10-5.08,20.3-5.08,25.44,1S667,64,667,64s6.68-11.42,14.39-9.9S710.16,66.2,710.16,66.2l6.42-5.49,27.24-1.27s-1.28-7.11,6.17-5.33,10-.89,11-1.71,5.14-3.49,9,0,25.44,8.31,32.89,8.31,15.93-6.35,22.61-4.57,13.36-1.52,14.39-2-.77-4.65,6.42-3.47,19-.76,20.58-.25,6.17-.76,11.31-1.78,6.34-11.63,12.25-4.27,8.68,5.28,11.51,6.74,7.45,1.33,9.25,0-1.54-7.93,7.19-5.39,4.17,3.48,10.08,3,14.13,4.06,14.13,4.06,10.79-2,13.11-2.28,9.25-4.57,12.59-2.79,6.17,1.52,9,2.28,10-.51,11.82-1.78,2.57-6.35,7.71-3.55a11.91,11.91,0,0,1,3.14,2.18V0Z" style="opacity:0.66"></path><path d="M0,0V59.17c4.84-3,4.08,1,5.36-.23s0,0,2.57-1.27,3.08.51,7.19,1,2.83,2.54,2.83,2.54,8.74,5.08,10.28,4.57,4.88-9.14,4.37-10.15S40,61.22,40,61.22l4.37,3.3s9.76,2,11,1a59.11,59.11,0,0,1,8-4.57c1.8-.76,4.11,2.28,6.68,2.79s8.74,3.81,8.74,3.81S90.92,60.71,94,60.21s16.7,3.55,17.47,2,11.82-3,13.1-2.79,8.48,10.91,8.48,10.91l30.83-.51s6.68-6.09,7.45-7.61.26-1.78.26-1.78,9-4.57,10-4.57S193.18,61,193.18,61s10.54-4.06,14.39-5.08,6.68,1.52,12.85-2,19.79-2.79,20.56-3.3,7.45-6.34,12.85-9.39,11.31.76,13.1.76,7.71,5.33,10.79,4.57,10.28-5.33,13.62-5.33,2.83,2.28,10.28,1.78,5.91.51,12.59,4.32,8-2.29,12.85-3.55,1.8.25,4.63-.51a19,19,0,0,1,5.65-.76c1.29,0,2.57,1.52,8.74,3.55s5.91-.76,9.25-1.78,8.22-3.3,18.76-10.15,2.57,5.33,6.94,6.85,22.87,3.55,24.41,2,4.37-3,7.2-4.57,2.82-.51,3.59-.51,9,2.54,11.31,4.06,3.85,4.57,6.17,4.57,4.62-2.54,11-3.55-.26,4.82,0,5.58,2.06,0,5.4-.25,4.88-2.79,9.76-2.79,5.14,3.3,8.48,4.06,2.83,0,10.54-3.81,6.68-1.78,14.9-3.55,22.61,6.85,24.41,6.09,4.88-1.27,11.3-2.54,11.56,3,16.19,5.58,5.14-1.52,8.74-5.08,12.08.25,14.9.25,9.25-.25,13.36-.51,5.14-3,13.88-5.08,8,4.57,14.65,3.55,14.13-1.27,28-5.08,6.42,3,10.79,5.58,9,1.78,11.56,1.52S676,39.65,679.84,36.35s9.51,4.31,16.19,8.12,9.25,3.81,14.13,1.78,9.51-4.82,14.9-7.87,5.4,5.84,10,2.79,15.42.76,17.21-.25,8.48.76,15.42-1,1.8,2,7.45,6.85,3.08-2.29,15.42,1,28.52-2.29,32.89-3,4.88,5.33,9.25,5.84,5.4-4.82,9.76-7.87,17-.76,20.56-2a17.22,17.22,0,0,0,6.17-4.06s13.36,0,15.16-1.52,10.28-.76,13.36-.76,26,4.57,35.2,2.79,11.82-7.62,16.44-10.91,23.13,2.54,30.32,2.54,20.3-2.54,20.3-2.54V0Z"></path></svg>';
break;
case 'bridge' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 283 20.99" preserveAspectRatio="none"><path d="M81.66,18.4C67.67,6.89,32.57.93,18.57,20.33,14.2,14.75,6.34,11.48,0,9.75V0H0V21H143.75C134.52,9.95,107.42,1.35,81.66,18.4Z" transform="translate(0.02 -0.01)"></path><path d="M283,0V11c-3.82.72-6.67,2.21-13.46,9.21-15.71-21-52.38-5.64-55,.58-12.95-12.92-53.74-17.6-70.74.21H283V0Z" transform="translate(0.02 -0.01)"></path></svg>';
break;
case 'rockymoutain' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 90.1" preserveAspectRatio="none"><path d="M999.2,0V89.3c-2.1-.4-3.8.3-5.7.4,0,.1.1.2.1.3l-.3-.1a4.27,4.27,0,0,0-2.5-.1l-.1.1c-3.1-.8-2.6-3.4-8.3-3v-.5c-5.2-.2-10.4-.7-15.7-.5-5-.3-10.3-1.6-15.1-.8-5.6.9-10.9.7-16.4.8a29.31,29.31,0,0,0-7.2-1.2c-6.4-.3-8.2-2-8.6-4.3,0-.5-.2-1.1,1.2-1.5,3.9.1,5.7-1.1,8.4-2.1-4.9-1-9,.5-13.2.1h-2.4c-4.4-.6-.5-2.7-3.7-3.5a40,40,0,0,1-8.4-1.5c.3-2.6-3.8-4.2-8.5-5.5,0-1.1-.4-2.3,3.6-2.5h1.3l4.8-.5c3.3-.4,6.6-.9,9.7-1.5,1.8-.4,4-.6,4.9-1.5a.52.52,0,0,0,.4-.2c.1-.1,0-.2-.4-.3-2.2,0-4.4.1-6.6,0-4.4-.2-8.3,1.4-12.8.5a46.46,46.46,0,0,0-9.7-2l-2.4-1.5c.4-.1.4-.3,0-.5.7-2.2,3.8-3.3,9-3.5a6.54,6.54,0,0,0,3.1-.5c.4-2-2.7-1.1-4.9-1-2.5.8-4.9.2-7.3,0h-1.2c-3.5-2.3,2.3-3,4.6-4.1,4.6-2.2,4.5-2.8-2.1-4v-.5a257.26,257.26,0,0,0-29.1,1l-31.5,3.5a58.57,58.57,0,0,1-14.5,1.5c-1.2.7-3.1.4-4.8.5-1.3.7-3.2.4-4.9.5v.5c-7.2.4-14,1.5-20.7,2.5H779c-1.8-.7-4.2-1.2-5.3-2-5.1-3.7-13.8-5.8-21.2-8.5.1,0,.2-.1.3-.1.3-.3.2-.6-.5-.9-3.2-1.8-7.5-3.2-10.9-5l-1.2-.4a58.37,58.37,0,0,0-17-4.4,16.59,16.59,0,0,1-4.5-1.2c-8.4-2.7-15.5-6.4-27.9-5.9-1.8.1-3.2-.6-5-.8h-.2l-.1-.7a8.16,8.16,0,0,1-3.6-1.5c-8.7-2-18.3-3.1-27.8-4.1l-3.6-1-1.3-1c-5.8-.4-11.6-1.2-17,.5l-10.8.5a8.75,8.75,0,0,0-1.6-.2c-13.2-1.8-25.9-2.1-37.3,2.2-13.8.9-26.7,2.5-36.3,7.1l-2.6,2.5c-5.1,1.4-11.3,1.4-16.9,2-14.1.2-28.4-.3-41.8,2.2-.2,0-.4.1-.6.1-3.5.3-6,0-6-1.8,1.8-.8,1.7-1.7,0-2.5-1.5-2.3-6.3-4-6.2-6.5a16.84,16.84,0,0,1-4.8-2,42.72,42.72,0,0,0-21.8,2.5c-5.5.9-9,3.1-14.5,4l-2.5,1.4-4.8.5a13.86,13.86,0,0,1-5.3,1l-20,1.5a1.71,1.71,0,0,0-1.4,0c-6.9.5-12.2,3-19.9,2.9,3.2-.6,3-2.1,5.4-2.9.6-2.1.6-2.1-1.2-2.5-3.9.2-5.9,2.8-10.9,1.5-.4-.5-.5-1.2-2.4-.9h-.1c-1.3-1.4-2.2-3-7.5-2.2-.8.2-2.3-.5-3.4-.8,1.9-.8,3.3-1.7,4.9-2.5,2.5-.2,4.8-.5,6.1-1.5-.8-1.4-2.9-.7-4.8-.5a63.58,63.58,0,0,1-14.5,1c-1.5-.5-1-1,0-1.5l1.2-.5a11.6,11.6,0,0,0,2.4-2c2.7-.3,6.2.1,7.3-1.5h1.2c.7-.6,2.7-1.1,1.2-2l-6.1-1c-1.6.5-3.2-.7-4.8,0-6.7,1.1-13,2.7-20.6,2.5-.7.3-2,.2-2.6.5-2.4.2-5-.4-7.1.5-1.6,0-2.4.4-2.5,1l-2.3.5a36.43,36.43,0,0,0-13.4,3.5c-3.5.6-5.7,2.1-9.7,2.5-1.3,1.1-4.1,1.3-6.2,1.8-3.3.8-7.5,1.1-9.5,2.7-2.7-.1-3.5,1-4.9,1.6-4,1.8-9.8,3-12.1,5.5h-4.8c-3.4-1-7.3-.3-10.9-.5-1.9-1.3-1.6-3.6-7.9-3-1.5.1-4.2.5-4.7-.5s2.6-1.1,4.1-1.5c1.1-.4,3-.8,3-1.2.2-2.5,4.4-3.9,8.6-5.6-2.2-.3-5.1.3-6.4-.7-1.1-.9,3.7-.3,1.9-1.6-8.8,1.2-15.3,4-22.7,6.1l-3.7,1c-3.4.8-7.6,0-10.9,1-3.4.3-5.4,1.1-6.1,2.5-4.1,1.8-7.8,3.8-12.5,5.3A30.53,30.53,0,0,0,175.5,44c-1.9.4-3.5,1-3.6,2-2.2.6-4.5,1.2-4.8,2.5-3,.6-4,2-6,3-2,.4-3.6,1-3.7,2-3.3,1-4.3,2.4-4.2,4.1.1,2.5-3.7,4.7-9.3,5.5-3.5.5-7.1.9-10.7,1.4-4.5.6-9.4.5-13.6,1.6a8.07,8.07,0,0,1-5.7-.6c-1.6-.9-2.9-2.3-5.8-1.8s-2.7,2.1-2.7,3.3v1c-.1,0-.2.1-.3.2-1.6,1-2.4,2.4-6.6,2.3-3.9-.1-4.9-1.4-6.4-2.5,0-1.1-.4-2.1-3.3-2.8-.1,1.3-1.2,2.4.9,3.3-.1,1.4-3.8,1.9-4.9,3a4,4,0,0,0-2.4.5c-2.9.7-5.2.7-6.2-.9-.7-1.2-2.6-1.9-5.4-2.2-2.4,1.6-.6,3.7-4.1,5.1-6.5,0-4.6,2-4.8,3.4-.3,2.3-1.2,2.6-5.8,1.4-4-1.1-5-.3-5.1,1.2v4.8c-3.7-2.1-7.9-2.6-10.9-3.8l-1.2-2c.2-1.6-1.7-2.7-4.5-3.6-1.6-.5-3.1-.1-2.3.6,1.5,1.3-.5,2.8,2,4v1.5c-.4,2.6-7,4.2-6.1,7-3.6.8-6.8.9-9.1-.9-.7-.5-2.8-1.4-3.5-.4C13.7,89.9,9.1,89,5,89L1.3,85.5A2.07,2.07,0,0,0,0,84.4v5.7H1000V0Z" transform="translate(0 0)"></path></svg>';
break;
case 'singlewave' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 99" preserveAspectRatio="none"><path d="M768.06,59.54C687,48.21,607.41,28.42,526.35,17.15,347.45-7.73,155.24,13.87.07,99H1000V68.11A1149.19,1149.19,0,0,1,768.06,59.54Z"></path><rect width="1000" height="0.04"></rect></svg>';
break;
case 'multislope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" preserveAspectRatio="none"><path d="M0,22.3V0H1000V100Z" transform="translate(0 0)" style="opacity:0.66"></path><path d="M0,6V0H1000V100Z" transform="translate(0 0)"></path></svg>';
break;
case 'slope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 94" preserveAspectRatio="none"><polygon points="0 94 1000 94 0 0 0 94"></polygon></svg>';
break;
case 'waves3' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 84.94" preserveAspectRatio="none"><path d="M0,0V72.94c14.46,5.89,32.38,10.5,54.52.26,110.25-51,120.51,23.71,192.6-4.3,144.73-56.23,154.37,49.44,246.71,4.64C637,4.05,622.19,124.16,757.29,66.21c93-39.91,108.38,54.92,242.71-8.25V0Z" style="fill-rule:evenodd;opacity:0.33"></path><path d="M0,0V52.83c131.11,59.9,147-32.91,239.24,6.65,135.09,58,120.24-62.16,263.46,7.34,92.33,44.8,102-60.88,246.71-4.64,72.1,28,82.35-46.71,192.6,4.3,23.95,11.08,43,4.78,58-1.72V0Z" style="fill-rule:evenodd;opacity:0.66"></path><path d="M0,0V24.26c15.6,6.95,35.77,15.41,61.78,3.38,110.25-51,120.51,23.71,192.6-4.3C399.11-32.89,408.75,72.79,501.08,28,644.3-41.51,629.45,78.6,764.54,20.65,855.87-18.53,872.34,72.12,1000,15.7V0Z" style="fill-rule:evenodd"></path></svg>';
break;
case 'drip' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 91.02" preserveAspectRatio="none"><path d="M772,11c-32.4,4-58,9.51-58,9.51C685.3,26.69,659.67,34.32,658,35c-15.34,6.3-25.24,13.11-43,13-27.54-.18-37.37-16.79-56-11-19,5.91-19.53,26.54-35,27-13.47.4-16.5-15.14-36-18-1.32-.19-15.92-2.13-29,6-20.34,12.64-18.82,38.28-28,39-8.62.68-10.8-21.86-26-40-5.44-6.49-24.19-25.34-100-32a429.73,429.73,0,0,0-94,2C165,26.91,96.11,27.3,0,0V91H1000V0C894.78,1.07,813.3,5.92,772,11Z" transform="translate(0 0)"></path></svg>';
break;
case 'asymslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none"><polygon points="0 89 741 89 0 0 0 89"></polygon><polygon points="741 89 1000 89 1000 0 741 89"></polygon></svg>';
break;
case 'vslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" style="width: 100%; max-width: 100%;"><polygon points="0 89 500 89 0 0 0 89"></polygon><polygon points="500 89 1000 89 1000 0 500 89"></polygon></svg>';
break;
case 'multivslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" style="width: 100%; max-width: 100%;"><polygon points="0 89 500 89 0 20 0 89"></polygon><polygon points="500 89 1000 89 1000 20 500 89"></polygon><polygon style="opacity: 0.6;" points="0 20 500 89 0 0 0 89"></polygon><polygon style="opacity: 0.6;" points="500 89 1000 20 1000 0 500 89"></polygon></svg>';
break;
case 'multiv3slope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" ><polygon points="0 89 500 89 0 40 0 89"></polygon><polygon points="500 89 1000 89 1000 40 500 89"></polygon><polygon style="opacity: 0.6;" points="0 40 500 89 0 20 0 69"></polygon><polygon style="opacity: 0.6;" points="500 89 1000 20 1000 40 500 89"></polygon><polygon style="opacity: 0.3;" points="0 20 500 89 0 0 0 89" ></polygon><polygon style="opacity: 0.3;" points="500 89 1000 20 1000 0 500 89"></polygon></svg>';
break;
case 'triangle' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 100"><polygon points="0 100 1000 100 1000 50 550 50 500 0 450 50 0 50 0 100"></polygon></svg>';
break;
case 'trianglesmall' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><polygon points="0 50 1000 50 1000 25 520 25 500 0 480 25 0 25 0 50"></polygon></svg>';
break;
case 'triangle3' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><polygon points="0 50 1000 50 1000 25 560 25 540 0 520 25 500 0 480 25 460 0 440 25 0 25 0 50"></polygon></svg>';
break;
case 'ellipse' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><path d="M0 50 C 200 0 500 0 1000 50 Z"></path></svg>';
break;
case 'none' :
default :
focus.find('.tck-divider-container').remove();
return;
break;
}
if (! focus.find('.tck-divider1-container').length) focus.prepend('<div class="tck-divider-container tck-divider1-container">' + svgpath + '</div>');
var divider = focus.find('.tck-divider1-container');
// position
if ($ck('#' + prefix + 'position').val() == 'top') {
divider.removeClass('pbck-divider-bottom').addClass('pbck-divider-top');
} else {
divider.removeClass('pbck-divider-top').addClass('pbck-divider-bottom');
}
// placement
if ($ck('#' + prefix + 'placement').val() == 'over') {
divider.removeClass('pbck-divider-under').addClass('pbck-divider-over');
} else {
divider.removeClass('pbck-divider-over').addClass('pbck-divider-under');
}
// flip
if ($ck('#' + prefix + 'fliphorizontal').val() == '1') {
divider.addClass('ckflip-horizontal');
} else {
divider.removeClass('ckflip-horizontal');
}
if ($ck('#' + prefix + 'flipvertical').val() == '1') {
divider.addClass('ckflip-vertical');
} else {
divider.removeClass('ckflip-vertical');
}
divider.find('path, polygon').attr('fill', $ck('#' + prefix + 'color').val());
divider.css('background-color', $ck('#' + prefix + 'bgcolor').val());
divider.css('height', ckTestUnit($ck('#' + prefix + 'height').val()));
divider.find('svg').css('width', ckTestUnit($ck('#' + prefix + 'width').val()));
divider.find('svg').css('max-width', ckTestUnit($ck('#' + prefix + 'width').val()));
} else {
focus.find('.tck-divider2-container').remove();
// for the 2nd divider
switch ($ck('#' + prefix + 'shape').val()) {
case 'multiclouds' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 86.47" preserveAspectRatio="none"><g style="opacity:0.33"><path d="M823,15.52l.24-.07A27.72,27.72,0,0,0,864.3,30.53a46.9,46.9,0,0,0,51.9,28A55,55,0,0,0,1000,73.07V0H792C795.79,12,809.32,18.85,823,15.52Z"></path><path d="M23.71,83.4A50,50,0,0,0,85.39,48.77v-.05a25.19,25.19,0,0,0,20.89-4.31,32.67,32.67,0,0,0,12.82,7A32.88,32.88,0,0,0,154.31,0H0V68.64A49.74,49.74,0,0,0,23.71,83.4Z"></path></g><g style="opacity:0.66"><path d="M499.63,19.13h.08a8.91,8.91,0,0,0,12.64,6.15A15.07,15.07,0,0,0,528,35.9a17.67,17.67,0,0,0,33.67-9.55v0A8.9,8.9,0,0,0,567.86,22a11.61,11.61,0,0,0,7.48-22H503.08a11.65,11.65,0,0,0-1.71,4.21,9.2,9.2,0,0,0-3.85-.28c-4.65.65-8,4.58-7.37,8.77S495,19.78,499.63,19.13Z"></path><path d="M631.55,20.67c1,7.6,8.68,12.87,17.22,11.78a16.35,16.35,0,0,0,11.45-6.74,16.34,16.34,0,0,0,7.07,2.14A10.86,10.86,0,0,0,686.86,35a10.82,10.82,0,0,0,8.1-1c1.68,6.83,9,11.4,17,10.38a16,16,0,0,0,12.48-8.49,19.56,19.56,0,0,0,10.37,1.45,19.24,19.24,0,0,0,11.72-5.89,10.85,10.85,0,0,0,17.33-.92A10.81,10.81,0,0,0,776,31.2a17.64,17.64,0,0,0,3.38,1,18.52,18.52,0,0,0,16.52,6A18.82,18.82,0,0,0,809.34,30c2.67,10,12.75,17.44,24.8,17.44,9.38,0,17.57-4.5,22-11.2a32,32,0,0,0,16.53,4.5,31.47,31.47,0,0,0,20.23-7.14,17.75,17.75,0,0,0,28.32,2.09,17.74,17.74,0,0,0,22.71,1.75c4.13,10.05,15,17.22,27.72,17.22,13.43,0,24.75-8,28.33-18.88V0H599.32C607.84,23.13,631.55,20.67,631.55,20.67Z"></path><path d="M.74,30.73c0,12.33,11.21,22.33,25.08,22.36,10.84,0,20.08-6.07,23.61-14.62A15.09,15.09,0,0,0,68.74,37a15.1,15.1,0,0,0,24.1-1.74,26.76,26.76,0,0,0,17.2,6.1,27.24,27.24,0,0,0,14.07-3.81,22.33,22.33,0,0,0,18.71,9.56c11.24,0,20.49-7.56,21.62-17.28a14.92,14.92,0,0,0,10.72.18c3.29,7.35,12.1,11.63,21.28,9.81a20.31,20.31,0,0,0,13.62-9.33A20.31,20.31,0,0,0,219,32.56a13.49,13.49,0,0,0,24.86,7.25,13.43,13.43,0,0,0,10-1.91c2.66,8.32,12.06,13.37,21.9,11.42a19.93,19.93,0,0,0,14.75-11.58,24.3,24.3,0,0,0,13,.92,23.88,23.88,0,0,0,14-8.3,13.47,13.47,0,0,0,21.4-2.61,13.46,13.46,0,0,0,17.17-2c4.56,6.88,13.69,10.63,23.18,8.76,12.14-2.4,20.26-13.09,18.13-23.88A73.93,73.93,0,0,0,400.48,0H0V29.49C.24,29.91.48,30.32.74,30.73Z"></path></g><path d="M16.3,13.9c10.2,2.5,20.3-1.1,25.5-8.3a14.66,14.66,0,0,0,18.5,3A14.6,14.6,0,0,0,80,14.9a13.14,13.14,0,0,0,3.4-2.4,25.71,25.71,0,0,0,14.8,9.7,26,26,0,0,0,14.1-.4,21.75,21.75,0,0,0,15.4,13.3c10.6,2.6,21-2.4,24.3-11.3a15,15,0,0,0,10.7,2.6,17.69,17.69,0,0,0,1.6,2.2,14.69,14.69,0,0,0,17.6,3.5,7.46,7.46,0,0,0,1.2-.7,14.54,14.54,0,0,0,6.4-8.9,12.61,12.61,0,0,0,.4-2.8,20.63,20.63,0,0,0,9.8-1.8,11.35,11.35,0,0,0,1.5,2.3A22.35,22.35,0,0,0,214,28.6c11.2,2.8,22.4-3.1,24.8-13.1a24.63,24.63,0,0,0,16.3,11.6c9.8,2.1,19.4-1.7,24.2-8.7a14,14,0,0,0,17.8,2.4,14.07,14.07,0,0,0,19.1,5.4,12.25,12.25,0,0,0,3.1-2.4,22.5,22.5,0,0,0,5.8,5.3,25.42,25.42,0,0,0,16.1,4,30.38,30.38,0,0,0,6-1.2c.2.4.4.9.6,1.3a20.81,20.81,0,0,0,14.6,11c10.2,2.2,20-2.9,22.9-11.5a13.84,13.84,0,0,0,10.3,2.1,14,14,0,0,0,19.3,4.6,14.17,14.17,0,0,0,6.7-11.8,20,20,0,0,0,9.3-2,21.31,21.31,0,0,0,14,9.9c10.6,2.3,20.9-3.4,23.2-12.7a28.46,28.46,0,0,0,37.2,7.1,23.54,23.54,0,0,0,7.3-7.1,15.79,15.79,0,0,0,20.1,2.1,15.69,15.69,0,0,0,21.6,5.5,13.88,13.88,0,0,0,3.5-2.9,26.66,26.66,0,0,0,9.5,7.2,28.5,28.5,0,0,0,7,2.2,29.16,29.16,0,0,0,15.2-1.3c2.8,6.6,9.3,11.8,17.5,13.3,11.4,2.1,22.2-3.8,25.3-13.4,0-.1.1-.2.1-.4.3.2.7.4,1,.6a15.93,15.93,0,0,0,10.7,1.5,15.79,15.79,0,0,0,28.7-6c.1-.4.1-.8.2-1.2a10.87,10.87,0,0,0,.1-1.8,22.26,22.26,0,0,0,10.4-2.6,25,25,0,0,0,3.9,4.7,24.65,24.65,0,0,0,12.2,6A24.5,24.5,0,0,0,715.3,34a19.09,19.09,0,0,0,10.2-13.4h.5a21.68,21.68,0,0,0,21.1,13,13.67,13.67,0,0,0,1.9-.2,22.1,22.1,0,0,0,13.8-7.7,24.79,24.79,0,0,0,11.9,8.5,25.09,25.09,0,0,0,8.1,1.4,25.86,25.86,0,0,0,18.5-6.7,21.77,21.77,0,0,0,5.2-7.2,15,15,0,0,0,19.1-1,15,15,0,0,0,21,2,13.81,13.81,0,0,0,2.8-3.1A26.84,26.84,0,0,0,866.3,26a27.39,27.39,0,0,0,14-3.4,22.36,22.36,0,0,0,18.3,9.9c11.1.3,20.4-7,21.8-16.6a15,15,0,0,0,11.2.2,15,15,0,0,0,21.1,1,15.16,15.16,0,0,0,4.7-13.5A22.32,22.32,0,0,0,966.3,0H0V1.6A25.29,25.29,0,0,0,16.3,13.9Z"></path><path d="M983.6,7.3A22.61,22.61,0,0,0,1000,1.1V0H967.3A22.52,22.52,0,0,0,983.6,7.3Z"></path></svg>';
break;
case 'clouds' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 63.67" preserveAspectRatio="none"><path d="M916.2,58.53a46.9,46.9,0,0,1-46.1-17.89,32,32,0,0,1-14-4.4c-4.43,6.7-12.62,11.2-22,11.2-12,0-22.13-7.44-24.8-17.44a18.82,18.82,0,0,1-13.44,8.2,18.51,18.51,0,0,1-12.45-2.59h-.65a25.09,25.09,0,0,1-8.1-1.4,24.79,24.79,0,0,1-3.52-1.48,10.8,10.8,0,0,1-7.32-2.19,10.84,10.84,0,0,1-15.13,2.91,13.67,13.67,0,0,1-1.63.16,21.69,21.69,0,0,1-2.93,0,19.23,19.23,0,0,1-9.36,3.78,19.56,19.56,0,0,1-10.37-1.45A16,16,0,0,1,712,44.38c-7.56,1-14.51-3.07-16.67-9.28q-.71-.27-1.41-.58a10.82,10.82,0,0,1-7,.48,10.85,10.85,0,0,1-16.07,1.54,15.75,15.75,0,0,1-26.69.66,15.93,15.93,0,0,1-10.7-1.5c-.3-.2-.7-.4-1-.6,0,.2-.1.3-.1.4C629.2,45.1,618.4,51,607,48.9c-8.2-1.5-14.7-6.7-17.5-13.3a29.16,29.16,0,0,1-15.2,1.3,28.5,28.5,0,0,1-7-2.2,26.65,26.65,0,0,1-5.65-3.46A17.66,17.66,0,0,1,528,35.9a15.07,15.07,0,0,1-15.65-10.62,8.91,8.91,0,0,1-2.07.72L510,26a23.53,23.53,0,0,1-4.73,3.86,28.46,28.46,0,0,1-37.2-7.1c-2.3,9.3-12.6,15-23.2,12.7a21.31,21.31,0,0,1-14-9.9,20,20,0,0,1-9.3,2,14.17,14.17,0,0,1-6.7,11.8l-.05,0A14,14,0,0,1,395.6,34.8a13.84,13.84,0,0,1-10.3-2.1c-2.9,8.6-12.7,13.7-22.9,11.5a20.81,20.81,0,0,1-14.6-11c-.2-.4-.4-.9-.6-1.3a30.38,30.38,0,0,1-6,1.2,25.39,25.39,0,0,1-7.23-.41,13.46,13.46,0,0,1-16.46-2.33,23.88,23.88,0,0,1-14,8.3,24.3,24.3,0,0,1-13-.92,19.93,19.93,0,0,1-14.75,11.58c-9.84,2-19.24-3.1-21.9-11.42a13.43,13.43,0,0,1-10,1.91A13.49,13.49,0,0,1,219,32.56a20.31,20.31,0,0,1-8.94-2.07,20.31,20.31,0,0,1-13.62,9.33c-7.6,1.51-14.95-1.18-19.11-6.32a14.7,14.7,0,0,1-11.15-3.1,14.89,14.89,0,0,1-1.74-.57c-1,8.55-8.28,15.43-17.67,17a32.85,32.85,0,0,1-40.49-2.38,25.19,25.19,0,0,1-20.89,4.31v.09A50,50,0,0,1,0,68.64V86.47H1000V73.07a55,55,0,0,1-83.8-14.54Z" transform="translate(0 -22.8)"></path></svg>';
break;
case 'papertorn' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 80" preserveAspectRatio="none"><path d="M0,0V71.07l.22.05c2.83,1,7.45-4.57,7.45-4.57s13.36,6.34,14.9,6.6S30,76.45,30,76.45L36.7,71.5s5.4,6,8,4.95,16.19-8.88,17.73-3.55S64.2,80,65,80s5.4-5.59,6.42-5.59,11,2.79,11.82,2.79,7.71-5.84,9.25-6.6,18.24.51,22.1,2.66,14.13.13,19.79,0,25.18,1.9,25.18,1.9l8.48-1.9s0-5.46,1.8-5.2,9.25.51,9.25.51L180.34,65s20.81,2,22.1,2,2.31-3.81,4.37-3.81,14.13,3.81,15.42,3.81,9.25-3.55,11.56-3.81,8.48,5.08,10.28,5.58,55-6.6,55-6.6-.26-5.33,4.88-3.55,15.16,1.27,19.53,2,3.34,6.34,7.71,2.54,5.65-7.36,8.22-6.09,10.28,2.28,11,2.28,4.37-8.12,7.19-6.6,21.59,12.5,30.06,13.48,13.1-10.44,13.1-10.44l13.1,2.54s7.71,10.15,16.19,11.17,11,6.34,19.27,3.55,17.73-9.39,20-8.38,17.47-6.6,18.24-6.85,8.74.76,16.44.25,9.51-5.52,9.51-5.52,25.69-1.08,28.78,1.21,3.6,4.31,6.68,4.31,12.33-5.84,22.35-3.55,26,6.34,27.49,7.11,10.28-5.58,10.28-5.58,5.14,4.57,6.42,5.84,6.17.76,9.25,0,3.85-9.14,10-5.08,20.3-5.08,25.44,1S667,64,667,64s6.68-11.42,14.39-9.9S710.16,66.2,710.16,66.2l6.42-5.49,27.24-1.27s-1.28-7.11,6.17-5.33,10-.89,11-1.71,5.14-3.49,9,0,25.44,8.31,32.89,8.31,15.93-6.35,22.61-4.57,13.36-1.52,14.39-2-.77-4.65,6.42-3.47,19-.76,20.58-.25,6.17-.76,11.31-1.78,6.34-11.63,12.25-4.27,8.68,5.28,11.51,6.74,7.45,1.33,9.25,0-1.54-7.93,7.19-5.39,4.17,3.48,10.08,3,14.13,4.06,14.13,4.06,10.79-2,13.11-2.28,9.25-4.57,12.59-2.79,6.17,1.52,9,2.28,10-.51,11.82-1.78,2.57-6.35,7.71-3.55a11.91,11.91,0,0,1,3.14,2.18V0Z" style="opacity:0.66"></path><path d="M0,0V59.17c4.84-3,4.08,1,5.36-.23s0,0,2.57-1.27,3.08.51,7.19,1,2.83,2.54,2.83,2.54,8.74,5.08,10.28,4.57,4.88-9.14,4.37-10.15S40,61.22,40,61.22l4.37,3.3s9.76,2,11,1a59.11,59.11,0,0,1,8-4.57c1.8-.76,4.11,2.28,6.68,2.79s8.74,3.81,8.74,3.81S90.92,60.71,94,60.21s16.7,3.55,17.47,2,11.82-3,13.1-2.79,8.48,10.91,8.48,10.91l30.83-.51s6.68-6.09,7.45-7.61.26-1.78.26-1.78,9-4.57,10-4.57S193.18,61,193.18,61s10.54-4.06,14.39-5.08,6.68,1.52,12.85-2,19.79-2.79,20.56-3.3,7.45-6.34,12.85-9.39,11.31.76,13.1.76,7.71,5.33,10.79,4.57,10.28-5.33,13.62-5.33,2.83,2.28,10.28,1.78,5.91.51,12.59,4.32,8-2.29,12.85-3.55,1.8.25,4.63-.51a19,19,0,0,1,5.65-.76c1.29,0,2.57,1.52,8.74,3.55s5.91-.76,9.25-1.78,8.22-3.3,18.76-10.15,2.57,5.33,6.94,6.85,22.87,3.55,24.41,2,4.37-3,7.2-4.57,2.82-.51,3.59-.51,9,2.54,11.31,4.06,3.85,4.57,6.17,4.57,4.62-2.54,11-3.55-.26,4.82,0,5.58,2.06,0,5.4-.25,4.88-2.79,9.76-2.79,5.14,3.3,8.48,4.06,2.83,0,10.54-3.81,6.68-1.78,14.9-3.55,22.61,6.85,24.41,6.09,4.88-1.27,11.3-2.54,11.56,3,16.19,5.58,5.14-1.52,8.74-5.08,12.08.25,14.9.25,9.25-.25,13.36-.51,5.14-3,13.88-5.08,8,4.57,14.65,3.55,14.13-1.27,28-5.08,6.42,3,10.79,5.58,9,1.78,11.56,1.52S676,39.65,679.84,36.35s9.51,4.31,16.19,8.12,9.25,3.81,14.13,1.78,9.51-4.82,14.9-7.87,5.4,5.84,10,2.79,15.42.76,17.21-.25,8.48.76,15.42-1,1.8,2,7.45,6.85,3.08-2.29,15.42,1,28.52-2.29,32.89-3,4.88,5.33,9.25,5.84,5.4-4.82,9.76-7.87,17-.76,20.56-2a17.22,17.22,0,0,0,6.17-4.06s13.36,0,15.16-1.52,10.28-.76,13.36-.76,26,4.57,35.2,2.79,11.82-7.62,16.44-10.91,23.13,2.54,30.32,2.54,20.3-2.54,20.3-2.54V0Z"></path></svg>';
break;
case 'bridge' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 283 20.99" preserveAspectRatio="none"><path d="M81.66,18.4C67.67,6.89,32.57.93,18.57,20.33,14.2,14.75,6.34,11.48,0,9.75V0H0V21H143.75C134.52,9.95,107.42,1.35,81.66,18.4Z" transform="translate(0.02 -0.01)"></path><path d="M283,0V11c-3.82.72-6.67,2.21-13.46,9.21-15.71-21-52.38-5.64-55,.58-12.95-12.92-53.74-17.6-70.74.21H283V0Z" transform="translate(0.02 -0.01)"></path></svg>';
break;
case 'rockymoutain' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 90.1" preserveAspectRatio="none"><path d="M999.2,0V89.3c-2.1-.4-3.8.3-5.7.4,0,.1.1.2.1.3l-.3-.1a4.27,4.27,0,0,0-2.5-.1l-.1.1c-3.1-.8-2.6-3.4-8.3-3v-.5c-5.2-.2-10.4-.7-15.7-.5-5-.3-10.3-1.6-15.1-.8-5.6.9-10.9.7-16.4.8a29.31,29.31,0,0,0-7.2-1.2c-6.4-.3-8.2-2-8.6-4.3,0-.5-.2-1.1,1.2-1.5,3.9.1,5.7-1.1,8.4-2.1-4.9-1-9,.5-13.2.1h-2.4c-4.4-.6-.5-2.7-3.7-3.5a40,40,0,0,1-8.4-1.5c.3-2.6-3.8-4.2-8.5-5.5,0-1.1-.4-2.3,3.6-2.5h1.3l4.8-.5c3.3-.4,6.6-.9,9.7-1.5,1.8-.4,4-.6,4.9-1.5a.52.52,0,0,0,.4-.2c.1-.1,0-.2-.4-.3-2.2,0-4.4.1-6.6,0-4.4-.2-8.3,1.4-12.8.5a46.46,46.46,0,0,0-9.7-2l-2.4-1.5c.4-.1.4-.3,0-.5.7-2.2,3.8-3.3,9-3.5a6.54,6.54,0,0,0,3.1-.5c.4-2-2.7-1.1-4.9-1-2.5.8-4.9.2-7.3,0h-1.2c-3.5-2.3,2.3-3,4.6-4.1,4.6-2.2,4.5-2.8-2.1-4v-.5a257.26,257.26,0,0,0-29.1,1l-31.5,3.5a58.57,58.57,0,0,1-14.5,1.5c-1.2.7-3.1.4-4.8.5-1.3.7-3.2.4-4.9.5v.5c-7.2.4-14,1.5-20.7,2.5H779c-1.8-.7-4.2-1.2-5.3-2-5.1-3.7-13.8-5.8-21.2-8.5.1,0,.2-.1.3-.1.3-.3.2-.6-.5-.9-3.2-1.8-7.5-3.2-10.9-5l-1.2-.4a58.37,58.37,0,0,0-17-4.4,16.59,16.59,0,0,1-4.5-1.2c-8.4-2.7-15.5-6.4-27.9-5.9-1.8.1-3.2-.6-5-.8h-.2l-.1-.7a8.16,8.16,0,0,1-3.6-1.5c-8.7-2-18.3-3.1-27.8-4.1l-3.6-1-1.3-1c-5.8-.4-11.6-1.2-17,.5l-10.8.5a8.75,8.75,0,0,0-1.6-.2c-13.2-1.8-25.9-2.1-37.3,2.2-13.8.9-26.7,2.5-36.3,7.1l-2.6,2.5c-5.1,1.4-11.3,1.4-16.9,2-14.1.2-28.4-.3-41.8,2.2-.2,0-.4.1-.6.1-3.5.3-6,0-6-1.8,1.8-.8,1.7-1.7,0-2.5-1.5-2.3-6.3-4-6.2-6.5a16.84,16.84,0,0,1-4.8-2,42.72,42.72,0,0,0-21.8,2.5c-5.5.9-9,3.1-14.5,4l-2.5,1.4-4.8.5a13.86,13.86,0,0,1-5.3,1l-20,1.5a1.71,1.71,0,0,0-1.4,0c-6.9.5-12.2,3-19.9,2.9,3.2-.6,3-2.1,5.4-2.9.6-2.1.6-2.1-1.2-2.5-3.9.2-5.9,2.8-10.9,1.5-.4-.5-.5-1.2-2.4-.9h-.1c-1.3-1.4-2.2-3-7.5-2.2-.8.2-2.3-.5-3.4-.8,1.9-.8,3.3-1.7,4.9-2.5,2.5-.2,4.8-.5,6.1-1.5-.8-1.4-2.9-.7-4.8-.5a63.58,63.58,0,0,1-14.5,1c-1.5-.5-1-1,0-1.5l1.2-.5a11.6,11.6,0,0,0,2.4-2c2.7-.3,6.2.1,7.3-1.5h1.2c.7-.6,2.7-1.1,1.2-2l-6.1-1c-1.6.5-3.2-.7-4.8,0-6.7,1.1-13,2.7-20.6,2.5-.7.3-2,.2-2.6.5-2.4.2-5-.4-7.1.5-1.6,0-2.4.4-2.5,1l-2.3.5a36.43,36.43,0,0,0-13.4,3.5c-3.5.6-5.7,2.1-9.7,2.5-1.3,1.1-4.1,1.3-6.2,1.8-3.3.8-7.5,1.1-9.5,2.7-2.7-.1-3.5,1-4.9,1.6-4,1.8-9.8,3-12.1,5.5h-4.8c-3.4-1-7.3-.3-10.9-.5-1.9-1.3-1.6-3.6-7.9-3-1.5.1-4.2.5-4.7-.5s2.6-1.1,4.1-1.5c1.1-.4,3-.8,3-1.2.2-2.5,4.4-3.9,8.6-5.6-2.2-.3-5.1.3-6.4-.7-1.1-.9,3.7-.3,1.9-1.6-8.8,1.2-15.3,4-22.7,6.1l-3.7,1c-3.4.8-7.6,0-10.9,1-3.4.3-5.4,1.1-6.1,2.5-4.1,1.8-7.8,3.8-12.5,5.3A30.53,30.53,0,0,0,175.5,44c-1.9.4-3.5,1-3.6,2-2.2.6-4.5,1.2-4.8,2.5-3,.6-4,2-6,3-2,.4-3.6,1-3.7,2-3.3,1-4.3,2.4-4.2,4.1.1,2.5-3.7,4.7-9.3,5.5-3.5.5-7.1.9-10.7,1.4-4.5.6-9.4.5-13.6,1.6a8.07,8.07,0,0,1-5.7-.6c-1.6-.9-2.9-2.3-5.8-1.8s-2.7,2.1-2.7,3.3v1c-.1,0-.2.1-.3.2-1.6,1-2.4,2.4-6.6,2.3-3.9-.1-4.9-1.4-6.4-2.5,0-1.1-.4-2.1-3.3-2.8-.1,1.3-1.2,2.4.9,3.3-.1,1.4-3.8,1.9-4.9,3a4,4,0,0,0-2.4.5c-2.9.7-5.2.7-6.2-.9-.7-1.2-2.6-1.9-5.4-2.2-2.4,1.6-.6,3.7-4.1,5.1-6.5,0-4.6,2-4.8,3.4-.3,2.3-1.2,2.6-5.8,1.4-4-1.1-5-.3-5.1,1.2v4.8c-3.7-2.1-7.9-2.6-10.9-3.8l-1.2-2c.2-1.6-1.7-2.7-4.5-3.6-1.6-.5-3.1-.1-2.3.6,1.5,1.3-.5,2.8,2,4v1.5c-.4,2.6-7,4.2-6.1,7-3.6.8-6.8.9-9.1-.9-.7-.5-2.8-1.4-3.5-.4C13.7,89.9,9.1,89,5,89L1.3,85.5A2.07,2.07,0,0,0,0,84.4v5.7H1000V0Z" transform="translate(0 0)"></path></svg>';
break;
case 'singlewave' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 99" preserveAspectRatio="none"><path d="M768.06,59.54C687,48.21,607.41,28.42,526.35,17.15,347.45-7.73,155.24,13.87.07,99H1000V68.11A1149.19,1149.19,0,0,1,768.06,59.54Z"></path><rect width="1000" height="0.04"></rect></svg>';
break;
case 'multislope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" preserveAspectRatio="none"><path d="M0,22.3V0H1000V100Z" transform="translate(0 0)" style="opacity:0.66"></path><path d="M0,6V0H1000V100Z" transform="translate(0 0)"></path></svg>';
break;
case 'slope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 94" preserveAspectRatio="none"><polygon points="0 94 1000 94 0 0 0 94"></polygon></svg>';
break;
case 'waves3' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 84.94" preserveAspectRatio="none"><path d="M0,0V72.94c14.46,5.89,32.38,10.5,54.52.26,110.25-51,120.51,23.71,192.6-4.3,144.73-56.23,154.37,49.44,246.71,4.64C637,4.05,622.19,124.16,757.29,66.21c93-39.91,108.38,54.92,242.71-8.25V0Z" style="fill-rule:evenodd;opacity:0.33"></path><path d="M0,0V52.83c131.11,59.9,147-32.91,239.24,6.65,135.09,58,120.24-62.16,263.46,7.34,92.33,44.8,102-60.88,246.71-4.64,72.1,28,82.35-46.71,192.6,4.3,23.95,11.08,43,4.78,58-1.72V0Z" style="fill-rule:evenodd;opacity:0.66"></path><path d="M0,0V24.26c15.6,6.95,35.77,15.41,61.78,3.38,110.25-51,120.51,23.71,192.6-4.3C399.11-32.89,408.75,72.79,501.08,28,644.3-41.51,629.45,78.6,764.54,20.65,855.87-18.53,872.34,72.12,1000,15.7V0Z" style="fill-rule:evenodd"></path></svg>';
break;
case 'drip' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 91.02" preserveAspectRatio="none"><path d="M772,11c-32.4,4-58,9.51-58,9.51C685.3,26.69,659.67,34.32,658,35c-15.34,6.3-25.24,13.11-43,13-27.54-.18-37.37-16.79-56-11-19,5.91-19.53,26.54-35,27-13.47.4-16.5-15.14-36-18-1.32-.19-15.92-2.13-29,6-20.34,12.64-18.82,38.28-28,39-8.62.68-10.8-21.86-26-40-5.44-6.49-24.19-25.34-100-32a429.73,429.73,0,0,0-94,2C165,26.91,96.11,27.3,0,0V91H1000V0C894.78,1.07,813.3,5.92,772,11Z" transform="translate(0 0)"></path></svg>';
break;
case 'asymslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none"><polygon points="0 89 741 89 0 0 0 89"></polygon><polygon points="741 89 1000 89 1000 0 741 89"></polygon></svg>';
break;
case 'vslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" style="width: 100%; max-width: 100%;"><polygon points="0 89 500 89 0 0 0 89"></polygon><polygon points="500 89 1000 89 1000 0 500 89"></polygon></svg>';
break;
case 'multivslope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" style="width: 100%; max-width: 100%;"><polygon points="0 89 500 89 0 20 0 89"></polygon><polygon points="500 89 1000 89 1000 20 500 89"></polygon><polygon style="opacity: 0.6;" points="0 20 500 89 0 0 0 89"></polygon><polygon style="opacity: 0.6;" points="500 89 1000 20 1000 0 500 89"></polygon></svg>';
break;
case 'multiv3slope' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 89" preserveAspectRatio="none" ><polygon points="0 89 500 89 0 40 0 89"></polygon><polygon points="500 89 1000 89 1000 40 500 89"></polygon><polygon style="opacity: 0.6;" points="0 40 500 89 0 20 0 69"></polygon><polygon style="opacity: 0.6;" points="500 89 1000 20 1000 40 500 89"></polygon><polygon style="opacity: 0.3;" points="0 20 500 89 0 0 0 89" ></polygon><polygon style="opacity: 0.3;" points="500 89 1000 20 1000 0 500 89"></polygon></svg>';
break;
case 'triangle' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 100"><polygon points="0 100 1000 100 1000 50 550 50 500 0 450 50 0 50 0 100"></polygon></svg>';
break;
case 'trianglesmall' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><polygon points="0 50 1000 50 1000 25 520 25 500 0 480 25 0 25 0 50"></polygon></svg>';
break;
case 'triangle3' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><polygon points="0 50 1000 50 1000 25 560 25 540 0 520 25 500 0 480 25 460 0 440 25 0 25 0 50"></polygon></svg>';
break;
case 'ellipse' :
var svgpath = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1000 50"><path d="M0 50 C 200 0 500 0 1000 50 Z"></path></svg>';
break;
case 'none' :
default :
focus.find('.tck-divider2-container').remove();
return;
break;
}
if ($ck('#divider-2shape').val()) {
if (! focus.find('.tck-divider2-container').length) focus.prepend('<div class="tck-divider-container tck-divider2-container">' + svgpath + '</div>');
} else {
return;
}
var divider2 = focus.find('.tck-divider2-container');
// position
if ($ck('#' + prefix + 'position').val() == 'top') {
divider2.removeClass('pbck-divider-bottom').addClass('pbck-divider-top');
} else {
divider2.removeClass('pbck-divider-top').addClass('pbck-divider-bottom');
}
// placement
if ($ck('#' + prefix + 'placement').val() == 'over') {
divider2.removeClass('pbck-divider-under').addClass('pbck-divider-over');
} else {
divider2.removeClass('pbck-divider-over').addClass('pbck-divider-under');
}
// flip
if ($ck('#' + prefix + 'fliphorizontal').val() == '1') {
divider2.addClass('ckflip-horizontal');
} else {
divider2.removeClass('ckflip-horizontal');
}
if ($ck('#' + prefix + 'flipvertical').val() == '1') {
divider2.addClass('ckflip-vertical');
} else {
divider2.removeClass('ckflip-vertical');
}
divider2.find('path, polygon').attr('fill', $ck('#' + prefix + 'color').val());
divider2.css('background-color', $ck('#' + prefix + 'bgcolor').val());
divider2.css('height', ckTestUnit($ck('#' + prefix + 'height').val()));
divider2.find('svg').css('width', ckTestUnit($ck('#' + prefix + 'width').val()));
divider2.find('svg').css('max-width', ckTestUnit($ck('#' + prefix + 'width').val()));
}
}
function ckShowQuickDataImport() {
var name = $ck('#name').val();
CKBox.open({id: 'ckimportquickdata', handler: 'iframe', url: TEMPLATECREATORCK_ADMIN_URL + '&view=quickdata&name=' + name + '&tmpl=component'});
}