pari: branch 2.0 r4271 - /branches/2.0/config/js/astman.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Wed Dec 3 11:19:57 CST 2008


Author: pari
Date: Wed Dec  3 11:19:57 2008
New Revision: 4271

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4271
Log:

 ASTGUI.TABLE() function to easily manipulation of Rows & Cells in a table



Modified:
    branches/2.0/config/js/astman.js

Modified: branches/2.0/config/js/astman.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=4271&r1=4270&r2=4271
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Wed Dec  3 11:19:57 2008
@@ -657,6 +657,13 @@
 	customObject : function(){
 		//	eliminates the need of 'hasOwnProperty' to read this objects propeties, look for this objects prototype below.
 		if ( !(this instanceof ASTGUI.customObject) ) { return new ASTGUI.customObject(); }
+	},
+
+	TABLE : function(a){
+		if(!a) return;
+		if ( !(this instanceof ASTGUI.TABLE) ) { return new ASTGUI.TABLE(a); }
+		this.TableElement = ( typeof a == 'string' ) ? _$(a) : a ;
+		this.TableRow = null ;
 	},
 
 	toCustomObject : function(a){// if a is a native object returns an ASTGUI.customObject version of a
@@ -2621,6 +2628,44 @@
 	}
 };
 
+ASTGUI.TABLE.prototype = {
+
+	addRow: function( e , rowindex ){ // Usage: 'TABLE'.addRow({className : 'alt'});
+		var TBL = this.TableElement ;
+		var newRow = (typeof rowindex == 'number' ) ? TBL.insertRow(rowindex) : TBL.insertRow(-1) ;
+		if( !!e ){
+			if( e.hasOwnProperty('className') ){
+				if(e.className == 'alt'){
+					newRow.className = ((TBL.rows.length)%2==1) ? 'odd':'even';
+				}else{
+					newRow.className = e.className ;
+				}
+				delete e.className;
+			}
+			for( f in e ){
+				if( !e.hasOwnProperty(f) ) continue;
+				newRow.f = e[f] ;
+			}
+		}
+		this.TableRow = newRow ;
+	},
+
+	addCell: function( C ){ // Usage: 'TABLE'.addCell({ html: 'newCell Text', align:'center', width:'20px' });
+		var el = this.TableRow ;
+		ASTGUI.domActions.tr_addCell( el, C );
+	},
+
+	clear : function(){ // Usage: 'TABLE'.clear()
+		var el = this.TableElement ;
+		ASTGUI.domActions.clear_table(el);
+	},
+
+	rowCount : function(){
+		var el = this.TableElement ;
+		return el.rows.length;
+	}
+};
+
 var makeRequest = function( params){ // for making Asynchronus requests
 	// usage ::  makeRequest ( { action :'getconfig', filename: 'something.conf', callback:callbackfunction() } )
 	var cb = params.callback ; delete params.callback;




More information about the asterisk-gui-commits mailing list