/**
* SMOF js
*
* contains the core functionalities to be used
* inside SMOF
*/
jQuery.noConflict();
/** Fire up jQuery - let's dance!
*/
jQuery(document).ready(function($){
var $ofContainer = $('#of_container');
//(un)fold options in a checkbox-group
jQuery('.fld').click(function() {
var $fold='.f_'+this.id;
$($fold).slideToggle('normal', "swing");
});
//Color picker
$('.of-color').wpColorPicker();
//hides warning if js is enabled
$('#js-warning').hide();
//Tabify Options
$('.group').hide();
// Get the URL parameter for tab
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,''])[1]
);
}
// If the $_GET param of tab is set, use that for the tab that should be open
if (getURLParameter('tab') != "") {
$.cookie('of_current_opt', '#'+getURLParameter('tab'), { expires: 7, path: '/' });
}
// Display last current tab
if ($.cookie("of_current_opt") === null) {
$('.group:first').fadeIn('fast');
$('#of-nav li:first').addClass('current');
} else {
var hooks = $('#hooks').html();
hooks = jQuery.parseJSON(hooks);
$.each(hooks, function(key, value) {
if ($.cookie("of_current_opt") == '#of-option-'+ value) {
$('.group#of-option-' + value).fadeIn();
$('#of-nav li.' + value).addClass('current');
}
});
}
//Current Menu Class
$('#of-nav li a').click(function(evt){
// event.preventDefault();
$('#of-nav li').removeClass('current');
$(this).parent().addClass('current');
var clicked_group = $(this).attr('href');
$.cookie('of_current_opt', clicked_group, { expires: 7, path: '/' });
$('.group').hide();
$(clicked_group).fadeIn('fast');
return false;
});
//Masked Inputs (images as radio buttons)
$('.of-radio-img-img').click(function(){
$(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
$(this).addClass('of-radio-img-selected');
});
$('.of-radio-img-label').hide();
$('.of-radio-img-img').show();
$('.of-radio-img-radio').hide();
//Masked Inputs (background images as radio buttons)
$('.of-radio-tile-img').click(function(){
$(this).parent().parent().find('.of-radio-tile-img').removeClass('of-radio-tile-selected');
$(this).addClass('of-radio-tile-selected');
});
$('.of-radio-tile-label').hide();
$('.of-radio-tile-img').show();
$('.of-radio-tile-radio').hide();
/** Aquagraphite Slider MOD */
//Hide (Collapse) the toggle containers on load
$(".slide_body").hide();
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$ofContainer.on('click', '.slide_edit_button', function () {
/*
//display as an accordion
$(".slide_header").removeClass("active");
$(".slide_body").slideUp("fast");
*/
//toggle for each
$(this).parent().toggleClass("active").next().slideToggle("fast");
return false; //Prevent the browser jump to the link anchor
});
// Update slide title upon typing
function update_slider_title(e) {
var element = e;
if ( this.timer ) {
clearTimeout( element.timer );
}
this.timer = setTimeout( function() {
$(element).parent().prev().find('strong').text( element.value );
}, 100);
return true;
}
$ofContainer.on('keyup', '.of-slider-title', function () {
update_slider_title(this);
});
//Remove individual slide
$ofContainer.on('click', '.slide_delete_button', function () {
// event.preventDefault();
var agree = confirm("Are you sure you wish to delete this slide?");
if (agree) {
var $trash = $(this).parents('li');
//$trash.slideUp('slow', function(){ $trash.remove(); }); //chrome + confirm bug made slideUp not working...
$trash.animate({
opacity: 0.25,
height: 0,
}, 500, function() {
$(this).remove();
});
return false; //Prevent the browser jump to the link anchor
} else {
return false;
}
});
//Add new slide
$ofContainer.on('click', '.slide_add_button', function () {
var slidesContainer = $(this).prev();
var sliderId = slidesContainer.attr('id');
var numArr = $('#'+sliderId +' li').find('.order').map(function() {
var str = this.id;
str = str.replace(/\D/g,'');
str = parseFloat(str);
return str;
}).get();
var maxNum = Math.max.apply(Math, numArr);
if (maxNum < 1 ) { maxNum = 0};
var newNum = maxNum + 1;
var newSlide = '