{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+g+óRI" length;TiŸI" digest;TI"%232f6701108b650b77562d8c5b68d57e;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}); // Handle weighting the pages and their children. updateWeightsAndRelationships($('#nested-pages')); }); function updateWeightsAndRelationships(selector){ $.each(selector, function() { $(this).on('change',function(){ var data = $(this).nestable('serialize') var weight = 0; for(var i in data){ var parent_id = data[i]['id']; parent_node = findNode(parent_id) 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); setWeight(child_node, weight++); setParent(child_node, parent_id); } } else { setParent(parent_node, ""); } } }); }); } function findNode(id) { return $("[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"%323f9b997dcd2225736ae03969fde5b7;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-05T22:27:51-08:00;TI" digest;TI"%2713531af926f97323bf3e1486c0a663;FI" _version;TI"%ad5851230fbdd4f8a862674697158df2;F