/* Eliminate JavaScript functionality provided by Blacklight */ Blacklight.do_zebra_stripe = function(){}; Blacklight.do_select_submit = function(){}; Blacklight.do_more_facets_behavior = function(){}; Blacklight.do_lightbox_dialog = function(){}; Blacklight.do_bookmark_toggle_behavior = function(){}; Blacklight.do_folder_toggle_behavior = function(){}; Blacklight.do_facet_expand_contract_behavior = function(){}; HydraHead = {validation: true, combinedEdit: true, autoSave: true}; // Load appropriate Hydra-Head functions when document is ready $(document).ready(function() { HydraHead.init(); }); // Define Hydra-Head methods for HydraHead object (function($) { /************************* * PUBLIC METHODS * *************************/ HydraHead.init = function() { if(this.combinedEdit){ this.add_asset_links(); } if(this.autoSave){ this.auto_save(); } this.enable_form_save(); this.add_keywords(); } // Take Javascript-enabled users to the combined view by // adding a parameter to necessary URLs. HydraHead.add_asset_links = function() { $('.create_asset, .edit-browse .edit, .document .document_title a').each(function() { var url = $(this).attr('href'); // Check to see if there are already URL encoded params before adding our new param $(this).attr('href', url + ((url).indexOf('?') != -1 ? "&combined=true" : "?combined=true")); }); }; // Enable Ajax save functionality on edit pages HydraHead.enable_form_save = function() { HydraHead.target = null; var all_forms = $('.document_edit form'); $('.document_edit input[type="submit"], .all-steps-actions button').click(function() { HydraHead.target = $(this); all_forms.first().submit(); return false; }); all_forms.submit(function(e) { // Only submit the forms if they pass validation // and validation is enabled. if(!HydraHead.validation || formValidation()){ formPreSave(); all_forms.each(function(index) { $(this).ajaxSubmit(); }); formPostSave(); } // Don't continue to submit or we'll loop infinitely return false; }); }; HydraHead.add_keywords = function() { $('.fedora-text-field-add a').click(function() { var keyword_count = $(this).parent().siblings('.fedora-text-field').length; $(this).parent().before( '
' + '' + '' + '
'); return false; }); } // When an input changes (using blur for IE consistency), // submit the containing form. HydraHead.auto_save = function() { $('.document_edit input, .document_edit textarea, .document_edit select').blur(function() { $(this).closest('form').ajaxSubmit(); }); }; /************************* * PRIVATE METHODS * *************************/ // Display a saving notice and spinner that takes up the whole screen. formPreSave = function() { var opts = { lines: 12, // The number of lines to draw length: 14, // The length of each line width: 4, // The line thickness radius: 12, // The radius of the inner circle color: '#000', // #rbg or #rrggbb speed: 0.5, // Rounds per second trail: 50, // Afterglow percentage shadow: false // Whether to render a shadow }; $('#document').prepend('