From 06a17da8f3e120dd36d0ccc893b0a2c095fee0cc Mon Sep 17 00:00:00 2001 From: William Panting Date: Fri, 27 Sep 2013 17:27:24 -0300 Subject: [PATCH] handling more user issues --- includes/ingest.form.inc | 7 ++++--- js/ingesting_object.js | 33 ++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 2d27905c..0b8546b2 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -696,10 +696,11 @@ function islandora_ingest_form_ingest_button(array &$form_state) { $islandora_path = drupal_get_path('module', 'islandora'); - drupal_add_js($islandora_path . '/js/spin/spin.min.js'); - drupal_add_js($islandora_path . '/js/ingesting_object.js'); - return array( + '#attached' => array('js' => array( + "$islandora_path/js/spin/spin.min.js", + "$islandora_path/js/ingesting_object.js", + )), '#type' => 'submit', '#name' => 'ingest', '#value' => t('Ingest'), diff --git a/js/ingesting_object.js b/js/ingesting_object.js index e55870d1..913e5be9 100755 --- a/js/ingesting_object.js +++ b/js/ingesting_object.js @@ -6,7 +6,7 @@ (function ($) { function islandora_start_ingest_feedback() { $('#islandora-ingest-form').after('
' + - Drupal.t('Please wait while the object is ingested.') + + Drupal.t('Please be patient while the the page loads.') + '
'); var opts = { @@ -29,19 +29,26 @@ }; var target = document.getElementById('islandora_is_working'); var spinner = new Spinner(opts).spin(target); + // Don't want to do this in Safari, can't submit after form errors. + if (!(navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1)) { + $('#edit-next').hide(); + $('#edit-prev').hide(); + } } - $(document).ready(function() { - // Safari is having issues with stalling JS execution that was preventing this from running. - if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { - $('#edit-next').mousedown(function() { - islandora_start_ingest_feedback() - }); - } - else { - $('#islandora-ingest-form').submit(function() { - islandora_start_ingest_feedback() - }); + Drupal.behaviors.islandoraIngestingObject = { + attach: function(context, settings) { + // Safari is having issues with stalling JS execution that was preventing this from running. + if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) { + $('#edit-next').one('mousedown', function() { + islandora_start_ingest_feedback() + }); + } + else { + $('#islandora-ingest-form').one('submit', function() { + islandora_start_ingest_feedback() + }); + } } - }); + }; })(jQuery);