Dodaj nowe obrazy i szablony do modułu AP Page Builder
This commit is contained in:
574
modules/appagebuilder/views/js/admin/detail.js
Normal file
574
modules/appagebuilder/views/js/admin/detail.js
Normal file
@@ -0,0 +1,574 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2018 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();
|
||||
|
||||
$('#saveAndStay').click(function(event){
|
||||
event.preventDefault();
|
||||
$('input[name=submitAddappagebuilder_details]').val('1');
|
||||
genreateForm();
|
||||
$('#appagebuilder_details_form').submit();
|
||||
return false;
|
||||
});
|
||||
|
||||
//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");
|
||||
}
|
||||
895
modules/appagebuilder/views/js/admin/form.js
Normal file
895
modules/appagebuilder/views/js/admin/form.js
Normal file
@@ -0,0 +1,895 @@
|
||||
/*
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2018 Apollotheme
|
||||
* @description:
|
||||
*/
|
||||
function initFullSlider(type) {
|
||||
var total = parseInt($("#total_slider").val());
|
||||
$(".apfullslider-row").addClass("hide");
|
||||
$(".apfullslider-row input, .apfullslider-row textarea").removeAttr("name");
|
||||
}
|
||||
function updateListIdFullSlider() {
|
||||
var listId = "";
|
||||
var sep = "";
|
||||
$("#list-slider li").each(function() {
|
||||
listId += sep + $(this).attr("id");
|
||||
sep = "|";
|
||||
});
|
||||
$("#total_slider").val(listId);
|
||||
}
|
||||
$(document).ready(function() {
|
||||
$("#modal_form").draggable({
|
||||
handle: ".modal-header"
|
||||
});
|
||||
//close menu
|
||||
$('.adminappagebuilderhome').addClass('page-sidebar-closed');
|
||||
// $('.addnew-group').popover({
|
||||
// html: true,
|
||||
// content: function () {
|
||||
// return $('#addnew-group-form').html();
|
||||
// }
|
||||
// });
|
||||
|
||||
// NOT WORK FOR AJAX
|
||||
$('.form-action').change(function(){
|
||||
var elementName = $(this).attr('name');
|
||||
$('.'+elementName+'_sub').hide();
|
||||
$('.'+elementName+'-'+$(this).val()).show();
|
||||
});
|
||||
$('.form-action').trigger("change");
|
||||
|
||||
$('.checkbox-group').change(function(){
|
||||
id = $(this).attr('id');
|
||||
if($(this).is(':checked'))
|
||||
$('.'+id).show();
|
||||
else
|
||||
$('.'+id).hide();
|
||||
});
|
||||
$('.checkbox-group').trigger("change");
|
||||
|
||||
|
||||
$(document).on("click", ".hook-top", function() {
|
||||
$(".hook-content", $(this).parent()).each(function(){
|
||||
$(this).toggle('clip');
|
||||
var groupTop = $(".open-group i", $(this).parent());
|
||||
if($(groupTop).attr('class').indexOf('up') >-1){
|
||||
$(groupTop).attr('class',$(groupTop).attr('class').replace('up', 'down'));
|
||||
}else{
|
||||
$(groupTop).attr('class',$(groupTop).attr('class').replace('down', 'up'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//DONGND:: fix can't click tab 1 when create new widget tab
|
||||
// $('.ApTabs .nav-tabs a:first').tab('show');
|
||||
// $('.ApTabs:not(#default_ApTabs)').each(function(){
|
||||
// console.log($(this).data('form'));
|
||||
// console.log($(this).attr('form'));
|
||||
// var data_form = $(this).data();
|
||||
// console.log(data_form.type);
|
||||
// console.log(data_form.form);
|
||||
// console.log(data_form['form'].active_tab);
|
||||
// $(this).find('.nav-tabs a:first').tab('show');
|
||||
// })
|
||||
|
||||
$(".ApAccordions").each(function(){
|
||||
$('.panel-collapse:first' , $(this)).collapse('show');
|
||||
});
|
||||
$('.btn-form-toggle').click(function () {
|
||||
if ($('.displayLeftColumn').hasClass('col-md-3')) {
|
||||
$('i', $(this)).attr('class', 'icon-resize-small');
|
||||
$(".hook-content").hide();
|
||||
$(".open-group i").attr('class', $(".open-group i").attr('class').replace('down', 'up'));
|
||||
$('.displayLeftColumn').removeClass('col-md-3').addClass('col-md-12');
|
||||
$('.displayRightColumn').removeClass('col-md-3').addClass('col-md-12');
|
||||
$('.home-content-wrapper').removeClass('col-md-6').addClass('col-md-12');
|
||||
} else {
|
||||
$('i', $(this)).attr('class', 'icon-resize-full');
|
||||
$(".hook-content").show();
|
||||
$(".open-group i").attr('class', $(".open-group i").attr('class').replace('up', 'down'));
|
||||
$('.displayLeftColumn').removeClass('col-md-12').addClass('col-md-3');
|
||||
$('.displayRightColumn').removeClass('col-md-12').addClass('col-md-3');
|
||||
$('.home-content-wrapper').removeClass('col-md-12').addClass('col-md-6');
|
||||
}
|
||||
});
|
||||
|
||||
//only for product generate
|
||||
$( ".product-container .content" ).sortable({
|
||||
revert: false
|
||||
});
|
||||
$('.element-list .plist-element').draggable({
|
||||
connectToSortable: ".product-container .content",
|
||||
revert: "true",
|
||||
helper: "clone",
|
||||
stop: function() {
|
||||
|
||||
$( ".product-container .content" ).sortable({
|
||||
revert: false
|
||||
});
|
||||
}
|
||||
});
|
||||
$(document).on("click", "#list-slider .btn-delete-slider", function() {
|
||||
if(confirm($("#form_content").data("delete"))) {
|
||||
$(this).closest("li").remove();
|
||||
$("#frm-slider").removeAttr("edit");
|
||||
updateListIdFullSlider();
|
||||
}
|
||||
});
|
||||
$(document).on("click", "#list-slider .btn-delete-fullslider", function() {
|
||||
if(confirm($("#form_content").data("delete"))) {
|
||||
$(this).closest("li").remove();
|
||||
$("#frm-slider").removeAttr("edit");
|
||||
updateListIdFullSlider();
|
||||
}
|
||||
});
|
||||
$(document).on("click", "#btn-add-slider", function() {
|
||||
$("#frm-slider, .apfullslider-row, #frm-block-slider").removeClass("hide");
|
||||
$(".btn-reset-slider, .btn-reset-fullslider").trigger("click");
|
||||
$("#frm-slider, #frm-block-slider").removeAttr("edit");
|
||||
});
|
||||
$(document).on("click", ".btn-cancel-slider, .btn-cancel-fullslider", function() {
|
||||
$("#frm-slider, .apfullslider-row, #frm-block-slider").addClass("hide");
|
||||
});
|
||||
// $(document).on("click", ".btn-reset-slider", function() {
|
||||
// $("#frm-slider, #frm-block-slider").removeAttr("edit");
|
||||
// $("#s-open").removeAttr("checked");
|
||||
// $("#s-image").attr("src", "");
|
||||
// $("#s-image").hide();
|
||||
// $("#frm-slider input, #frm-slider textarea, #frm-block-slider input, #frm-block-slider textarea").val("");
|
||||
// $("#s-tit").focus();
|
||||
// });
|
||||
$(document).on("click", ".btn-reset-fullslider, .btn-reset-slider", function() {
|
||||
$("#frm-slider, #frm-block-slider").removeAttr("edit");
|
||||
$(".apfullslider-row img").attr("src", "").hide();
|
||||
$(".apfullslider-row input, .apfullslider-row textarea").val("");
|
||||
});
|
||||
$(document).on("click", ".btn-edit-slider", function() {
|
||||
var li = $(this).closest("li");
|
||||
var idRow = $(li).attr("id");
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
$("#frm-slider, .apfullslider-row").removeClass("hide");
|
||||
$("#frm-slider").attr("edit", $(li).attr("id"));
|
||||
|
||||
if(lengthLang > 1) {
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
currentLang = $(this).data("lang");
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
var img = $(li).find("#img_" + tempId).val();
|
||||
var title = $(li).find("#tit_" + tempId).val();
|
||||
var link= $(li).find("#link_" + tempId).val();
|
||||
var descript = $(li).find("#descript_" + tempId).val();
|
||||
$("#temp_title_" + currentLang).val(title);
|
||||
$("#temp_image_" + currentLang).val(img);
|
||||
// Check only diplay image for language
|
||||
if(img) {
|
||||
if($(".select-img .lang-" + currentLang).find("img").length == 0) {
|
||||
$(".select-img .lang-" + currentLang + " div:first-child").prepend("<img src='" + img + "' class='img-thumbnail'/>");
|
||||
} else {
|
||||
$(".select-img .lang-" + currentLang).find("img").attr("src", img);
|
||||
$(".select-img .lang-" + currentLang).find("img").css("display", "block");
|
||||
}
|
||||
}
|
||||
$("#temp_link_" + currentLang).val(link);
|
||||
$(".description-slide .lang-" + currentLang + " textarea").val(descript.replace(/_APNEWLINE_/g, " "));
|
||||
});
|
||||
} else {
|
||||
currentLang = default_language;
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
var img = $(li).find("#img_" + tempId).val();
|
||||
var title = $(li).find("#tit_" + tempId).val();
|
||||
var link= $(li).find("#link_" + tempId).val();
|
||||
var descript = $(li).find("#descript_" + tempId).val();
|
||||
$("#temp_title_" + currentLang).val(title);
|
||||
$("#temp_image_" + currentLang).val(img);
|
||||
// Check only diplay image for language
|
||||
if(img) {
|
||||
if($(".select-img img").length == 0) {
|
||||
$(".select-img div:first-child").prepend("<img src='" + img + "' class='img-thumbnail'/>");
|
||||
} else if(img) {
|
||||
$(".select-img img").attr("src", img);
|
||||
}
|
||||
}
|
||||
$("#temp_link_" + currentLang).val(link);
|
||||
$(".description-slide textarea").val(descript.replace(/_APNEWLINE_/g, " "));
|
||||
}
|
||||
});
|
||||
$(document).on("click", ".btn-edit-fullslider", function() {
|
||||
var li = $(this).closest("li");
|
||||
var idRow = $(li).attr("id");
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
$("#frm-slider, .apfullslider-row").removeClass("hide");
|
||||
$("#frm-slider").attr("edit", $(li).attr("id"));
|
||||
|
||||
if(lengthLang > 1) {
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
var currentLang = $(this).data("lang");
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
var img = $(li).find("#img_" + tempId).val();
|
||||
var imgLink = imgModuleLink+img;
|
||||
var title = $(li).find("#tit_" + tempId).val();
|
||||
var link= $(li).find("#link_" + tempId).val();
|
||||
var descript = $(li).find("#descript_" + tempId).val();
|
||||
$("#temp_title_" + currentLang).val(title);
|
||||
$("#temp_image_" + currentLang).val(img);
|
||||
// Check only diplay image for language
|
||||
if(img) {
|
||||
if($(".select-img .lang-" + currentLang).find("img").length == 0) {
|
||||
$(".select-img .lang-" + currentLang + " div").first().prepend("<img src='" + imgLink + "' class='img-thumbnail'/>");
|
||||
} else if(img) {
|
||||
$(".select-img .lang-" + currentLang).find("img").attr("src", imgLink);
|
||||
$(".select-img .lang-" + currentLang).find("img").css("display", "block");
|
||||
}
|
||||
}else{
|
||||
// NOT EXIST IMAGE
|
||||
$(".select-img .lang-" + currentLang).find("img").css("display", "none");
|
||||
}
|
||||
$("#temp_link_" + currentLang).val(link);
|
||||
$(".description-slide .lang-" + currentLang + " textarea").val(descript.replace(/_APNEWLINE_/g, " "));
|
||||
});
|
||||
} else {
|
||||
var currentLang = default_language;
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
var img = $(li).find("#img_" + tempId).val();
|
||||
var imgLink = imgModuleLink+img;
|
||||
var title = $(li).find("#tit_" + tempId).val();
|
||||
var link= $(li).find("#link_" + tempId).val();
|
||||
var descript = $(li).find("#descript_" + tempId).val();
|
||||
$("#temp_title_" + currentLang).val(title);
|
||||
$("#temp_image_" + currentLang).val(img);
|
||||
// Check only diplay image for language
|
||||
if(img) {
|
||||
if($(".select-img img").length == 0) {
|
||||
$(".select-img div").first().prepend("<img src='" + imgLink + "' class='img-thumbnail'/>");
|
||||
} else if(img) {
|
||||
$(".select-img img").attr("src", imgLink);
|
||||
$(".select-img img").css("display", "block");
|
||||
}
|
||||
}else{
|
||||
// NOT EXIST IMAGE
|
||||
$(".select-img").find("img").css("display", "none");
|
||||
}
|
||||
$("#temp_link_" + currentLang).val(link);
|
||||
$(".description-slide textarea").val(descript.replace(/_APNEWLINE_/g, " "));
|
||||
}
|
||||
});
|
||||
$(document).on("click", ".btn-save-slider", function() {
|
||||
// Validate
|
||||
// Get current language code selected
|
||||
var currentLang = default_language;
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
var temId = lengthLang > 1 ? ".title-slide .lang-" + default_language + " input" : ".title-slide input";
|
||||
var title = $.trim($(temId).val());
|
||||
temId = lengthLang > 1 ? ".select-img .lang-" + default_language + " img" : ".select-img img";
|
||||
var image = $.trim($(temId).attr("src"));
|
||||
var imageName = $.trim($(temId).data("img"));
|
||||
temId = lengthLang > 1 ? ".link-slide .lang-" + default_language + " input" : ".link-slide input";
|
||||
var link = $.trim($(temId).val());
|
||||
temId = lengthLang > 1 ? ".description-slide .lang-" + default_language + " textarea" : ".description-slide textarea";
|
||||
var description = $.trim($(temId).val());
|
||||
var countLimit = 0;
|
||||
if(!image) {
|
||||
countLimit++;
|
||||
}
|
||||
if(!title) {
|
||||
countLimit++;
|
||||
}
|
||||
if(!description) {
|
||||
countLimit++;
|
||||
}
|
||||
// Require enter value for one in of [image, title, description]
|
||||
if(countLimit == 3) {
|
||||
alert($(this).data("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
var idForm = "#frm-slider";
|
||||
var idRow = (typeof $(idForm).attr("edit") != "undefined") ? $(idForm).attr("edit") : "";
|
||||
if(!idRow) {
|
||||
var html = $("#temp-list li:first").html();
|
||||
idRow = 1;
|
||||
var arr = $("#total_slider").val().split("|");
|
||||
arr.sort(function (a, b) { return a - b; });
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
if(idRow != arr[i]) {
|
||||
break;
|
||||
}
|
||||
idRow++;
|
||||
}
|
||||
if(lengthLang > 1) {
|
||||
//console.log(idRow);
|
||||
// Duplicate for new slider and build name and id by language
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
currentLang = $(this).data("lang");
|
||||
var tempId = idRow + "_" + currentLang + "'";
|
||||
html += "<input type='hidden' name='tit_" + tempId + " id='tit_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='img_" + tempId + " id='img_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='link_" + tempId + " id='link_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='descript_" + tempId + " id='descript_" + tempId + "/>";
|
||||
});
|
||||
} else {
|
||||
var tempId = idRow + "_" + currentLang + "'";
|
||||
html += "<input type='hidden' name='tit_" + tempId + " id='tit_" + tempId + " value='" + title + "'/>";
|
||||
html += "<input type='hidden' name='img_" + tempId + " id='img_" + tempId + " value='" + imageName + "'/>";
|
||||
html += "<input type='hidden' name='link_" + tempId + " id='link_" + tempId + " value='" + link + "'/>";
|
||||
html += "<input type='hidden' name='descript_" + tempId + " id='descript_" + tempId + " value='" + description + "'/>";
|
||||
}
|
||||
$("#list-slider").prepend("<li id='" + idRow + "'>" + html + "</li>");
|
||||
}
|
||||
// Update labels for diplay interface
|
||||
var label = (title ? '<div class="col-lg-5">'+ title +'</div>' : "");
|
||||
label += (image ? '<img src="' + image + '">': "");
|
||||
$("#" + idRow + " div:first").html(label);
|
||||
|
||||
if(lengthLang > 1) {
|
||||
// Update value for other language by default language and save to dum hidden fields
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
currentLang = $(this).data("lang");
|
||||
var titleOther = $.trim($(".title-slide .lang-" + currentLang + " input").val());
|
||||
var imageOther = $.trim($(".select-img #temp_image_" + currentLang).val());
|
||||
var linkOther = $.trim($(".link-slide .lang-" + currentLang + " input").val());
|
||||
var descriptionOther = $.trim($(".description-slide .lang-" + currentLang + " textarea").val());
|
||||
if(currentLang != default_language) {
|
||||
if(!titleOther) {
|
||||
titleOther = title;
|
||||
$(".title-slide .lang-" + currentLang + " input").val(title);
|
||||
}
|
||||
if(!imageOther) {
|
||||
imageOther = imageName;
|
||||
$(".select-img .lang-" + currentLang + " input").val(imageOther);
|
||||
}
|
||||
if(!linkOther) {
|
||||
linkOther = link;
|
||||
$(".link-slide .lang-" + currentLang + " input").val(link);
|
||||
}
|
||||
if(!descriptionOther) {
|
||||
descriptionOther = description;
|
||||
$(".description-slide .lang-" + currentLang + " textarea").val(description);
|
||||
}
|
||||
}
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
|
||||
$("#tit_" + tempId).val(titleOther);
|
||||
$("#img_" + tempId).val(imageOther);
|
||||
$("#link_" + tempId).val(linkOther);
|
||||
$("#descript_" + tempId).val(descriptionOther);
|
||||
});
|
||||
} else {
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
$("#tit_" + tempId).val(title);
|
||||
$("#img_" + tempId).val(imageName);
|
||||
$("#link_" + tempId).val(link);
|
||||
$("#descript_" + tempId).val(description);
|
||||
}
|
||||
$(idForm).attr("edit", idRow);
|
||||
updateListIdFullSlider();
|
||||
$(idForm).addClass("hide");
|
||||
$(".apfullslider-row").addClass("hide");
|
||||
});
|
||||
/**
|
||||
* Validate and gender data for fullsilder and fill data for all language from current language selected in form
|
||||
*/
|
||||
$(document).on("click", ".btn-save-fullslider", function() {
|
||||
// Validate
|
||||
// Get current language code selected
|
||||
var currentLang = default_language;
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
var temId = lengthLang > 1 ? ".title-slide .lang-" + default_language + " input" : ".title-slide input";
|
||||
var title = $.trim($(temId).val());
|
||||
temId = lengthLang > 1 ? ".select-img .lang-" + default_language + " img" : ".select-img img";
|
||||
var image = $.trim($(temId).attr("src"));
|
||||
var imageName = $.trim($(temId).data("img"));
|
||||
temId = lengthLang > 1 ? ".link-slide .lang-" + default_language + " input" : ".link-slide input";
|
||||
var link = $.trim($(temId).val());
|
||||
temId = lengthLang > 1 ? ".description-slide .lang-" + default_language + " textarea" : ".description-slide textarea";
|
||||
var description = $.trim($(temId).val());
|
||||
var countLimit = 0;
|
||||
if(!image) {
|
||||
countLimit++;
|
||||
}
|
||||
if(!title) {
|
||||
countLimit++;
|
||||
}
|
||||
if(!description) {
|
||||
countLimit++;
|
||||
}
|
||||
// Require enter value for one in of [image, title, description]
|
||||
if(countLimit == 3) {
|
||||
alert($(this).data("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
var idForm = "#frm-slider";
|
||||
var idRow = (typeof $(idForm).attr("edit") != "undefined") ? $(idForm).attr("edit") : "";
|
||||
if(!idRow) {
|
||||
var html = $("#temp-list li:first").html();
|
||||
idRow = 1;
|
||||
var arr = $("#total_slider").val().split("|");
|
||||
arr.sort();
|
||||
for(var i = 0; i < arr.length; i++) {
|
||||
if(idRow != arr[i]) {
|
||||
break;
|
||||
}
|
||||
idRow++;
|
||||
}
|
||||
if(lengthLang > 1) {
|
||||
//console.log(idRow);
|
||||
// Duplicate for new slider and build name and id by language
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
currentLang = $(this).data("lang");
|
||||
var tempId = idRow + "_" + currentLang + "'";
|
||||
html += "<input type='hidden' name='tit_" + tempId + " id='tit_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='img_" + tempId + " id='img_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='link_" + tempId + " id='link_" + tempId + "/>";
|
||||
html += "<input type='hidden' name='descript_" + tempId + " id='descript_" + tempId + "/>";
|
||||
});
|
||||
} else {
|
||||
var tempId = idRow + "_" + currentLang + "'";
|
||||
html += "<input type='hidden' name='tit_" + tempId + " id='tit_" + tempId + " value='" + title + "'/>";
|
||||
html += "<input type='hidden' name='img_" + tempId + " id='img_" + tempId + " value='" + image + "'/>";
|
||||
html += "<input type='hidden' name='link_" + tempId + " id='link_" + tempId + " value='" + link + "'/>";
|
||||
html += "<input type='hidden' name='descript_" + tempId + " id='descript_" + tempId + " value='" + description + "'/>";
|
||||
}
|
||||
$("#list-slider").prepend("<li id='" + idRow + "'>" + html + "</li>");
|
||||
}
|
||||
// Update labels for diplay interface
|
||||
var label = (title ? '<div class="col-lg-5">'+ title +'</div>' : "");
|
||||
label += (image ? '<img src="' + image + '">': "");
|
||||
$("#" + idRow + " div:first").html(label);
|
||||
|
||||
if(lengthLang > 1) {
|
||||
// Update value for other language by default language and save to dum hidden fields
|
||||
$(".select-img .translatable-field").each(function() {
|
||||
currentLang = $(this).data("lang");
|
||||
var titleOther = $.trim($(".title-slide .lang-" + currentLang + " input").val());
|
||||
var imageOther = $.trim($(".select-img #temp_image_" + currentLang).val());
|
||||
var linkOther = $.trim($(".link-slide .lang-" + currentLang + " input").val());
|
||||
var descriptionOther = $.trim($(".description-slide .lang-" + currentLang + " textarea").val());
|
||||
if(currentLang != default_language) {
|
||||
if(!titleOther) {
|
||||
titleOther = title;
|
||||
$(".title-slide .lang-" + currentLang + " input").val(title);
|
||||
}
|
||||
if(!imageOther) {
|
||||
imageOther = imageName;
|
||||
$(".select-img .lang-" + currentLang + " input").val(imageOther);
|
||||
}
|
||||
if(!linkOther) {
|
||||
linkOther = link;
|
||||
$(".link-slide .lang-" + currentLang + " input").val(link);
|
||||
}
|
||||
if(!descriptionOther) {
|
||||
descriptionOther = description;
|
||||
$(".description-slide .lang-" + currentLang + " textarea").val(description);
|
||||
}
|
||||
}
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
$("#tit_" + tempId).val(titleOther);
|
||||
$("#img_" + tempId).val(imageOther);
|
||||
$("#link_" + tempId).val(linkOther);
|
||||
$("#descript_" + tempId).val(descriptionOther);
|
||||
});
|
||||
} else {
|
||||
var tempId = idRow + "_" + currentLang;
|
||||
$("#tit_" + tempId).val(title);
|
||||
$("#img_" + tempId).val(imageName);
|
||||
$("#link_" + tempId).val(link);
|
||||
$("#descript_" + tempId).val(description);
|
||||
}
|
||||
$(idForm).attr("edit", idRow);
|
||||
updateListIdFullSlider();
|
||||
$(idForm).addClass("hide");
|
||||
$(".apfullslider-row").addClass("hide");
|
||||
});
|
||||
$(document).on("click", ".latest-blog-category input[type='checkbox']", function() {
|
||||
ckb = $(this).is(':checked');
|
||||
if(ckb) {
|
||||
$(this).closest("li").find('input').attr("checked", "checked");
|
||||
} else {
|
||||
$(this).closest("li").find('input').removeAttr("checked");
|
||||
}
|
||||
});
|
||||
$(document).on("click", ".list-font-awesome li", function() {
|
||||
$(".list-font-awesome li").removeClass("selected");
|
||||
$("#font_name").val($(this).find("i").data("default"));
|
||||
$(".preview-widget i").attr("class", $(this).find("i").attr("class"));
|
||||
$(this).addClass("selected");
|
||||
renderDefaultPreviewFontwesome();
|
||||
});
|
||||
$(document).on("change", "#font_type, #font_size, #is_spin", function() {
|
||||
renderDefaultPreviewFontwesome();
|
||||
});
|
||||
|
||||
if(typeof ap_controller != "undefined" && ap_controller == 'AdminApPageBuilderThemeConfigurationController')
|
||||
{
|
||||
initApTabForm();
|
||||
}
|
||||
|
||||
});
|
||||
function renderDefaultPreviewFontwesome() {
|
||||
var cls = "icon " + $("#font_name").val() + " " + $("#font_type").val()
|
||||
+ " " + $("#font_size").val()
|
||||
+ " " + $("#is_spin").val();
|
||||
$(".preview-widget i").attr("class", cls);
|
||||
}
|
||||
/**
|
||||
* Start block for module ApCategoryImage
|
||||
*/
|
||||
/**
|
||||
* Update status check a current category, this function is called from event in file home.js in this module
|
||||
* @param {type} obj: install of image just selected
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
var selected_images = {};
|
||||
function resetSelectedImage() {
|
||||
if(typeof selected_images != "undefined") {
|
||||
selected_images = {};
|
||||
}
|
||||
}
|
||||
function updateStatusCheck(obj) {
|
||||
var checkbox = $(obj).closest("span").find("input[type='checkbox']").first();
|
||||
if($(obj).attr("src-url") != "") {
|
||||
selected_images[$(checkbox).val()] = $(obj).attr("src-url");
|
||||
// Set status for checkbox
|
||||
// $(checkbox).attr("checked", "checked");
|
||||
$(obj).closest("span").find(".remove-img").removeClass("hidden");
|
||||
} else {
|
||||
$(checkbox).removeAttr("checked");
|
||||
$(obj).closest("span").find(".remove-img").addClass("hidden");
|
||||
delete selected_images[$(checkbox).val()];
|
||||
}
|
||||
$("#category_img").val(JSON.stringify(selected_images));
|
||||
return false;
|
||||
}
|
||||
function intiForApCategoryImage() {
|
||||
$("#categorybox").addClass('full_loaded'); // Not load AJAX Tree Category again, For action expandAll in tree.js library
|
||||
$('#collapse-all-categorybox').hide();
|
||||
|
||||
$("#pcategories").closest(".form-group").hide();
|
||||
$("#ptype").closest(".form-group").hide();
|
||||
$("#pproductids").closest(".form-group").hide();
|
||||
$("#pmanufacturers").closest(".form-group").hide();
|
||||
$("#source option:selected").each(function() {
|
||||
var val = $(this).val();
|
||||
$("#"+val).closest(".form-group").show();
|
||||
});
|
||||
$("#source").change(function(){
|
||||
$("#pcategories").closest(".form-group").hide();
|
||||
$("#ptype").closest(".form-group").hide();
|
||||
$("#pproductids").closest(".form-group").hide();
|
||||
$("#pmanufacturers").closest(".form-group").hide();
|
||||
var val = $(this).val();
|
||||
$("#"+val).closest(".form-group").show(500);
|
||||
});
|
||||
//hide checkbox of root node
|
||||
$("input[type=checkbox]", "#categorybox").first().hide();
|
||||
var root_id = $("input[type=checkbox]", "#categorybox").first().val();
|
||||
Array.prototype.remove = function(v) { this.splice(this.indexOf(v) == -1 ? this.length : this.indexOf(v), 1); }
|
||||
if($("#category_img").val()){
|
||||
selected_images = JSON.parse($("#category_img").val());
|
||||
}
|
||||
$("input[type=checkbox]", "#categorybox").click(function(){
|
||||
if($(this).is(":checked")) {
|
||||
//find parent category
|
||||
//all parent category must be not checked
|
||||
var check = checkParentNodes($(this));
|
||||
if(!check){
|
||||
$(this).prop("checked", false);
|
||||
alert("All parent of this category must be not checked");
|
||||
} else {
|
||||
$(this).closest("ul").find("ul input[type=checkbox]").removeAttr("checked");
|
||||
}
|
||||
} else {
|
||||
//$(".list-image-" + $(this).val()).remove();
|
||||
delete selected_images[$(this).val()];
|
||||
}
|
||||
$("#category_img").val(JSON.stringify(selected_images));
|
||||
});
|
||||
|
||||
// Show selected_image when loaded page
|
||||
refreshListIcon();
|
||||
function refreshListIcon() {
|
||||
$("input[type=checkbox]", $(".form-select-icon")).each(function() {
|
||||
var listImage;
|
||||
if($(this).val() != root_id){
|
||||
listImage = $(".list-image", "#list_image_wrapper").clone(1);
|
||||
var d = new Date();
|
||||
var n = "" + d.getTime() + Math.random();
|
||||
n = n.replace(".", "");
|
||||
var span = $(this).closest("li").find("span");
|
||||
$(listImage).find("img").attr("id", "apci_" + n);
|
||||
$(listImage).find("a").data("for", "#apci_" + n);
|
||||
listImage.appendTo($(span).first());
|
||||
}
|
||||
for(var key in selected_images){
|
||||
if(key == $(this).val()){
|
||||
image_name = selected_images[key];
|
||||
if(listImage) {
|
||||
var path = $(listImage).find("img").attr("path");
|
||||
$(listImage).find("img").attr("src", path + image_name);
|
||||
$(listImage).find("img").removeClass("hidden");
|
||||
$(listImage).find(".remove-img").removeClass("hidden");
|
||||
}
|
||||
//listImage.find(".dropdown-toggle").html(image_name+' <span class="caret"></span>');
|
||||
// Set status for checkbox
|
||||
//$(this).attr("checked", "checked");
|
||||
break;
|
||||
}
|
||||
}
|
||||
$("#category_img").val(JSON.stringify(selected_images));
|
||||
//$(this).closest("ul.tree").css("display", "none");
|
||||
});
|
||||
}
|
||||
|
||||
function checkParentNodes(obj) {
|
||||
var flag = true;
|
||||
if(parent = obj.closest("ul").closest("li").find("input[type=checkbox]")){
|
||||
if(parent.val() != root_id){
|
||||
if($("input[value=" + parent.val() + "]","#categorybox").is(":checked")){
|
||||
flag = false;
|
||||
} else {
|
||||
flag = checkParentNodes(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
function replaceSpecialString(str){
|
||||
return str.replace(/\t/g, "_APTAB_").replace(/\r/g, "_APNEWLINE_").replace(/\n/g, "_APENTER_").replace(/"/g, "_APQUOT_").replace(/'/g, "_APAPOST_");
|
||||
}
|
||||
/*
|
||||
* End block for module ApCategoryImage
|
||||
*/
|
||||
|
||||
function hideFormLevel2(){
|
||||
$(".row-level2").addClass("hide");
|
||||
// Remove name
|
||||
$(".row-level2 input, .row-level2 textarea, .row-level2 select").each(function(){
|
||||
$(this).attr("data-name", $(this).attr('name'));
|
||||
});
|
||||
$(".row-level2 input, .row-level2 textarea, .row-level2 select").removeAttr("name");
|
||||
}
|
||||
|
||||
function showFormLevel2(){
|
||||
$(".row-level2").removeClass("hide");
|
||||
// get name
|
||||
$(".row-level2 input, .row-level2 textarea, .row-level2 select").each(function(){
|
||||
$(this).attr("name", $(this).attr('data-name'));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).on("click", ".btn-add-level2", function() {
|
||||
$(".btn-reset-level2").trigger("click");
|
||||
showFormLevel2();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-reset-level2", function() {
|
||||
// $("#frm-slider, #frm-block-slider").removeAttr("edit");
|
||||
$(".row-level2 input, .row-level2 textarea").val('');
|
||||
$(".row-level2 img").not('.mColorPickerTrigger img').attr("src", "").hide();// not remove image from color_picker
|
||||
|
||||
$('.mColorPickerInput.mColorPicker').each(function(){
|
||||
|
||||
var val = $(this).val();
|
||||
$(this).css('background-color', val);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// $(document).undelegate(".btn-cancel-level2", "click");
|
||||
$(document).on("click", ".btn-cancel-level2", function() {
|
||||
hideFormLevel2();
|
||||
$(".btn-reset-level2").trigger("click");
|
||||
$('.frm-level2').removeAttr("edit" );
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-save-level2", function() {
|
||||
var currentLang = default_language;
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
|
||||
var temId = lengthLang > 1 ? ".row2-title .lang-" + default_language + " input" : ".row2-title input";
|
||||
var title = $.trim($(temId).val());
|
||||
|
||||
var countLimit = 0; // error
|
||||
if(!title) {
|
||||
countLimit++;
|
||||
}
|
||||
|
||||
// Require enter value for one in of [title]
|
||||
if(countLimit > 1) {
|
||||
alert($(this).data("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
var html = $("#temp-list li:first").html();
|
||||
var idRow = (typeof $('.frm-level2').attr("edit") != "undefined") ? $('.frm-level2').attr("edit") : "";
|
||||
var action = (typeof $('.frm-level2').attr("edit") != "undefined") ? 'edit' : 'add';
|
||||
|
||||
if(action == 'add')
|
||||
{
|
||||
idRow = 1;
|
||||
// SORT id_Row
|
||||
var arr = $("#total_slider").val().split("|");
|
||||
arr.sort();
|
||||
for(var i = 0; i < arr.length; i++)
|
||||
{
|
||||
if(idRow != arr[i])
|
||||
{
|
||||
break;
|
||||
}
|
||||
idRow++;
|
||||
}
|
||||
}
|
||||
|
||||
// LIST INPUT NAME_idrow for temp form
|
||||
var list_input = new Array();
|
||||
$(".row-level2 *[name^='temp_']").each(function(html){
|
||||
list_input.push( $(this).attr('name') );
|
||||
});
|
||||
|
||||
// LIST INPUT NAME_idrow_idlang for div
|
||||
var list_input_name = new Array();
|
||||
$(".row-level2 *[name^='temp_']").each(function(html){
|
||||
if ( $(this).parent().parent().hasClass('translatable-field') || $(this).hasClass('js-multilang') ){
|
||||
// Input Multi-lang
|
||||
var full_name=$(this).attr('name');
|
||||
var name = full_name.slice( 0, full_name.lastIndexOf("_") );
|
||||
var lang_name = full_name.slice( full_name.lastIndexOf("_"), full_name.length );
|
||||
list_input_name.push( name + '_' + idRow + lang_name );
|
||||
}else{
|
||||
// Input No-lang
|
||||
var full_name=$(this).attr('name');
|
||||
list_input_name.push( full_name + '_' + idRow);
|
||||
}
|
||||
});
|
||||
|
||||
for (var i=0; i<list_input.length; i++)
|
||||
{
|
||||
//html += "\n<input type='hidden' name='" + list_input[i] + " id='" + list_input[i] + "/>";
|
||||
var value= $("[name='"+list_input[i]+"']").val();
|
||||
html += "\n<input type='hidden' name='" + list_input_name[i] + "' id='" + list_input_name[i] + "' value='"+value+"'/>";
|
||||
}
|
||||
|
||||
if(action =='add')
|
||||
{
|
||||
$("#list-slider").prepend("<li id='" + idRow + "'>" + html + "</li>");
|
||||
}else if(action =='edit')
|
||||
{
|
||||
$("#list-slider #" + idRow).html(html);
|
||||
}
|
||||
|
||||
|
||||
// Update labels for diplay interface
|
||||
var label = (title ? '<div class="col-lg-5">'+ title +'</div>' : "");
|
||||
|
||||
var image = '';
|
||||
if ($(".row2-image img").length)
|
||||
{
|
||||
// Exist image
|
||||
image = $.trim( $('.row2-image img').attr('src') );
|
||||
}
|
||||
label += (image ? '<img src="' + image + '">': "");
|
||||
$("#list-slider #" + idRow + " div:first").html(label);
|
||||
|
||||
$('.frm-level2').removeAttr("edit" );
|
||||
updateListIdFullSlider();
|
||||
|
||||
hideFormLevel2();
|
||||
|
||||
});
|
||||
|
||||
$(document).on("click", "#list-slider .btn-delete-level2", function() {
|
||||
if(confirm($("#form_content").data("delete"))) {
|
||||
$(this).closest("li").remove();
|
||||
$("#frm-slider").removeAttr("edit");
|
||||
updateListIdFullSlider();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-edit-level2", function() {
|
||||
$(".btn-reset-level2").trigger("click");
|
||||
showFormLevel2();
|
||||
var li = $(this).closest("li");
|
||||
var idRow = $(li).attr("id");
|
||||
var lengthLang = Object.keys($globalthis.languages).length;
|
||||
$(".frm-level2").attr("edit", $(li).attr("id"));
|
||||
|
||||
// LIST INPUT NAME of temp_form
|
||||
var list_input = new Array();
|
||||
$(".row-level2 *[name^='temp_']").each(function(html){
|
||||
list_input.push( $(this).attr('name') );
|
||||
});
|
||||
|
||||
// LIST INPUT NAME of div
|
||||
var list_input_name = new Array();
|
||||
$(".row-level2 *[name^='temp_']").each(function(html){
|
||||
if ( $(this).parent().parent().hasClass('translatable-field') || $(this).hasClass('js-multilang') ){
|
||||
// Input Multi-lang
|
||||
var full_name=$(this).attr('name');
|
||||
var name = full_name.slice( 0, full_name.lastIndexOf("_") );
|
||||
var lang_name = full_name.slice( full_name.lastIndexOf("_"), full_name.length );
|
||||
list_input_name.push( name + '_' + idRow + lang_name );
|
||||
}else{
|
||||
// Input No-lang
|
||||
var full_name=$(this).attr('name');
|
||||
list_input_name.push( full_name + '_' + idRow);
|
||||
}
|
||||
});
|
||||
|
||||
// SET DATA FROM div To temp_form
|
||||
for (var i=0; i<list_input.length; i++)
|
||||
{
|
||||
var input_idrow_name = list_input_name[i];
|
||||
var input_idrow_value = $("#list-slider #" + idRow + " [name='" + list_input_name[i] +"']").val();
|
||||
|
||||
$(".row-level2 [name='" + list_input[i] + "']").each(function(){
|
||||
$(this).val(input_idrow_value);
|
||||
|
||||
if($(this).closest('.row-level2').hasClass('row2-image') && input_idrow_value)
|
||||
{
|
||||
// IF temp_form have image
|
||||
var imgLink = imgModuleLink+input_idrow_value;
|
||||
$(this).parent().remove('img');
|
||||
$(this).parent().prepend( "<img src='" + imgLink + "' class='img-thumbnail'/>" );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('.mColorPickerInput.mColorPicker').each(function(){
|
||||
|
||||
var val = $(this).val();
|
||||
$(this).css('background-color', val);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function initApTabForm() {
|
||||
if ($('.aptab-config').length > 0)
|
||||
{
|
||||
//set tab aciton
|
||||
$('.aptab-config').each(function () {
|
||||
if (!$(this).parent().hasClass('active')) {
|
||||
element = $(this).attr('href').toString().replace("#", ".");
|
||||
$(element).hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('.aptab-config').click(function () {
|
||||
divElement = $(this).attr('href').toString().replace("#", ".");
|
||||
aElement = $(this);
|
||||
$('.aptab-config').each(function () {
|
||||
if ($(this).parent().hasClass('active')) {
|
||||
element = $(this).attr('href').toString().replace("#", ".");
|
||||
$(this).parent().removeClass('active');
|
||||
$(element).hide();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$(divElement).show();
|
||||
$(aElement).parent().addClass('active');
|
||||
|
||||
$('.form-action', $(divElement)).each(function () {
|
||||
$(this).trigger("change");
|
||||
});
|
||||
|
||||
$('.checkbox-group', $(divElement)).each(function () {
|
||||
$globalthis.showOrHideCheckBox($(this));
|
||||
});
|
||||
|
||||
|
||||
// if ($(this).attr('href') == "#aprow_animation" && $('#animation').length > 0)
|
||||
// $('#animation').trigger("change");
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function SaveAndStayAdminApPageBuilderProfiles(){
|
||||
$("button[name$='submitAddappagebuilder_profilesAndStay']").click();
|
||||
}
|
||||
|
||||
function SaveAdminApPageBuilderProfiles(){
|
||||
$("button[name$='submitAddappagebuilder_profiles']").click();
|
||||
}
|
||||
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 2007-2018 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();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
2577
modules/appagebuilder/views/js/admin/home.js
Normal file
2577
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
97
modules/appagebuilder/views/js/admin/product-list.js
Normal file
97
modules/appagebuilder/views/js/admin/product-list.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2018 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();
|
||||
}
|
||||
});
|
||||
|
||||
$('#saveAndStay').click(function(){
|
||||
$('input[name=submitAddappagebuilder_productsAndStay]').val('1');
|
||||
genreateForm();
|
||||
$('#appagebuilder_products_form').submit();
|
||||
return false;
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
142
modules/appagebuilder/views/js/admin/setting.js
Normal file
142
modules/appagebuilder/views/js/admin/setting.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @Website: apollotheme.com - prestashop template provider
|
||||
* @author Apollotheme <apollotheme@gmail.com>
|
||||
* @copyright 2007-2018 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() {
|
||||
$('.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 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);
|
||||
});
|
||||
$("#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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
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