Skip to content
Snippets Groups Projects
Commit c2c8c4bb authored by Julian Pustkuchen's avatar Julian Pustkuchen
Browse files

Added further admin options.

parent 451d5afe
Branches
Tags
No related merge requests found
......@@ -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
......@@ -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() {
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment