一個輕量級的JavaScript庫:ICE
一個輕量級的JavaScript庫:ICE。
ICE 特性:
- Small footprint (65KB uncompressed)
- Mature - used on Todoist.com since 2007
- Unified things that work in all the modern browsers (IE 7+)
- Functional programming
- DOM helpers
- Array helpers
- Element store
- Powerful and easy to use requests
- Deferred abstraction
- Class abstraction
- Effects
- Drag and drop helpers
- and a lot more...
ICE示例:
// Requests
function loadUsers() {
var req = $requestJSON('/users/get')
req.addCallback(function(users) {
var user_holder = $('user_holder')
$map(users, function(user) {
var li = LI({c: 'user'}, user.name)
$AEV(li, 'click', UserController.click)
$add(user_holder, li)
})
})
req.sendReq({token: TOKEN})
}
// Events
$AEV(window, 'load', loadUsers)
// Effects
$fx.setWidth($('fluffy_4'), {from: 150, to: 400})
// Array helpers
$arrayFlatten([[1, 2, [3, 4]], 5]) == [1, 2, 3, 4, 5]
// DOM abstraction
$add($body(),
DIV({c: 'my_class', s:'padding-top: 10px'}, "Hello"))
// Element store
ElementStore.set(elm, "meaning of life", {42: 42}) 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!