';
$('html body').append(pophtml);
$('li#as_add_new_gallery').on('click', function(){
$('.as_ga_main_overlay, .as_gl_main_popup').fadeIn(300);
});
$('#as_gl_cancel').on('click', function(){
$('.as_ga_main_overlay, .as_gl_main_popup').fadeOut(300);
});
$('form#as_gl_popup_form').on('submit', function(e){
e.preventDefault();
var titleval = $('#as_enter_title').val();
var a1 = $('#as_add_new_gallery').attr('as-data');
var altval = $('#as_enter_alt_text').val();
var idval = $('#as_image_id').attr('as-imgid');
var imgval = $('.as_gl_image img').attr('src');
var as_thamb = $('#as_image_thamb').attr('as-imgthamb');
var imgchack = $('.as_gl_image').html();
if (a1 == '') {
a1 = 0;
}else{
a1++;
}
if (imgchack !== '') {
if (imgval !== '') {
$('', {
id: 'as_remove_'+a1,
onclick: 'as_gl_remove_img('+a1+')',
html: ''+
''+
''+
''+
''+
''
}).insertBefore('#as_add_new_gallery');
$('#as_enter_title').val('');
$('#as_enter_alt_text').val('');
$('.as_gl_image img').remove('img');
$('.as_ga_main_overlay, .as_gl_main_popup').fadeOut(300);
$('#as_add_new_gallery').attr('as-data', a1);
}else{
alert('Please select Image');
}
}else{
alert('Please select Image');
}
});
$('#as_gl_upload').click(function(e) {
e.preventDefault();
var image = wp.media({
title: 'Upload Image',
// mutiple: true if you want to upload multiple files at once
multiple: false
}).open()
.on('select', function(e){
// This will return the selected image from the Media Uploader, the result is an object
var as_gallery_url_image = image.state().get('selection').first();
// We convert uploaded_image to a JSON object to make accessing it easier
// console.log(as_gallery_url_image.id);
var as_gal_url = as_gallery_url_image.toJSON().url;
var as_thamb_url = as_gallery_url_image.toJSON().sizes.thumbnail.url;
// Let's assign the url value to the input field
$('.as_gl_image').html('');
$('#as_image_id').attr('as-imgid', as_gallery_url_image.id);
$('#as_image_thamb').attr('as-imgthamb', as_thamb_url);
});
});
$('#as_gl_left_icon_upload').click(function(e) {
e.preventDefault();
as_click_to_wp_popup('#as_gl_left_icon', 'Upload Lightbox Left Icon');
});
$('#as_gl_right_icon_upload').click(function(e) {
e.preventDefault();
as_click_to_wp_popup('#as_gl_right_icon', 'Upload Lightbox Right Icon');
});
$('#as_gl_close_icon_upload').click(function(e) {
e.preventDefault();
as_click_to_wp_popup('#as_gl_close_icon', 'Upload Lightbox Close Icon');
});
var as_gl_color = {
// you can declare a default color here,
// or in the data-default-color attribute on the input
defaultColor: false,
// a callback to fire whenever the color changes to a valid color
change: function(event, ui){
},
// a callback to fire when the input is emptied or an invalid color
clear: function() {},
// hide the color picker controls on load
hide: true,
// show a group of common colors beneath the square
// or, supply an array of colors to customize further
palettes: false
};
$('#as_gl_bg_overlay_color').wpColorPicker(as_gl_color);
$('#as_gl_title_color').wpColorPicker(as_gl_color);
$('#as_gl_main_border_color').wpColorPicker(as_gl_color);
$('#as_gl_main_hover_color').wpColorPicker(as_gl_color);
$('#as_gl_title_tx_color').wpColorPicker(as_gl_color);
//
$('#as_gl_bg_overlay_opacity').jRange({
from: 1,
to: 10,
step: 1,
width: 400,
showLabels: true
});
$('#as_gl_speed').jRange({
from: 100,
to: 5000,
step: 50,
width: 400,
showLabels: true
});
$('#as_gl_title_bg_opacity').jRange({
from: 1,
to: 10,
step: 1,
width: 400,
showLabels: true
});
//
$('#as_gl_resset').on('click', function(e){
e.preventDefault();
var as_gl_resset = confirm("Want to reset all options?");
if (as_gl_resset === true) {
$.ajax({
type: 'POST',
url: ajaxurl,
data: {
action: 'as_gl_reset_options',
as_bool_val: 'yes',
},
success: function(data){
if (data == 'reset') {
location.reload(true);
}
}
});
}
});
$( ".anu_my_stutas_main .anu_stutas_inner span.as_gl_toggle" ).toggle(function() {
$('.anu_my_stutas_main').removeClass('as_gl_right');
$('.anu_my_stutas_main .anu_stutas_inner span.as_gl_toggle').removeClass('as_gl_close');
$('.anu_my_stutas_main').addClass('as_gl_left');
$('.anu_my_stutas_main .anu_stutas_inner span.as_gl_toggle').addClass('as_gl_open');
}, function() {
$('.anu_my_stutas_main').removeClass('as_gl_left');
$('.anu_my_stutas_main .anu_stutas_inner span.as_gl_toggle').removeClass('as_gl_open');
$('.anu_my_stutas_main').addClass('as_gl_right');
$('.anu_my_stutas_main .anu_stutas_inner span.as_gl_toggle').addClass('as_gl_close');
});
});
function as_gl_remove_img(id){
var as_result = confirm("Want to delete?");
if (as_result) {
jQuery('#as_remove_'+id).remove();
}
}
function as_click_to_wp_popup(id, title){
var image = wp.media({
title: title,
// mutiple: true if you want to upload multiple files at once
multiple: false
}).open()
.on('select', function(e){
// This will return the selected image from the Media Uploader, the result is an object
var as_gallery_url_image = image.state().get('selection').first();
// We convert uploaded_image to a JSON object to make accessing it easier
// console.log(as_gallery_url_image.id);
var as_gal_url = as_gallery_url_image.toJSON().url;
var as_gal_id = as_gallery_url_image.id;
jQuery(id).val(as_gal_url);
});
}
function as_gl_remove(id){
jQuery('#'+id).val('');
}