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
This commit is contained in:
parent
6bf329d68d
commit
4f68a0933c
1026 changed files with 331404 additions and 60 deletions
297
www/extras/yui-ext/docs/overview-summary-XMLDataModel.js.html
Normal file
297
www/extras/yui-ext/docs/overview-summary-XMLDataModel.js.html
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
<!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="XMLDataModel.js Overview";
|
||||
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body bgcolor="white" onload="asd();" style="margin:15px;">
|
||||
<center>
|
||||
|
||||
<h2>XMLDataModel.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.XMLDataModel.html">YAHOO.ext.grid.XMLDataModel</a></b></td>
|
||||
<td>This is an implementation of a DataModel used by the Grid.</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<hr/>
|
||||
|
||||
|
||||
<!-- ========== METHOD SUMMARY =========== -->
|
||||
|
||||
<!-- ========== END METHOD SUMMARY =========== -->
|
||||
|
||||
|
||||
<pre class="sourceview">
|
||||
<span class="comment">/**
|
||||
* <span class="attrib">@class</span>
|
||||
* This is an implementation of a DataModel used by the Grid. It works
|
||||
* with XML data.
|
||||
* <br>Example schema from Amazon search:
|
||||
* <pre><code>
|
||||
* var schema = {
|
||||
* tagName: 'Item',
|
||||
* id: 'ASIN',
|
||||
* fields: ['Author', 'Title', 'Manufacturer', 'ProductGroup']
|
||||
* };
|
||||
* </code></pre>
|
||||
* <span class="attrib">@extends</span> YAHOO.ext.grid.LoadableDataModel
|
||||
* <span class="attrib">@constructor</span>
|
||||
* <span class="attrib">@param</span> {Object} schema The schema to use
|
||||
* <span class="attrib">@param</span> {XMLDocument} xml An XML document to load immediately
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel = <span class="reserved">function</span>(schema, xml){
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.constructor.call(<span class="reserved">this</span>, YAHOO.ext.grid.LoadableDataModel.XML);
|
||||
<span class="comment">/**<span class="attrib">@private</span>*/</span>
|
||||
<span class="reserved">this</span>.schema = schema;
|
||||
<span class="reserved">this</span>.xml = xml;
|
||||
<span class="reserved">if</span>(xml){
|
||||
<span class="reserved">this</span>.loadData(xml);
|
||||
}
|
||||
};
|
||||
YAHOO.extendX(YAHOO.ext.grid.XMLDataModel, YAHOO.ext.grid.LoadableDataModel);
|
||||
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.getDocument = <span class="reserved">function</span>(){
|
||||
<span class="reserved">return</span> <span class="reserved">this</span>.xml;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Overrides loadData in LoadableDataModel to process XML
|
||||
* <span class="attrib">@param</span> {XMLDocument} doc The document to load
|
||||
* <span class="attrib">@param</span> {<i>Function</i>} callback (optional) callback to call when loading is complete
|
||||
* <span class="attrib">@param</span> {<i>Boolean</i>} keepExisting (optional) true to keep existing data
|
||||
* <span class="attrib">@param</span> {<i>Number</i>} insertIndex (optional) if present, loaded data is inserted at the specified index instead of overwriting existing data
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.loadData = <span class="reserved">function</span>(doc, callback, keepExisting, insertIndex){
|
||||
<span class="reserved">this</span>.xml = doc;
|
||||
var idField = <span class="reserved">this</span>.schema.id;
|
||||
var fields = <span class="reserved">this</span>.schema.fields;
|
||||
<span class="reserved">if</span>(<span class="reserved">this</span>.schema.totalTag){
|
||||
<span class="reserved">this</span>.totalCount = null;
|
||||
var totalNode = doc.getElementsByTagName(<span class="reserved">this</span>.schema.totalTag);
|
||||
<span class="reserved">if</span>(totalNode && totalNode.item(0) && totalNode.item(0).firstChild) {
|
||||
var v = parseInt(totalNode.item(0).firstChild.nodeValue, 10);
|
||||
<span class="reserved">if</span>(!isNaN(v)){
|
||||
<span class="reserved">this</span>.totalCount = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
var rowData = [];
|
||||
var nodes = doc.getElementsByTagName(<span class="reserved">this</span>.schema.tagName);
|
||||
<span class="reserved">if</span>(nodes && nodes.length > 0) {
|
||||
<span class="reserved">for</span>(var i = 0; i < nodes.length; i++) {
|
||||
var node = nodes.item(i);
|
||||
var colData = [];
|
||||
colData.node = node;
|
||||
colData.id = <span class="reserved">this</span>.getNamedValue(node, idField, String(i));
|
||||
<span class="reserved">for</span>(var j = 0; j < fields.length; j++) {
|
||||
var val = <span class="reserved">this</span>.getNamedValue(node, fields[j], <span class="literal">""</span>);
|
||||
<span class="reserved">if</span>(<span class="reserved">this</span>.preprocessors[j]){
|
||||
val = <span class="reserved">this</span>.preprocessors[j](val);
|
||||
}
|
||||
colData.push(val);
|
||||
}
|
||||
rowData.push(colData);
|
||||
}
|
||||
}
|
||||
<span class="reserved">if</span>(keepExisting !== true){
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.removeAll.call(<span class="reserved">this</span>);
|
||||
}
|
||||
<span class="reserved">if</span>(typeof insertIndex != <span class="literal">'number'</span>){
|
||||
insertIndex = <span class="reserved">this</span>.getRowCount();
|
||||
}
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.insertRows.call(<span class="reserved">this</span>, insertIndex, rowData);
|
||||
<span class="reserved">if</span>(typeof callback == <span class="literal">'function'</span>){
|
||||
callback(<span class="reserved">this</span>, true);
|
||||
}
|
||||
<span class="reserved">this</span>.fireLoadEvent();
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Adds a row to this DataModel and syncs the XML document
|
||||
* <span class="attrib">@param</span> {String} id The id of the row, if null the next row index is used
|
||||
* <span class="attrib">@param</span> {Array} cellValues The cell values for this row
|
||||
* <span class="attrib">@return</span> {Number} The index of the new row
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.addRow = <span class="reserved">function</span>(id, cellValues){
|
||||
var newIndex = <span class="reserved">this</span>.getRowCount();
|
||||
var node = <span class="reserved">this</span>.createNode(<span class="reserved">this</span>.xml, id, cellValues);
|
||||
cellValues.id = id || newIndex;
|
||||
cellValues.node = node;
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.addRow.call(<span class="reserved">this</span>, cellValues);
|
||||
<span class="reserved">return</span> newIndex;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Inserts a row into this DataModel and syncs the XML document
|
||||
* <span class="attrib">@param</span> {Number} index The index to insert the row
|
||||
* <span class="attrib">@param</span> {String} id The id of the row, if null the next row index is used
|
||||
* <span class="attrib">@param</span> {Array} cellValues The cell values for this row
|
||||
* <span class="attrib">@return</span> {Number} The index of the new row
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.insertRow = <span class="reserved">function</span>(index, id, cellValues){
|
||||
var node = <span class="reserved">this</span>.createNode(<span class="reserved">this</span>.xml, id, cellValues);
|
||||
cellValues.id = id || <span class="reserved">this</span>.getRowCount();
|
||||
cellValues.node = node;
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.insertRow.call(<span class="reserved">this</span>, index, cellValues);
|
||||
<span class="reserved">return</span> index;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Removes the row from DataModel and syncs the XML document
|
||||
* <span class="attrib">@param</span> {Number} index The index of the row to remove
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.removeRow = <span class="reserved">function</span>(index){
|
||||
var node = <span class="reserved">this</span>.data[index].node;
|
||||
node.parentNode.removeChild(node);
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.removeRow.call(<span class="reserved">this</span>, index, index);
|
||||
};
|
||||
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.getNode = <span class="reserved">function</span>(rowIndex){
|
||||
<span class="reserved">return</span> <span class="reserved">this</span>.data[rowIndex].node;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Override this method to define your own node creation routine for when new rows are added.
|
||||
* By default this method clones the first node and sets the column values in the newly cloned node.
|
||||
* <span class="attrib">@param</span> {XMLDocument} xmlDoc The xml document being used by this model
|
||||
* <span class="attrib">@param</span> {Array} colData The column data for the new node
|
||||
* <span class="attrib">@return</span> {XMLNode} The created node
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.createNode = <span class="reserved">function</span>(xmlDoc, id, colData){
|
||||
var template = <span class="reserved">this</span>.data[0].node;
|
||||
var newNode = template.cloneNode(true);
|
||||
var fields = <span class="reserved">this</span>.schema.fields;
|
||||
<span class="reserved">for</span>(var i = 0; i < fields.length; i++){
|
||||
var nodeValue = colData[i];
|
||||
<span class="reserved">if</span>(<span class="reserved">this</span>.postprocessors[i]){
|
||||
nodeValue = <span class="reserved">this</span>.postprocessors[i](nodeValue);
|
||||
}
|
||||
<span class="reserved">this</span>.setNamedValue(newNode, fields[i], nodeValue);
|
||||
}
|
||||
<span class="reserved">if</span>(id){
|
||||
<span class="reserved">this</span>.setNamedValue(newNode, <span class="reserved">this</span>.schema.idField, id);
|
||||
}
|
||||
template.parentNode.appendChild(newNode);
|
||||
<span class="reserved">return</span> newNode;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Convenience function looks for value in attributes, then in children tags - also
|
||||
* normalizes namespace matches (ie matches ns:tag, FireFox matches tag and not ns:tag).
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.getNamedValue = <span class="reserved">function</span>(node, name, defaultValue){
|
||||
<span class="reserved">if</span>(!node || !name){
|
||||
<span class="reserved">return</span> defaultValue;
|
||||
}
|
||||
var nodeValue = defaultValue;
|
||||
var attrNode = node.attributes.getNamedItem(name);
|
||||
<span class="reserved">if</span>(attrNode) {
|
||||
nodeValue = attrNode.value;
|
||||
} <span class="reserved">else</span> {
|
||||
var childNode = node.getElementsByTagName(name);
|
||||
<span class="reserved">if</span>(childNode && childNode.item(0) && childNode.item(0).firstChild) {
|
||||
nodeValue = childNode.item(0).firstChild.nodeValue;
|
||||
}<span class="reserved">else</span>{
|
||||
<span class="comment">// try to strip namespace for FireFox</span>
|
||||
var index = name.indexOf(<span class="literal">':'</span>);
|
||||
<span class="reserved">if</span>(index > 0){
|
||||
<span class="reserved">return</span> <span class="reserved">this</span>.getNamedValue(node, name.substr(index+1), defaultValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="reserved">return</span> nodeValue;
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Convenience function set a value in the underlying xml node.
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.setNamedValue = <span class="reserved">function</span>(node, name, value){
|
||||
<span class="reserved">if</span>(!node || !name){
|
||||
<span class="reserved">return</span>;
|
||||
}
|
||||
var attrNode = node.attributes.getNamedItem(name);
|
||||
<span class="reserved">if</span>(attrNode) {
|
||||
attrNode.value = value;
|
||||
<span class="reserved">return</span>;
|
||||
}
|
||||
var childNode = node.getElementsByTagName(name);
|
||||
<span class="reserved">if</span>(childNode && childNode.item(0) && childNode.item(0).firstChild) {
|
||||
childNode.item(0).firstChild.nodeValue = value;
|
||||
}<span class="reserved">else</span>{
|
||||
<span class="comment">// try to strip namespace for FireFox</span>
|
||||
var index = name.indexOf(<span class="literal">':'</span>);
|
||||
<span class="reserved">if</span>(index > 0){
|
||||
<span class="reserved">this</span>.setNamedValue(node, name.substr(index+1), value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Overrides DefaultDataModel.setValueAt to update the underlying XML Document
|
||||
* <span class="attrib">@param</span> {Object} value The new value
|
||||
* <span class="attrib">@param</span> {Number} rowIndex
|
||||
* <span class="attrib">@param</span> {Number} colIndex
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.setValueAt = <span class="reserved">function</span>(value, rowIndex, colIndex){
|
||||
var node = <span class="reserved">this</span>.data[rowIndex].node;
|
||||
<span class="reserved">if</span>(node){
|
||||
var nodeValue = value;
|
||||
<span class="reserved">if</span>(<span class="reserved">this</span>.postprocessors[colIndex]){
|
||||
nodeValue = <span class="reserved">this</span>.postprocessors[colIndex](value);
|
||||
}
|
||||
<span class="reserved">this</span>.setNamedValue(node, <span class="reserved">this</span>.schema.fields[colIndex], nodeValue);
|
||||
}
|
||||
YAHOO.ext.grid.XMLDataModel.superclass.setValueAt.call(<span class="reserved">this</span>, value, rowIndex, colIndex);
|
||||
};
|
||||
|
||||
<span class="comment">/**
|
||||
* Overrides getRowId in DefaultDataModel to return the ID value of the specified node.
|
||||
* <span class="attrib">@param</span> {Number} rowIndex
|
||||
* <span class="attrib">@return</span> {Number}
|
||||
*/</span>
|
||||
YAHOO.ext.grid.XMLDataModel.<span class="reserved">prototype</span>.getRowId = <span class="reserved">function</span>(rowIndex){
|
||||
<span class="reserved">return</span> <span class="reserved">this</span>.data[rowIndex].id;
|
||||
};</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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue