











Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!












autor: Emerson Shigueo Sugimoto [email protected] 2012 direitos autorais: O uso deste código é permitido de forma pessoal ou comercial, sob a condição de que os direitos autorais sejam mantidos. Para sugestões de melhoria do código entre em contato: [email protected]. Testes: chrome, ie9+ -------------------------------------------------------*/
Pasta 1
Sub Pasta 1 Sub Pasta 2
Pasta 2 ...
Saída de Debug
autor: Emerson Shigueo Sugimoto [email protected] 2012 direitos autorais: O uso deste código é permitido de forma pessoal ou comercial, sob a condição de que os direitos autorais sejam mantidos. Para sugestões de melhoria do código entre em contato: [email protected]. Testes: chrome, ie9+ -------------------------------------------------------/ //IE fix if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt /, from*/) { var len = this.length >>> 0;
var from = Number(arguments[1]) || 0; from = (from < 0)? Math.ceil(from) : Math.floor(from); if (from < 0) from += len;
for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; }
var FuncoesAuxiliares = function(){ this.FuncaoSaidaDebug = null; this.GetIdRandom = function(){ return 'id' + Math.floor((Math.random()1000)+1) + Math.floor((Math.random()1000)+1); } this.Igual = function(tx1, tx2) { tx1 = String(tx1).toLowerCase(); tx2 = String(tx2).toLowerCase(); //if (tx1.length < tx2.length) {var t = tx1; tx1 = tx2; tx = t;} //é melhor:do not switch! return tx1.indexOf(tx2) >= 0; } this.AdicionarPastaPrincipal = function(obj){ var pai = obj.parentNode; this.RemoveAddPastaPrincipal(); var el = document.createElement('span'); el.setAttribute('id','spnAdicionarPastaPrincipal'); var html = ''; html += ' '; html += ''; html += ''; html += ' ' + ''; el.innerHTML = html; pai.appendChild(el);
var txt = document.getElementById('txtAddPastaPrincipal');if(txt!=null){if(txt.f ocus){txt.focus();}} } this.RemoveAddPastaPrincipal = function(){ var el = document.getElementById('spnAdicionarPastaPrincipal'); if (el!=null) {el.parentNode.removeChild(el);} this.RePrint(); } this.addPastaPrincipal = function(nome){ rootPastas.AdicionarPasta(nome, ''); this.RemoveAddPastaPrincipal(); } this.addPasta = function(obj, id){ var pai = obj.parentNode; this.removerAddPasta(); var el = document.createElement('span'); el.setAttribute('id','spnAdicionarSubPasta'); var html = ''; html += ' '; html += ''; html += ''; html += ' ' + '';
el.innerHTML = html; pai.appendChild(el);
var txt = document.getElementById('txtAddSubPasta');if(txt!=null){if(txt.focus){ txt.focus();}} } this.removerAddPasta = function(){ var el = document.getElementById('spnAdicionarSubPasta'); if (el!=null) {el.parentNode.removeChild(el);} } this.salvarSubPastaAdd = function(id, valor){ if (valor==null || valor=='' || valor.length <= 0){this.removerAddPasta();return;} //if (!confirm('Deseja adicionar a Sub Pasta "'+valor+'" ?')){removerAddPasta();return;} var pasta = rootPastas.GetById(id); if (pasta == null){return;} pasta.ShowAll(); //evitar hide de subpastas pasta.AdicionarSubPasta(valor, ''); this.RePrint(); } this.RemoverPasta = function(id, nome){ if (!confirm('Deseja remover a Pasta "'+nome+'" ?')){return;} rootPastas.Remover(id); this.RePrint(); } this.RenomearPasta = function(obj, id){
var rt = findById(this.Pastas[i], id); if (rt != null){return rt;} } return null; } this.Remover = function(id){ var removeu = false; for(i in this.Pastas){ if (funcoesAuxiliares.Igual(this.Pastas[i].Id, id)){
this.Pastas.splice(this.Pastas.indexOf(this.Pastas[i]), 1); removeu = true;break; } } if (removeu){return;}
var pasta = this.GetById(id);
pasta.Pai.SubPastas.splice(pasta.Pai.SubPastas.indexOf(pasta), 1); }
this.ToString = function(){ if (this.Pastas==null || this.Pastas.length <= 0){return '';} var r = ''; for (i in this.Pastas){ r += this.Pastas[i].ToString(); } r += ''; return r; } this.Print = function(){ var alvo = document.getElementById(this.DivAlvo); if (alvo==null){return;} alvo.innerHTML = ''; alvo.innerHTML = this.ToString(); } this.PrintDebug = function(){ var r = ''; for (i in this.Pastas){ r += this.Pastas[i].PrintDebug(); } return r; } this.ShowAll = function(){ for(i in this.Pastas){this.Pastas[i].ShowAll();} this.Print(); }
//--- Html funções --- this.ShowHideNode = function(id){ var pasta = this.GetById(id); pasta.ShowHideSubPastas(); this.Print(); if (funcoesAuxiliares.FuncaoSaidaDebug) {funcoesAuxiliares.FuncaoSaidaDebug(rootPastas.PrintDebug());}//debug } this.Pesquisar = function(tx){ this.ShowAll(); for(i in this.Pastas){this.Pastas[i].Pesquisar(tx);} this.Print();
if (funcoesAuxiliares.FuncaoSaidaDebug) {funcoesAuxiliares.FuncaoSaidaDebug(rootPastas.PrintDebug());}//debug } } var Pasta = function(nome, id, pai){ this.Nome = nome; this.Id = (id==null||id=='')?funcoesAuxiliares.GetIdRandom():id; this.Pai = pai; this.Visivel = true; this.SubPastas = new Array();
this.AdicionarSubPasta = function(nome, id){ var sbp = new Pasta(nome, (id==null||id=='')?funcoesAuxiliares.GetIdRandom():id, this); this.SubPastas.push(sbp); return sbp; }
this.GetLink = function(){ var rt = '';
//add folder down rt += ' ' + '';
rt += ' '; rt += '';
rt += ' '; rt += '';
return rt; } this.ToString = function(){ if (!this.Visivel) {return '';} var rt = ''; //var rt = ''; //este ul sera dados pelo objeto RootPasta rt += ' this.Pesquisar = function(tx){ function pesqPastaESubPastas(pasta, tx){ if (funcoesAuxiliares.Igual(pasta.Nome, tx)){return true;} for(i in pasta.SubPastas){ if (pesqPastaESubPastas(pasta.SubPastas[i], tx)) { return true; } //else: pesquisa demais subpastas } return false; } function pesqPastaSubPastas(pasta, tx){ pasta.Visivel = pesqPastaESubPastas(pasta, tx); if (pasta.Visivel){ for(i in pasta.SubPastas){ pesqPastaSubPastas(pasta.SubPastas[i], tx); } } } pesqPastaSubPastas(this, tx); } }
@charset "utf-8"; /------------------------------------------------------- autor: Emerson Shigueo Sugimoto [email protected] 2012 direitos autorais: O uso deste código é permitido de forma pessoal ou comercial, sob a condição de que os direitos autorais sejam mantidos. Para sugestões de melhoria do código entre em contato: [email protected]. Testes: chrome, ie9+ -------------------------------------------------------/ body {margin:0;padding:0;font:12px Arial, Gadget, Helvetica, sans- serif;background:#f0f0f0;} html, body {height: 100%;} img, input[type=image] {border:0;} .clear {clear:both;display:block;overflow:hidden;visibility:hidden;width:0;he ight:0;} input, select, textarea,input[type="submit"]:focus{outline:0 none;} /------------------------ @font-face Lucida Sans Unicode,Lucida Grande,Open Sans,Open Sans LR, Ubuntu,HeroLight,Hero,Code,Lane ------------------------/ @font-face { font-family: 'Lane'; src: url('../fontes/lanenar.eot'); src: url('../fontes/lanenar.eot?#iefix') format('embedded- opentype'), url('../fontes/lanenar.woff') format('woff'), url('../fontes/lanenar.ttf') format('truetype'), url('../fontes/lanenar.svg#lane_-_narrowregular') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'Code'; src: url('../fontes/code_light.eot'); src: url('../fontes/code_light.eot?#iefix') format('embedded- opentype'), url('../fontes/code_light.woff') format('woff'), url('../fontes/code_light.ttf') format('truetype'), url('../fontes/code_light.svg#code_lightregular') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'Hero'; src: url('../fontes/hero.eot'); src: url('../fontes/hero.eot?#iefix') format('embedded-opentype'), url('../fontes/hero.woff') format('woff'), url('../fontes/hero.ttf') format('truetype'), url('../fontes/hero.svg#heroregular') format('svg'); font-weight: normal; font-style: normal; } @font-face {
src: url('../fontes/lucida_sans_unicode.eot'); src: url('../fontes/lucida_sans_unicode.eot?#iefix') format('embedded-opentype'), url('../fontes/lucida_sans_unicode.woff') format('woff'), url('../fontes/lucida_sans_unicode.ttf') format('truetype'),
url('../fontes/lucida_sans_unicode.svg#lucida_sans_unicoderegular') format('svg'); font-weight: normal; font-style: normal; }
/------------------------ Container ------------------------/ .Container {width:1000px;min-height:80%;margin:0 auto;text- align:left;background:#FFF;} .ContainerSite {padding:30pt;} /------------------------ Formulario ------------------------/ .Formulario { font:11px/1.7 'Open Sans','Lucida Sans Unicode','Lucida Grande',sans-serif; color:#333333; } .Formulario .FormularioTitulo { color:#333333; text-decoration:none; font-size:13pt;text- transform:uppercase; } .Formulario input[type=text], .Formulario select, .Formulario textarea { background:url(../imagens/fundo_form.png) repeat; color:#959595; font-size:9pt; border:none; padding:5pt; margin-bottom:7pt; width:300px; }
@charset "utf-8"; /------------------------------------------------------- autor: Emerson Shigueo Sugimoto [email protected] 2012 direitos autorais: O uso deste código é permitido de forma pessoal ou comercial, sob a condição de que os direitos autorais sejam mantidos. Para sugestões de melhoria do código entre em contato: [email protected]. Testes: chrome, ie9+ -------------------------------------------------------/ textarea { font:11px/1.7 'Open Sans','Lucida Sans Unicode','Lucida Grande',sans-serif;color:#636363; background:url(../imagens/fundo_form.png) repeat; color:#959595; font-size:9pt; border:none; padding:5pt; margin-bottom:7pt; } a {text-decoration:none;}
#alvo { font:11px/1.7 'Open Sans','Lucida Sans Unicode','Lucida Grande',sans-serif;color:#636363; max-width:340px; min-height:300px; max-height:300px; overflow:auto; } #alvo ul {margin:0 0 0 5pt; padding:0 0 0 10pt;} #alvo ul li { padding-left:2pt; margin-bottom:3pt; list-style- image:url(../imagens/icones/pasta_setas/tree_folder_open.png); } #alvo ul li:hover {list-style- image:url(../imagens/icones/pasta_setas/tree_folder_open_hover.png);} #alvo ul li a {text-decoration:none;color:#636363; margin-right:3pt;} #alvo .FolderClosed {list-style- image:url(../imagens/icones/pasta_setas/tree_folder_closed.png);} #alvo .FolderClosed:hover {list-style- image:url(../imagens/icones/pasta_setas/tree_folder_closed_hover.png); } #alvo .SemSubPastas, #alvo .SemSubPastas:hover {list-style:none;} #alvo input[type=text] { /color:#636363; padding:0; margin:0; border:1pt solid 636363;/ background:url(../imagens/fundo_form.png) repeat; color:#959595; font-size:9pt; border:none; padding:5pt; margin-bottom:7pt; } #txtPesquisarTreeView {margin-bottom:7pt;}
var p1 = rootPastas.AdicionarPasta('Pasta 1', ''); var sb1 = p1.AdicionarSubPasta('Subp1', ''); var sbsb1 = sb1.AdicionarSubPasta('SubSubp1', ''); var sb2 = p1.AdicionarSubPasta('Subp2', 'idSubPS2');
var p2 = rootPastas.AdicionarPasta('Pasta 2', '');
var p3 = rootPastas.AdicionarPasta('Dados de acesso', ''); var sb3_1 = p3.AdicionarSubPasta('Subp3.1', '3.1'); var sb3_1_1 = sb3_1.AdicionarSubPasta('Subp3.1.1', '3.1.1');
//adicionar em uma posição especifica var spAdd = rootPastas.AdicionarPastaPosicao('idSubPS2', 'Adicionado por id', '');
funcoesAuxiliares.RePrint(); //--------------------------------------------- //function pt(tx){document.getElementById('alvo').innerHTML += tx+'';} function pa(tx){document.getElementById('txa').value = tx;}