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
|
/*!
* Admin js
*/
function media_upload( button_class) {
if (!window.wp || !window.wp.media || !window.wp.media.editor || !window.wp.media.editor.send || !window.wp.media.editor.send.attachment) return;
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
jQuery('body').on('click',button_class, function(e) {
uploadparent = jQuery(this).closest('div');
var button_id ='#'+jQuery(this).attr('id');
/* console.log(button_id); */
var self = jQuery(button_id);
var send_attachment_bkp = wp.media.editor.send.attachment;
var button = jQuery(button_id);
/* var id = button.attr('id').replace('_button', ''); */
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment){
if ( _custom_media ) {
/* jQuery('.custom_media_id').val(attachment.id); */
uploadparent.find('.slideimages').val(attachment.url);
uploadparent.find('.imagebox').attr('src',attachment.url);
/* jQuery('.custom_media_image').attr('src',attachment.url).css('display','block'); */
} else {
return _orig_send_attachment.apply( button_id, [props, attachment] );
}
}
wp.media.editor.open(button);
return false;
});
}
jQuery(document).ready(function() {
var uploadparent = 0;
media_upload( '.upload_image_button' );
// Show/hide slides
jQuery('.slidetitle').click(function() {
jQuery(this).next().toggle("fast");
});
// Jquery confim window on reset to defaults
jQuery('#mantra_defaults').click( function() {
if (!confirm('Reset Mantra Settings to Defaults?')) { return false; }
});
// Hide or show dimmensions
jQuery('#mantra_dimselect').change(function() {
if (jQuery('#mantra_dimselect option:selected').val()=="Absolute") {
jQuery('#relativedim').hide("normal");jQuery('#absolutedim').show("normal");
} else {
jQuery('#relativedim').show("normal");jQuery('#absolutedim').hide("normal");
}
});
if (jQuery('#mantra_dimselect option:selected').val()=="Absolute") {
jQuery('#relativedim').hide("normal");jQuery('#absolutedim').show("normal");}
else {
jQuery('#relativedim').show("normal");jQuery('#absolutedim').hide("normal");
}
// Hide or show slider settings
jQuery('#mantra_slideType').change(function() {
jQuery('.slideDivs').hide("normal");
switch (jQuery('#mantra_slideType option:selected').val()) {
case "Slider Shortcode" :
jQuery('#sliderShortcode').show("normal");
jQuery('#sliderParameters').hide("normal");
break;
case "Custom Slides" :
jQuery('#sliderCustomSlides').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Latest Posts" :
jQuery('#sliderLatestPosts').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Random Posts" :
jQuery('#sliderRandomPosts').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Sticky Posts" :
jQuery('#sliderStickyPosts').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Latest Posts from Category" :
jQuery('#sliderLatestCateg').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Random Posts from Category" :
jQuery('#sliderRandomCateg').show("normal");
jQuery('#sliderParameters').show("normal");
break;
case "Specific Posts" :
jQuery('#sliderSpecificPosts').show("normal");
jQuery('#sliderParameters').show("normal");
break;
}//switch
});//function
jQuery('#mantra_slideType').trigger('change');
//Slide type value
$sliderNr = jQuery('#mantra_slideType').val();
//Show category if a category type is selected
if ($sliderNr=="Latest Posts from Category" || $sliderNr=="Random Posts from Category" )
jQuery('#slider-category').show();
else jQuery('#slider-category').hide();
//Show number of slides if that's the case
if ($sliderNr=="Latest Posts" || $sliderNr =="Random Posts" || $sliderNr =="Sticky Posts" || $sliderNr=="Latest Posts from Category" || $sliderNr=="Random Posts from Category" )
jQuery('#slider-post-number').show();
else jQuery('#slider-post-number').hide();
//On change
jQuery('#mantra_slideType').change(function(){
$sliderNr=jQuery('#mantra_slideType').val();
//Show category if a category type is selected
if ($sliderNr=="Latest Posts from Category" || $sliderNr=="Random Posts from Category" )
jQuery('#slider-category').show();
else jQuery('#slider-category').hide();
//Show number of slides if that's the case
if ($sliderNr=="Latest Posts" || $sliderNr =="Random Posts" || $sliderNr =="Sticky Posts" || $sliderNr=="Latest Posts from Category" || $sliderNr=="Random Posts from Category" )
jQuery('#slider-post-number').show();
else jQuery('#slider-post-number').hide();
});//onchange funciton
// Create accordion from existing settings table
jQuery('.form-table').wrap('<div>');
jQuery(function() {
if (jQuery( "#accordion h2" ).length > 0) {
// wordpress 4.4+ changed headings to h2
jQuery( "#accordion" ).accordion({
header: 'h2',
heightStyle: "content",
collapsible: true,
navigation: true,
active: false
});
} else {
jQuery( "#accordion" ).accordion({
header: 'h3',
autoHeight: false, // for jQueryUI <1.10
heightStyle: "content", // required in jQueryUI 1.10
collapsible: true,
navigation: true,
active: false
});
}
});
if (vercomp(jQuery.ui.version,"1.9.0")) {
// tooltip function is included since jQuery UI 1.9.0
tooltip_terain();
startfarb("#mantra_backcolor","#mantra_backcolor2");
startfarb("#mantra_headercolor","#mantra_headercolor2");
startfarb("#mantra_contentbg","#mantra_contentbg2");
startfarb("#mantra_menubg","#mantra_menubg2");
startfarb("#mantra_s1bg","#mantra_s1bg2");
startfarb("#mantra_s2bg","#mantra_s2bg2");
startfarb("#mantra_prefootercolor","#mantra_prefootercolor2");
startfarb("#mantra_footercolor","#mantra_footercolor2");
startfarb("#mantra_titlecolor","#mantra_titlecolor2");
startfarb("#mantra_descriptioncolor","#mantra_descriptioncolor2");
startfarb("#mantra_contentcolor","#mantra_contentcolor2");
startfarb("#mantra_linkscolor","#mantra_linkscolor2");
startfarb("#mantra_hovercolor","#mantra_hovercolor2");
startfarb("#mantra_headtextcolor","#mantra_headtextcolor2");
startfarb("#mantra_headtexthover","#mantra_headtexthover2");
startfarb("#mantra_sideheadbackcolor","#mantra_sideheadbackcolor2");
startfarb("#mantra_sideheadtextcolor","#mantra_sideheadtextcolor2");
startfarb("#mantra_footerheader","#mantra_footerheader2");
startfarb("#mantra_footertext","#mantra_footertext2");
startfarb("#mantra_footerhover","#mantra_footerhover2");
startfarb("#mantra_fpsliderbordercolor","#mantra_fpsliderbordercolor2");
startfarb("#mantra_fronttitlecolor","#mantra_fronttitlecolor2");
} else {
jQuery("#mantra_backcolor").addClass('colorthingy');
jQuery("#mantra_headercolor").addClass('colorthingy');
jQuery("#mantra_contentbg").addClass('colorthingy');
jQuery("#mantra_menubg").addClass('colorthingy');
jQuery("#mantra_s1bg").addClass('colorthingy');
jQuery("#mantra_s2bg").addClass('colorthingy');
jQuery("#mantra_prefootercolor").addClass('colorthingy');
jQuery("#mantra_footercolor").addClass('colorthingy');
jQuery("#mantra_titlecolor").addClass('colorthingy');
jQuery("#mantra_descriptioncolor").addClass('colorthingy');
jQuery("#mantra_contentcolor").addClass('colorthingy');
jQuery("#mantra_linkscolor").addClass('colorthingy');
jQuery("#mantra_hovercolor").addClass('colorthingy');
jQuery("#mantra_headtextcolor").addClass('colorthingy');
jQuery("#mantra_sideheadbackcolor").addClass('colorthingy');
jQuery("#mantra_sideheadtextcolor").addClass('colorthingy');
jQuery("#mantra_footerheader").addClass('colorthingy');
jQuery("#mantra_footertext").addClass('colorthingy');
jQuery("#mantra_headtexthover").addClass('colorthingy');
jQuery("#mantra_footerhover").addClass('colorthingy');
jQuery("#mantra_fpsliderbordercolor").addClass('colorthingy');
jQuery("#mantra_fronttitlecolor").addClass('colorthingy');
jQuery('.colorthingy').each(function(){
id = "#"+jQuery(this).attr('id');
jQuery(this).on('keyup',function(){coloursel(this)});
coloursel(this);
});
// inform the user about the old partially unsupported version
jQuery("#jsAlert").after("<div class='updated fade' style='clear:left; font-size: 16px;'><p>Mantra has detected you are running an old version of Wordpress (jQuery) and will be running in compatibility mode. Some features may not work correctly. Consider updating your Wordpress to the latest version.</p></div>");
}
jQuery('#jsAlert').hide();
});// ready
function startfarb(a,b) {
jQuery(b).css('display','none');
jQuery(b).farbtastic(a);
jQuery(a).click(function() {
if(jQuery(b).css('display') == 'none') {
jQuery(b).parents('.ui-accordion-content').addClass('ui-accordion-content-overflow');
jQuery(b).css('display','inline-block').hide().show(300);
}
});
jQuery(document).mousedown( function() {
jQuery(b).hide(700, function(){ jQuery(b).parents('.ui-accordion-content').removeClass('ui-accordion-content-overflow'); });
// todo: find a better way to remove class after the fade on IEs
});
}
function tooltip_terain() {
jQuery('#accordion small').parent('div').append('<a class="tooltip"><img src="'+mantra_tooltip_icon_url+'" /></a>').each(function() {
var tooltip_info = jQuery(this).children('small').html();
jQuery(this).children('.tooltip').tooltip({content : tooltip_info});
jQuery(this).children('.tooltip').tooltip( "option", "items", "a" );
jQuery(this).children('.tooltip').tooltip( "option", "hide", "false");
jQuery(this).children('small').remove();
if (!jQuery(this).hasClass('slmini') && !jQuery(this).hasClass('slidercontent') && !jQuery(this).hasClass('slideDivs')) jQuery(this).addClass('tooltip_div');
});
}
function coloursel(el){
var id = "#"+jQuery(el).attr('id');
jQuery(id+"2").hide();
var bgcolor = jQuery(id).val();
if (bgcolor <= "#666666") { jQuery(id).css('color','#ffffff'); } else { jQuery(id).css('color','#000000'); };
jQuery(id).css('background-color',jQuery(id).val());
}
function vercomp(ver, req) {
var v = ver.split('.');
var q = req.split('.');
for (var i = 0; i < v.length; ++i) {
if (q.length == i) { return true; } // v is bigger
if (parseInt(v[i]) == parseInt(q[i])) { continue; } // nothing to do here, move along
else if (parseInt(v[i]) > parseInt(q[i])) { return true; } // v is bigger
else { return false; } // q is bigger
}
if (v.length != q.length) { return false; } // q is bigger
return true; // v = q;
}
// Change border for selected inputs
function changeBorder(idName, className) {
jQuery('.'+className).removeClass( 'checkedClass' );
jQuery('.'+className).removeClass( 'borderful' );
jQuery('#'+idName).addClass( 'borderful' );
return 0;
}
/* FB like button */
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/* Twitter follow button */
window.twttr = (function (d, s, id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src= "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function (f) { t._e.push(f) } });
}(document, "script", "twitter-wjs"));
/* FIN */
|