日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Ajax與Javascript類(Modello)

 命運(yùn)之輪 2008-10-20
Ajax與系列精華Javascript庫(Modello)

聲明:以下推薦的類均來自互聯(lián)網(wǎng)的開源項(xiàng)目,版權(quán)所有屬于原作者。

引用
使用Modello編寫JavaScript類
到目前為止,JavaScript 是一種不完全支持面向?qū)ο筇匦缘哪_本語言。之所以這樣說是因?yàn)?JavaScript 的確支持對(duì)象的概念,在程序中我們看到都是對(duì)象,可是 Javascipt 并不支持類的封裝和繼承。JavaScript 的確支持自定義對(duì)象和繼承,不過使用的是另外一種方式:prototype(中文譯作:原型)。用過 JavaScript 的或者讀過《設(shè)計(jì)模式》的讀者都會(huì)了解這種技術(shù),描述如下:

每個(gè)對(duì)象都包含一個(gè) prototype 對(duì)象,當(dāng)向?qū)ο蟛樵円粋€(gè)屬性或者請(qǐng)求一個(gè)方法的時(shí)候,運(yùn)行環(huán)境會(huì)先在當(dāng)前對(duì)象中查找,如果查找失敗則查找其 prototype 對(duì)象。注意 prototype 也是一個(gè)對(duì)象,于是這種查找過程同樣適用在對(duì)象的 prototype 對(duì)象中,直到當(dāng)前對(duì)象的 prototpye 為空。

在 JavaScript 中,對(duì)象的 prototype 在運(yùn)行期是不可見的,只能在定義對(duì)象的構(gòu)造函數(shù)時(shí),創(chuàng)建對(duì)象之前設(shè)定。



使用 Modello 編寫的類所具備如下特性:

·私有成員、公共成員和靜態(tài)成員
·類的繼承,多繼承
·命名空間
·類型鑒別


Modello 還具有以下特性:

·更少的概念,更方便的使用方法
·小巧,只有兩百行左右的代碼
·設(shè)計(jì)期和運(yùn)行期徹底分離,使用繼承的時(shí)候不需要使用 prototype,也不需要先創(chuàng)建父類的實(shí)例
·兼容 prototype.js 的類,兼容 JavaScript 構(gòu)造函數(shù)
·跨瀏覽器,跨瀏覽器版本
·開放源代碼,BSD licenced,允許免費(fèi)使用在個(gè)人項(xiàng)目或者商業(yè)項(xiàng)目中


使用 Modello 編寫的類功能可以媲美使用 Atlas 編寫的類,并且使用起來更簡(jiǎn)潔。如果你想用 Modello 框架代替 prototype.js 中的簡(jiǎn)單類框架,只需要先包含 modello.js,然后去掉 prototype.js 中定義 Class 的幾行代碼即可,一切將正常運(yùn)行。

Modello
Modello 的完整參考說明和下載地址:http://modello./
JavaScript Class Framework
Modello is a lightweight framework that enables you to write JavaScript class like other class-based object-oriented programming language. It introduces class, class-based inheritance, multi-inheritance, private members, RTTI and more into JavaScript. Modello can help you write more readable, reusable and maintainable JavaScript code.


Modello

Modello下載: http:///project/showfiles.php?group_id=164137&package_id=185772

Modello.ajax
跨域Ajax工具
Ajax是個(gè)好東西,但使用起來卻不是那么方便。問題總結(jié)如下:

·在各種瀏覽器上的創(chuàng)建方式和使用方法不一致
·各個(gè)瀏覽器對(duì)響應(yīng)的緩存策略有所不同
·瀏覽器存在跨域獲取限制

前兩個(gè)問題可以通過封裝 XMLHTTPRequest 對(duì)象來解決,第三個(gè)問題的解決方法有很多中,兼容性和移植性比較好的就是在本域服務(wù)器上放置一個(gè)中轉(zhuǎn) proxy 。Modello.ajax 就是提供這套解決方案的工具集。

Modello.ajax下載: http:///project/showfiles.php?group_id=164137&package_id=187232

ColorCode
代碼著色,多語言高亮,使用極為簡(jiǎn)單
ColorCode官方網(wǎng)址:http://www./colorcode/
Multi-Language Syntax Highlighter
ColorCode is a multi-language syntax source code highlighter. It is designed to be very easy to use and extend. There is two parts in ColorCode: client-side script and back-end render. You can redefine the color scheme in client-side vias changing the CSS file, and you can also define a new syntax for the language which ColorCode does not support. ColorCode use PEAR's Text_Highlighter as it's back-end render, and supports 14 languages syntax:

c++, css, diff, dtd, html, java, javascript, mysql, perl, php, python, ruby, sql, xml

Usage
First, include modello.js, ajax.js, colorcode.js and colorcode.css into your html page. Second, define COLORCODE_BACK_END macro. Third, create and ColorCode object and call it's apply() function. And then use textarea tag to wrap the code that need to be rendered with ColorCode.


ColorCode下載:http://www./download/colorcode.zip


Nifty Corners Cube
JavaScript 圓角(斜角)矩形,同樣使用起來也很快捷。
Nifty Corners Cube官方網(wǎng)址:http://www./articoli/niftycube/index.html
Nifty Corners Cube are a solution to get rounded corners without images, and this third version is build by three main components:


·A javascript file, named "niftycornerscube.js"
·A CSS file, named "niftycorners.css"
·The javascript calls specific for the pages


Now we're now ready to look at the first example: it's a div with big rounded corners thanks to Nifty Corners. As I said before, the CSS file it's added automatically by javascript. In fact, the only reference to an external file in the example is the following:



Regarding the third point, as is the javascript calls needed for the page, the code for the example is the following:



    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多