webgui/www/extras/yui-ext/docs/overview-summary-EditorSelectionModel.js.html
JT Smith 4f68a0933c added YUI and YUI-ext
fixed the resizable text area with IE problem
fixed the ad space with IE problem
merged the 7.2.0 and 7.1.4 change logs
2006-11-07 23:15:57 +00:00

244 lines
12 KiB
HTML

<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
parent.document.title="EditorSelectionModel.js Overview";
}
</script>
</head>
<body bgcolor="white" onload="asd();" style="margin:15px;">
<center>
<h2>EditorSelectionModel.js</h2>
</center>
<h4>Summary</h4>
<p>
</p>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<td colspan="2" class="title-cell">
<b>Class Summary</b>
</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td width="15%"><b><a href="YAHOO.ext.grid.EditorAndSelectionModel.html">YAHOO.ext.grid.EditorAndSelectionModel</a></b></td>
<td>&nbsp;</td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td width="15%"><b><a href="YAHOO.ext.grid.EditorSelectionModel.html">YAHOO.ext.grid.EditorSelectionModel</a></b></td>
<td>Extends <a href="YAHOO.ext.grid.DefaultSelectionModel.html#">YAHOO.ext.grid.DefaultSelectionModel</a> to enable cell navigation.</td>
</tr>
</table>
<hr/>
<!-- ========== METHOD SUMMARY =========== -->
<!-- ========== END METHOD SUMMARY =========== -->
<pre class="sourceview">
<span class="comment">/**
<span class="attrib">@class</span> Extends {<span class="attrib">@link</span> YAHOO.ext.grid.DefaultSelectionModel} to enable cell navigation. &lt;br&gt;&lt;br&gt;
<span class="attrib">@extends</span> YAHOO.ext.grid.DefaultSelectionModel
<span class="attrib">@constructor</span>
*/</span>
YAHOO.ext.grid.EditorSelectionModel = <span class="reserved">function</span>(){
YAHOO.ext.grid.EditorSelectionModel.superclass.constructor.call(<span class="reserved">this</span>);
<span class="comment">/** Number of clicks to activate a cell (for editing) - valid values are 1 or 2
* <span class="attrib">@type</span> Number */</span>
<span class="reserved">this</span>.clicksToActivateCell = 1;
<span class="reserved">this</span>.events[<span class="literal">'cellactivate'</span>] = new YAHOO.util.CustomEvent(<span class="literal">'cellactivate'</span>);
};
YAHOO.extendX(YAHOO.ext.grid.EditorSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.disableArrowNavigation = false;
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.controlForArrowNavigation = false;
<span class="comment">/** <span class="attrib">@ignore</span> */</span>
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.initEvents = <span class="reserved">function</span>(){
<span class="reserved">this</span>.grid.addListener(<span class="literal">"cellclick"</span>, <span class="reserved">this</span>.onCellClick, <span class="reserved">this</span>, true);
<span class="reserved">this</span>.grid.addListener(<span class="literal">"celldblclick"</span>, <span class="reserved">this</span>.onCellDblClick, <span class="reserved">this</span>, true);
<span class="reserved">this</span>.grid.addListener(<span class="literal">"keydown"</span>, <span class="reserved">this</span>.keyDown, <span class="reserved">this</span>, true);
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.onCellClick = <span class="reserved">function</span>(grid, rowIndex, colIndex){
<span class="reserved">if</span>(<span class="reserved">this</span>.clicksToActivateCell == 1){
var row = <span class="reserved">this</span>.grid.getRow(rowIndex);
var cell = row.childNodes[colIndex];
<span class="reserved">if</span>(cell){
<span class="reserved">this</span>.activate(row, cell);
}
}
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.activate = <span class="reserved">function</span>(row, cell){
<span class="reserved">this</span>.fireEvent(<span class="literal">'cellactivate'</span>, <span class="reserved">this</span>, row, cell);
<span class="reserved">this</span>.grid.doEdit(row, cell);
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.onCellDblClick = <span class="reserved">function</span>(grid, rowIndex, colIndex){
<span class="reserved">if</span>(<span class="reserved">this</span>.clicksToActivateCell == 2){
var row = <span class="reserved">this</span>.grid.getRow(rowIndex);
var cell = row.childNodes[colIndex];
<span class="reserved">if</span>(cell){
<span class="reserved">this</span>.activate(row, cell);
}
}
};
<span class="comment">/** <span class="attrib">@ignore</span> */</span>
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.setRowState = <span class="reserved">function</span>(row, selected){
YAHOO.ext.grid.EditorSelectionModel.superclass.setRowState.call(<span class="reserved">this</span>, row, false, false);
};
<span class="comment">/** <span class="attrib">@ignore</span> */</span>
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.focusRow = <span class="reserved">function</span>(row, selected){
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.getEditorCellAfter = <span class="reserved">function</span>(cell, spanRows){
var g = <span class="reserved">this</span>.grid;
var next = g.getCellAfter(cell);
<span class="reserved">while</span>(next &amp;&amp; !g.colModel.isCellEditable(next.columnIndex)){
next = g.getCellAfter(next);
}
<span class="reserved">if</span>(!next &amp;&amp; spanRows){
var row = g.getRowAfter(g.getRowFromChild(cell));
next = g.getFirstCell(row);
<span class="reserved">if</span>(!g.colModel.isCellEditable(next.columnIndex)){
next = <span class="reserved">this</span>.getEditorCellAfter(next);
}
}
<span class="reserved">return</span> next;
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.getEditorCellBefore = <span class="reserved">function</span>(cell, spanRows){
var g = <span class="reserved">this</span>.grid;
var prev = g.getCellBefore(cell);
<span class="reserved">while</span>(prev &amp;&amp; !g.colModel.isCellEditable(prev.columnIndex)){
prev = g.getCellBefore(prev);
}
<span class="reserved">if</span>(!prev &amp;&amp; spanRows){
var row = g.getRowBefore(g.getRowFromChild(cell));
prev = g.getLastCell(row);
<span class="reserved">if</span>(!g.colModel.isCellEditable(prev.columnIndex)){
prev = <span class="reserved">this</span>.getEditorCellBefore(prev);
}
}
<span class="reserved">return</span> prev;
};
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.allowArrowNav = <span class="reserved">function</span>(e){
<span class="reserved">return</span> (!<span class="reserved">this</span>.disableArrowNavigation &amp;&amp; (!<span class="reserved">this</span>.controlForArrowNavigation || e.ctrlKey));
}
<span class="comment">/** <span class="attrib">@ignore</span> */</span>
YAHOO.ext.grid.EditorSelectionModel.<span class="reserved">prototype</span>.keyDown = <span class="reserved">function</span>(e){
var g = <span class="reserved">this</span>.grid, cm = g.colModel, cell = g.getEditingCell();
<span class="reserved">if</span>(!cell) <span class="reserved">return</span>;
var newCell;
switch(e.browserEvent.keyCode){
case e.TAB:
<span class="reserved">if</span>(e.shiftKey){
newCell = <span class="reserved">this</span>.getEditorCellBefore(cell, true);
}<span class="reserved">else</span>{
newCell = <span class="reserved">this</span>.getEditorCellAfter(cell, true);
}
break;
case e.DOWN:
<span class="reserved">if</span>(<span class="reserved">this</span>.allowArrowNav(e)){
var next = g.getRowAfter(g.getRowFromChild(cell));
<span class="reserved">if</span>(next){
newCell = next.childNodes[cell.columnIndex];
}
}
break;
case e.UP:
<span class="reserved">if</span>(<span class="reserved">this</span>.allowArrowNav(e)){
var prev = g.getRowBefore(g.getRowFromChild(cell));
<span class="reserved">if</span>(prev){
newCell = prev.childNodes[cell.columnIndex];
}
}
break;
case e.RETURN:
<span class="reserved">if</span>(e.shiftKey){
var prev = g.getRowBefore(g.getRowFromChild(cell));
<span class="reserved">if</span>(prev){
newCell = prev.childNodes[cell.columnIndex];
}
}<span class="reserved">else</span>{
var next = g.getRowAfter(g.getRowFromChild(cell));
<span class="reserved">if</span>(next){
newCell = next.childNodes[cell.columnIndex];
}
}
break;
case e.RIGHT:
<span class="reserved">if</span>(<span class="reserved">this</span>.allowArrowNav(e)){
newCell = <span class="reserved">this</span>.getEditorCellAfter(cell);
}
break;
case e.LEFT:
<span class="reserved">if</span>(<span class="reserved">this</span>.allowArrowNav(e)){
newCell = <span class="reserved">this</span>.getEditorCellBefore(cell);
}
break;
};
<span class="reserved">if</span>(newCell){
<span class="reserved">this</span>.activate(g.getRowFromChild(newCell), newCell);
e.stopEvent();
}
};
YAHOO.ext.grid.EditorAndSelectionModel = <span class="reserved">function</span>(){
YAHOO.ext.grid.EditorAndSelectionModel.superclass.constructor.call(<span class="reserved">this</span>);
<span class="reserved">this</span>.events[<span class="literal">'cellactivate'</span>] = new YAHOO.util.CustomEvent(<span class="literal">'cellactivate'</span>);
};
YAHOO.extendX(YAHOO.ext.grid.EditorAndSelectionModel, YAHOO.ext.grid.DefaultSelectionModel);
YAHOO.ext.grid.EditorAndSelectionModel.<span class="reserved">prototype</span>.initEvents = <span class="reserved">function</span>(){
YAHOO.ext.grid.EditorAndSelectionModel.superclass.initEvents.call(<span class="reserved">this</span>);
<span class="reserved">this</span>.grid.addListener(<span class="literal">"celldblclick"</span>, <span class="reserved">this</span>.onCellDblClick, <span class="reserved">this</span>, true);
};
YAHOO.ext.grid.EditorAndSelectionModel.<span class="reserved">prototype</span>.onCellDblClick = <span class="reserved">function</span>(grid, rowIndex, colIndex){
var row = <span class="reserved">this</span>.grid.getRow(rowIndex);
var cell = row.childNodes[colIndex];
<span class="reserved">if</span>(cell){
<span class="reserved">this</span>.fireEvent(<span class="literal">'cellactivate'</span>, <span class="reserved">this</span>, row, cell);
<span class="reserved">this</span>.grid.doEdit(row, cell);
}
}; </pre>
<hr>
<hr>
<font size="-1">
</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sat Oct 14 06:07:10 2006</div>
</body>
</html>