Histórico da Página
...
HTML |
---|
<div id="keyWordContainerDiv"></div> <style> .Keyword-Container-Wrapper{ width: 100%; height: auto; min-height: 30px; } .Keyword-Container-Wrapper-Span{ padding: 5px; background-color: #3572b0; color: #fff; } </style> <script> TOTVS_Keywords = { Id: 'KeyWord1', Container: null, Tags: [], Init: function(id, nameOfContainer, tags){ this.Id = id; this.Container = (typeof nameOfContainer === "string") ? document.getElementById(nameOfContainer) : nameOfContainer; this.Tags = { Length: (tags) ? tags.length: 0, Items: [], Add: function(item){ if(!item) return; if(!this.Exists(item)){ this.Items[this.Length] = []; this.Items[this.Length]['Value'] = item; this.Items[this.Length]['Index'] = this.Length; this.Items[item] = []; this.Items[item]['Value'] = item; this.Items[item]['Index'] = this.Length; this.Length += 1; } }, AddRange: function(rangeOfItems){ if(!rangeOfItems) return; for(var i = 0; i < rangeOfItems.length; i++){ if(!this.Exists(rangeOfItems[i])){ this.Items[this.Length] = []; this.Items[this.Length]['Value'] = rangeOfItems[i]; this.Items[this.Length]['Index'] = this.Length; this.Items[item] = []; this.Items[rangeOfItems[i]]['Value'] = rangeOfItems[i]; this.Items[rangeOfItems[i]]['Index'] = this.Length; this.Length += 1; } } }, Exists: function(item){ if(!item) return false; for(var att in this.Items){ if(att == item) return true; } return false; }, Find: function(item){ if(!item) return null; for(var att in this.Items){ if(att == item) return this.Items[item]; } return null; }, IndexOf: function(item){ if(!item) return null; var _item = this.Find(item); if(_item != null) return _item.Index; return null; } } this.Tags.AddRange(tags); }, Build: function(id, nameOfContainer, tags){ this.Init(id, nameOfContainer, tags); var _keyWordContainerWrapper = document.createElement('div'); _keyWordContainerWrapper.id = this.Id + "_ContainerWrapper"; _keyWordContainerWrapper.className = "Keyword-Container-Wrapper"; var _keyWordContainerWrapperInput = document.createElement('input'); _keyWordContainerWrapperInput.id = _keyWordContainerWrapper.id + "_Input"; _keyWordContainerWrapperInput.name = _keyWordContainerWrapperInput.id; _keyWordContainerWrapperInput.type = "text"; _keyWordContainerWrapperInput.className = 'Keyword-Container-Wrapper-Input'; _keyWordContainerWrapperInput.onkeypress = function(e){ var _evt = e || window.event; if (event.which == 13 || event.keyCode == 13) { TOTVS_Keywords.Tags.Add(this.value); var _index = TOTVS_Keywords.Tags.IndexOf(this.Value); var _span = document.createElement('span'); _span.id = this.id + "_" + (_index != null) ? _index : this.value; _span.name = _span.id; _span.className = 'Keyword-Container-Wrapper-Span'; _span.innerHTML = this.value; this.parentNode.insertBefore(_span, this); return false; } } _keyWordContainerWrapper.appendChild(_keyWordContainerWrapperInput); this.Container.appendChild(_keyWordContainerWrapper); } } TOTVS_Keywords.Build('TOTVS_KeyWord', 'keyWordContainerDiv', []) </script> |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas