editormapfile_layer.js
10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//
//Dependencias: Este programa necessita do arquivo "../dicionario/editormapfile.js"
//
function montaNoLayer(codigo,indice){
var conteudo = " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('sobe','layer','"+codigo+"','"+indice+"')\" title="+ $trad("sobe",i3GEOadmin.core.dicionario) +" src=\"../imagens/34.png\" />";
conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"sobeDesce('desce','layer','"+codigo+"','"+indice+"')\" title="+ $trad("desce",i3GEOadmin.core.dicionario) +" src=\"../imagens/33.png\" />";
conteudo += " <img style=\"position:relative;cursor:pointer;top:0px\" onclick=\"excluirLayer('"+codigo+"','"+indice+"')\" title="+ $trad("excluir",i3GEOadmin.core.dicionario) +" width='10px' heigth='10px' src=\"../imagens/01.png\" /> <span>"+indice+"</span>";
var d = {html:conteudo,id:codigo+"_"+indice,codigoMap:codigo,codigoLayer:indice};
return d;
}
function loadLayerData(node, fnLoadComplete)
{
var sUrl = "../php/editormapfile.php?funcao=listaClasses&codigoMap="+node.data.codigoMap+"&codigoLayer="+node.data.codigoLayer;
var callback =
{
success: function(oResponse)
{
var dados = YAHOO.lang.JSON.parse(oResponse.responseText);
montaParametrosTemas(node,dados,false);
oResponse.argument.fnLoadComplete();
},
failure: function(oResponse)
{
oResponse.argument.fnLoadComplete();
},
argument:
{
"node": node,
"fnLoadComplete": fnLoadComplete
},
timeout: 25000
};
YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
}
/*
Function: montaParametrosTemas
Complementa as opções de edição básicas de um LAYER
<LISTAESTILOS>
*/
function montaParametrosTemas(no,dados,redesenha)
{
var codigoMap = no.data.codigoMap,
codigoLayer = no.data.codigoLayer,
id = codigoMap+"_"+codigoLayer,
conteudo = "",
tempNodeR = "",
tempNode = "",
d;
if(!tree.getNodeByProperty("etiquetaDados",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorDados('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='' src=\"../imagens/06.png\" />"+ $trad("conexaoLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaDados",etiquetaDados:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
}
if(!tree.getNodeByProperty("etiquetaTitulo",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorTitulo('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='' src=\"../imagens/06.png\" />"+ $trad("tituloLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaTitulo",etiquetaTitulo:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
if(!tree.getNodeByProperty("etiquetaEditavel",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorEditavel('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='' src=\"../imagens/06.png\" />"+ $trad("editavelLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaEditavel",etiquetaEditavel:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
if(!tree.getNodeByProperty("etiquetaComport",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorComport('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='' src=\"../imagens/06.png\" />"+ $trad("comportamentoLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaComport",etiquetaComport:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
if(!tree.getNodeByProperty("etiquetaDispo",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorDispo('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='' src=\"../imagens/06.png\" />"+ $trad("disponibLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaDispo",etiquetaDispo:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
//rever
if(!tree.getNodeByProperty("etiquetaMetadados",id))
{
conteudo = "<span style=cursor:pointer; onclick=\"editorMetadados('"+codigoMap+"','"+codigoLayer+"')\" ><img width='10px' heigth='10px' style=\"position:relative;top:0px\" title='edita metadados' src=\"../imagens/06.png\" />"+ $trad("miscLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {tipo:"etiquetaMetadados",etiquetaMetadados:id,html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
if(!tree.getNodeByProperty("etiquetaClasses",id))
{
d = {id:id,codigoLayer:codigoLayer,tipo:"etiquetaClasses",etiquetaClasses:id,html:"<i> Classes</i>"};
tempNodeR = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNodeR.isLeaf = false;
tempNodeR.enableHighlight = false;
conteudo = "<span style='cursor:pointer;' onclick=\"adicionaNovaClasse('"+codigoMap+"','"+codigoLayer+"')\" ><img style='position:relative;top:2px' src=\"../imagens/05.png\" />"+ $trad("adicionaClasseLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, tempNodeR, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
conteudo = "<span style='cursor:pointer;' onclick=\"classesAuto('"+codigoMap+"','"+codigoLayer+"')\" ><img style='position:relative;top:2px' src=\"../imagens/classificar.gif\" />"+ $trad("criaClassesLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, tempNodeR, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
conteudo = "<span style='cursor:pointer;' onclick=\"window.open('../../testamapfile.php?solegenda=sim&map="+no.data.codigoMap+"')\" > <img style='position:relative;top:2px' src=\"../imagens/41.png\" />"+ $trad("testaLayer",i3GEOadmin.editormapfile.dicionario) +"</span>";
d = {html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, tempNodeR, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
for (var i=0, j=dados.length; i<j; i++)
{
d = conteudoNoClasse(no.data.codigoMap,codigoLayer,dados[i].indice,dados[i].nome);
tempNode = new YAHOO.widget.HTMLNode(d,tempNodeR, false,true);
tempNode.setDynamicLoad(loadClasseData, iconMode);
tempNode.isLeaf = false;
tempNode.enableHighlight = false;
}
if(!tree.getNodeByProperty("pluginI3geo",id))
{
d = {id:id,codigoLayer:codigoLayer,tipo:"pluginI3geo",etiquetaPluginI3geo:id,html:"<i> "+ $trad("pluginLayer",i3GEOadmin.editormapfile.dicionario) +"</i>"};
tempNodeR = new YAHOO.widget.HTMLNode(d, no, false,true);
tempNodeR.isLeaf = false;
tempNodeR.enableHighlight = false;
var temp = i3GEO.pluginI3geo.PLUGINS;
for (var i=0, j=temp.length; i<j; i++){
if(temp[i].editor === true){
conteudo = "<span style='cursor:pointer;' onclick=\"pegaPluginLayer('"+temp[i].classe+"','"+codigoMap+"','"+codigoLayer+"')\" ><img style='position:relative;top:2px' src=\"../imagens/classificar.gif\" /> "+temp[i].nome + " - " + temp[i].classe+"</span>";
d = {html:conteudo};
tempNode = new YAHOO.widget.HTMLNode(d, tempNodeR, false,true);
tempNode.isLeaf = true;
tempNode.enableHighlight = false;
}
}
}
tree.draw();
}
/**
* Pega a string de definicao de um plugin no LAYER e monta o formulario
*
* @param plugin
* @param codigoMap
* @param codigoLayer
*/
function pegaPluginLayer(plugin,codigoMap,codigoLayer){
core_montaEditor("","450px","500px","","Plugin",true,false,false);
var sUrl = "../php/editormapfile.php?funcao=pegaPlugin&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer;
var montaEditorPlugin = function(retorno){
var ins = "<input type=button title='"+ $trad("salva",i3GEOadmin.core.dicionario) +"' value='"+ $trad("salva",i3GEOadmin.core.dicionario) +"' id=salvarPlugin />"
+ "<input type=button title='"+ $trad("remove",i3GEOadmin.core.dicionario) +"' value='"+ $trad("remove",i3GEOadmin.core.dicionario) +"' id=removerPlugin />";
//pega os campos do formulario
ins += i3GEO.pluginI3geo.formAdmin(plugin,retorno);
var ajuda = "<p>Mais informações:<br><a href='"+i3GEO.pluginI3geo.linkAjuda(plugin)+"' target=_blank >" + i3GEO.pluginI3geo.linkAjuda(plugin) + "</a></p>";
$i("editor_bd").innerHTML = ins + ajuda;
new YAHOO.widget.Button("salvarPlugin",{ onclick: { fn: function(){
salvarDadosEditorPlugin($i("editor_bd"),plugin,codigoMap,codigoLayer);
} }});
new YAHOO.widget.Button("removerPlugin",{ onclick: { fn: function(){
salvarDadosEditorPlugin($i("editor_bd"),"",codigoMap,codigoLayer);
} }});
};
core_pegaDados($trad("obtemDados",i3GEOadmin.core.dicionario),sUrl,montaEditorPlugin);
}
/*
Function: adicionaNovoLayer
Adiciona um novo layer
<CRIARNOVOLAYER>
*/
function adicionaNovoLayer(codigoMap)
{
core_carregando("ativa");
core_carregando($trad("msgAdicionaNovoLayer",i3GEOadmin.editormapfile.dicionario));
sUrl = "../php/editormapfile.php?funcao=criarNovoLayer&codigoMap="+codigoMap;
var callback =
{
success:function(o)
{
try
{
if(YAHOO.lang.JSON.parse(o.responseText) == "erro")
{
core_carregando("<span style=color:red >"+ $trad("erro",i3GEOadmin.core.dicionario) +"</span>");
setTimeout("core_carregando('desativa')",3000);
}
else
{
var dados = YAHOO.lang.JSON.parse(o.responseText);
var no = tree.getNodeByProperty("etiquetaLayers",codigoMap);
var tempNode = new YAHOO.widget.HTMLNode(montaNoLayer(codigoMap,dados.layers[0]), no, false,true);
tempNode.setDynamicLoad(loadLayerData, iconMode);
tempNode.isLeaf = false;
tempNode.enableHighlight = false;
tree.draw();
//editorGeral(codigoMap,dados.layers[0]);
editorTitulo(codigoMap,dados.layers[0]);
core_carregando("desativa");
}
}
catch(e){core_handleFailure(e,o.responseText);}
},
failure:core_handleFailure,
argument: { foo:"foo", bar:"bar" }
};
core_makeRequest(sUrl,callback);
}
/*
Function: excluirLayer
Exclui um layer
<EXCLUIRLAYER>
*/
function excluirLayer(codigoMap,codigoLayer)
{
var mensagem = $trad("msgExcluiMap",i3GEOadmin.core.dicionario)+codigoLayer;
var no = tree.getNodeByProperty("id",codigoMap+"_"+codigoLayer);
var sUrl = "../php/editormapfile.php?funcao=excluirLayer&codigoMap="+codigoMap+"&codigoLayer="+codigoLayer;
core_excluiNoTree(sUrl,no,mensagem,codigoLayer);
}