kissy-past-now-future

127
1 的昨天、今天与明天 承玉 [email protected]

Upload: yiming-he

Post on 21-Apr-2017

1.751 views

Category:

Automotive


0 download

TRANSCRIPT

Page 1: kissy-past-now-future

1

的昨天、今天与明天

承玉

[email protected]

Page 2: kissy-past-now-future

定位、目标

立足淘宝业务,服务电子商务行业,做一个功能全面、灵活定制、社区活跃的前端框架.

- kissyteam

Page 3: kissy-past-now-future

大纲

• KISSY 的昨天

• KISSY 今天与明天

– seed

– core

– component

– gallery

– sub project

Page 4: kissy-past-now-future

KISSY

• 2009.07 – 2009.12 构思期

• 2010.01 – 2010.07 孕育期

• 2010.07 – 2011.01 快速成长期

• 2011.01 – now 稳固发展期

Page 5: kissy-past-now-future

• KISSY 的昨天

Page 6: kissy-past-now-future

2009 构思

Page 7: kissy-past-now-future

2009

• KISSY Editor 1.0

– 依赖 YUI2 Core

– KISSY 雏形

• mix

• add

• app

• ready

Page 8: kissy-past-now-future

2010上 孕育

• KISSY 1.0.0 – 1.0.8

Page 9: kissy-past-now-future

2010上

• KISSY 1.0.0 – 1.0.8

– getScript/cookie/dom/event/json/node

– css/common/grid/reset.css

– datalazyload/suggest/switchable/editor/

swf(flash)

Page 10: kissy-past-now-future

• suggest

Page 11: kissy-past-now-future

• switchable

– tab/carousel/slide

Page 12: kissy-past-now-future

2010 下 快速成长期

全职的 kissyteam + 志愿者

KISSY 1.1.0 – 1.1.7

Page 13: kissy-past-now-future

2010 下

• 核心基本可用

– simple loader => seajs

– ajax/anim/dom/event/node/ua/base/cookie

– cssreset/grid/common.css

• 组件兼容

– switchable/suggest/datalazyload/flash

Page 14: kissy-past-now-future

2010 下

• 更多的组件

Page 15: kissy-past-now-future

2010 下

• Calendar

– 日期选择

– 范围限定

– 事件触发

Page 16: kissy-past-now-future

• Ajbridge:javascript 和 flash 的桥梁

– storage

– uploader

– communication

Page 17: kissy-past-now-future

• Imagezoom:图片放大镜

– 多种放大形式自由选择

Page 18: kissy-past-now-future

• Overlay:浮层控制

– align

– width/height

– drag

Page 19: kissy-past-now-future

New KISSY Editor

• 底层稳定

• 插件丰富

Page 20: kissy-past-now-future

• Draggable 节点可拖放

• Template 模板系统

– logic

– 控制结构自定义

Page 21: kissy-past-now-future

• KISSY 今天 v1.2 的变化

Page 22: kissy-past-now-future

概况

sub project

gallery

component

core

seed

• kissy-nodejs/kissy-tools…

• grid/chart/kscroll…

• editor/overlay/switchable…

• dom/event/base…

• lang/loader

Page 23: kissy-past-now-future

seed

Page 24: kissy-past-now-future

seed

Page 25: kissy-past-now-future

• 语言增强&前提准备

– mix/merge/clone/extend…

– each/map/reduce/bind…

– escapeHTML/param/substitute…

– ready/globalEval…

– config()

Page 26: kissy-past-now-future

• module mechanism

AMD

module compiler

package

Page 27: kissy-past-now-future

AMD

Page 28: kissy-past-now-future

KISSY.add

KISSY.add(function(S,DOM){

// TODO!

},{

requires:[“dom”]

});

module registration

Page 29: kissy-past-now-future

KISSY.use

KISSY.use(“overlay,switchable”,

function(S,Overlay,Switchable){

// TODO!

});

Use modules

Page 30: kissy-past-now-future

package

Page 31: kissy-past-now-future

KISSY.config

KISSY.config({

packages:[{

name:”yourpackage”

path:”yourpath”

}]

});

Package config

Page 32: kissy-past-now-future

module compiler

Page 33: kissy-past-now-future

module compiler

<java classname="com.taobao.f2e.Main">

<arg value="-requires"/>

<!-- 入口模块 -->

<arg value="youpackage/xx"/>

<arg value="-baseUrls"/>

<arg value="${assets.dir}"/>

<arg value="-encodings"/>

<arg value="${charset}"/>

<arg value="-outputEncoding"/>

<arg value="${charset}"/>

<arg value="-output"/>

<arg value="xx.combo.js"/>

<classpath>

<pathelement path="${module.compiler}"/>

<pathelement path="${java.class.path}"/>

</classpath>

</java>

Combine modules

Page 34: kissy-past-now-future

core

Page 35: kissy-past-now-future

core

Page 36: kissy-past-now-future

DOM

Page 37: kissy-past-now-future

– query(selector,context):context 限制同selector

– clone:克隆自身以及事件

– inner/outer|Width/Height

Page 38: kissy-past-now-future

Event

Page 39: kissy-past-now-future

Unified registration

• 原生节点

– S.one(domNode).on(“click”,fn,context)

• 自定义事件

– obj.on(“customEvent”,fn,context)

Page 40: kissy-past-now-future

fire

• Native event

– S.one(domNode).fire(“click”)

• Custom event

– obj.fire(“customEvent”)

Page 41: kissy-past-now-future

bubbling

• Native event

li

li

li

ul id=„test‟

S.all(“#test li”).on(“click”,fn)

Page 42: kissy-past-now-future

delegation

• Native event

li

li

li

ul id=„test‟ S.one(“#test”).delegate(“click”,”li”,fn)

Page 43: kissy-past-now-future

Custom event

• registration

obj1

obj2

obj3

obj[1..3].on(“customEvent”,fn)

Page 44: kissy-past-now-future

Custom event

obj1

obj2

obj3

host host.on(“customEvent”,fn)

e.target instanceof Obj

obj.addTarget(host);

Obj.publish(“customEvent”,{

bubbles:true

});

Bubble and delegation

Page 45: kissy-past-now-future

DOM事件补全

• submit/change @ie bubble

• focusin/out @non-ie

• mouseenter/leave @non-ie

• hashchange @ie

• mousewheel @firefox

• valuechange @all

Page 46: kissy-past-now-future

ajax

Page 47: kissy-past-now-future

ajax

Page 48: kissy-past-now-future

IO

Page 49: kissy-past-now-future

io

Page 50: kissy-past-now-future

XMLHttpRequest

KISSY.io({

url : ‟getJson.htm‟,

cache : false,

type : ‟get‟,// „post‟

data : { x: 1},

dataType : ‟json‟, // „text‟?

success : function(d){

},

error : function(_,reason){

},

complete : function(){

}

});

Page 51: kissy-past-now-future

JSONP

KISSY.io({

url : ‟getJsonp.htm‟,

type : ‟get‟,// „post‟

cache : false,

data : { x: 1},

dataType : ‟jsonp‟,

success : function(d){

},

error : function(_,reason){

},

complete : function(){

}

});

Page 52: kissy-past-now-future

file upload

KISSY.io({

url : ‟upload.htm‟,

type : „post‟,

data : {x: 1},

dataType : ‟json‟,

form: „#formEl‟,

success : function(d){

},

error : function(_,reason){

},

complete : function(){

}

});

<form id=„formEl‟ method=„post‟

enctype=„multipart/form-data‟ >

<input name=„f‟ type=„file‟ />

</form>

Page 53: kissy-past-now-future

form serialization

KISSY.io({

url : ‟getJson.htm‟,

type : „post‟,

data : {x: 1},

dataType : ‟json‟,

form: „#formEl‟,

success : function(d){

},

error : function(_,reason){

},

complete : function(){

}

});

<form id=„formEl‟ >

<input name=„f‟ value=„s‟ />

</form>

Page 54: kissy-past-now-future

xdr

• Cross domain request

– Sub domain

{ xdr : { subDomain :

{ proxy : ”/proxy.html” } // 默认:/sub_domain_proxy.html

} }

– Different domain

• transparent in client

• server apply to CORS

Page 55: kissy-past-now-future

cancellable

xhr.abort();

Page 56: kissy-past-now-future
Page 57: kissy-past-now-future

anim

Page 58: kissy-past-now-future

• memory efficient

– 1.1.6

– 1.2

Page 59: kissy-past-now-future

• Less cpu

Page 60: kissy-past-now-future

more

• support scrollTop/Left

Page 61: kissy-past-now-future

more

• support scrollTop/Left

• Support queue

– Stop single animation

– Stop single queue

– Stop all queues

Page 62: kissy-past-now-future

node

Easy to use

Page 63: kissy-past-now-future

Node

Anim

EventDOM

Page 64: kissy-past-now-future

• Easy chained query

S.all(“.cls”).all(“a”)

.css(“color”,”red”)

.end()

.css(“color”,”green”);

Page 65: kissy-past-now-future

Easy node creation

S.all(“<div class=„easy‟>kissy</div>”).

appendTo(document.body);

Page 66: kissy-past-now-future

Easy dom operation

node.appendTo(another);

node.css(„color‟,‟red‟);

node.attr(“checked”)

Page 67: kissy-past-now-future

Easy event registration

node.on(„click‟,fn);

node.delegate(„click‟,‟a‟,fn);

node.detach(„click‟)

node.fire(„click‟)

Page 68: kissy-past-now-future

Easy animation

node.animate({left:”100px”,top:”100px”});

node.stop();

node.stop(true);

node.isRunning();

node.stop(true,true,queueName);

node.slideToggle();

node.fadeToggle();

Page 69: kissy-past-now-future

base

• Solid foundation

Page 70: kissy-past-now-future

Support validator

MyClass.ATTRS={

myAttr:{

validator:function(v){

return v>10;

}

}

};

myClass.set(“myAttr”,1) // => false

Page 71: kissy-past-now-future

Support bulk set

myClass.set({

attr1 : v1,

attr2 : v2,

attr3 : v3

});

Page 72: kissy-past-now-future

Support sub attribute

myClass.set(“attr”, { child1:1 });

myClass.set( “attr.child2” , ”2”);

myClass.get(“attr”) // => { child1:1,child2:2}

Page 73: kissy-past-now-future

兼容

• ua

• json

• Cookie

Page 74: kissy-past-now-future

Component

Page 75: kissy-past-now-future

component

Page 76: kissy-past-now-future

dd

Page 77: kissy-past-now-future

dd

• Droppable

– 可放置区域

• DraggableDelegate

– 拖委托

• DroppableDelegate

– 放委托

• Proxy

– 拖代理

• Scroll

– 容器自适应滚动

Page 78: kissy-past-now-future

switchable

• aria

• keyboard

Page 79: kissy-past-now-future

resizable

new Resizable({

node : ”#container”,

handlers: [“b”,”tl”], // 可拖动位置// 最大最小宽高minHeight : 50,

maxHeight : 100,

minWidth : 40,

maxWidth : 400

});

Page 80: kissy-past-now-future

validation

• 配置简单

• 丰富的验证规则

• 多重验证,依赖验证

• 自定义验证规则

• 多种信息提示方式

Page 81: kissy-past-now-future

waterfall与时俱进的新布局

new Waterfall.Loader({

// 容器container:"#ColumnContainer",

// 加载方式load: function(success, end) {

$('#loadingPins').show();

S.ajax({

success: function(d) {

// 如果数据错误, 则立即结束if (d.stat !== 'ok') {

alert('load data error!');

// 停止加载end();

return;

}

// 拼装每页数据var items = [];

// 继续加载success (items);

},

complete: function() {

$('#loadingPins').hide();

}

});

},

// 最小列数minColCount : 2,

// 列宽度colWidth : 228

});

Page 82: kissy-past-now-future

mvc

• Scaffold for KISSY app.

– Model / Collection

• Base

– View

– Router

– Sync

Page 83: kissy-past-now-future

editor is module too!

KISSY.use(“editor”,function(S , Editor){

new Editor(…).use(…);

});

Page 84: kissy-past-now-future

Consistent interface

Page 85: kissy-past-now-future

Consistent interface

• Consistent interface across most components

– set() / get()

– new / render() / show() / hide() / destroy()

– addChild()/removeChild()

– width/height/prefixCls/render

Page 86: kissy-past-now-future

Consistent interface

• Consistent interface across most components

– set() / get()

– new / render() / show() / hide() / destroy()

– addChild()/removeChild()

– width/height/prefixCls/render

• Overlay / Menu / MenuButton / Button / Tree

Page 87: kissy-past-now-future

overlay

• closeAction

– hide / destroy

new Overlay.Dialog({

closeAction : “hide”

});

Page 88: kissy-past-now-future

overlay

• aria

– 焦点捕获

• resize

– 配合 resizable

• effect

– none/ fade/ slide

Page 89: kissy-past-now-future

Simulated controls

• Button

– attributes

• disabled

• content

• Value

– events

• click

Page 90: kissy-past-now-future

Simulated controls

• Menu

– events

• click

• MenuItem

– Attributes

• selectable

• checkable

• value

• content

Page 91: kissy-past-now-future

• MenuButton

– Attributes

• Menu

• menuCfg

– Events

• Click

– Method

• addItem

• removeItem

Page 92: kissy-past-now-future

• Tree

– Events

• click

• TreeNode

– Attributes

• content

• selected

• expanded

– Methods

• select()

• collapse()

Page 93: kissy-past-now-future

gallery

Page 94: kissy-past-now-future

gallery

Page 95: kissy-past-now-future

usage

KISSY.config({ packages : [{

name : ‟gallery‟,

path : ‟http://a.tbcdn.cn/s/kissy/‟

}] });

KISSY.use(“gallery/name/version/”)

Page 96: kissy-past-now-future

• grid

– gallery/grid/1.0/

– 董晓庆 (lp.taobao.com)

Page 97: kissy-past-now-future

• chart

– gallery/chart/1.0

– 文龙

Page 98: kissy-past-now-future

• uploader

– gallery/form/1.0

– 剑平 & …

Page 99: kissy-past-now-future

• Starrating

– gallery/starrating/1.0

– 盛艳(乔花)

Page 100: kissy-past-now-future

• kscroll

– gallery/kscroll/1.0

– 常胤

Page 101: kissy-past-now-future

• huabao

– Gallery/huabao/1.0/

– 法海

Page 102: kissy-past-now-future

• Countdown

– gallery/countdown/1.0

– 基德

Page 103: kissy-past-now-future

• Reflection

– gallery/reflection/1.0

– 元泉

Page 104: kissy-past-now-future

• image-tagging

– gallery/image-tagging/1.0

– 乔福

Page 105: kissy-past-now-future

• more

– Selectable

– Spotlight

– Pagination

– Magnifier

– …..

• 25

Page 106: kissy-past-now-future

Look forward to your participation

Page 107: kissy-past-now-future

Sub project

Page 108: kissy-past-now-future

Sub project

• Kissy-tools : 工具集合

• Kissy-util : 代码片段

• Kissy-dpl : 设计模式规范库

• Kissy-ajbridge : as-js 桥梁

• Kissy-nodejs : kissy on nodejs

Page 109: kissy-past-now-future

Kissy-nodejs

• nodejs-kissy

– ui-less unit test

Page 110: kissy-past-now-future

• nodejs-kissy

– ui-less unit test

• npm install KISSY

– KISSY = require(“KISSY”);

– KISSY.config()

– KISSY.add

– KISSY.use

Page 111: kissy-past-now-future

KISSY 的明天

Page 112: kissy-past-now-future

• Loader

– Auto combo

– Load on demand

• S.use("overlay,calendar,switchable,

suggest,gallery/kscroll/1.0/");

Page 113: kissy-past-now-future

• Loader

– Auto combo v1.3

– Load on demand v1.3

• S.use("overlay,calendar,switchable,

suggest,gallery/kscroll/1.0/");

Page 114: kissy-past-now-future

• Core

– Stable

Page 115: kissy-past-now-future

• Core

– Stable

– Bug-free

• Github issue

Page 116: kissy-past-now-future

• Core

– Stable

– Bug-free

– api-friendly

• more sugar ?

• Promise api v1.3

Page 117: kissy-past-now-future

• Core

– Stable

– Bug-free

– api-friendly

– Evolve

• namespace in event v1.3

• pause/resume in anim v1.3

• wrap in DOM v1.3

Page 118: kissy-past-now-future

• Component

– Consistent interface

• Suggest => Autocomplete v1.3

• Switchable -> Tab v1.3

• …

Page 119: kissy-past-now-future

• Component

– Consistent interface

– Full-featured components

• Switchable – enhancement v1.3

• …

Page 120: kissy-past-now-future

• Component

– Consistent interface

– Full-featured components

– performance

• ie

Page 121: kissy-past-now-future

• Component

– Consistent interface

– Full-featured components

– performance

– Scalability

• Easy to customize

Page 122: kissy-past-now-future

• Component

– Consistent interface

– Full-featured components

– performance

– Scalability

– Test case covered

• more tc

Page 123: kissy-past-now-future

• Editor

– Open – API

– Load on demand v1.3

– Core functionality covered by test case

– Plugin gallery

Page 124: kissy-past-now-future

• KISSY - Gallery

– Open

– Promotion

– Easy to use

Page 125: kissy-past-now-future

• KISSY Sub Project

– KISSY Mobile ?

– Game Engine ?

– Parser ?

– Welcome !

Page 126: kissy-past-now-future

• Contact kissyteam– Docs:

http://docs.kissyui.com

– Bug:

http://github.com/kissyteam/kissy/issues

– email:

[email protected]

– Twitter:

http://twitter.com/#!/kissyteam

– Google Group:

http://groups.google.com/group/kissy-ui

Page 127: kissy-past-now-future