listatemas.js
5.21 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
function editorTemaMapfile(mapfile)
{
core_pegaDados("buscando dados...","../php/menutemas.php?funcao=pegaTemaPorMapfile&codigo_tema="+mapfile,"montaEditorTema")
}
function montaEditorTema(dados)
{
function on_editorCheckBoxChange(p_oEvent)
{
var ins = "";
if(p_oEvent.newValue.get("value") == "OK")
{
gravaDadosTema(dados[0].id_tema);
}
else
{
YAHOO.example.container.panelEditorTema.destroy();
YAHOO.example.container.panelEditorTema = null;
}
};
if(!YAHOO.example.container.panelEditorTema)
{
var novoel = document.createElement("div");
novoel.id = "janela_editor";
var ins = '<div class="hd">Editor</div>';
ins += "<div class='bd' style='height:354px;overflow:auto'>";
ins += "<div id='okcancel_checkbox'></div><div id='editor_bd'></div>";
novoel.innerHTML = ins;
document.body.appendChild(novoel);
var editorBotoes = new YAHOO.widget.ButtonGroup({id:"okcancel_checkbox_id", name: "okcancel_checkbox_id", container: "okcancel_checkbox" });
editorBotoes.addButtons([
{ label: "Salva", value: "OK", checked: false},
{ label: "Cancela", value: "CANCEL", checked: false }
]);
editorBotoes.on("checkedButtonChange", on_editorCheckBoxChange);
YAHOO.example.container.panelEditorTema = new YAHOO.widget.Panel("janela_editor", { fixedcenter:true,close:true,width:"400px", height:"400px",overflow:"auto", visible:false,constraintoviewport:true } );
YAHOO.example.container.panelEditorTema.render();
}
YAHOO.example.container.panelEditorTema.show();
//carrega os dados na janela
$i("editor_bd").innerHTML = montaDivTemas(dados[0])
core_carregando("desativa");
//
//preenche a div com a lista de tags
//
core_comboTags("comboTags","tags_tema","registraTagTema");
}
function registraTagTema(valor)
{
var inp = $i("tags_tema")
var tags = inp.value
if(tags == "")
inp.value = valor
else
inp.value = tags+" "+valor
}
function montaDivTemas(i)
{
var param = {
"linhas":[
{titulo:"Nome que será mostrado na árvore de menus:",id:"nome_tema",size:"50",value:i.nome_tema,tipo:"text",div:""}
]
}
var ins = ""
ins += core_geraLinhas(param)
ins += "<p>Descrição:<br>";
ins += "<input size=50 type=text id=desc_tema value='"+i.desc_tema+"' /></p>"
ins += "<p>Link para a fonte:<br>";
ins += "<input size=50 type=text id=link_tema value='"+i.link_tema+"' /></p>"
ins += "<p>Tags (separe com espaço). Você pode digitar novos tags ou pegar da lista abaixo:"
ins += "<input type=text size=50 value='"+i.tags_tema+"' id='tags_tema' ><br>"
ins += "<div id=comboTags >Buscando...</div>";
ins += "<p>Tipo (preencha apenas se for do tipo WMS):<br>"
ins += "<select id='tipo_tema' />"
ins += "<option value='' "
if (i.tipoa_tema == ""){ins += "selected";}
ins += ">Normal</option>"
ins += "<option value='WMS' "
if (i.tipoa_tema == "WMS"){ins += "selected";}
ins += " >WMS<option></select></p>"
ins += "<p>Permite acesso via WMS/WFS?<br>"
ins += "<select id='ogc_tema' >"
ins += core_combosimnao(i.ogc_tema)
ins += "</select></p>"
ins += "<p>Permite o download na aplicação datadownload.htm?<br>"
ins += "<select id='download_tema' >"
ins += core_combosimnao(i.download_tema)
ins += "</select></p>"
ins += "<p>Permite acesso via kml?<br>"
ins += "<select id='kml_tema' >"
ins += core_combosimnao(i.kml_tema)
ins += "</select></p>"
ins += "<p>Permite acesso via kmz (kml com dados vetoriais)?<br>"
ins += "<select id='kmz_tema' >"
ins += core_combosimnao(i.kmz_tema)
ins += "</select></p><br><br><br>"
ins += "<input type=hidden id=codigo_tema value='"+i.codigo_tema+"'/>"
return(ins)
}
function gravaDadosTema(id)
{
//validacao
if($i("kml_tema") && $i("ogc_tema")){
if($i("ogc_tema").value == "SIM")
{$i("kml_tema").value = "SIM";}
}
if($i("kml_tema") && $i("kmz_tema")){
if($i("kmz_tema").value == "SIM")
{$i("kml_tema").value = "SIM";}
if($i("kml_tema").value == "NAO")
{$i("kmz_tema").value = "NAO";}
}
var campos = new Array("nome","desc","link","tags","tipo","ogc","download","kml","codigo","kmz")
var par = ""
for (i=0;i<campos.length;i++)
{
if($i(campos[i]+"_tema"))
par += "&"+campos[i]+"="+($i(campos[i]+"_tema").value)
}
par += "&id="+id
core_carregando("ativa");
core_carregando(" gravando o registro do id= "+id);
var sUrl = "../php/menutemas.php?funcao=alteraTemas"+par;
var callback =
{
success:function(o)
{
try
{
if(YAHOO.lang.JSON.parse(o.responseText) == "erro")
{
core_carregando("<span style=color:red >Não foi possível excluir. Verifique se não existem menus vinculados a este tema</span>");
setTimeout("core_carregando('desativa')",3000)
}
else
{
//var rec = myDataTable.getRecordSet().getRecord(recordid);
//myDataTable.updateRow(rec,YAHOO.lang.JSON.parse(o.responseText)[0])
core_carregando("desativa");
}
YAHOO.example.container.panelEditorTema.destroy();
YAHOO.example.container.panelEditorTema = null;
}
catch(e){core_handleFailure(e,o.responseText);}
},
failure:core_handleFailure,
argument: { foo:"foo", bar:"bar" }
};
core_makeRequest(sUrl,callback,"POST")
}