$(document).ready(function() { BigTreeCustomControls(); BigTreePageLoadHooks(); //BigTreeQuickLoader.init(); // !BigTree Quick Search $('nav.main form .qs_query').keyup(function(ev) { v = $(this).val(); if (v && ev.keyCode != 9) { //no tabs! $("#quick_search_results").load("admin_root/ajax/quick-search-results/", { query: v }, function() { $("#quick_search_results").show(); }); } else { $("#quick_search_results").hide().html(""); } }).focus(function() { $(this).addClass("focus"); }).blur(function() { setTimeout("$('nav.main form input[type=\"search\"]').removeClass(\"focus\").val(\"\"); $(\"#quick_search_results\").fadeOut(200, function() { $(this).html(\"\"); });", 300); }); $("nav.main").on("click",".advanced_search",function() { $("#quick_search_results").parents().submit(); return false; }); // Subnav extras menu $("#sub_nav menu").hover(function() { $(this).parent().addClass("dropdown_open"); },function() { $(this).parent().removeClass("dropdown_open"); }); // Growl Hooks $("#growl").on("click",".close",function() { $(this).parents("article").remove(); return false; }); }); function BigTreeCustomControls(selector) { if (selector) { // Setup custom checkboxes $(selector).find("input[type=checkbox]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeCheckbox(this); } }); // Setup custom select boxes $(selector).find("select:not([multiple])").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeSelect(this); } }); // Setup custom file boxes. $(selector).find("input[type=file]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeFileInput(this); } }); // Setup custom radio buttons. $(selector).find("input[type=radio]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeRadioButton(this); } }); } else { // Setup custom checkboxes $("input[type=checkbox]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeCheckbox(this); } }); // Setup custom select boxes $("select:not([multiple])").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeSelect(this); } }); // Setup custom file boxes. $("input[type=file]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeFileInput(this); } }); // Setup custom radio buttons. $("input[type=radio]").each(function() { if (!$(this).hasClass("custom_control") && $(this).css("display") != "none") { this.customControl = new BigTreeRadioButton(this); } }); } } function BigTreePageLoadHooks() { // !BigTree Link Finder $("#link_finder").keyup(function() { q = $(this).val(); if (q == "") { $("#link_finder_results").hide().html(""); } else { $("#link_finder_results").load("admin_root/ajax/link-finder/", { query: q }, function() { $("#link_finder_results").show().children("a").click(function() { return false; }); }); } }); // !BigTree Sticky Controls BigTree.stickyControls = $(".sticky_controls"); if (BigTree.stickyControls.length) { BigTree.stickyControlsTop = BigTree.stickyControls.offset().top; if (window.scrollY >= BigTree.stickyControlsTop && !BigTree.stickyControlsStuck) { BigTree.stickyControlsStuck = true; BigTree.stickyControls.addClass("stuck"); } $(window).scroll(function() { if (window.scrollY >= BigTree.stickyControlsTop && !BigTree.stickyControlsStuck) { BigTree.stickyControlsStuck = true; BigTree.stickyControls.addClass("stuck"); } if (window.scrollY < BigTree.stickyControlsTop && BigTree.stickyControlsStuck) { BigTree.stickyControlsStuck = false; BigTree.stickyControls.removeClass("stuck"); } }); } // Property Block Hide/Show $("h3.properties").click(function() { if ($(this).find(".icon_small").hasClass("icon_small_caret_right")) { // Set a cookie to keep it open next time. $.cookie("bigtree_admin[page_properties_open]","on", { expires: 365, path: "/" }); } else { $.cookie("bigtree_admin[page_properties_open]","", { path: "/" }); } $(this).find(".icon_small").toggleClass("icon_small_caret_right").toggleClass("icon_small_caret_down"); $(".property_block").toggle().next().toggle(); return false; }); $(".inset_block .hide").click(function() { id = $(this).attr("data-id"); $.cookie("bigtree_admin[ignore_view_description][" + id + "]","on", { expires: 365, path: "/" }); $(this).parent().hide(); }); // Tooltips $(".has_tooltip").each(function() { width = BigTree.WindowWidth(); offset = $(this).offset(); if (offset.left > (width / 2)) { position = "left"; } else { position = "right"; } new BigTreeToolTip($(this),$(this).attr("data-tooltip"),position,false,true); }); // Image views $(".image_list img").load(function() { w = $(this).width(); h = $(this).height(); if (w > h) { perc = 108 / w; h = perc * h; style = { margin: Math.floor((108 - h) / 2) + "px 0 0 0" }; } else { style = { margin: "0px" }; } $(this).css(style); }); BigTree.FormHooks(".container form"); } var BigTreePasswordInput = Class.extend({ Buffer: "", Element: false, FakeElement: false, Timer: false, init: function(element) { this.FakeElement = $('').attr("tabindex",$(element).attr("tabindex")); // Copy class name over this.FakeElement.get(0).className = $(element).get(0).className; this.Element = $(element).addClass("custom_control").removeClass("required"); this.Element.hide().after(this.FakeElement); this.FakeElement.on("blur",$.proxy(this.blur,this)) .on("focus",$.proxy(this.focus,this)) .on("change",$.proxy(this.change,this)); }, blur: function() { this.Buffer = this.FakeElement.val(); this.FakeElement.val(str_repeat("•",this.FakeElement.val().length)); }, change: function() { this.Element.val(this.FakeElement.val()); }, focus: function() { this.FakeElement.val(this.Buffer); } }); // !BigTreeCheckbox Class var BigTreeCheckbox = Class.extend({ Element: false, Link: false, init: function(element,text) { this.Element = $(element); if (this.Element.hasClass("custom_control")) { return false; } this.Element.addClass("custom_control"); div = $("