Permalink
Browse files

#884. Allow spinning loader to be toggled on off.

  • Loading branch information...
1 parent c75eee9 commit 06a23765ba9dfa46a2f8592ac94e19e4a5feea00 @signalpoint committed Dec 9, 2016
Showing with 20 additions and 10 deletions.
  1. +1 −0 app/default.settings.js
  2. +19 −10 src/dg.js
@@ -133,6 +133,7 @@ drupalgap.settings.exit_message = 'Exit ' + drupalgap.settings.title + '?';
// Loader Animations - http://demos.jquerymobile.com/1.4.0/loader/
drupalgap.settings.loader = {
+ enabled: true,
loading: {
text: 'Loading...',
textVisible: true,
View
@@ -1261,15 +1261,28 @@ function drupalgap_set_title(title) {
}
/**
+ * Returns true if the loader spinner is enabled, false otherwise. Defaults to true if no config for it is present.
+ * @returns {Boolean}
+ */
+function drupalgap_loader_enabled() {
+ return typeof drupalgap.settings.loader.enabled !== 'undefined' ?
+ drupalgap.settings.loader.enabled : true;
+}
+
+/**
+ * Toggle on or off the loader spinner, send true to turn it on, false to turn it off.
+ * @param {Boolean} enable
+ */
+function drupalgap_loader_enable(enable) {
+ drupalgap.settings.loader.enabled = enable;
+}
+
+/**
* Implements hook_services_preprocess().
* @param {Object} options
*/
function drupalgap_services_preprocess(options) {
- try {
- // Show the loading icon.
- drupalgap_loading_message_show();
- }
- catch (error) { console.log('drupalgap_services_preprocess - ' + error); }
+ if (drupalgap_loader_enabled()) { drupalgap_loading_message_show(); }
}
/**
@@ -1278,11 +1291,7 @@ function drupalgap_services_preprocess(options) {
* @param {Object} result
*/
function drupalgap_services_postprocess(options, result) {
- try {
- // Hide the loading icon.
- drupalgap_loading_message_hide();
- }
- catch (error) { console.log('drupalgap_services_postprocess - ' + error); }
+ if (drupalgap_loader_enabled()) { drupalgap_loading_message_hide(); }
}
/**

0 comments on commit 06a2376

Please sign in to comment.