first commit
This commit is contained in:
12
modules/appagebuilder/views/js/admin/autoload.js
Normal file
12
modules/appagebuilder/views/js/admin/autoload.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
if (typeof autoload_func_name !== 'undefined') {
|
||||
window[autoload_func_name]();
|
||||
}
|
||||
});
|
||||
570
modules/appagebuilder/views/js/admin/detail.js
Normal file
570
modules/appagebuilder/views/js/admin/detail.js
Normal file
@@ -0,0 +1,570 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
var windowWidth = $(window).width();
|
||||
var currentId;
|
||||
var currentConfig;
|
||||
$(document).ready(function() {
|
||||
//only for product generate
|
||||
$(".adminappagebuilderdetails #nav-sidebar").trigger("click");
|
||||
|
||||
$('.plist-eedit').click(function(){
|
||||
element = $(this).data('element');
|
||||
$.fancybox.open([{
|
||||
type: 'iframe',
|
||||
href : ($('#appagebuilder_products_form').length?$('#appagebuilder_products_form').attr('action'):$('#appagebuilder_details_form').attr('action')) + '&pelement=' + element,
|
||||
afterLoad:function(){
|
||||
if ($('body',$('.fancybox-iframe').contents()).find("#main").length) {
|
||||
hideSomeElement();
|
||||
$('.fancybox-iframe').load( hideSomeElement );
|
||||
} else {
|
||||
$('body',$('.fancybox-iframe').contents()).find("#psException").html('<div class="alert error">Can not find this element</div>');
|
||||
}
|
||||
},
|
||||
afterClose: function (event, ui) {
|
||||
}
|
||||
}], {
|
||||
padding: 10
|
||||
});
|
||||
});
|
||||
|
||||
$('.element-list .plist-element').draggable({
|
||||
connectToSortable: ".product-container .content",
|
||||
revert: "true",
|
||||
helper: "clone",
|
||||
handle: ".gaction-drag",
|
||||
stop: function() {
|
||||
$( ".product-container .content" ).sortable({
|
||||
revert: false
|
||||
});
|
||||
setProFormAction();
|
||||
setSortAble();
|
||||
}
|
||||
});
|
||||
|
||||
$('.show-postion').click(function(){$("#postion_layout img").show()});
|
||||
$('.postion-img-co').click(function(){$("#postion_layout img").toggle()});
|
||||
|
||||
|
||||
$(document).on("click", ".column-add", function () {
|
||||
createColumn(this);
|
||||
$(currentId).find('.btn-add-column').trigger( "click" );
|
||||
editcolumn();
|
||||
//DONGND:: re-call event for new element
|
||||
setProFormAction();
|
||||
setSortAble();
|
||||
});
|
||||
setProFormAction();
|
||||
setSortAble();
|
||||
|
||||
$('body').on('click', function (e) {
|
||||
$('[data-toggle=popover]').each(function () {
|
||||
// hide any open popovers when the anywhere else in the body is clicked
|
||||
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
|
||||
$(this).popover('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
widthselect();
|
||||
setCssClass();
|
||||
saveData();
|
||||
thumbconfig();
|
||||
//DONGND:: add config for zoom
|
||||
zoomconfig();
|
||||
|
||||
$('#appagebuilder_details_form').submit(function() {
|
||||
genreateForm();
|
||||
});
|
||||
|
||||
//DONGND:: setup ui for element
|
||||
$('.ap_proGrid .row, .ap_proGrid .column-row').addClass('ui-widget ui-widget-content ui-helper-clearfix ui-corner-all');
|
||||
$('.ap_proGrid .gaction-drag, .ap_proGrid .caction-drag, .ap_proGrid .waction-drag').addClass('ui-widget-header ui-corner-all');
|
||||
});
|
||||
|
||||
function thumbconfig(){
|
||||
$('.select_thumb').change(function() {
|
||||
if ($(this).val() == 'none')
|
||||
$(this).closest('.formmodal').find('.select_thumb-none').hide();
|
||||
else
|
||||
$(this).closest('.formmodal').find('.select_thumb-none').show();
|
||||
});
|
||||
}
|
||||
|
||||
//DONGND:: add config for zoom
|
||||
function zoomconfig(){
|
||||
$('.select_zoom').change(function() {
|
||||
if ($(this).val() == 'none' || $(this).val() == 'in' || $(this).val() == 'in_scrooll')
|
||||
$(this).closest('.formmodal').find('.select-zoom-none').hide();
|
||||
else
|
||||
$(this).closest('.formmodal').find('.select-zoom-none').show();
|
||||
});
|
||||
}
|
||||
|
||||
function genreateForm(){
|
||||
//generate grid first
|
||||
var ObjectFrom = {};
|
||||
ObjectFrom.gridLeft = returnObjElemnt('.ap_proGrid .gridLeft-block-content');
|
||||
ObjectFrom.class = $("#main_class").val();
|
||||
// console.log(ObjectFrom);
|
||||
$('input[name=params]').val(JSON.stringify(ObjectFrom));
|
||||
}
|
||||
|
||||
function returnObjElemnt(element){
|
||||
var Object = {};
|
||||
// console.log(element);
|
||||
$(element).children().each(function(iElement){
|
||||
var Obj = {};
|
||||
Obj.name = $(this).data('element');
|
||||
if($(this).data("form") == undefined || $(this).data("form") == "" || $(this).data("form") == '\"\"')
|
||||
Obj.form = "";
|
||||
else
|
||||
Obj.form = $(this).data('form');
|
||||
|
||||
if(Obj.name=='product_image_with_thumb'){
|
||||
if (Obj.form.templateview == 'left' || Obj.form.templateview == 'right' || Obj.form.templateview == 'bottom')
|
||||
$("#main_class").val('product-image-thumbs product-thumbs-'+Obj.form.templateview);
|
||||
else $("#main_class").val('product-image-thumbs no-thumbs');
|
||||
}
|
||||
|
||||
if(Obj.name=='product_image_show_all'){
|
||||
$("#main_class").val('product-image-gallery');
|
||||
}
|
||||
|
||||
if($(this).hasClass('functional_buttons')){
|
||||
|
||||
Obj.columns = {};
|
||||
$(this).find('.column-row').each(function(yElement){
|
||||
var ObjectColumn = {};
|
||||
ObjectColumn.form = $(this).data('form');
|
||||
ObjectColumn.element = 'column';
|
||||
ObjectColumn.sub = returnObjElemnt($('.content', $(this)));
|
||||
Obj.columns[yElement] = ObjectColumn;
|
||||
});
|
||||
}
|
||||
if($(this).hasClass('code')){
|
||||
Obj.code = replaceSpecialString($('textarea', $(this)).val());
|
||||
}
|
||||
|
||||
Object[iElement] = Obj;
|
||||
});
|
||||
//console.log($(element).children());
|
||||
//console.log(Object);
|
||||
|
||||
return Object;
|
||||
}
|
||||
function replaceSpecialString(str){
|
||||
return str.replace(/\t/g, "_APTAB_").replace(/\r/g, "_APNEWLINE_").replace(/\n/g, "_APENTER_").replace(/"/g, "_APQUOT_").replace(/'/g, "_APAPOST_");
|
||||
}
|
||||
function saveData(){
|
||||
$(".btn-savewidget").click(function(){
|
||||
// console.log($(".formmodal"));
|
||||
var data = getFormData($(".formmodal"));
|
||||
// console.log(data);
|
||||
$("#modal_form .close").trigger('click');
|
||||
$(currentConfig).data('form', data);
|
||||
});
|
||||
}
|
||||
|
||||
function getFormData($form){
|
||||
var unindexed_array = $form.serializeArray();
|
||||
var indexed_array = {};
|
||||
|
||||
if($(currentConfig).hasClass('column-row'))
|
||||
{
|
||||
$(currentConfig).attr('class', 'column-row plist-element');
|
||||
}
|
||||
|
||||
$.map(unindexed_array, function(n, i){
|
||||
if(n['name']!='hidden_from[]')
|
||||
indexed_array[n['name']] = n['value'];
|
||||
//process class of column
|
||||
if($(currentConfig).hasClass('column-row') && (n['name'] == 'xl' || n['name'] == 'lg' || n['name'] == 'md' || n['name'] == 'sm' || n['name'] == 'xs' || n['name'] == 'sp'))
|
||||
$(currentConfig).addClass('col-'+n['name']+'-'+n['value']);
|
||||
|
||||
});
|
||||
|
||||
return indexed_array;
|
||||
}
|
||||
|
||||
function hideSomeElement(){
|
||||
$('body',$('.fancybox-iframe').contents()).addClass("page-sidebar-closed");
|
||||
}
|
||||
|
||||
function setSortAble(){
|
||||
$( ".product-container .content" ).sortable({
|
||||
connectWith: ".content",
|
||||
});
|
||||
}
|
||||
|
||||
function setCssClass(){
|
||||
if ($(".select-class").length) {
|
||||
$(".select-class").click(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
|
||||
$('.select-class').each(function() {
|
||||
// REMOVE ALL CHECKBOX VALUE IN TEXT
|
||||
var classChk = $(this).data("value");
|
||||
input_text = $(this).closest('.well').find('.element_class').first().val();
|
||||
// trim string
|
||||
var input_text = input_text.replace(classChk, "");
|
||||
input_text = input_text.split(" ").join(" ");
|
||||
input_text = $.trim(input_text);
|
||||
|
||||
$(this).closest('.well').find('.element_class').first().val(input_text);
|
||||
});
|
||||
|
||||
var classChk = $(this).data("value");
|
||||
var elementText = $(this).closest('.well').find('.element_class').first();
|
||||
|
||||
// SET VALUE CHECKBOX TO TEXT
|
||||
if ($(elementText).val().indexOf(classChk) == -1) {
|
||||
if ($(elementText).val() != "") {
|
||||
$(elementText).val($(elementText).val() + " " + classChk);
|
||||
} else {
|
||||
$(elementText).val(classChk);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".chk-row").click(function () {
|
||||
var classChk = $(this).data("value");
|
||||
var elementText = $(this).closest('.well').find('.element_class').first();
|
||||
if ($(elementText).val().indexOf(classChk) == -1) {
|
||||
// NOT EXIST AND ADD
|
||||
if ($(elementText).val() != "") {
|
||||
$(elementText).val($(elementText).val() + " " + classChk);
|
||||
} else {
|
||||
$(elementText).val(classChk);
|
||||
}
|
||||
}else{
|
||||
// EXIST AND REMOVE
|
||||
var find = classChk;
|
||||
var re = new RegExp(find, 'g');
|
||||
var text = $(elementText).val();
|
||||
text = text.replace(re, '');
|
||||
$(elementText).val(text);
|
||||
}
|
||||
});
|
||||
|
||||
$(".element_class").change(function () {
|
||||
elementChk = $(this).closest('.well').find('input[type=checkbox]');
|
||||
classText = $(this).val();
|
||||
$(elementChk).each(function () {
|
||||
classChk = $(this).data("value");
|
||||
if (classText.indexOf(classChk) != -1) {
|
||||
if (!$(this).is(':checked'))
|
||||
$(this).prop("checked", true);
|
||||
} else {
|
||||
$(this).prop("checked", false);
|
||||
}
|
||||
});
|
||||
});
|
||||
$(".element_class").trigger("change");
|
||||
}
|
||||
}
|
||||
|
||||
//set action when c
|
||||
function setProFormAction(){
|
||||
$('#home_wrapper .plist-code').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).click(function(){
|
||||
textAre = $(this).closest('.plist-element').find('textarea').first();
|
||||
if(textAre.attr('rows') == 20)
|
||||
$(textAre).attr('rows',5);
|
||||
else
|
||||
$(textAre).attr('rows',20);
|
||||
});
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#home_wrapper .btn-add-column').each(function(){
|
||||
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).popover({
|
||||
html: true,
|
||||
content: function () {
|
||||
currentId = $(this).closest('.plist-element');
|
||||
return $('#addnew-column-form').html();
|
||||
}
|
||||
});
|
||||
$(this).mousedown(function(){
|
||||
// toggle popover when link is clicked
|
||||
$(this).popover('toggle');
|
||||
});
|
||||
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#home_wrapper .plist-eremove').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).click(function(){
|
||||
if(!confirm("Are you sure to remove?")) return false;
|
||||
$(this).closest('.plist-element').remove();
|
||||
$(this).addClass('setaction');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#home_wrapper .btn-edit-group').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).click(function(){
|
||||
currentConfig = $(this).closest('.plist-element');
|
||||
$('#modal_form .modal-footer').show();
|
||||
|
||||
$('#modal_form .modal-body').html('');
|
||||
|
||||
column_config = $("#group_config").clone(true);
|
||||
|
||||
//load config
|
||||
data = $(currentConfig).data('form');
|
||||
column_config = setData(data, column_config);
|
||||
$('#modal_form .modal-body').append('<form class="formmodal"></form>');
|
||||
$('#modal_form .formmodal').append(column_config);
|
||||
|
||||
$('#modal_form').removeClass('modal-new').addClass('modal-edit');
|
||||
$("#modal_form").modal({
|
||||
"backdrop": "static"
|
||||
});
|
||||
});
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
});
|
||||
|
||||
$('#home_wrapper .element-config').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).click(function(){
|
||||
currentConfig = $(this).closest('.plist-element');
|
||||
$('#modal_form .modal-footer').show();
|
||||
|
||||
$('#modal_form .modal-body').html('');
|
||||
|
||||
dataconfig = $(this).data('config');
|
||||
|
||||
column_config = $("#"+dataconfig).clone(true);
|
||||
//load config
|
||||
|
||||
data = $(currentConfig).data('form');
|
||||
|
||||
column_config = setData(data, column_config);
|
||||
|
||||
if($(column_config).find('.select_thumb').val() == 'none')
|
||||
$(column_config).find('.select_thumb-none').hide();
|
||||
else
|
||||
$(column_config).find('.select_thumb-none').show();
|
||||
|
||||
//DONGND:: add zoom config
|
||||
if($(column_config).find('.select_zoom').val() == 'none' || $(column_config).find('.select_zoom').val() == 'in' || $(column_config).find('.select_zoom').val() == 'in_scrooll')
|
||||
$(column_config).find('.select-zoom-none').hide();
|
||||
else
|
||||
$(column_config).find('.select-zoom-none').show();
|
||||
|
||||
$('#modal_form .modal-body').append('<form class="formmodal"></form>');
|
||||
$('#modal_form .formmodal').append(column_config);
|
||||
|
||||
$('#modal_form').removeClass('modal-new').addClass('modal-edit');
|
||||
$("#modal_form").modal({
|
||||
"backdrop": "static"
|
||||
});
|
||||
});
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
});
|
||||
|
||||
editcolumn();
|
||||
}
|
||||
function setData(data, column_config){
|
||||
if(!data || data == 'undefined' || data == 'undefined') return column_config;
|
||||
|
||||
Object.keys(data).forEach(function (key) {
|
||||
//$('.' + key).data('form', dataObj[key]);
|
||||
$(column_config).find('input[name='+key+']').val(data[key]);
|
||||
|
||||
$(column_config).find('select[name='+key+']').val(data[key]);
|
||||
|
||||
if(key=="class" && $(column_config).find('.select-class').length)
|
||||
$(column_config).find('.select-class').each(function(){
|
||||
if(data[key].indexOf($(this).data('value'))>-1) $(this).prop("checked", true);
|
||||
});
|
||||
if(key=="xl" || key=="lg" || key=="md" || key=="sm" || key=="xs" || key=="sp"){
|
||||
classcss = 'width-select-'+key+'-'+data[key];
|
||||
classcss = classcss.replace(".", "-");
|
||||
$(column_config).find('.'+classcss).trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
return column_config;
|
||||
}
|
||||
function editcolumn()
|
||||
{
|
||||
$('#home_wrapper .btn-edit-column').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$(this).click(function(){
|
||||
currentConfig = $(this).closest('.plist-element');
|
||||
|
||||
$('#modal_form .modal-body').html('');
|
||||
|
||||
$('#modal_form .modal-footer').show();
|
||||
|
||||
data = $(currentConfig).data('form');
|
||||
//console.log(data);
|
||||
column_config = $("#column_config").clone(true);
|
||||
column_config = setData(data, column_config);
|
||||
|
||||
$('#modal_form .modal-body').append('<form class="formmodal"></form>');
|
||||
$('#modal_form .formmodal').append(column_config);
|
||||
|
||||
$('#modal_form').removeClass('modal-new').addClass('modal-edit');
|
||||
$("#modal_form").modal({
|
||||
"backdrop": "static"
|
||||
});
|
||||
//widthselect();
|
||||
});
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
});
|
||||
}
|
||||
function widthselect(){
|
||||
$('.width-select').each(function(){
|
||||
if(!$(this).hasClass('setaction')){
|
||||
$('.width-select').click(function () {
|
||||
btnGroup = $(this).closest('.btn-group');
|
||||
spanObj = $('.width-val', $(this));
|
||||
width = $(spanObj).data('width');
|
||||
$('.col-val', $(btnGroup)).val(width);
|
||||
$('.apbtn-width .width-val', $(btnGroup)).html($(spanObj).html());
|
||||
$('.apbtn-width .width-val', $(btnGroup)).attr('class', $(spanObj).attr('class'));
|
||||
});
|
||||
$(this).addClass('setaction');
|
||||
}
|
||||
});
|
||||
}
|
||||
function createColumn(obj) {
|
||||
var widthCol = $(obj).data('width');
|
||||
var classActive = returnWidthClass();
|
||||
var col = $(obj).data('col');
|
||||
var realValue = widthCol.toString().replace('.', '-');
|
||||
for (var i = 1; i <= col; i++) {
|
||||
wrapper = currentId.find('.group');
|
||||
|
||||
column = $('#default_column').clone();
|
||||
var cls = $(column).attr("class");
|
||||
//column-row col-sp-12 col-xs-12 col-sm-12 col-md-12 col-lg-12 ui-widget ui-widget-content ui-helper-clearfix ui-corner-all
|
||||
cls = cls.replace("col-xl-12", "col-xl-" + realValue);
|
||||
cls = cls.replace("col-lg-12", "col-lg-" + realValue);
|
||||
cls = cls.replace("col-md-12", "col-md-" + realValue);
|
||||
cls = cls.replace("col-sm-12", "col-sm-" + realValue);
|
||||
cls = cls.replace("col-xs-12", "col-xs-" + realValue);
|
||||
cls = cls.replace("col-sp-12", "col-sp-" + realValue);
|
||||
$(column).attr("class", cls);
|
||||
objColumn = {form_id: "form_" + getRandomNumber()};
|
||||
if (classActive == "md" || classActive == "lg" || classActive == "xl") {
|
||||
objColumn.md = widthCol;
|
||||
objColumn.lg = widthCol;
|
||||
objColumn.xl = widthCol;
|
||||
}
|
||||
//DONGND:: set default for sm, xs, sp
|
||||
objColumn.sm = 12;
|
||||
objColumn.xs = 12;
|
||||
objColumn.sp = 12;
|
||||
//jQuery.extend(objColumn, $globalthis.getColDefault());
|
||||
$(column).data("form", objColumn);
|
||||
|
||||
column.removeAttr('id');
|
||||
wrapper.append(column);
|
||||
getNumberColumnInClass(column, classActive);
|
||||
$(".label-tooltip").tooltip();
|
||||
}
|
||||
}
|
||||
|
||||
function getNumberColumnInClass(obj, type) {
|
||||
var cls = $(obj).attr("class").split(" ");
|
||||
var len = cls.length;
|
||||
var result = "";
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (cls[i].search("col-" + type) >= 0) {
|
||||
result = cls[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
var temp = result.replace("col-" + type + "-", "");
|
||||
$(obj).find(".pull-right .btn-group .btn span:first-child").attr("class", "width-val ap-w-" + temp);
|
||||
var group = $(obj).find("ul.dropdown-menu-right");
|
||||
$(group).find("li").removeClass("selected");
|
||||
$(group).find(".col-" + temp).addClass("selected");
|
||||
}
|
||||
|
||||
function getRandomNumber()
|
||||
{
|
||||
return (+new Date() + (Math.random() * 10000000000000000)).toString().replace('.', '');
|
||||
}
|
||||
function returnWidthClass(width) {
|
||||
if (!width)
|
||||
width = windowWidth;
|
||||
|
||||
if (parseInt(width) >= 1200)
|
||||
return 'xl';
|
||||
if (parseInt(width) >= 992)
|
||||
return 'lg';
|
||||
if (parseInt(width) >= 768)
|
||||
return 'md';
|
||||
if (parseInt(width) >= 576)
|
||||
return 'sm';
|
||||
if (parseInt(width) >= 480)
|
||||
return 'xs';
|
||||
if (parseInt(width) < 480)
|
||||
return 'sp';
|
||||
};
|
||||
$(document).on("click", ".btn-fwidth", function () {
|
||||
$('#home_wrapper').css('width', $(this).data('width'));
|
||||
|
||||
btnElement = $(this);
|
||||
$('.btn-fwidth').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
//reset
|
||||
if ($(this).hasClass('width-default')) {
|
||||
windowWidth = $(window).width();
|
||||
$('#home_wrapper').attr('class', 'default');
|
||||
} else {
|
||||
$('#home_wrapper').attr('class', 'col-' + returnWidthClass(parseInt($(this).data('width'))));
|
||||
windowWidth = $(this).data('width');
|
||||
}
|
||||
classVal = returnWidthClass();
|
||||
$(".column-row", $('#home_wrapper')).each(function () {
|
||||
valueFra = $(this).data("form")[classVal];
|
||||
$(".apbtn-width .width-val", $(this)).attr("class", "width-val ap-w-" + valueFra.toString().replace(".", "-"));
|
||||
});
|
||||
initColumnSetting();
|
||||
});
|
||||
|
||||
function initColumnSetting() {
|
||||
var classActive = returnWidthClass();
|
||||
$(".column-row").each(function () {
|
||||
getNumberColumnInClass(this, classActive);
|
||||
});
|
||||
}
|
||||
|
||||
function getNumberColumnInClass(obj, type) {
|
||||
var cls = $(obj).attr("class").split(" ");
|
||||
var len = cls.length;
|
||||
var result = "";
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (cls[i].search("col-" + type) >= 0) {
|
||||
result = cls[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
var temp = result.replace("col-" + type + "-", "");
|
||||
$(obj).find(".pull-right .btn-group .btn span:first-child").attr("class", "width-val ap-w-" + temp);
|
||||
var group = $(obj).find("ul.dropdown-menu-right");
|
||||
$(group).find("li").removeClass("selected");
|
||||
$(group).find(".col-" + temp).addClass("selected");
|
||||
}
|
||||
1046
modules/appagebuilder/views/js/admin/form.js
Normal file
1046
modules/appagebuilder/views/js/admin/form.js
Normal file
File diff suppressed because it is too large
Load Diff
28
modules/appagebuilder/views/js/admin/form_admin_positions.js
Normal file
28
modules/appagebuilder/views/js/admin/form_admin_positions.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.leo_delete_position').each(function(){
|
||||
|
||||
$(this).closest('a').attr('href',"javascript:void(0);");
|
||||
|
||||
$('<input>', {
|
||||
type: 'hidden',
|
||||
id : 'leo_delete_position',
|
||||
name: 'leo_delete_position',
|
||||
value: '0'
|
||||
}).appendTo( $(this).parent() );
|
||||
|
||||
$(this).closest('a').click(function(){
|
||||
if (confirm(leo_confirm_text)){
|
||||
$('#leo_delete_position').val('1');
|
||||
$(this).closest('form').attr('action', leo_form_submit);
|
||||
$(this).closest('form').submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
44
modules/appagebuilder/views/js/admin/function.js
Normal file
44
modules/appagebuilder/views/js/admin/function.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
|
||||
function SetButonSaveToHeader() {
|
||||
var html_save_and_stay =
|
||||
'<li>' +
|
||||
'<a id="page-header-desc-appagebuilder_shortcode-SaveAndStay" class="toolbar_btn pointer" href="javascript:void(0);" title="Save and stay" onclick="TopSaveAndStay()">' +
|
||||
'<i class="process-icon-save"></i>' +
|
||||
'<div>Save and stay</div>' +
|
||||
'</a>' +
|
||||
'</li>';
|
||||
$('.toolbarBox .btn-toolbar ul').prepend(html_save_and_stay);
|
||||
|
||||
}
|
||||
|
||||
function TopSave(){
|
||||
if (typeof TopSave_Name !== 'undefined') {
|
||||
$("button[name$='"+TopSave_Name+"']").click();
|
||||
}
|
||||
}
|
||||
|
||||
function TopSaveAndStay(){
|
||||
if (typeof TopSaveAndStay_Name !== 'undefined') {
|
||||
$("button[name$='"+TopSaveAndStay_Name+"']").click();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* review $('.nav-bar').on('click', '.menu-collapse', function() {
|
||||
*/
|
||||
function miniLeftMenu(parameters) {
|
||||
if( !$('body').hasClass('page-sidebar-closed')){
|
||||
$('body').toggleClass('page-sidebar-closed');
|
||||
if ($('body').hasClass('page-sidebar-closed')) {
|
||||
$('nav.nav-bar ul.main-menu > li')
|
||||
.removeClass('ul-open open')
|
||||
.find('a > i.material-icons.sub-tabs-arrow').text('keyboard_arrow_down');
|
||||
}
|
||||
}
|
||||
}
|
||||
2976
modules/appagebuilder/views/js/admin/home.js
Normal file
2976
modules/appagebuilder/views/js/admin/home.js
Normal file
File diff suppressed because it is too large
Load Diff
36
modules/appagebuilder/views/js/admin/index.php
Normal file
36
modules/appagebuilder/views/js/admin/index.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2012 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2012 PrestaShop SA
|
||||
* @version Release: $Revision: 13573 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
8
modules/appagebuilder/views/js/admin/isotope.pkgd.min.js
vendored
Normal file
8
modules/appagebuilder/views/js/admin/isotope.pkgd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
94
modules/appagebuilder/views/js/admin/product-list.js
Normal file
94
modules/appagebuilder/views/js/admin/product-list.js
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
//only for product generate
|
||||
|
||||
$('.plist-eedit').click(function(){
|
||||
element = $(this).data('element');
|
||||
$.fancybox.open([{
|
||||
type: 'iframe',
|
||||
href : ($('#appagebuilder_products_form').length?$('#appagebuilder_products_form').attr('action'):$('#appagebuilder_details_form').attr('action')) + '&pelement=' + element,
|
||||
afterLoad:function(){
|
||||
if( $('body',$('.fancybox-iframe').contents()).find("#main").length ){
|
||||
hideSomeElement();
|
||||
$('.fancybox-iframe').load( hideSomeElement );
|
||||
}else {
|
||||
$('body',$('.fancybox-iframe').contents()).find("#psException").html('<div class="alert error">Can not find this element</div>');
|
||||
}
|
||||
},
|
||||
afterClose: function (event, ui) {
|
||||
}
|
||||
}], {
|
||||
padding: 10
|
||||
});
|
||||
});
|
||||
|
||||
$('.element-list .plist-element').draggable({
|
||||
connectToSortable: ".product-container .content",
|
||||
revert: "true",
|
||||
helper: "clone",
|
||||
stop: function() {
|
||||
setProFormAction();
|
||||
setSortAble();
|
||||
}
|
||||
});
|
||||
|
||||
$('#appagebuilder_products_form').submit(function() {
|
||||
genreateForm();
|
||||
});
|
||||
|
||||
setProFormAction();
|
||||
setSortAble();
|
||||
});
|
||||
|
||||
function genreateForm(){
|
||||
//generate grid first
|
||||
var ObjectFrom = {};
|
||||
ObjectFrom.gridLeft = returnObjElemnt('.ap_proGrid .gridLeft-block-content');
|
||||
ObjectFrom.gridRight = returnObjElemnt('.ap_proGrid .gridRight-block-content');
|
||||
$('input[name=params]').val(JSON.stringify(ObjectFrom));
|
||||
}
|
||||
|
||||
function returnObjElemnt(element){
|
||||
var Object = {};
|
||||
$(element).children().each(function(iElement){
|
||||
var Obj = {};
|
||||
Obj.name = $(this).data('element');
|
||||
|
||||
if($(this).hasClass('functional_buttons')){
|
||||
Obj.element = returnObjElemnt($('.content', $(this)));
|
||||
}
|
||||
if($(this).hasClass('code')){
|
||||
Obj.code = replaceSpecialString($('textarea', $(this)).val());
|
||||
}
|
||||
Object[iElement] = Obj;
|
||||
});
|
||||
return Object;
|
||||
}
|
||||
|
||||
function hideSomeElement(){
|
||||
$('body',$('.fancybox-iframe').contents()).addClass("page-sidebar-closed");
|
||||
}
|
||||
|
||||
function setSortAble(){
|
||||
$( ".product-container .content" ).sortable({
|
||||
connectWith: ".content",
|
||||
});
|
||||
}
|
||||
function setProFormAction(){
|
||||
$('.plist-code').click(function(){
|
||||
textAre = $(this).closest('.plist-element').find('textarea').first();
|
||||
if(textAre.attr('rows') == 20)
|
||||
$(textAre).attr('rows',5);
|
||||
else
|
||||
$(textAre).attr('rows',20);
|
||||
});
|
||||
|
||||
$('.plist-eremove').click(function(){
|
||||
$(this).closest('.plist-element').remove();
|
||||
});
|
||||
}
|
||||
189
modules/appagebuilder/views/js/admin/setting.js
Normal file
189
modules/appagebuilder/views/js/admin/setting.js
Normal file
@@ -0,0 +1,189 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
function proccessData(id) {
|
||||
var list = $.trim($(id).val()).split(",");
|
||||
var result = "";
|
||||
var sep = "";
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
if($.trim(list[i])) {
|
||||
result += sep + $.trim(list[i]);
|
||||
sep = ",";
|
||||
}
|
||||
}
|
||||
$(id).val(result);
|
||||
}
|
||||
$(document).ready(function() {
|
||||
if(typeof use_mobile_theme !== 'undefined' && use_mobile_theme == 0){
|
||||
if (window.location.href.indexOf("mobiletheme") > -1) {
|
||||
if(confirm($('.source-profile').data('emobile'))){
|
||||
window.location.href = $("#subtab-AdminApPageBuilderThemeConfiguration a").attr('href');
|
||||
}
|
||||
}
|
||||
}
|
||||
if($("#apcheck_version").hasClass('firt')) {apCheckUpdate()}
|
||||
$("#apcheck_version").click(function() {apCheckUpdate()});
|
||||
|
||||
$('.panel-content-builder').slideUp();
|
||||
$('span.open-content').click(function(){
|
||||
$(this).closest('.panel').find('.panel-content-builder').slideToggle();
|
||||
});
|
||||
|
||||
// SHOW FULL input html
|
||||
$(".ap-html-full").closest( ".col-lg-9.col-lg-offset-3" ).removeClass("col-lg-9 col-lg-offset-3");
|
||||
|
||||
//DONGND:: hide home config with theme of leotheme, redirect to profile page
|
||||
if ($('#psthemecusto').length && (typeof ap_check_theme_name != 'undefined'))
|
||||
{
|
||||
$('#psthemecusto .panel').hide();
|
||||
$('#psthemecusto').append('<div class="panel"><div class="panel-heading">'+ap_profile_txt_redirect+': <a target="_blank" href="'+ap_profile_url+'">'+ap_profile_url+'</a></div></div>');
|
||||
}
|
||||
});
|
||||
function apCheckUpdate() {
|
||||
$.ajax({
|
||||
url: 'ht'+'tps'+'://w'+'ww.leo'+'theme'+'.com/moduleservice.php',
|
||||
type: "POST",
|
||||
data: $("#apcheck_version").data('form'),
|
||||
dataType: 'text',
|
||||
success: function(result) {
|
||||
console.log(result);
|
||||
$('.apmess').removeClass('hidden').html(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
function compareListHooks(oldHooks, newHooks) {
|
||||
//console.log(oldHooks);
|
||||
//console.log(newHooks);
|
||||
isEqual = true;
|
||||
if(oldHooks.length > 0 && newHooks.length > 0) {
|
||||
for(var i = 0; i < oldHooks.length; i++) {
|
||||
var isSubLook = false;
|
||||
for(var j = 0; j < newHooks.length; j++) {
|
||||
if(oldHooks[i] === newHooks[j]) {
|
||||
newHooks.splice(j, 1);
|
||||
//console.log(newHooks);
|
||||
isSubLook = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isSubLook) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
// SHOW MENU 'Ap Module Configuration' - BEGIN
|
||||
if( (typeof(js_ap_controller) != 'undefined') && (js_ap_controller == 'module_configuration')){
|
||||
$('#subtab-AdminApPageBuilder').addClass('active');
|
||||
$('#subtab-AdminApPageBuilderModule').addClass('active');
|
||||
$('#subtab-AdminParentModulesSf').removeClass('active');
|
||||
}
|
||||
// SHOW MENU 'Ap Module Configuration' - END
|
||||
|
||||
// Hide RESUME at left menu, BO
|
||||
if( (typeof(js_ap_dev) != 'undefined') && (js_ap_dev == 1)){
|
||||
// $('#tab-AdminDashboard').hide();
|
||||
$('.onboarding-navbar').hide();
|
||||
}
|
||||
|
||||
$("#hook_header_old").val($("#HEADER_HOOK").val());
|
||||
$("#hook_content_old").val($("#CONTENT_HOOK").val());
|
||||
$("#hook_footer_old").val($("#FOOTER_HOOK").val());
|
||||
$("#hook_product_old").val($("#PRODUCT_HOOK").val());
|
||||
|
||||
$(".list-all-hooks a").click(function() {
|
||||
var newHook = $.trim($(this).text());
|
||||
var id = $("#position-hook-select").val();
|
||||
id = id ? id : "#HEADER_HOOK";
|
||||
var listHook = $.trim($(id).val());
|
||||
if(listHook.search(newHook) < 0) {
|
||||
listHook += (listHook ? "," : "") + newHook;
|
||||
$(id).val(listHook);
|
||||
} else {
|
||||
alert("This hook is existed");
|
||||
}
|
||||
});
|
||||
$("#HEADER_HOOK, #CONTENT_HOOK, #FOOTER_HOOK, #PRODUCT_HOOK").focus(function() {
|
||||
var id = "#" + $(this).attr("id");
|
||||
$("#position-hook-select").val(id);
|
||||
});
|
||||
|
||||
/**
|
||||
* SAVE MODULE CONFIGUATION
|
||||
*/
|
||||
$("#btn-save-appagebuilder").click(function(e) {
|
||||
$isChange = false;
|
||||
proccessData("#HEADER_HOOK");
|
||||
proccessData("#CONTENT_HOOK");
|
||||
proccessData("#FOOTER_HOOK");
|
||||
proccessData("#PRODUCT_HOOK");
|
||||
// Check change config hooks
|
||||
var oldHook = $.trim($("#hook_header_old").val()).split(",");
|
||||
var currentHook = $.trim($("#HEADER_HOOK").val()).split(",");
|
||||
if(oldHook.length != currentHook.length || !compareListHooks(oldHook, currentHook)) {
|
||||
$isChange = true;
|
||||
}
|
||||
oldHook = $.trim($("#hook_content_old").val()).split(",");
|
||||
currentHook = $.trim($("#CONTENT_HOOK").val()).split(",");
|
||||
if(oldHook.length != currentHook.length || !compareListHooks(oldHook, currentHook)) {
|
||||
$isChange = true;
|
||||
}
|
||||
oldHook = $.trim($("#hook_footer_old").val()).split(",");
|
||||
currentHook = $.trim($("#FOOTER_HOOK").val()).split(",");
|
||||
if(oldHook.length != currentHook.length || !compareListHooks(oldHook, currentHook)) {
|
||||
$isChange = true;
|
||||
}
|
||||
oldHook = $.trim($("#hook_product_old").val()).split(",");
|
||||
currentHook = $.trim($("#PRODUCT_HOOK").val()).split(",");
|
||||
if(oldHook.length != currentHook.length || !compareListHooks(oldHook, currentHook)) {
|
||||
$isChange = true;
|
||||
}
|
||||
if($isChange) {
|
||||
if(!confirm($("#message_confirm").val())) {
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
$("#is_change").val("is_change");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$("#modal_form").on("click", ".btn-savewidget", function() {
|
||||
// Is form add new module to appagebuilder
|
||||
if($("#modal_form").find(".form_ap_module").length > 0) {
|
||||
// Validate select hook
|
||||
if(!$("#select-hook").val()) {
|
||||
alert($("#select-hook-error").val());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* EXPORT + IMPORT - BEGIN */
|
||||
$(".btn_xml_export").click(function(e) {
|
||||
e.preventDefault();
|
||||
if (typeof record_id !== 'undefined') {
|
||||
var url = $(this).closest('a').attr('href');
|
||||
$('input[name="'+record_id+'"]').each(function(i){
|
||||
if( $(this).is(':checked')){
|
||||
url += '&record_id[]=' + $(this).attr('value');
|
||||
}
|
||||
});
|
||||
window.location.href = url;
|
||||
}
|
||||
});
|
||||
|
||||
$(".btn_xml_import").click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#xml_import_form').slideToggle();
|
||||
$(':focus').blur();
|
||||
});
|
||||
/* EXPORT + IMPORT - END */
|
||||
});
|
||||
230
modules/appagebuilder/views/js/admin/themeeditor.js
Normal file
230
modules/appagebuilder/views/js/admin/themeeditor.js
Normal file
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* @copyright Commercial License By LeoTheme.Com
|
||||
* @email leotheme.com
|
||||
* @visit http://www.leotheme.com
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
$("#leo-customize .btn-show").click(function() {
|
||||
$("body").toggleClass("off-customize");
|
||||
});
|
||||
$('#myCustomTab a').click(function(e) {
|
||||
e.preventDefault();
|
||||
$(this).tab('show');
|
||||
})
|
||||
$('#myCustomTab a:first').tab('show');
|
||||
$("#custom-accordion .accordion-group:first .accordion-body").addClass('in');
|
||||
$(".bg-config").hide();
|
||||
|
||||
setBackGroundAction();
|
||||
setPatternActive();
|
||||
|
||||
$(".clear-bg").click(function() {
|
||||
var $parent = $(this).parent();
|
||||
var $input = $(".input-setting", $parent);
|
||||
if ($input.val('')) {
|
||||
if ($parent.hasClass("background-images")) {
|
||||
$('.bi-wrapper > div', $parent).removeClass('active');
|
||||
$($input.data('selector'), $("#main-preview iframe").contents()).css($input.data('attrs'), 'none');
|
||||
$('ul select', $parent).each(function(){
|
||||
$($input.data('selector'), $("#main-preview iframe").contents()).css($(this).data('attrs'), '');
|
||||
});
|
||||
$('ul select', $parent).val("");
|
||||
$('ul.bg-config', $parent).hide();
|
||||
} else {
|
||||
$input.attr('style', '')
|
||||
}
|
||||
$($input.data('selector'), $("#main-preview iframe").contents()).css($input.data('attrs'), 'inherit');
|
||||
|
||||
}
|
||||
$input.val('');
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* FORM SUBMIT
|
||||
*/
|
||||
$("#form").submit(function() {
|
||||
$('.input-setting').each(function() {
|
||||
if ($(this).data("match")) {
|
||||
var val = $(this).data('selector') + "|" + $(this).data('attrs');
|
||||
$(this).parent().append('<input type="hidden" name="customize_match[' + $(this).data("match") + '][]" value="' + val + '"/>');
|
||||
if($(this).data('attrs') == "background-image"){
|
||||
$("select",$(this).closest(".background-images")).each(function(){
|
||||
// if($(this).val()){
|
||||
val = $(this).data('selector') + "|" + $(this).data('attrs');
|
||||
$(this).closest(".background-images").append('<input type="hidden" name="customize_match[' + $(this).data("match") + '][]" value="' + val + '"/>');
|
||||
//}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
$("#main-preview iframe").ready(function() {
|
||||
$('.accordion-group input.input-setting').each(function() {
|
||||
var input = this;
|
||||
$(input).attr('readonly', 'readonly');
|
||||
$(input).ColorPicker({
|
||||
onChange: function(hsb, hex, rgb) {
|
||||
$(input).css('backgroundColor', '#' + hex);
|
||||
$(input).val(hex);
|
||||
if ($(input).data('selector')) {
|
||||
$("#main-preview iframe").contents().find($(input).data('selector')).css($(input).data('attrs'), "#" + $(input).val())
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.accordion-group select.input-setting').change(function() {
|
||||
var input = this;
|
||||
if ($(input).data('selector')) {
|
||||
var ex = $(input).data('attrs') == 'font-size' ? 'px' : "";
|
||||
$("#main-preview iframe").contents().find($(input).data('selector')).css($(input).data('attrs'), $(input).val() + ex);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$(".show-for-existed").hide();
|
||||
$("#saved-files").change(function() {
|
||||
setPatternActive();
|
||||
if ($(this).val()) {
|
||||
$(".show-for-notexisted").hide();
|
||||
$(".show-for-existed").show();
|
||||
} else {
|
||||
$(".show-for-notexisted").show();
|
||||
$(".show-for-existed").hide();
|
||||
$("#main-preview iframe").contents().find("#customize-theme").remove();
|
||||
return;
|
||||
}
|
||||
var url = customizeFolderURL + $(this).val() + ".json?rand=" + Math.random();
|
||||
|
||||
$.getJSON(url, function(data) {
|
||||
var items = data;
|
||||
if (items) {
|
||||
$('#customize-body .accordion-group').each(function() {
|
||||
var i = 0;
|
||||
$("input, select", this).each(function() {
|
||||
if ($(this).data('match')) {
|
||||
if (items[$(this).data('match')] && items[$(this).data('match')][i]) {
|
||||
var el = items[$(this).data('match')][i];
|
||||
$(this).val(el.val);
|
||||
if (el.val == '') {
|
||||
$(this).css('background', "inherit");
|
||||
}
|
||||
else {
|
||||
if(el.attr == "background-image"){
|
||||
$(this).parent().find("div.pull-left").each(function(){
|
||||
if($(this).data("val") == el.val)
|
||||
$(this).addClass('active');
|
||||
});
|
||||
}else if(el.attr == "background-color"){
|
||||
$(this).css('background', "#" + el.val); // SET BACKGROUND FOR INPUT
|
||||
}else if(el.attr == "color"){
|
||||
$(this).css('background', "#" + el.val); // SET BACKGROUND FOR INPUT
|
||||
}else {
|
||||
$(this).closest("ul").show();
|
||||
}
|
||||
}
|
||||
if(el.attr == "background-color")
|
||||
$(this).ColorPickerSetColor(el.val); // SET BACKGROUND FOR INPUT
|
||||
if(el.attr == "color")
|
||||
$(this).ColorPickerSetColor(el.val); // SET BACKGROUND FOR INPUT
|
||||
}
|
||||
i++;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#main-preview iframe").contents().find("#customize-theme").remove();
|
||||
if ($(this).val()) {
|
||||
var _link = $('<link rel="stylesheet" href="" id="customize-theme">');
|
||||
_link.attr('href', customizeFolderURL + $(this).val() + ".css?rand=" + Math.random());
|
||||
$("#main-preview iframe").contents().find("head").append(_link);
|
||||
}
|
||||
});
|
||||
|
||||
$("#main-preview iframe").load(function() {
|
||||
if ($("#main-preview iframe").contents().find(".paneltool.editortool").length) {
|
||||
$("#main-preview iframe").contents().find(".paneltool.editortool").hide();
|
||||
}
|
||||
});
|
||||
$("#upload_pattern").click(function(e){
|
||||
e.preventDefault();
|
||||
$.fancybox.open([
|
||||
{
|
||||
type: 'iframe',
|
||||
href : $(this).attr("href"),
|
||||
afterLoad:function(){
|
||||
hideSomeElement();
|
||||
},
|
||||
afterClose: function (event, ui) {
|
||||
refressImage();
|
||||
}
|
||||
}
|
||||
], {
|
||||
padding: 10
|
||||
});
|
||||
|
||||
});
|
||||
var hideSomeElement = function(){
|
||||
$('body',$('.fancybox-iframe').contents()).find("#header").hide();
|
||||
$('body',$('.fancybox-iframe').contents()).find("#footer").hide();
|
||||
$('body',$('.fancybox-iframe').contents()).find(".page-head, #nav-sidebar ").hide();
|
||||
//$('body',$('.fancybox-iframe').contents()).find("#content.bootstrap").css( 'padding',0).css('margin',0);
|
||||
};
|
||||
});
|
||||
|
||||
var refressImage = function(){
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: $("#upload_pattern").attr("href")+ '&ajax=1&action=reloadBackground&sortBy=name',
|
||||
data: '',
|
||||
dataType: 'json',
|
||||
cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example
|
||||
success: function(data)
|
||||
{
|
||||
$('.bi-wrapper').html(data);
|
||||
setBackGroundAction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var setBackGroundAction = function(){
|
||||
/**
|
||||
* BACKGROUND-IMAGE SELECTION
|
||||
*/
|
||||
$(".background-images").each(function() {
|
||||
var $parent = this;
|
||||
var $input = $(".input-setting", $parent);
|
||||
$(".bi-wrapper > div", this).click(function() {
|
||||
$(".bg-config",$parent).show();
|
||||
$input.val($(this).data('val'));
|
||||
$('.bi-wrapper > div', $parent).removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
if ($input.data('selector')) {
|
||||
$($input.data('selector'), $("#main-preview iframe").contents()).css($input.data('attrs'), 'url(' + $(this).data('image') + ')');
|
||||
}
|
||||
|
||||
});
|
||||
$(".bg-config select", this).change(function(){
|
||||
if ($input.data('selector')) {
|
||||
$($input.data('selector'), $("#main-preview iframe").contents()).css($(this).data('attrs'), $(this).val());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var setPatternActive = function()
|
||||
{
|
||||
if( $("#saved-files").val() == $("#saved-files").attr('active') && $("#saved-files").val() != '')
|
||||
{
|
||||
$("input[name=active][value=" + 1 + "]").prop('checked', true);
|
||||
}else if ($('#saved-files option').size() == 1){
|
||||
$("input[name=active][value=" + 1 + "]").prop('checked', true);
|
||||
}else{
|
||||
$("input[name=active][value=" + 0 + "]").prop('checked', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user