add bootstrap
authorAlan Knowles <alan@roojs.com>
Fri, 10 Jan 2014 01:45:01 +0000 (09:45 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 10 Jan 2014 01:45:01 +0000 (09:45 +0800)
12 files changed:
Roo/bootstrap/Body.js [new file with mode: 0644]
Roo/bootstrap/Column.js [new file with mode: 0644]
Roo/bootstrap/Component.js [new file with mode: 0644]
Roo/bootstrap/Container.js [new file with mode: 0644]
Roo/bootstrap/Navbar.Dropdown.Item.js [new file with mode: 0644]
Roo/bootstrap/Navbar.Dropdown.js [new file with mode: 0644]
Roo/bootstrap/Navbar.Item.js [new file with mode: 0644]
Roo/bootstrap/Navbar.js [new file with mode: 0644]
Roo/bootstrap/Row.js [new file with mode: 0644]
examples/bootstrap [deleted file]
roojs-all.js
roojs-debug.js

diff --git a/Roo/bootstrap/Body.js b/Roo/bootstrap/Body.js
new file mode 100644 (file)
index 0000000..5a84949
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * - LGPL
+ *
+ * page contgainer.
+ * 
+ */ 
+Roo.bootstrap.Body = function(config){
+    Roo.bootstrap.Body.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component,  {
+      
+       autoCreate : {
+        cls: 'container'
+    },
+    onRender : function(ct, position){
+        this.el = Roo.get(document.body);
+        
+        //this.el.addClass([this.fieldClass, this.cls]);
+        
+    }
+    
+    
+   
+});
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Column.js b/Roo/bootstrap/Column.js
new file mode 100644 (file)
index 0000000..0d12fc2
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * - LGPL
+ *
+ * column
+ * 
+ */ 
+Roo.bootstrap.Column = function(config){
+    Roo.bootstrap.Column.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component,  {
+      
+    colspan : 6,
+    
+       autoCreate : {
+        cls: 'column'
+    },
+    
+    getAutoCreate : function(){
+        var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
+        cfg.cls += 'col-md-' + this.colspan;
+        return cfg;
+    },
+   
+});
+
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Component.js b/Roo/bootstrap/Component.js
new file mode 100644 (file)
index 0000000..1247474
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * - LGPL
+ *
+ * base class for bootstrap elements..
+ * 
+ */
+Roo.bootstrap = Roo.bootstrap || {};
+Roo.bootstrap.Component = function(config){
+    Roo.bootstrap.Component.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent,  {
+      
+        
+    autoCreate : false,
+    
+    initEvents : function() {  },
+    // private
+    onRender : function(ct, position){
+        Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
+        if(!this.el){
+            var cfg = Roo.apply({},  this.getAutoCreate());
+            cfg.id = Roo.id();
+            //if(!cfg.name){
+            //    cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
+            //}
+            //if (!cfg.name.length) {
+            //    delete cfg.name;
+           // }
+            if (this.cls) {
+                cfg.cls += ' ' + this.cls;
+            }
+            if (this.style) {
+                cfg.style = this.style;
+            }
+            this.el = ct.createChild(cfg, position);
+        }
+        //var type = this.el.dom.type;
+         
+        if(this.tabIndex !== undefined){
+            this.el.dom.setAttribute('tabIndex', this.tabIndex);
+        }
+        this.initEvents();
+        //this.el.addClass([this.fieldClass, this.cls]);
+        
+    },
+    getChildContainer : function()
+    {
+        return this.el;
+    },
+    
+    addxtype : function (tree) {
+        var cn = this;
+        if (tree.xtype != 'Body') {
+            var tt = Roo.apply({}, tree);
+            delete tt.items;
+            cn = Roo.factory(tree);
+            cn.onRender(this.getChildContainer());
+            // then add the element..
+        }
+        if (!tree.items || !tree.items.length) {
+            return this;
+        }
+        // add the items..
+        for(var i =0;i < tree.items.length;i++) {
+            cn.addxtype(Roo.apply({}, tree.items[i]));
+            
+        }
+        return this;
+    }
+    
+     
+    
+});
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Container.js b/Roo/bootstrap/Container.js
new file mode 100644 (file)
index 0000000..85c13ca
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * - LGPL
+ *
+ * page contgainer.
+ * 
+ */ 
+Roo.bootstrap.Container = function(config){
+    Roo.bootstrap.Container.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component,  {
+      
+       autoCreate : {
+        cls: 'container',
+        html : null
+    },
+    getAutoCreate : function(){
+        
+        var cfg = Roo.apply({}, Roo.bootstrap.Container.superclass.getAutoCreate.call(this));
+        
+        cfg.html = this.html || cfg.html;
+        return cfg;
+    }
+   
+});
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Navbar.Dropdown.Item.js b/Roo/bootstrap/Navbar.Dropdown.Item.js
new file mode 100644 (file)
index 0000000..014224c
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * - LGPL
+ *
+ * row
+ * 
+ */ 
+Roo.bootstrap.Navbar.Dropdown.Item = function(config){
+    Roo.bootstrap.Navbar.Dropdown.Item.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Navbar.Dropdown.Item, Roo.bootstrap.Component,  {
+      
+       href : false,
+    html : false,
+    
+    autoCreate : {
+       // cls: '',
+        tag : 'li',
+        cn : [
+            {
+                tag : 'a',
+                href : '#',
+                html : 'Link'
+            }
+        ]
+    },
+    
+    getAutoCreate : function(){
+        
+        var cfg = Roo.apply({}, Roo.bootstrap.Navbar.Dropdown.Item.superclass.getAutoCreate.call(this));
+        cfg.cn[0].href = this.href || cfg.cn[0].href ;
+        cfg.cn[0].html = this.html || cfg.cn[0].html ;
+        return cfg;
+    }
+   
+});
+
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Navbar.Dropdown.js b/Roo/bootstrap/Navbar.Dropdown.js
new file mode 100644 (file)
index 0000000..71f2da7
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * - LGPL
+ *
+ * row
+ * 
+ */ 
+Roo.bootstrap.Navbar.Dropdown = function(config){
+    Roo.bootstrap.Navbar.Dropdown.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Navbar.Dropdown, Roo.bootstrap.Component,  {
+      
+        
+    html : false,
+    
+    autoCreate : {
+        cls: 'dropdown',
+        tag : 'li',
+        cn : [
+            {
+                tag : 'a',
+                href : '#',
+                cls : 'dropdown-toggle',
+                'data-toggle' : 'dropdown',
+                cn : [
+                    'Link',
+                    {
+                        tag: 'strong',
+                        cls : 'caret'
+                    },
+                    
+                ]
+                
+            },
+            {
+                tag : 'ul',
+                cls : 'dropdown-menu',
+                
+            }
+        ]
+    },
+    
+    getChildContainer : function() {
+        return this.el.select('ul', true).first();
+    },
+    
+    getAutoCreate : function(){
+        var cfg = Roo.bootstrap.Navbar.Dropdown.superclass.getAutoCreate.call(this);
+          
+        cfg.cn[0].cn[0] = this.html || cfg.cn[0].cn[0];
+        return cfg;
+    },
+    initEvents : function() {
+        Roo.log("ADD event");
+        Roo.log(this.el.dom);
+        this.el.on('click', this.toggle, this);
+        
+    },
+    toggle  : function(e)
+    {
+        Roo.log(e.getTarget());
+        Roo.log(this.el.dom);
+        if (Roo.get(e.getTarget()).findParent('ul.dropdown-menu')) {
+            return;
+        }
+        var isActive = this.el.hasClass('open');
+        // if disabled.. ingore
+        this.clearMenus(e);
+        //if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
+         // if mobile we use a backdrop because click events don't delegate
+        // $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
+        // }
+       //var relatedTarget = { relatedTarget: this }
+       //$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
+       //if (e.isDefaultPrevented()) return;
+        
+       this.el.toggleClass('open');
+       
+       //  .trigger('shown.bs.dropdown', relatedTarget)
+       this.el.focus();
+       Roo.log(e);
+       e.preventDefault(); 
+        
+        
+    },
+    clearMenus : function()
+    {
+        //$(backdrop).remove()
+        this.el.select('a.dropdown-toggle',true).each(function(aa) {
+            if (!aa.hasClass('open')) {
+                return;
+            }
+            // triger close...
+            aa.removeClass('open');
+          //var parent = getParent($(this))
+          //var relatedTarget = { relatedTarget: this }
+          
+           //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
+          //if (e.isDefaultPrevented()) return
+           //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
+        })
+    }
+    
+   
+});
+
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Navbar.Item.js b/Roo/bootstrap/Navbar.Item.js
new file mode 100644 (file)
index 0000000..7c5989f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * - LGPL
+ *
+ * row
+ * 
+ */ 
+Roo.bootstrap.Navbar.Item = function(config){
+    Roo.bootstrap.Navbar.Item.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Navbar.Item, Roo.bootstrap.Component,  {
+      
+       href : false,
+    html : false,
+    
+    autoCreate : {
+        cls: 'nav navbar-nav',
+        tag : 'li',
+        cn : [
+            {
+                tag : 'a',
+                href : '#',
+                html : 'Link'
+            }
+        ]
+    },
+    
+    getAutoCreate : function(){
+        
+        var cfg = Roo.apply({}, Roo.bootstrap.Navbar.Item.superclass.getAutoCreate.call(this));
+        cfg.cn[0].href = this.href || cfg.cn[0].href ;
+        cfg.cn[0].html = this.html || cfg.cn[0].html ;
+        return cfg;
+    }
+   
+});
+
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Navbar.js b/Roo/bootstrap/Navbar.js
new file mode 100644 (file)
index 0000000..8b3d70a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * - LGPL
+ *
+ * row
+ * 
+ */ 
+Roo.bootstrap.Navbar = function(config){
+    Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component,  {
+      
+       autoCreate : {
+        cls: 'navbar navbar-default',
+        tag : 'nav',
+        role : 'navigation',
+        cn : [
+            {
+                cls: 'nav navbar-nav',
+                tag : 'ul'
+            }
+        
+        ]
+    },
+    getChildContainer : function() {
+        return this.el.select('ul', true).first();
+    },
+   
+});
+
+
\ No newline at end of file
diff --git a/Roo/bootstrap/Row.js b/Roo/bootstrap/Row.js
new file mode 100644 (file)
index 0000000..aff7fa5
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * - LGPL
+ *
+ * row
+ * 
+ */ 
+Roo.bootstrap.Row = function(config){
+    Roo.bootstrap.Row.superclass.constructor.call(this, config);
+};
+
+Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component,  {
+      
+       autoCreate : {
+        cls: 'row clearfix'
+    }
+   
+});
+
+
\ No newline at end of file
diff --git a/examples/bootstrap b/examples/bootstrap
deleted file mode 100644 (file)
index e69de29..0000000
index e3fb6e9..678e241 100644 (file)
@@ -306,8 +306,8 @@ A.on(this.id,"touchstart",this.handleMouseDown,this);},initTarget:function(id,C,
 this.id=id;this.addToGroup((C)?C:"default");this.handleElId=id;this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();this.handleOnAvailable();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(C,D,E,F){if(!D&&0!==D){this.padding=[C,C,C,C];}else if(!E&&0!==E){this.padding=[C,D,C,D];}else {this.padding=[C,D,E,F];}},setInitPosition:function(C,D){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;}var dx=C||0;var dy=D||0;var p=B.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(C){var p=C||B.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(C){this.groups[C]=true;this.DDM.regDragDrop(this,C);},removeFromGroup:function(C){if(this.groups[C]){delete this.groups[C];}
 this.DDM.removeDDFromGroup(this,C);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){if(typeof id!=="string"){id=Roo.id(id);}
 this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){if(typeof id!=="string"){id=Roo.id(id);}
-A.on(id,"mousedown",this.handleMouseDown,this);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){A.un(this.id,"mousedown",this.handleMouseDown);A.un(this.id,"touchstart",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},destroy:function(){this.unreg();},isLocked:function(){return (this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,C){Roo.log(this);Roo.log(e);if(!Roo.isTouch&&this.primaryButtonOnly&&e.button!=0){Roo.log('not touch/ button !=0');return;}if(this.isLocked()){Roo.log('locked');return;}
-this.DDM.refreshCache(this.groups);Roo.log([Roo.lib.Event.getPageX(e),Roo.lib.Event.getPageY(e)]);var pt=new Roo.lib.Point(Roo.lib.Event.getPageX(e),Roo.lib.Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){Roo.log('no outer handes or not over target');}else {Roo.log('check validator');if(this.clickValidator(e)){Roo.log('validate success');this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else {}}},clickValidator:function(e){var C=e.getTarget();return (this.isValidHandleChild(C)&&(this.id==this.handleElId||this.DDM.handleWasClicked(C,this.id)));},addInvalidHandleType:function(C){var D=C.toUpperCase();this.invalidHandleTypes[D]=D;},addInvalidHandleId:function(id){if(typeof id!=="string"){id=Roo.id(id);}
+A.on(id,"mousedown",this.handleMouseDown,this);this.setHandleElId(id);this.hasOuterHandles=true;},unreg:function(){A.un(this.id,"mousedown",this.handleMouseDown);A.un(this.id,"touchstart",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},destroy:function(){this.unreg();},isLocked:function(){return (this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,C){Roo.log(this);Roo.log(e);if(!Roo.isTouch&&this.primaryButtonOnly&&e.button!=0){return;}if(ev.browserEvent.touches&&ev.browserEvent.touches.length!=1){return;}if(this.isLocked()){return;}
+this.DDM.refreshCache(this.groups);Roo.log([Roo.lib.Event.getPageX(e),Roo.lib.Event.getPageY(e)]);var pt=new Roo.lib.Point(Roo.lib.Event.getPageX(e),Roo.lib.Event.getPageY(e));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(pt,this)){}else {Roo.log('check validator');if(this.clickValidator(e)){Roo.log('validate success');this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}else {}}},clickValidator:function(e){var C=e.getTarget();return (this.isValidHandleChild(C)&&(this.id==this.handleElId||this.DDM.handleWasClicked(C,this.id)));},addInvalidHandleType:function(C){var D=C.toUpperCase();this.invalidHandleTypes[D]=D;},addInvalidHandleId:function(id){if(typeof id!=="string"){id=Roo.id(id);}
 this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(C){this.invalidHandleClasses.push(C);},removeInvalidHandleType:function(C){var D=C.toUpperCase();delete this.invalidHandleTypes[D];},removeInvalidHandleId:function(id){if(typeof id!=="string"){id=Roo.id(id);}delete this.invalidHandleIds[id];},removeInvalidHandleClass:function(C){for(var i=0,D=this.invalidHandleClasses.length;i<D;++i){if(this.invalidHandleClasses[i]==C){delete this.invalidHandleClasses[i];}}},isValidHandleChild:function(C){var D=true;var E;try{E=C.nodeName.toUpperCase();}catch(e){E=C.nodeName;}
 D=D&&!this.invalidHandleTypes[E];D=D&&!this.invalidHandleIds[C.id];for(var i=0,F=this.invalidHandleClasses.length;D&&i<F;++i){D=!B.hasClass(C,this.invalidHandleClasses[i]);}return D;},setXTicks:function(C,D){this.xTicks=[];this.xTickSize=D;var E={};for(var i=this.initPageX;i>=this.minX;i=i-D){if(!E[i]){this.xTicks[this.xTicks.length]=i;E[i]=true;}}for(i=this.initPageX;i<=this.maxX;i=i+D){if(!E[i]){this.xTicks[this.xTicks.length]=i;E[i]=true;}}
 this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(C,D){this.yTicks=[];this.yTickSize=D;var E={};for(var i=this.initPageY;i>=this.minY;i=i-D){if(!E[i]){this.yTicks[this.yTicks.length]=i;E[i]=true;}}for(i=this.initPageY;i<=this.maxY;i=i+D){if(!E[i]){this.yTicks[this.yTicks.length]=i;E[i]=true;}}
index 724a7de..a6f5c7d 100644 (file)
@@ -15780,12 +15780,16 @@ Roo.extend(Roo.dd.DragDrop, Roo.util.Observable , {
         Roo.log(this);
         Roo.log(e);
         if (!Roo.isTouch && this.primaryButtonOnly && e.button != 0) {
-            Roo.log('not touch/ button !=0');
+            //Roo.log('not touch/ button !=0');
             return;
         }
+        if (ev.browserEvent.touches && ev.browserEvent.touches.length != 1) {
+            return; // double touch..
+        }
+        
 
         if (this.isLocked()) {
-            Roo.log('locked');
+            //Roo.log('locked');
             return;
         }
 
@@ -15793,7 +15797,7 @@ Roo.extend(Roo.dd.DragDrop, Roo.util.Observable , {
         Roo.log([Roo.lib.Event.getPageX(e), Roo.lib.Event.getPageY(e)]);
         var pt = new Roo.lib.Point(Roo.lib.Event.getPageX(e), Roo.lib.Event.getPageY(e));
         if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) )  {
-            Roo.log('no outer handes or not over target');
+            //Roo.log('no outer handes or not over target');
                 // do nothing.
         } else {
             Roo.log('check validator');