Mercurial > hg > ChinaGisRestApi
comparison gis_gui/lib/blocks.js @ 68:49fb47bbe2e6
saving and loading maps
author | casties |
---|---|
date | Mon, 22 Nov 2010 17:16:23 +0100 |
parents | 2f477270cc0c |
children | 825a92d0ab10 |
comparison
equal
deleted
inserted
replaced
67:b6aa7b77d110 | 68:49fb47bbe2e6 |
---|---|
9 }; | 9 }; |
10 } | 10 } |
11 | 11 |
12 function defined(x) { | 12 function defined(x) { |
13 // returns if x is defined | 13 // returns if x is defined |
14 return (typeof arguments[0] != "undefined"); | 14 return (typeof arguments[0] !== "undefined"); |
15 } | 15 } |
16 | 16 |
17 /* | 17 /* |
18 * guiBlocks base | 18 * guiBlocks base |
19 */ | 19 */ |
36 return this; | 36 return this; |
37 }; | 37 }; |
38 | 38 |
39 // create a new block and add it to the current workspaces stack | 39 // create a new block and add it to the current workspaces stack |
40 guiBlocks.prototype.addBlock = function(url, baseId, params, whenDone) { | 40 guiBlocks.prototype.addBlock = function(url, baseId, params, whenDone) { |
41 // old version compatibility | |
42 if (typeof(params) == "function") { | |
43 whenDone = params; | |
44 } | |
45 // add title to url | 41 // add title to url |
46 var newblock = $("<div>Block loading...</div>"); | 42 var newblock = $("<div>Block loading...</div>"); |
47 var newid=baseId+"_"+randomString(); | 43 var newid = baseId+"_"+randomString(); |
48 var container = this.containerElement; | 44 var container = this.containerElement; |
49 console.debug("addblock newid="+newid); | 45 console.debug("addblock newid="+newid); |
50 newblock.hide(); | 46 newblock.hide(); |
51 newblock.load(url, function() { | 47 newblock.load(url, function() { |
52 // after load function | 48 // after load function |
65 | 61 |
66 }); | 62 }); |
67 // create new Block object | 63 // create new Block object |
68 var block = new guiBlocks.Block(newid, newblock); | 64 var block = new guiBlocks.Block(newid, newblock); |
69 // add parameters | 65 // add parameters |
70 if (typeof(params) != "object") { | 66 if (params == null) { |
71 // create new params | 67 // create new params |
72 params = {"id": newid}; | 68 params = {"id": newid}; |
73 } else if (typeof(params.id) == "undefined") { | |
74 // must be new block (with params) | |
75 params.id = newid; | |
76 } | 69 } |
77 block.params = params; | 70 block.params = params; |
78 // add to list of blocks | 71 // add to list of blocks |
79 this.blocks.push(block); | 72 this.blocks.push(block); |
80 return block; | 73 return block; |