';
$('.importer-popup').append(secondPopUp);
$('.importer-popup,.second-popup > .clearfix').click(function(e){
e.stopPropagation();
var $this = $(e.target);
if($this.hasClass('close')){
var $elem = ($this.parent().hasClass('clearfix'))?$('.second-popup'):$('.importer-overlay');
$elem.animate({opacity:0},300,function(){
$elem.remove();
});
}else if($this.hasClass('import-demo')){
// Add false to this condition to temprory disable purchase code
if( ($('textarea#purchase_code').val() == '' || !$this.hasClass('purchase-code-true')) && false ){
pixflow_messageBox('Verify Purchase','caution',"Before importing the demo website, please enter and validate your purchase code here, save and come back to demo importer.",'Enter Purchase Code',function(){
pixflow_enterPurchaseCode();
});
}else{
var importContent = $('.import-content').is(":checked"),
importSetting = $('.import-setting').is(":checked"),
importWidget = $('.import-widget').is(":checked"),
importMedia = $('.import-media').is(":checked"),
importConfirm = false,
ready = false;
if( ($('.agree').is(":checked") || $('.agree').val() == 'yes')){
importConfirm = true;
}
if( importContent || importSetting || importWidget ){
ready = true;
}
if( importConfirm && ready ){
e.preventDefault();
/*setTimeout(function(){
pixflow_messageBox('Give it some time','caution',"If you want to import media, please wait at least 10 to 15 minutes. It won't break or stop, it just takes time to load all those images.",'GOT IT',function(){
pixflow_closeMessageBox();
});
},60000);*/
if (!$this.find('.loader').length ) {
$('.import-demo').text(customizerValues.importing).append('
');
}
$('.import-demo .loader').stop().animate({width: '0%'}, 100, function () {
$('.import-demo .loader').remove();
});
$('.import-err').animate({marginLeft: '10px'}, 100, function () {
$('.import-err').next('span').animate({marginLeft: 0}, 100);
});
$('.import-demo').text(customizerValues.importDemo);
} else if (response.indexOf('continue') !=-1) {
var regex = /continue:([0-9]+)\/([0-9]+)/i;
var content = regex.exec(response);
setTimeout(function () {
if(content) {
pixflow_doImport(isStore, content[1], content[2]);
}else
pixflow_doImport(isStore);
}, 1);
} else {
jQuery.ajax({
url: customizerValues.importFileUrl,
type: 'HEAD',
// Successful Import
error: function(data)
{
// Regenerate Thumbnails
/*jQuery.ajax({
type: 'post',
url: customizerValues.ajax_url,
data: {
action: 'pixflow_generateThumbs',
nonce: customizerValues.ajax_nonce
},
success: function (response) {
console.log(response);
}
});*/
$('.import-demo .loader').animate({width: '100%'}, 1000, function () {
$('.import-demo .loader').remove();
});
$('.import-demo').text(customizerValues.imported);
trying=0;
pixflow_messageBox('Successfully Done','caution',"Import process is completed. Please reload the builder to see the demo.
After reloading the builder, if header navigation is not set correctly, go to Massive Builder > Menus and set the correct menu as primary and mobile menu.
Also if you want to get the correct size of imported images, you can install and use Regenerate Thumbnails .",'Reload Now',function(){
window.location.href = customizerValues.customizer_url ;
});
},
// Failed Import
success: function (data) {
if (typeof data != 'undefind') {
if (data.indexOf("Permission is Not Avaialable" > 0)) {
$(".import-demo").after('
' + customizerValues.faildImportPermission + '
');
}
if (data.indexOf('Remote Function Failed') > 0) {
$(".import-demo").after('
' + customizerValues.faildImportServer + '
');
}
else {
$(".import-demo").after('
' + customizerValues.faildImport + '
');
}
}
$('.import-demo .loader').stop().animate({width: '0%'}, 100, function () {
$('.import-demo .loader').remove();
});
$('.import-err').animate({marginLeft: '10px'}, 100, function () {
$('.import-err').next('span').animate({marginLeft: 0}, 100);
});
$('.import-demo').text(customizerValues.importDemo);
trying=0;
}
});
}
},
error: function(){
if(loaded == '1' && total=='1'){
trying++;
if(trying>5){
trying = 0;
$('.import-demo .loader').animate({width: '100%'}, 1000, function () {
$('.import-demo .loader').remove();
});
$('.import-demo').text(customizerValues.imported);
jQuery.ajax({
type: 'post',
url: customizerValues.ajax_url,
data: {
action: 'pixflow_ImportClearAllCache',
nonce: customizerValues.ajax_nonce,
demo: $('.import-demo').attr('data-id')
},
success: function (response) {
window.location.reload();
}
});
return;
}
}
pixflow_doImport(isStore, loaded, total);
}
});
}
var lastStatus = '',
lastUrl = '';
function pixflow_masterSetting() {
'use strict';
var currentStatus = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status');
if (currentStatus == 'unique') {
pixflow_loadRelatedSetting('unique');
pixflow_setUniqueCustomizer();
$('li.unique-page-setting').click()
}else{
pixflow_setGeneralCustomizer();
$('li.general-page-setting').click();
}
$('li.general-page-setting').click(function () {
var currentStatus = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status');
if (currentStatus == 'general') {
return;
}
var detailStatus = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('detail');
var text = customizerValues.mastersettingMsg1;
pixflow_messageBox(customizerValues.mastersettingMsgTitle,'caution',text,customizerValues.mastersettingMsgYes,function(){
pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status', 'general');
pixflow_livePreviewObj().pixflow_save_status('general', pixflow_livePreviewObj().$('meta[name="post-id"]').attr('content'), detailStatus,'change',function(){
pixflow_setGeneralCustomizer();
pixflow_closeMessageBox();
});
},customizerValues.mastersettingMsgNo,function(){
$('li.unique-page-setting').click();
pixflow_closeMessageBox();
},function(){
$('li.unique-page-setting').click();
});
});
$('li.unique-page-setting').click(function () {
lastStatus = 'unique';
//Running back button click twice - I'm not noob, I'm just tired :)
$('.back-btn').click();
$('.back-btn').click();
var currentStatus = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status');
if (currentStatus == 'unique') {
return;
}
var detailStatus = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('detail');
if (detailStatus == 'post' || detailStatus == 'portfolio' || detailStatus == 'product') {
var text;
if(detailStatus == 'post'){
text = customizerValues.mastersettingMsgPost;
}else if(detailStatus == 'portfolio'){
text = customizerValues.mastersettingMsgPortfolio;
}else if(detailStatus == 'product'){
text = customizerValues.mastersettingMsgProduct;
}
pixflow_messageBox(customizerValues.mastersettingMsgTitle,'caution',text,customizerValues.mastersettingMsgYes,function(){
pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status', 'unique');
try {
pixflow_livePreviewObj().pixflow_save_status('unique', pixflow_livePreviewObj().$('meta[name="post-id"]').attr('content'), detailStatus, 'change',function(){
pixflow_setUniqueCustomizer();
pixflow_closeMessageBox();
});
}catch(e){}
},customizerValues.mastersettingMsgNo1,function(){
$('li.general-page-setting').click();
pixflow_closeMessageBox();
},function(){
$('li.general-page-setting').click();
});
}else {
pixflow_livePreviewObj().$('meta[name="post-id"]').attr('setting-status', 'unique');
try {
pixflow_livePreviewObj().pixflow_save_status('unique', pixflow_livePreviewObj().$('meta[name="post-id"]').attr('content'), detailStatus, 'change',function(){
pixflow_setUniqueCustomizer();
});
}catch(e){}
}
});
}
function pixflow_loadRelatedSetting(status){
'use strict';
var settings = JSON.parse(customizerValues.uniqueSettings),
data={},
id;
for(var i = 0;i < settings.length ; i++){
var k = settings[i],
value = wp.customize(k).get(),
type = wp.customize.control(k).params.type;
data[k] = {"value":value,"type":type};
}
//Get and load unique settings
id = pixflow_livePreviewObj().$('meta[name="post-id"]').attr('content');
/*if((lastStatus != status || lastUrl != wp.customize.previewer.previewUrl()) && !(lastStatus == 'general' && status == 'unique')) {*/
if((lastStatus != status || lastUrl != wp.customize.previewer.previewUrl())) {
jQuery.ajax({
type: "post",
url: customizerValues.ajax_url,
data: "action=pixflow-get-setting" +
"&nonce=" + customizerValues.ajax_nonce +
"&pixflow_get_setting=" +
"&id=" + id +
"&settings=" + JSON.stringify(data) +
"&status=" + status,
success: function (result) {
var loadedSettings = JSON.parse(result);
// Set loaded values on controllers
// Maybe need to call loading overlay manually
for (var key in loadedSettings) {
var lObj = data[key];
if (loadedSettings.hasOwnProperty(key)) {
var obj = loadedSettings[key];
if (obj.value != lObj.value) {
switch (obj.type) {
case 'checkbox':
if (obj.value == 'true' && $('#' + key).is(":checked") == false) {
//check mark checkbox
$('#customize-control-' + key + ' span.switchery').click()
} else if ($('#' + key).is(":checked") == true) {
//unckeck check box
$('#customize-control-' + key + ' span.switchery').click()
}
break;
case 'image':
wp.customize.control(key).setting(obj.value);
if (obj.value == '') {
$('#customize-control-' + key + ' button.remove-button').click();
} else {
$('#customize-control-' + key + ' .current .container').html('