From a971c2146012a6a3cc2d4bf5fbc9fbf78c10c204 Mon Sep 17 00:00:00 2001 From: wangxueliang Date: Fri, 3 Nov 2017 17:10:38 +0800 Subject: [PATCH 1/2] add rate demo --- components/rate/demo/rate.vue | 71 +++++++++++++++++++++++++++++++++++ components/util/util.js | 49 ++++++++++++------------ 2 files changed, 95 insertions(+), 25 deletions(-) create mode 100644 components/rate/demo/rate.vue diff --git a/components/rate/demo/rate.vue b/components/rate/demo/rate.vue new file mode 100644 index 000000000..31f3a2fe3 --- /dev/null +++ b/components/rate/demo/rate.vue @@ -0,0 +1,71 @@ + + diff --git a/components/util/util.js b/components/util/util.js index 6d0070323..bef8da463 100644 --- a/components/util/util.js +++ b/components/util/util.js @@ -1,40 +1,39 @@ -function getScroll(w, top) { - let ret = top ? w.pageYOffset : w.pageXOffset; - const method = top ? 'scrollTop' : 'scrollLeft'; +function getScroll (w, top) { + let ret = top ? w.pageYOffset : w.pageXOffset + const method = top ? 'scrollTop' : 'scrollLeft' if (typeof ret !== 'number') { - const d = w.document; + const d = w.document // ie6,7,8 standard mode - ret = d.documentElement[method]; + ret = d.documentElement[method] if (typeof ret !== 'number') { // quirks mode - ret = d.body[method]; + ret = d.body[method] } } - return ret; + return ret } -function getClientPosition(elem) { - let box; - let x; - let y; - const doc = elem.ownerDocument; - const body = doc.body; - const docElem = doc && doc.documentElement; - box = elem.getBoundingClientRect(); - x = box.left; - y = box.top; - x -= docElem.clientLeft || body.clientLeft || 0; - y -= docElem.clientTop || body.clientTop || 0; +function getClientPosition (elem) { + let x + let y + const doc = elem.ownerDocument + const body = doc.body + const docElem = doc && doc.documentElement + const box = elem.getBoundingClientRect() + x = box.left + y = box.top + x -= docElem.clientLeft || body.clientLeft || 0 + y -= docElem.clientTop || body.clientTop || 0 return { left: x, top: y, - }; + } } export const getOffsetLeft = (el) => { - const pos = getClientPosition(el); - const doc = el.ownerDocument; - const w = doc.defaultView || doc.parentWindow; - pos.left += getScroll(w); - return pos.left; + const pos = getClientPosition(el) + const doc = el.ownerDocument + const w = doc.defaultView || doc.parentWindow + pos.left += getScroll(w) + return pos.left } From ba79c3eee183614ade2273d00bad1711b2dea714 Mon Sep 17 00:00:00 2001 From: tangjinzhou Date: Fri, 3 Nov 2017 18:46:18 +0800 Subject: [PATCH 2/2] fix demo --- components/button/demo/basic.vue | 1 - components/button/demo/button-group.vue | 58 +++++++++++++++ components/button/demo/button.vue | 96 ------------------------- components/button/demo/disabled.vue | 23 ++++++ components/button/demo/ghost.vue | 16 +++++ components/button/demo/icon.vue | 21 ++++++ components/button/demo/index.vue | 42 +++++++++++ components/button/demo/loading.vue | 42 +++++++++++ components/button/demo/multiple.vue | 17 +++++ components/button/demo/size.vue | 48 +++++++++++++ components/checkbox/Group.vue | 14 ++-- components/checkbox/demo/basic.vue | 18 +++++ components/checkbox/demo/check-all.vue | 47 ++++++++++++ components/checkbox/demo/controller.vue | 18 +++++ components/checkbox/demo/disabled.vue | 15 ++++ components/checkbox/demo/group.vue | 45 ++++++++++++ components/checkbox/demo/layout.vue | 18 +++++ components/radio/Group.vue | 2 +- components/style.js | 4 ++ examples/button.vue | 95 ------------------------ examples/index.js | 1 + examples/routes.js | 2 +- 22 files changed, 445 insertions(+), 198 deletions(-) create mode 100644 components/button/demo/button-group.vue delete mode 100644 components/button/demo/button.vue create mode 100644 components/button/demo/disabled.vue create mode 100644 components/button/demo/ghost.vue create mode 100644 components/button/demo/icon.vue create mode 100644 components/button/demo/index.vue create mode 100644 components/button/demo/loading.vue create mode 100644 components/button/demo/multiple.vue create mode 100644 components/button/demo/size.vue create mode 100644 components/checkbox/demo/basic.vue create mode 100644 components/checkbox/demo/check-all.vue create mode 100644 components/checkbox/demo/controller.vue create mode 100644 components/checkbox/demo/disabled.vue create mode 100644 components/checkbox/demo/group.vue create mode 100644 components/checkbox/demo/layout.vue create mode 100644 components/style.js delete mode 100644 examples/button.vue diff --git a/components/button/demo/basic.vue b/components/button/demo/basic.vue index 065e842df..d79bb4641 100644 --- a/components/button/demo/basic.vue +++ b/components/button/demo/basic.vue @@ -7,7 +7,6 @@ + diff --git a/components/button/demo/button.vue b/components/button/demo/button.vue deleted file mode 100644 index a1545a162..000000000 --- a/components/button/demo/button.vue +++ /dev/null @@ -1,96 +0,0 @@ - - diff --git a/components/button/demo/disabled.vue b/components/button/demo/disabled.vue new file mode 100644 index 000000000..1ae12909f --- /dev/null +++ b/components/button/demo/disabled.vue @@ -0,0 +1,23 @@ + + diff --git a/components/button/demo/ghost.vue b/components/button/demo/ghost.vue new file mode 100644 index 000000000..3b474225b --- /dev/null +++ b/components/button/demo/ghost.vue @@ -0,0 +1,16 @@ + + diff --git a/components/button/demo/icon.vue b/components/button/demo/icon.vue new file mode 100644 index 000000000..471b07a80 --- /dev/null +++ b/components/button/demo/icon.vue @@ -0,0 +1,21 @@ + + diff --git a/components/button/demo/index.vue b/components/button/demo/index.vue new file mode 100644 index 000000000..1c633c5f9 --- /dev/null +++ b/components/button/demo/index.vue @@ -0,0 +1,42 @@ + + diff --git a/components/button/demo/loading.vue b/components/button/demo/loading.vue new file mode 100644 index 000000000..842bdf260 --- /dev/null +++ b/components/button/demo/loading.vue @@ -0,0 +1,42 @@ + + diff --git a/components/button/demo/multiple.vue b/components/button/demo/multiple.vue new file mode 100644 index 000000000..f27a4fb5e --- /dev/null +++ b/components/button/demo/multiple.vue @@ -0,0 +1,17 @@ +// TODO: 依赖组件开发中 + + diff --git a/components/button/demo/size.vue b/components/button/demo/size.vue new file mode 100644 index 000000000..50fafe069 --- /dev/null +++ b/components/button/demo/size.vue @@ -0,0 +1,48 @@ + + diff --git a/components/checkbox/Group.vue b/components/checkbox/Group.vue index 7408105e5..ef2518833 100644 --- a/components/checkbox/Group.vue +++ b/components/checkbox/Group.vue @@ -1,6 +1,6 @@