[Commits] r291 - in apps/opengeo/geoexplorer/trunk: . lib
commits at geoext.org
commits at geoext.org
Sun Mar 29 23:09:13 CEST 2009
Author: tschaub
Date: 2009-03-29 23:09:12 +0200 (Sun, 29 Mar 2009)
New Revision: 291
Added:
apps/opengeo/geoexplorer/trunk/lib/Viewer.js
Removed:
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer/
Modified:
apps/opengeo/geoexplorer/trunk/debug.html
apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
Log:
basic viewer constructor
Modified: apps/opengeo/geoexplorer/trunk/debug.html
===================================================================
--- apps/opengeo/geoexplorer/trunk/debug.html 2009-03-28 14:40:51 UTC (rev 290)
+++ apps/opengeo/geoexplorer/trunk/debug.html 2009-03-29 21:09:12 UTC (rev 291)
@@ -16,6 +16,7 @@
<script type="text/javascript" src="externals/geoext/lib/GeoExt.js"></script>
<!-- GeoExplorer resources -->
+ <script type="text/javascript" src="lib/Viewer.js"></script>
<script type="text/javascript" src="lib/GeoExplorer.js"></script>
<script type="text/javascript" src="lib/GeoExplorer/dispatch.js"></script>
Modified: apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-03-28 14:40:51 UTC (rev 290)
+++ apps/opengeo/geoexplorer/trunk/lib/GeoExplorer.js 2009-03-29 21:09:12 UTC (rev 291)
@@ -1,5 +1,7 @@
/**
* Copyright (c) 2008 The Open Planning Project
+ *
+ * @requires Viewer.js
*/
/**
@@ -24,27 +26,10 @@
* queryable - {Boolean} Layer may be queried (with GetFeatureInfo)
*
* Extends:
- * - Ext.util.Observable
+ * - Viewer
*/
-var GeoExplorer = function(config) {
+var GeoExplorer = Ext.extend(Viewer, {
- this.initialConfig = Ext.apply({}, config);
-
- // add any custom application events
- this.addEvents(
- /**
- * Event: ready
- * Fires when the entire application is ready.
- */
- "ready"
- );
-
- this.load();
-
-};
-
-Ext.extend(GeoExplorer, Ext.util.Observable, {
-
/**
* Property: map
* {OpenLayers.Map} The application's map.
@@ -64,21 +49,7 @@
* prepares the application for use.
*/
load: function() {
- GeoExplorer.dispatch(
- [
- function(done) {
- Ext.onReady(function() {
- this.createLayout();
- done();
- }, this);
- }
- // other functions to be executed in parallel can go here
- ], function() {
- // executed when all of the above are done
- this.fireEvent("ready");
- },
- this // scope for all above functions
- );
+ Ext.onReady(this.createLayout, this);
},
/**
Added: apps/opengeo/geoexplorer/trunk/lib/Viewer.js
===================================================================
--- apps/opengeo/geoexplorer/trunk/lib/Viewer.js (rev 0)
+++ apps/opengeo/geoexplorer/trunk/lib/Viewer.js 2009-03-29 21:09:12 UTC (rev 291)
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2008 The Open Planning Project
+ */
+
+/**
+ * Constructor: Viewer
+ * Create a new Viewer application.
+ *
+ * Parameters:
+ * config - {Object} Optional application configuration properties.
+ *
+ * Extends:
+ * - Ext.util.Observable
+ */
+var Viewer = Ext.extend(Ext.util.Observable, {
+
+ /**
+ * Constructor: Viewer
+ */
+ constructor: function(config) {
+
+ this.initialConfig = Ext.apply({}, config);
+ Ext.apply(this, config);
+
+ // add any custom application events
+ this.addEvents(
+ /**
+ * Event: afterlayout
+ * Fires when the layout has been rendered.
+ */
+ "afterlayout"
+ );
+
+ this.load();
+
+ },
+
+ /**
+ * Method: load
+ * Called to load the application. Implemented by a subclass.
+ */
+ load: Ext.emptyFn,
+
+ /**
+ * Method: dispatch
+ * Allows multiple asynchronous sequences to be called in parallel. A final
+ * callback is called when all other sequences report that they are done.
+ *
+ * Parameters:
+ * functions - {Array(Function)} List of functions to be called. All
+ * functions will be called with two arguments - a callback to call when
+ * the sequence is done and a storage object
+ * complete - {Function} A function that will be called when all other
+ * functions report that they are done. The final callback will be
+ * called with the storage object passed to all other functions.
+ * scope - {Object} Optional object to be set as the scope of all functions
+ * called.
+ */
+ dispatch: function(functions, complete, scope) {
+ complete = complete || Ext.emptyFn;
+ scope = scope || this;
+ var requests = functions.length;
+ var responses = 0;
+ var storage = {};
+ function respond() {
+ ++responses;
+ if(responses === requests) {
+ complete.call(scope, storage);
+ }
+ }
+ function trigger(index) {
+ window.setTimeout(function() {
+ functions[index].apply(scope, [respond, storage]);
+ });
+ }
+ for(var i=0; i<requests; ++i) {
+ trigger(i);
+ }
+ }
+
+});
\ No newline at end of file
More information about the Commits
mailing list