diff --git a/jquery_loadinganimation.install b/jquery_loadinganimation.install index c353eadf3e8a281af6cedbaff7cfb231a69ff74f..39837ff3e8a9d85fdc87245b1d7123c850a4bcd2 100644 --- a/jquery_loadinganimation.install +++ b/jquery_loadinganimation.install @@ -11,6 +11,8 @@ function jquery_loadinganimation_install() { // Set general settings. variable_set('jquery_loadinganimation_show_on_ajax', TRUE); + variable_set('jquery_loadinganimation_show_on_href', TRUE); + variable_set('jquery_loadinganimation_show_on_form_submit', TRUE); } /** @@ -20,5 +22,7 @@ function jquery_loadinganimation_uninstall() { // Remove the general settings. variable_del('jquery_loadinganimation_img_src'); variable_del('jquery_loadinganimation_show_on_ajax'); + variable_del('jquery_loadinganimation_show_on_href'); + variable_del('jquery_loadinganimation_show_on_form_submit'); variable_del('jquery_loadinganimation_subselector'); } \ No newline at end of file diff --git a/jquery_loadinganimation.js b/jquery_loadinganimation.js index 67895967a17095def4d353452417deeeb404e17a..601daac975003c73f2752cd0e57f5dc753ee9f46 100644 --- a/jquery_loadinganimation.js +++ b/jquery_loadinganimation.js @@ -12,42 +12,46 @@ } else { var subselectorSuffix = ''; } - $(context).find("a[href]" + settings.subselector).not( - "a[href=javascript:;]").not("a[href=#]").not(".noLoadingAnimation").each( - function(i, element) { - // Nur Elemente, die keine JS-Events haben (TODO: Nur - // click-events beachten) - if (typeof $(element).data("events") == 'undefined' - || $(element).data("events").length == 0) { - $(element).click(function(eventObject) { - // Nicht bei Öffnen in neuem Tab (Strg+Klick) - if (!eventObject.ctrlKey) { - Loadinganimation.show(); - } - }); - } - }); + if (Drupal.settings.jquery_loadinganimation.show_on_href) { + $(context).find("a[href]" + settings.subselector).not( + "a[href=javascript:;]").not("a[href=#]").not(".noLoadingAnimation").each( + function(i, element) { + // Nur Elemente, die keine JS-Events haben (TODO: Nur + // click-events beachten) + if (typeof $(element).data("events") == 'undefined' + || $(element).data("events").length == 0) { + $(element).click(function(eventObject) { + // Nicht bei Öffnen in neuem Tab (Strg+Klick) + if (!eventObject.ctrlKey) { + Loadinganimation.show(); + } + }); + } + }); + } - // Bei Formularversand auch ausfuehren, wenn keine anderen Events - // registriert sind. - $(context).find("form" + subselectorSuffix).submit( - function() { - if (typeof $(this).data("events") == 'undefined' - || $(this).data("events").length == 0 - ) { - Loadinganimation.show(); - } else { - var show=true; - jQuery.each($(this).data("events"), function(index, element){ - if(element.type != undefined){ - show = false; - } - }); - if(show){ + if (Drupal.settings.jquery_loadinganimation.show_on_form_submit) { + // Bei Formularversand auch ausfuehren, wenn keine anderen Events + // registriert sind. + $(context).find("form" + subselectorSuffix).submit( + function() { + if (typeof $(this).data("events") == 'undefined' + || $(this).data("events").length == 0 + ) { Loadinganimation.show(); + } else { + var show=true; + jQuery.each($(this).data("events"), function(index, element){ + if(element.type != undefined){ + show = false; + } + }); + if(show){ + Loadinganimation.show(); + } } - } - }); + }); + } // Bei Klick auf die Animation ausblenden $("div#loadinganimation").click(function() { diff --git a/jquery_loadinganimation.module b/jquery_loadinganimation.module index 3c9cedbb2d719cf10bd39c35f3f6c5c18a32dd81..5e6ed6da7133bf838f4a508e78c292bb4e0beadc 100644 --- a/jquery_loadinganimation.module +++ b/jquery_loadinganimation.module @@ -52,5 +52,7 @@ function _jquery_loadinganimation_get_settings() { 'module_path' => $module_path, 'img_src' => variable_get('jquery_loadinganimation_img_src', $module_path . '/images/ajax-loader.gif'), 'show_on_ajax' => variable_get('jquery_loadinganimation_show_on_ajax', TRUE), + 'show_on_href' => variable_get('jquery_loadinganimation_show_on_href', TRUE), + 'show_on_form_submit' => variable_get('jquery_loadinganimation_show_on_form_submit', TRUE), 'subselector' => variable_get('jquery_loadinganimation_subselector', '')); } \ No newline at end of file