(function ($){
var el_form=$('#form-new-post'),
el_form_submit=$('.submit', el_form);
el_form.on('submit', function (e){
e.preventDefault();
el_form_submit.attr('disabled', 'disabled');
new_post();
});
/* function isEmail(email){
var regex=/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
} */
function new_post(){
$.ajax({
url: localized_donot_sell_form.admin_donot_sell_ajax_url,
type: 'POST',
dataType: 'json',
data: {
action: 'donot_sell_save_post',
form_data: el_form.serialize()
},
cache: false
}).done(function (r){
console.log(r);
if(r.donotsellrequests!==''){
console.log('complete')
jQuery('#donotsellmsg').addClass('donotsell-msg');
jQuery('#donotsellmsg').removeClass('donotsell-error-msg');
jQuery('#donotsellmsg').text('Request has been submitted successfully!!').delay(10000).fadeOut();
}
console.log(r.error)
if(r.error!==''&&r.error!=undefined){
jQuery('#donotsellmsg').removeClass('donotsell-msg');
jQuery('#donotsellmsg').addClass('donotsell-error-msg');
jQuery('#donotsell-error-msg').text(r.error).delay(10000).fadeOut();
}
el_form_submit.removeAttr('disabled');
});
}
function trigger_new_post(){
el_form.trigger('submit');
}
})(jQuery);
(function($){
window.NggPaginatedGallery=function(displayed_gallery_id, container){
this.displayed_gallery_id=displayed_gallery_id;
this.container=$(container);
this.container_name=container;
this.get_displayed_gallery_obj=function(){
var index='gallery_' + this.displayed_gallery_id;
if(typeof(window.galleries[index])=='undefined'){
return false;
}else{
return window.galleries[index];
}};
this.enable_ajax_pagination=function(){
var self=this;
$('body').on('click', 'a.ngg-browser-prev, a.ngg-browser-next', function (event){
var skip=true;
$(this).parents(container).each(function(){
if($(this).data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
skip=false;
});
if(!skip){
event.preventDefault();
}else{
return;
}
window['ngg_ajax_operaton_count']++;
$('body, a').css('cursor', 'wait');
$.get({
url: $(this).attr('href'),
headers: { 'X-NGG-Pagination-Request': true },
success: function (response){
window['ngg_ajax_operaton_count']--;
if(window['ngg_ajax_operaton_count'] <=0){
window['ngg_ajax_operaton_count']=0;
$('body, a').css('cursor', 'auto');
}
if(response){
var html=$(response);
var replacement=false;
html.find(self.container_name).each(function(){
if(replacement){
return true;
}
if($(this).data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
replacement=$(this);
});
if(replacement){
self.container.each(function (){
var $this=$(this);
if($this.data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
var $new_element=$(replacement.html());
var promises=$new_element.find('img').toArray().map(function(img){
return new Promise(function(resolve, reject){
var i=new Image();
i.src=img.src;
$(i).on('load', resolve);
});
});
Promise.all(promises).then(function(){
$this.html($new_element);
$(document).trigger('refreshed');
const event=new Event("nextgen_page_refreshed");
document.dispatchEvent(event);
});
return true;
});
}}
}});
});
};
var displayed_gallery=this.get_displayed_gallery_obj();
if(displayed_gallery){
if(typeof(displayed_gallery.display_settings['ajax_pagination'])!='undefined'){
if(parseInt(displayed_gallery.display_settings['ajax_pagination'])){
this.enable_ajax_pagination();
}}
}
if(typeof(window['ngg_ajax_operation_count'])=='undefined'){
window['ngg_ajax_operaton_count']=0;
}};
Object.setPrototypeOf=Object.setPrototypeOf||function(obj, proto){
obj.__proto__=proto;
return obj;
};
if(typeof window.galleries!=='undefined'){
Object.setPrototypeOf(window.galleries,
{
get_api_version: function(){
return '0.1';
},
get_from_id: function (gallery_id){
var self=this;
var retval=null;
var keys=Object.keys(this);
for (var i=1; i <=keys.length; i++){
var gallery=self[keys[i - 1]];
if(gallery.ID===gallery_id||gallery.ID==='gallery_' + gallery_id||gallery.ID===parseInt(gallery_id)){
retval=gallery;
break;
}}
return retval;
},
get_from_slug: function (slug){
var self=this;
var retval=null;
var keys=Object.keys(this);
for (var i=1; i <=keys.length; i++){
var gallery=self[keys[i - 1]];
if(gallery.slug===slug){
retval=gallery;
break;
}}
return retval;
},
get_setting: function(gallery_id, name, def){
var tmp='';
var gallery=this.get_from_id(gallery_id);
if(gallery&&typeof gallery[name]!=='undefined'){
tmp=gallery[name];
}else{
tmp=def;
}
if(tmp===1)       tmp=true;
if(tmp===0)       tmp=false;
if(tmp==='1')     tmp=true;
if(tmp==='0')     tmp=false;
if(tmp==='false') tmp=false;
if(tmp==='true')  tmp=true;
return tmp;
},
get_display_setting: function(gallery_id, name, def){
var tmp='';
var gallery=this.get_from_id(gallery_id);
if(gallery&&typeof gallery.display_settings[name]!=='undefined'){
tmp=gallery.display_settings[name];
}else{
tmp=def;
}
if(tmp===1)       tmp=true;
if(tmp===0)       tmp=false;
if(tmp==='1')     tmp=true;
if(tmp==='0')     tmp=false;
if(tmp==='false') tmp=false;
if(tmp==='true')  tmp=true;
return tmp;
},
is_widget: function(gallery_id){
var retval=false;
var gallery=this.get_from_id(gallery_id);
var slug=gallery.slug;
if(slug){
return slug.indexOf('widget-ngg-images')!==-1;
}
return retval;
}}
); }})(jQuery);