// Custom jQuery for theme

// Script to toggle copyright popup
$( "button" ).click(function() {
    $( "#sugarcopy" ).toggle();

});

// Custom JavaScript for copyright pop-ups
$(function() {
    $( "#dialog, #dialog2" ).dialog({
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 100
        },
        hide: {
            effect: "fade",
            duration: 1000
        }
    });
    $( "#powered_by" ).click(function() {
        $( "#dialog" ).dialog( "open" );
        $("#overlay").show().css({"opacity": "0.5"});
    });
    $( "#admin_options" ).click(function() {
        $( "#dialog2" ).dialog( "open" );
    });
});

// Back to top animation
$('#backtotop').click(function(event) {
    event.preventDefault();
    $('html, body').animate({scrollTop:0}, 500); // Scroll speed to the top
});

// Refresh function for refresh button on sidebar
function refresh(reload)
{
    window.location.reload(true);
}

// Tabs jQuery for Admin panel
$(function() {
    var tabs = $( "#tabs" ).tabs();
    tabs.find( ".ui-tabs-nav" ).sortable({
        axis: "x",
        stop: function() {
            tabs.tabs( "refresh" );
        }
    });
});

var checkContents = setInterval(function(){
    if ($(".list.view").length > 0){ // Check if element has been found
        $('#dashletPanel th:not(:first-child)').attr("data-hide","phone, tablet");
        $('#subPanel th:not(:first-child)').attr("data-hide","phone, tablet");
//        $('.footable').footable();
        $('.list.view').footable();
        $(".footable").find("th:first").attr("data-toggle","true");
        console.log("called");
        clearInterval(checkContents);
    }
},1);

// JavaScript fix to remove unrequired classes on smaller screens where sidebar is obsolete
$(window).resize(function () {
    if ($(window).width() < 979) {
        $('#bootstrap-container').removeClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 sidebar main');
    }
    if ($(window).width() > 980 && $('.sidebar').is(':visible')) {
        $('#bootstrap-container').addClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main');
    }
});

// Button to toggle list view search
$('.showsearch').click(function() {
    $('.search_form').toggle();
});

// jQuery to toggle sidebar

$('#buttontoggle').click(function(){
    $('.sidebar').toggle();
    if ($('.sidebar').is(':visible')){
        $.cookie('sidebartoggle', 'expanded');
        $('#bootstrap-container').addClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2');
        $('#buttontoggle').css({
            'left' : "+=215px"
        });
    }
    if ($('.sidebar').is(':hidden')){
        $.cookie('sidebartoggle', 'collapsed');
        $('#bootstrap-container').removeClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 col-sm-3 col-md-2 sidebar');
        $('#buttontoggle').css({
            'left' : "-=215px"
        });
    }
    console.log($.cookie('sidebartoggle'));
});
var sidebartoggle = $.cookie('sidebartoggle');
if (sidebartoggle == 'collapsed'){
    $('.sidebar').hide();
    $('#bootstrap-container').removeClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 col-sm-3 col-md-2 sidebar');
    $('#buttontoggle').css({
        'left' : "-=215px"
    });
}
if (sidebartoggle == 'expanded'){
    $('#bootstrap-container').addClass('col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2');

}

// End of custom jQuery
@@ -1259,16 +1259,46 @@
 length %3E
+ 0 %7C%7C $(%22.list.View%22).length %3E
  0)%7B // 
@@ -1329,16 +1329,194 @@
 n found%0A
+%0A       if($(%22.list.view%22).length %3E 0)%7B%0A           element = $(%22.list.view%22);%0A       %7D%0A%0A        if($(%22.list.View%22).length %3E 0)%7B%0A            element = $(%22.list.View%22);%0A        %7D%0A%0A
         
@@ -1669,18 +1669,16 @@
 blet%22);%0A
-//
         
@@ -1683,55 +1683,15 @@
   $(
-'.footable').footable();%0A        $('.list.view'
+element
 ).fo

Fix to load footables on global search.