This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

重新调整目录结构;使用es6语法重写,Babel自动自动以UMD规范编译为es5, 以更好的支持webpack

old
宇天 2017-12-04 02:02:18 +08:00
parent 442707471b
commit d393ad4876
116 changed files with 13798 additions and 10655 deletions

2
.gitignore vendored
View File

@ -2,5 +2,7 @@
*.min.css
index.html
.vscode
node_modules/
dist/
dist.sublime-project
dist.sublime-workspace

View File

@ -2,3 +2,17 @@
## yua.js 框架
> yua.js是一款迷你,易用、高性能的前端MVVM框架, 属于单独维护avalon的一个独立分支, 基于avalon1.5开发, 精简部分冗余的API, 同时针对组件拓展进行了优化。
## doUI 组件库
> doUI组件库是基于yua框架开发的一套高效,轻量,可定制的现代化组件库。
## 开发环境及生产环境
```bash
# 开发环境
npm start
# 生产环境
npm run build
```

95
build.dev.js Normal file
View File

@ -0,0 +1,95 @@
#! /usr/bin/env node
const fs = require('iofs')
const path = require('path')
const babel = require('babel-core')
const scss = require('node-sass')
const chokidar = require('chokidar')
const log = console.log
const sourceDir = path.resolve(__dirname, 'src')
const buildDir = path.resolve(__dirname, 'dist')
const jsOpt = {
presets: ['es2015'],
plugins: ['transform-es2015-modules-umd']
}
const cssOpt = {
includePaths: ['src/css/'],
outputStyle: 'compressed'
}
const compileJs = (entry, output) => {
let t1 = Date.now()
const { code } = babel.transformFileSync(entry, jsOpt)
log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(code, output)
}
const compileCss = (entry, output) => {
let t1 = Date.now()
const { css } = scss.renderSync({ ...cssOpt, file: entry })
log('编译scss: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(css, output)
}
const compileHtm = (entry, output) => {
let t1 = Date.now()
let htm = fs.cat(entry).toString('utf8')
htm = htm.replace(/[\r\n\t]+/g, ' ').replace(/\s{2,}/g, ' ')
log('压缩HTML: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(htm, output)
}
/*=======================================================*/
/*===== ===*/
/*=======================================================*/
const fontFiles = fs.ls('./src/font/', true)
const jsFiles = fs.ls('./src/js/', true)
const cssFiles = fs.ls('./src/css/', true)
// 字体文件直接复制
chokidar.watch(path.join(sourceDir, 'font/')).on('all', (act, file) => {
if (act === 'add' || act === 'change') {
let output = file.replace('src/font/', 'dist/font/')
fs.cp(file, output)
}
})
// css目录
chokidar.watch(path.resolve(sourceDir, 'css/')).on('all', (act, file) => {
if (act === 'add' || act === 'change') {
if (/\.scss$/.test(file)) {
let output = file.replace('src/css/', 'dist/css/')
compileCss(file, output)
}
}
})
// js目录的处理要复杂一点
chokidar
.watch(path.resolve(sourceDir, 'js/'))
.on('all', (act, file) => {
if (act === 'add' || act === 'change') {
let output = file.replace('src/js/', 'dist/js/')
let ext = file.slice(file.lastIndexOf('.') + 1)
switch (ext) {
case 'js':
compileJs(file, output)
break
case 'scss':
output = output.replace(/scss$/, 'css')
compileCss(file, output)
break
case 'htm':
compileHtm(file, output)
break
default:
fs.cp(file, output)
}
}
})
.on('ready', () => {
log('预处理完成,监听文件变化中,请勿关闭本窗口...')
})

93
build.prod.js Normal file
View File

@ -0,0 +1,93 @@
#! /usr/bin/env node
const fs = require('iofs')
const path = require('path')
const babel = require('babel-core')
const scss = require('node-sass')
const log = console.log
const sourceDir = path.resolve(__dirname, 'src')
const buildDir = path.resolve(__dirname, 'dist')
const jsOpt = {
presets: ['es2015', 'minify'],
plugins: ['transform-es2015-modules-umd']
}
const cssOpt = {
includePaths: ['src/css/'],
outputStyle: 'compressed'
}
const compileJs = (entry, output) => {
let t1 = Date.now()
const { code } = babel.transformFileSync(entry, jsOpt)
log('编译JS: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(code, output)
}
const compileCss = (entry, output) => {
let t1 = Date.now()
const { css } = scss.renderSync({ ...cssOpt, file: entry })
log('编译scss: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(css, output)
}
const compileHtm = (entry, output) => {
let t1 = Date.now()
let htm = fs.cat(entry).toString('utf8')
htm = htm.replace(/[\r\n\t]+/g, ' ').replace(/\s{2,}/g, ' ')
log('压缩HTML: %s, 耗时 %d ms', entry, Date.now() - t1)
fs.echo(htm, output)
}
/*=======================================================*/
/*===== ===*/
/*=======================================================*/
const fontFiles = fs.ls('./src/font/', true)
const jsFiles = fs.ls('./src/js/', true)
const cssFiles = fs.ls('./src/css/', true)
if (fs.isdir(buildDir)) {
fs.rm(buildDir, true)
log('清除旧目录 dist/')
}
// 字体文件直接复制
fontFiles.forEach(file => {
fs.cp('./src/font/' + file, './dist/font/' + file)
})
// css目录
cssFiles.forEach(file => {
if (/\.scss$/.test(file)) {
let entry = path.resolve(sourceDir, 'css/', file)
let output = path.resolve(buildDir, 'css/', file.replace(/scss$/, 'css'))
compileCss(entry, output)
}
})
// js目录的处理要复杂一点
jsFiles.forEach(file => {
let entry = path.resolve(sourceDir, 'js', file)
let output = path.resolve(buildDir, 'js', file)
let ext = file.slice(file.lastIndexOf('.') + 1)
switch (ext) {
case 'js':
compileJs(entry, output)
break
case 'scss':
output = output.replace(/scss$/, 'css')
compileCss(entry, output)
break
case 'htm':
compileHtm(entry, output)
break
default:
if (!fs.isdir(entry)) {
fs.cp(entry, output)
}
}
})

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
*{margin:0;padding:0;vertical-align:baseline;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,content{display:block}img{border:0;display:inline-block}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote::before,blockquote::after,q::before,q::after{content:'';content:none}table{border-collapse:collapse;border-spacing:0}a:focus,input,button:focus,input:focus{outline:none}::-moz-focus-inner{border:none;outline:none}@font-face{font-family:"ui font";src:url("../font/ui-font.eot");src:url("../font/ui-font.ttf") format("truetype")}.do-ui-font{display:inline-block;font-family:"ui font" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.do-fn-cl{*zoom:1}.do-fn-cl::after{content:".";display:block;height:0;clear:both;visibility:hidden;overflow:hidden}.do-fn-clear{clear:both;display:inline}.do-fn-show{display:block}.do-fn-hide{display:none}.do-fn-fl{float:left}.do-fn-fr{float:right}.do-fn-noselect{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.do-fn-noselect img,.do-fn-noselect a{-webkit-user-drag:none}.do-fn-ell{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.do-st-thin{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.do-st-hand{cursor:pointer}

View File

@ -1,275 +0,0 @@
.CodeMirror {
height: 100%;
line-height: 1.5;
font-family: monospace;
position: relative;
overflow: hidden;
background: #272822;
color: #f8f8f2
}
.CodeMirror-scroll {
overflow: auto;
height: 100%;
width: 100%;
position: relative;
outline: none
}
.CodeMirror-scrollbar {
position: absolute;
right: 0;
top: 0;
overflow-x: hidden;
overflow-y: scroll;
z-index: 5
}
.CodeMirror-scrollbar-inner {
width: 1px
}
.CodeMirror-scrollbar.cm-sb-overlap {
position: absolute;
z-index: 1;
float: none;
right: 0;
min-width: 12px
}
.CodeMirror-scrollbar.cm-sb-nonoverlap {
min-width: 12px
}
.CodeMirror-scrollbar.cm-sb-ie7 {
min-width: 18px
}
.CodeMirror-gutter {
position: absolute;
left: 0;
top: 0;
z-index: 10;
background-color: transparent;
border-right: 1px solid #454545;
min-width: 2em;
height: 100%
}
.CodeMirror-gutter-text {
color: #aaa;
text-align: right;
padding: .4em .2em .4em .4em;
white-space: pre !important;
cursor: default
}
.CodeMirror-lines {
padding: .4em;
white-space: pre;
cursor: text
}
.CodeMirror pre {
-moz-border-radius: 0;
-webkit-border-radius: 0;
-o-border-radius: 0;
border-radius: 0;
border-width: 0;
margin: 0;
padding: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
padding: 0;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
overflow: visible
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal
}
.CodeMirror-wrap .CodeMirror-scroll {
overflow-x: hidden
}
.CodeMirror textarea {
outline: none !important
}
.CodeMirror pre.CodeMirror-cursor {
z-index: 10;
position: absolute;
visibility: hidden;
border-left: 1px solid #9effff;
border-right: none;
width: 0
}
.cm-keymap-fat-cursor pre.CodeMirror-cursor {
width: auto;
border: 0;
background: transparent;
background: rgba(0, 200, 0, .4);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800)
}
.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
filter: progid: DXImageTransform.Microsoft.gradient(enabled=false)
}
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
.CodeMirror-focused pre.CodeMirror-cursor {
visibility: visible
}
div.CodeMirror-selected {
background: #49483E
}
.CodeMirror-focused div.CodeMirror-selected {
background: #49483E
}
.CodeMirror-searching {
background: #ffa;
background: rgba(255, 255, 0, .4)
}
.cm-s-default span.cm-keyword {
color: #f92672
}
.cm-s-default span.cm-atom {
color: #ae81ff
}
.cm-s-default span.cm-number {
color: #f30
}
.cm-s-default span.cm-def {
color: #fd971f
}
.cm-s-default span.cm-variable {
color: #f8f8f2
}
.cm-s-default span.cm-variable-2 {
color: #9effff
}
.cm-s-default span.cm-variable-3 {
color: #66d9ef
}
.cm-s-default span.cm-property {
color: #66d9ef
}
.cm-s-default span.cm-operator {
color: #9effff
}
.cm-s-default span.cm-comment {
color: #75715e
}
.cm-s-default span.cm-string {
color: #e6db74
}
.cm-s-default span.cm-string-2 {
color: #f50
}
.cm-s-default span.cm-meta {
color: #555
}
.cm-s-default span.cm-error {
background: #f92672;
color: #f8f8f0
}
.cm-s-default span.cm-qualifier {
color: #75d908
}
.cm-s-default span.cm-builtin {
color: #66d9ef
}
.cm-s-default span.cm-bracket {
color: #f8f8f2
}
.cm-s-default span.cm-tag {
color: #f92672
}
.cm-s-default span.cm-attribute {
color: #a6e22e
}
.cm-s-default span.cm-header {
color: #ae81ff
}
.cm-s-default span.cm-quote {
color: #090
}
.cm-s-default span.cm-hr {
color: #999
}
.cm-s-default span.cm-link {
color: #ae81ff
}
span.cm-header,
span.cm-strong {
font-weight: bold
}
span.cm-em {
font-style: italic
}
span.cm-emstrong {
font-style: italic;
font-weight: bold
}
span.cm-link {
text-decoration: underline
}
span.cm-invalidchar {
color: #f00
}
div.CodeMirror span.CodeMirror-matchingbracket {
text-decoration: underline;
color: #fff!important
}
div.CodeMirror span.CodeMirror-nonmatchingbracket {
color: #f22
}
@media print {
.CodeMirror pre.CodeMirror-cursor {
visibility: hidden
}
}

View File

@ -1 +0,0 @@
.CodeMirror{height:100%;line-height:1.5;font-family:monospace;position:relative;overflow:hidden;background:#272822;color:#f8f8f2}.CodeMirror-scroll{overflow:auto;height:100%;width:100%;position:relative;outline:0}.CodeMirror-scrollbar{position:absolute;right:0;top:0;overflow-x:hidden;overflow-y:scroll;z-index:5}.CodeMirror-scrollbar-inner{width:1px}.CodeMirror-scrollbar.cm-sb-overlap{position:absolute;z-index:1;float:none;right:0;min-width:12px}.CodeMirror-scrollbar.cm-sb-nonoverlap{min-width:12px}.CodeMirror-scrollbar.cm-sb-ie7{min-width:18px}.CodeMirror-gutter{position:absolute;left:0;top:0;z-index:10;background-color:transparent;border-right:1px solid #454545;min-width:2em;height:100%}.CodeMirror-gutter-text{color:#aaa;text-align:right;padding:.4em .2em .4em .4em;white-space:pre!important;cursor:default}.CodeMirror-lines{padding:.4em;white-space:pre;cursor:text}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;-o-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;padding:0;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;overflow:visible}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.CodeMirror textarea{outline:0!important}.CodeMirror pre.CodeMirror-cursor{z-index:10;position:absolute;visibility:hidden;border-left:1px solid #9effff;border-right:none;width:0}.cm-keymap-fat-cursor pre.CodeMirror-cursor{width:auto;border:0;background:0 0;background:rgba(0,200,0,.4);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800)}.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id){filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.CodeMirror-focused pre.CodeMirror-cursor{visibility:visible}.CodeMirror-focused div.CodeMirror-selected,div.CodeMirror-selected{background:#49483E}.CodeMirror-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-s-default span.cm-keyword{color:#f92672}.cm-s-default span.cm-atom{color:#ae81ff}.cm-s-default span.cm-number{color:#f30}.cm-s-default span.cm-def{color:#fd971f}.cm-s-default span.cm-variable{color:#f8f8f2}.cm-s-default span.cm-variable-2{color:#9effff}.cm-s-default span.cm-property,.cm-s-default span.cm-variable-3{color:#66d9ef}.cm-s-default span.cm-operator{color:#9effff}.cm-s-default span.cm-comment{color:#75715e}.cm-s-default span.cm-string{color:#e6db74}.cm-s-default span.cm-string-2{color:#f50}.cm-s-default span.cm-meta{color:#555}.cm-s-default span.cm-error{background:#f92672;color:#f8f8f0}.cm-s-default span.cm-qualifier{color:#75d908}.cm-s-default span.cm-builtin{color:#66d9ef}.cm-s-default span.cm-bracket{color:#f8f8f2}.cm-s-default span.cm-tag{color:#f92672}.cm-s-default span.cm-attribute{color:#a6e22e}.cm-s-default span.cm-header{color:#ae81ff}.cm-s-default span.cm-quote{color:#090}.cm-s-default span.cm-hr{color:#999}.cm-s-default span.cm-link{color:#ae81ff}span.cm-header,span.cm-strong{font-weight:700}span.cm-em{font-style:italic}span.cm-emstrong{font-style:italic;font-weight:700}span.cm-link{text-decoration:underline}span.cm-invalidchar{color:red}div.CodeMirror span.CodeMirror-matchingbracket{text-decoration:underline;color:#fff!important}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}@media print{.CodeMirror pre.CodeMirror-cursor{visibility:hidden}}

View File

@ -1 +0,0 @@
"use strict";define(["avalon"],function(t){function e(t,e){if(t+="",t.length>=e)return t;for(;t.length<e;)t="0"+t;return t}return t.component("do:count",{$replace:!0,$template:'<ul class="do-ui-count"><li class="num-box" ms-repeat-obj="list" ms-class="split:obj.opt === 0"><span class="num" ms-repeat="obj.val">{{el}}</span></li></ul>',maxLen:8,speed:1,update:t.noop,list:[],$list:[],total:0,style:2,$construct:function(e,i,l){var n=t.mix(i,l);return document.head.insertAdjacentHTML("afterBegin","<style>.do-ui-count {width: 100%;height: 50px;text-align:center;}.do-ui-count li.num-box {overflow:hidden;display: inline-block;position: relative;width: 40px;height: 50px;margin:0 15px;line-height: 50px;background: #09f;font-size: 30px;}.do-ui-count li.num-box .num {display: block;width: 100%;height: 50px;margin-top: 0;transition: .3s ease-in-out}.do-ui-count li.num-box.split {width: auto;margin:0;background: none;}</style>"),n.total=n.total>>0,n.maxLen=n.maxLen||8,t.mix(e,n)},$ready:function(t,i){function l(l){l=e(l,t.maxLen),t.$list=[],t.$list=l.split(""),2===t.style&&(t.$list=t.$list.reverse(),l=t.$list.join("").replace(/([\d,]{3})/g,"$1,"),l=l.replace(/^,|,$/g,""),t.$list=l.split("").reverse()),t.$list.forEach(function(e,l){if(","===e)t.list[l]||t.list.push({opt:0,val:[e]});else if(t.list[l]){if(e!==t.list[l].last){t.list[l].last=e,t.list[l].val.push(e);var n=i.querySelectorAll(".num-box")[l];n.querySelector(".num").style.marginTop=50*t.speed+"px",setTimeout(function(){t.list[l].val.shift()},300)}}else t.list.push({opt:1,last:e,val:[e]})})}l(t.total),t.update=function(e){t.speed=0>e?1:-1,t.total=t.total-0+e},t.$watch("total",function(t,e){t!==e&&l(t)})}}),t});

View File

@ -1 +0,0 @@
.do-datepicker{position:relative;z-index:65534;width:100%;height:100%}.do-datepicker a{text-decoration:none}.do-datepicker .date-input{display:block;width:100%;height:100%;padding:0 5px;line-height:18px;border:1px solid #e7e8eb;transition:all .1s ease-in-out}.do-datepicker .date-input:focus{border-color:#1abc9c}.do-datepicker .calendar-box{position:absolute;left:0;top:100%;width:267px;height:auto;min-height:60px;padding:10px;line-height:35px;border:1px solid #ddd;background:#fff;font-size:14px;color:#546e7a;text-align:center;box-shadow:0 1px 5px rgba(0,0,0,0.1)}.do-datepicker .calendar-box dt.title{width:100%;height:35px;background:#e7e8eb}.do-datepicker .calendar-box dd.contrl{position:relative;width:90%;height:35px;margin:0 5%}.do-datepicker .calendar-box dd.contrl a{position:absolute;left:0;top:0;width:35px;height:35px;color:#546e7a;font-weight:bold}.do-datepicker .calendar-box dd.contrl a:hover{color:#1abc9c}.do-datepicker .calendar-box dd.contrl a.prev-month{left:35px}.do-datepicker .calendar-box dd.contrl a.next-month{left:auto;right:35px}.do-datepicker .calendar-box dd.contrl a.next-year{left:auto;right:0}.do-datepicker .calendar-box dd.calendar{width:100%;height:auto}.do-datepicker .calendar-box dd.calendar .week{width:100%;height:35px;margin-bottom:5px;border-bottom:1px solid #eee}.do-datepicker .calendar-box dd.calendar span.td{float:left;width:35px}.do-datepicker .calendar-box dd.calendar .list span.td{height:30px;line-height:30px;cursor:pointer;transition:all .1s ease-in-out}.do-datepicker .calendar-box dd.calendar .list span.td:hover{background:#e7e8eb}.do-datepicker .calendar-box dd.calendar .list span.td.weeken{color:#ff5722}.do-datepicker .calendar-box dd.calendar .list span.td.selected{background:#48c9b0;color:#fff}.do-datepicker .calendar-box dd.calendar .list span.td.disabled{color:#bdc3c7;cursor:default}.do-datepicker .calendar-box dd.calendar .list span.td.disabled:hover{background:none}.do-datepicker .calendar-box dd.time{position:relative;width:100%;height:41px;padding:5px 0;margin-top:5px;line-height:30px;border-top:1px solid #eee}.do-datepicker .calendar-box dd.time label{float:left;width:60px;height:30px}.do-datepicker .calendar-box dd.time label input{width:30px;height:30px;border:1px solid #e7e8eb;text-align:center}.do-datepicker .calendar-box dd.time .now{float:right;width:50px;height:30px;border-radius:3px;background:#1abc9c;color:#fff;text-align:center}.do-datepicker .calendar-box dd.time .now:hover{background:#48c9b0}.do-datepicker .calendar-box dd.time .now:active{background:#16a085}.do-datepicker .calendar-box dd.tips{position:absolute;z-index:65535;left:25%;top:40%;width:50%;height:30px;line-height:30px;background:rgba(0,0,0,0.7);color:#fff;font-size:12px;text-align:center}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
.do-marked-theme{position:relative}.do-marked-theme .md-head{position:relative;margin:15px 0;padding-left:30px;font-weight:normal;font-size:17px}.do-marked-theme h1.md-head{padding-left:0}.do-marked-theme .md-head a{position:relative;display:inline-block;padding:0 8px;background:#fff;color:#454545}.do-marked-theme .md-head a:hover{text-decoration:none}.do-marked-theme h1.md-head a{padding-left:0;color:#000}.do-marked-theme h2.md-head a{color:#000}.do-marked-theme h1.md-head{margin:0 0 30px;font-size:25px}.do-marked-theme h2.md-head{margin:20px 0;font-size:23px}.do-marked-theme h3.md-head{margin:20px 0 15px;font-size:20px}.do-marked-theme h1:after{display:block;width:100%;content:" ";border-bottom:1px solid #ddd}.do-marked-theme h2:before,.do-marked-theme h3:before,.do-marked-theme h4:before,.do-marked-theme h5:before,.do-marked-theme h6:before{display:block;position:absolute;left:0;top:50%;width:100%;content:" ";border-bottom:1px solid #ddd}.do-marked-theme a{text-decoration:none}.do-marked-theme a:hover{text-decoration:underline}.do-marked-theme p{margin:15px 0}.do-marked-theme blockquote.md-quote{margin:10px 0;padding:5px 10px;border-left:5px solid #6bb294;background:#f7f7f7}.do-marked-theme blockquote.md-quote p{margin:0}.do-marked-theme .md-warn,.do-marked-theme .md-mark{display:inline-block;position:relative;min-height:40px;margin:5px 0;padding:5px 8px 5px 50px;border:1px solid #ff9800;border-radius:5px;background:#fffbed;color:#f57c00;word-break:break-all}.do-marked-theme .md-warn p,.do-marked-theme .md-mark p{margin:0 !important}.do-marked-theme .md-warn::before,.do-marked-theme .md-mark::before{position:absolute;left:15px;top:5px;font:20px/1.5 "ui font";color:#ff5722;content:"\e6f6"}.do-marked-theme .md-mark{border-color:#48c9b0;color:#16a085;background:#edfbf8}.do-marked-theme .md-mark::before{color:#16a085;content:"\e657"}.do-marked-theme table{width:100%}.do-marked-theme table thead tr{height:45px;line-height:45px;background:#f7f7f7}.do-marked-theme table thead th{padding:0 8px;border:0}.do-marked-theme table tbody tr{height:43px;line-height:42px;transition:all .3s ease-in-out}.do-marked-theme table tbody tr:hover{background:#ecf6fd}.do-marked-theme table tbody td{padding:0 8px;border-bottom:1px solid #e9e9e9}.do-marked-theme hr{margin:30px 0;border-bottom:0}.do-marked-theme ol{margin-left:2em;list-style:decimal outside none}.do-marked-theme ul{margin-left:2em;list-style:disc outside none}.do-marked-theme li ol{margin-left:2em}.do-marked-theme li ul{margin-left:2em;list-style-type:circle}.do-marked-theme li ol ul,.do-marked-theme li ul ul{list-style-type:square}

View File

@ -1 +0,0 @@
.do-meditor-attach{width:630px;height:auto;background:#f7f7f7;cursor:default}.do-meditor-attach .tab-box{width:100%;height:50px;line-height:49px;border-bottom:1px solid #e2e2e2;text-align:center}.do-meditor-attach .tab-box .item{position:relative;float:left;width:100px;height:49px;border-right:1px solid #ddd;cursor:pointer}.do-meditor-attach .tab-box .item.active{background:#fff}.do-meditor-attach .tab-box .item.active::after{position:absolute;left:0;bottom:-1px;width:100%;height:1px;background:#fff;content:""}.do-meditor-attach .tab-box a.action-close{top:5px;width:40px;height:40px;line-height:40px;font-size:20px}.do-meditor-attach .tab-box a.action-close:hover{line-height:40px;border:0}.do-meditor-attach .cont-box{position:relative;width:100%;height:auto;min-height:200px;background:#fff}.do-meditor-attach .cont-box .remote,.do-meditor-attach .cont-box .local{position:relative;width:60%;height:auto;margin:0 auto;padding:15px 0 30px}.do-meditor-attach .cont-box .local{width:96%}.do-meditor-attach .cont-box .hide{display:none}.do-meditor-attach .cont-box .section{display:block;width:100%;height:auto;margin:15px 0;line-height:35px}.do-meditor-attach .cont-box .section.input{line-height:33px;border:1px solid #e9e9e9}.do-meditor-attach .cont-box .section .label{float:left;width:30%;text-align:center;background:#f7f7f7}.do-meditor-attach .cont-box .section .txt{float:left;width:70%;height:33px;padding:0 8px;border:0;border-left:1px solid #e9e9e9;background:#fff;color:#666}.do-meditor-attach .cont-box .section .submit{float:right;width:30%;height:35px;background:#ddd;color:#666;text-align:center}.do-meditor-attach .cont-box .select-file{width:100%;height:35px;line-height:33px}.do-meditor-attach .cont-box .select-file span.file{float:left;width:100px;height:35px;border:1px solid #ddd;background:#f7f7f7;color:#666;text-align:center;cursor:pointer}.do-meditor-attach .cont-box .select-file span.tips{display:inline-block;padding:0 10px;line-height:35px;color:#666}.do-meditor-attach .cont-box .upload-box{width:100%;height:auto;min-height:190px;margin:10px 0;border:1px solid #e2e2e2}.do-meditor-attach .cont-box .upload-box .tr{width:100%;height:35px;line-height:35px;text-align:center}.do-meditor-attach .cont-box .upload-box .tr:hover{background:#fafafa}.do-meditor-attach .cont-box .upload-box .thead{line-height:34px;border-bottom:1px solid #e2e2e2;background:#f7f7f7}.do-meditor-attach .cont-box .upload-box .td{float:left}.do-meditor-attach .cont-box .upload-box .td.name{width:45%}.do-meditor-attach .cont-box .upload-box .td.progress{width:40%}.do-meditor-attach .cont-box .upload-box .td.option{width:15%}.do-meditor-attach .cont-box .upload-box .td.option a{display:inline-block;padding:3px 5px;line-height:13px;border:1px solid #e2e2e2;background:#f7f7f7;color:#666}.do-meditor-attach .cont-box .upload-box .td .red{color:#f30}.do-meditor-attach .cont-box .manager{overflow:hidden;overflow-y:auto;width:100%;height:320px;padding:10px}.do-meditor-attach .cont-box .manager .item{float:left;width:22%;height:130px;margin:10px 1.5%;padding:5px}.do-meditor-attach .cont-box .manager .item:hover{background:#f7f7f7}.do-meditor-attach .cont-box .manager .thumb{display:block;width:100%;height:100px}.do-meditor-attach .cont-box .manager .name{overflow:hidden;height:20px;line-height:30px;text-align:center}.do-meditor-attach .cont-box .manager img{width:100%;height:100%}.do-meditor-attach .cont-box .manager .attach-icon{display:inline-block;width:100%;height:100px;text-align:center;font:50px/100px "ui font" !important;-webkit-font-smoothing:antialiased;-webkit-text-stroke-width:0.2px;-moz-osx-font-smoothing:grayscale}

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
.do-pages{height:auto;text-align:center;font-size:13px}.do-pages a{display:inline-block;width:auto;min-width:40px;height:40px;line-height:40px;color:#546e7a;text-decoration:none;cursor:pointer}.do-pages a.curr,.do-pages a.disabled{cursor:default}.do-pages.skin-1{width:100%}.do-pages.skin-1 a.normal,.do-pages.skin-1 a.disabled,.do-pages.skin-1 a.curr{padding:0 10px;margin:0 3px}.do-pages.skin-1 a.curr{font-weight:bold;font-size:15px}.do-pages.skin-1 a.disabled{min-width:0;padding:0}.do-pages.skin-1 .input-box,.do-pages.skin-1 .input-box span,.do-pages.skin-1 .input-box input{display:inline-block}.do-pages.skin-1 .input-box input{width:25px;height:20px;padding:0 3px;background:#fff;border:1px solid #ddd}.do-pages.skin-1 .input-box a.normal{height:30px;line-height:30px}.do-pages.skin-2{float:right;width:auto}.do-pages.skin-2 a.normal,.do-pages.skin-2 a.disabled,.do-pages.skin-2 a.curr{float:left;margin:0;padding:0 5px;color:#fff}.do-pages.skin-2 a.disabled{display:none}.do-pages.skin-2 .input-box{display:none}.do-pages.plain a.normal{background:#e7e8eb}.do-pages.plain a.normal:hover{background:#ecf0f1}.do-pages.skin-2.plain a.curr,.do-pages.plain a.normal:active{background:#bdc3c7}.do-pages.grey a.normal{background:#546e7a;color:#fff}.do-pages.grey a.normal:hover{background:#607d8b}.do-pages.skin-2.grey a.curr,.do-pages.grey a.normal:active{background:#37474f}.do-pages.red a.normal{background:#ff5722;color:#fff}.do-pages.red a.normal:hover{background:#ff7043}.do-pages.skin-2.red a.curr,.do-pages.red a.normal:active{background:#e64a19}.do-pages.orange a.normal{background:#ff9800;color:#fff}.do-pages.orange a.normal:hover{background:#ffa726}.do-pages.skin-2.orange a.curr,.do-pages.orange a.normal:active{background:#f57c00}.do-pages.green a.normal{background:#4caf50;color:#fff}.do-pages.green a.normal:hover{background:#81c784}.do-pages.skin-2.green a.curr,.do-pages.green a.normal:active{background:#388e3c}.do-pages.teal a.normal{background:#1abc9c;color:#fff}.do-pages.teal a.normal:hover{background:#48c9b0}.do-pages.skin-2.teal a.curr,.do-pages.teal a.normal:active{background:#16a085}.do-pages.blue a.normal{background:#2196f3;color:#fff}.do-pages.blue a.normal:hover{background:#64b5f6}.do-pages.skin-2.blue a.curr,.do-pages.blue a.normal:active{background:#1976d2}.do-pages.purple a.normal{background:#651fff;color:#fff}.do-pages.purple a.normal:hover{background:#7c4dff}.do-pages.skin-2.purple a.curr,.do-pages.purple a.normal:active{background:#6200ea}

View File

@ -1 +0,0 @@
.do-ui-blockcode{position:relative;border:1px solid #ddd;margin:15px 0;padding:8px 0;line-height:1.5;background:#fafafa}.do-ui-blockcode .lang{position:relative;display:block;padding:0 8px;color:#383a42;word-wrap:break-word;white-space:pre-wrap;font-family:Courier}.do-ui-blockcode .lang .c-comment{color:#8e908c;font-style:italic}.do-ui-blockcode .lang .c-smartyx{color:#607d8b}.do-ui-blockcode .lang .c-important{color:#f5871f;font-style:italic}.do-ui-blockcode .lang .c-punctuation{color:#986756}.do-ui-blockcode .lang .c-regex{color:#c82829}.do-ui-blockcode .lang .c-boolean,.do-ui-blockcode .lang .c-number{color:#f5871f}.do-ui-blockcode .lang .c-function{color:#009688}.do-ui-blockcode .lang .c-class-name,.do-ui-blockcode .lang .c-build-in{color:#3aa9f3}.do-ui-blockcode .lang .c-class-name,.do-ui-blockcode .lang .c-build-in{font-style:italic;font-weight:bold}.do-ui-blockcode .lang .c-attr-name,.do-ui-blockcode .lang .c-property{color:#c79f0f;font-weight:bold}.do-ui-blockcode .lang .c-property{font-style:italic}.do-ui-blockcode .lang .c-string,.do-ui-blockcode .lang .c-attr-value{color:#5ab302}.do-ui-blockcode .lang .c-tag,.do-ui-blockcode .lang .c-keyword,.do-ui-blockcode .lang .c-selector,.do-ui-blockcode .lang .c-operator{color:#d81406}.do-ui-blockcode .lang .c-keyword{font-style:italic}.do-ui-inlinecode{margin:0 2px;padding:0 5px;color:#d14;border:1px solid #ddd;border-radius:3px}

View File

@ -1,656 +0,0 @@
/**
* Request组件, modern版, 支持IE9+,chrome,FF
* @authors yutent (yutent@doui.cc)
* @date 2016-11-27 13:08:40
*
*/
'use strict';
define(['yua', './promise'], function(yua) {
var _request = function(url, protocol) {
this.transport = true;
protocol = (protocol + '').trim().toUpperCase();
this.xhr = Xhr();
this.defer = Promise.defer();
this.opt = {
url: (url + '').trim(),
type: protocol || 'GET',
form: '',
data: {},
headers: {},
timeoutID: 0,
uuid: Math.random()
.toString(16)
.substr(2)
};
},
_requestp = _request.prototype,
toS = Object.prototype.toString,
win = window,
doc = win.document,
encode = encodeURIComponent,
decode = decodeURIComponent,
noop = function(e, res) {
this.defer.resolve(res);
};
// -----------------------------
// 本地协议判断正则
var rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/;
var isLocal = false;
try {
isLocal = rlocalProtocol.test(location.ptyperotocol);
} catch (e) {}
var rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm;
// ----------------- 一些兼容性预处理 --------------------
win.Xhr = function() {
return new XMLHttpRequest();
};
var supportCors = 'withCredentials' in Xhr();
// ------------------- 几个解释方法 -----------------------
function serialize(p, obj, q) {
var k;
if (Array.isArray(obj)) {
obj.forEach(function(it, i) {
k = p ? p + '[' + (Array.isArray(it) ? i : '') + ']' : i;
if (typeof it === 'object') {
serialize(k, it, q);
} else {
q(k, it);
}
});
} else {
for (var i in obj) {
k = p ? p + '[' + i + ']' : i;
if (typeof obj[i] === 'object') {
serialize(k, obj[i], q);
} else {
q(k, obj[i]);
}
}
}
}
var Format = function() {};
Format.prototype = {
parseJS: function(code) {
code = (code + '').trim();
if (code) {
if (code.indexOf('use strict') === 1) {
var script = doc.createElement('script');
script.text = code;
doc.head.appendChild(script).parentNode.removeChild(script);
} else {
eval(code);
}
}
},
parseXML: function(data, xml, tmp) {
try {
tmp = new DOMParser();
xml = tmp.parseFromString(data, 'text/xml');
} catch (e) {
xml = void 0;
}
if (
!xml ||
!xml.documentElement ||
xml.getElementsByTagName('parsererror').length
) {
console.error('Invalid XML: ' + data);
}
return xml;
},
parseHTML: function(html) {
return yua.parseHTML(html);
},
param: function(obj) {
if (!obj || typeof obj === 'string' || typeof obj === 'number')
return obj;
var arr = [];
var q = function(k, v) {
if (/native code/.test(v)) return;
v = typeof v === 'function' ? v() : v;
v = toS.call(v) !== '[object File]' ? encode(v) : v;
arr.push(encode(k) + '=' + v);
};
if (typeof obj === 'object') serialize('', obj, q);
return arr.join('&');
},
parseForm: function(form) {
var data = {};
for (var i = 0, field; (field = form.elements[i++]); ) {
switch (field.type) {
case 'select-one':
case 'select-multiple':
if (field.name.length && !field.disabled) {
for (var j = 0, opt; (opt = field.options[j++]); ) {
if (opt.selected) {
data[field.name] = opt.value || opt.text;
}
}
}
break;
case 'file':
if (field.name.length && !field.disabled) {
data[field.name] = field.files[0];
}
break;
case undefined:
case 'submit':
case 'reset':
case 'button':
break; //按钮啥的, 直接忽略
case 'radio':
case 'checkbox':
// 只处理选中的
if (!field.checked) break;
default:
if (field.name.length && !field.disabled) {
data[field.name] = field.value;
}
}
}
return data;
},
merge: function(a, b) {
if (typeof a !== 'object' || typeof b !== 'object')
throw new TypeError('argument must be an object');
if (Object.assign) return Object.assign(a, b);
for (var i in b) {
a[i] = b[i];
}
return a;
}
};
var F = new Format();
// ---------------------------------------------------------
// -------------------- request 模块开始 --------------------
// ---------------------------------------------------------
var requestConvert = {
text: function(val) {
return val;
},
xml: function(val, xml) {
return xml !== undefined ? xml : F.parseXML(val);
},
html: function(val) {
return F.parseHTML(val);
},
json: function(val) {
return JSON.parse(val);
},
script: function(val) {
return F.parseJS(val);
},
jsonp: function(name) {
var json = request.cache[name];
delete request.cache[name];
return json;
}
};
var requestExtend = {
formData: function() {
if (this.opt.form) {
var data = F.parseForm(this.opt.form);
F.merge(this.opt.data, data);
}
var form = new FormData();
for (var i in this.opt.data) {
var el = this.opt.data[i];
if (Array.isArray(el)) {
el.forEach(function(it) {
form.append(i + '[]', it);
});
} else {
form.append(i, this.opt.data[i]);
}
}
return form;
},
jsonp: function(jsonpcallback) {
win[jsonpcallback] = function(val) {
delete win[jsonpcallback];
request.cache[jsonpcallback] = val;
};
},
dispatch: function(self) {
if (!this.transport) return this.defer.reject('Request pending...');
var _this = this,
result = {
response: {
url: this.opt.url,
headers: { 'content-type': '' }
},
request: {
url: this.opt.url,
headers: _this.opt.headers
},
status: self === null ? 504 : 200,
statusText: self === null ? 'Connected timeout' : 'ok',
text: '',
body: '',
error: null
};
//状态为4,既已成功, 则清除超时
clearTimeout(_this.opt.timeoutID);
if (
typeof this.transport === 'object' &&
this.opt.type === 'JSONP'
) {
//移除script
// this.transport.parentNode.removeChild(this.transport);
//超时返回
if (self !== null) {
var exec =
!this.transport.readyState ||
this.transport.readyState === 'loaded' ||
this.transport.readyState === 'complete';
if (exec) {
result.body = requestConvert.jsonp(
this.opt.data.callback
);
result.text = JSON.stringify(result.body);
}
}
this.callback(result.error, result);
} else {
//成功的回调
var isSucc = self
? (self.status >= 200 && self.status < 300) ||
self.status === 304
: false,
headers =
(self && self.getAllResponseHeaders().split('\n')) ||
[];
//处理返回的Header
headers.forEach(function(it, i) {
it = it.trim();
if (it) {
it = it.split(':');
result.response.headers[
it.shift().toLowerCase()
] = it.join(':').trim();
}
});
if (isSucc) {
result.status = self.status;
if (result.status === 204) {
result.statusText = 'no content';
} else if (result.status === 304) {
result.statusText = 'not modified';
}
} else {
result.status = self === null ? 504 : self.status || 500;
result.statusText =
self === null
? 'Connected timeout'
: self.statusText || 'Internal Server Error';
result.error = F.merge(new Error(result.statusText), {
status: result.status
});
}
try {
//处理返回的数据
var dataType = result.response.headers[
'content-type'
].match(/json|xml|script|html/i) || ['text'];
dataType = dataType[0].toLowerCase();
result.text =
(self && (self.responseText || self.responseXML)) || '';
result.body = requestConvert[dataType](
result.text,
self && self.responseXML
);
} catch (err) {
result.error = err;
result.statusText = 'parse error';
}
_this.callback(result.error, result);
}
delete _this.defer;
delete _this.transport;
delete _this.opt;
delete _this.xhr;
}
};
// 设置表单类型, 支持2种, form/json
_requestp.type = function(t) {
if (this.opt.formType === 'form-data') return this;
this.opt.formType = t || 'form';
if (t === 'form' || this.opt.type === 'GET')
this.set(
'content-type',
'application/x-www-form-urlencoded; charset=UTF-8'
);
else this.set('content-type', 'application/json; charset=UTF-8');
return this;
};
//设置头信息
_requestp.set = function(k, val) {
if (!this.transport) return;
if (typeof k === 'object') {
for (var i in k) {
i = i.toLowerCase();
this.opt.headers[i] = k[i];
}
} else if (typeof k === 'string') {
if (arguments.length < 2) throw new Error('2 arguments required');
// 全转小写,避免重复写入
k = k.toLowerCase();
if (val === undefined) delete this.opt.headers[k];
else this.opt.headers[k] = val;
} else {
throw new Error(
'arguments must be string/object, but [' + typeof k + '] given'
);
}
return this;
};
//设置请求参数
_requestp.send = function(k, val) {
if (!this.transport) return;
// 1. send方法可以多次调用, 但必须保证格式一致
// 2. 2次圴提交纯字符串也会抛出异常
if (typeof k === 'object') {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error(
'param can not be string and object at the same time'
);
if (!this.opt.data) this.opt.data = {};
F.merge(this.opt.data, k);
} else {
if (typeof k === 'string') {
if (arguments.length === 1) {
if (this.opt.data)
throw new Error('invalid param in function send');
this.opt.data = k;
} else {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error(
'param can not be string and object at the same time'
);
if (!this.opt.data) this.opt.data = {};
this.opt.data[k] = val;
}
} else {
throw new Error(
'argument of send must be string/object, but [' +
typeof k +
'] given'
);
}
}
return this;
};
//该方法用于 form-data类型的post请求的参数设置
_requestp.field = function(k, val) {
if (!this.transport) return this;
// 此类型优先级最高
this.opt.formType = 'form-data';
this.opt.type = 'POST';
if (
!this.opt.data ||
(this.opt.data && typeof this.opt.data !== 'object')
)
this.opt.data = {};
if (arguments.length === 1 && typeof k === 'object') {
F.merge(this.opt.data, k);
} else if (arguments.length === 2) {
this.opt.data[k] = val;
} else {
throw new TypeError(
'argument must be an object, but ' + typeof k + ' given'
);
}
return this;
};
//设置缓存
_requestp.cache = function(t) {
if (!this.transport) return;
if (this.opt.type === 'GET') this.opt.cache = !!t;
return this;
};
//取消网络请求
_requestp.abort = function() {
delete this.transport;
if (!this.opt.form) this.xhr.abort();
return this;
};
//超时设置, 单位毫秒
_requestp.timeout = function(time) {
if (typeof time !== 'number' || time < 1) return this;
this.opt.timeout = time;
return this;
};
_requestp.form = function(form) {
if (typeof form === 'object' && form.nodeName === 'FORM') {
this.opt.type = 'POST';
this.opt.form = form;
}
return this;
};
var originAnchor = doc.createElement('a');
originAnchor.href = location.href;
_requestp.end = function(callback) {
var _this = this;
// 回调已执行, 或已取消, 则直接返回, 防止重复执行
if (!this.transport) return this;
if (!this.opt.url) throw new Error('Invalid request url');
F.merge(this, requestExtend);
this.callback = callback || noop.bind(this);
// 1. url规范化
this.opt.url = this.opt.url
.replace(/#.*$/, '')
.replace(/^\/\//, location.protocol + '//');
// 2. 处理跨域
if (typeof this.opt.crossDomain !== 'boolean') {
var anchor = doc.createElement('a');
try {
anchor.href = this.opt.url;
// IE7及以下浏览器 '1'[0]的结果是 undefined
// IE7下需要获取绝对路径
var absUrl = !'1'[0]
? anchor.getAttribute('href', 4)
: anchor.href;
anchor.href = absUrl;
anchor.async = true;
this.opt.crossDomain =
originAnchor.protocol !== anchor.protocol ||
originAnchor.host !== anchor.host;
} catch (e) {
this.opt.crossDomain = true;
}
}
// 2.1 进一步处理跨域配置
if (this.opt.type === 'JSONP') {
//如果没有跨域自动转回xhr GET
if (!this.opt.crossDomain) {
this.opt.type = 'GET';
} else {
this.opt.data['callback'] =
this.opt.data['callback'] || 'jsonp' + request.cid++;
this.jsonp(this.opt.data['callback']); //创建临时处理方法
}
}
// 2.2 如果不是跨域请求则自动加上一条header信息用以标识这是ajax请求
if (!this.opt.crossDomain) {
this.set('X-Requested-With', 'XMLHttpRequest');
} else {
supportCors && (this.xhr.withCredentials = true);
}
// 3. data转字符串
this.opt.param = F.param(this.opt.data);
// 4. 设置Content-Type类型, 默认x-www-form-urlencoded
if (!this.opt.formType) this.type('form');
// 5.处理GET请求
this.opt.hasContent = this.opt.type === 'POST'; //是否为post请求
if (!this.opt.hasContent) {
//GET请求直接把参数拼接到url上
if (this.opt.param) {
this.opt.url +=
(/\?/.test(this.opt.url) ? '&' : '?') + this.opt.param;
}
//加随机值,避免缓存
if (this.opt.cache === false)
this.opt.url +=
(/\?/.test(this.opt.url) ? '&' : '?') +
'_=' +
Math.random();
} else {
if (this.opt.formType === 'form-data') {
delete this.opt.headers['content-type'];
this.opt.param = this.formData();
} else if (this.opt.formType !== 'form') {
this.opt.param = JSON.stringify(this.opt.data);
}
}
//jsonp
if (this.opt.type === 'JSONP') {
this.transport = doc.createElement('script');
this.transport.onerror = this.transport.onload = function() {
_this.dispatch(_this.transport);
};
this.transport.src = this.opt.url;
doc.head.insertBefore(this.transport, doc.head.firstChild);
//6. 超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.opt.timeoutID = setTimeout(function() {
_this.transport.onerror = _this.transport.onload = null;
_this.dispatch(null);
}, this.opt.timeout);
}
} else {
this.xhr.onreadystatechange = function(ev) {
if (_this.opt.timeout && _this.opt.timeout > 0) {
_this.opt['time' + this.readyState] = ev.timeStamp;
if (this.readyState === 4) {
_this.opt.isTimeout =
_this.opt.time4 - _this.opt.time1 >
_this.opt.timeout;
}
}
if (this.readyState !== 4) {
return;
}
_this.dispatch(_this.opt.isTimeout ? null : _this.xhr);
};
// 6. 初始化xhr提交
this.xhr.open(this.opt.type, this.opt.url, true);
// 7. 设置头信息
for (var i in this.opt.headers) {
if (this.opt.headers[i])
this.xhr.setRequestHeader(i, this.opt.headers[i]);
}
// 8. 发起网络请求
_this.xhr.send(_this.opt.param);
//超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.xhr.timeout = this.opt.timeout;
}
}
return this.defer.promise;
};
// ---------------------- end ------------------------
if (!win.request) {
win.request = {
get: function(url) {
if (!url) throw new Error('argument url is required');
return new _request(url, 'GET');
},
post: function(url) {
if (!url) throw new Error('argument url is required');
return new _request(url, 'POST');
},
jsonp: function(url) {
if (!url) throw new Error('argument url is required');
return new _request(url, 'JSONP');
},
cache: {},
cid: 0,
version: '1.1.0-es5'
};
yua.ui.request = request.version;
}
return request;
});

View File

@ -1 +0,0 @@
.do-sliders{position:relative;height:100%;width:100%}.do-sliders .skin{height:100%}.do-sliders.fullscreen{position:absolute;width:100%;height:100%;left:0;top:0}.do-sliders .slider-content{position:relative}.do-sliders .slider-content .container{position:relative;height:100%;overflow:hidden}.do-sliders .slider-content .container .box{position:relative;height:100%;width:100%;transition:.4s}.do-sliders .slider-content .container .box .page{position:relative;display:inline-block;height:100%;vertical-align:middle}.do-sliders .slider-content .container .box .page img{width:100%;height:100%;object-fit:cover}.do-sliders .slider-content .container .box .page .title-class{position:absolute;width:30%;min-height:30px;line-height:30px;left:0;bottom:15%;right:0;margin:auto;text-align:center;font-size:25px}.do-sliders .slider-content .container .box .page .elm{height:100%;width:100%;background:#333}.do-sliders .slider-content .container .box .page .default-elm{width:100%;height:100%}.do-sliders .slider-content .container .box .page .default-btn{width:100%;height:100%}.do-sliders .slider-content .container .box .fadeType{position:absolute;left:0;top:0;width:100%;transition:.4s}.do-sliders .slider-content .slider-btn{position:absolute;top:50%;min-width:50px;min-height:50px;margin-top:-25px;text-decoration:none;font-size:30px;line-height:50px;text-align:center;border-radius:100%;color:rgba(255,255,255,0.6);font-weight:bold;z-index:1;transition:.4s}.do-sliders .slider-content .slider-btn:nth-of-type(1){margin-left:20px}.do-sliders .slider-content .slider-btn:nth-of-type(2){right:0;margin-right:20px}.do-sliders .slider-preview-btn{position:absolute;bottom:2%;height:12%;width:100%;margin:0 auto;text-align:center;overflow:hidden}.do-sliders .slider-preview-btn span{display:inline-block;width:10px;height:10px;margin:0 5px;border-radius:100%;background:rgba(255,255,255,0.8);cursor:pointer;transition:.5s}.do-sliders .slider-preview-btn span:hover{background:#4caf50}.do-sliders .slider-preview-btn .no-preview-act{background:#388e3c}.do-sliders .slider-preview-btn .btn-group{height:100%}.do-sliders .slider-preview-btn .btn-img{display:inline-block;position:relative;width:80px;height:100%;margin:0 5px;transition:.4s;cursor:pointer}.do-sliders .slider-preview-btn .btn-img img{position:relative;width:100%;height:100%;object-fit:cover;transition:.4s;z-index:2}.do-sliders .slider-preview-btn .btn-img .preview-act{transform:scale(0.95)}.do-sliders .slider-preview-btn .btn-img:after{content:'';position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;transition:.8s;z-index:1}.do-sliders .slider-preview-btn .btn-img.act:after{opacity:1}.do-sliders .slider-preview-btn-vertical{right:10px;bottom:50%;width:20px;height:auto;text-align:center;transform:translate(0, 50%)}.do-sliders .skin-0 .title-class{color:#e0e0e0}.do-sliders .skin-1 .title-class{color:#e64a19}.do-sliders .skin-2 .title-class{color:#388e3c}.do-sliders .skin-3 .title-class{color:#1976d2}.do-sliders .skin-0 .slider-btn{color:rgba(255,255,255,0.6)}.do-sliders .skin-1 .slider-btn{color:#e64a19}.do-sliders .skin-2 .slider-btn{color:#388e3c}.do-sliders .skin-3 .slider-btn{color:#1976d2}.do-sliders .skin-0 .slider-btn:hover{color:#e0e0e0}.do-sliders .skin-1 .slider-btn:hover{color:#ff5722}.do-sliders .skin-2 .slider-btn:hover{color:#4caf50}.do-sliders .skin-3 .slider-btn:hover{color:#2196f3}.do-sliders .skin-0 .btn-img:after{background:rgba(0,0,0,0.5)}.do-sliders .skin-1 .btn-img:after{background:#ff5722}.do-sliders .skin-2 .btn-img:after{background:#4caf50}.do-sliders .skin-3 .btn-img:after{background:#2196f3}.do-sliders .skin-0 .default-elm{background:#e0e0e0}.do-sliders .skin-1 .default-elm{background:#ff5722}.do-sliders .skin-2 .default-elm{background:#4caf50}.do-sliders .skin-3 .default-elm{background:#2196f3}.do-sliders .skin-0 .default-btn{background:#e0e0e0}.do-sliders .skin-1 .default-btn{background:#ff5722}.do-sliders .skin-2 .default-btn{background:#4caf50}.do-sliders .skin-3 .default-btn{background:#2196f3}.do-sliders .skin-0 .no-preview-act{background:rgba(0,0,0,0.6)}.do-sliders .skin-1 .no-preview-act{background:#e64a19}.do-sliders .skin-2 .no-preview-act{background:#388e3c}.do-sliders .skin-3 .no-preview-act{background:#1976d2}.do-sliders .skin-0 .slider-preview-btn span:hover{background:rgba(0,0,0,0.6)}.do-sliders .skin-1 .slider-preview-btn span:hover{background:#e64a19}.do-sliders .skin-2 .slider-preview-btn span:hover{background:#388e3c}.do-sliders .skin-3 .slider-preview-btn span:hover{background:#1976d2}.do-sliders .h-83{height:83%}.do-sliders .h-100{height:100%}@keyframes right-to-left{49%{-webkit-transform:translate(100%)}50%{-webkit-transform:translate(-100%);opacity:0}100%{opacity:1}}@keyframes left-to-right{49%{-webkit-transform:translate(-100%)}50%{-webkit-transform:translate(100%);opacity:0}100%{opacity:1}}

View File

@ -1 +0,0 @@
.do-tree{overflow:hidden;overflow-y:auto;position:relative;width:100%;height:100%;line-height:28px}.do-tree ul{width:100%;height:auto}.do-tree li{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.do-tree li ul{display:none;margin-left:20px}.do-tree li ul.open{display:block}.do-tree li em,.do-tree li span{display:block;cursor:pointer}.do-tree 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}.do-tree li span:hover{color:#6bb294}.do-tree li span.active{color:#000;font-weight:bold}.do-tree.skin-def li>em::before{content:"\e612"}.do-tree.skin-def li.dir>em::before{content:"\e622"}.do-tree.skin-def li.dir.open>em::before{content:"\e8ea"}.do-tree.skin-light li>em::before{content:"\e73e"}.do-tree.skin-light li.dir>em::before{content:"\e635"}.do-tree.skin-light li.dir.open>em::before{content:"\e8ea"}.do-tree.skin-line li>em::before{content:"\e614"}.do-tree.skin-line li.dir>em::before{content:"\e8eb";font-weight:bold}.do-tree.skin-line li.dir.open>em::before{content:"\e662"}

View File

@ -1,62 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="../css/base.min.css" rel="stylesheet">
<style type="text/css">
.preview {width:500px;height:300px;margin:auto;border:1px solid #ddd;}
</style>
</head>
<body ms-controller="test">
<div class="preview">
<img ms-attr-src="preview">
</div>
<input type="file" ms-duplex="file" id="file">
<a href="javascript:;" class="submit">提交</a>
<script src="../avalon.modern.js"></script>
<script type="text/javascript">
require(['uploader/uploader', 'ajax/ajax.min'], function(Up){
var uploader = new Up()
uploader.setUrl('http://up.qbox.me')
.onProgress(function(obj){
console.log(obj.speed, obj.progress, obj.loaded, obj.time)
})
.onEnd(function(res){
console.info(res)
})
var submit = document.querySelector('.submit')
var file = document.querySelector('#file')
submit.onclick = function(){
// console.log(file.files[0])
avalon.get('/upload.php?image=' + file.files[0].name, '', function(txt){
uploader.init()
.setField('file', file.files[0])
.setField('token', txt)
.setField('key', 'avatar/dsfghj')
.start()
}, 'text')
}
})
</script>
</body>
</html>

View File

@ -1 +0,0 @@
"use strict";define(function(){var e=function(){this.init()};return e.prototype={init:function(){return this.xhr=new XMLHttpRequest,this.form=new FormData,this.field={},this.header={},this},setUrl:function(e){return e&&"string"==typeof e?(this.url=e,this):console.error("url不能为空且必须是字符串")},setField:function(e,r){if("object"==typeof e)for(var t in e)this.field[t]=e[t];else this.field[e]=r;return this},setHeader:function(e,r){if("object"==typeof e)for(var t in e)this.header[t]=e[t];else this.header[e]=r;return this},start:function(){var e=this;if(!this.url)return console.error("请先设置url");this.xhr.open("POST",this.url,!0);for(var r in this.field)this.form.append(r,this.field[r]);var t=Date.now();this.xhr.upload.addEventListener("progress",function(r){if(r.lengthComputable&&e.progress){var s=Date.now(),i=1e3*r.loaded/1024,n={loaded:r.loaded,time:s-t};n.speed=i/n.time,n.speed<10?n.speed=Math.floor(1024*n.speed)+" B/s":n.speed=n.speed.toFixed(2)+" KB/s",n.progress=Math.round(100*r.loaded/r.total),e.progress(n)}},!1),this.xhr.onreadystatechange=function(){if(4===e.xhr.readyState&&200===e.xhr.status&&""!==e.xhr.responseText){var r=e.xhr.responseText;try{r=JSON.parse(r)}catch(e){}e.end&&e.end(r)}else 200!==e.xhr.status&&e.xhr.responseText&&e.error&&e.error(e.xhr.responseText)},this.xhr.send(this.form)},onProgress:function(e){return this.progress=e,this},onEnd:function(e){return this.end=e,this},onError:function(e){return this.error=e,this}},window.Uploader||(window.Uploader=e),e});

View File

@ -1,544 +0,0 @@
var ua = navigator.userAgent.toLowerCase()
//http://stackoverflow.com/questions/9038625/detect-if-device-is-ios
function iOSversion() {
//https://developer.apple.com/library/prerelease/mac/releasenotes/General/WhatsNewInSafari/Articles/Safari_9.html
//http://mp.weixin.qq.com/s?__biz=MzA3MDQ4MzQzMg==&mid=256900619&idx=1&sn=b29f84cff0b8d7b9742e5d8b3cd8f218&scene=1&srcid=1009F9l4gh9nZ7rcQJEhmf7Q#rd
if (/iPad|iPhone|iPod/i.test(ua) && !window.MSStream) {
if ("backdropFilter" in document.documentElement.style) {
return 9
}
if (!!window.indexedDB) {
return 8
}
if (!!window.SpeechSynthesisUtterance) {
return 7
}
if (!!window.webkitAudioContext) {
return 6
}
if (!!window.matchMedia) {
return 5
}
if (!!window.history && 'pushState' in window.history) {
return 4
}
return 3
}
return NaN
}
var deviceIsAndroid = ua.indexOf('android') > 0
var deviceIsIOS = iOSversion()
var Recognizer = yua.gestureHooks = {
pointers: {},
//以AOP切入touchstart, touchmove, touchend, touchcancel回调
start: function (event, callback) {
//touches是当前屏幕上所有触摸点的列表;
//targetTouches是当前对象上所有触摸点的列表;
//changedTouches是涉及当前事件的触摸点的列表。
for (var i = 0; i < event.changedTouches.length; i++) {
var touch = event.changedTouches[i],
id = touch.identifier,
pointer = {
startTouch: mixLocations({}, touch),
startTime: Date.now(),
status: 'tapping',
element: event.target,
pressingHandler: Recognizer.pointers[id] && Recognizer.pointers[id].pressingHandler
}
Recognizer.pointers[id] = pointer;
callback(pointer, touch)
}
},
move: function (event, callback) {
for (var i = 0; i < event.changedTouches.length; i++) {
var touch = event.changedTouches[i]
var pointer = Recognizer.pointers[touch.identifier]
if (!pointer) {
return
}
if (!("lastTouch" in pointer)) {
pointer.lastTouch = pointer.startTouch
pointer.lastTime = pointer.startTime
pointer.deltaX = pointer.deltaY = pointer.duration = pointer.distance = 0
}
var time = Date.now() - pointer.lastTime
if (time > 0) {
var RECORD_DURATION = 70
if (time > RECORD_DURATION) {
time = RECORD_DURATION
}
if (pointer.duration + time > RECORD_DURATION) {
pointer.duration = RECORD_DURATION - time
}
pointer.duration += time;
pointer.lastTouch = mixLocations({}, touch)
pointer.lastTime = Date.now()
pointer.deltaX = touch.clientX - pointer.startTouch.clientX
pointer.deltaY = touch.clientY - pointer.startTouch.clientY
var x = pointer.deltaX * pointer.deltaX
var y = pointer.deltaY * pointer.deltaY
pointer.distance = Math.sqrt(x + y)
pointer.isVertical = x < y
callback(pointer, touch)
}
}
},
end: function (event, callback) {
for (var i = 0; i < event.changedTouches.length; i++) {
var touch = event.changedTouches[i],
id = touch.identifier,
pointer = Recognizer.pointers[id]
if (!pointer)
continue
callback(pointer, touch)
delete Recognizer.pointers[id]
}
},
//人工触发合成事件
fire: function (elem, type, props) {
if (elem) {
var event = document.createEvent('Events')
event.initEvent(type, true, true)
yua.mix(event, props)
elem.dispatchEvent(event)
}
},
//添加各种识别器
add: function (name, recognizer) {
function move(event) {
recognizer.touchmove(event)
}
function end(event) {
recognizer.touchend(event)
document.removeEventListener('touchmove', move)
document.removeEventListener('touchend', end)
document.removeEventListener('touchcancel', cancel)
}
function cancel(event) {
recognizer.touchcancel(event)
document.removeEventListener('touchmove', move)
document.removeEventListener('touchend', end)
document.removeEventListener('touchcancel', cancel)
}
recognizer.events.forEach(function (eventName) {
yua.eventHooks[eventName] = {
fix: function (el, fn) {
if (!el['touch-' + name]) {
el['touch-' + name] = '1'
el.addEventListener('touchstart', function (event) {
recognizer.touchstart(event)
document.addEventListener('touchmove', move)
document.addEventListener('touchend', end)
document.addEventListener('touchcancel', cancel)
})
}
return fn
}
}
})
}
}
var locations = ['screenX', 'screenY', 'clientX', 'clientY', 'pageX', 'pageY']
// 复制 touch 对象上的有用属性到固定对象上
function mixLocations(target, source) {
if (source) {
locations.forEach(function (key) {
target[key] = source[key]
})
}
return target
}
var supportPointer = !!navigator.pointerEnabled || !!navigator.msPointerEnabled
if (supportPointer) { // 支持pointer的设备可用样式来取消click事件的300毫秒延迟
root.style.msTouchAction = root.style.touchAction = 'none'
}
var tapRecognizer = {
events: ['tap'],
touchBoundary: 10,
tapDelay: 200,
needClick: function(target) {
//判定是否使用原生的点击事件, 否则使用sendClick方法手动触发一个人工的点击事件
switch (target.nodeName.toLowerCase()) {
case 'button':
case 'select':
case 'textarea':
if (target.disabled) {
return true
}
break;
case 'input':
// IOS6 pad 上选择文件如果不是原生的click弹出的选择界面尺寸错误
if ((deviceIsIOS && target.type === 'file') || target.disabled) {
return true
}
break;
case 'label':
case 'iframe':
case 'video':
return true
}
return false
},
needFocus: function(target) {
switch (target.nodeName.toLowerCase()) {
case 'textarea':
case 'select': //实测android下select也需要
return true;
case 'input':
switch (target.type) {
case 'button':
case 'checkbox':
case 'file':
case 'image':
case 'radio':
case 'submit':
return false
}
//如果是只读或disabled状态,就无须获得焦点了
return !target.disabled && !target.readOnly
default:
return false
}
},
focus: function(targetElement) {
var length;
//在iOS7下, 对一些新表单元素(如date, datetime, time, month)调用focus方法会抛错,
//幸好的是,我们可以改用setSelectionRange获取焦点, 将光标挪到文字的最后
var type = targetElement.type
if (deviceIsIOS && targetElement.setSelectionRange &&
type.indexOf('date') !== 0 && type !== 'time' && type !== 'month') {
length = targetElement.value.length
targetElement.setSelectionRange(length, length)
} else {
targetElement.focus()
}
},
findControl: function(labelElement) {
// 获取label元素所对应的表单元素
// 可以能过control属性, getElementById, 或用querySelector直接找其内部第一表单元素实现
if (labelElement.control !== undefined) {
return labelElement.control
}
if (labelElement.htmlFor) {
return document.getElementById(labelElement.htmlFor)
}
return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea')
},
fixTarget: function(target) {
if (target.nodeType === 3) {
return target.parentNode
}
if (window.SVGElementInstance && (target instanceof SVGElementInstance)) {
return target.correspondingUseElement;
}
return target
},
updateScrollParent: function(targetElement) {
//如果事件源元素位于某一个有滚动条的祖父元素中,那么保持其scrollParent与scrollTop值
var scrollParent = targetElement.tapScrollParent
if (!scrollParent || !scrollParent.contains(targetElement)) {
var parentElement = targetElement
do {
if (parentElement.scrollHeight > parentElement.offsetHeight) {
scrollParent = parentElement
targetElement.tapScrollParent = parentElement
break
}
parentElement = parentElement.parentElement
} while (parentElement)
}
if (scrollParent) {
scrollParent.lastScrollTop = scrollParent.scrollTop
}
},
touchHasMoved: function(event) {
//判定是否发生移动,其阀值是10px
var touch = event.changedTouches[0],
boundary = tapRecognizer.touchBoundary
return Math.abs(touch.pageX - tapRecognizer.pageX) > boundary ||
Math.abs(touch.pageY - tapRecognizer.pageY) > boundary
},
findType: function(targetElement) {
// 安卓chrome浏览器上模拟的 click 事件不能让 select 打开,故使用 mousedown 事件
return deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select' ?
'mousedown' : 'click'
},
sendClick: function(targetElement, event) {
// 在click之前触发tap事件
Recognizer.fire(targetElement, 'tap', {
touchEvent: event
})
var clickEvent, touch
//某些安卓设备必须先移除焦点之后模拟的click事件才能让新元素获取焦点
if (document.activeElement && document.activeElement !== targetElement) {
document.activeElement.blur()
}
touch = event.changedTouches[0]
// 手动触发点击事件,此时必须使用document.createEvent('MouseEvents')来创建事件
// 及使用initMouseEvent来初始化它
clickEvent = document.createEvent('MouseEvents')
clickEvent.initMouseEvent(tapRecognizer.findType(targetElement), true, true, window, 1, touch.screenX,
touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null)
clickEvent.touchEvent = event
targetElement.dispatchEvent(clickEvent)
},
touchstart: function(event) {
//忽略多点触摸
if (event.targetTouches.length !== 1) {
return true
}
//修正事件源对象
var targetElement = tapRecognizer.fixTarget(event.target)
var touch = event.targetTouches[0]
if (deviceIsIOS) {
// 判断是否是点击文字进行选择等操作如果是不需要模拟click
var selection = window.getSelection();
if (selection.rangeCount && !selection.isCollapsed) {
return true
}
var id = touch.identifier
//当 alert 或 confirm 时点击其他地方会触发touch事件identifier相同此事件应该被忽略
if (id && isFinite(tapRecognizer.lastTouchIdentifier) && tapRecognizer.lastTouchIdentifier === id) {
event.preventDefault()
return false
}
tapRecognizer.lastTouchIdentifier = id
tapRecognizer.updateScrollParent(targetElement)
}
//收集触摸点的信息
tapRecognizer.status = "tapping"
tapRecognizer.startTime = Date.now()
tapRecognizer.element = targetElement
tapRecognizer.pageX = touch.pageX
tapRecognizer.pageY = touch.pageY
// 如果点击太快,阻止双击带来的放大收缩行为
if ((tapRecognizer.startTime - tapRecognizer.lastTime) < tapRecognizer.tapDelay) {
event.preventDefault()
}
},
touchmove: function(event) {
if (tapRecognizer.status !== "tapping") {
return true
}
// 如果事件源元素发生改变,或者发生了移动,那么就取消触发点击事件
if (tapRecognizer.element !== tapRecognizer.fixTarget(event.target) ||
tapRecognizer.touchHasMoved(event)) {
tapRecognizer.status = tapRecognizer.element = 0
}
},
touchend: function(event) {
var targetElement = tapRecognizer.element
var now = Date.now()
//如果是touchstart与touchend相隔太久,可以认为是长按,那么就直接返回
//或者是在touchstart, touchmove阶段,判定其不该触发点击事件,也直接返回
if (!targetElement || now - tapRecognizer.startTime > tapRecognizer.tapDelay) {
return true
}
tapRecognizer.lastTime = now
var startTime = tapRecognizer.startTime
tapRecognizer.status = tapRecognizer.startTime = 0
targetTagName = targetElement.tagName.toLowerCase()
if (targetTagName === 'label') {
//尝试触发label上可能绑定的tap事件
Recognizer.fire(targetElement, 'tap', {
touchEvent: event
})
var forElement = tapRecognizer.findControl(targetElement)
if (forElement) {
tapRecognizer.focus(targetElement)
targetElement = forElement
}
} else if (tapRecognizer.needFocus(targetElement)) {
// 如果元素从touchstart到touchend经历时间过长,那么不应该触发点击事
// 或者此元素是iframe中的input元素,那么它也无法获点焦点
if ((now - startTime) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
tapRecognizer.element = 0
return false
}
tapRecognizer.focus(targetElement)
deviceIsAndroid && tapRecognizer.sendClick(targetElement, event)
return false
}
if (deviceIsIOS) {
//如果它的父容器的滚动条发生改变,那么应该识别为划动或拖动事件,不应该触发点击事件
var scrollParent = targetElement.tapScrollParent;
if (scrollParent && scrollParent.lastScrollTop !== scrollParent.scrollTop) {
return true
}
}
//如果这不是一个需要使用原生click的元素则屏蔽原生事件避免触发两次click
if (!tapRecognizer.needClick(targetElement)) {
event.preventDefault()
// 触发一次模拟的click
tapRecognizer.sendClick(targetElement, event)
}
},
touchcancel: function() {
tapRecognizer.startTime = tapRecognizer.element = 0
}
}
Recognizer.add("tap", tapRecognizer)
var pressRecognizer = {
events: ['longtap', 'doubletap'],
cancelPress: function (pointer) {
clearTimeout(pointer.pressingHandler)
pointer.pressingHandler = null
},
touchstart: function (event) {
Recognizer.start(event, function (pointer, touch) {
pointer.pressingHandler = setTimeout(function () {
if (pointer.status === 'tapping') {
Recognizer.fire(event.target, 'longtap', {
touch: touch,
touchEvent: event
})
}
pressRecognizer.cancelPress(pointer)
}, 800)
if (event.changedTouches.length !== 1) {
pointer.status = 0
}
})
},
touchmove: function (event) {
Recognizer.move(event, function (pointer) {
if (pointer.distance > 10 && pointer.pressingHandler) {
pressRecognizer.cancelPress(pointer)
if (pointer.status === 'tapping') {
pointer.status = 'panning'
}
}
})
},
touchend: function (event) {
Recognizer.end(event, function (pointer, touch) {
pressRecognizer.cancelPress(pointer)
if (pointer.status === 'tapping') {
pointer.lastTime = Date.now()
if (pressRecognizer.lastTap && pointer.lastTime - pressRecognizer.lastTap.lastTime < 300) {
Recognizer.fire(pointer.element, 'doubletap', {
touch: touch,
touchEvent: event
})
}
pressRecognizer.lastTap = pointer
}
})
},
touchcancel: function (event) {
Recognizer.end(event, function (pointer) {
pressRecognizer.cancelPress(pointer)
})
}
}
Recognizer.add('press', pressRecognizer)
var swipeRecognizer = {
events: ['swipe', 'swipeleft', 'swiperight', 'swipeup', 'swipedown'],
getAngle: function (x, y ) {
return Math.atan2(y, x) * 180 / Math.PI
},
getDirection: function (x, y) {
var angle = swipeRecognizer.getAngle(x, y)
if ((angle < -45) && (angle > -135)) {
return "up"
} else if ((angle >= 45) && (angle < 315)) {
return "down"
} else if ((angle > -45) && (angle <= 45)) {
return "right"
} else{
return "left"
}
},
touchstart: function (event) {
Recognizer.start(event, noop)
},
touchmove: function (event) {
Recognizer.move(event, noop)
},
touchend: function (event) {
if(event.changedTouches.length !== 1){
return
}
Recognizer.end(event, function (pointer, touch) {
var isflick = (pointer.distance > 30 && pointer.distance / pointer.duration > 0.65)
if (isflick) {
var extra = {
deltaX : pointer.deltaX,
deltaY: pointer.deltaY,
touch: touch,
touchEvent: event,
direction: swipeRecognizer.getDirection(pointer.deltaX, pointer.deltaY),
isVertical: pointer.isVertical
}
var target = pointer.element
Recognizer.fire(target, 'swipe', extra)
Recognizer.fire(target, 'swipe' + extra.direction, extra)
}
})
}
}
swipeRecognizer.touchcancel = swipeRecognizer.touchend
Recognizer.add('swipe', swipeRecognizer)

6478
js/yua.js

File diff suppressed because it is too large Load Diff

2926
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

26
package.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "doui-yua",
"version": "0.0.1",
"description": "基于yua框架的doUI组件库。支持IE10+,及现代浏览器。",
"main": "dist/",
"scripts": {
"start": "node ./build.dev.js",
"build": "node ./build.prod.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yutent/doui.git"
},
"keywords": ["doui", "yua"],
"author": "yutent",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-minify": "^0.2.0",
"chokidar": "^1.7.0",
"iofs": "^1.0.2",
"node-sass": "^4.7.2"
}
}

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

633
src/js/lib/request/es5.js Normal file
View File

@ -0,0 +1,633 @@
/**
* Request组件, modern版, 支持IE9+,chrome,FF
* @authors yutent (yutent@doui.cc)
* @date 2016-11-27 13:08:40
*
*/
'use strict'
define(['yua', './lib/promise'], function(yua) {
// console.log(11243)
var _request = function(url, protocol) {
this.transport = true
protocol = (protocol + '').trim().toUpperCase()
this.xhr = Xhr()
this.defer = Promise.defer()
this.opt = {
url: (url + '').trim(),
type: protocol || 'GET',
form: '',
data: {},
headers: {},
timeoutID: 0,
uuid: Math.random()
.toString(16)
.substr(2)
}
},
_requestp = _request.prototype,
toS = Object.prototype.toString,
win = window,
doc = win.document,
encode = encodeURIComponent,
decode = decodeURIComponent,
noop = function(e, res) {
this.defer.resolve(res)
}
// -----------------------------
// 本地协议判断正则
var rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/
var isLocal = false
try {
isLocal = rlocalProtocol.test(location.ptyperotocol)
} catch (e) {}
var rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm
// ----------------- 一些兼容性预处理 --------------------
win.Xhr = function() {
return new XMLHttpRequest()
}
var supportCors = 'withCredentials' in Xhr()
// ------------------- 几个解释方法 -----------------------
function serialize(p, obj, q) {
var k
if (Array.isArray(obj)) {
obj.forEach(function(it, i) {
k = p ? p + '[' + (Array.isArray(it) ? i : '') + ']' : i
if (typeof it === 'object') {
serialize(k, it, q)
} else {
q(k, it)
}
})
} else {
for (var i in obj) {
k = p ? p + '[' + i + ']' : i
if (typeof obj[i] === 'object') {
serialize(k, obj[i], q)
} else {
q(k, obj[i])
}
}
}
}
var Format = function() {}
Format.prototype = {
parseJS: function(code) {
code = (code + '').trim()
if (code) {
if (code.indexOf('use strict') === 1) {
var script = doc.createElement('script')
script.text = code
doc.head.appendChild(script).parentNode.removeChild(script)
} else {
eval(code)
}
}
},
parseXML: function(data, xml, tmp) {
try {
tmp = new DOMParser()
xml = tmp.parseFromString(data, 'text/xml')
} catch (e) {
xml = void 0
}
if (
!xml ||
!xml.documentElement ||
xml.getElementsByTagName('parsererror').length
) {
console.error('Invalid XML: ' + data)
}
return xml
},
parseHTML: function(html) {
return yua.parseHTML(html)
},
param: function(obj) {
if (!obj || typeof obj === 'string' || typeof obj === 'number') return obj
var arr = []
var q = function(k, v) {
if (/native code/.test(v)) return
v = typeof v === 'function' ? v() : v
v = toS.call(v) !== '[object File]' ? encode(v) : v
arr.push(encode(k) + '=' + v)
}
if (typeof obj === 'object') serialize('', obj, q)
return arr.join('&')
},
parseForm: function(form) {
var data = {}
for (var i = 0, field; (field = form.elements[i++]); ) {
switch (field.type) {
case 'select-one':
case 'select-multiple':
if (field.name.length && !field.disabled) {
for (var j = 0, opt; (opt = field.options[j++]); ) {
if (opt.selected) {
data[field.name] = opt.value || opt.text
}
}
}
break
case 'file':
if (field.name.length && !field.disabled) {
data[field.name] = field.files[0]
}
break
case undefined:
case 'submit':
case 'reset':
case 'button':
break //按钮啥的, 直接忽略
case 'radio':
case 'checkbox':
// 只处理选中的
if (!field.checked) break
default:
if (field.name.length && !field.disabled) {
data[field.name] = field.value
}
}
}
return data
},
merge: function(a, b) {
if (typeof a !== 'object' || typeof b !== 'object')
throw new TypeError('argument must be an object')
if (Object.assign) return Object.assign(a, b)
for (var i in b) {
a[i] = b[i]
}
return a
}
}
var F = new Format()
// ---------------------------------------------------------
// -------------------- request 模块开始 --------------------
// ---------------------------------------------------------
var requestConvert = {
text: function(val) {
return val
},
xml: function(val, xml) {
return xml !== undefined ? xml : F.parseXML(val)
},
html: function(val) {
return F.parseHTML(val)
},
json: function(val) {
return JSON.parse(val)
},
script: function(val) {
return F.parseJS(val)
},
jsonp: function(name) {
var json = request.cache[name]
delete request.cache[name]
return json
}
}
var requestExtend = {
formData: function() {
if (this.opt.form) {
var data = F.parseForm(this.opt.form)
F.merge(this.opt.data, data)
}
var form = new FormData()
for (var i in this.opt.data) {
var el = this.opt.data[i]
if (Array.isArray(el)) {
el.forEach(function(it) {
form.append(i + '[]', it)
})
} else {
form.append(i, this.opt.data[i])
}
}
return form
},
jsonp: function(jsonpcallback) {
win[jsonpcallback] = function(val) {
delete win[jsonpcallback]
request.cache[jsonpcallback] = val
}
},
dispatch: function(self) {
if (!this.transport) return this.defer.reject('Request pending...')
var _this = this,
result = {
response: {
url: this.opt.url,
headers: { 'content-type': '' }
},
request: {
url: this.opt.url,
headers: _this.opt.headers
},
status: self === null ? 504 : 200,
statusText: self === null ? 'Connected timeout' : 'ok',
text: '',
body: '',
error: null
}
//状态为4,既已成功, 则清除超时
clearTimeout(_this.opt.timeoutID)
if (typeof this.transport === 'object' && this.opt.type === 'JSONP') {
//移除script
// this.transport.parentNode.removeChild(this.transport);
//超时返回
if (self !== null) {
var exec =
!this.transport.readyState ||
this.transport.readyState === 'loaded' ||
this.transport.readyState === 'complete'
if (exec) {
result.body = requestConvert.jsonp(this.opt.data.callback)
result.text = JSON.stringify(result.body)
}
}
this.callback(result.error, result)
} else {
//成功的回调
var isSucc = self
? (self.status >= 200 && self.status < 300) || self.status === 304
: false,
headers = (self && self.getAllResponseHeaders().split('\n')) || []
//处理返回的Header
headers.forEach(function(it, i) {
it = it.trim()
if (it) {
it = it.split(':')
result.response.headers[it.shift().toLowerCase()] = it
.join(':')
.trim()
}
})
if (isSucc) {
result.status = self.status
if (result.status === 204) {
result.statusText = 'no content'
} else if (result.status === 304) {
result.statusText = 'not modified'
}
} else {
result.status = self === null ? 504 : self.status || 500
result.statusText =
self === null
? 'Connected timeout'
: self.statusText || 'Internal Server Error'
result.error = F.merge(new Error(result.statusText), {
status: result.status
})
}
try {
//处理返回的数据
var dataType = result.response.headers['content-type'].match(
/json|xml|script|html/i
) || ['text']
dataType = dataType[0].toLowerCase()
result.text = (self && (self.responseText || self.responseXML)) || ''
result.body = requestConvert[dataType](
result.text,
self && self.responseXML
)
} catch (err) {
result.error = err
result.statusText = 'parse error'
}
_this.callback(result.error, result)
}
delete _this.defer
delete _this.transport
delete _this.opt
delete _this.xhr
}
}
// 设置表单类型, 支持2种, form/json
_requestp.type = function(t) {
if (this.opt.formType === 'form-data') return this
this.opt.formType = t || 'form'
if (t === 'form' || this.opt.type === 'GET')
this.set(
'content-type',
'application/x-www-form-urlencoded; charset=UTF-8'
)
else this.set('content-type', 'application/json; charset=UTF-8')
return this
}
//设置头信息
_requestp.set = function(k, val) {
if (!this.transport) return
if (typeof k === 'object') {
for (var i in k) {
i = i.toLowerCase()
this.opt.headers[i] = k[i]
}
} else if (typeof k === 'string') {
if (arguments.length < 2) throw new Error('2 arguments required')
// 全转小写,避免重复写入
k = k.toLowerCase()
if (val === undefined) delete this.opt.headers[k]
else this.opt.headers[k] = val
} else {
throw new Error(
'arguments must be string/object, but [' + typeof k + '] given'
)
}
return this
}
//设置请求参数
_requestp.send = function(k, val) {
if (!this.transport) return
// 1. send方法可以多次调用, 但必须保证格式一致
// 2. 2次圴提交纯字符串也会抛出异常
if (typeof k === 'object') {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error('param can not be string and object at the same time')
if (!this.opt.data) this.opt.data = {}
F.merge(this.opt.data, k)
} else {
if (typeof k === 'string') {
if (arguments.length === 1) {
if (this.opt.data) throw new Error('invalid param in function send')
this.opt.data = k
} else {
if (this.opt.data && typeof this.opt.data === 'string')
throw new Error(
'param can not be string and object at the same time'
)
if (!this.opt.data) this.opt.data = {}
this.opt.data[k] = val
}
} else {
throw new Error(
'argument of send must be string/object, but [' + typeof k + '] given'
)
}
}
return this
}
//该方法用于 form-data类型的post请求的参数设置
_requestp.field = function(k, val) {
if (!this.transport) return this
// 此类型优先级最高
this.opt.formType = 'form-data'
this.opt.type = 'POST'
if (!this.opt.data || (this.opt.data && typeof this.opt.data !== 'object'))
this.opt.data = {}
if (arguments.length === 1 && typeof k === 'object') {
F.merge(this.opt.data, k)
} else if (arguments.length === 2) {
this.opt.data[k] = val
} else {
throw new TypeError(
'argument must be an object, but ' + typeof k + ' given'
)
}
return this
}
//设置缓存
_requestp.cache = function(t) {
if (!this.transport) return
if (this.opt.type === 'GET') this.opt.cache = !!t
return this
}
//取消网络请求
_requestp.abort = function() {
delete this.transport
if (!this.opt.form) this.xhr.abort()
return this
}
//超时设置, 单位毫秒
_requestp.timeout = function(time) {
if (typeof time !== 'number' || time < 1) return this
this.opt.timeout = time
return this
}
_requestp.form = function(form) {
if (typeof form === 'object' && form.nodeName === 'FORM') {
this.opt.type = 'POST'
this.opt.form = form
}
return this
}
var originAnchor = doc.createElement('a')
originAnchor.href = location.href
_requestp.end = function(callback) {
var _this = this
// 回调已执行, 或已取消, 则直接返回, 防止重复执行
if (!this.transport) return this
if (!this.opt.url) throw new Error('Invalid request url')
F.merge(this, requestExtend)
this.callback = callback || noop.bind(this)
// 1. url规范化
this.opt.url = this.opt.url
.replace(/#.*$/, '')
.replace(/^\/\//, location.protocol + '//')
// 2. 处理跨域
if (typeof this.opt.crossDomain !== 'boolean') {
var anchor = doc.createElement('a')
try {
anchor.href = this.opt.url
// IE7及以下浏览器 '1'[0]的结果是 undefined
// IE7下需要获取绝对路径
var absUrl = !'1'[0] ? anchor.getAttribute('href', 4) : anchor.href
anchor.href = absUrl
anchor.async = true
this.opt.crossDomain =
originAnchor.protocol !== anchor.protocol ||
originAnchor.host !== anchor.host
} catch (e) {
this.opt.crossDomain = true
}
}
// 2.1 进一步处理跨域配置
if (this.opt.type === 'JSONP') {
//如果没有跨域自动转回xhr GET
if (!this.opt.crossDomain) {
this.opt.type = 'GET'
} else {
this.opt.data['callback'] =
this.opt.data['callback'] || 'jsonp' + request.cid++
this.jsonp(this.opt.data['callback']) //创建临时处理方法
}
}
// 2.2 如果不是跨域请求则自动加上一条header信息用以标识这是ajax请求
if (!this.opt.crossDomain) {
this.set('X-Requested-With', 'XMLHttpRequest')
} else {
supportCors && (this.xhr.withCredentials = true)
}
// 3. data转字符串
this.opt.param = F.param(this.opt.data)
// 4. 设置Content-Type类型, 默认x-www-form-urlencoded
if (!this.opt.formType) this.type('form')
// 5.处理GET请求
this.opt.hasContent = this.opt.type === 'POST' //是否为post请求
if (!this.opt.hasContent) {
//GET请求直接把参数拼接到url上
if (this.opt.param) {
this.opt.url += (/\?/.test(this.opt.url) ? '&' : '?') + this.opt.param
}
//加随机值,避免缓存
if (this.opt.cache === false)
this.opt.url +=
(/\?/.test(this.opt.url) ? '&' : '?') + '_=' + Math.random()
} else {
if (this.opt.formType === 'form-data') {
delete this.opt.headers['content-type']
this.opt.param = this.formData()
} else if (this.opt.formType !== 'form') {
this.opt.param = JSON.stringify(this.opt.data)
}
}
//jsonp
if (this.opt.type === 'JSONP') {
this.transport = doc.createElement('script')
this.transport.onerror = this.transport.onload = function() {
_this.dispatch(_this.transport)
}
this.transport.src = this.opt.url
doc.head.insertBefore(this.transport, doc.head.firstChild)
//6. 超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.opt.timeoutID = setTimeout(function() {
_this.transport.onerror = _this.transport.onload = null
_this.dispatch(null)
}, this.opt.timeout)
}
} else {
this.xhr.onreadystatechange = function(ev) {
if (_this.opt.timeout && _this.opt.timeout > 0) {
_this.opt['time' + this.readyState] = ev.timeStamp
if (this.readyState === 4) {
_this.opt.isTimeout =
_this.opt.time4 - _this.opt.time1 > _this.opt.timeout
}
}
if (this.readyState !== 4) {
return
}
_this.dispatch(_this.opt.isTimeout ? null : _this.xhr)
}
// 6. 初始化xhr提交
this.xhr.open(this.opt.type, this.opt.url, true)
// 7. 设置头信息
for (var i in this.opt.headers) {
if (this.opt.headers[i])
this.xhr.setRequestHeader(i, this.opt.headers[i])
}
// 8. 发起网络请求
_this.xhr.send(_this.opt.param)
//超时处理
if (this.opt.timeout && this.opt.timeout > 0) {
this.xhr.timeout = this.opt.timeout
}
}
return this.defer.promise
}
// ---------------------- end ------------------------
if (!win.request) {
win.request = {
get: function(url) {
if (!url) throw new Error('argument url is required')
return new _request(url, 'GET')
},
post: function(url) {
if (!url) throw new Error('argument url is required')
return new _request(url, 'POST')
},
jsonp: function(url) {
if (!url) throw new Error('argument url is required')
return new _request(url, 'JSONP')
},
cache: {},
cid: 0,
version: '1.1.0-es5'
}
yua.ui.request = request.version
}
return request
})

Some files were not shown because too many files have changed in this diff Show More