﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>IT博客-yunshichen-随笔分类-Yahoo YUI</title><link>http://www.cnitblog.com/yunshichen/category/7660.html</link><description>我相信人生是值得活的,尽管人在一生中必须遭受痛苦,卑劣,残酷,不幸和死亡的折磨,我依然深信如此.但我认为人生不一定要有意义,只是对一些人而言,他们可以使人生有意义.  ---J 赫胥黎</description><language>zh-cn</language><lastBuildDate>Mon, 26 Sep 2011 14:16:52 GMT</lastBuildDate><pubDate>Mon, 26 Sep 2011 14:16:52 GMT</pubDate><ttl>60</ttl><item><title>YUI datatable 源码</title><link>http://www.cnitblog.com/yunshichen/archive/2009/10/30/test_yui_dt.html</link><dc:creator>Chenyunshi</dc:creator><author>Chenyunshi</author><pubDate>Fri, 30 Oct 2009 05:49:00 GMT</pubDate><guid>http://www.cnitblog.com/yunshichen/archive/2009/10/30/test_yui_dt.html</guid><wfw:comment>http://www.cnitblog.com/yunshichen/comments/62266.html</wfw:comment><comments>http://www.cnitblog.com/yunshichen/archive/2009/10/30/test_yui_dt.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yunshichen/comments/commentRss/62266.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yunshichen/services/trackbacks/62266.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Java:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->package org.diegochen.yuitut.base.controller;import java.io.PrintWriter;import java.util.List;imp...&nbsp;&nbsp;<a href='http://www.cnitblog.com/yunshichen/archive/2009/10/30/test_yui_dt.html'>阅读全文</a><img src ="http://www.cnitblog.com/yunshichen/aggbug/62266.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yunshichen/" target="_blank">Chenyunshi</a> 2009-10-30 13:49 <a href="http://www.cnitblog.com/yunshichen/archive/2009/10/30/test_yui_dt.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>YUI 第一篇 : Yahoo global object 翻译</title><link>http://www.cnitblog.com/yunshichen/archive/2008/10/09/50022.html</link><dc:creator>Chenyunshi</dc:creator><author>Chenyunshi</author><pubDate>Thu, 09 Oct 2008 09:25:00 GMT</pubDate><guid>http://www.cnitblog.com/yunshichen/archive/2008/10/09/50022.html</guid><wfw:comment>http://www.cnitblog.com/yunshichen/comments/50022.html</wfw:comment><comments>http://www.cnitblog.com/yunshichen/archive/2008/10/09/50022.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cnitblog.com/yunshichen/comments/commentRss/50022.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yunshichen/services/trackbacks/50022.html</trackback:ping><description><![CDATA[
		<br />
		<b>
				<font size="5" color="#006400">简介</font>
		</b>
		<br />
		<br />Yahoo global object 提供namespace机制和封装了一些好用的方法. js名称为yahoo.js ,使用YUI前必须先引入这个js,且应该最先加载.<br /><br /><font color="#006400"><b><font size="5">源文件</font></b></font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">script </span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="text/javascript"</span><span style="color: rgb(255, 0, 0);"> src</span><span style="color: rgb(0, 0, 255);">="http://yui.yahooapis.com/2.6.0/build/yahoo/yahoo-min.js"</span><span style="color: rgb(255, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">&gt;&lt;/</span><span style="color: rgb(128, 0, 0);">script</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br />常用方法列举如下:<br /><ul><li><a href="http://developer.yahoo.com/yui/yahoo/#namespace">YAHOO.namespace</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#lang">YAHOO.lang</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#hasOwnProperty">YAHOO.lang.hasOwnProperty</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#extend">YAHOO.lang.extend</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#augment">YAHOO.lang.augment</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#log">YAHOO.log</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#config">YAHOO_config and YAHOO.env</a></li><li><a href="http://developer.yahoo.com/yui/yahoo/#modulenames">YUI Module Names</a></li></ul><br /><h3 id="namespace"><b><font color="#006400">YAHOO.namespace</font></b></h3><br />避免js全局变量污染的好办法,用法如下:<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Creates a namespace for "myproduct1"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.namespace (</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">myproduct1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.myproduct1.Class1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    alert(info);<br />};<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Creates a namespace for "myproduct2", and for "mysubproject1"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.namespace (</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">myproduct2.mysubproject1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.myproduct2.mysubproject1.Class1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    alert(info);<br />};<br /></span></div><br /><h3 id="lang"><b><font color="#006400">YAHOO.lang</font></b><br /></h3><br />提供了一些简便易用方法,如下:<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true, an array literal is an array</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isArray([</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">]);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, an object literal is not an array</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isArray({</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">one</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">two</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">});<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> however, when declared as an array, it is true</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">() {<br />    </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> a </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Array();<br />    a[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">one</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">two</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> YAHOO.lang.isArray(a);<br />}();<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, a collection of elements is like an array, but isn't</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isArray(document.getElementsByTagName(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">body</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true, false is a boolean</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isBoolean(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, 1 and the string "true" are not booleans</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isBoolean(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.lang.isBoolean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">true</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> null is null, but false, undefined and "" are not</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNull(</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNull(undefined); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNull(</span><span style="color: rgb(0, 0, 0);">""</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> a function is a function, but an object is not</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isFunction(</span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(){}); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isFunction({foo: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">}); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true, ints and floats are numbers</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNumber(</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.lang.isNumber(</span><span style="color: rgb(0, 0, 0);">123.123</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, strings that can be cast to numbers aren't really numbers</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNumber(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">123.123</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, undefined numbers and infinity are not numbers we want to use</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isNumber(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true, objects, functions, and arrays are objects</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isObject({});<br />YAHOO.lang.isObject(</span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(){});<br />YAHOO.lang.isObject([</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">]);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false, primitives are not objects</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isObject(</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.lang.isObject(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">);<br />YAHOO.lang.isObject(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">{}</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> strings</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isString(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">{}</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isString({foo: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">}); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isString(</span><span style="color: rgb(0, 0, 0);">123</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isString(</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"> <br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> undefined is undefined, but null and false are not</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isUndefined(undefined); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> true</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isUndefined(</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.isUndefined(</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">); </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> false</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br /></span></div><br /><h3 id="hasOwnProperty"><b><font color="#006400">YAHOO.lang.hasOwnProperty</font></b></h3>检查某个对象是否有某属性<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> this is what we are protecting against</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">Object.prototype.myCustomFunction </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(x) {<br />    alert(x);<br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> o </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> {};<br />o[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">foo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bar</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />o[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">marco</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">] </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">polo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> this is where we need the protection</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> i </span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);"> o) {<br />    </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (YAHOO.lang.hasOwnProperty(o, i)) {<br />        alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">good key: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> i);<br />    } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br />        alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bad key: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> i);<br />    }<br />}<br /></span></div><br /><h3 id="extend"><b><font color="#006400">YAHOO.lang.extend</font></b></h3>提供了继承机制.(译者注:js使用继承还是有一定风险,建议酌情使用.)<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">YAHOO.namespace(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">test</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br />YAHOO.test.Class1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Class1: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> info);<br />};<br /><br />YAHOO.test.Class1.prototype.testMethod </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Class1: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> info);<br />};<br /><br />YAHOO.test.Class2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> chain the constructors</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    YAHOO.test.Class2.superclass.constructor.call(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">, info);<br />    alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Class2: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> info);<br />};<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> Class2 extends Class1.  Must be done immediately after the Class2 constructor</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.lang.extend(YAHOO.test.Class2, YAHOO.test.Class1);<br /><br />YAHOO.test.Class2.prototype.testMethod </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(info) {<br />    </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> chain the method</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">    YAHOO.test.Class2.superclass.testMethod.call(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">, info);<br />    alert(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Class2: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> info);<br />};<br /><br /></span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> class2Instance </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> YAHOO.test.Class2(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">constructor executed</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />class2Instance.testMethod(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">testMethod invoked</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span></div><br /><h3 id="augment"><b><font color="#006400">YAHOO.lang.augment</font></b></h3>将某个对象的prototype属性复制到另一个对象,代码重用的好方法.<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">&lt;!--</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">debugger</span><span style="color: rgb(0, 0, 0);"> output </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> environments without </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">console</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">--&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">div id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">consoleelement</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">div</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);"> The ConsoleProvider example will log to the console if available, or a </span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);"> div with id="consoleelement" if the console is not available</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.example.ConsoleProvider </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">() { };<br />YAHOO.example.ConsoleProvider.prototype </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> {<br />    log: </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">(msg) {<br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> use the error console if available (FF+FireBug or Safari)</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (</span><span style="color: rgb(0, 0, 255);">typeof</span><span style="color: rgb(0, 0, 0);"> console </span><span style="color: rgb(0, 0, 0);">!=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">undefined</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">) {<br />            console.log(msg);<br />        </span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"> write the msg to a well-known div element</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">        } </span><span style="color: rgb(0, 0, 255);">else</span><span style="color: rgb(0, 0, 0);"> {<br />            </span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> el </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> document.getElementById(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">consoleelement</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />            </span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);"> (el) {<br />                el.innerHTML </span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;p&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> msg </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&lt;/p&gt;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />            }<br />        }<br />    }<br />};<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);"> Define a class that should be able to write debug messages</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">YAHOO.example.ClassWithLogging </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">function</span><span style="color: rgb(0, 0, 0);">() { };<br />YAHOO.lang.augment(YAHOO.example.ClassWithLogging, YAHOO.example.ConsoleProvider);<br /><br /></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);"> Try it out</span><span style="color: rgb(0, 128, 0);"><br />//</span><span style="color: rgb(0, 128, 0);">//////////////////////////////////////////////////////////////////////////</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 255);">var</span><span style="color: rgb(0, 0, 0);"> c </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> YAHOO.example.ClassWithLogging();<br />c.log(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">worked</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br /></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">script</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span></div><br /><h3 id="log"><b><font color="#006400">YAHOO.log</font></b></h3>log工具,使用之前要先引入logger控件,如果没有引入,那么浏览器会忽略这条log语句.用这个东西使你免陷于开发时加alert,发布时四处删除alert的窘境.(注:当然,用firebug调试也可以避免alert问题.).<br /><br /><br /><font size="5" color="#006400">其他</font><br /><br />至于YAHOO.env 和 YAHOO.name 等,参考官方文档即可.<br /><br /><a href="http://developer.yahoo.com/yui/yahoo/">http://developer.yahoo.com/yui/yahoo/</a><br /><br /><br /><br /><br /><img src ="http://www.cnitblog.com/yunshichen/aggbug/50022.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yunshichen/" target="_blank">Chenyunshi</a> 2008-10-09 17:25 <a href="http://www.cnitblog.com/yunshichen/archive/2008/10/09/50022.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实战YUI 的  patinator(datatable) 组件</title><link>http://www.cnitblog.com/yunshichen/archive/2008/10/06/YUI_paginator_datatable_customize.html</link><dc:creator>Chenyunshi</dc:creator><author>Chenyunshi</author><pubDate>Mon, 06 Oct 2008 03:17:00 GMT</pubDate><guid>http://www.cnitblog.com/yunshichen/archive/2008/10/06/YUI_paginator_datatable_customize.html</guid><wfw:comment>http://www.cnitblog.com/yunshichen/comments/49890.html</wfw:comment><comments>http://www.cnitblog.com/yunshichen/archive/2008/10/06/YUI_paginator_datatable_customize.html#Feedback</comments><slash:comments>21</slash:comments><wfw:commentRss>http://www.cnitblog.com/yunshichen/comments/commentRss/49890.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yunshichen/services/trackbacks/49890.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 讲述如何定制YUI的paginator组件&nbsp;&nbsp;<a href='http://www.cnitblog.com/yunshichen/archive/2008/10/06/YUI_paginator_datatable_customize.html'>阅读全文</a><img src ="http://www.cnitblog.com/yunshichen/aggbug/49890.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yunshichen/" target="_blank">Chenyunshi</a> 2008-10-06 11:17 <a href="http://www.cnitblog.com/yunshichen/archive/2008/10/06/YUI_paginator_datatable_customize.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实战YUI 的 Menu 组件</title><link>http://www.cnitblog.com/yunshichen/archive/2008/10/02/49709.html</link><dc:creator>Chenyunshi</dc:creator><author>Chenyunshi</author><pubDate>Wed, 01 Oct 2008 17:07:00 GMT</pubDate><guid>http://www.cnitblog.com/yunshichen/archive/2008/10/02/49709.html</guid><wfw:comment>http://www.cnitblog.com/yunshichen/comments/49709.html</wfw:comment><comments>http://www.cnitblog.com/yunshichen/archive/2008/10/02/49709.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yunshichen/comments/commentRss/49709.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yunshichen/services/trackbacks/49709.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Menu家族成员												YAHOO.widget.Menu												YAHOO.widget.Overlay		 的子类,其他menu容器的超类. Menu类创建一个容器(Container)并放置一列垂直的列表.每项菜单称为MenuItem.YAHOO.widget.ContextMenuMenu的子类,创建一个菜单,能被某html元...&nbsp;&nbsp;<a href='http://www.cnitblog.com/yunshichen/archive/2008/10/02/49709.html'>阅读全文</a><img src ="http://www.cnitblog.com/yunshichen/aggbug/49709.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yunshichen/" target="_blank">Chenyunshi</a> 2008-10-02 01:07 <a href="http://www.cnitblog.com/yunshichen/archive/2008/10/02/49709.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实战YUI的Layout Manager 组件</title><link>http://www.cnitblog.com/yunshichen/archive/2008/10/01/YUI_tutorial_javascript_web_web2_development_layout_manager.html</link><dc:creator>Chenyunshi</dc:creator><author>Chenyunshi</author><pubDate>Wed, 01 Oct 2008 13:27:00 GMT</pubDate><guid>http://www.cnitblog.com/yunshichen/archive/2008/10/01/YUI_tutorial_javascript_web_web2_development_layout_manager.html</guid><wfw:comment>http://www.cnitblog.com/yunshichen/comments/49706.html</wfw:comment><comments>http://www.cnitblog.com/yunshichen/archive/2008/10/01/YUI_tutorial_javascript_web_web2_development_layout_manager.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnitblog.com/yunshichen/comments/commentRss/49706.html</wfw:commentRss><trackback:ping>http://www.cnitblog.com/yunshichen/services/trackbacks/49706.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 序 和官网示例吹得天花乱坠不同,使用YUI是特别让人讨厌的经历,按照官方网指导有时候并不能得到正确的结果.本文记录了一些心得,顺手把官网文章翻译下来,以作备忘.正文出现的是翻译文字,个人见解用蓝色或红色字体标出.YUI使用常识篇1.必须引入一些js库和css,并且顺序很重要.顺序不对很可能得不到正确结果.2.debug版本js格式整齐,带所有log,通常用于开发阶段.min版本js将debug版本...&nbsp;&nbsp;<a href='http://www.cnitblog.com/yunshichen/archive/2008/10/01/YUI_tutorial_javascript_web_web2_development_layout_manager.html'>阅读全文</a><img src ="http://www.cnitblog.com/yunshichen/aggbug/49706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnitblog.com/yunshichen/" target="_blank">Chenyunshi</a> 2008-10-01 21:27 <a href="http://www.cnitblog.com/yunshichen/archive/2008/10/01/YUI_tutorial_javascript_web_web2_development_layout_manager.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>