');
}
}
return;
}
$obj.find('.vc_welcome-header').html('
'+admin_var.portfolioPostLayout+'
');
$obj.find('.vc_welcome-header h5').after('
'+admin_var.welcomeMsg+'
');
$obj.find('.vc_welcome-header h3').after('
' +
'
' +
'
' +
''+admin_var.yourStyle+'' +
'
' +
'
' +
'
');
$obj.find('#vc_no-content-add-element,#vc_templates-more-layouts').css({opacity:0,zIndex:-999});
$obj.find('.portfolio-templates .md-template-button').click(function(){
var clicked = $(this).attr('data-name');
clicked = clicked[0].toUpperCase()+clicked.slice(1);
$obj.find('.portfolio-templates .md-template-button').removeClass('clicked');
$(this).addClass('clicked');
if ($(this).hasClass('custom')){
$obj.find('#vc_no-content-add-element').click();
}else {
$body.find('#vc_templates-more-layouts').click();
$popup.find('.vc_templates-panel').css('opacity', 0);
$popup.find('#vc_ui-panel-templates .vc_ui-list-bar-item-trigger:contains(' + clicked + ')').click();
$popup.find('.vc_templates-panel .vc_ui-close-button').click();
}
});
$('#poststuff #postbox-container-1 #postimagediv').after('
');
$('.wpb_switch-to-composer').click(function(){
var $this = $(this);
if( $this.parent('.composer-switch').hasClass('vc_backend-status') ){
$this.text(admin_var.classicMode);
}else{
$this.text(admin_var.backendEditor);
}
}).click();
$('.composer-switch , .vc_backend-status').append('
'+admin_var.massiveBuilder+''+admin_var.changeLayout+'');
$obj.find('.vc_default-templates .wpb_row,.vc_default-templates .vc_row-fluid').append(''+
'
'+admin_var.yourStyle+'');
$('.post-type-portfolio .vc_templates-image').click(function(){
$('.post-type-portfolio .vc_templates-image').removeClass('clicked');
$(this).addClass('clicked');
if($(this).hasClass('vc_templates-blank')) {
$('#vc_no-content-add-element').click();
}
});
$('.templates').click(function(){
if ($('.vc_not-empty').length) {
var r = confirm(admin_var.changeLayoutMsg);
if (r == true) {
$('[data-model-id]').each(function () {
try {
vc.shortcodes.get($(this).attr('data-model-id')).destroy();
$('.post-type-portfolio .vc_templates-image').removeClass('clicked');
} catch (e) {
}
})
} else {
}
}else{
$('#vc_templates-more-layouts').click();
$('[data-model-id]').each(function () {
try {
vc.shortcodes.get($(this).attr('data-model-id')).destroy();
$('.post-type-portfolio .vc_templates-image').removeClass('clicked');
} catch (e) {
}
})
}
});
}
function pixflow_classic_mode(){
'use strict';
var $composerBtn = jQuery('.wpb_switch-to-composer'),
$postPage = $('.post-type-post'),
$switch = $('.composer-switch');
if($composerBtn.length<1 || $('body').hasClass('post-type-portfolio')){
return;
}
if (! $switch.hasClass('vc_backend-status') && !$postPage.length ){
$composerBtn.click();
$composerBtn.html(admin_var.classicMode);
} else if( $switch.hasClass('vc_backend-status') && $postPage.length ) {
$composerBtn.click();
$composerBtn.html(admin_var.backendEditor);
}
}
function pixflow_addMassivePanel(){
'use strict';
var $welcomePanel = $('#welcome-panel');
if( ! $welcomePanel.length )
return;
var rand_class = 'massive-panel-bg3' ;
$welcomePanel.before('' +
'
' +
'

' +
'' +
'
' +
'
' +
'
' +
'
VISIONARY LIVE
WEBSITE BUILDER ' + '
' + '
' +
'
' +
'
' +
'
' +
'
current version '+ admin_var.theme_version +'
' + '

' +'
' +
'
');
}
function pixflow_metabox(){
'use strict';
if($('.post-format').length<1){
return;
}
if($('#post-format-gallery').attr('checked')=='checked'){
$('#featuredgallerydiv').css('display','block');
$('#section-video').css('display','none');
$('#section-audio').css('display','none');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','none');
}
else if($('#post-format-audio').attr('checked')=='checked'){
$('#featuredgallerydiv').css('display','none');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','block');
$('#section-video').css('display','none');
$('#section-audio').css('display','block');
}
else if($('#post-format-video').attr('checked')=='checked'){
$('#featuredgallerydiv').css('display','none');
$('#blog_meta_box_video_url').css('display','block');
$('#blog_meta_box_audio_url').css('display','none');
$('#section-video').css('display','block');
$('#section-audio').css('display','none');
}else{
$('#featuredgallerydiv').css('display','none');
$('#section-video').css('display','none');
$('#section-audio').css('display','none');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','none');
}
$('.post-format').click(function(){
if($(this).attr('value')=='gallery'){
$('#featuredgallerydiv').css('display','block');
$('#section-video').css('display','none');
$('#section-audio').css('display','none');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','none');
}
if($(this).attr('value')=='audio'){
$('#featuredgallerydiv').css('display','none');
$('#section-video').css('display','none');
$('#section-audio').css('display','block');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','block');
}
if($(this).attr('value')=='video'){
$('#featuredgallerydiv').css('display','none');
$('#section-video').css('display','block');
$('#section-audio').css('display','none');
$('#blog_meta_box_video_url').css('display','block');
$('#blog_meta_box_audio_url').css('display','none');
}
if($(this).attr('value')=='0' || $(this).attr('value')=='quote') {
$('#featuredgallerydiv').css('display','none');
$('#section-video').css('display','none');
$('#section-audio').css('display','none');
$('#blog_meta_box_video_url').css('display','none');
$('#blog_meta_box_audio_url').css('display','none');
}
});
}
function pixflow_featuredGallery(){
'use strict';
function pixflow_fixBackButton() {
'use strict';
setTimeout(function(){
jQuery('.media-menu a:first-child').text('? '+admin_var.editSelection).addClass('button').addClass('button-large').addClass('button-primary');
},0);
}
function pixflow_ajaxUpdateTempMetaData() {
'use strict';
jQuery.ajax({
type : "post",
dataType : "json",
url : myAjax.ajaxurl,
data : {
action: "pixflow_fg_update_temp",
fg_post_id: jQuery("#fg_perm_metadata").data("post_id"),
fg_temp_noncedata: jQuery("#fg_temp_noncedata").val(),
fg_temp_metadata: jQuery("#fg_perm_metadata").val()
},
success: function(response) {
if (response == "error") {
alert(admin_var.updateErr);
}
}
});
}
// Uploading files
if (jQuery('#fg_removeall').hasClass('premp6')) {
var button = '
';
} else {
var button = '
';
}
jQuery('#fg_select').on('click', function (event) {
event.preventDefault();
// If the media frame already exists, reopen it.
if (file_frame) {
file_frame.open();
pixflow_fixBackButton();
return;
}
// Create the media frame.
var file_frame = wp.media.frame = wp.media({
frame: "post",
state: "featured-gallery",
library: {type: 'image'},
button: {text: "Edit Image Order"},
multiple: true
});
// Create Featured Gallery state. This is essentially the Gallery state, but selection behavior is altered.
file_frame.states.add([
new wp.media.controller.Library({
id: 'featured-gallery',
title: 'Select Images for Gallery',
priority: 20,
toolbar: 'main-gallery',
filterable: 'uploaded',
library: wp.media.query(file_frame.options.library),
multiple: file_frame.options.multiple ? 'reset' : false,
editable: true,
allowLocalEdits: true,
displaySettings: true,
displayUserSettings: true
}),
]);
file_frame.on('open', function () {
var selection = file_frame.state().get('selection');
var library = file_frame.state('gallery-edit').get('library');
var ids = jQuery('#fg_perm_metadata').val();
if (ids) {
var idsArray = ids.split(',');
idsArray.forEach(function (id) {
var attachment = wp.media.attachment(id);
attachment.fetch();
selection.add(attachment ? [attachment] : []);
});
file_frame.setState('gallery-edit');
idsArray.forEach(function (id) {
var attachment = wp.media.attachment(id);
attachment.fetch();
library.add(attachment ? [attachment] : []);
});
}
});
file_frame.on('ready', function () {
jQuery('.media-modal').addClass('no-sidebar');
pixflow_fixBackButton();
});
// When an image is selected, run a callback.
file_frame.on('update', function () {
var imageIDArray = [];
var imageHTML = '';
var metadataString = '',
images = file_frame.state().get('library');
images.each(function (attachment) {
imageIDArray.push(attachment.attributes.id);
imageHTML += '
' + button + '
';
});
metadataString = imageIDArray.join(",");
if (metadataString) {
jQuery("#fg_perm_metadata").val(metadataString);
jQuery("#featuredgallerydiv ul").html(imageHTML);
jQuery('#fg_select').text(admin_var.editSelection);
jQuery('#fg_removeall').addClass('visible');
setTimeout(function () {
pixflow_ajaxUpdateTempMetaData();
}, 0);
}
});
// Finally, open the modal
file_frame.open();
});
jQuery('#featuredgallerydiv ul').on('click', 'button', function (event) {
event.preventDefault();
if (confirm('Are you sure you want to remove this image?')) {
var removedImage = jQuery(this).parent().children('img').attr('id');
var oldGallery = jQuery("#fg_perm_metadata").val();
var newGallery = oldGallery.replace(',' + removedImage, '').replace(removedImage + ',', '').replace(removedImage, '');
jQuery(this).parent('li').remove();
jQuery("#fg_perm_metadata").val(newGallery);
if (newGallery == "") {
jQuery('#fg_select').text(admin_var.selectImage);
jQuery('#fg_removeall').removeClass('visible');
}
pixflow_ajaxUpdateTempMetaData();
}
});
jQuery('#fg_removeall').on('click', function (event) {
event.preventDefault();
if (confirm('Are you sure you want to remove all images?')) {
jQuery("#featuredgallerydiv ul").html("");
jQuery("#fg_perm_metadata").val("");
jQuery('#fg_removeall').removeClass('visible');
jQuery('#fg_select').text(admin_var.selectImage);
pixflow_ajaxUpdateTempMetaData();
}
});
}
$('.remove-megaMenu-attachment').click(function(){
var $this=$(this),
menuId=$this.attr('id').split("-");
$('#image-'+menuId[1]).remove();
$('#attachment-'+menuId[1]).remove();
$('#input-attachment-'+menuId[1]).val('1');
});
function pixflow_vcBackendIcons(){
var regex = /(http.*)x=([0-9-]+)[|]y=([0-9-]+)/i;
$('#vc_ui-panel-add-element li.wpb-layout-element-button').each(function(){
var icon = $(this).find('a i.vc_element-icon').css('background-image');
if(icon.search(regex)!=-1){
var match = regex.exec(icon);
var url = match[1], x = match[2], y= match[3];
icon = 'background: transparent url(' + url + ') '+x+'px '+y+'px no-repeat;';
}else {
icon = 'background: transparent ' + icon + '15px center no-repeat;';
}
$(this).find('a i.vc_element-icon').attr('style',icon);
})
}
$(document).ready(function () {
pixflow_IconSelect();
pixflow_showIcons();
pixflow_showMegaBg();
pixflow_menuUpdate();
pixflow_customShortcodesJs();
pixflow_media_upload();
pixflow_addMassivePanel();
pixflow_metabox();
pixflow_featuredGallery();
pixflow_vcBackendIcons();
});
$(window).load(function(){
pixflow_singlePageLayout();
pixflow_classic_mode();
});
})(jQuery);