functions.js
9.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
function noEmptyField(target, value) {
if (jQuery(target).val() == '')
jQuery(target).val(value);
}
function deleteFieldVal(target, standard_value) {
if (jQuery(target).val() == standard_value)
jQuery(target).val('');
}
function selectAllC(from, where) {
if (jQuery(from).is(':checked')) {
jQuery(where).prop('checked', true);
} else {
jQuery(where).prop('checked', false);
}
}
function check_and_h(from, where) {
if (jQuery(from).is(":checked")) {
jQuery(where).val(1);
} else {
jQuery(where).val(0);
}
}
function co_menu(menu_id, content_id, value) {
/////CONTENT OPTIONS MENU
unselected_class = "co_m_item";
selected_class = "co_m_item_selected";
var menu_ids = ['#co_m_html',
'#co_m_if',
'#co_m_v',
'#co_m_div',
'#co_m_postpag',
'#co_m_imgSlider',
'#co_m_FBlikebox',
'#co_m_googleMaps',
'#co_m_opt_in',
'#co_m_shortcode'
];
var div_ids = ['#html_c',
'#thev_c',
'#if_c',
'#imgSlider',
'#div_c',
'#the_post_pag_div',
'#fb_likebox_c',
'#google_map_c',
'#opt_in_c',
'#shortcode_c'
];
for(i=0;i<menu_ids.length;i++){
if(menu_ids[i]==menu_id) jQuery(menu_ids[i]).attr('class', selected_class);
else jQuery(menu_ids[i]).attr('class', unselected_class);
}
for(i=0;i<div_ids.length;i++){
if(div_ids[i]==content_id) jQuery(div_ids[i]).css('display', 'block');
else jQuery(div_ids[i]).css('display', 'none');
}
jQuery("#c_type").val(value);
}
function checkAndH_boolean( checkID, targetID ){
if (jQuery(checkID).is(":checked")) {
jQuery(targetID).val('true');
} else {
jQuery(targetID).val('false');
}
}
function changePos_tb(from, type) {
if (type == 'bt') {
jQuery("#pos_tb_bottom").css('display', 'none');
jQuery("#pos_tb_top").css('display', 'none');
if (jQuery(from).val() == 'top') {
jQuery("#pos_tb_top").css('display', 'block');
jQuery("#gt_top_bottom").val('top');
} else {
jQuery("#pos_tb_bottom").css('display', 'block');
jQuery("#gt_top_bottom").val('bottom');
}
} else if (type == 'rl') {
jQuery("#pos_rl_left").css('display', 'none');
jQuery("#pos_rl_right").css('display', 'none');
if (jQuery(from).val() == 'left') {
jQuery("#pos_rl_left").css('display', 'block');
jQuery("#gt_right_left").val('left');
} else {
jQuery("#pos_rl_right").css('display', 'block');
jQuery("#gt_right_left").val('right');
}
}
}
jQuery(document).ready(function() {
jQuery("#date_pick_from").datepicker({
defaultDate : "+1w",
showOn : "button",
minDate : 0,
buttonImage : window.dir_path + "admin/assets/img/calendar_icon1.png",
buttonImageOnly : true,
changeMonth : true,
onClose : function(selectedDate) {
jQuery("#date_pick_until").datepicker("option", "minDate", selectedDate);
}
});
jQuery("#date_pick_until").datepicker({
defaultDate : "+1w",
minDate : 0,
showOn : "button",
minDate : 0,
buttonImage : window.dir_path + "admin/assets/img/calendar_icon1.png",
buttonImageOnly : true,
changeMonth : true,
onClose : function(selectedDate) {
jQuery("#date_pick_from").datepicker("option", "maxDate", selectedDate);
}
});
});
jQuery(document).ready(function() {
jQuery("#time_pick_from").timepicker({
showOn : "button",
buttonImage : window.dir_path + "admin/assets/img/Time.png",
buttonImageOnly : true
});
jQuery("#time_pick_until").timepicker({
showOn : "button",
buttonImage : window.dir_path + "admin/assets/img/Time.png",
buttonImageOnly : true
});
});
function checkfh(id) {
var str = jQuery(id).val();
var correct_str = new Array();
if (str.indexOf(',') > -1) {
var arr_str = str.split(',');
for (i = 0; i < arr_str.length; i++) {
if (arr_str[i].indexOf('//') > -1) {
var n_arr = arr_str[i].split('//');
correct_str.push(n_arr[1]);
} else {
correct_str.push(arr_str[i]);
}
}
var final_str = correct_str.join();
jQuery(id).val(final_str);
} else if (str.indexOf('//') > -1) {
var n_arr = str.split('//');
jQuery(id).val(n_arr[1]);
}
}
function writeTagValue(the_value) {
var tags_div = '#tags_field';
var hidden_field = '#hidden_country_list';
var span_tag_count = jQuery('#input_tag_num').val();
//console.log(span_tag_count);
if (span_tag_count == 0) {
jQuery(tags_div).append("<div class='clear'></div>");
}
var str = jQuery(hidden_field).val();
if (str.indexOf(the_value) > -1)
return false;
else {
var html_val = '<span class="tag_item" id="tag_num_'
+ span_tag_count
+ '"><span>'
+ the_value
+ ' </span><span class="remove_tag" onClick="removeTag('
+ span_tag_count + ', \'' + the_value
+ '\');" title="Removing tag">x</span></span>';
jQuery(tags_div).prepend(html_val);
if (str != '')
new_str = str + ',' + the_value;
else
new_str = the_value;
jQuery(hidden_field).val(new_str);
span_tag_count++;
jQuery('#input_tag_num').val(span_tag_count);
}
}
function removeTag(num, the_value) {
jQuery('#tag_num_' + num).remove();
var hidden_id = '#hidden_country_list';
var str = jQuery(hidden_id).val();
if (str.indexOf(',') > -1) {
var arr = str.split(',');
var new_arr = new Array();
for (i = 0; i < arr.length; i++) {
if (arr[i] != the_value)
new_arr.push(arr[i]);
}
var new_str = new_arr.join(',');
} else {
new_str = '';
jQuery('#tags_field').empty();
jQuery('#input_tag_num').val(0);
}
jQuery(hidden_id).val(new_str);
}
/***** OPT IN **************/
function ips_connect_aweber( textarea ){
jQuery.ajax({
type : "post",
url : window.base_url+'/wp-admin/admin-ajax.php',
data : {
action: "ips_update_aweber",
auth_code: jQuery( textarea ).val()
},
success: function (data) {
alert('Connected');
}
});
}
function ips_get_cc_list( ips_cc_user,ips_cc_pass ){
jQuery("#ips_cc_list").find('option').remove();
jQuery.ajax({
type : "post",
dataType: 'JSON',
url : window.base_url+'/wp-admin/admin-ajax.php',
data : {
action: "ips_get_cc_list",
ips_cc_user: jQuery( ips_cc_user ).val(),
ips_cc_pass: jQuery( ips_cc_pass ).val()
},
success: function (data) {
jQuery.each(data, function(i, option){
jQuery("<option/>").val(i).text(option.name).appendTo("#ips_cc_list");
});
}
});
}
jQuery(function() {
jQuery( 'textarea.editors' ).ckeditor();
});
function ips_delete_popup(value, name){
var confirm_box = confirm("Are You Sure You Want To Delete '"+name+"'?");
if(confirm_box){
jQuery('#hidden_tmp_delete').val(value);
jQuery('#manage_templates').submit();
}
}
function ips_confirm_multiple_delete(){
var confirm_box = confirm("Are You Sure You Want To Delete Selected Items?");
if(confirm_box) jQuery('#manage_templates').submit();
}
function ips_change_item_status(id, icon){
if(jQuery('#item_'+id+'_status').val()=='active') newval = 'inactive';
else newval = 'active';
////AJAX
jQuery.ajax({
type : "post",
url : window.base_url+'/wp-admin/admin-ajax.php',
data : {
action: "ips_update_popup_status",
status: newval,
the_id: id
},
success: function (data) {
if(data==1){
jQuery('#item_'+id+'_status').val(newval);
jQuery(icon).attr('class', 'ips_item_status_'+newval);
}
}
});
}
function isp_update_popup_content_box(){
position_x = jQuery('#isp_box_bk_position_x').val();
position_y = jQuery('#isp_box_bk_position_y').val();
repeat_bk = jQuery('#isp_bk_box_repeat').val();
background_color = jQuery('#box_bk_color').val();
background_image = jQuery('#bk_img_box').val();
obj = {};
if(background_color!='' && background_image!='') obj['background'] = background_color +' url('+background_image+')';
else if(background_color!='') obj['background'] = background_color;
else if(background_image!='') obj['background'] = 'url('+background_image+')';
obj['background-position'] = position_y + ' ' +position_x;
obj['background-repeat'] = repeat_bk;
obj['min-height'] = jQuery('#general_height').val()+"px";
jQuery('#cke_1_contents, #cke_2_contents').css(obj);
//console.log(obj);
}
jQuery(document).ready(function(){
isp_update_popup_content_box();
});
jQuery(document).ready(function(){
jQuery('.isp-left-ul-menu-add-edit-admin li a').on('click', function(){
jQuery('.isp-left-ul-menu-add-edit-admin li').each(function(){
jQuery(this).attr('class', '');
});
jQuery(this).parent().addClass('isp-hover');
selector = jQuery(this).attr('href');
console.log('select: '+selector);
jQuery('.isp-right-options-inner .accordion-body').each(function(){
current = '#'+jQuery(this).attr('id');
if (current!=selector){
//console.log('current: '+current);
jQuery(this).css('height', '0px');
jQuery(this).css('min-height', '0px');
jQuery(this).removeClass('in');
}
});
jQuery(selector).css('height', 'auto');
jQuery(selector).css('min-height', '300px');
})
});