← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 469: Checkbox behaviour fixed.

 

------------------------------------------------------------
revno: 469
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-08-01 00:22:28 +0700
message:
  Checkbox behaviour fixed.
added:
  gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/checkbox_or.css
  gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/examples.css
  gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples/
  gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples/examples.js
modified:
  gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js
  gis/dhis-web-mapping/src/main/webapp/mapping/geostat/index.html


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-07-14 11:53:04 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js	2009-07-31 17:22:28 +0000
@@ -39,6 +39,107 @@
         onShow: Ext.form.TriggerField.superclass.onShow,
         onHide: Ext.form.TriggerField.superclass.onHide
     });
+    
+    Ext.override(Ext.form.Checkbox, {
+	onRender: function(ct, position){
+		Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
+		if(this.inputValue !== undefined){
+			this.el.dom.value = this.inputValue;
+		}
+		//this.el.addClass('x-hidden');
+		this.innerWrap = this.el.wrap({
+			//tabIndex: this.tabIndex,
+			cls: this.baseCls+'-wrap-inner'
+		});
+		this.wrap = this.innerWrap.wrap({cls: this.baseCls+'-wrap'});
+		this.imageEl = this.innerWrap.createChild({
+			tag: 'img',
+			src: Ext.BLANK_IMAGE_URL,
+			cls: this.baseCls
+		});
+		if(this.boxLabel){
+			this.labelEl = this.innerWrap.createChild({
+				tag: 'label',
+				htmlFor: this.el.id,
+				cls: 'x-form-cb-label',
+				html: this.boxLabel
+			});
+		}
+		//this.imageEl = this.innerWrap.createChild({
+			//tag: 'img',
+			//src: Ext.BLANK_IMAGE_URL,
+			//cls: this.baseCls
+		//}, this.el);
+		if(this.checked){
+			this.setValue(true);
+		}else{
+			this.checked = this.el.dom.checked;
+		}
+		this.originalValue = this.checked;
+	},
+	afterRender: function(){
+		Ext.form.Checkbox.superclass.afterRender.call(this);
+		//this.wrap[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
+		this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
+	},
+	initCheckEvents: function(){
+		//this.innerWrap.removeAllListeners();
+		this.innerWrap.addClassOnOver(this.overCls);
+		this.innerWrap.addClassOnClick(this.mouseDownCls);
+		this.innerWrap.on('click', this.onClick, this);
+		//this.innerWrap.on('keyup', this.onKeyUp, this);
+	},
+	onFocus: function(e) {
+		Ext.form.Checkbox.superclass.onFocus.call(this, e);
+		//this.el.addClass(this.focusCls);
+		this.innerWrap.addClass(this.focusCls);
+	},
+	onBlur: function(e) {
+		Ext.form.Checkbox.superclass.onBlur.call(this, e);
+		//this.el.removeClass(this.focusCls);
+		this.innerWrap.removeClass(this.focusCls);
+	},
+	onClick: function(e){
+		if (e.getTarget().htmlFor != this.el.dom.id) {
+			if (e.getTarget() !== this.el.dom) {
+				this.el.focus();
+			}
+			if (!this.disabled && !this.readOnly) {
+				this.toggleValue();
+			}
+		}
+		//e.stopEvent();
+	},
+	onEnable: Ext.form.Checkbox.superclass.onEnable,
+	onDisable: Ext.form.Checkbox.superclass.onDisable,
+	onKeyUp: undefined,
+	setValue: function(v) {
+		var checked = this.checked;
+		this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
+		if(this.rendered){
+			this.el.dom.checked = this.checked;
+			this.el.dom.defaultChecked = this.checked;
+			//this.wrap[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
+			this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
+		}
+		if(checked != this.checked){
+			this.fireEvent("check", this, this.checked);
+			if(this.handler){
+				this.handler.call(this.scope || this, this, this.checked);
+			}
+		}
+	},
+	getResizeEl: function() {
+		//if(!this.resizeEl){
+			//this.resizeEl = Ext.isSafari ? this.wrap : (this.wrap.up('.x-form-element', 5) || this.wrap);
+		//}
+		//return this.resizeEl;
+		return this.wrap;
+	}
+    });
+    Ext.override(Ext.form.Radio, {
+        checkedCls: 'x-form-radio-checked'
+    });
 
     myMap: null;
     map = new OpenLayers.Map($('olmap'));
@@ -1366,23 +1467,50 @@
                             
                             Ext.Ajax.request(
                             {
-                                url: path + 'setMapSourceTypeUserSetting' + type,
+                                url: path + 'getMapSourceTypeUserSetting' + type,
                                 method: 'POST',
-                                params: { mapSourceType: msv },
 
                                 success: function( responseObject )
                                 {
-                                    Ext.messageBlack.msg('Map source', msg_highlight_start + msrw + msg_highlight_end + ' was saved as map source.');
-
-                                    MAPSOURCE = msv;
-                                    Ext.getCmp('map_cb').getStore().reload();
-                                    Ext.getCmp('maps_cb').getStore().reload();
+                                    if (Ext.util.JSON.decode(responseObject.responseText).mapSource == msv)
+                                    {
+                                        Ext.messageRed.msg('Map source', msg_highlight_start + msrw + msg_highlight_end + ' is already selected.');
+                                    }
+                                    else
+                                    {
+                                        Ext.Ajax.request(
+                                        {
+                                            url: path + 'setMapSourceTypeUserSetting' + type,
+                                            method: 'POST',
+                                            params: { mapSourceType: msv },
+
+                                            success: function( responseObject )
+                                            {
+                                                Ext.messageBlack.msg('Map source', msg_highlight_start + msrw + msg_highlight_end + ' is saved as map source.');
+
+                                                MAPSOURCE = msv;
+                                                
+                                                Ext.getCmp('map_cb').getStore().reload();
+                                                Ext.getCmp('maps_cb').getStore().reload();
+                                                Ext.getCmp('mapview_cb').getStore().reload();
+
+                                                Ext.getCmp('map_cb').reset();
+                                                Ext.getCmp('mapview_cb').reset();
+                                            },
+                                            failure: function()
+                                            {
+                                                alert( 'Status', 'Error while saving data' );
+                                            }
+                                        });
+                                    }
                                 },
                                 failure: function()
                                 {
                                     alert( 'Status', 'Error while saving data' );
                                 }
                             });
+                            
+                            
                         }
                     }
                 }

=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/index.html'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/index.html	2009-07-13 11:45:16 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/index.html	2009-07-31 17:22:28 +0000
@@ -12,7 +12,7 @@
     <link rel="stylesheet" type="text/css" href="../../mfbase/ext-community-extensions/color-field.css" />
     <link rel="stylesheet" type="text/css" href="../../mfbase/ext-community-extensions/multiselect.css" />
     <link rel="stylesheet" type="text/css" href="../../mfbase/ext/resources/css/examples.css" />
-    
+    <link rel="stylesheet" type="text/css" href="../../mfbase/ext/resources/css/checkbox_or.css" />    
 
     <script type="text/javascript" src="../../mfbase/ext/adapter/ext/ext-base.js"></script>
     <script type="text/javascript" src="../../mfbase/ext/ext-all.js"></script>

=== added file 'gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/checkbox_or.css'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/checkbox_or.css	1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/checkbox_or.css	2009-07-31 17:22:28 +0000
@@ -0,0 +1,20 @@
+<style type="text/css">
+.x-form-check-group .x-form-check-wrap,.x-form-radio-group .x-form-radio-wrap{height:auto;}
+.ext-ie .x-form-check-group .x-form-check-wrap,.ext-ie .x-form-radio-group .x-form-radio-wrap{height:auto;}
+.x-form-check-wrap,.x-form-radio-wrap{padding:1px 0 3px;line-height:18px;}
+.ext-ie .x-form-check-wrap,.ext-ie .x-form-radio-wrap{padding-top:3px;}
+.ext-strict .ext-ie7 .x-form-check-wrap,.ext-strict .ext-ie7 .x-form-radio-wrap{padding-bottom:1px;}
+.x-form-check-wrap-inner,.x-form-radio-wrap-inner{display:inline;padding:0;}
+.x-form-check,.x-form-radio{height:13px;width:13px;vertical-align:bottom;margin:2px 0;}
+.ext-ie .x-form-check,.ext-ie .x-form-radio{margin-top:1px;}
+.ext-strict .ext-ie7 .x-form-check,.ext-strict .ext-ie7 .x-form-radio{margin-bottom:4px;}
+.ext-opera .x-form-check,.ext-opera .x-form-radio{margin-top:3px;}
+.x-form-check-focus .x-form-check,.x-form-check-over .x-form-check,.x-form-check-focus .x-form-radio,.x-form-check-over .x-form-radio{background-position:-13px 0;}
+.x-form-check-down .x-form-check,.x-form-check-down .x-form-radio{background-position:-26px 0;}
+.x-item-disabled .x-form-check,.x-item-disabled .x-form-radio{background-position:-39px 0;}
+.x-form-check-checked,.x-form-radio-checked{background-position:0 -13px;}
+.x-form-check-focus .x-form-check-checked,.x-form-check-over .x-form-check-checked,.x-form-check-focus .x-form-radio-checked,.x-form-check-over .x-form-radio-checked{background-position:-13px -13px;}
+.x-form-check-down .x-form-check-checked,.x-form-check-down .x-form-radio-checked{background-position:-26px -13px;}
+.x-item-disabled .x-form-check-checked,.x-item-disabled .x-form-radio-checked{background-position:-39px -13px;}
+.x-form-check-wrap-inner input,.x-form-radio-wrap-inner input{position:absolute;-ms-filter:"alpha(opacity=0)";filter:alpha(opacity=0);-moz-opacity:0;opacity:0;}
+</style>
\ No newline at end of file

=== added file 'gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/examples.css'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/examples.css	1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/ext/resources/css/examples.css	2009-07-31 17:22:28 +0000
@@ -0,0 +1,68 @@
+/*
+ * Ext JS Library 2.2
+ * Copyright(c) 2006-2008, Ext JS, LLC.
+ * licensing@xxxxxxxxx
+ * 
+ * http://extjs.com/license
+ */
+body {
+	font-family:helvetica,tahoma,verdana,sans-serif;
+	padding:20px;
+    padding-top:32px;
+    font-size:13px;
+	background-color:#fff !important;
+}
+h1 {
+	font-size:large;
+	margin-bottom:20px;
+}
+h2 {
+	font-size:14px;
+    color:#333;
+    font-weight:bold;
+    margin:10px 0;
+}
+h3 {
+    font-size:16px;
+    color:#111111;
+    letter-spacing:1px;
+}
+h4 {
+    font-size:16px;
+    color:red;
+    letter-spacing:1px;
+}
+
+.example-info{
+	width:150px;
+	border:1px solid #c3daf9;
+	border-top:1px solid #DCEAFB;
+	border-left:1px solid #DCEAFB;
+	background:#ecf5fe url( info-bg.gif ) repeat-x;
+	font-size:10px;
+	padding:8px;
+}
+pre.code{
+	background: #F8F8F8;
+	border: 1px solid #e8e8e8;
+	padding:10px;
+	margin:10px;
+	margin-left:0px;
+	border-left:5px solid #e8e8e8;
+	font-size: 12px !important;
+	line-height:14px !important;
+}
+.msg .x-box-mc {
+    font-size:14px;
+    letter-spacing:1px;
+}
+#msg-div {
+    position:absolute;
+    left:35%;
+    top:10px;
+    width:250px;
+    z-index:20000;
+}
+.x-grid3-row-body p {
+    margin:5px 5px 10px 5px !important;
+}

=== added directory 'gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples'
=== added file 'gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples/examples.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples/examples.js	1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/ext/source/examples/examples.js	2009-07-31 17:22:28 +0000
@@ -0,0 +1,140 @@
+Ext.messageBlack = function(){
+    var msgCt;
+
+    function createBox(t, s){
+        return ['<div class="msg">',
+                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
+                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
+                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
+                '</div>'].join('');
+    }
+    
+    return {
+        msg : function(title, format){
+            if(!msgCt){
+                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
+            }
+            msgCt.alignTo(document, 't-t');
+            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
+            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
+            m.slideIn('t').pause(3).ghost("t", {remove:true});
+        },
+        
+        init : function(){
+            var t = Ext.get('exttheme');
+            if(!t){ // run locally?
+                return;
+            }
+            var theme = Cookies.get('exttheme') || 'aero';
+            if(theme){
+                t.dom.value = theme;
+                Ext.getBody().addClass('x-'+theme);
+            }
+            t.on('change', function(){
+                Cookies.set('exttheme', t.getValue());
+                setTimeout(function(){
+                    window.location.reload();
+                }, 250);
+            });
+
+            var lb = Ext.get('lib-bar');
+            if(lb){
+                lb.show();
+            }
+        }
+    };
+}();
+
+Ext.messageRed = function(){
+    var msgCt;
+
+    function createBox(t, s){
+        return ['<div class="msg">',
+                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
+                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h4>', t, '</h4>', s, '</div></div></div>',
+                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
+                '</div>'].join('');
+    }
+    
+    return {
+        msg : function(title, format){
+            if(!msgCt){
+                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
+            }
+            msgCt.alignTo(document, 't-t');
+            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
+            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
+            m.slideIn('t').pause(3).ghost("t", {remove:true});
+        },
+        
+        init : function(){
+            var t = Ext.get('exttheme');
+            if(!t){ // run locally?
+                return;
+            }
+            var theme = Cookies.get('exttheme') || 'aero';
+            if(theme){
+                t.dom.value = theme;
+                Ext.getBody().addClass('x-'+theme);
+            }
+            t.on('change', function(){
+                Cookies.set('exttheme', t.getValue());
+                setTimeout(function(){
+                    window.location.reload();
+                }, 250);
+            });
+
+            var lb = Ext.get('lib-bar');
+            if(lb){
+                lb.show();
+            }
+        }
+    };
+}();
+
+Ext.messageNone = function(){
+    var msgCt;
+
+    function createBox(t, s){
+        return ['<div class="msg">',
+                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
+                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">', s, '</div></div></div>',
+                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
+                '</div>'].join('');
+    }
+    
+    return {
+        msg : function(title, format){
+            if(!msgCt){
+                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
+            }
+            msgCt.alignTo(document, 't-t');
+            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
+            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
+            m.slideIn('t').pause(3).ghost("t", {remove:true});
+        },
+        
+        init : function(){
+            var t = Ext.get('exttheme');
+            if(!t){ // run locally?
+                return;
+            }
+            var theme = Cookies.get('exttheme') || 'aero';
+            if(theme){
+                t.dom.value = theme;
+                Ext.getBody().addClass('x-'+theme);
+            }
+            t.on('change', function(){
+                Cookies.set('exttheme', t.getValue());
+                setTimeout(function(){
+                    window.location.reload();
+                }, 250);
+            });
+
+            var lb = Ext.get('lib-bar');
+            if(lb){
+                lb.show();
+            }
+        }
+    };
+}();
\ No newline at end of file