diff --git a/src/js/anot.shim.js b/src/js/anot.shim.js
index a97cc24..2bb2730 100644
--- a/src/js/anot.shim.js
+++ b/src/js/anot.shim.js
@@ -3287,10 +3287,7 @@
if (newVmodel.props[name].check(value)) {
newVmodel.props[name] = value
} else {
- Anot.error(
- 'props「' + name + '」类型错误!' + value,
- TypeError
- )
+ Anot.error('props「' + name + '」类型错误!', TypeError)
}
} else {
newVmodel.props[name] = value
@@ -3436,8 +3433,8 @@
var componentQueue = []
var widgetList = []
var componentHooks = {
- construct: function(props, next) {
- next(props)
+ construct: function(props, state, next) {
+ next(props, state)
},
componentWillMount: noop,
componentDidMount: noop,
@@ -3480,14 +3477,27 @@
props = Object.assign({}, vmOpts, props)
vmOpts = void 0
+ // log(props)
+ for (var i in props) {
+ if (props[i] === '__fn__') {
+ props[i] = elem[i]
+ delete elem[i]
+ }
+ }
+
delete props.config
delete props.uuid
- hooks.construct.call(elem, props, function next(val) {
- Object.assign(hooks.props, val)
+ delete props.name
+
+ hooks.props = hooks.props || {}
+ hooks.state = hooks.state || {}
+
+ hooks.construct.call(elem, props, {}, function next(props, state) {
+ Object.assign(hooks.props, props)
+ Object.assign(hooks.state, state)
Object.assign(componentDefinition, hooks)
})
- componentDefinition.$refs = {}
componentDefinition.$id = $id
//==========构建VM=========
@@ -3506,6 +3516,7 @@
delete componentDefinition.componentWillUnmount
var vmodel = Anot(componentDefinition)
+ vmodel.$refs = {}
elem.msResolved = 1 //防止二进扫描此元素
@@ -3689,9 +3700,13 @@
var obj = val
if (typeof obj === 'object' && obj !== null) {
- if (!Anot.isPlainObject(obj)) obj = obj.$model
+ if (!Anot.isPlainObject(obj)) {
+ obj = obj.$model
+ }
} else {
- if (!this.param) return
+ if (!this.param) {
+ return
+ }
obj = {}
obj[this.param] = val
@@ -3718,7 +3733,9 @@
} else {
var k = i
//古董IE下,部分属性名字要进行映射
- if (!W3C && propMap[k]) k = propMap[k]
+ if (!W3C && propMap[k]) {
+ k = propMap[k]
+ }
if (typeof elem[boolMap[k]] === 'boolean') {
//布尔属性必须使用el.xxx = true|false方式设值
@@ -3737,6 +3754,13 @@
if (isInnate) {
elem[k] = obj[i]
} else {
+ if (typeof obj[i] === 'object') {
+ obj[i] = JSON.stringify(obj[i])
+ } else if (typeof obj[i] === 'function') {
+ var ck = Anot.filters.camelize(k)
+ elem[ck] = obj[i]
+ obj[i] = '__fn__'
+ }
elem.setAttribute(k, obj[i])
}
}
diff --git a/src/js/lib/avatar/def.jpg b/src/js/avatar/def.jpg
similarity index 100%
rename from src/js/lib/avatar/def.jpg
rename to src/js/avatar/def.jpg
diff --git a/src/js/lib/avatar/index.js b/src/js/avatar/index.js
similarity index 100%
rename from src/js/lib/avatar/index.js
rename to src/js/avatar/index.js
diff --git a/src/js/lib/codemirror/codemirror.js b/src/js/codemirror/codemirror.js
similarity index 100%
rename from src/js/lib/codemirror/codemirror.js
rename to src/js/codemirror/codemirror.js
diff --git a/src/js/lib/codemirror/htmlmixed.js b/src/js/codemirror/htmlmixed.js
similarity index 100%
rename from src/js/lib/codemirror/htmlmixed.js
rename to src/js/codemirror/htmlmixed.js
diff --git a/src/js/console/index.js b/src/js/console/index.js
new file mode 100644
index 0000000..ab5fd9f
--- /dev/null
+++ b/src/js/console/index.js
@@ -0,0 +1,53 @@
+/**
+ *
+ * @authors yutent (yutent@doui.cc)
+ * @date 2017-12-26 11:04:52
+ * @version $Id$
+ */
+
+import './style.scss'
+
+const logElem = document.createElement('div')
+logElem.className = 'do-console'
+
+const Logger = function() {
+ document.body.appendChild(logElem)
+}
+
+Logger.prototype = {
+ log: function(...args) {
+ let pre = document.createElement('pre')
+ args = args.map(it => {
+ if (Anot.isPlainObject(it)) {
+ return JSON.stringify(it)
+ } else {
+ if (Anot.type(it) === 'error') {
+ return it.stack || it
+ }
+ return it
+ }
+ })
+ pre.textContent = args.join(' ')
+ logElem.appendChild(pre)
+ },
+ error: function(...args) {
+ let pre = document.createElement('pre')
+ args = args.map(it => {
+ if (Anot.isPlainObject(it)) {
+ return JSON.stringify(it)
+ } else {
+ if (Anot.type(it) === 'error') {
+ return it.stack || it
+ }
+ return it
+ }
+ })
+ pre.className = 'error'
+ pre.textContent = args.join(' ')
+ logElem.appendChild(pre)
+ }
+}
+
+window.console = new Logger()
+
+export default window.console
diff --git a/src/js/console/style.scss b/src/js/console/style.scss
new file mode 100644
index 0000000..e1fad39
--- /dev/null
+++ b/src/js/console/style.scss
@@ -0,0 +1,11 @@
+@import '../css/var.scss';
+
+.do-console {
+ overflow:hidden;overflow-y:auto;position:fixed;left:0;bottom:0;z-index:65535;width:100%;height:50vh;padding:8px 5px;background:rgba(255,255,255,.9);color:#666;font-size:13px;line-height:17px;
+
+ pre {position:relative;display:block;width:100%;height:auto;padding-left:13px;word-wrap: break-word;white-space: pre-wrap;border-bottom:1px solid #ddd;
+
+ &.error {background:#fff0f0;color:#ff6161}
+ &::before {position:absolute;left:0;top:0;content:">";color:nth($ct, 1)}
+ }
+}
\ No newline at end of file
diff --git a/src/js/lib/count/doui.count.js b/src/js/count/doui.count.js
similarity index 100%
rename from src/js/lib/count/doui.count.js
rename to src/js/count/doui.count.js
diff --git a/src/js/lib/datepicker/Readme.md b/src/js/datepicker/Readme.md
similarity index 100%
rename from src/js/lib/datepicker/Readme.md
rename to src/js/datepicker/Readme.md
diff --git a/src/js/lib/datepicker/main.htm b/src/js/datepicker/main.htm
similarity index 100%
rename from src/js/lib/datepicker/main.htm
rename to src/js/datepicker/main.htm
diff --git a/src/js/lib/datepicker/main.js b/src/js/datepicker/main.js
similarity index 100%
rename from src/js/lib/datepicker/main.js
rename to src/js/datepicker/main.js
diff --git a/src/js/lib/datepicker/style.scss b/src/js/datepicker/style.scss
similarity index 100%
rename from src/js/lib/datepicker/style.scss
rename to src/js/datepicker/style.scss
diff --git a/src/js/lib/drag/doc.md b/src/js/drag/doc.md
similarity index 100%
rename from src/js/lib/drag/doc.md
rename to src/js/drag/doc.md
diff --git a/src/js/lib/drag/main.js b/src/js/drag/main.js
similarity index 100%
rename from src/js/lib/drag/main.js
rename to src/js/drag/main.js
diff --git a/src/js/lib/layer/Release.md b/src/js/layer/Release.md
similarity index 100%
rename from src/js/lib/layer/Release.md
rename to src/js/layer/Release.md
diff --git a/src/js/lib/layer/base.js b/src/js/layer/base.js
similarity index 100%
rename from src/js/lib/layer/base.js
rename to src/js/layer/base.js
diff --git a/src/js/lib/layer/full.js b/src/js/layer/full.js
similarity index 100%
rename from src/js/lib/layer/full.js
rename to src/js/layer/full.js
diff --git a/src/js/lib/layer/mobile.js b/src/js/layer/mobile.js
similarity index 100%
rename from src/js/lib/layer/mobile.js
rename to src/js/layer/mobile.js
diff --git a/src/js/lib/layer/skin/def.scss b/src/js/layer/skin/def.scss
similarity index 100%
rename from src/js/lib/layer/skin/def.scss
rename to src/js/layer/skin/def.scss
diff --git a/src/js/lib/tree/main.js b/src/js/lib/tree/main.js
deleted file mode 100644
index 3a808de..0000000
--- a/src/js/lib/tree/main.js
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- *
- * @authors yutent (yutent@doui.cc)
- * @date 2017-04-14 21:04:50
- *
- */
-
-"use strict";
-
-define(['css!./main.css'], function(){
-
- //储存版本信息
- yua.ui.tree = '1.0.0'
-
- var box = '
',
- ul = '',
- li = ''
- + ''
- + ''
- + '{child}';
- var keyPath = {};
-
-
- function repeat(arr, name){
- var html = ''
- arr.forEach(function(it, i){
- var from = name + '[' + i + ']',
- child = '';
- html += li.replace(/\{it\}/g, from);
-
- if(it.children){
- child += repeat(it.children, from +'.children')
- child = ul.replace('{li}', child).replace('{it}', from)
- }
- html = html.replace(/\{child\}/, child)
- })
-
- return html
- }
-
- function format(arr){
- var tmp = {}, farr = []
- arr.sort(function(a, b){
- return (a.pid === b.pid) ? (a.sort - b.sort) : (a.pid - b.pid)
- })
- arr.forEach(function(it){
- tmp[it.id] = it
- keyPath[it.id] = ''
- var parentItem = tmp[it.pid]
-
- if(!parentItem){
- return farr.push(tmp[it.id])
- }
- keyPath[it.id] += keyPath[parentItem.id] + parentItem.id + ','
- parentItem.open = !!parentItem.open
- parentItem.children = parentItem.children || []
- parentItem.children.push(it)
- })
- return farr
- }
-
- return yua.component('tree', {
- $template: '',
- $init: function(vm){
- vm.$select = function(obj){
- vm.currItem = obj.id
- if(vm.$onClick){
- vm.$onClick(obj)
- }
- }
- vm.$reset = function(arr){
- vm.treeArr.clear()
- vm.treeHTML = ''
-
- vm.treeArr.pushArray(format(arr))
- vm.currItem = -1
- var tpl = repeat(vm.treeArr.$model, 'treeArr')
- yua.nextTick(function(){
- vm.treeHTML = box.replace('{li}', tpl)
- })
-
- }
- vm.$update = function(id, obj){
- var path = keyPath[id],
- tmpid = null,
- tmpobj = null
-
- path += id
- path = path.split(',')
-
- while(tmpid = +path.shift()){
- if(!tmpobj){
- tmpobj = vm.treeArr
- }else{
- tmpobj = tmpobj.children
- }
-
- for(var i = 0, it; it = tmpobj[i++];){
- if(it.id === tmpid){
- tmpobj = it
- break
- }
- }
- }
- for(var j in obj){
- tmpobj[j] = obj[j]
- }
-
- }
- },
- $ready: function(vm){
- vm.$onSuccess(vm)
- },
- $skin: 'skin-def',
- treeHTML: '',
- currItem: -1,
- treeArr: [],
- $select: yua.noop,
- $update: yua.noop,
- $reset: yua.noop,
- $onSuccess: yua.noop,
- $onClick: yua.noop,
- $toggle: function(obj){
- obj.open = !obj.open
- }
- })
-
-})
\ No newline at end of file
diff --git a/src/js/lib/marked/main.js b/src/js/marked/main.js
similarity index 100%
rename from src/js/lib/marked/main.js
rename to src/js/marked/main.js
diff --git a/src/js/lib/marked/theme.scss b/src/js/marked/theme.scss
similarity index 100%
rename from src/js/lib/marked/theme.scss
rename to src/js/marked/theme.scss
diff --git a/src/js/lib/md5/Readme.md b/src/js/md5/Readme.md
similarity index 100%
rename from src/js/lib/md5/Readme.md
rename to src/js/md5/Readme.md
diff --git a/src/js/lib/md5/main.js b/src/js/md5/main.js
similarity index 100%
rename from src/js/lib/md5/main.js
rename to src/js/md5/main.js
diff --git a/src/js/lib/meditor/addon/attach.js b/src/js/meditor/addon/attach.js
similarity index 100%
rename from src/js/lib/meditor/addon/attach.js
rename to src/js/meditor/addon/attach.js
diff --git a/src/js/lib/meditor/addon/attach.scss b/src/js/meditor/addon/attach.scss
similarity index 100%
rename from src/js/lib/meditor/addon/attach.scss
rename to src/js/meditor/addon/attach.scss
diff --git a/src/js/lib/meditor/addon/base.js b/src/js/meditor/addon/base.js
similarity index 100%
rename from src/js/lib/meditor/addon/base.js
rename to src/js/meditor/addon/base.js
diff --git a/src/js/lib/meditor/addon/face/0.gif b/src/js/meditor/addon/face/0.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/0.gif
rename to src/js/meditor/addon/face/0.gif
diff --git a/src/js/lib/meditor/addon/face/1.gif b/src/js/meditor/addon/face/1.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/1.gif
rename to src/js/meditor/addon/face/1.gif
diff --git a/src/js/lib/meditor/addon/face/10.gif b/src/js/meditor/addon/face/10.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/10.gif
rename to src/js/meditor/addon/face/10.gif
diff --git a/src/js/lib/meditor/addon/face/11.gif b/src/js/meditor/addon/face/11.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/11.gif
rename to src/js/meditor/addon/face/11.gif
diff --git a/src/js/lib/meditor/addon/face/12.gif b/src/js/meditor/addon/face/12.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/12.gif
rename to src/js/meditor/addon/face/12.gif
diff --git a/src/js/lib/meditor/addon/face/13.gif b/src/js/meditor/addon/face/13.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/13.gif
rename to src/js/meditor/addon/face/13.gif
diff --git a/src/js/lib/meditor/addon/face/14.gif b/src/js/meditor/addon/face/14.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/14.gif
rename to src/js/meditor/addon/face/14.gif
diff --git a/src/js/lib/meditor/addon/face/15.gif b/src/js/meditor/addon/face/15.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/15.gif
rename to src/js/meditor/addon/face/15.gif
diff --git a/src/js/lib/meditor/addon/face/16.gif b/src/js/meditor/addon/face/16.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/16.gif
rename to src/js/meditor/addon/face/16.gif
diff --git a/src/js/lib/meditor/addon/face/17.gif b/src/js/meditor/addon/face/17.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/17.gif
rename to src/js/meditor/addon/face/17.gif
diff --git a/src/js/lib/meditor/addon/face/18.gif b/src/js/meditor/addon/face/18.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/18.gif
rename to src/js/meditor/addon/face/18.gif
diff --git a/src/js/lib/meditor/addon/face/19.gif b/src/js/meditor/addon/face/19.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/19.gif
rename to src/js/meditor/addon/face/19.gif
diff --git a/src/js/lib/meditor/addon/face/2.gif b/src/js/meditor/addon/face/2.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/2.gif
rename to src/js/meditor/addon/face/2.gif
diff --git a/src/js/lib/meditor/addon/face/20.gif b/src/js/meditor/addon/face/20.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/20.gif
rename to src/js/meditor/addon/face/20.gif
diff --git a/src/js/lib/meditor/addon/face/21.gif b/src/js/meditor/addon/face/21.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/21.gif
rename to src/js/meditor/addon/face/21.gif
diff --git a/src/js/lib/meditor/addon/face/22.gif b/src/js/meditor/addon/face/22.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/22.gif
rename to src/js/meditor/addon/face/22.gif
diff --git a/src/js/lib/meditor/addon/face/23.gif b/src/js/meditor/addon/face/23.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/23.gif
rename to src/js/meditor/addon/face/23.gif
diff --git a/src/js/lib/meditor/addon/face/24.gif b/src/js/meditor/addon/face/24.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/24.gif
rename to src/js/meditor/addon/face/24.gif
diff --git a/src/js/lib/meditor/addon/face/25.gif b/src/js/meditor/addon/face/25.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/25.gif
rename to src/js/meditor/addon/face/25.gif
diff --git a/src/js/lib/meditor/addon/face/26.gif b/src/js/meditor/addon/face/26.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/26.gif
rename to src/js/meditor/addon/face/26.gif
diff --git a/src/js/lib/meditor/addon/face/27.gif b/src/js/meditor/addon/face/27.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/27.gif
rename to src/js/meditor/addon/face/27.gif
diff --git a/src/js/lib/meditor/addon/face/28.gif b/src/js/meditor/addon/face/28.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/28.gif
rename to src/js/meditor/addon/face/28.gif
diff --git a/src/js/lib/meditor/addon/face/29.gif b/src/js/meditor/addon/face/29.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/29.gif
rename to src/js/meditor/addon/face/29.gif
diff --git a/src/js/lib/meditor/addon/face/3.gif b/src/js/meditor/addon/face/3.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/3.gif
rename to src/js/meditor/addon/face/3.gif
diff --git a/src/js/lib/meditor/addon/face/30.gif b/src/js/meditor/addon/face/30.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/30.gif
rename to src/js/meditor/addon/face/30.gif
diff --git a/src/js/lib/meditor/addon/face/31.gif b/src/js/meditor/addon/face/31.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/31.gif
rename to src/js/meditor/addon/face/31.gif
diff --git a/src/js/lib/meditor/addon/face/32.gif b/src/js/meditor/addon/face/32.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/32.gif
rename to src/js/meditor/addon/face/32.gif
diff --git a/src/js/lib/meditor/addon/face/33.gif b/src/js/meditor/addon/face/33.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/33.gif
rename to src/js/meditor/addon/face/33.gif
diff --git a/src/js/lib/meditor/addon/face/34.gif b/src/js/meditor/addon/face/34.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/34.gif
rename to src/js/meditor/addon/face/34.gif
diff --git a/src/js/lib/meditor/addon/face/35.gif b/src/js/meditor/addon/face/35.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/35.gif
rename to src/js/meditor/addon/face/35.gif
diff --git a/src/js/lib/meditor/addon/face/4.gif b/src/js/meditor/addon/face/4.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/4.gif
rename to src/js/meditor/addon/face/4.gif
diff --git a/src/js/lib/meditor/addon/face/5.gif b/src/js/meditor/addon/face/5.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/5.gif
rename to src/js/meditor/addon/face/5.gif
diff --git a/src/js/lib/meditor/addon/face/6.gif b/src/js/meditor/addon/face/6.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/6.gif
rename to src/js/meditor/addon/face/6.gif
diff --git a/src/js/lib/meditor/addon/face/7.gif b/src/js/meditor/addon/face/7.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/7.gif
rename to src/js/meditor/addon/face/7.gif
diff --git a/src/js/lib/meditor/addon/face/8.gif b/src/js/meditor/addon/face/8.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/8.gif
rename to src/js/meditor/addon/face/8.gif
diff --git a/src/js/lib/meditor/addon/face/9.gif b/src/js/meditor/addon/face/9.gif
similarity index 100%
rename from src/js/lib/meditor/addon/face/9.gif
rename to src/js/meditor/addon/face/9.gif
diff --git a/src/js/lib/meditor/main.js b/src/js/meditor/main.js
similarity index 100%
rename from src/js/lib/meditor/main.js
rename to src/js/meditor/main.js
diff --git a/src/js/lib/meditor/skin/main.scss b/src/js/meditor/skin/main.scss
similarity index 100%
rename from src/js/lib/meditor/skin/main.scss
rename to src/js/meditor/skin/main.scss
diff --git a/src/js/lib/pages/index.js b/src/js/pages/index.js
similarity index 98%
rename from src/js/lib/pages/index.js
rename to src/js/pages/index.js
index 4bccbf1..0bc5a33 100644
--- a/src/js/lib/pages/index.js
+++ b/src/js/pages/index.js
@@ -50,12 +50,12 @@ function update(currPage, vm) {
}
export default Anot.component('pages', {
- construct: function(props, next) {
+ construct: function(props, state, next) {
props.className =
'skin-' + (props.theme || 1) + ' ' + (props.color || 'plain')
delete props.theme
delete props.color
- next(props)
+ next(props, state)
},
render: function() {
return tpl
diff --git a/src/js/lib/pages/main.htm b/src/js/pages/main.htm
similarity index 100%
rename from src/js/lib/pages/main.htm
rename to src/js/pages/main.htm
diff --git a/src/js/lib/pages/main.scss b/src/js/pages/main.scss
similarity index 98%
rename from src/js/lib/pages/main.scss
rename to src/js/pages/main.scss
index b60f3c8..e9d37bb 100644
--- a/src/js/lib/pages/main.scss
+++ b/src/js/pages/main.scss
@@ -6,8 +6,7 @@
* @version $Id$
*/
-@import "../../../css/var.scss";
-
+@import "../css/var.scss";
.do-pages {height:auto;text-align:center;font-size:13px;color: nth($cgr, 1);
diff --git a/src/js/lib/prism/base.js b/src/js/prism/base.js
similarity index 100%
rename from src/js/lib/prism/base.js
rename to src/js/prism/base.js
diff --git a/src/js/lib/prism/full.js b/src/js/prism/full.js
similarity index 100%
rename from src/js/lib/prism/full.js
rename to src/js/prism/full.js
diff --git a/src/js/lib/prism/highlight.scss b/src/js/prism/highlight.scss
similarity index 100%
rename from src/js/lib/prism/highlight.scss
rename to src/js/prism/highlight.scss
diff --git a/src/js/lib/promise/index.js b/src/js/promise/index.js
similarity index 100%
rename from src/js/lib/promise/index.js
rename to src/js/promise/index.js
diff --git a/src/js/lib/request/index.js b/src/js/request/index.js
similarity index 99%
rename from src/js/lib/request/index.js
rename to src/js/request/index.js
index 469668a..d866efa 100644
--- a/src/js/lib/request/index.js
+++ b/src/js/request/index.js
@@ -6,7 +6,7 @@
*/
'use strict'
-import 'lib/promise/index'
+import 'promise/index'
import Format from './lib/format'
var _request = function(url, protocol) {
diff --git a/src/js/lib/request/lib/format.js b/src/js/request/lib/format.js
similarity index 100%
rename from src/js/lib/request/lib/format.js
rename to src/js/request/lib/format.js
diff --git a/src/js/lib/request/lib/json.js b/src/js/request/lib/json.js
similarity index 100%
rename from src/js/lib/request/lib/json.js
rename to src/js/request/lib/json.js
diff --git a/src/js/lib/request/light.js b/src/js/request/light.js
similarity index 99%
rename from src/js/lib/request/light.js
rename to src/js/request/light.js
index 2fdc641..b83e268 100644
--- a/src/js/lib/request/light.js
+++ b/src/js/request/light.js
@@ -6,7 +6,7 @@
*/
'use strict'
-import 'lib/promise/index'
+import 'promise/index'
import Format from './lib/format'
var _request = function(url, protocol) {
diff --git a/src/js/lib/router/main.js b/src/js/router/main.js
similarity index 100%
rename from src/js/lib/router/main.js
rename to src/js/router/main.js
diff --git a/src/js/lib/sliders/Readme.md b/src/js/sliders/Readme.md
similarity index 100%
rename from src/js/lib/sliders/Readme.md
rename to src/js/sliders/Readme.md
diff --git a/src/js/lib/sliders/main.htm b/src/js/sliders/main.htm
similarity index 100%
rename from src/js/lib/sliders/main.htm
rename to src/js/sliders/main.htm
diff --git a/src/js/lib/sliders/main.js b/src/js/sliders/main.js
similarity index 100%
rename from src/js/lib/sliders/main.js
rename to src/js/sliders/main.js
diff --git a/src/js/lib/sliders/main.scss b/src/js/sliders/main.scss
similarity index 100%
rename from src/js/lib/sliders/main.scss
rename to src/js/sliders/main.scss
diff --git a/src/js/tree/index.js b/src/js/tree/index.js
new file mode 100644
index 0000000..89d237b
--- /dev/null
+++ b/src/js/tree/index.js
@@ -0,0 +1,152 @@
+/**
+ *
+ * @authors yutent (yutent@doui.cc)
+ * @date 2017-04-14 21:04:50
+ *
+ */
+
+'use strict'
+
+import './main.scss'
+
+//储存版本信息
+Anot.ui.tree = '1.0.0'
+
+var box = '',
+ ul = '',
+ li =
+ '' +
+ '' +
+ '' +
+ '{child}'
+var keyPath = {}
+
+function repeat(arr, name) {
+ var html = ''
+ arr.forEach(function(it, i) {
+ var from = name + '[' + i + ']',
+ child = ''
+ html += li.replace(/\{it\}/g, from)
+
+ if (it.children) {
+ child += repeat(it.children, from + '.children')
+ child = ul.replace('{li}', child).replace('{it}', from)
+ }
+ html = html.replace(/\{child\}/, child)
+ })
+
+ return html
+}
+
+function format(arr) {
+ var tmp = {},
+ farr = []
+ arr.sort(function(a, b) {
+ return a.pid === b.pid ? a.sort - b.sort : a.pid - b.pid
+ })
+ arr.forEach(function(it) {
+ tmp[it.id] = it
+ keyPath[it.id] = ''
+ var parentItem = tmp[it.pid]
+
+ if (!parentItem) {
+ return farr.push(tmp[it.id])
+ }
+ keyPath[it.id] += keyPath[parentItem.id] + parentItem.id + ','
+ parentItem.open = !!parentItem.open
+ parentItem.children = parentItem.children || []
+ parentItem.children.push(it)
+ })
+ return farr
+}
+
+export default Anot.component('tree', {
+ render: function() {
+ // return ''
+ return `
+
+ `
+ },
+ construct: function(props, state, next) {
+ props.className = 'skin-' + (props.theme || 'def')
+ state.list = format(props.list || [])
+
+ delete props.list
+ delete props.theme
+ next(props, state)
+ },
+ componentWillMount: function() {
+ // this.$reset(this.props.arr)
+ },
+ componentDidMount: function() {
+ if (typeof this.props.created === 'function') {
+ this.props.created.call(null, this)
+ }
+ },
+ state: {
+ treeHTML: '',
+ list: [],
+ currItem: -1
+ },
+ props: {
+ className: '',
+ created: Anot.PropsTypes.isFunction(),
+ componentWillMount: Anot.PropsTypes.isFunction()
+ },
+ methods: {
+ toggle: function(obj) {
+ obj.open = !obj.open
+ },
+ select: function(obj) {
+ this.currItem = obj.id
+ console.log(obj, this.props.componentWillMount)
+ if (typeof this.props.componentWillMount === 'function') {
+ this.props.componentWillMount(obj)
+ }
+ },
+ $update: function(id, obj) {
+ var path = keyPath[id],
+ tmpid = null,
+ tmpobj = null
+
+ path += id
+ path = path.split(',')
+
+ while ((tmpid = +path.shift())) {
+ if (!tmpobj) {
+ tmpobj = this.treeArr
+ } else {
+ tmpobj = tmpobj.children
+ }
+
+ for (var i = 0, it; (it = tmpobj[i++]); ) {
+ if (it.id === tmpid) {
+ tmpobj = it
+ break
+ }
+ }
+ }
+ for (var j in obj) {
+ tmpobj[j] = obj[j]
+ }
+ },
+ $reset: function(arr) {
+ this.treeArr.clear()
+ this.treeHTML = ''
+
+ this.treeArr.pushArray(format(arr))
+ this.currItem = -1
+ console.log(this.treeArr)
+ /* var tpl = repeat(this.treeArr.$model, 'treeArr')
+ Anot.nextTick(() => {
+ this.treeHTML = box.replace('{li}', tpl)
+ })*/
+ }
+ }
+})
diff --git a/src/js/lib/tree/main.scss b/src/js/tree/main.scss
similarity index 63%
rename from src/js/lib/tree/main.scss
rename to src/js/tree/main.scss
index dffc1c7..8a5cff7 100644
--- a/src/js/lib/tree/main.scss
+++ b/src/js/tree/main.scss
@@ -6,20 +6,21 @@
*
*/
+@import '../../css/var.scss';
-.do-tree {overflow:hidden;overflow-y:auto;position:relative;width:100%;height:100%;line-height:28px;
+.do-tree {overflow:hidden;overflow-y:auto;position:relative;width:100%;height:100%;line-height:28px;font-size:13px;
ul {width:100%;height:auto;}
li {overflow:hidden; white-space:nowrap; text-overflow:ellipsis}
li ul {display:none;margin-left:20px;}
- li ul.open {display:block;}
+ li.open ul {display:block;}
li em,
li span {display:block;cursor:pointer;}
li em {float:left;padding:0 5px;color:#000;font-family:"ui font" !important;font-style:normal;-webkit-font-smoothing: antialiased;-webkit-text-stroke-width: 0.2px;-moz-osx-font-smoothing: grayscale;}
- li span:hover {color:#6bb294;}
+ li span:hover {color:nth($cgr, 2);}
li span.active {color:#000;font-weight:bold;}
&.skin-def {
@@ -27,17 +28,4 @@
li.dir>em::before {content:"\e622";}
li.dir.open>em::before {content:"\e8ea";}
}
-
- &.skin-light {
- li>em::before {content:"\e73e";}
- li.dir>em::before {content:"\e635";}
- li.dir.open>em::before {content:"\e8ea";}
- }
-
-
- &.skin-line {
- li>em::before {content:"\e614";}
- li.dir>em::before {content:"\e8eb";font-weight:bold;}
- li.dir.open>em::before {content:"\e662";}
- }
}
\ No newline at end of file
diff --git a/src/js/lib/uploader/uploader.js b/src/js/uploader/uploader.js
similarity index 100%
rename from src/js/lib/uploader/uploader.js
rename to src/js/uploader/uploader.js