jsm

net/sf/jsm/table/util/jsmTableEvents.js

Summary

Some table events Regarding _xxxDelegate methods: Because in Internet Explorer you can not simply set an event handler attribute on a node (it will not be executed) I created the delegates to avoid closures. One can set attributes on any model-object, eg. xxx.setAttribute('onclick', 'alert("lala")). The addAttributesToViewComponent method of JsmObject will see those attributes and not set them on the node but set the appropriate delgate method on the respective event handler of the node. The delegate method will then get the value from the models-attibute and eval() it.


Method Summary
static private  void _jsmOnChangeEventDelegate(e)
           Will be called by for on change events; retrieves the attached model from the node object
static private  void _jsmOnClickEventDelegate(e)
           Will be called by for onclick-events; retrieves the attached model from the node object and then calls the attached onClickFunction handing over the appropriate arguments This is neccessary to avoid closures but still be able to hand over user friendly parameters and not let the user work with this.model
static private  void _jsmOnKeyUpEventDelegate(e)
           Will be called by for on key up events; retrieves the attached model from the node object
static private  void _jsmOnMouseDownEventDelegate(e)
           Will be called by for onmousedown-events; retrieves the attached model from the node object This is neccessary to avoid closures
static void _jsmOnMouseMoveEventDelegate(e)
          
static private  void _jsmOnMouseUpEventDelegate(e)
           Will be called by for onmouseup-events; retrieves the attached model from the node object This is neccessary to avoid closures
static void jsmOnTableCellClick(<JsmTable> table, <int> rowIdx, <int> columnIdx)
           The default event handler for a table data cell click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed
static void jsmOnTableHeaderClick(<JsmTable> table, <int> columnIdx)
           The default event handler for a table header cell click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed
static void jsmOnTableRowClick(<JsmTable> table, <int> rowIdx)
           The default event handler for a table row click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed

/**
 * @fileoverview Some table events
 * Regarding _xxxDelegate methods: Because in Internet Explorer you can not simply set an event handler attribute on a node
 * (it will not be executed)
 * I created the delegates to avoid closures. One can set attributes on any model-object, eg. xxx.setAttribute('onclick', 'alert("lala")).
 * The addAttributesToViewComponent method of JsmObject will see those attributes and not set them on the node but set the appropriate delgate 
 * method on the respective event handler of the node. The delegate method will then get the value from the models-attibute and eval() it.
 */
 
/**
 * The default event handler for a table header cell click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed
 * @param {JsmTable} table The table object
 * @param {int} columnIdx The index of the column  
 */   
  function jsmOnTableHeaderClick(table, columnIdx) {
  	table.sort(columnIdx);
  	table.render();
  } 
  
/**
 * The default event handler for a table data cell click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed
 * @param {JsmTable} table The table object
 * @param {int} rowIdx The index of the row
 * @param {int} columnIdx The index of the column  
 */   
  function jsmOnTableCellClick(table, rowIdx, columnIdx) {
  } 
  
/**
 * The default event handler for a table row click event (only called if the .setOnClick-method has not be used); define your own version of this function if needed
 * @param {JsmTable} table The table object
 * @param {int} rowIdx The index of the row
 */   
  function jsmOnTableRowClick(table, rowIdx) {
  }  

/**
 * Will be called by for onclick-events; retrieves the attached model from the node object and then
 * calls the attached onClickFunction handing over the appropriate arguments
 * This is neccessary to avoid closures but still be able to hand over user friendly parameters and
 * not let the user work with this.model
 * @private
 */
	function _jsmOnClickEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnClickEventDelegate: Handle onclick for " + model);			
		if (!jsm.noud(this.model.getAttribute('onclick'))) {eval(this.model.getAttribute('onclick'));}
					
		if (model.className == 'JsmTr') {
			eval(model.getOnClick()).call(this, model.getTable(), model.getIndex());
			return;
		}
		if (model.className == 'JsmTd' || model.className == 'JsmActionCell') {
			eval(model.getOnClick()).call(this, model.getRow().getTable(), model.getRow().getIndex(), model.getIndex());
			return;
		}	
		if (model.className == 'JsmTh') {
			eval(model.getOnClick()).call(this, model.getRow().getTable(), model.getIndex());
			return;
		}		
	}
	
/**
 * Will be called by for on key up events; retrieves the attached model from the node object
 * @private
 */	
	function _jsmOnKeyUpEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnKeyUpEventDelegate: Handle onkeyup for " + model);			
		if (!jsm.noud(this.model.getAttribute('onkeyup'))) {eval(this.model.getAttribute('onkeyup'));}		
	}
/**
 * Will be called by for on change events; retrieves the attached model from the node object
 * @private
 */		
	function _jsmOnChangeEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnChangeEventDelegate: Handle onchange for " + model);			
		if (!jsm.noud(this.model.getAttribute('onchange'))) {eval(this.model.getAttribute('onchange'));}		
	}			

/**
 * Will be called by for onmousedown-events; retrieves the attached model from the node object 
 * This is neccessary to avoid closures
 * @private
 */
	function _jsmOnMouseDownEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnMouseDownEventDelegate: Handle onmousedown for " + model);			
		if (!jsm.noud(this.model.getAttribute('onmousedown'))) {eval(this.model.getAttribute('onmousedown'));}	
	}

/**
 * Will be called by for onmouseup-events; retrieves the attached model from the node object 
 * This is neccessary to avoid closures
 * @private
 */	
	function _jsmOnMouseUpEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnMouseUpEventDelegate: Handle onmouseup for " + model);			
		if (!jsm.noud(this.model.getAttribute('onmouseup'))) {eval(this.model.getAttribute('onmouseup'));}	
	}	

 * Will be called by for onmousemove-events; retrieves the attached model from the node object 
 * This is neccessary to avoid closures
 * @private
 */	
	function _jsmOnMouseMoveEventDelegate(e) {
		var model = this.model;
		logger.debug("jsmOnMouseMoveEventDelegate: Handle onmousemove for " + model);			
		if (!jsm.noud(this.model.getAttribute('onmousemove'))) {eval(this.model.getAttribute('onmousemove'));}
						
		if (model.className == 'JsmTable') {
			if (jsm.resize && !jsm.noud(model._headerRow)) {	  		
		  		if (!e) {e=window.event;}
		 		var thModel = model._headerRow._cells[jsm.resizeColumn];
				if (!jsm.noud(thModel)) {					
					var thView=document.getElementById(thModel.getId());
					if (!jsm.noud(thView) && thView.width) {					
						if (jsm.resizeOriginalWidth==-1) {jsm.resizeOriginalWidth=thView.width;}
					  	var newWidth = jsm.resizeOriginalWidth - ((jsm.resizeStartX - e.screenX)*3);
					  	if (newWidth>0) {					  	
						  	thView.width=newWidth;
							thModel.setAttribute("width", newWidth);
						}
					}
				} 		
		  	}				
		}	
	}			 
   
      
  

jsm

Documentation generated by JSDoc on Tue Sep 26 08:42:57 2006