]> 91.132.146.200 Git - klimbim.git/commitdiff
html tree demo. window.onload was missing and replace $A function with new one
authorBanana <banana@starscream.de>
Mon, 1 Aug 2011 08:35:52 +0000 (10:35 +0200)
committerBanana <banana@starscream.de>
Mon, 1 Aug 2011 08:35:52 +0000 (10:35 +0200)
javascript/mif-tree/Demos/HTMLTree/demo.css [new file with mode: 0755]
javascript/mif-tree/Demos/HTMLTree/demo.js [new file with mode: 0755]
javascript/mif-tree/Demos/HTMLTree/index.html [new file with mode: 0755]
javascript/mif-tree/Demos/index.html

diff --git a/javascript/mif-tree/Demos/HTMLTree/demo.css b/javascript/mif-tree/Demos/HTMLTree/demo.css
new file mode 100755 (executable)
index 0000000..8f363ae
--- /dev/null
@@ -0,0 +1,293 @@
+.warning{
+background-color:#ad4b3a;
+color:#e0e93f;
+margin:20px;
+font-weight:bold;
+font-size:16px;
+padding-left:2em;
+}
+
+
+#tree_container{
+height:300px;
+margin:0 20px;
+position:relative;
+border:solid 1px #c7c7c7;
+}
+
+.mif-tree-wrapper{
+font-family:verdana;
+font-size:11px;
+}
+
+.mif-tree-name{
+margin-left:0;
+padding-left:4px;
+}
+
+.tag-close{
+
+}
+
+.attr-value{
+color:#e9441b;
+}
+
+.value{
+color:#000;
+}
+
+.mif-tree-wrapper span.tag{
+cursor:pointer;
+}
+
+.mif-tree-wrapper .mif-tree-gadjet{
+cursor:default;
+}
+
+.mif-tree-empty-icon{
+padding-right:0;
+}
+
+.mif-tree-hover-gadjet .mif-tree-name, .mif-tree-hover-name .mif-tree-name, .mif-tree-hover-icon .mif-tree-name{
+color:blue;
+
+}
+
+
+/*@global*/
+
+.mif-tree-wrapper{
+position: absolute;
+width: 100%;
+height:100%;
+margin:0;
+padding:0;
+overflow:auto;
+font-family:Tahoma;
+color:#3147e6;
+font-size:11px;
+line-height:18px;/******Tree node height******/
+white-space:nowrap;
+cursor:default;
+}
+
+.mif-tree-bg{
+width:100%;
+height:100%;
+position:absolute;
+overflow:hidden;
+}
+
+.mif-tree-bg-container{
+width:100%;
+display:none;
+}
+
+.mif-tree-bg-node{
+width:100%;
+height:18px;
+}
+
+.mif-tree-bg-selected{
+background-color:#dcd7ab;
+}
+
+.mif-tree-wrapper:focus{
+outline:0;
+}
+
+.mif-tree-wrapper span{
+padding-bottom:2px;
+padding-top:2px;
+cursor:text;
+}
+
+.mif-tree-children{
+padding-left: 25px;
+width:auto;
+}
+
+.mif-tree-node{
+/*background:url('../assets/images/line.gif') repeat-y 8px 0px;*/
+}
+
+.mif-tree-node-last{
+/*background:url('../assets/images/line.gif') no-repeat 8px 0px;*/
+}
+
+.mif-tree-name{
+cursor: default;
+overflow:hidden;
+margin-left:0px;
+}
+
+.mif-tree-name a{
+color:red;
+}
+
+.mif-tree-name a:hover{
+color:blue;
+}
+
+
+.mif-tree-node-wrapper{
+/*background:url('../assets/images/horizontal-line.gif') no-repeat 9px center;*/
+}
+
+/*@gadjets*/
+
+.mif-tree-gadjet{
+background-image:url('../assets/images/twistyGadjets.gif');
+padding-right: 16px;
+z-index:1;
+overflow:hidden;
+background-repeat:no-repeat;
+cursor:default;
+}
+
+.mif-tree-gadjet-none{
+background:none;
+}
+
+.mif-tree-gadjet-minus{
+background-position: 0px 50%;
+}
+
+.mif-tree-gadjet-plus{
+background-position: -18px 50%;
+}
+
+/*
+.mif-tree-gadjet-hover .mif-tree-gadjet-minus{
+background-position: -54px 50%;
+}
+
+.mif-tree-gadjet-hover .mif-tree-gadjet-plus{
+background-position: -72px 50%;
+}
+
+*/
+
+
+/*.mif-tree-gadjet-hover{
+background-image:url('../assets/images/gadjets-hover.gif');
+}*/
+
+
+
+
+/*@icons*/
+.mif-tree-icon{
+
+}
+
+
+/*@selection*/
+
+.mif-tree-node-selected .mif-tree-name{
+background-color: #010161;
+color:#fff;
+text-transform:italic;
+}
+
+.mif-tree-node-selected .attr-value, .mif-tree-node-selected .value{
+color:#fff;
+}
+/*@d'n'd*/
+.mif-tree-pointer{
+height:1px;
+overflow: hidden;
+position: absolute;
+background-image:url('../assets/images/1.gif');
+background-repeat:repeat-x;
+background-color:#292fef;
+}
+
+
+.mif-tree-ghost{
+background-color:#fff;
+border:solid 2px #e8e8f7;
+padding-left:2px;
+}
+
+.mif-tree-ghost .mif-tree-node-wrapper{
+background:none;
+}
+
+.mif-tree-ghost span.mif-tree-text{
+padding-top:1px;
+padding-bottom:1px;
+}
+
+.mif-tree-ghost-icon{
+padding-left:16px;
+background-color:#fff;
+background-repeat:no-repeat;
+background-image:url('../assets/images/dropzone.gif');
+}
+
+.mif-tree-ghost-after{
+background-position:-64px 2px;
+}
+
+.mif-tree-ghost-before{
+background-position:-48px 2px;
+}
+
+.mif-tree-ghost-between{
+background-position:-16px 2px;
+}
+
+.mif-tree-ghost-inside{
+background-position:-0px 2px;
+}
+
+.mif-tree-ghost-notAllowed{
+background-position:-32px 2px;
+}
+
+.mif-tree-drag-current{
+background-color:#cfcfd8;
+}
+
+.mif-tree-replace{
+background-color:#99c8fb;
+}
+
+
+/*@checkbox*/
+.mif-tree-checkbox{
+padding-left:18px;
+}
+
+.mif-tree-node-checked, .mif-tree-node-checked .mif-tree-checkbox{
+background:url('../assets/images/checked.gif') center 2px no-repeat;
+}
+
+.mif-tree-node-unchecked, .mif-tree-node-unchecked .mif-tree-checkbox{
+background:url('../assets/images/unchecked.gif') center 2px no-repeat;
+}
+
+.mif-tree-node-checked-selected{
+background:url('../assets/images/checked_selected.gif') center 2px no-repeat;
+}
+
+.mif-tree-node-unchecked-selected{
+background:url('../assets/images/unchecked_selected.gif') center 2px no-repeat;
+}
+
+
+
+/*@rename*/
+.mif-tree-rename{
+display: inline;
+line-height: 14px;
+height:14px;
+cursor: default;
+overflow:hidden;
+font-family:sans-serif;
+font-size:11px;
+padding:1px 0;
+border:solid 1px black;
+}
\ No newline at end of file
diff --git a/javascript/mif-tree/Demos/HTMLTree/demo.js b/javascript/mif-tree/Demos/HTMLTree/demo.js
new file mode 100755 (executable)
index 0000000..3b09534
--- /dev/null
@@ -0,0 +1,194 @@
+window.addEvent('domready',function(){
+Mif.Tree.implement({
+
+       getTarget: function(event){
+               var target = event.target;
+               var cls = target.className;
+               while(!(/mif-tree/).test(target.className)){
+                       target = target.parentNode;
+               }
+               var test = target.className.match(/mif-tree-(gadjet)-[^n]|mif-tree-(name)/);
+               if(!test){
+                       return {
+                               node: false,
+                               target: 'node'
+                       };
+               }
+               for(var i = 3; i > 0; i--){
+                       if(test[i]){
+                               var type = test[i];
+                               break;
+                       }
+               }
+               if(type == 'name' && cls != 'tag'){
+                       return {
+                               node: false,
+                               target: 'node'
+                       };
+               }
+               return {
+                       node: Mif.Tree.Nodes[target.getAttribute('uid')],
+                       target: type
+               };
+       }
+
+});
+
+
+Mif.Tree.Node.prototype.getNextVisible_ = Mif.Tree.Node.prototype.getNextVisible;
+Mif.Tree.Node.prototype.getPreviousVisible_ = Mif.Tree.Node.prototype.getPreviousVisible;
+
+Mif.Tree.Node.implement({
+
+       hide: function(){
+               this.state.hidden = true;
+               this.getDOM('node').style.display = 'none';
+       },
+       
+       show: function(){
+               this.state.hidden = false;
+               this.getDOM('node').style.display = 'block';
+       },
+       
+       isHide: function(){
+               return this.state.hidden;
+       },
+       
+       getNextVisible: function(){
+               var node = this;
+               do{
+                       node = node.getNextVisible_();
+                       if(!node) return false;
+               }while(node.isHide())
+               return node;
+       },
+       
+       getPreviousVisible: function(){
+               var node = this;
+               do{
+                       node = node.getPreviousVisible_();
+                       if(!node) return false;
+               }while(node.isHide())
+               return node;
+       }
+
+});
+
+
+Mif.Tree.KeyNav.implement({
+
+       goForward: function(current){
+               var forward = current;
+               do{
+                       forward = forward.getNextVisible();
+                       if(!forward) return;
+               }while(forward.type == 'close');
+               if( forward ) this.tree.select(forward);
+       },
+       
+       goBack: function(current){
+               var back = current;
+               do{
+                       back = back.getPreviousVisible();
+                       if(!back) return;
+               }while(back.type == 'close');
+               if (back) this.tree.select(back);
+       }
+
+});
+
+
+
+DOMTree = new Mif.Tree({
+       container: $('tree_container'),
+       forest: true,
+       types: {
+               open:{
+                       cls: 'tag-open',
+                       loadable: true
+               },
+               close:{
+                       loadable: false,
+                       cls: 'tag-close'
+               }
+       },
+       dfltType: 'open',
+       height: 18,
+       initialize: function(){
+               new Mif.Tree.KeyNav(this);
+       },
+       onToggle: function(node, state){
+               var next = node.getNext();
+               if(!next) return;
+               next[state ? 'show' : 'hide']();
+       },
+       onDrawChildren: function(parent){
+               parent.children.each(function(child){
+                       if(child.type != 'close') return;
+                       child.hide();
+               });
+       },
+       onSelect: function(node){
+               if(node.type == 'close'){
+                       node.tree.select(node.getPrevious());
+               }
+               this.wrapper.focus();
+       }
+})
+.load({
+       json: [{
+               property: {
+                       name: '&lt;<span class="tag">html</span>&gt;'
+               },
+               data:{
+                       el: $(document.documentElement)
+               }
+       },
+       {
+               property: {
+                       name: '&lt;/<span class="tag">html</span>&gt;'
+               },
+               type: 'close'
+       }]
+});
+DOMTree.loadOptions = function(node){
+       var json = [];
+       var el = node.data.el;
+       el.getChildren().each(function(child){
+               var attrs = '';
+               Array.from(child.attributes).each(function(attr){
+                       attrs += " " + attr.nodeName + '="<span class="attr-value">' + attr.nodeValue + '</span>"';
+               });
+               var hasChildren = child.getChildren().length > 0;
+               var name;
+               if(!hasChildren){
+                       var text = child.firstChild ? child.firstChild.nodeValue : '';
+                       name = '&lt;<span class="tag">' + child.get('tag') + '</span>' + attrs + '&gt;<span class="value">' + text +  '</span>&lt;/<span class="tag">' + child.get('tag') + '</span>&gt;';
+                       var loadable = false;
+               }else{
+                       name = '&lt;<span class="tag">' + child.get('tag') + '</span>' + attrs + '&gt;';
+                       loadable = true;
+               }
+               json.push({
+                       property: {
+                               name: name,
+                               loadable: loadable
+                       },
+                       data: {
+                               el: child
+                       }
+               });
+               json.push({
+                       property: {
+                               name: '&lt;/<span class="tag">' + child.get('tag') + '</span>&gt;'
+                       },
+                       type: 'close'
+               });
+       });
+       return {json: json};
+};
+
+if(Browser.ie){
+       (new Element('div', {styles:{color: 'red', fontSize: '20px', paddingLeft: '20px'}}).set('html', 'LOL IE')).inject($('tree_container'),'before');
+};
+});
\ No newline at end of file
diff --git a/javascript/mif-tree/Demos/HTMLTree/index.html b/javascript/mif-tree/Demos/HTMLTree/index.html
new file mode 100755 (executable)
index 0000000..e45b63b
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+       <link rel="stylesheet" href="../assets/styles/demos.css" type="text/css" />
+       <link rel="stylesheet" href="demo.css" type="text/css" />
+       <script type="text/javascript" src="../../mootools-core-1.3.2-full-nocompat.js"></script>
+       <script type="text/javascript" src="../../mootools-more-1.3.2.1.js"></script>
+       <script type="text/javascript" src="../../mif.tree_for-mt-1.3.2.js"></script>
+       <script type="text/javascript" src="demo.js"></script>
+       <title>Mif.Tree DOM Tree Demo</title>
+</head>
+<body>
+       <h1>DOM Tree example</h1>
+       <div id="tree_container"></div>
+       <p>
+               <a href="../index.html">Back</a>
+       </p>
+</body>
+</html>
index 7f01fd06d20a2e3f32f09fec49edf15c26cff5a1..040d149b2a42e69610735a57c40e1ec982cd51a6 100755 (executable)
@@ -27,6 +27,7 @@
                                        <li><a href="IconUrl/index.html">set icon using url instead class</a></li>
                                        <li><a href="">File Tree ( left since it requires a webserver )</a></li>
                                        <li><a href="DOMTree/index.html">DOM Tree</a></li>
+                                       <li><a href="HTMLTree/index.html">HTML Tree</a></li>
                                </ul>
                        </div>
                        <div id="footer">