{I" class:ETI"ProcessedAsset;FI"logical_path;TI"spotlight/pages.js;FI" pathname;TI"V/Volumes/TempStorage/Projects/spotlight/app/assets/javascripts/spotlight/pages.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+ï‰SI" length;Ti I" digest;TI"%08958893d6026b45e2a67b5955591892;FI" source;TI" // Place all the behaviors and hooks related to the matching controller here. // All this logic will automatically be available in application.js. Spotlight.onLoad(function() { // Initialize Nestable for nested pages $('#nested-pages.about_page_admin').nestable({maxDepth: 1}); $('#nested-pages.feature_page_admin').nestable({maxDepth: 2, expandBtnHTML: "", collapseBtnHTML: ""}); $('#nested-pages.search_admin').nestable({maxDepth: 1}); $('.contacts_admin').nestable({maxDepth: 1}); // Handle weighting the pages and their children. updateWeightsAndRelationships($('#nested-pages')); updateWeightsAndRelationships($('.contacts_admin')); $.each($('.dd-handle'), function(k, el){ var height; if ($(el).next('.dd3-content').length > 0) { height = $(el).next('.dd3-content').outerHeight(); } else { height = $(el).closest(".dd-item").outerHeight(); } $(el).css('height', height); }); SirTrevor.EventBus.on('block:create:new', addTitleToSirTrevorBlock); SirTrevor.EventBus.on('block:create:existing', addTitleToSirTrevorBlock); }); function addTitleToSirTrevorBlock(block){ block.$inner.append("
" + block.title() + "
"); }; function updateWeightsAndRelationships(selector){ $.each(selector, function() { $(this).on('change', function(event){ // Scope to a container because we may have two orderable sections on the page (e.g. About page has pages and contacts) container = $(event.currentTarget); var data = $(this).nestable('serialize') var weight = 0; for(var i in data){ var parent_id = data[i]['id']; parent_node = findNode(parent_id, container); setWeight(parent_node, weight++); if(data[i]['children']){ var children = data[i]['children']; for(var child in children){ var id = children[child]['id'] child_node = findNode(id, container); setWeight(child_node, weight++); setParent(child_node, parent_id); } } else { setParent(parent_node, ""); } } }); }); } function findNode(id, container) { return container.find("[data-id="+id+"]"); } function setWeight(node, weight) { weight_field(node).val(weight); } function setParent(node, parent_id) { parent_page_field(node).val(parent_id); } /* find the input element with data-property="weight" that is nested under the given node */ function weight_field(node) { return find_property(node, "weight"); } /* find the input element with data-property="parent_page" that is nested under the given node */ function parent_page_field(node){ return find_property(node, "parent_page"); } function find_property(node, property) { return node.find("input[data-property=" + property + "]"); } ; ;TI"dependency_digest;TI"%f2821fa68724bed515a9318a960a9576;FI"required_paths;T[I"V/Volumes/TempStorage/Projects/spotlight/app/assets/javascripts/spotlight/pages.js;FI"dependency_paths;T[{I" path;TI"V/Volumes/TempStorage/Projects/spotlight/app/assets/javascripts/spotlight/pages.js;FI" mtime;TI"2014-02-20T15:04:15-08:00;TI" digest;TI"%a268dd7760e8b5634f5f9a44129565fd;FI" _version;TI"%1005ed9f20e25fb0a0599a7017dd0e6b;F