comparison gis_gui/lib/blocks.js @ 65:2f477270cc0c

adding layers to maps works now
author casties
date Tue, 09 Nov 2010 20:49:36 +0100
parents 7f008e782563
children 49fb47bbe2e6
comparison
equal deleted inserted replaced
64:3f6e32265c53 65:2f477270cc0c
3 */ 3 */
4 if (typeof(console) == 'undefined') { 4 if (typeof(console) == 'undefined') {
5 console = { 5 console = {
6 log : function(){}, 6 log : function(){},
7 debug : function(){}, 7 debug : function(){},
8 error : function(){}, 8 error : function(){}
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");
30 */ 30 */
31 guiBlocks.Block = function(id, element) { 31 guiBlocks.Block = function(id, element) {
32 this.id = id; // the blocks html id 32 this.id = id; // the blocks html id
33 this.element = element; // the html dom element 33 this.element = element; // the html dom element
34 this.storeId = null; // the id in online storage 34 this.storeId = null; // the id in online storage
35 this.params = new Object(); // parameters to store 35 this.params = {}; // parameters to store
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) {
59 // chain whenDone 59 // chain whenDone
60 whenDone(); 60 whenDone();
61 } else { 61 } else {
62 // default after load function 62 // default after load function
63 $(this).fadeIn(); 63 $(this).fadeIn();
64 }; 64 }
65 65
66 }); 66 });
67 // create new Block object 67 // create new Block object
68 var block = new guiBlocks.Block(newid, newblock); 68 var block = new guiBlocks.Block(newid, newblock);
69 // add parameters 69 // add parameters
76 } 76 }
77 block.params = params; 77 block.params = params;
78 // add to list of blocks 78 // add to list of blocks
79 this.blocks.push(block); 79 this.blocks.push(block);
80 return block; 80 return block;
81 } 81 };
82 82
83 guiBlocks.prototype.getBlock = function(id) { 83 guiBlocks.prototype.getBlock = function(id) {
84 for (b in this.blocks) { 84 for (b in this.blocks) {
85 if (b.id == id) { 85 if (b.id == id) {
86 return b; 86 return b;
87 } 87 }
88 } 88 }
89 return null; 89 return null;
90 } 90 };
91 91
92 /* 92 /*
93 guiBlocks.prototype.getStoreItem = function(tag,type,item) { 93 guiBlocks.prototype.getStoreItem = function(tag,type,item) {
94 // get item from online storage 94 // get item from online storage
95 jQuery.get(); 95 jQuery.get();
98 98
99 guiBlocks.prototype.loadListOfItems = function(storeTag,storeType,callback) { 99 guiBlocks.prototype.loadListOfItems = function(storeTag,storeType,callback) {
100 // loads list of id and type objects and executes callback function 100 // loads list of id and type objects and executes callback function
101 var url = "../db/RESTjson/db/public/gui_objects/"+escape(storeTag)+"/"+storeType+"?recursive=true"; 101 var url = "../db/RESTjson/db/public/gui_objects/"+escape(storeTag)+"/"+storeType+"?recursive=true";
102 jQuery.getJSON(url,callback); 102 jQuery.getJSON(url,callback);
103 } 103 };
104 104
105 105
106 guiBlocks.Block.prototype.storeBlock = function(storeTag) { 106 guiBlocks.Block.prototype.storeBlock = function(storeTag) {
107 var storeType = this.params.type; 107 var storeType = this.params.type;
108 var storeItem = this.params.id; 108 var storeItem = this.params.id;
158 }); 158 });
159 159
160 // TitleBar Close 160 // TitleBar Close
161 $("div.block div.titlebar div.close_button").live("click", function(e){ 161 $("div.block div.titlebar div.close_button").live("click", function(e){
162 segment = $(this).parents().filter("div.block"); 162 segment = $(this).parents().filter("div.block");
163 segment.fadeOut(function(){ segment.remove()}); 163 segment.fadeOut(function(){ segment.remove();});
164 }); 164 });
165 165
166 }; 166 }
167 167
168 168
169 function randomString() { 169 function randomString() {
170 var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; 170 var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
171 var string_length = 8; 171 var string_length = 8;