janela.js
39.9 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
/**
* Title: Janelas
*
* Cria e gerencia janelas flutuantes
*
* As janelas são criadas por meio da biblioteca YUI
*
* Namespace:
*
* i3GEO.janela
*
* Veja:
*
* <http://localhost/i3geo/classesjs/classe_janela.js>
*/
/**
* Licença
*
* GPL2
*
* i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet
*
* Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com
*
* Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo sob os termos da Licença
* Pública Geral GNU conforme publicada pela Free Software Foundation;
*
* Este programa é distribuído na expectativa de que seja útil, porém, SEM NENHUMA GARANTIA; nem mesmo a
* garantia implícita de COMERCIABILIDADE OU ADEQUACÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença
* Pública Geral do GNU para mais detalhes. Você deve ter recebido uma cópia da Licença Pública Geral do
* GNU junto com este programa; se não, escreva para a Free Software Foundation, Inc., no endereço 59 Temple Street, Suite
* 330, Boston, MA 02111-1307 USA.
*/
if (typeof (i3GEO) === 'undefined') {
var i3GEO = {};
}
/**
* YAHOO.namespace
*
* Namespace da biblioteca YUI utilizado para armazenar janelas flutuantes
*/
YAHOO.namespace("i3GEO.janela");
/**
* Variavel: YAHOO.widget.OverlayManager
*
* Gerenciador das janelas flutuantes da biblioteca YUI
*
* Type:
*
* {YAHOO.widget.OverlayManager}
*/
YAHOO.i3GEO.janela.manager = new YAHOO.widget.OverlayManager();
//para efeitos de compatibilidade com a versão 4.6
YAHOO.namespace("janelaDoca.xp");
YAHOO.janelaDoca.xp.manager = new YAHOO.widget.OverlayManager();
/**
* Variavel: YAHOO.i3GEO.janela.managerAguarde
*
* Gerenciador das janelas flutuantes de aguarde
*
* Type:
*
* {YAHOO.widget.OverlayManager}
*/
YAHOO.i3GEO.janela.managerAguarde = new YAHOO.widget.OverlayManager();
//TODO criar janela que permita inserir um link e salva-la junto com o mapa
i3GEO.janela =
{
//Config do plugin que controla a barra de rolagem
scrollBar: {
theme: "3d-dark",
axis: "yx",
scrollbarPosition: "inside",
advanced:{ autoExpandHorizontalScroll: true },
scrollButtons:{ enable: true }
},
/**
* Cada vez que uma janela flutuante é criada, esse valor é acrescido de 1
*/
ULTIMOZINDEX : 5,
//aplica a estilizacao da barra de rolagem
//https://github.com/malihu/malihu-custom-scrollbar-plugin
applyScrollBar: function(iddiv,seletor,config) {
var a = i3GEO.janela.scrollBar;
if(config){
a = i3GEO.util.cloneObj(i3GEO.janela.scrollBar);
$.each( config, function( key, value ) {
a[key] = value;
});
}
var i = $($i(iddiv));
if(seletor && selector != ""){
i.find(seletor).mCustomScrollbar(a);
} else {
i.mCustomScrollbar(a);
}
},
/**
* Executa funções default antes de abrir a janela
*/
prepara : function() {
if (typeof (console) !== 'undefined')
console.info("i3GEO.janela.prepara()");
//
// esconde o box de zoom e outros objetos temporários se
// estiverem visíveis
//
var iu = i3GEO.util;
// iu.escondePin();
iu.escondeBox();
},
/**
* Function: cria
*
* Cria uma janela flutuante.
*
* Vc pode obter o elemento HTML interno da janela por meio de:
*
* retorno[2].innerHTML
*
* Vc pode recuperar uma janela com o comando
*
* YAHOO.i3GEO.janela.manager.find(id);
*
* Parametros:
*
* {integer} - largura da janela em pixels
*
* {integer} - altura da janela em pixels
*
* {String} - URL que será incluída no SRC do iframe interno da janela. Se for "", o iframe não será
* criado
*
* {Integer} - posição x da janela em pixels. Se for "" será fixada no centro
*
* {Integer} - posição y da janela em pixels. Se for "" será fixada no centro
*
* {String} - texto do cabeçalho
*
* {String} - (opcional) nome que será dado ao id que conterá a janela. Se não for definido, será usado
* o id="wdoca". O id do iframe interno é sempre igual ao id + a letra i. Por default, será "wdocai". O id do
* cabçalho será igual a id+"_cabecalho" e o id do corpo será id+"_corpo". O id também é
* utilizado na função de fechamento da janela. Quando for usada a técnica de script tag, ao fechar a janela a
* função de mesmo nome do id será definida como "null".
*
* {Boolean} - (opcional) indica se a janela bloqueará as inferiores ou não. Por default é false
*
* {String} - (opcional) classe CSS que será aplicada a barra de menu. Por default o valor é hd2. Na interface Google
* Earth, esse valor é sempre alterado para "hd".
*
* {function} - (opcional) funcao que será executada quando o usuário clicar no cabecalho
*
* {function} - (opcional) funcao que será executada para minimizar a janela
*
* {function} - (opcional) funcao que será executada para alterar o tamanho da janela
*
* {boolean} - (opcional) a janela pode ser redimensionada ou nao pelo usuario
*
* {string} - (opcional) icone que será mostrado no canto superior esquerdo da janela
*
* {funcao} - funcao executada quando o icone + for clicado
*
* {sim|nao} - (opcional) indica se o efeito de transparência nos eventos mouseover/out será aplicado
*
* Return:
*
* {Array} Array contendo objeto YAHOO.panel criado,elemento HTML com o cabecalho, elemento HTML com o corpo
*/
cria : function(wlargura, waltura, wsrc, nx, ny, texto, id, modal, classe, funcaoCabecalho, funcaoMinimiza, funcaoAposRedim,
dimensionavel, icone, funcaoDuplica, opacidade, classeAdicional, idajuda) {
if (typeof (console) !== 'undefined')
console.info("i3GEO.janela.cria()");
if(waltura && waltura == ""){
waltura = "auto";
}
if (arguments.length < 13 ) {
dimensionavel = true;
}
if(arguments.length < 17){
classeAdicional = "i3geo6";
}
if (!icone) {
icone = "";
}
var i, wlargurA, ins, novoel, wdocaiframe, temp, fix, underlay, ifr, janela;
if ($i(id)) {
janela = YAHOO.i3GEO.janela.manager.find(id);
janela.show();
janela.bringToTop();
return;
}
i3GEO.janela.prepara();
// define os parametros default
if (!classe || classe == "") {
classe = "hd";
}
if (!id || id === "") {
id = "wdoca";
}
if (!modal || modal === "") {
modal = false;
}
ifr = false;
fix = "contained";
if (nx === "" || nx === "center") {
fix = true;
}
// no IE, com CSS3, a sombra não funciona
if (modal === true) {
underlay = "none";
} else {
underlay = "shadow";
}
// cria as marcações html para a janela
temp = navm ? 0 : 2;
wlargurA = parseInt(wlargura, 10) + temp + "px";
ins = '<div id="' + id + '_cabecalho" class="' + classe + ' ' + classeAdicional + '" >';
if (i3GEO.configura !== undefined) {
/*
ins +=
"<img id='" + id
+ "_imagemCabecalho' class='i3GeoAguardeJanela' style='visibility:hidden;' src=\'"
+ i3GEO.configura.locaplic
+ "/imagens/aguarde2.gif\' />";
*/
ins += Mustache.render(i3GEO.template.janela.aguarde, {id: id});
}
if (icone != "") {
//ins += "<img class='i3GeoIconeJanela' src='" + icone + "' >";
}
if(idajuda){
ins += texto;
} else {
ins += "<span style='font-size:10px;'>" + texto + "</span>";
}
if (funcaoDuplica && funcaoDuplica != "") {
ins += "<div id='" + id + "_duplicaJanela' class='container-duplica'><span class='material-icons'>add_circle_outline</span></div>";
}
if (funcaoMinimiza && funcaoMinimiza != "") {
ins += "<div id='" + id + "_minimizaCabecalho' class='container-minimiza'><span class='material-icons'>aspect_ratio</span></div>";
}
ins += '</div><div id="' + id + '_corpo" class="bd ' + classeAdicional + '" style="display:block;padding:0px">';
if (wsrc !== "") {
ins += '<div class="container-fluid"><iframe name="' + id + 'i" id="' + id + 'i" valign="top" style="border:0px white solid;width:100%"></iframe></div>';
}
ins += '</div>';
if(idajuda){
ins += '<div class="ft ' + classeAdicional + '"><i onclick="i3GEO.ajuda.ferramenta(\''+idajuda+'\')" class="material-icons iconeAjudaFerramentas" >help</i></div>';
} else {
ins += '<div class="ft ' + classeAdicional + '"></div>';
}
novoel = document.createElement("div");
novoel.id = id;
novoel.style.display = "block";
novoel.innerHTML = ins;
document.body.appendChild(novoel);
wdocaiframe = $i(id + "i");
if (wdocaiframe) {
temp = wdocaiframe.style;
// temp.width = parseInt(wlargura,10)-12 + "px";
temp.height = waltura;
temp.display = "block";
wdocaiframe.src = wsrc;
} else {
if (waltura !== "auto") {
$i(id + '_corpo').style.height = parseInt(waltura, 10) + "px";
}
$i(id + '_corpo').style.width = '100%'; // parseInt(wlargura,10)+"px";
$i(id + '_corpo').style.overflow = "auto";
}
// cria a janela
if (waltura === "auto" || dimensionavel == false) {
janela = new YAHOO.widget.Panel(id, {
iframe : ifr,
modal : modal,
width : wlargurA,
underlay : underlay,
fixedcenter : fix,
constraintoviewport : true,
visible : true,
monitorresize : false,
dragOnly : true,
keylisteners : null,
strings: {close: "<span class='material-icons'>cancel</span>"}
});
} else {
janela = new YAHOO.widget.Panel(id, {
hideMode : 'offsets',
iframe : ifr,
underlay : underlay,
modal : modal,
width : wlargurA,
fixedcenter : fix,
constraintoviewport : true,
visible : true,
monitorresize : false,
dragOnly : true,
keylisteners : null,
strings: {close: "<span class='material-icons'>cancel</span>"}
});
}
if (YAHOO.util.Resize && dimensionavel == true) {
var resize = new YAHOO.util.Resize(id, {
handles : [
'br'
],
autoRatio : false,
minWidth : 10,
minHeight : 10,
status : false,
proxy : true,
ghost : false,
animate : false,
useShim : true
});
resize.on('resize', function(args) {
this.cfg.setProperty("height", args.height + "px");
if (wdocaiframe) {
wdocaiframe.style.height = args.height - 50 + "px";
}
}, janela, true);
if (funcaoAposRedim && funcaoAposRedim != "") {
resize.on('endResize', function(args) {
i3GEO.janela.minimiza();
funcaoAposRedim.call();
}, janela, true);
}
resize.getProxyEl().style.height = "0px";
}
if (nx !== "" && nx !== "center") {
janela.moveTo(nx, ny + 50);
}
YAHOO.i3GEO.janela.manager.register(janela);
janela.cfg.setProperty("effect", [
{
effect : YAHOO.widget.ContainerEffect.FADE,
duration : 0.5
}
]);
janela.cfg.setProperty("zIndex", [
4
]);
janela.render();
if (ifr === true) {
janela.iframe.style.zIndex = 4;
}
YAHOO.util.Event.addListener($i(id + '_corpo'), "click", YAHOO.util.Event.stopPropagation);
// finaliza
if (funcaoDuplica && funcaoDuplica != "") {
$i(id + '_duplicaJanela').onclick = funcaoDuplica;
}
if (funcaoCabecalho && funcaoCabecalho != "") {
$i(id + '_cabecalho').onclick = funcaoCabecalho;
}
if (funcaoMinimiza && funcaoMinimiza != "") {
$i(id + "_minimizaCabecalho").onclick = funcaoMinimiza;
}
YAHOO.util.Event.addListener(janela.close, "click", i3GEO.janela.fecha, janela, {
id : id
}, true);
temp = $i(id + "_c");
if(temp && temp.style){
temp.style.maxWidth = "90%";
//temp.style.zIndex = 50000;
}
temp = $i(id);
if(temp && temp.style){
temp.style.maxWidth = "100%";
}
temp = $i(id + "_corpo");
janela.bringToTop();
if(waltura !== "auto" && wsrc == ""){
i3GEO.janela.applyScrollBar(temp.id,"",{live:true,liveSelector:".customScrollBar"});
i3GEO.janela.applyScrollBar(temp.id,"",{live:true,liveSelector:".customScrollBarXY",advanced:{ autoExpandHorizontalScroll: false }});
}
return ([
janela, $i(id + "_cabecalho"), temp
]);
},
/**
* Minimiza uma janela na forma de um icone com opcoes de fechar e abrir novamente
*
* Parametro:
*
* {string} - id da janela
*
* {number} - largura em pixels da janela iconizada
*
* {string} - (opcional) id do rodape da janela
*/
iconiza : function(id,w,rodape){
var j,r,t = i3GEO.janela.minimiza(id, w+"px",rodape);
r = YAHOO.util.Resize.getResizeById(id);
j = $i(id + "I");
if(!j){
return;
}
if (t === "min") {
j.style.display = "none";
if(r){
r.lock();
}
if(rodape){
$i(rodape).style.display = "none";
}
} else {
j.style.display = "block";
if(r){
r.unlock();
}
if(rodape){
$i(rodape).style.display = "block";
}
}
},
/**
* Minimiza ou maximiza a janela
*
* Parametro:
*
* {string} - prefixo utilizado na composição do id da janela
*
* {string} - (opcional) largura minima da janela
*
* Return:
*
* {min|max} indicativo se minimizou ou maximizou
*/
minimiza : function(id, min) {
var temp = $i(id + "_corpo"), n, i, m = YAHOO.i3GEO.janela.manager.find(id), c = $i(id), t = "min", r = YAHOO.util.Resize.getResizeById(id),
tipo = "";
if (temp) {
if (temp.style.display === "block") {
temp.style.display = "none";
if (m) {
m.hideIframe();
}
m.winicial = c.style.width;
if (min) {
c.style.width = parseInt(min,10)+"px";
}
tipo = "none";
if(r){
r.lock();
}
} else {
temp.style.display = "block";
if (m) {
m.showIframe();
}
c.style.width = m.winicial;
t = "max";
tipo = "block";
if(r){
r.unlock();
}
}
}
temp = $i(id + "_c");
if (temp) {
$(temp).find(".comboTemasCabecalhoBs,.ft,.yui-resize-handle,.underlay,.bd").css("display",tipo);
}
temp = $i(id + "_corpo");
if (temp) {
temp.style.display = tipo;
}
temp = $i(id);
if (temp) {
if (tipo === "block") {
temp.style.height = "100%";
} else {
temp.style.height = "10%";
}
}
return t;
},
/**
* Elimina alguns objetos que são comumente adicionados por algumas
* operações do i3geo como box, pin
*
* Parametros:
*
* event {objeto} - objeto YUI do evento que gerou o fechamento da janela
*
* args {objeto} - parametros do evento que fechou a janela
*/
fecha : function(event, args) {
if (typeof (console) !== 'undefined')
console.info("i3GEO.janela.fecha()");
var i, id;
// esconde elementos gráficos q a ferramenta pode ter aberto
// i3GEO.util.escondePin();
i3GEO.util.escondeBox();
if (i3GEO.janela.id) {
id = i3GEO.janela.id;
} else {
id = event.id;
}
if (id == undefined) {
id = args.id;
}
i3GEO.janela.destroi(id);
},
/**
* Destroi uma janela sem aplicar as funcoes adicionais
*
* Parametros:
*
* id {string} - id da janela
*/
destroi : function(id) {
if (typeof (console) !== 'undefined')
console.info("i3GEO.janela.destroi() " + id);
if(typeof(YAHOO) != "undefined"){
var janela = YAHOO.i3GEO.janela.manager.find(id);
i3GEO.util.removeScriptTag(id + "_script");
i3GEO.util.removeScriptTag(id + ".dicionario_script");
if (janela) {
YAHOO.i3GEO.janela.manager.remove(janela);
// janela.destroy();
// destroy remove os listeners!!!!
janela = $i(id + "_c");
if(janela){
janela.parentNode.removeChild(janela);
try{
YAHOO.util.Resize.getResizeById(id).destroy();
} catch(e){}
}
}
}
},
/**
* Function: alteraTamanho
*
* Altera o tamanho de uma janela aberta
*
* Parametros:
*
* {Integer} - nova largura
*
* {Integer} - nova altura
*
* {String} - (opcional) id que identifica a janela aberta
*/
alteraTamanho : function(w, h, id) {
if (typeof (console) !== 'undefined')
console.info("i3GEO.janela.alteraTamanho()");
var i;
if (arguments.length === 3) {
i = $i(id);
} else {
i = $i("wdoca");
}
if (i) {
i.style.width = w + "px";
i.style.height = h + "px";
}
},
CONTADORAGUARDE : [],
/**
* Function: abreAguarde
*
* Abre uma janela com a mensagem de aguarde
*
* Parametros:
*
* {String} - id da nova janela
*
* {String} - texto da janela
*/
abreAguarde : function() {
var p = $i("i3GEObarraAguarde");
if(p){
p.style.width = "100%";
}
i3GEO.janela.CONTADORAGUARDE.push(" ");
},
/**
* Function: fechaAguarde
*
* Fecha uma janela do tipo aguarde
*
* Paremeters:
*
* {String} - id da janela que será fechada. Se não for definido, tenta fechar as janelas principais.
*/
fechaAguarde : function() {
var p = $i("i3GEObarraAguarde");
if (p){
if (i3GEO.janela.CONTADORAGUARDE.length == 1) {
p.style.width = "0px";
}
i3GEO.janela.CONTADORAGUARDE.pop();
}
},
/**
* Function: tempoMsg
*
* Abre uma janela com uma mensagem temporaria
*
* Parametros:
*
* {String} - texto da janela
*
* {segundos}
*/
tempoMsg : function(texto, tempo) {
if(!i3GEO.janela.tempoModal){
i3GEO.janela.tempoModal = $(
Mustache.render(i3GEO.template.janela.msg, {"texto": texto})
);
} else {
$i("i3GEOMensagemTempoModal").innerHTML = texto;
}
i3GEO.janela.tempoModal.modal("show");
if(!tempo){
tempo = 3000;
}
setTimeout(function() {
i3GEO.janela.tempoModal.modal("hide");
}, tempo);
},
closeModal: false,
closeMsg : function(texto) {
if(!i3GEO.janela.closeModal){
i3GEO.janela.closeModal = $(
Mustache.render(i3GEO.template.janela.msg, {"texto": texto})
);
} else {
$("#i3GEOMensagemCloseModal").html(texto);
i3GEO.janela.closeModal.modal("show");
return;
}
i3GEO.janela.closeModal.modal("show");
},
/**
* Function: ativaAlerta
*
* Substitui a janelça de alerta padrão do sistema operacional por uma outra customizada
*/
ativaAlerta : function() {
window.alert = function(texto) {
var textoI, janela = YAHOO.i3GEO.janela.managerAguarde.find("alerta");
if (!janela) {
janela = new YAHOO.widget.SimpleDialog("alerta", {
width : "300px",
fixedcenter : true,
visible : false,
draggable : false,
zIndex : 100000,
textAlign : "left",
close : false,
modal : false,
effect : {
effect : YAHOO.widget.ContainerEffect.FADE,
duration : 0.25
},
constraintoviewport : true,
text : ""
});
// YAHOO.i3GEO.janela.dialogInfo.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_WARN);
YAHOO.i3GEO.janela.managerAguarde.register(janela);
janela.setHeader(" ");
janela.render(document.body);
janela.setFooter("<div class='form-group condensed' id='alertFooter'></div>");
var ins = Mustache.render(i3GEO.template.botoes.padrao, {text: $trad("x74")});
var fecha = function(){YAHOO.i3GEO.janela.managerAguarde.find("alerta").destroy();};
$('#alertFooter').append($(ins).click(fecha));
}
textoI = janela.cfg.getProperty("text");
if (textoI != "") {
textoI += "<br>";
}
texto = textoI + texto;
janela.cfg.setProperty("text", "<h4 class='alertTitulo'>" + texto + "</h4>");
janela.show();
};
},
/**
* Function: confirma
*
* Janela de confirmacao
*
* Parametros:
*
* {string} - texto da pegunta
*
* {numeric} - largura da janela
*
* {string} - (opcional) texto do botao 1
*
* {string} - (opcional) texto do botao 2
*
* {function} - (opcional) funcao do botao 1
*
* {function} - (opcional) funcao do botao 2
*/
confirma : function(pergunta, w, resposta1, resposta2, funcao1, funcao2) {
var b, f1, f2, f3, janela = YAHOO.i3GEO.janela.managerAguarde.find("confirma");
if (!w || w == "") {
w = 300;
}
if (!funcao1 || funcao1 == "") {
f1 = function() {
YAHOO.i3GEO.janela.managerAguarde.find("confirma").destroy();
return true;
};
} else {
f1 = function() {
funcao1.call();
YAHOO.i3GEO.janela.managerAguarde.find("confirma").destroy();
};
}
if (!funcao2 || funcao2 == "") {
f2 = function() {
YAHOO.i3GEO.janela.managerAguarde.find("confirma").destroy();
return false;
};
} else {
f2 = function() {
funcao2.call();
YAHOO.i3GEO.janela.managerAguarde.find("confirma").destroy();
};
}
f3 = function() {
YAHOO.i3GEO.janela.managerAguarde.find("confirma").destroy();
};
if (!resposta1 || resposta1 == "") {
resposta1 = $trad("confirma");
}
if (janela) {
janela.destroy();
}
b = [
{
text : $trad("x75"),
handler : f3
}, {
text : resposta1,
handler : f1
}
];
if (resposta2 && resposta2 != "") {
b.push({
text : resposta2,
handler : f2
});
}
janela = new YAHOO.widget.SimpleDialog("confirma", {
width : w + "px",
fixedcenter : true,
visible : false,
draggable : false,
zIndex : 100000,
textAlign : "left",
close : false,
modal : false,
effect : {
effect : YAHOO.widget.ContainerEffect.FADE,
duration : 0.25
},
constraintoviewport : true,
//buttons : b,
text : "<h4 class='alertTitulo'>" + pergunta + "</h4>"
});
YAHOO.i3GEO.janela.managerAguarde.register(janela);
janela.setHeader(" ");
//botoes
janela.setFooter("<div class='form-group condensed' id='confirmaFooter'></div>");
janela.render(document.body);
var ins = "";
$.each(b, function( index, value ) {
ins = Mustache.render(i3GEO.template.botoes.padrao, {style:'margin-right:10px;',text: value.text});
$('#confirmaFooter').append($(ins).click(value.handler));
});
janela.show();
},
/**
* Function: prompt
*
* Janela de prompt para entrada de dados
*
* O campo para digitacao contem o ID 'i3GEOjanelaprompt'
*
* Parametros:
*
* {string} - texto da pegunta
*
* {function} - (opcional) funcao do botao ok
*
* {string} - (opcional) valor default
*/
prompt : function(pergunta, funcaoOk, valorDefault) {
if ($i("i3GEOjanelaprompt")) {
return;
}
if (!valorDefault) {
valorDefault = "";
}
var i = "<div class='form-group label-fixed condensed' ><label class='control-label' for='i3GEOjanelaprompt'>"+pergunta+"</label><input placeholder='"+pergunta+"' class='form-control input-lg' type='text' id='i3GEOjanelaprompt' value='"+ valorDefault +"' /></div>";
i3GEO.janela.confirma(i, "", "", "", funcaoOk);
},
/**
* Function: mensagemSimples
*
* Mostra uma janela simples com uma mensagem
*
* Parametros:
*
* {String} - texto da mensagem
*
* {String} - texto do cabecalho
*
* {numeric} - (opcional) largura em pixel
*
* {numeric} - (opcional) altura em pixel
*/
mensagemSimples : function(texto, cabecalho, largura, altura) {
var janela;
if (!largura) {
largura = 300;
}
if (!altura) {
altura = 300;
}
if (!cabecalho) {
cabecalho = "";
}
janela = new YAHOO.widget.SimpleDialog(i3GEO.util.generateId(), {
width : parseInt(largura, 10) + "px",
height : parseInt(altura, 10) + "px",
fixedcenter : true,
visible : true,
draggable : true,
zIndex : 100000,
textAlign : "left",
close : true,
modal : false,
effect : {
effect : YAHOO.widget.ContainerEffect.FADE,
duration : 0.25
},
constraintoviewport : true,
text : ""
});
YAHOO.i3GEO.janela.manager.register(janela);
// $i(id + '_corpo').style.height = parseInt(waltura, 10) + "px";
janela.setHeader(cabecalho);
janela.render(document.body);
janela.setHeader("<div class='i3GeoTituloJanela'>"+cabecalho+"</div>");
janela.cfg.setProperty("text", texto);
janela.bringToTop();
janela.show();
return janela;
},
/**
* Adiciona no cabeçalho da janela um combo com a lista de temas para janelas abertas por ferramentas
*
* Essa função é utilizada pelas ferramentas que operam sobre um determinado tema. O combo permite que o
* usuário selecione um tema e ative a ferramenta para funcionar com esse tema
*
* Parametros:
*
* idDiv {string} - id do elemento HTML que receberá o combo
*
* idCombo {string} - id do combo que será criado
*
* ferramenta {string} - nome da ferramenta (namespace da classe, por exemplo "tabela" para a classe i3GEOF.tabela
*
* tipo {string} - tipo de combo
*
* onButtonClick {function} - funcao que sera executada no evento onchange do combo a ser criado
*/
comboCabecalhoTemas : function(idDiv, idCombo, ferramenta, tipo, onButtonClick, temaSel) {
var temp = $i(idDiv);
// tenta pegar o tema que ja foi escolhido antes
if (!temaSel) {
temaSel = "";
}
if (temaSel == "" && i3GEOF[ferramenta] && i3GEOF[ferramenta].tema && i3GEOF[ferramenta].tema != "") {
// o tema escolhido pode estar definido na variavel da ferramenta
temaSel = i3GEOF[ferramenta].tema;
}
if (temp) {
i3GEO.util.comboTemas(temp.id + "Sel", function(retorno) {
var tema, container = $i(idDiv), botao;
container.innerHTML = retorno.dados;
botao = new YAHOO.widget.Button(idCombo, {
type : "menu",
menu : idCombo + "select"
});
if (temaSel != "") {
tema = i3GEO.arvoreDeCamadas.pegaTema(temaSel);
if (tema && tema != undefined) {
botao.set("label", "<span class='cabecalhoTemas' >" + tema.tema + "</span> ");
} else {
botao.set("label", "<span class='cabecalhoTemas' >" + $trad("x92") + "</span> ");
}
} else {
botao.set("label", "<span class='cabecalhoTemas' >" + $trad("x92") + "</span> ");
}
if (!onButtonClick) {
onButtonClick =
function(p_sType, p_aArgs) {
var oMenuItem = p_aArgs[1];
if (oMenuItem) {
i3GEO.mapa.ativaTema(oMenuItem.value);
if (oMenuItem.value === "") {
i3GEO.temaAtivo = "";
botao.set("label", "<span class='cabecalhoTemas' >" + $trad("x92") + "</span> ");
} else {
botao.set("label", "<span class='cabecalhoTemas' >" + oMenuItem.cfg.getProperty("text")
+ "</span> ");
}
if (i3GEOF[ferramenta]) {
i3GEOF[ferramenta].tema = oMenuItem.value;
if ($i("i3GEOF." + ferramenta + "_corpo")) {
$i("i3GEOF." + ferramenta + "_corpo").innerHTML = "";
eval("i3GEOF." + ferramenta + ".inicia('i3GEOF." + ferramenta + "_corpo');");
}
}
}
};
//
// a busca nao funciona com parametros dentro de parenteses
// por isso e necessario zerar o array
//
if (i3GEO.eventos.ATUALIZAARVORECAMADAS.length > 20) {
i3GEO.eventos.ATUALIZAARVORECAMADAS = [];
}
i3GEO.eventos.adicionaEventos("ATUALIZAARVORECAMADAS", [
"i3GEO.janela.comboCabecalhoTemas('" + idDiv + "','" + idCombo + "','" + ferramenta + "','" + tipo + "')"
]);
}
botao.getMenu().subscribe("click", onButtonClick, botao);
}, temp.id, "", false, tipo, "", true, true, "");
}
},
comboCabecalhoTemasBs : function(idDiv, idCombo, ferramenta, tipo, onButtonClick, temaSel) {
var temp = $i(idDiv);
// tenta pegar o tema que ja foi escolhido antes
if (!temaSel) {
temaSel = "";
}
if (temaSel == "" && i3GEOF[ferramenta] && i3GEOF[ferramenta].tema && i3GEOF[ferramenta].tema != "") {
// o tema escolhido pode estar definido na variavel da ferramenta
temaSel = i3GEOF[ferramenta].tema;
} else {
temaSel = i3GEO.temaAtivo;
if (i3GEOF[ferramenta] && i3GEOF[ferramenta].tema) {
i3GEOF[ferramenta].tema = temaSel;
}
}
if (temp) {
i3GEO.util.comboTemas(temp.id + "Sel", function(retorno) {
var tema, container = $i(idDiv), botao;
container.innerHTML += retorno.dados;
botao = $i(temp.id + "Sel");
if (temaSel != "") {
tema = i3GEO.arvoreDeCamadas.pegaTema(temaSel);
if (tema && tema != undefined) {
botao.value = tema.name;
} else {
botao.value= "";
}
} else {
botao.value= "";
}
if (!onButtonClick) {
onButtonClick = function(botao){
i3GEO.mapa.ativaTema(botao.value);
if(botao.value == ""){
i3GEO.temaAtivo = "";
}
if (i3GEOF[ferramenta]) {
i3GEOF[ferramenta].tema = botao.value;
if ($i("i3GEOF." + ferramenta + "_corpo")) {
$i("i3GEOF." + ferramenta + "_corpo").innerHTML = "";
eval("i3GEOF." + ferramenta + ".inicia('i3GEOF." + ferramenta + "_corpo');");
}
}
};
}
botao.onchange = onButtonClick;
}, temp.id, "", false, tipo, "font-size: 12px;width: 95%;color:white;", false, true, "form-control comboTema");
}
}
};