From 37f64f4025f65e6d91c3ee76a6483fa83aca4efe Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 31 Jul 2013 19:30:21 -0300 Subject: Implementing block/unblock with a list of block requests --- gmap_arcgis.js | 59 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 11be1c5..315fa08 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -24,6 +24,7 @@ function gmapArcgis(config) { } } + // TODO: needs debug and fixing // Return a Gmap ArcGIS object return { // Storable properties @@ -31,17 +32,43 @@ function gmapArcgis(config) { map: (config.map != undefined) ? config.map : null, // UI unblocker wrapper - unblockUI: function() { - jQuery.unblockUI(); + unblockUI: function(name) { + if (window.blockUI == undefined) { + window.blockUI = [ ]; + } + + if (name == undefined) { + name = 'default'; + } + + if (window.blockUI[name] != undefined && window.blockUI[name] == true) { + var index = window.blockUI.indexOf(name); + window.blockUI = window.blockUI.splice(index, 1); + } + + if (window.blockUI.length == 0) { + jQuery.unblockUI(); + } }, // UI blocker wrapper blockUI: function(params) { - jQuery.blockUI(params); + if (window.blockUI == undefined) { + window.blockUI = [ ]; + } + + if (params.name == undefined) { + params.name = 'default'; + } + + if (window.blockUI[params.name] == undefined || window.blockUI[params.name] != true) { + window.blockUI[params.name] = true; + jQuery.blockUI(params); + } }, // Block the UI and show an overlay - showOverlay: function(t) { + showOverlay: function(name, timeout) { if (this.config.disableOverlay != undefined && this.config.disableOverlay == true) { return; } @@ -57,14 +84,13 @@ function gmapArcgis(config) { } var params = { + name: name, message: message, css: css, - onUnblock: this.unBlockUI, - ignoreIfBlocked: true, }; - if (t != false) { - params.timeout = t; + if (timeout != false) { + params.timeout = timeout; } this.blockUI(params); @@ -77,7 +103,7 @@ function gmapArcgis(config) { this.showOverlay(this.config[section][element].overlayTime); } else if (this.config[section][element].overlayTime != false) { - this.showOverlay(); + this.showOverlay(section + '_' + element); } }, @@ -128,12 +154,14 @@ function gmapArcgis(config) { if (params.callback == undefined) { // Default callback: remove the blockUI once the layer is shown google.maps.event.addListener(params.overlay, 'drawend', function() { + // TODO self.unblockUI(); }); } else { google.maps.event.addListener(params.overlay, 'drawend', function() { params.callback(this.map, params); + // TODO self.unblockUI(); }); } @@ -210,7 +238,7 @@ function gmapArcgis(config) { this.config['kmls'][element].overlay.setMap(this.map); this.config['kmls'][element].isVisible = true; - this.unblockUI(); + this.unblockUI('kmls_' + element); }, // Add a KML layer into the map @@ -243,7 +271,7 @@ function gmapArcgis(config) { } } - this.unblockUI(); + this.unblockUI('layers_' + element); return; } @@ -258,7 +286,7 @@ function gmapArcgis(config) { if (typeof this.config['sliders'][slider].overlays[layer] != 'undefined') { this.config['sliders'][slider].overlays[layer].setOpacity(this.config['sliders'][slider].opacity); - this.unblockUI(); + this.unblockUI('sliders_' + slider); } this.showOverlayIf('sliders', slider); @@ -342,7 +370,7 @@ function gmapArcgis(config) { self.config['markers'][element].overlay[i].addListener(); } - self.unblockUI(); + self.unblockUI('markers_' + element); } }, @@ -576,6 +604,7 @@ function gmapArcgis(config) { self.setCenter(center, true); } + // TODO self.unblockUI(); return params.overlay; }); @@ -619,7 +648,7 @@ function gmapArcgis(config) { addPanoramio: function() { if (this.config.panoramio.panoramioLayer == undefined) { var self = this; - this.showOverlay(); + this.showOverlay('panoramio'); var photoDiv = document.createElement('div'); var photoWidgetOptions = this.config.panoramio.photoWidgetOptions; @@ -663,7 +692,7 @@ function gmapArcgis(config) { } } - this.unblockUI(); + this.unblockUI('panoramio'); }, // Set the current map center, optionally updating the map -- cgit v1.2.3