/** * Prints out the inline javascript needed for the colorpicker and choosing * the tabs in the panel. */ jQuery(document).ready(function($) { $("#bu_custom_logo").change(function() { var toShow = $("#section-bu_logo"); if($(this).is(':checked')) { toShow.show(); } else { toShow.hide(); } }).change(); $("#bu_favicon_toggle").change(function() { var toShow = $("#section-bu_favicon"); if($(this).is(':checked')) { toShow.show(); } else { toShow.hide(); } }).change(); $("#bu_apple_touch_toggle").change(function() { var toShow = $("#section-bu_apple_touch"); if($(this).is(':checked')) { toShow.show(); } else { toShow.hide(); } }).change(); $("#bu_show_excerpts").change(function() { var toShow = $("#section-bu_excerpt_link_text, #section-bu_excerpt_length"); if($(this).is(':checked')) { toShow.show(); } else { toShow.hide(); } }).change(); $.each(['twitter', 'facebook', 'gplus', 'flickr', 'linkedin', 'pinterest', 'youtube', 'googlemaps', 'email', 'rsslink'], function(i, val) { $("#section-bu_" + val).each(function(){ var $this = $(this), $next = $(this).next(); $this.find(".controls").css({float: 'left', clear: 'both'}); $next.find(".controls").css({float: 'right', width: 80}); $next.hide(); $this.find('.option').before($next.find(".option")); $this.find("input[type='checkbox']").change(function() { if($(this).is(":checked")) { $(this).closest('.option').next().show(); } else { $(this).closest('.option').next().hide(); } }).change(); }); }); }); jQuery(function($) { var initialize = function(id) { var el = $("#" + id); function update(base) { var hidden = base.find("input[type='hidden']"); var val = []; base.find('.right_list .list_items span').each(function() { val.push($(this).data('key')); }); hidden.val(val.join(",")).change(); el.find('.right_list .action').show(); el.find('.left_list .action').hide(); } el.find(".left_list .list_items").delegate(".action", "click", function() { var item = $(this).closest('.list_item'); $(this).closest('.section_order').children('.right_list').children('.list_items').append(item); update($(this).closest(".section_order")); }); el.find(".right_list .list_items").delegate(".action", "click", function() { var item = $(this).closest('.list_item'); $(this).val('Add'); $(this).closest('.section_order').children('.left_list').children('.list_items').append(item); $(this).hide(); update($(this).closest(".section_order")); }); el.find(".right_list .list_items").sortable({ update: function() { update($(this).closest(".section_order")); }, connectWith: '#' + id + ' .left_list .list_items' }); el.find(".left_list .list_items").sortable({ connectWith: '#' + id + ' .right_list .list_items' }); update(el); } $('.section_order').each(function() { initialize($(this).attr('id')); }); $("input[name='business[bu_blog_section_order]']").change(function(){ var show = $(this).val().split(","); var map = { business_page_slider: "subsection-featureslider", business_callout_section: "subsection-calloutoptions" // , business_box_section: "" }; $.each(map, function(key, value) { $("#" + value).hide(); $.each(show, function(i, show_key) { if(key == show_key) $("#" + value).show(); }); }); }).trigger('change'); $("input[name='business[bu_front_section_order]']").change(function(){ var show = $(this).val().split(","); var map = { business_page_slider: "subsection-slider", business_callout_section: "subsection-callout" // , business_box_section: "" }; $.each(map, function(key, value) { $("#" + value).hide(); $.each(show, function(i, show_key) { if(key == show_key) $("#" + value).show(); }); }); }).trigger('change'); $("input[name='business[header_section_order]']").change(function(){ var show = $(this).val().split(","); var map = { business_sitename_contact: "section-bu_header_contact", business_description_icons: "subsection-social" // , business_box_section: "" }; $.each(map, function(key, value) { $("#" + value).hide(); $.each(show, function(i, show_key) { if(key == show_key) $("#" + value).show(); }); }); }).trigger('change'); });