From ba238b8aa2dcf38737626b4da8caafb15453a02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sat, 31 Aug 2019 23:59:20 +0800 Subject: [PATCH 1/6] update --- package.json | 2 +- src/js/app.js | 6 +- src/js/modules/ktv.js | 8 +- src/js/modules/local.js | 26 ++++-- src/js/modules/profile.js | 16 +++- src/js/modules/search.js | 16 ++-- src/lib/lyrics/index.js | 10 ++- src/main.js | 3 +- src/tools/init.js | 171 ++++++++++++++++++++------------------ src/tools/shortcut.js | 26 +++--- src/tools/windows.js | 2 +- src/views/local.htm | 12 +-- src/views/profile.htm | 8 ++ src/views/search.htm | 10 +-- 14 files changed, 181 insertions(+), 135 deletions(-) diff --git a/package.json b/package.json index 3e609d8..cddfd9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sonist", - "version": "1.1.0", + "version": "1.2.0", "description": "Music Player", "main": "src/main.js", "scripts": { diff --git a/src/js/app.js b/src/js/app.js index 5b0fa32..5292776 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -41,6 +41,10 @@ const PLAY_MODE = { 2: 'random' } +// window.onblur = function() { +// location.reload() +// } + // 本地音乐和试用音乐列表 window.LS = store.collection('local') window.TS = store.collection('temp') @@ -48,7 +52,7 @@ window.TS = store.collection('temp') window.SONIST = new AudioPlayer() window.LYRICS = new Lyrics() -let appInit = ipcRenderer.sendSync('get-init') +let appInit = ipcRenderer.sendSync('sonist', { type: 'get-init' }) Anot.ss('app-init', appInit) diff --git a/src/js/modules/ktv.js b/src/js/modules/ktv.js index daf9b7a..dd848f4 100644 --- a/src/js/modules/ktv.js +++ b/src/js/modules/ktv.js @@ -95,13 +95,17 @@ export default { SONIST.clear() SONIST.push(LS.getAll()) - ipcRenderer.send('set-music', LS.getAll()) + ipcRenderer.send('sonist', { type: 'set-music', data: LS.getAll() }) this.updateCurr(song) this.draw(true) } - ipcRenderer.send('save-lrc', { id, lrc: json.lyrics }) + ipcRenderer.send('sonist', { + type: 'save-lrc', + id, + data: json.lyrics + }) LYRICS.__init__(id) layer.toast('歌词应用成功...') diff --git a/src/js/modules/local.js b/src/js/modules/local.js index 23a0457..1555371 100644 --- a/src/js/modules/local.js +++ b/src/js/modules/local.js @@ -34,7 +34,7 @@ export default Anot({ }, mounted() { appInit = JSON.parse(Anot.ss('app-init')) - dbCache = ipcRenderer.sendSync('get-music') + dbCache = ipcRenderer.sendSync('sonist', { type: 'get-music' }) LS.insert(dbCache) @@ -112,11 +112,15 @@ export default Anot({ this.__APP__.updateCurr(it) this.__APP__.draw(true) - ipcRenderer.send('save-lrc', { + ipcRenderer.send('sonist', { + type: 'save-lrc', id: it.id, - lrc: json.lyrics + data: json.lyrics + }) + ipcRenderer.send('sonist', { + type: 'set-music', + data: LS.getAll() }) - ipcRenderer.send('set-music', LS.getAll()) LYRICS.__init__(it.id) }) @@ -145,7 +149,7 @@ export default Anot({ SONIST.clear() SONIST.push(dbCache) - ipcRenderer.send('set-music', dbCache) + ipcRenderer.send('sonist', { type: 'set-music', data: dbCache }) dbCache = null layer.toast(`刷新缓存完成,新增${this.__NEW_NUM__}首`) @@ -188,7 +192,10 @@ export default Anot({ return } if (appInit.musicPath) { - this.__LIST__ = ipcRenderer.sendSync('scan-dir', appInit.musicPath) + this.__LIST__ = ipcRenderer.sendSync('sonist', { + type: 'scan-dir', + path: appInit.musicPath + }) if (this.__LIST__) { this.__tmp__ = [] //创建一个临时的数组, 用于存放扫描的音乐 this.__APP__.loading = true @@ -235,7 +242,7 @@ export default Anot({ SONIST.clear() SONIST.push(LS.getAll()) - ipcRenderer.send('set-music', LS.getAll()) + ipcRenderer.send('sonist', { type: 'set-music', data: LS.getAll() }) }, handleMenu(it, idx, ev) { let that = this @@ -278,7 +285,10 @@ export default Anot({ SONIST.clear() SONIST.push(LS.getAll()) - ipcRenderer.send('set-music', LS.getAll()) + ipcRenderer.send('sonist', { + type: 'set-music', + data: LS.getAll() + }) } ) } else { diff --git a/src/js/modules/profile.js b/src/js/modules/profile.js index deeb7d8..1c7157d 100644 --- a/src/js/modules/profile.js +++ b/src/js/modules/profile.js @@ -15,7 +15,7 @@ const { const log = console.log -let appInit = ipcRenderer.sendSync('get-init') +let appInit = ipcRenderer.sendSync('sonist', { type: 'get-init' }) export default Anot({ $id: 'profile', @@ -24,7 +24,8 @@ export default Anot({ allowPlayOnBack: appInit.allowPlayOnBack, autoLrc: appInit.autoLrc, theme: appInit.theme || 1, - musicPath: appInit.musicPath || '' + musicPath: appInit.musicPath || '', + allowGS: !!appInit.allowGS }, version: app.getVersion(), cmd: process.platform === 'darwin' ? '⌘' : 'Ctrl', @@ -34,6 +35,15 @@ export default Anot({ 'setting.theme'(v) { v = +v this.__APP__.theme = v + }, + 'setting.allowGS'(v) { + if (v) { + log('++++++++++++') + ipcRenderer.send('sonist', { type: 'enable-gs' }) + } else { + log('-----------') + ipcRenderer.send('sonist', { type: 'disable-gs' }) + } } }, methods: { @@ -58,7 +68,7 @@ export default Anot({ Object.assign(appInit, setting) - ipcRenderer.send('set-init', appInit) + ipcRenderer.send('sonist', { type: 'set-init', data: appInit }) Anot.ss('app-init', appInit) diff --git a/src/js/modules/search.js b/src/js/modules/search.js index 02a0070..e3741f9 100644 --- a/src/js/modules/search.js +++ b/src/js/modules/search.js @@ -23,7 +23,7 @@ export default Anot({ list: [] // 搜索结果列表 }, mounted() { - dict.audition = ipcRenderer.sendSync('get-temp') + dict.audition = ipcRenderer.sendSync('sonist', { type: 'get-temp' }) TS.insert(dict.audition) this.__APP__ = Anot.vmodels.app @@ -91,14 +91,18 @@ export default Anot({ song.cover = json.img - ipcRenderer.send('save-lrc', { id: song.id, lrc: json.lyrics }) + ipcRenderer.send('sonist', { + type: 'save-lrc', + id: song.id, + data: json.lyrics + }) request.get(json.play_url, { dataType: 'arraybuffer' }).then(res => { - song.path = ipcRenderer.sendSync('save-cache', { - buff: Buffer.from(res.body), + song.path = ipcRenderer.sendSync('sonist', { + type: 'save-cache', + data: Buffer.from(res.body), file: song.kgHash }) - log(song) TS.insert(song) dict.audition.push(song) @@ -108,7 +112,7 @@ export default Anot({ this.curr = it.id }) - ipcRenderer.send('set-temp', TS.getAll()) + ipcRenderer.send('sonist', { type: 'set-temp', data: TS.getAll() }) }) }) }, diff --git a/src/lib/lyrics/index.js b/src/lib/lyrics/index.js index 325a8a3..c10d621 100644 --- a/src/lib/lyrics/index.js +++ b/src/lib/lyrics/index.js @@ -21,7 +21,7 @@ class Lyrics { r: { bg: '', txt: '' } } - let lrc = ipcRenderer.sendSync('read-lrc', id) + let lrc = ipcRenderer.sendSync('sonist', { type: 'read-lrc', id }) if (!id || lrc === null) { log('no lrc file', id) return false @@ -29,8 +29,6 @@ class Lyrics { this.__ID__ = id - log(id) - this.lib = lrc .split('\n') .map(it => { @@ -106,7 +104,11 @@ class Lyrics { // 延时3秒写入 this.__TIMER__ = setTimeout(() => { - ipcRenderer.send('save-lrc', { id: this.__ID__, lrc }) + ipcRenderer.send('sonist', { + type: 'save-lrc', + id: this.__ID__, + data: lrc + }) }, 3000) } diff --git a/src/main.js b/src/main.js index aa2edbe..6c94640 100644 --- a/src/main.js +++ b/src/main.js @@ -32,7 +32,7 @@ const MIME_TYPES = { require('./tools/init') const createTray = require('./tools/tray') const createMenu = require('./tools/menu') -const Shortcut = require('./tools/shortcut') + const { createMainWindow, createErrorWindow } = require('./tools/windows') const ROOT = __dirname @@ -75,7 +75,6 @@ app.once('ready', () => { win.webContents.send('dock-click') } }) - Shortcut.__init__(win) } else { createErrorWindow() } diff --git a/src/tools/init.js b/src/tools/init.js index 1b07ad9..e956a4a 100644 --- a/src/tools/init.js +++ b/src/tools/init.js @@ -6,10 +6,10 @@ 'use strict' -const { app, ipcMain } = require('electron') +const { app, ipcMain, globalShortcut: GS } = require('electron') const path = require('path') -// const http = require('http') const fs = require('iofs') +const Shortcut = require('./shortcut') /* ********** 修复环境变量 start *********** */ let PATH_SET = new Set() @@ -43,92 +43,97 @@ if (!fs.exists(APP_ROOT)) { } const SUPPORTED_EXTS = ['.mp3', '.webm', '.ogg', '.flac', '.m4a', '.aac'] +const DB = { + read(file) { + let cache = (fs.cat(file) || '[]').toString('utf-8') + try { + return JSON.parse(cache) + } catch (err) { + return cache + } + }, + save(file, data) { + fs.echo(JSON.stringify(data), file) + } +} /* ----------------------------------------------------------------- */ /* --------------------- 事件开始 ------------------------- */ /* ---------------------------------------------------------------- */ -// 获取应用配置 -ipcMain.on('get-init', (ev, val) => { - let cache = fs.cat(INIT_FILE).toString('utf-8') - cache = JSON.parse(cache) - ev.returnValue = cache -}) - -// 设置应用配置 -ipcMain.on('set-init', (ev, val) => { - fs.echo(JSON.stringify(val), INIT_FILE) -}) - -// 获取音乐数据库 -ipcMain.on('get-music', (ev, val) => { - let cache = fs.cat(DB_FILE).toString('utf-8') - cache = JSON.parse(cache) - ev.returnValue = cache -}) - -// 更新音乐数据库 -ipcMain.on('set-music', (ev, val) => { - fs.echo(JSON.stringify(val), DB_FILE) -}) - -// 获取临时音乐数据库 -ipcMain.on('get-temp', (ev, val) => { - let cache = (fs.cat(TEMP_DB) || '[]').toString('utf-8') - cache = JSON.parse(cache) - ev.returnValue = cache -}) - -// 更新临时音乐数据库 -ipcMain.on('set-temp', (ev, val) => { - fs.echo(JSON.stringify(val), TEMP_DB) -}) - -/** - * 保存歌词文件 - */ -ipcMain.on('save-lrc', (ev, obj) => { - fs.echo(obj.lrc, path.join(LRC_DIR, `${obj.id}.lrc`)) -}) - -/** - * 读取歌词文件 - */ -ipcMain.on('read-lrc', (ev, id) => { - let file = path.join(LRC_DIR, `${id}.lrc`) - if (fs.exists(file)) { - ev.returnValue = fs.cat(file).toString('utf8') - } else { - ev.returnValue = null - } -}) - -/** - * 保存音乐文件 - */ -ipcMain.on('save-cache', (ev, obj) => { - let savefile = path.join(CACHE_DIR, obj.file) - fs.echo(obj.buff, savefile) - ev.returnValue = `file://${savefile}` -}) - -/** - * 扫描目录 - */ -ipcMain.on('scan-dir', (ev, dir) => { - if (fs.isdir(dir)) { - let list = fs.ls(dir, true).filter(_ => { - if (fs.isdir(_)) { - return false +ipcMain.on('sonist', (ev, conn) => { + switch (conn.type) { + // 获取应用配置 + case 'get-init': + ev.returnValue = DB.read(INIT_FILE) + break + // 设置应用配置 + case 'set-init': + DB.save(INIT_FILE, conn.data) + break + // 获取音乐数据库 + case 'get-music': + ev.returnValue = DB.read(DB_FILE) + break + // 更新音乐数据库 + case 'set-music': + DB.save(DB_FILE, conn.data) + break + // 获取临时音乐数据库 + case 'get-temp': + ev.returnValue = DB.read(TEMP_DB) + break + // 更新临时音乐数据库 + case 'set-temp': + DB.save(TEMP_DB, conn.data) + break + // 读取歌词文件 + case 'read-lrc': + let lrc = path.join(LRC_DIR, `${conn.id}.lrc`) + if (fs.exists(lrc)) { + ev.returnValue = DB.read(lrc) } else { - let { ext, name } = path.parse(_) - if (!ext || name.startsWith('.')) { - return false - } - return SUPPORTED_EXTS.includes(ext) + ev.returnValue = null } - }) - ev.returnValue = list - } else { - ev.returnValue = null + break + // 保存歌词文件 + case 'save-lrc': + fs.echo(conn.data, path.join(LRC_DIR, `${conn.id}.lrc`)) + break + // 保存音乐文件 + case 'save-cache': + let file = path.join(CACHE_DIR, conn.file) + fs.echo(conn.data, file) + ev.returnValue = `file://${file}` + break + + // 扫描目录 + case 'scan-dir': + if (fs.isdir(conn.path)) { + let list = fs.ls(conn.path, true).filter(_ => { + if (fs.isdir(_)) { + return false + } else { + let { ext, name } = path.parse(_) + if (!ext || name.startsWith('.')) { + return false + } + return SUPPORTED_EXTS.includes(ext) + } + }) + ev.returnValue = list + } else { + ev.returnValue = null + } + break + + // 启用全局快捷键 + case 'enable-gs': + Shortcut.__init__() + break + + // 禁用全局快捷键 + case 'disable-gs': + GS.unregisterAll() + break } }) diff --git a/src/tools/shortcut.js b/src/tools/shortcut.js index 6d549c3..666c2c0 100644 --- a/src/tools/shortcut.js +++ b/src/tools/shortcut.js @@ -6,52 +6,52 @@ 'use strict' -const { globalShortcut: GS } = require('electron') +const { app, globalShortcut: GS } = require('electron') module.exports = { - __init__(win) { + __init__() { // 播放控制... GS.register('MediaNextTrack', _ => { - win.emit('gs-ctrl', 'next') + app.__MAIN__.emit('gs-ctrl', 'next') }) GS.register('MediaPreviousTrack', _ => { - win.emit('gs-ctrl', 'prev') + app.__MAIN__.emit('gs-ctrl', 'prev') }) GS.register('MediaStop', _ => { - win.emit('gs-ctrl', 'stop') + app.__MAIN__.emit('gs-ctrl', 'stop') }) GS.register('MediaPlayPause', _ => { - win.emit('gs-ctrl', 'play') + app.__MAIN__.emit('gs-ctrl', 'play') }) // others GS.register('Super+Alt+Space', _ => { - win.emit('gs-ctrl', 'play') + app.__MAIN__.emit('gs-ctrl', 'play') }) GS.register('Super+Alt+Left', _ => { - win.emit('gs-ctrl', 'prev') + app.__MAIN__.emit('gs-ctrl', 'prev') }) GS.register('Super+Alt+Right', _ => { - win.emit('gs-ctrl', 'next') + app.__MAIN__.emit('gs-ctrl', 'next') }) GS.register('Super+Alt+Up', _ => { - win.emit('gs-ctrl', 'vu') + app.__MAIN__.emit('gs-ctrl', 'vu') }) GS.register('Super+Alt+Down', _ => { - win.emit('gs-ctrl', 'vd') + app.__MAIN__.emit('gs-ctrl', 'vd') }) GS.register('Super+Alt+R', _ => { - win.emit('gs-ctrl', 'lrc') + app.__MAIN__.emit('gs-ctrl', 'lrc') }) GS.register('Super+Alt+Shift+M', _ => { - win.emit('gs-ctrl', 'mini') + app.__MAIN__.emit('gs-ctrl', 'mini') }) } } diff --git a/src/tools/windows.js b/src/tools/windows.js index 951560a..bac8561 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -33,7 +33,7 @@ exports.createMainWindow = function(icon) { win.on('ready-to-show', _ => { win.show() - // win.openDevTools() + win.openDevTools() }) return win diff --git a/src/views/local.htm b/src/views/local.htm index 6110c85..93eccdb 100644 --- a/src/views/local.htm +++ b/src/views/local.htm @@ -14,17 +14,17 @@ 时长 - + - - - - - + + + + + diff --git a/src/views/profile.htm b/src/views/profile.htm index a4ed989..d6124ab 100644 --- a/src/views/profile.htm +++ b/src/views/profile.htm @@ -91,6 +91,14 @@ +
+ 启用全局快捷键 +
+ (即使app在后台也能控制) +
+
+ +
关于Sonist
diff --git a/src/views/search.htm b/src/views/search.htm index 5638639..e435169 100644 --- a/src/views/search.htm +++ b/src/views/search.htm @@ -26,16 +26,16 @@ 时长 - + - - - - + + + + From b1bcf6d14d4511cbf6c9c887f152057547eed051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 1 Sep 2019 23:20:34 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=8D=87=E7=BA=A7UI=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/anot.js | 5229 +++++++++++++++++++++++++++++++++++++- src/lib/avatar/index.js | 16 +- src/lib/drag/core.js | 1 + src/lib/drag/doc.md | 85 - src/lib/drag/index.js | 2 +- src/lib/form/button.js | 15 + src/lib/form/cascader.js | 15 + src/lib/form/checkbox.js | 15 + src/lib/form/index.js | 1 - src/lib/form/input.js | 15 + src/lib/form/progress.js | 15 + src/lib/form/radio.js | 15 + src/lib/form/select.js | 15 + src/lib/form/switch.js | 15 + src/lib/layer/index.js | 2 +- src/lib/layer/next.js | 15 + src/lib/pager/index.js | 16 +- src/lib/request/index.js | 2 +- src/lib/utils.js | 1 + 19 files changed, 5391 insertions(+), 99 deletions(-) create mode 100644 src/lib/drag/core.js delete mode 100644 src/lib/drag/doc.md create mode 100644 src/lib/form/button.js create mode 100644 src/lib/form/cascader.js create mode 100644 src/lib/form/checkbox.js delete mode 100644 src/lib/form/index.js create mode 100644 src/lib/form/input.js create mode 100644 src/lib/form/progress.js create mode 100644 src/lib/form/radio.js create mode 100644 src/lib/form/select.js create mode 100644 src/lib/form/switch.js create mode 100644 src/lib/layer/next.js create mode 100644 src/lib/utils.js diff --git a/src/lib/anot.js b/src/lib/anot.js index a59eda4..252027b 100644 --- a/src/lib/anot.js +++ b/src/lib/anot.js @@ -1,8 +1,5221 @@ -/*================================================== - * Anot normal version for future browsers - * @authors yutent (yutent@doui.cc) - * @date 2017-03-21 21:05:57 - * V2.0.0 - * - ==================================================*/ - const _Anot=function(){const e={};let t=1024,n=0;window.VBArray&&(n=document.documentMode||(window.XMLHttpRequest?7:6));let r=T(),i=window.document,a=i.head;a.insertAdjacentHTML("afterbegin",'');let o=a.firstChild;function s(){console.log.apply(console,arguments)}function l(){return Object.create(null)}let c="$"+r,u={},f=/[^, ]+/g,p=/\w+/g,d=/^\[object SVG\w*Element\]$/,h=Object.prototype,v=h.hasOwnProperty,m=h.toString,y=Array.prototype,g=y.slice,b=window.dispatchEvent,w=i.documentElement,x=i.createDocumentFragment(),$=(i.createElement("div"),{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object Error]":"error","[object AsyncFunction]":"asyncfunction","[object Promise]":"promise","[object Generator]":"generator","[object GeneratorFunction]":"generatorfunction"});function k(){}function C(e){return Function.apply(k,e)}function A(e,t){"string"==typeof e&&(e=e.match(f)||[]);let n={},r=void 0!==t?t:1;for(let t=0,i=e.length;t{e.resolve=t,e.reject=n}),e}),String.prototype.splice||Object.defineProperty(String.prototype,"splice",{value:function(e,t,n){let r=this.length,i=arguments.length;if(n=void 0===n?"":n,i<1)return this;if(e<0&&(e=Math.abs(e)>=r?0:r+e),1===i)return this.slice(0,e);return t-=0,this.slice(0,e)+n+this.slice(e+t)},enumerable:!1}),Date.prototype.getFullWeek||(Object.defineProperty(Date.prototype,"getFullWeek",{value:function(){let e=this.getFullYear(),t=new Date(e,0,1),n=t.getDay()||1,r=(this-t)/864e5;return Math.ceil((r+n)/7)},enumerable:!1}),Object.defineProperty(Date.prototype,"getWeek",{value:function(){let e=this.getDate(),t=this.getMonth(),n=this.getFullYear(),r=new Date(n,t,1).getDay();return Math.ceil((e+r)/7)},enumerable:!1})),Date.isDate||Object.defineProperty(Date,"isDate",{value:function(e){return!("object"!=typeof e||!e.getTime)},enumerable:!1}),Date.prototype.format||Object.defineProperty(Date.prototype,"format",{value:function(e){e=e||"Y-m-d H:i:s";let t,n={fullyear:this.getFullYear(),year:this.getYear(),fullweek:this.getFullWeek(),week:this.getWeek(),month:this.getMonth()+1,date:this.getDate(),day:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"][this.getDay()],hours:this.getHours(),minutes:this.getMinutes(),seconds:this.getSeconds()};n.g=n.hours>12?n.hours-12:n.hours,t={Y:n.fullyear,y:n.year,m:n.month<10?"0"+n.month:n.month,n:n.month,d:n.date<10?"0"+n.date:n.date,j:n.date,H:n.hours<10?"0"+n.hours:n.hours,h:n.g<10?"0"+n.g:n.g,G:n.hours,g:n.g,i:n.minutes<10?"0"+n.minutes:n.minutes,s:n.seconds<10?"0"+n.seconds:n.seconds,W:n.fullweek,w:n.week,D:n.day};for(let n in t)e=e.replace(new RegExp(n,"g"),t[n]);return e},enumerable:!1});let N=function(e){return new N.init(e)};N.nextTick=new function(){let e=window.setImmediate,t=window.MutationObserver;if(e)return e.bind(window);let n=[];if(t){let e=document.createTextNode("anot");new t(function(){let e=n.length;for(let t=0;t>>0)return!0}return!1}(e))for(let r=e.length;n1){if(!e)return;if(n=n||{},n=Object.assign({expires:"",path:"/",domain:document.domain,secure:""},n),"string"==this.type(t)&&""===t.trim()||null===t)return document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain="+n.domain+"; path="+n.path,!0;if(n.expires)switch(n.expires.constructor){case Number:n.expires=n.expires===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n.expires;break;case String:n.expires="; expires="+n.expires;break;case Date:n.expires="; expires="+n.expires.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+n.expires+"; domain="+n.domain+"; path="+n.path+"; "+n.secure,!0}return e?decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:document.cookie},search:function(e){e+="";let t=location.search;if(!e||!t)return null;t=(t=t.slice(1)).split("&");let n={};for(let e,r=0;e=t[r++];){let t=e.split("=");t[1]=t.length<2?null:t[1],t[1]=decodeURIComponent(t[1]),n.hasOwnProperty(t[0])?"object"==typeof n[t[0]]?n[t[0]].push(t[1]):(n[t[0]]=[n[t[0]]],n[t[0]].push(t[1])):n[t[0]]=t[1]}return n.hasOwnProperty(e)?n[e]:null},copy:function(e){if(!i.queryCommandSupported||!i.queryCommandSupported("copy"))return s("该浏览器不支持复制到粘贴板");let t=i.createElement("textarea");t.textContent=e,t.style.position="fixed",t.style.bottom="-1000px",i.body.appendChild(t),t.select();try{i.execCommand("copy")}catch(e){s("复制到粘贴板失败")}i.body.removeChild(t)}});let j=N.bindingHandlers={},O=N.bindingExecutors={},S=N.directives={};N.directive=function(e,t){return j[e]=t.init=t.init||k,O[e]=t.update=t.update||k,S[e]=t};let D=new function(){function e(e){this.size=0,this.limit=e,this.head=this.tail=void 0,this._keymap={}}let t=e.prototype;return t.put=function(e,t){let n={key:e,value:t};return this._keymap[e]=n,this.tail?(this.tail.newer=n,n.older=this.tail):this.head=n,this.tail=n,this.size===this.limit?this.shift():this.size++,t},t.shift=function(){let e=this.head;e&&(this.head=this.head.newer,this.head.older=e.newer=e.older=this._keymap[e.key]=void 0,delete this._keymap[e.key])},t.get=function(e){let t=this._keymap[e];if(void 0!==t)return t===this.tail?t.value:(t.newer&&(t===this.head&&(this.head=t.newer),t.newer.older=t.older),t.older&&(t.older.newer=t.newer),t.newer=void 0,t.older=this.tail,this.tail&&(this.tail.newer=t),this.tail=t,t.value)},e};if(i.contains||(Node.prototype.contains=function(e){return!!(16&this.compareDocumentPosition(e))}),N.contains=function(e,t){try{for(;t=t.parentNode;)if(t===e)return!0;return!1}catch(e){return!1}},window.SVGElement){let e="http://www.w3.org/2000/svg",t=i.createElementNS(e,"svg");if(t.innerHTML='',!d.test(t.firstChild)){function L(t,n){if(t&&t.childNodes){let r=t.childNodes;for(let t,a=0;t=r[a++];)if(t.tagName){let r=i.createElementNS(e,t.tagName.toLowerCase());y.forEach.call(t.attributes,function(e){r.setAttribute(e.name,e.value)}),L(t,r),n.appendChild(r)}}}Object.defineProperties(SVGElement.prototype,{outerHTML:{enumerable:!0,configurable:!0,get:function(){return(new XMLSerializer).serializeToString(this)},set:function(e){let t=this.tagName.toLowerCase(),n=this.parentNode,r=N.parseHTML(e);if("svg"===t)n.insertBefore(r,this);else{let e=i.createDocumentFragment();L(r,e),n.insertBefore(e,this)}n.removeChild(this)}},innerHTML:{enumerable:!0,configurable:!0,get:function(){let e=this.outerHTML,t=new RegExp("<"+this.nodeName+'\\b(?:(["\'])[^"]*?(\\1)|[^>])*>',"i"),n=new RegExp("$","i");return e.replace(t,"").replace(n,"")},set:function(e){if(N.clearHTML){N.clearHTML(this),L(N.parseHTML(e),this)}}}})}}let M=N.eventHooks;function P(e){for(var t in e)if(v.call(e,t)){var n=e[t];"function"==typeof P.plugins[t]?P.plugins[t](n):"object"==typeof P[t]?N.mix(P[t],n):P[t]=n}return this}"onmouseenter"in w||N.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){M[e]={type:t,fix:function(t,n){return function(r){let i=r.relatedTarget;if(!i||i!==t&&!(16&t.compareDocumentPosition(i)))return delete r.type,r.type=e,n.call(t,r)}}}}),N.each({AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"},function(e,t){window[e]&&!M.animationend&&(M.animationend={type:t})}),void 0===i.onmousewheel&&(M.mousewheel={type:"wheel",fix:function(e,t){return function(n){n.wheelDeltaY=n.wheelDelta=n.deltaY>0?-120:120,n.wheelDeltaX=0,Object.defineProperty(n,"type",{value:"mousewheel"}),t.call(e,n)}}}),N.config=P;var H,R,B,F,I=/[-.*+?^${}()|[\]\/\\]/g;function q(e){return(e+"").replace(I,"\\$&")}var V={interpolate:function(e){if(H=e[0],R=e[1],H===R)throw new SyntaxError("openTag!==closeTag");P.openTag=H,P.closeTag=R;var t=q(H),n=q(R);B=new RegExp(t+"([\\s\\S]*)"+n),F=new RegExp(t+"([\\s\\S]*)"+n,"g"),new RegExp(t+"[\\s\\S]*"+n+"|\\s:")}};function W(e,n){var r=this.$events||(this.$events={}),a=r[e]||(r[e]=[]);if("function"==typeof n){var o=n;o.uuid="_"+ ++t,(n={element:w,type:"user-watcher",handler:k,vmodels:[this],expr:e,uuid:o.uuid}).wildcard=/\*/.test(e)}if(n.update)n.oneTime||N.Array.ensure(a,n);else{if(/\w\.*\B/.test(e)||"*"===e){n.getter=k;var s=this;n.update=function(){var e=this.fireArgs||[];e[2]&&n.handler.apply(s,e),delete this.fireArgs},a.sync=!0,N.Array.ensure(a,n)}else N.injectBinding(n);o&&(n.handler=o)}return function(){n.update=n.getter=n.handler=k,n.element=i.createElement("a")}}function U(e,n){var r=this.$events,i=null;if(r&&r[e]){n&&(n[2]=e);var a=r[e];if(function(e,n){if(!e)return;new Date-ce>444&&"object"==typeof e[0]&&pe();for(var r,i=[],a=[],o=0;r=e[o++];)"user-watcher"===r.type?i.push(r):a.push(r);if(P.async){for(xt.render(),o=0;r=a[o++];)if(r.update){r.uuid=r.uuid||"_"+ ++t;var s=r.uuid;xt.queue[s]||(xt.queue[s]="__",xt.queue.push(r))}}else for(o=0;r=a[o++];)r.update&&r.update();for(o=0;r=i[o++];)(n&&n[2]===r.expr||r.wildcard)&&(r.fireArgs=n),r.update()}(a,n),n&&r["*"]&&!/\./.test(e))for(var o,s=0;o=r["*"][s++];)try{o.handler.apply(this,n)}catch(e){}(i=this.$up)&&(this.$pathname&&U.call(i,this.$pathname+"."+e,n),U.call(i,"*."+e,n))}else{if(i=this.$up,this.$ups){for(var l in this.$ups)U.call(this.$ups[l],l+"."+e,n);return}if(i){var c=this.$pathname;""===c&&(c="*");var u=c+"."+e;a=u.split("."),n=n&&n.concat([u,e])||[u,e],-1===a.indexOf("*")?(U.call(i,u,n),a[1]="*",U.call(i,a.join("."),n)):U.call(i,u,n)}}}P.plugins=V,P.plugins.interpolate(["{{","}}"]),P.async=!0,P.paths={},P.shim={},P.maxRepeatSize=100;var z=A("$id,$watch,$fire,$events,$model,$active,$pathname,$up,$ups,$track,$accessors");function G(e,t){return(t=t||{}).watch=!0,X(e,t)}function X(e,t){if(!e||e.$id&&e.$accessors||e.nodeName&&e.nodeType>0)return e;var n,r=(t=t||u).force||u,i=t.old,a=i&&i.$accessors||u,o=new function(){},l={},c={},f=[],p=[],d={},h=e.state,v=e.computed,m=e.methods,y=e.props,g=e.watch,b=e.mounted;if(delete e.state,delete e.computed,delete e.methods,delete e.props,delete e.watch,e.skip&&(d=A(e.skip),delete e.skip),h)for(x in e.$id&&delete h.props,h){var w=h[x];z[x]||(c[x]=!0),"function"==typeof w||w&&w.nodeName&&w.nodeType>0||!r[x]&&("$"===(n=x).charAt(0)||"__"===n.slice(0,2)||z[n]||d[x])?f.push(x):Y(w)?(s("warning:计算属性建议放在[computed]对象中统一定义"),v[x]=w):(p.push(x),a[x]?l[x]=a[x]:l[x]=J(x,w))}if(v)for(var x in delete v.props,v)c[x]=!0,function(e,t){var n;"function"==typeof t&&(t={get:t,set:k}),"function"!=typeof t.set&&(t.set=k),l[e]={get:function(){return n=t.get.call(this)},set:function(r){var i,a=n;t.set.call(this,r),i=this[e],this.$fire&&i!==a&&this.$fire(e,i,a)},enumerable:!0,configurable:!0}}(x,v[x]);if(m)for(var x in delete m.props,m)c[x]=!0,f.push(x);if(y)for(var x in Z(o,"props",{}),c.props=!!e.$id,y)o.props[x]=y[x];if(Object.assign(e,h,m),l.$model=ee,o=Object.defineProperties(o,l,e),f.forEach(function(t){o[t]=e[t]}),Z(o,"$id","anonymous"),Z(o,"$up",i?i.$up:null),Z(o,"$track",Object.keys(c)),Z(o,"$active",!1),Z(o,"$pathname",i?i.$pathname:""),Z(o,"$accessors",l),Z(o,"$events",{}),Z(o,"$refs",{}),Z(o,"$children",[]),Z(o,"$components",[]),Z(o,"hasOwnProperty",function(e){return!0===c[e]}),Z(o,"$mounted",b),t.watch&&(Z(o,"$watch",function(){return W.apply(o,arguments)}),Z(o,"$fire",function(e,t){if(0===e.indexOf("all!")){var n=e.slice(4);for(var r in N.vmodels){(i=N.vmodels[r]).$fire&&i.$fire.apply(i,[n,t])}}else if(0===e.indexOf("child!")){n="props."+e.slice(6);for(var r in o.$children){var i;(i=o.$children[r]).$fire&&i.$fire.apply(i,[n,t])}}else U.call(o,e,[t])})),p.forEach(function(e){var t=i&&i[e],n=o[e]=h[e];n&&"object"==typeof n&&!Date.isDate(n)&&(n.$up=o,n.$pathname=e),U.call(o,e,[n,t])}),g)for(var $ in delete g.props,g)if(Array.isArray(g[$]))for(var C;C=g[$].pop();)W.call(o,$,C);else W.call(o,$,g[$]);return o.$active=!0,"anonymous"!==o.$id&&i&&i.$up&&i.$up.$children&&i.$up.$children.push(o),o}function Y(e){if(e&&"object"==typeof e){for(var t in e)if("get"!==t&&"set"!==t)return!1;return"function"==typeof e.get}}function J(e,t){var n;t=NaN;return{get:function(){return this.$active&&function(e,t){for(;;){if(e.$watch){var n=e.$events||(e.$events={}),r=n[t]||(n[t]=[]);return void se.collectDependency(r)}if(!(e=e.$up))break;t=e.$pathname+"."+t}}(this,e),t},set:function(r){if(t!==r){var i=t;(n=K(r,t))?t=n:(n=void 0,t=r),Object(n)===n&&(n.$pathname=e,n.$up=this),this.$active&&U.call(this,e,[t,i])}},enumerable:!0,configurable:!0}}function K(e,t,n,r){if(Array.isArray(e))return function(e,t,n){if(t&&t.splice){var r=[0,t.length].concat(e);return t.splice.apply(t,r),t}for(var i in ne)e[i]=ne[i];Z(e,"$up",null),Z(e,"$pathname",""),Z(e,"$track",ie(e.length)),e._=X({state:{length:NaN}},{watch:!0}),e._.length=e.length,e._.$watch("length",function(t,n){U.call(e.$up,e.$pathname+".length",[t,n])}),n&&Z(e,"$watch",function(){return W.apply(e,arguments)}),Object.defineProperty(e,"$model",ee);for(var a=0,o=e.length;a>>=0)>this.length)throw Error(e+"set方法的第一个参数不能大于原数组长度");if(this[e]!==t){var n=this[e];this.splice(e,1,t),U.call(this.$up,this.$pathname+".*",[t,n,null,e])}},contains:function(e){return this.indexOf(e)>-1},ensure:function(e){return this.contains(e)||this.push(e),this},pushArray:function(e){return this.push.apply(this,Q(e))},remove:function(e){return this.removeAt(this.indexOf(e))},removeAt:function(e){return e>>>=0,this.splice(e,1)},size:function(){return this._.length},removeAll:function(e){if(Array.isArray(e))for(var t=this.length-1;t>=0;t--)-1!==e.indexOf(this[t])&&(re.call(this.$track,t,1),re.call(this,t,1));else if("function"==typeof e)for(t=this.length-1;t>=0;t--){e(this[t],t)&&(re.call(this.$track,t,1),re.call(this,t,1))}else re.call(this.$track,0,this.length),re.call(this,0,this.length);b||(this.$model=Q(this)),this.notify(),this._.length=this.length},clear:function(){this.removeAll()}},re=te.splice;function ie(e){for(var t=[],n=0;n2){n[1],n.length;n=[n[0],n[1]].concat(ie(n.length-2))}}Array.prototype[t].apply(e,n)}(this.$track,e,n),b||(this.$model=Q(this)),this.notify(),this._.length=this.length,a}}),"sort,reverse".replace(f,function(e){ne[e]=function(){var t=this.concat(),n=Math.random(),r=[],i=!1;te[e].apply(this,arguments);for(var a=0,o=t.length;a444&&pe())}(t,e)}}),e.getter=Fe(e.expr,e.vmodels,e),e.observers.forEach(function(t){t.v.$watch(t.p,e)}),delete e.observers);try{var n,r,i=e.fireArgs;if(delete e.fireArgs,i)n=i[0],r=i[1];else if("on"===e.type)n=e.getter+"";else try{n=e.getter.apply(0,e.args)}catch(e){n=null}if(r=void 0===r?e.oldValue:r,e._filters&&(n=$n.$filter.apply(0,[n].concat(e._filters))),e.signature){var a=N.type(n);if("array"!==a&&"object"!==a)throw Error("warning:"+e.expr+"只能是对象或数组");e.xtype=a;var o=function(e,t){for(var n,r=[],i=0;n=e[i++];)r.push(t?n.$id:n.$key);return r.join(";")}(e.proxies||[],a),l=n.$track||("array"===a?ie(n.length):Object.keys(n));e.track=l,o!==l.join(";")&&(e.handler(n,r),e.oldValue=1)}else Array.isArray(n)&&n.length!==(r&&r.length)?(e.handler(n,r),e.oldValue=n.concat()):"oldValue"in e&&n===r||(e.handler(n,r),e.oldValue=Array.isArray(n)?n.concat():n)}catch(t){delete e.getter,s("warning:exception throwed in [Anot.injectBinding] ",t);var c=e.element;c&&3===c.nodeType&&(c.nodeValue=H+(e.oneTime?"::":"")+e.expr+R)}finally{t&&se.end()}},e.update()};var le=N.$$subscribers=[],ce=new Date;function ue(e,n){e.list=n,e.i=~~e.i,e.uuid||(e.uuid="_"+ ++t),le[e.uuid]||(le[e.uuid]="__",le.push(e))}var fe=0;function pe(e){for(var t=fe||le.length,n=0;e=le[--t];)if(e.i<7){if(null===e.element){le.splice(t,1),e.list&&(N.Array.remove(e.list,e),delete le[e.uuid]);continue}if(he(e.element)){if(le.splice(t,1),N.Array.remove(e.list,e),de(e),n++>500){fe=t;break}continue}e.i++,7===e.i&&(e.i=14)}else e.i--;ce=new Date}function de(e){for(var t in delete le[e.uuid],e.element=null,e.rollback&&e.rollback(),e)e[t]=null}function he(e){try{e.parentNode.nodeType}catch(e){return!0}return e.ifRemove&&!w.contains(e.ifRemove)&&o===e.parentNode?(e.parentNode&&e.parentNode.removeChild(e),!0):e.msRetain?0:1===e.nodeType?!w.contains(e):!N.contains(w,e)}var ve=new function(){N.mix(this,{option:i.createElement("select"),thead:i.createElement("table"),td:i.createElement("tr"),area:i.createElement("map"),tr:i.createElement("tbody"),col:i.createElement("colgroup"),legend:i.createElement("fieldset"),_default:i.createElement("div"),g:i.createElementNS("http://www.w3.org/2000/svg","svg")}),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td};String("circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use").replace(f,function(e){ve[e]=ve.g});var me=/<([\w:]+)/,ye=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,ge=A(["","text/javascript","text/ecmascript","application/ecmascript","application/javascript"]),be=i.createElement("script"),we=/<|&#?\w+;/;function xe(e){return e.replace(/([a-z\d])([A-Z]+)/g,"$1-$2").toLowerCase()}function $e(e){return e.indexOf("-")<0&&e.indexOf("_")<0?e:e.replace(/[-_][^-_]/g,function(e){return e.charAt(1).toUpperCase()})}N.parseHTML=function(e){var t=x.cloneNode(!1);if("string"!=typeof e)return t;if(!we.test(e))return t.appendChild(i.createTextNode(e)),t;e=e.replace(ye,"<$1>").trim();var n,r=(me.exec(e)||["",""])[1].toLowerCase(),a=ve[r]||ve._default;a.innerHTML=e;var o=a.getElementsByTagName("script");if(o.length)for(var s,l=0;s=o[l++];)if(ge[s.type]){var c=be.cloneNode(!1);y.forEach.call(s.attributes,function(e){c.setAttribute(e.name,e.value)}),c.text=s.text,s.parentNode.replaceChild(c,s)}for(;n=a.firstChild;)t.appendChild(n);return t},N.innerHTML=function(e,t){var n=this.parseHTML(t);this.clearHTML(e).appendChild(n)},N.clearHTML=function(e){for(e.textContent="";e.firstChild;)e.removeChild(e.firstChild);return e},"add,remove".replace(f,function(e){N.fn[e+"Class"]=function(t){var n=this[0];return t&&"string"==typeof t&&n&&1===n.nodeType&&t.replace(/\S+/g,function(t){n.classList[e](t)}),this}}),N.fn.mix({hasClass:function(e){var t=this[0]||{};return 1===t.nodeType&&t.classList.contains(e)},toggleClass:function(e,t){for(var n,r=0,i=String(e).match(/\S+/g)||[],a="boolean"==typeof t;n=i[r++];){this[(a?t:!this.hasClass(n))?"addClass":"removeClass"](n)}return this},attr:function(e,t){return 2===arguments.length?(this[0].setAttribute(e,t),this):this[0].getAttribute(e)},data:function(e,t){switch(e="data-"+xe(e||""),arguments.length){case 2:return this.attr(e,t),this;case 1:return Ce(this.attr(e));case 0:var n={};return y.forEach.call(this[0].attributes,function(t){t&&((e=t.name).indexOf("data-")||(e=$e(e.slice(5)),n[e]=Ce(t.value)))}),n}},removeData:function(e){return e="data-"+xe(e),this[0].removeAttribute(e),this},css:function(e,t){if(N.isPlainObject(e))for(var n in e)N.css(this,n,e[n]);else var r=N.css(this,e,t);return void 0!==r?r:this},position:function(){var e,t,n=this[0],r={top:0,left:0};if(n)return"fixed"===this.css("position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),"HTML"!==e[0].tagName&&(r=e.offset()),r.top+=N.css(e[0],"borderTopWidth",!0),r.left+=N.css(e[0],"borderLeftWidth",!0),r.top-=e.scrollTop(),r.left-=e.scrollLeft()),{top:t.top-r.top-N.css(n,"marginTop",!0),left:t.left-r.left-N.css(n,"marginLeft",!0)}},offsetParent:function(){for(var e=this[0].offsetParent;e&&"static"===N.css(e,"position");)e=e.offsetParent;return N(e||w)},bind:function(e,t,n){if(this[0])return N.bind(this[0],e,t,n)},unbind:function(e,t,n){return this[0]&&N.unbind(this[0],e,t,n),this},val:function(e){var t,n,r=this[0];if(r&&1===r.nodeType){var i=0===arguments.length,a=i?":get":":set",o=je[(t=r,n=t.tagName.toLowerCase(),("input"===n&&/checkbox|radio/.test(t.type)?"checked":n)+a)];if(o)var s=o(r,e);else{if(i)return(r.value||"").replace(/\r/g,"");r.value=e}}return i?s:this}}),w.dataset&&(N.fn.data=function(e,t){e=e&&$e(e);var n=this[0].dataset;switch(arguments.length){case 2:return n[e]=t,this;case 1:return Ce(t=n[e]);case 0:var r=l();for(e in n)r[e]=Ce(n[e]);return r}}),N.parseJSON=JSON.parse;var ke=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/;function Ce(e){try{if("object"==typeof e)return e;e="true"===e||"false"!==e&&("null"===e?null:+e+""===e?+e:ke.test(e)?JSON.parse(e):e)}catch(e){}return e}N.fireDom=function(e,t,n){var r=i.createEvent("Events");r.initEvent(t,!0,!0),N.mix(r,n),e.dispatchEvent(r)},N.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){N.fn[e]=function(n){var r=this[0]||{},i=function(e){return e.window&&e.document?e:9===e.nodeType&&e.defaultView}(r),a="scrollTop"===e;if(!arguments.length)return i?i[t]:r[e];i?i.scrollTo(a?i[t]:n,a?n:i[t]):r[e]=n}});var Ae=N.cssHooks=l(),Te=["","-webkit-","-moz-","-ms-"],Ne={float:"cssFloat"};N.cssNumber=A("animationIterationCount,animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom"),N.cssName=function(e,t,n){if(Ne[e])return Ne[e];t=t||w.style;for(var r=0,i=Te.length;r-1)&&(n=!0);n||(e.selectedIndex=-1)}},Oe={};["break,case,catch,continue,debugger,default,delete,do,else,false","finally,for,function,if,in,instanceof,new,null,return,switch,this","throw,true,try,typeof,var,void,while,with","abstract,boolean,byte,char,class,const,double,enum,export,extends","final,float,goto,implements,import,int,interface,long,native","package,private,protected,public,short,static,super,synchronized","throws,transient,volatile","arguments,let,yield,async,await,undefined"].join(",").replace(/\w+/g,function(e){Oe[e]=!0});var Se=/[a-z_$]/i,De=/[\s\uFEFF\xA0]/;function Le(e,t){if(t&&!Oe[t])return e.push(t),!0}function Me(e,t,n,r){for(var i,a=[],o=" = "+n+".",s=e.length;i=e[--s];){var l=i.split(".")[0];t.hasOwnProperty(l)&&(a.push(l+o+l),r.observers.push({v:t,p:i,type:N.type(t[l])}),e.splice(s,1))}return a}var Pe=/(proxy\-[a-z]+)\-[\-0-9a-f]+$/,He=new D(218),Re=new D(128);function Be(e){e=e.trim();var t=He.get(e);if(t)return t.concat();for(var n,r=function e(t,n){var r=[],i=!!n;n=n||0;for(var a="unknown",o="",s=0;s0){var t=e.replace(vt,function(e){return Array(e.length+1).join("1")}).replace(ht,"ᄢ㍄").indexOf("|");if(t>-1)return{type:"text",filters:e.slice(t).trim(),expr:e.slice(0,t)}}return{type:"text",expr:e,filters:""}}function gt(e){for(var t,n,r=[],i=0;;){if(-1===(n=e.indexOf(H,i)))break;if((t=e.slice(i,n))&&r.push({expr:t}),i=n+H.length,-1===(n=e.indexOf(R,i)))break;(t=e.slice(i,n))&&r.push(yt(t.replace(mt,""))),i=n+R.length}return(t=e.slice(i))&&r.push({expr:t}),r}function bt(e,t,n){var r=[],a=gt(e.data);if(a.length){for(var o,s=0;o=a[s++];){var l=i.createTextNode(o.expr);o.type&&(o.expr=o.expr.replace(Qe,function(){return o.oneTime=!0,""}),o.element=l,o.filters=o.filters.replace(dt,function(){return o.type="html",""}),o.pos=1e3*n+s,r.push(o)),x.appendChild(l)}e.parentNode.replaceChild(x,e),r.length&&Ke(r,t)}}var wt=function(){this.queue=[]};wt.prototype={render:function(e){if(!this.locked){this.locked=e?w.offsetHeight+10:1;var t=this;N.nextTick(function(){t.flush()})}},flush:function(){for(var e,t=0;e=this.queue[t++];)e.update&&e.update();this.locked=0,this.queue=[]}};var xt=new wt,$t=[],kt=[],Ct={__init__:k,componentWillMount:k,componentDidMount:k,childComponentDidMount:k,componentWillUnmount:k,render:function(){return null}};function At(e,t,n){if(2===arguments.length){var r=Function("o","return o."+t)(e);if(r&&"object"==typeof r)try{return r.$model}catch(e){}return r}3===arguments.length&&Function("o","v","return o."+t+" = v")(e,n)}N.components={},N.component=function(e,t){t&&(N.components[e]=N.mix({},Ct,t));for(var n,r=0;n=$t[r];r++)e===n.name&&($t.splice(r,1),r--,function(t,n,r,a){if(N.contains(i,r)&&!r.msResolved){var o=1;if(!r.getAttribute(":attr-uuid")){n.watch=n.watch||{};for(var s,l,c,u=t.vmodels.concat().pop(),f={},p=st(r,t.vmodels),d=p.uuid||T(a),h={__extra__:[]};u.$up&&u.$up.__WIDGET__===e;)u=u.$up;r.childNodes.length&&(s=r.childNodes,l=t.vmodels,c={__extra__:[]},g.call(s,0).forEach(function(e){switch(e.nodeType){case 1:var t="SLOT"===e.tagName,n=null,r=e.getAttribute("slot");if(t?n=e.name||e.getAttribute("name"):r&&(n=r),n)c[n]=c[n]||[],e.removeAttribute("slot"),t?c[n].push(e.innerHTML):c[n].push(e.outerHTML);else{var i=e.outerHTML;if(Ye(e)||/:[\w-]*=".*"/.test(i))break;B.test(i)&&(i=Fe(Ie(i),l,{}).apply(0,l)),c.__extra__.push(i)}break;case 3:(i=e.textContent.trim())&&c.__extra__.push(i)}e.parentNode.removeChild(e)}),h=c);var v=h.__extra__.join("");if(delete h.__extra__,r.text=function(){return v},p.hasOwnProperty(":disabled")){var m=p[":disabled"],y=!1;0===m.indexOf("!")&&(m=m.slice(1),y=!0),f.disabled=At(u,m),y&&(f.disabled=!f.disabled),u.$watch(m,function(e){y&&(e=!e),N.vmodels[d].disabled=e}),delete p[":disabled"]}if(p.hasOwnProperty(":loading")){var b=p[":loading"],w=!1;0===b.indexOf("!")&&(b=b.slice(1),w=!0),f.loading=At(u,b),w&&(f.loading=!f.loading),u.$watch(b,function(e){w&&(e=!e),N.vmodels[d].loading=e}),delete p[":loading"]}if(p.hasOwnProperty(":value")){var x=p[":value"],$=function(){var e=At(u,x);N.vmodels[d].value=e},k=function(){var e=this.value;e&&"object"==typeof e&&(e=e.$model),At(u,x,e)};f.value=At(u,x),n.watch.value?n.watch.value=[n.watch.value]:n.watch.value=[],n.watch["value.length"]?n.watch["value.length"]=[n.watch["value.length"]]:n.watch["value.length"]=[],n.watch["value.*"]?n.watch["value.*"]=[n.watch["value.*"]]:n.watch["value.*"]=[],u.$watch(x,$),Array.isArray(f.value)?(u.$watch(x+".*",$),u.$watch(x+".length",$),n.watch["value.*"].push(k),n.watch["value.length"].push(k)):n.watch.value.push(k),delete p[":value"]}delete p.uuid,delete p.name,delete p.isWidget,n.props=n.props||{},n.state=n.state||{},Object.assign(n.props,p),Object.assign(n.state,f);var C=!1;if(n.__init__.call(r,n.props,n.state,function(){C=!0,delete r.text}),C){n.$id=d;var{componentWillMount:A,componentDidMount:_,childComponentDidMount:E,componentWillUnmount:j,render:O}=n;delete n.__init__,delete n.componentWillMount,delete n.componentDidMount,delete n.childComponentDidMount,delete n.componentWillUnmount;var S=N(n);N.vmodels[S.$id]=S,Z(S,"__WIDGET__",e),Z(S,"$recycle",function(){for(var e in this.$events)for(var t=this.$events[e]||[],n=t.length;n--;)null!==t[n].type&&"user-watcher"!==t[n].type||t.splice(n,1)}),delete S.$mounted,u.$components.push(S),u.__WIDGET__===e&&(S.$up=u),r.msResolved=1,A.call(S),N.clearHTML(r);var D=O.call(S,h)||"";D=D.replace(/<\w+[^>]*>/g,function(e,t){return e.replace(/[\n\t\s]{1,}/g," ")}),r.innerHTML=D,Z(S,"$elem",r),r.__VM__=S,N.fireDom(r,"datasetchanged",{vm:S,childReady:1});var L=0,M=N.bind(r,"datasetchanged",function(e){if(e.childReady&&(o+=e.childReady,S.$id!==e.vm.$id&&(-1===e.childReady&&(L++,E.call(S,e.vm)),e.stopPropagation())),0===o){var n=setTimeout(function(){clearTimeout(n),r.removeAttribute("is-widget"),_.call(S)},L?Math.max(17*L,100):17);N.unbind(r,"datasetchanged",M),t.rollback=function(){try{j.call(S)}catch(e){}u.$recycle&&u.$recycle(),N.Array.remove(u.$components,S),delete N.vmodels[S.$id]},ue(t,kt),window.chrome&&r.addEventListener("DOMNodeRemovedFromDocument",function(){setTimeout(pe)})}});if(pt(r,[S]),r.childNodes.length)var P=setTimeout(function(){clearTimeout(P),N.fireDom(r,"datasetchanged",{vm:S,childReady:-1})},17);else N.fireDom(r,"datasetchanged",{vm:S,childReady:-1})}}}else N.Array.remove($t,t)}(n,Q(N.components[e]),n.element,n.name))};var Tt={};["autofocus,autoplay,async,allowTransparency,checked,controls","declare,disabled,defer,defaultChecked,defaultSelected","contentEditable,isMap,loop,multiple,noHref,noResize,noShade","open,readOnly,selected"].join(",").replace(f,function(e){Tt[e.toLowerCase()]=e});var Nt={"accept-charset":"acceptCharset",char:"ch",charoff:"chOff",class:"className",for:"htmlFor","http-equiv":"httpEquiv"};["accessKey,bgColor,cellPadding,cellSpacing,codeBase,codeType,colSpan","dateTime,defaultValue,frameBorder,longDesc,maxLength,marginWidth,marginHeight","rowSpan,tabIndex,useMap,vSpace,valueType,vAlign"].join(",").replace(f,function(e){Nt[e.toLowerCase()]=e});N.directive("attr",{init:function(e){if(e.expr=Ie(e.expr.trim()),"include"===e.type){var t=e.element;Ut(t,e),e.includeRendered=Je(t,"data-rendered",e.vmodels),e.includeLoaded=Je(t,"data-loaded",e.vmodels);var n=e.includeReplace=!!N(t).data("includeReplace");N(t).data("cache")&&(e.templateCache={}),e.start=i.createComment(":include"),e.end=i.createComment(":include-end"),n?(e.element=e.end,e._element=t,t.parentNode.insertBefore(e.start,t),t.parentNode.insertBefore(e.end,t.nextSibling)):(t.insertBefore(e.start,t.firstChild),t.appendChild(e.end))}},update:function(e){var t=this.element,n={},r=this.vmodels[0];if(e=Q(e),this.param)"object"==typeof e&&null!==e?Array.isArray(e)?n[this.param]=e:Date.isDate(e)?n[this.param]=e.toUTCString():n[this.param]=e:n[this.param]=e;else{if(!e||"object"!=typeof e||Array.isArray(e))return;if(Date.isDate(e))return;n=e}for(var a in n)if("style"!==a){if(0!==a.indexOf("@")||"function"==typeof n[a])if("href"===a||"src"===a){if(w.hasAttribute||(n[a]=n[a].replace(/&/g,"&")),t[a]=n[a],window.chrome&&"EMBED"===t.tagName){var o=t.parentNode,s=i.createComment(":src");o.replaceChild(s,t),o.replaceChild(t,s)}}else{var l=a;if(!b&&Nt[l]&&(l=Nt[l]),!1!==n[a]&&null!==n[a]&&void 0!==n[a]||(n[a]=""),"boolean"==typeof t[Tt[l]]&&(t[Tt[l]]=!!n[a],n[a]||(n[a]=!!n[a]),!1===n[a])){t.removeAttribute(l);continue}!d.test(t)&&(!(!i.namespaces||!isVML(t))||l in t.cloneNode(!1))?t[l]=n[a]:("object"==typeof n[a]?n[a]=Date.isDate(n[a])?n[a].toUTCString():JSON.stringify(n[a]):"function"==typeof n[a]&&(t[l=it+$e(l.slice(1))]=n[a].bind(r),n[a]=l),t.setAttribute(l,n[a]))}}else console.error("设置style样式, 请改用 :css指令")}});N.directive("class",{init:function(e){e.expr=e.expr.replace(/\n/g," ").replace(/\s{2,}/g," ");var t=[];if(/^\{.*\}$/.test(e.expr))/^\{\{.*\}\}$/.test(e.expr)&&(e.expr=e.expr.slice(2,-2));else{(t=e.expr.split(":"))[1]=t[1]&&t[1].trim()||"true";var n=t[0].split(/\s+/);e.expr="{"+n.map(function(e){return e+": "+t[1]}).join(", ")+"}"}if("hover"===e.type||"active"===e.type){if(!e.hasBindEvent){var r=e.element,i=N(r),a="mouseenter",o="mouseleave";if("active"===e.type){r.tabIndex=r.tabIndex||-1,a="mousedown",o="mouseup";var s=i.bind("mouseleave",function(){i.removeClass(t[0])})}}var l=i.bind(a,function(){i.addClass(t[0])}),c=i.bind(o,function(){i.removeClass(t[0])});e.rollback=function(){i.unbind("mouseleave",s),i.unbind(a,l),i.unbind(o,c)},e.hasBindEvent=!0}},update:function(e){if("class"===this.type){var t=e;if(!t||this.param)return s('class指令语法错误 %c %s="%s"',"color:#f00",this.name,this.expr);"string"==typeof t&&((t={})[e]=!0),N.isPlainObject(t)||(t=t.$model);var n=N(this.element);for(var r in t)n.toggleClass(r,!!t[r])}}}),"hover,active".replace(f,function(e){S[e]=S.class}),N.directive("css",{init:S.attr.init,update:function(e){var t=N(this.element);if(this.param)t.css(this.param,e);else{var n=e;try{for(var r in"object"==typeof e?N.isPlainObject(e)||(n=e.$model):n=new Function("return "+e)(),n)t.css(r,n[r])}catch(e){s('样式格式错误 %c %s="%s"',"color:#f00",this.name,this.expr)}}}}),N.directive("data",{priority:100,init:S.attr.init,update:function(e){var t=e;if("object"==typeof t&&null!==t)for(var n in N.isPlainObject(t)||(t=e.$model),t)this.element.setAttribute("data-"+n,t[n]);else{if(!this.param)return;this.element.setAttribute("data-"+this.param,t)}}});var _t={};N.validate=function(e,t){if(!_t[e])throw new Error("validate ["+e+"] not exists.");"function"==typeof t&&(_t[e].event=t);var n=_t[e].result;for(var r in n)if(!n[r].passed)return n[r];return!0},N.directive("rule",{priority:2010,init:function(e){e.param&&!_t[e.param]&&(_t[e.param]={event:k,result:{}}),e.target=_t[e.param]},update:function(e){var t=this,n=this.element;if(["INPUT","TEXTAREA"].includes(n.nodeName)&&!n.msBinded){this.target&&(this.target.result[n.expr]={key:n.expr});var r=this.target;N(n).bind("blur",i),this.rollback=function(){N(n).unbind("blur",i)},n.msBinded=!0,i()}function i(i){var a=n.value,o=0;(!e.require||""!==a&&null!==a||(o=10001),0===o&&e.isNumeric&&(o=isFinite(a)?0:10002),0===o&&e.isEmail&&(o=/^[\w\.\-]+@\w+([\.\-]\w+)*\.\w+$/.test(a)?0:10003),0===o&&e.isPhone&&(o=/^1[34578]\d{9}$/.test(a)?0:10004),0===o&&e.isCN&&(o=/^[\u4e00-\u9fa5]+$/.test(a)?0:10005),0===o&&e.exp&&(o=e.exp.test(a)?0:10006),0===o&&e.maxLen&&(o=a.length>e.maxLen?10011:0),0===o&&e.minLen&&(o=a.lengthe.max?10021:0),0===o&&e.hasOwnProperty("min")&&(o=a-1;break;case"select":this._value=e,n.msHasEvent?N.fireDom(n,"datasetchanged",{bubble:n.msHasEvent}):n.msHasEvent="selectDuplex"}}});function St(e){return null==e?"":e}function Dt(e,t,n,r){return t.param.replace(p,function(r){var i=N.duplexHooks[r];i&&"function"==typeof i[n]&&(e=i[n](e,t))}),e}N.duplexHooks={checked:{get:function(e,t){return!t.oldValue}},string:{get:function(e){return e},set:St},boolean:{get:function(e){return"true"===e},set:St},number:{get:function(e,t){var n=+e;return+e===n?n:0},set:St}};var Lt,Mt=[];function Pt(){for(var e=Mt.length-1;e>=0;e--){!1===(0,Mt[e])()&&Mt.splice(e,1)}Mt.length||clearInterval(Lt)}N.tick=function(e){1===Mt.push(e)&&(Lt=setInterval(Pt,60))};var Ht=k;new function(){try{var e={},t=HTMLInputElement.prototype,n=HTMLTextAreaElement.prototype;function r(t){e[this.tagName].call(this,t),!this.msFocus&&this.anotSetter&&this.anotSetter()}var i=HTMLInputElement.prototype;Object.getOwnPropertyNames(i),e.INPUT=Object.getOwnPropertyDescriptor(t,"value").set,Object.defineProperty(t,"value",{set:r}),e.TEXTAREA=Object.getOwnPropertyDescriptor(n,"value").set,Object.defineProperty(n,"value",{set:r})}catch(e){Ht=N.tick}},N.directive("effect",{priority:5,init:function(e){var t,n,r=e.expr,i=r.replace(F,function(e){return e.replace(/./g,"0")}).indexOf(":");-1===i?(t=r,n=!0):(t=r.slice(0,i),n=r.slice(i+1)),t=B.test(r)?Ie(t):Ge(t),e.expr="["+t+","+n+"]"},update:function(e){var t=e[0],n=this.element;if(n.getAttribute("data-effect-name")!==t){n.removeAttribute("data-effect-driver");var r=n.style,i=window.getComputedStyle?window.getComputedStyle(n):null,a=!1;if(i&&(Ft||It)){var o=r[qt]||i[qt];o&&"0s"!==o&&(n.setAttribute("data-effect-driver","t"),a=!0),a||(o=r[Vt]||i[Vt])&&"0s"!==o&&(n.setAttribute("data-effect-driver","a"),a=!0)}a||N.effects[t]&&(n.setAttribute("data-effect-driver","j"),a=!0),a&&n.setAttribute("data-effect-name",t)}}}),N.effects={},N.effect=function(e,t){N.effects[e]=t};var Rt,Bt,Ft=!1,It=!1,qt=N.cssName("transition-duration"),Vt=N.cssName("animation-duration");new function(){var e,t,n={TransitionEvent:"transitionend",WebKitTransitionEvent:"webkitTransitionEnd",OTransitionEvent:"oTransitionEnd",otransitionEvent:"otransitionEnd"};for(var r in n){if(window[r]){e=n[r];break}try{document.createEvent(r);e=n[r];break}catch(e){}}for(r in"string"==typeof e&&(Ft=!0,Rt=e),n={AnimationEvent:"animationend",WebKitAnimationEvent:"webkitAnimationEnd"})if(window[r]){t=n[r];break}"string"==typeof t&&(Ft=!0,Bt=t)};var Wt=[];function Ut(e,t){var n=e.getAttribute("data-effect-name");if(n){t.effectName=n,t.effectDriver=e.getAttribute("data-effect-driver");var r=+e.getAttribute("data-effect-stagger");t.effectLeaveStagger=+e.getAttribute("data-effect-leave-stagger")||r,t.effectEnterStagger=+e.getAttribute("data-effect-enter-stagger")||r,t.effectClass=e.className||NaN}}function zt(e){return e.replace(/^[\S]/g,function(e){return e.toUpperCase()})}var Gt=new wt;function Xt(){}function Yt(e,t){var n=e.callbacks[t+"Class"];return"string"==typeof n?n:"function"==typeof n?n():e.name+"-"+t}function Jt(e,t,n){var r=e.callbacks[t];r&&r.call(e,e.el,n)}Xt.prototype={contrustor:Xt,enterClass:function(){return Yt(this,"enter")},leaveClass:function(){return Yt(this,"leave")},actionFun:function(e,t,n){if(!document.hidden){var r=this,i=r.el,a="leave"===e;e=a?"leave":"enter",Jt(r,"abort"+zt(a?"enter":"leave")),Jt(r,"before"+zt(e)),a||t(i);var o=function(o){i.removeEventListener(r.cssEvent,r.cssCallback),a?(t(i),N(i).removeClass(r.cssClass)):"a"===r.driver&&N(i).removeClass(r.cssClass),!0!==o&&(Jt(r,"after"+zt(e)),n&&n(i)),r.dispose()};r.useCss?(r.cssCallback&&r.cssCallback(!0),r.cssClass=Yt(r,e),r.cssCallback=o,r.update=function(){i.addEventListener(r.cssEvent,r.cssCallback),a||"t"!==r.driver||N(i).removeClass(r.cssClass)},N(i).addClass(r.cssClass),Gt.render(!0),Gt.queue.push(r)):Jt(r,e,o)}},enter:function(e,t){this.actionFun.apply(this,["enter"].concat(N.slice(arguments)))},leave:function(e,t){this.actionFun.apply(this,["leave"].concat(N.slice(arguments)))},dispose:function(){this.update=this.cssCallback=null,Wt.unshift(this)>100&&Wt.pop()}};var Kt=function(e,t){var n=g.call(arguments,0);"function"!=typeof n[2]&&n.splice(2,0,k),"function"!=typeof n[3]&&n.splice(3,0,k);var r=n[2],i=n[3],a=function(e,t){if(!e||1!==e.nodeType)return null;if(t)var n=t.effectName,r=t.effectDriver;else n=e.getAttribute("data-effect-name"),r=e.getAttribute("data-effect-driver");if(!n||!r)return null;var i=Wt.pop()||new Xt;return i.el=e,i.driver=r,i.useCss="j"!==r,i.useCss&&(t&&N(e).addClass(t.effectClass),i.cssEvent="t"===r?Rt:Bt),i.name=n,i.callbacks=N.effects[n]||{},i}(e,n[4]);if(!a)return r(),i(),!1;a[t?"enter":"leave"](r,i)};N.mix(N.effect,{apply:Kt,append:function(e,t,n,r){return Kt(e,1,function(){t.appendChild(e)},n,r)},before:function(e,t,n,r){return Kt(e,1,function(){t.parentNode.insertBefore(e,t)},n,r)},remove:function(e,t,n,r){return Kt(e,0,function(){e.parentNode===t&&t.removeChild(e)},n,r)}}),N.directive("html",{update:function(e){var t=this.element,n=1!==t.nodeType,r=n?t.parentNode:t;if(r){if(e=null==e?"":e,3===t.nodeType){var a=T("html");r.insertBefore(i.createComment(a),t),this.element=i.createComment(a+":end"),r.replaceChild(this.element,t),t=this.element}if("object"!=typeof e)var o=N.parseHTML(String(e));else if(11===e.nodeType)o=e;else if(1===e.nodeType||e.item){var s=1===e.nodeType?e.childNodes:e.item;for(o=x.cloneNode(!0);s[0];)o.appendChild(s[0])}if(s=N.slice(o.childNodes),n){for(var l=t.nodeValue.slice(0,-4);;){var c=t.previousSibling;if(!c||8===c.nodeType&&c.nodeValue===l)break;r.removeChild(c)}r.insertBefore(o,t)}else N.clearHTML(t).appendChild(o);ft(s,this.vmodels)}}}),N.directive("text",{update:function(e){var t=this.element;if(e=null==e?"":e,3===t.nodeType)try{t.data=e}catch(e){}else t.textContent=e}}),N.directive("if",{priority:10,update:function(e){var t,n=this,r=this.element,a=n.stamp=+new Date,s=function(){a===n.stamp&&(n.recoverNode=null)};n.recoverNode&&n.recoverNode();try{if(!r.parentNode)return;t=r.parentNode}catch(e){return}if(e){function l(){r.getAttribute(n.name)&&(r.removeAttribute(n.name),lt(r,n.vmodels)),n.rollback=null}if(8===r.nodeType){var c=n.keep,u=N.effect.apply(c,1,function(){a===n.stamp&&(r.parentNode.replaceChild(c,r),r=n.element=c,c.getAttribute("_required")&&(r.required=!0,r.removeAttribute("_required")),r.querySelectorAll&&N.each(r.querySelectorAll("[_required=true]"),function(e){e.required=!0,e.removeAttribute("_required")}),l())},s);u=!1===u}u||l()}else if(1===r.nodeType){!0===r.required&&(r.required=!1,r.setAttribute("_required","true"));try{N.each(r.querySelectorAll(":required"),function(e){r.required=!1,e.setAttribute("_required","true")})}catch(e){}var f=n.element=i.createComment(":if"),p=r.nextSibling;n.recoverNode=function(){n.recoverNode=null,f.parentNode!==t&&(t.insertBefore(f,p),n.keep=r)},N.effect.apply(r,0,function(){n.recoverNode=null,a===n.stamp&&(r.parentNode.replaceChild(f,r),n.keep=r,o.appendChild(r),n.rollback=function(){r.parentNode===o&&o.removeChild(r)})},s)}}});var Zt=N.templateCache={};function Qt(e){for(var t=i.createDocumentFragment(),n=0,r=e.length;n0&&t.indexOf(")")>-1){var r=(t.match(en)||["",""])[1].trim();""!==r&&"$event"!==r||(t=t.replace(en,""))}e.expr=t},update:function(e){var t=this,n=this.element;e=function(e){return(t.getter||k).apply(t.args[0],t.args.concat(e))};var r=t.param.replace(/-\d+$/,"");if("scan"===r)e.call(n,{type:r});else if("function"==typeof t.specialBind)t.specialBind(n,e);else var i=N.bind(n,r,e);t.rollback=function(){"function"==typeof t.specialUnbind?t.specialUnbind():N.unbind(n,r,i)}}});function nn(e,t,n){for(var r,i=0;r=e[i++];)r.className===n.effectClass&&N.effect.apply(r,t,k,k,n)}function rn(e,t,n){return e?setTimeout(t,++n*e):t(),n}function an(e,t,n){for(var r=x.cloneNode(!1),i=e,a=i.nodeValue,o=t&&Math.max(+t.staggerIndex,0),s=N.slice(i.parentNode.childNodes),l=s.indexOf(i);;){var c=s[--l];if(!c||0===String(c.nodeValue).indexOf(a))break;!n&&t&&c.className===t.effectClass?(e=c,function(e){t.staggerIndex=rn(t.effectLeaveStagger,function(){N.effect.apply(e,0,k,function(){r.appendChild(e)},t)},o)}(c)):r.insertBefore(c,r.firstChild)}return r.appendChild(i),r}function on(e,t,n,r,i){var a=e.template.cloneNode(!0),o=N.slice(a.childNodes);a.appendChild(n.$anchor),i&&t.appendChild(a);n[e.param||"el"];var s={nodes:o,vmodels:[n].concat(e.vmodels),content:a};r.push(s)}function sn(e){var t=("object"===e.xtype?pn:un)(e);return(t.$anchor||(t.$anchor=e.element.cloneNode(!1))).nodeValue=e.signature,t.$outer=e.$outer,t}function ln(e,t,n){if("array"===n){e.$remove=function(){t.$repeat.removeAt(e.$index)};var r=t.param;e.$watch(r,function(n){var r=e.$index;t.$repeat[r]=n})}else{var i=t.vars[0],a=t.vars[1];e.$up.$watch(t.expr+"."+e[i],function(n){e[t.param][a]=n,e[a]=n})}}N.directive("for",{priority:90,init:function(e){var t=e.type;e.cache={},e.enterCount=0;var n=e.element;if(1===n.nodeType){var r=e.expr.split(" in ");e.expr=r.pop(),r.length&&(r=r.pop().split(/\s+/)),e.vars=r,n.removeAttribute(e.name),Ut(n,e);var a=Je(n,"data-rendered",e.vmodels),o=T(t),s=i.createComment(o+":start"),l=e.element=i.createComment(o+":end");e.signature=o,e.start=s,e.template=x.cloneNode(!1);var c=n.parentNode;if(c.replaceChild(l,n),c.insertBefore(s,l),e.template.appendChild(n),e.element=l,a)var u=N.bind(c,"datasetchanged",function(){a.apply(c,c.args),N.unbind(c,"datasetchanged",u),c.msRendered=a})}},update:function(e,t){var n=this,r=this.xtype;"array"===r?(this.vars.length?1===this.vars.length&&this.vars.unshift("$index"):this.vars.push("$index","el"),this.param=this.vars[1]):(this.param="__el__",this.vars.length?1===this.vars.length&&this.vars.push("$val"):this.vars.push("$key","$val")),this.enterCount+=1;var i=!t;if(i){n.$outer={};var a=this.vars[0],o=this.vars[1];"array"===r&&(a="$first",o="$last");for(var s,l=0;s=n.vmodels[l++];)if(s.hasOwnProperty(a)&&s.hasOwnProperty(o)){n.$outer=s;break}}var c=this.track,u="move";n.$repeat=e;var f=[],p=i&&x.cloneNode(!1),d=[],h=this.param,v=N.mix({},this.cache),m=this.element,y=c.length,g=m.parentNode,b=0;for(l=0;l10,A=m.previousSibling,T=n.start;if(C)for(;A!==T;)g.removeChild(A),A=m.previousSibling;for(l=0;lP.maxRepeatSize&&i.pop(),delete e[t]}}function hn(e,t){var n="_"+e;if(!hn[n]){var r=i.createElement(e);w.appendChild(r),t=b?getComputedStyle(r,null).display:r.currentStyle.display,w.removeChild(r),hn[n]=t}return hn[n]}N.parseDisplay=hn,N.directive("visible",{init:function(e){Ut(e.element,e)},update:function(e){var t,n=this,r=this.element,i=!this.effectName;if(!this.stamp)return t=this.stamp=+new Date,void(e?(r.style.display=n.display||"","none"===N(r).css("display")&&(r.style.display=n.display=hn(r.nodeName))):r.style.display="none");t=this.stamp=+new Date,e?N.effect.apply(r,1,function(){if(t===n.stamp){var e=r.getAttribute("data-effect-driver")||"a";i&&(r.style.display=n.display||""),"a"!==e&&"t"!==e||"none"===N(r).css("display")&&(r.style.display=n.display||hn(r.nodeName))}}):N.effect.apply(r,0,function(){t===n.stamp&&(r.style.display="none")})}});var vn=/]*>([\S\s]*?)<\/script\s*>/gim,mn=/\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g,yn=/<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi,gn={a:/\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi,img:/\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi,form:/\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi},bn=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,wn=/([^\#-~| |!])/g;function xn(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var i=isFinite(+e)?+e:0,a=isFinite(+t)?Math.abs(t):3,o=r||",",s=n||".",l="";return(l=(a?function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)}(i,a):""+Math.round(i)).split("."))[0].length>3&&(l[0]=l[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)),(l[1]||"").length>=0)%60,n=Math.floor(e/60),r=Math.floor(n/60);return n=(n%=60)<10?"0"+n:n,t=t<10?"0"+t:t,r>0?(r=r<10?"0"+r:r)+":"+n+":"+t:n+":"+t},$filter:function(e){for(var t=1,n=arguments.length;t/g,">")},currency:function(e,t,n){return(t||"¥")+xn(e,isFinite(n)?n:2)},number:xn,date:function(e,t,n){var r;if(n=void 0!==n,Date.isDate(e))r=e;else if(/[^\d]/.test(e)||(e-=0,n&&(e*=1e3)),(r=new Date(e))+""=="Invalid Date")return"Invalid Date";return r.format(t)}};let kn,Cn=[],An=function(e){for(kn=!0;e=Cn.shift();)e(N)};return"complete"===i.readyState?setTimeout(An):i.addEventListener("DOMContentLoaded",An),window.addEventListener("load",An),N.ready=function(e){kn?e(N):Cn.push(e)},window.importCss=function(t,n){t=t.replace(/^\/+/,"/"),n?t=n+t:window.LIBS_BASE_URL&&(t=window.LIBS_BASE_URL+t),e[t]||(a.insertAdjacentHTML("afterbegin",''),e[t]=1)},window.Anot=N,N}();export default _Anot; \ No newline at end of file + +const _Anot = (function() { +/********************************************************************* + * 全局变量及方法 * + **********************************************************************/ +var bindingID = 1024 + +var expose = generateID() +//http://stackoverflow.com/questions/7290086/javascript-use-strict-and-nicks-find-global-function +var DOC = window.document +var head = DOC.head //HEAD元素 +head.insertAdjacentHTML( + 'afterbegin', + '' +) +var ifGroup = head.firstChild + +function log() { + // http://stackoverflow.com/questions/8785624/how-to-safely-wrap-console-log + console.log.apply(console, arguments) +} + +/** + * Creates a new object without a prototype. This object is useful for lookup without having to + * guard against prototypically inherited properties via hasOwnProperty. + * + * Related micro-benchmarks: + * - http://jsperf.com/object-create2 + * - http://jsperf.com/proto-map-lookup/2 + * - http://jsperf.com/for-in-vs-object-keys2 + */ +function createMap() { + return Object.create(null) +} + +var subscribers = '$' + expose + +var nullObject = {} //作用类似于noop,只用于代码防御,千万不要在它上面添加属性 +var rword = /[^, ]+/g //切割字符串为一个个小块,以空格或豆号分开它们,结合replace实现字符串的forEach +var rw20g = /\w+/g +var rsvg = /^\[object SVG\w*Element\]$/ +var oproto = Object.prototype +var ohasOwn = oproto.hasOwnProperty +var serialize = oproto.toString +var ap = Array.prototype +var aslice = ap.slice +var root = DOC.documentElement +var anotFragment = DOC.createDocumentFragment() +var cinerator = DOC.createElement('div') +var class2type = { + '[object Boolean]': 'boolean', + '[object Number]': 'number', + '[object String]': 'string', + '[object Function]': 'function', + '[object Array]': 'array', + '[object Date]': 'date', + '[object RegExp]': 'regexp', + '[object Object]': 'object', + '[object Error]': 'error', + '[object AsyncFunction]': 'asyncfunction', + '[object Promise]': 'promise', + '[object Generator]': 'generator', + '[object GeneratorFunction]': 'generatorfunction' +} + +function noop() {} +function scpCompile(array) { + return Function.apply(noop, array) +} + +function oneObject(array, val) { + if (typeof array === 'string') { + array = array.match(rword) || [] + } + var result = {}, + value = val !== void 0 ? val : 1 + for (var i = 0, n = array.length; i < n; i++) { + result[array[i]] = value + } + return result +} + +function generateID(mark) { + mark = (mark && mark + '-') || 'anot-' + return mark + (++bindingID).toString(16) +} +/*-----------------部分ES6的JS实现 start---------------*/ + +// =============================== +// ========== Promise ============ +// =============================== + +if (!Promise.defer) { + Promise.defer = function() { + let obj = {} + obj.promise = new Promise((resolve, reject) => { + obj.resolve = resolve + obj.reject = reject + }) + return obj + } +} + +//类似于Array 的splice方法 +if (!String.prototype.splice) { + Object.defineProperty(String.prototype, 'splice', { + value: function(start, len, fill) { + let length = this.length + let argLen = arguments.length + + fill = fill === undefined ? '' : fill + + if (argLen < 1) { + return this + } + + //处理负数 + if (start < 0) { + if (Math.abs(start) >= length) { + start = 0 + } else { + start = length + start + } + } + + if (argLen === 1) { + return this.slice(0, start) + } else { + len -= 0 + + let strl = this.slice(0, start) + let strr = this.slice(start + len) + + return strl + fill + strr + } + }, + enumerable: false + }) +} + +if (!Date.prototype.getFullWeek) { + //获取当天是本年度第几周 + Object.defineProperty(Date.prototype, 'getFullWeek', { + value: function() { + let thisYear = this.getFullYear() + let that = new Date(thisYear, 0, 1) + let firstDay = that.getDay() || 1 + let numsOfToday = (this - that) / 86400000 + return Math.ceil((numsOfToday + firstDay) / 7) + }, + enumerable: false + }) + + //获取当天是本月第几周 + Object.defineProperty(Date.prototype, 'getWeek', { + value: function() { + let today = this.getDate() + let thisMonth = this.getMonth() + let thisYear = this.getFullYear() + let firstDay = new Date(thisYear, thisMonth, 1).getDay() + return Math.ceil((today + firstDay) / 7) + }, + enumerable: false + }) +} + +if (!Date.isDate) { + Object.defineProperty(Date, 'isDate', { + value: function(obj) { + return typeof obj === 'object' && obj.getTime ? true : false + }, + enumerable: false + }) +} + +//时间格式化 +if (!Date.prototype.format) { + Object.defineProperty(Date.prototype, 'format', { + value: function(str) { + str = str || 'Y-m-d H:i:s' + let week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + let dt = { + fullyear: this.getFullYear(), + year: this.getYear(), + fullweek: this.getFullWeek(), + week: this.getWeek(), + month: this.getMonth() + 1, + date: this.getDate(), + day: week[this.getDay()], + hours: this.getHours(), + minutes: this.getMinutes(), + seconds: this.getSeconds() + } + let re + + dt.g = dt.hours > 12 ? dt.hours - 12 : dt.hours + + re = { + Y: dt.fullyear, + y: dt.year, + m: dt.month < 10 ? '0' + dt.month : dt.month, + n: dt.month, + d: dt.date < 10 ? '0' + dt.date : dt.date, + j: dt.date, + H: dt.hours < 10 ? '0' + dt.hours : dt.hours, + h: dt.g < 10 ? '0' + dt.g : dt.g, + G: dt.hours, + g: dt.g, + i: dt.minutes < 10 ? '0' + dt.minutes : dt.minutes, + s: dt.seconds < 10 ? '0' + dt.seconds : dt.seconds, + W: dt.fullweek, + w: dt.week, + D: dt.day + } + + for (let i in re) { + str = str.replace(new RegExp(i, 'g'), re[i]) + } + return str + }, + enumerable: false + }) +} +/*-----------------部分ES6的JS实现 ending---------------*/ +let Anot = function(el) { + //创建jQuery式的无new 实例化结构 + return new Anot.init(el) +} + +/*视浏览器情况采用最快的异步回调*/ +Anot.nextTick = new function() { + // jshint ignore:line + let tickImmediate = window.setImmediate + let tickObserver = window.MutationObserver + if (tickImmediate) { + return tickImmediate.bind(window) + } + + let queue = [] + function callback() { + let n = queue.length + for (let i = 0; i < n; i++) { + queue[i]() + } + queue = queue.slice(n) + } + + if (tickObserver) { + let node = document.createTextNode('anot') + new tickObserver(callback).observe(node, { characterData: true }) // jshint ignore:line + let bool = false + return function(fn) { + queue.push(fn) + bool = !bool + node.data = bool + } + } + + return function(fn) { + setTimeout(fn, 4) + } +}() // jshint ignore:line + +/********************************************************************* + * Anot的静态方法定义区 * + **********************************************************************/ + +Anot.type = function(obj) { + //取得目标的类型 + if (obj == null) { + return String(obj) + } + // 早期的webkit内核浏览器实现了已废弃的ecma262v4标准,可以将正则字面量当作函数使用,因此typeof在判定正则时会返回function + return typeof obj === 'object' || typeof obj === 'function' + ? class2type[serialize.call(obj)] || 'object' + : typeof obj +} + +Anot.PropsTypes = function(type) { + this.type = 'PropsTypes' + this.checkType = type +} + +Anot.PropsTypes.prototype = { + toString: function() { + return '' + }, + check: function(val) { + this.result = Anot.type(val) + return this.result === this.checkType + }, + call: function() { + return this.toString() + } +} + +Anot.PropsTypes.isString = function() { + return new this('string') +} + +Anot.PropsTypes.isNumber = function() { + return new this('number') +} + +Anot.PropsTypes.isFunction = function() { + return new this('function') +} + +Anot.PropsTypes.isArray = function() { + return new this('array') +} + +Anot.PropsTypes.isObject = function() { + return new this('object') +} + +Anot.PropsTypes.isBoolean = function() { + return new this('boolean') +} + +/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/ +Anot.isPlainObject = function(obj) { + // 简单的 typeof obj === "object"检测,会致使用isPlainObject(window)在opera下通不过 + return ( + serialize.call(obj) === '[object Object]' && + Object.getPrototypeOf(obj) === oproto + ) +} + +let VMODELS = (Anot.vmodels = {}) //所有vmodel都储存在这里 +Anot.init = function(source) { + if (Anot.isPlainObject(source)) { + let $id = source.$id + let vm = null + if (!$id) { + log('warning: vm必须指定id') + } + vm = modelFactory(Object.assign({ props: {} }, source)) + vm.$id = $id + VMODELS[$id] = vm + + Anot.nextTick(function() { + let $elem = document.querySelector('[anot=' + vm.$id + ']') + if ($elem) { + if ($elem === DOC.body) { + scanTag($elem, []) + } else { + let _parent = $elem + while ((_parent = _parent.parentNode)) { + if (_parent.__VM__) { + break + } + } + scanTag($elem.parentNode, _parent ? [_parent.__VM__] : []) + } + } + }) + + return vm + } else { + this[0] = this.element = source + } +} +Anot.fn = Anot.prototype = Anot.init.prototype + +//与jQuery.extend方法,可用于浅拷贝,深拷贝 +Anot.mix = Anot.fn.mix = function() { + let options, + name, + src, + copy, + copyIsArray, + clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false + + // 如果第一个参数为布尔,判定是否深拷贝 + if (typeof target === 'boolean') { + deep = target + target = arguments[1] || {} + i++ + } + + //确保接受方为一个复杂的数据类型 + if (typeof target !== 'object' && Anot.type(target) !== 'function') { + target = {} + } + + //如果只有一个参数,那么新成员添加于mix所在的对象上 + if (i === length) { + target = this + i-- + } + + for (; i < length; i++) { + //只处理非空参数 + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name] + copy = options[name] + // 防止环引用 + if (target === copy) { + continue + } + if ( + deep && + copy && + (Anot.isPlainObject(copy) || (copyIsArray = Array.isArray(copy))) + ) { + if (copyIsArray) { + copyIsArray = false + clone = src && Array.isArray(src) ? src : [] + } else { + clone = src && Anot.isPlainObject(src) ? src : {} + } + + target[name] = Anot.mix(deep, clone, copy) + } else if (copy !== void 0) { + target[name] = copy + } + } + } + } + return target +} + +function cacheStore(tpye, key, val) { + if (this.type(key) === 'object') { + for (let i in key) { + window[tpye].setItem(i, key[i]) + } + return + } + switch (arguments.length) { + case 2: + return window[tpye].getItem(key) + case 3: + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { + window[tpye].removeItem(key) + return + } + if (this.type(val) !== 'object' && this.type(val) !== 'array') { + window[tpye].setItem(key, val.toString()) + } else { + window[tpye].setItem(key, JSON.stringify(val)) + } + break + } +} + +/*判定是否类数组,如节点集合,纯数组,arguments与拥有非负整数的length属性的纯JS对象*/ +function isArrayLike(obj) { + if (obj && typeof obj === 'object') { + let n = obj.length, + str = serialize.call(obj) + if (/(Array|List|Collection|Map|Arguments)\]$/.test(str)) { + return true + } else if (str === '[object Object]' && n === n >>> 0) { + return true //由于ecma262v5能修改对象属性的enumerable,因此不能用propertyIsEnumerable来判定了 + } + } + return false +} + +Anot.mix({ + rword: rword, + subscribers: subscribers, + version: '1.0.0', + log: log, + ui: {}, //仅用于存放组件版本信息等 + slice: function(nodes, start, end) { + return aslice.call(nodes, start, end) + }, + noop: noop, + /*如果不用Error对象封装一下,str在控制台下可能会乱码*/ + error: function(str, e) { + throw new (e || Error)(str) // jshint ignore:line + }, + /* Anot.range(10) + => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + Anot.range(1, 11) + => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + Anot.range(0, 30, 5) + => [0, 5, 10, 15, 20, 25] + Anot.range(0, -10, -1) + => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] + Anot.range(0) + => []*/ + range: function(start, end, step) { + // 用于生成整数数组 + step || (step = 1) + if (end == null) { + end = start || 0 + start = 0 + } + let index = -1, + length = Math.max(0, Math.ceil((end - start) / step)), + result = new Array(length) + while (++index < length) { + result[index] = start + start += step + } + return result + }, + deepCopy: toJson, + eventHooks: {}, + /*绑定事件*/ + bind: function(el, type, fn, phase) { + let hooks = Anot.eventHooks + type = type.split(',') + Anot.each(type, function(i, t) { + t = t.trim() + let hook = hooks[t] + if (typeof hook === 'object') { + type = hook.type || type + phase = hook.phase || !!phase + fn = hook.fix ? hook.fix(el, fn) : fn + } + el.addEventListener(t, fn, phase) + }) + return fn + }, + /*卸载事件*/ + unbind: function(el, type, fn, phase) { + let hooks = Anot.eventHooks + type = type.split(',') + fn = fn || noop + Anot.each(type, function(i, t) { + t = t.trim() + let hook = hooks[t] + if (typeof hook === 'object') { + type = hook.type || type + phase = hook.phase || !!phase + } + el.removeEventListener(t, fn, phase) + }) + }, + /*读写删除元素节点的样式*/ + css: function(node, name, value) { + if (node instanceof Anot) { + node = node[0] + } + var prop = /[_-]/.test(name) ? camelize(name) : name + var fn + + name = Anot.cssName(prop) || prop + if (value === void 0 || typeof value === 'boolean') { + //获取样式 + fn = cssHooks[prop + ':get'] || cssHooks['@:get'] + if (name === 'background') { + name = 'backgroundColor' + } + var val = fn(node, name) + return value === true ? +val || 0 : val + } else if (value === '') { + //请除样式 + node.style[name] = '' + } else { + //设置样式 + if (value == null || value !== value) { + return + } + if (isFinite(value) && !Anot.cssNumber[prop]) { + value += 'px' + } + fn = cssHooks[prop + ':set'] || cssHooks['@:set'] + fn(node, name, value) + } + }, + /*遍历数组与对象,回调的第一个参数为索引或键名,第二个或元素或键值*/ + each: function(obj, fn) { + if (obj) { + //排除null, undefined + let i = 0 + if (isArrayLike(obj)) { + for (let n = obj.length; i < n; i++) { + if (fn(i, obj[i]) === false) break + } + } else { + for (i in obj) { + if (obj.hasOwnProperty(i) && fn(i, obj[i]) === false) { + break + } + } + } + } + }, + Array: { + /*只有当前数组不存在此元素时只添加它*/ + ensure: function(target, item) { + if (target.indexOf(item) === -1) { + return target.push(item) + } + }, + /*移除数组中指定位置的元素,返回布尔表示成功与否*/ + removeAt: function(target, index) { + return !!target.splice(index, 1).length + }, + /*移除数组中第一个匹配传参的那个元素,返回布尔表示成功与否*/ + remove: function(target, item) { + let index = target.indexOf(item) + if (~index) return Anot.Array.removeAt(target, index) + return false + } + }, + /** + * [ls localStorage操作] + * @param {[type]} key [键名] + * @param {[type]} val [键值,为空时删除] + * @return + */ + ls: function() { + let args = aslice.call(arguments, 0) + args.unshift('localStorage') + return cacheStore.apply(this, args) + }, + ss: function() { + let args = aslice.call(arguments, 0) + args.unshift('sessionStorage') + return cacheStore.apply(this, args) + }, + /** + * [cookie cookie 操作 ] + * @param key [cookie名] + * @param val [cookie值] + * @param {[json]} opt [有效期,域名,路径等] + * @return {[boolean]} [读取时返回对应的值,写入时返回true] + */ + cookie: function(key, val, opt) { + if (arguments.length > 1) { + if (!key) { + return + } + + //设置默认的参数 + opt = opt || {} + opt = Object.assign( + { + expires: '', + path: '/', + domain: document.domain, + secure: '' + }, + opt + ) + + if ((this.type(val) == 'string' && val.trim() === '') || val === null) { + document.cookie = + encodeURIComponent(key) + + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=' + + opt.domain + + '; path=' + + opt.path + return true + } + if (opt.expires) { + switch (opt.expires.constructor) { + case Number: + opt.expires = + opt.expires === Infinity + ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' + : '; max-age=' + opt.expires + break + case String: + opt.expires = '; expires=' + opt.expires + break + case Date: + opt.expires = '; expires=' + opt.expires.toUTCString() + break + } + } + document.cookie = + encodeURIComponent(key) + + '=' + + encodeURIComponent(val) + + opt.expires + + '; domain=' + + opt.domain + + '; path=' + + opt.path + + '; ' + + opt.secure + return true + } else { + if (!key) { + return document.cookie + } + return ( + decodeURIComponent( + document.cookie.replace( + new RegExp( + '(?:(?:^|.*;)\\s*' + + encodeURIComponent(key).replace(/[\-\.\+\*]/g, '\\$&') + + '\\s*\\=\\s*([^;]*).*$)|^.*$' + ), + '$1' + ) + ) || null + ) + } + }, + //获取url的参数 + search: function(key) { + key += '' + let uri = location.search + + if (!key || !uri) { + return null + } + uri = decodeURIComponent(uri) + + uri = uri.slice(1) + uri = uri.split('&') + + let obj = {} + for (let i = 0, item; (item = uri[i++]); ) { + let tmp = item.split('=') + tmp[1] = tmp.length < 2 ? null : tmp[1] + tmp[1] = tmp[1] + if (obj.hasOwnProperty(tmp[0])) { + if (typeof obj[tmp[0]] === 'object') { + obj[tmp[0]].push(tmp[1]) + } else { + obj[tmp[0]] = [obj[tmp[0]]] + obj[tmp[0]].push(tmp[1]) + } + } else { + obj[tmp[0]] = tmp[1] + } + } + return obj.hasOwnProperty(key) ? obj[key] : null + }, + //复制文本到粘贴板 + copy: function(txt) { + if (!DOC.queryCommandSupported || !DOC.queryCommandSupported('copy')) { + return log('该浏览器不支持复制到粘贴板') + } + + let ta = DOC.createElement('textarea') + ta.textContent = txt + ta.style.position = 'fixed' + ta.style.bottom = '-1000px' + DOC.body.appendChild(ta) + ta.select() + try { + DOC.execCommand('copy') + } catch (err) { + log('复制到粘贴板失败', err) + } + DOC.body.removeChild(ta) + } +}) + +let bindingHandlers = (Anot.bindingHandlers = {}) +let bindingExecutors = (Anot.bindingExecutors = {}) + +let directives = (Anot.directives = {}) +Anot.directive = function(name, obj) { + bindingHandlers[name] = obj.init = obj.init || noop + bindingExecutors[name] = obj.update = obj.update || noop + return (directives[name] = obj) +} +// https://github.com/rsms/js-lru +let Cache = new function() { + // jshint ignore:line + function LRU(maxLength) { + this.size = 0 + this.limit = maxLength + this.head = this.tail = void 0 + this._keymap = {} + } + + let p = LRU.prototype + + p.put = function(key, value) { + let entry = { + key: key, + value: value + } + this._keymap[key] = entry + if (this.tail) { + this.tail.newer = entry + entry.older = this.tail + } else { + this.head = entry + } + this.tail = entry + if (this.size === this.limit) { + this.shift() + } else { + this.size++ + } + return value + } + + p.shift = function() { + let entry = this.head + if (entry) { + this.head = this.head.newer + this.head.older = entry.newer = entry.older = this._keymap[ + entry.key + ] = void 0 + delete this._keymap[entry.key] //#1029 + } + } + p.get = function(key) { + let entry = this._keymap[key] + if (entry === void 0) return + if (entry === this.tail) { + return entry.value + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) { + this.head = entry.newer + } + entry.newer.older = entry.older // C <-- E. + } + if (entry.older) { + entry.older.newer = entry.newer // C. --> E + } + entry.newer = void 0 // D --x + entry.older = this.tail // D. --> E + if (this.tail) { + this.tail.newer = entry // E. <-- D + } + this.tail = entry + return entry.value + } + return LRU +}() // jshint ignore:line +/********************************************************************* + * DOM 底层补丁 * + **********************************************************************/ + +//safari5+是把contains方法放在Element.prototype上而不是Node.prototype +if (!DOC.contains) { + Node.prototype.contains = function(arg) { + return !!(this.compareDocumentPosition(arg) & 16) + } +} +Anot.contains = function(root, el) { + try { + while ((el = el.parentNode)) if (el === root) return true + return false + } catch (e) { + return false + } +} + +//========================= event binding ==================== + +let eventHooks = Anot.eventHooks + +//针对firefox, chrome修正mouseenter, mouseleave(chrome30+) +if (!('onmouseenter' in root)) { + Anot.each( + { + mouseenter: 'mouseover', + mouseleave: 'mouseout' + }, + function(origType, fixType) { + eventHooks[origType] = { + type: fixType, + fix: function(elem, fn) { + return function(e) { + let t = e.relatedTarget + if (!t || (t !== elem && !(elem.compareDocumentPosition(t) & 16))) { + delete e.type + e.type = origType + return fn.call(elem, e) + } + } + } + } + } + ) +} + +//针对IE9+, w3c修正animationend +Anot.each( + { + AnimationEvent: 'animationend', + WebKitAnimationEvent: 'webkitAnimationEnd' + }, + function(construct, fixType) { + if (window[construct] && !eventHooks.animationend) { + eventHooks.animationend = { + type: fixType + } + } + } +) + +if (DOC.onmousewheel === void 0) { + /* IE6-11 chrome mousewheel wheelDetla 下 -120 上 120 + firefox DOMMouseScroll detail 下3 上-3 + firefox wheel detlaY 下3 上-3 + IE9-11 wheel deltaY 下40 上-40 + chrome wheel deltaY 下100 上-100 */ + eventHooks.mousewheel = { + type: 'wheel', + fix: function(elem, fn) { + return function(e) { + e.wheelDeltaY = e.wheelDelta = e.deltaY > 0 ? -120 : 120 + e.wheelDeltaX = 0 + Object.defineProperty(e, 'type', { + value: 'mousewheel' + }) + fn.call(elem, e) + } + } + } +} +/********************************************************************* + * 配置系统 * + **********************************************************************/ + +function kernel(settings) { + for (var p in settings) { + if (!ohasOwn.call(settings, p)) continue + var val = settings[p] + if (typeof kernel.plugins[p] === 'function') { + kernel.plugins[p](val) + } else if (typeof kernel[p] === 'object') { + Anot.mix(kernel[p], val) + } else { + kernel[p] = val + } + } + return this +} +Anot.config = kernel + +var openTag, + closeTag, + rexpr, + rexprg, + rbind, + rregexp = /[-.*+?^${}()|[\]\/\\]/g + +function escapeRegExp(target) { + //http://stevenlevithan.com/regex/xregexp/ + //将字符串安全格式化为正则表达式的源码 + return (target + '').replace(rregexp, '\\$&') +} + +var plugins = { + interpolate: function(array) { + openTag = array[0] + closeTag = array[1] + if (openTag === closeTag) { + throw new SyntaxError('openTag!==closeTag') + var test = openTag + 'test' + closeTag + cinerator.innerHTML = test + if ( + cinerator.innerHTML !== test && + cinerator.innerHTML.indexOf('<') > -1 + ) { + throw new SyntaxError('此定界符不合法') + } + cinerator.innerHTML = '' + } + kernel.openTag = openTag + kernel.closeTag = closeTag + var o = escapeRegExp(openTag), + c = escapeRegExp(closeTag) + rexpr = new RegExp(o + '([\\s\\S]*)' + c) + rexprg = new RegExp(o + '([\\s\\S]*)' + c, 'g') + rbind = new RegExp(o + '[\\s\\S]*' + c + '|\\s:') //此处有疑问 + } +} +kernel.plugins = plugins +kernel.plugins['interpolate'](['{{', '}}']) + +kernel.async = true +kernel.paths = {} +kernel.shim = {} +kernel.maxRepeatSize = 100 +function $watch(expr, binding) { + var $events = this.$events || (this.$events = {}), + queue = $events[expr] || ($events[expr] = []) + + if (typeof binding === 'function') { + var backup = binding + backup.uuid = '_' + ++bindingID + binding = { + element: root, + type: 'user-watcher', + handler: noop, + vmodels: [this], + expr: expr, + uuid: backup.uuid + } + binding.wildcard = /\*/.test(expr) + } + + if (!binding.update) { + if (/\w\.*\B/.test(expr) || expr === '*') { + binding.getter = noop + var host = this + binding.update = function() { + var args = this.fireArgs || [] + if (args[2]) binding.handler.apply(host, args) + delete this.fireArgs + } + queue.sync = true + Anot.Array.ensure(queue, binding) + } else { + Anot.injectBinding(binding) + } + if (backup) { + binding.handler = backup + } + } else if (!binding.oneTime) { + Anot.Array.ensure(queue, binding) + } + + return function() { + binding.update = binding.getter = binding.handler = noop + binding.element = DOC.createElement('a') + } +} + +function $emit(key, args) { + var event = this.$events + var _parent = null + if (event && event[key]) { + if (args) { + args[2] = key + } + var arr = event[key] + notifySubscribers(arr, args) + if (args && event['*'] && !/\./.test(key)) { + for (var sub, k = 0; (sub = event['*'][k++]); ) { + try { + sub.handler.apply(this, args) + } catch (e) {} + } + } + _parent = this.$up + if (_parent) { + if (this.$pathname) { + $emit.call(_parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡 + } + $emit.call(_parent, '*.' + key, args) //以模糊的值往上冒泡 + } + } else { + _parent = this.$up + if (this.$ups) { + for (var i in this.$ups) { + $emit.call(this.$ups[i], i + '.' + key, args) //以确切的值往上冒泡 + } + return + } + if (_parent) { + var p = this.$pathname + if (p === '') p = '*' + var path = p + '.' + key + arr = path.split('.') + + args = (args && args.concat([path, key])) || [path, key] + + if (arr.indexOf('*') === -1) { + $emit.call(_parent, path, args) //以确切的值往上冒泡 + arr[1] = '*' + $emit.call(_parent, arr.join('.'), args) //以模糊的值往上冒泡 + } else { + $emit.call(_parent, path, args) //以确切的值往上冒泡 + } + } + } +} + +function collectDependency(el, key) { + do { + if (el.$watch) { + var e = el.$events || (el.$events = {}) + var array = e[key] || (e[key] = []) + dependencyDetection.collectDependency(array) + return + } + el = el.$up + if (el) { + key = el.$pathname + '.' + key + } else { + break + } + } while (true) +} + +function notifySubscribers(subs, args) { + if (!subs) return + if (new Date() - beginTime > 444 && typeof subs[0] === 'object') { + rejectDisposeQueue() + } + var users = [], + renders = [] + for (var i = 0, sub; (sub = subs[i++]); ) { + if (sub.type === 'user-watcher') { + users.push(sub) + } else { + renders.push(sub) + } + } + if (kernel.async) { + buffer.render() //1 + for (i = 0; (sub = renders[i++]); ) { + if (sub.update) { + sub.uuid = sub.uuid || '_' + ++bindingID + var uuid = sub.uuid + if (!buffer.queue[uuid]) { + buffer.queue[uuid] = '__' + buffer.queue.push(sub) + } + } + } + } else { + for (i = 0; (sub = renders[i++]); ) { + if (sub.update) { + sub.update() //最小化刷新DOM树 + } + } + } + for (i = 0; (sub = users[i++]); ) { + if ((args && args[2] === sub.expr) || sub.wildcard) { + sub.fireArgs = args + } + sub.update() + } +} + +//一些不需要被监听的属性 +var kernelProps = oneObject( + '$id,$watch,$fire,$events,$model,$active,$pathname,$up,$ups,$track,$accessors' +) + +//如果浏览器不支持ecma262v5的Object.defineProperties或者存在BUG,比如IE8 +//标准浏览器使用__defineGetter__, __defineSetter__实现 + +function modelFactory(source, options) { + options = options || {} + options.watch = true + return observeObject(source, options) +} + +function isSkip(k) { + return k.charAt(0) === '$' || k.slice(0, 2) === '__' || kernelProps[k] +} + +//监听对象属性值的变化(注意,数组元素不是数组的属性),通过对劫持当前对象的访问器实现 +//监听对象或数组的结构变化, 对对象的键值对进行增删重排, 或对数组的进行增删重排,都属于这范畴 +// 通过比较前后代理VM顺序实现 +function Component() {} + +function observeObject(source, options) { + if ( + !source || + (source.$id && source.$accessors) || + (source.nodeName && source.nodeType > 0) + ) { + return source + } + //source为原对象,不能是元素节点或null + //options,可选,配置对象,里面有old, force, watch这三个属性 + options = options || nullObject + var force = options.force || nullObject + var old = options.old + var oldAccessors = (old && old.$accessors) || nullObject + var $vmodel = new Component() //要返回的对象, 它在IE6-8下可能被偷龙转凤 + var accessors = {} //监控属性 + var hasOwn = {} + var skip = [] + var simple = [] + var userSkip = {} + // 提取 source中的配置项, 并删除相应字段 + var state = source.state + var computed = source.computed + var methods = source.methods + var props = source.props + var watches = source.watch + var mounted = source.mounted + + delete source.state + delete source.computed + delete source.methods + delete source.props + delete source.watch + + if (source.skip) { + userSkip = oneObject(source.skip) + delete source.skip + } + + // 基础数据 + if (state) { + if (source.$id) { + // 直接删除名为props的 字段, 对于主VM对象, props将作为保留关键字 + // 下面的计算属性,方法等, 作同样的逻辑处理 + delete state.props + } + for (name in state) { + var value = state[name] + if (!kernelProps[name]) { + hasOwn[name] = true + } + if ( + typeof value === 'function' || + (value && value.nodeName && value.nodeType > 0) || + (!force[name] && (isSkip(name) || userSkip[name])) + ) { + skip.push(name) + } else if (isComputed(value)) { + log('warning:计算属性建议放在[computed]对象中统一定义') + // 转给下一步处理 + computed[name] = value + } else { + simple.push(name) + if (oldAccessors[name]) { + accessors[name] = oldAccessors[name] + } else { + accessors[name] = makeGetSet(name, value) + } + } + } + } + + //处理计算属性 + if (computed) { + delete computed.props + for (var name in computed) { + hasOwn[name] = true + ;(function(key, value) { + var old + if (typeof value === 'function') { + value = { get: value, set: noop } + } + if (typeof value.set !== 'function') { + value.set = noop + } + accessors[key] = { + get: function() { + return (old = value.get.call(this)) + }, + set: function(x) { + var older = old, + newer + value.set.call(this, x) + newer = this[key] + if (this.$fire && newer !== older) { + this.$fire(key, newer, older) + } + }, + enumerable: true, + configurable: true + } + })(name, computed[name]) // jshint ignore:line + } + } + + // 方法 + if (methods) { + delete methods.props + for (var name in methods) { + hasOwn[name] = true + skip.push(name) + } + } + + if (props) { + hideProperty($vmodel, 'props', {}) + hasOwn.props = !!source.$id + for (var name in props) { + $vmodel.props[name] = props[name] + } + } + + Object.assign(source, state, methods) + + accessors['$model'] = $modelDescriptor + $vmodel = Object.defineProperties($vmodel, accessors, source) + function trackBy(name) { + return hasOwn[name] === true + } + skip.forEach(function(name) { + $vmodel[name] = source[name] + }) + + // hideProperty($vmodel, '$ups', null) + hideProperty($vmodel, '$id', 'anonymous') + hideProperty($vmodel, '$up', old ? old.$up : null) + hideProperty($vmodel, '$track', Object.keys(hasOwn)) + hideProperty($vmodel, '$active', false) + hideProperty($vmodel, '$pathname', old ? old.$pathname : '') + hideProperty($vmodel, '$accessors', accessors) + hideProperty($vmodel, '$events', {}) + hideProperty($vmodel, '$refs', {}) + hideProperty($vmodel, '$children', []) + hideProperty($vmodel, 'hasOwnProperty', trackBy) + hideProperty($vmodel, '$mounted', mounted) + if (options.watch) { + hideProperty($vmodel, '$watch', function() { + return $watch.apply($vmodel, arguments) + }) + hideProperty($vmodel, '$fire', function(path, a) { + if (path.indexOf('all!') === 0) { + var ee = path.slice(4) + for (var i in Anot.vmodels) { + var v = Anot.vmodels[i] + v.$fire && v.$fire.apply(v, [ee, a]) + } + } else if (path.indexOf('child!') === 0) { + var ee = 'props.' + path.slice(6) + for (var i in $vmodel.$children) { + var v = $vmodel.$children[i] + v.$fire && v.$fire.apply(v, [ee, a]) + } + } else { + $emit.call($vmodel, path, [a]) + } + }) + } + + simple.forEach(function(name) { + var oldVal = old && old[name] + var val = ($vmodel[name] = state[name]) + if (val && typeof val === 'object' && !Date.isDate(val)) { + val.$up = $vmodel + val.$pathname = name + } + $emit.call($vmodel, name, [val, oldVal]) + }) + + // 属性的监听, 必须放在上一步$emit后处理, 否则会在初始时就已经触发一次 监听回调 + if (watches) { + delete watches.props + for (var key in watches) { + if (Array.isArray(watches[key])) { + var tmp + while ((tmp = watches[key].pop())) { + $watch.call($vmodel, key, tmp) + } + } else { + $watch.call($vmodel, key, watches[key]) + } + } + } + + $vmodel.$active = true + + if ($vmodel.$id !== 'anonymous') { + if (old && old.$up && old.$up.$children) { + old.$up.$children.push($vmodel) + } + } + + return $vmodel +} + +/* + 新的VM拥有如下私有属性 + $id: vm.id + $events: 放置$watch回调与绑定对象 + $watch: 增强版$watch + $fire: 触发$watch回调 + $track:一个数组,里面包含用户定义的所有键名 + $active:boolean,false时防止依赖收集 + $model:返回一个纯净的JS对象 + $accessors:放置所有读写器的数据描述对象 + $pathname:返回此对象在上级对象的名字,注意,数组元素的$pathname为空字符串 + ============================= + skip:用于指定不可监听的属性,但VM生成是没有此属性的 + */ +function isComputed(val) { + //speed up! + if (val && typeof val === 'object') { + for (var i in val) { + if (i !== 'get' && i !== 'set') { + return false + } + } + return typeof val.get === 'function' + } +} +function makeGetSet(key, value) { + var childVm, + value = NaN + return { + get: function() { + if (this.$active) { + collectDependency(this, key) + } + return value + }, + set: function(newVal) { + if (value === newVal) return + var oldValue = value + childVm = observe(newVal, value) + if (childVm) { + value = childVm + } else { + childVm = void 0 + value = newVal + } + + if (Object(childVm) === childVm) { + childVm.$pathname = key + childVm.$up = this + } + if (this.$active) { + $emit.call(this, key, [value, oldValue]) + } + }, + enumerable: true, + configurable: true + } +} + +function observe(obj, old, hasReturn, watch) { + if (Array.isArray(obj)) { + return observeArray(obj, old, watch) + } else if (Anot.isPlainObject(obj)) { + if (old && typeof old === 'object') { + var keys = Object.keys(obj) + var keys2 = Object.keys(old) + if (keys.join(';') === keys2.join(';')) { + for (var i in obj) { + if (obj.hasOwnProperty(i)) { + old[i] = obj[i] + } + } + return old + } + old.$active = false + } + return observeObject( + { state: obj }, + { + old: old, + watch: watch + } + ) + } + if (hasReturn) { + return obj + } +} + +function observeArray(array, old, watch) { + if (old && old.splice) { + var args = [0, old.length].concat(array) + old.splice.apply(old, args) + return old + } else { + for (var i in newProto) { + array[i] = newProto[i] + } + hideProperty(array, '$up', null) + hideProperty(array, '$pathname', '') + hideProperty(array, '$track', createTrack(array.length)) + + array._ = observeObject( + { + state: { length: NaN } + }, + { + watch: true + } + ) + array._.length = array.length + array._.$watch('length', function(a, b) { + $emit.call(array.$up, array.$pathname + '.length', [a, b]) + }) + if (watch) { + hideProperty(array, '$watch', function() { + return $watch.apply(array, arguments) + }) + } + + Object.defineProperty(array, '$model', $modelDescriptor) + + for (var j = 0, n = array.length; j < n; j++) { + var el = (array[j] = observe(array[j], 0, 1, 1)) + if (Object(el) === el) { + //#1077 + el.$up = array + } + } + + return array + } +} + +function hideProperty(host, name, value) { + Object.defineProperty(host, name, { + value: value, + writable: true, + enumerable: false, + configurable: true + }) +} +Anot.hideProperty = hideProperty + +function toJson(val) { + var xtype = Anot.type(val) + if (xtype === 'array') { + var array = [] + for (var i = 0; i < val.length; i++) { + array[i] = toJson(val[i]) + } + return array + } else if (xtype === 'object') { + var obj = {} + for (i in val) { + if (val.hasOwnProperty(i)) { + var value = val[i] + obj[i] = value && value.nodeType ? value : toJson(value) + } + } + return obj + } + return val +} + +var $modelDescriptor = { + get: function() { + return toJson(this) + }, + set: noop, + enumerable: false, + configurable: true +} +/********************************************************************* + * 监控数组(:for配合使用) * + **********************************************************************/ + +var arrayMethods = ['push', 'pop', 'shift', 'unshift', 'splice'] +var arrayProto = Array.prototype +var newProto = { + notify: function() { + $emit.call(this.$up, this.$pathname) + }, + set: function(index, val) { + index = index >>> 0 + if (index > this.length) { + throw Error(index + 'set方法的第一个参数不能大于原数组长度') + } + if (this[index] !== val) { + var old = this[index] + this.splice(index, 1, val) + $emit.call(this.$up, this.$pathname + '.*', [val, old, null, index]) + } + }, + contains: function(el) { + //判定是否包含 + return this.indexOf(el) > -1 + }, + ensure: function(el) { + if (!this.contains(el)) { + //只有不存在才push + this.push(el) + } + return this + }, + pushArray: function(arr) { + return this.push.apply(this, toJson(arr)) + }, + remove: function(el) { + //移除第一个等于给定值的元素 + return this.removeAt(this.indexOf(el)) + }, + removeAt: function(index) { + index = index >>> 0 + //移除指定索引上的元素 + return this.splice(index, 1) + }, + size: function() { + //取得数组长度,这个函数可以同步视图,length不能 + return this._.length + }, + removeAll: function(all) { + //移除N个元素 + if (Array.isArray(all)) { + for (var i = this.length - 1; i >= 0; i--) { + if (all.indexOf(this[i]) !== -1) { + _splice.call(this.$track, i, 1) + _splice.call(this, i, 1) + } + } + } else if (typeof all === 'function') { + for (i = this.length - 1; i >= 0; i--) { + var el = this[i] + if (all(el, i)) { + _splice.call(this.$track, i, 1) + _splice.call(this, i, 1) + } + } + } else { + _splice.call(this.$track, 0, this.length) + _splice.call(this, 0, this.length) + } + + this.notify() + this._.length = this.length + }, + clear: function() { + this.removeAll() + } +} + +var _splice = arrayProto.splice +arrayMethods.forEach(function(method) { + var original = arrayProto[method] + newProto[method] = function() { + // 继续尝试劫持数组元素的属性 + var args = [] + for (var i = 0, n = arguments.length; i < n; i++) { + args[i] = observe(arguments[i], 0, 1, 1) + } + var result = original.apply(this, args) + addTrack(this.$track, method, args) + + this.notify() + this._.length = this.length + return result + } +}) + +'sort,reverse'.replace(rword, function(method) { + newProto[method] = function() { + var oldArray = this.concat() //保持原来状态的旧数组 + var newArray = this + var mask = Math.random() + var indexes = [] + var hasSort = false + arrayProto[method].apply(newArray, arguments) //排序 + for (var i = 0, n = oldArray.length; i < n; i++) { + var neo = newArray[i] + var old = oldArray[i] + if (neo === old) { + indexes.push(i) + } else { + var index = oldArray.indexOf(neo) + indexes.push(index) //得到新数组的每个元素在旧数组对应的位置 + oldArray[index] = mask //屏蔽已经找过的元素 + hasSort = true + } + } + if (hasSort) { + sortByIndex(this.$track, indexes) + + this.notify() + } + return this + } +}) + +function sortByIndex(array, indexes) { + var map = {} + for (var i = 0, n = indexes.length; i < n; i++) { + map[i] = array[i] + var j = indexes[i] + if (j in map) { + array[i] = map[j] + delete map[j] + } else { + array[i] = array[j] + } + } +} + +function createTrack(n) { + var ret = [] + for (var i = 0; i < n; i++) { + ret[i] = generateID('proxy-each') + } + return ret +} + +function addTrack(track, method, args) { + switch (method) { + case 'push': + case 'unshift': + args = createTrack(args.length) + break + case 'splice': + if (args.length > 2) { + // 0, 5, a, b, c --> 0, 2, 0 + // 0, 5, a, b, c, d, e, f, g--> 0, 0, 3 + var del = args[1] + var add = args.length - 2 + // args = [args[0], Math.max(del - add, 0)].concat(createTrack(Math.max(add - del, 0))) + args = [args[0], args[1]].concat(createTrack(args.length - 2)) + } + break + } + Array.prototype[method].apply(track, args) +} +/********************************************************************* + * 依赖调度系统 * + **********************************************************************/ + +//检测两个对象间的依赖关系 +var dependencyDetection = (function() { + var outerFrames = [] + var currentFrame + return { + begin: function(binding) { + //accessorObject为一个拥有callback的对象 + outerFrames.push(currentFrame) + currentFrame = binding + }, + end: function() { + currentFrame = outerFrames.pop() + }, + collectDependency: function(array) { + if (currentFrame) { + //被dependencyDetection.begin调用 + currentFrame.callback(array) + } + } + } +})() + +//将绑定对象注入到其依赖项的订阅数组中 +var roneval = /^on$/ + +function returnRandom() { + return new Date() - 0 +} + +Anot.injectBinding = function(binding) { + binding.handler = binding.handler || directives[binding.type].update || noop + binding.update = function() { + var begin = false + if (!binding.getter) { + begin = true + dependencyDetection.begin({ + callback: function(array) { + injectDependency(array, binding) + } + }) + + binding.getter = parseExpr(binding.expr, binding.vmodels, binding) + binding.observers.forEach(function(a) { + a.v.$watch(a.p, binding) + }) + delete binding.observers + } + try { + var args = binding.fireArgs, + a, + b + delete binding.fireArgs + if (!args) { + if (binding.type === 'on') { + a = binding.getter + '' + } else { + try { + a = binding.getter.apply(0, binding.args) + } catch (e) { + a = null + } + } + } else { + a = args[0] + b = args[1] + } + b = typeof b === 'undefined' ? binding.oldValue : b + if (binding._filters) { + a = filters.$filter.apply(0, [a].concat(binding._filters)) + } + if (binding.signature) { + var xtype = Anot.type(a) + if (xtype !== 'array' && xtype !== 'object') { + throw Error('warning:' + binding.expr + '只能是对象或数组') + } + binding.xtype = xtype + var vtrack = getProxyIds(binding.proxies || [], xtype) + var mtrack = + a.$track || + (xtype === 'array' ? createTrack(a.length) : Object.keys(a)) + binding.track = mtrack + if (vtrack !== mtrack.join(';')) { + binding.handler(a, b) + binding.oldValue = 1 + } + } else if (Array.isArray(a) ? a.length !== (b && b.length) : false) { + binding.handler(a, b) + binding.oldValue = a.concat() + } else if (!('oldValue' in binding) || a !== b) { + binding.handler(a, b) + binding.oldValue = Array.isArray(a) ? a.concat() : a + } + } catch (e) { + delete binding.getter + log('warning:exception throwed in [Anot.injectBinding] ', e) + var node = binding.element + if (node && node.nodeType === 3) { + node.nodeValue = + openTag + (binding.oneTime ? '::' : '') + binding.expr + closeTag + } + } finally { + begin && dependencyDetection.end() + } + } + binding.update() +} + +//将依赖项(比它高层的访问器或构建视图刷新函数的绑定对象)注入到订阅者数组 +function injectDependency(list, binding) { + if (binding.oneTime) return + if (list && Anot.Array.ensure(list, binding) && binding.element) { + injectDisposeQueue(binding, list) + if (new Date() - beginTime > 444) { + rejectDisposeQueue() + } + } +} + +function getProxyIds(a, isArray) { + var ret = [] + for (var i = 0, el; (el = a[i++]); ) { + ret.push(isArray ? el.$id : el.$key) + } + return ret.join(';') +} +/********************************************************************* + * 定时GC回收机制 (基于1.6基于频率的GC) * + **********************************************************************/ + +var disposeQueue = (Anot.$$subscribers = []) +var beginTime = new Date() + +//添加到回收列队中 +function injectDisposeQueue(data, list) { + data.list = list + data.i = ~~data.i + if (!data.uuid) { + data.uuid = '_' + ++bindingID + } + if (!disposeQueue[data.uuid]) { + disposeQueue[data.uuid] = '__' + disposeQueue.push(data) + } +} + +var lastGCIndex = 0 +function rejectDisposeQueue(data) { + var i = lastGCIndex || disposeQueue.length + var threshold = 0 + while ((data = disposeQueue[--i])) { + if (data.i < 7) { + if (data.element === null) { + disposeQueue.splice(i, 1) + if (data.list) { + Anot.Array.remove(data.list, data) + delete disposeQueue[data.uuid] + } + continue + } + if (shouldDispose(data.element)) { + //如果它的虚拟DOM不在VTree上或其属性不在VM上 + disposeQueue.splice(i, 1) + Anot.Array.remove(data.list, data) + disposeData(data) + //Anot会在每次全量更新时,比较上次执行时间, + //假若距离上次有半秒,就会发起一次GC,并且只检测当中的500个绑定 + //而一个正常的页面不会超过2000个绑定(500即取其4分之一) + //用户频繁操作页面,那么2,3秒内就把所有绑定检测一遍,将无效的绑定移除 + if (threshold++ > 500) { + lastGCIndex = i + break + } + continue + } + data.i++ + //基于检测频率,如果检测过7次,可以认为其是长久存在的节点,那么以后每7次才检测一次 + if (data.i === 7) { + data.i = 14 + } + } else { + data.i-- + } + } + beginTime = new Date() +} + +function disposeData(data) { + delete disposeQueue[data.uuid] // 先清除,不然无法回收了 + data.element = null + data.rollback && data.rollback() + for (var key in data) { + data[key] = null + } +} + +function shouldDispose(el) { + try { + //IE下,如果文本节点脱离DOM树,访问parentNode会报错 + var fireError = el.parentNode.nodeType + } catch (e) { + return true + } + if (el.ifRemove) { + // 如果节点被放到ifGroup,才移除 + if (!root.contains(el.ifRemove) && ifGroup === el.parentNode) { + el.parentNode && el.parentNode.removeChild(el) + return true + } + } + return el.msRetain + ? 0 + : el.nodeType === 1 + ? !root.contains(el) + : !Anot.contains(root, el) +} +/************************************************************************ + * HTML处理(parseHTML, innerHTML, clearHTML) * + *************************************************************************/ + +//parseHTML的辅助变量 +var tagHooks = new function() { + // jshint ignore:line + Anot.mix(this, { + option: DOC.createElement('select'), + thead: DOC.createElement('table'), + td: DOC.createElement('tr'), + area: DOC.createElement('map'), + tr: DOC.createElement('tbody'), + col: DOC.createElement('colgroup'), + legend: DOC.createElement('fieldset'), + _default: DOC.createElement('div'), + g: DOC.createElementNS('http://www.w3.org/2000/svg', 'svg') + }) + this.optgroup = this.option + this.tbody = this.tfoot = this.colgroup = this.caption = this.thead + this.th = this.td +}() // jshint ignore:line +String( + 'circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use' +).replace(rword, function(tag) { + tagHooks[tag] = tagHooks.g //处理SVG +}) + +var rtagName = /<([\w:]+)/ +var rxhtml = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi +var scriptTypes = oneObject([ + '', + 'text/javascript', + 'text/ecmascript', + 'application/ecmascript', + 'application/javascript' +]) +var script = DOC.createElement('script') +var rhtml = /<|&#?\w+;/ + +Anot.parseHTML = function(html) { + var fragment = anotFragment.cloneNode(false) + if (typeof html !== 'string') { + return fragment + } + if (!rhtml.test(html)) { + fragment.appendChild(DOC.createTextNode(html)) + return fragment + } + html = html.replace(rxhtml, '<$1>').trim() + var tag = (rtagName.exec(html) || ['', ''])[1].toLowerCase(), + //取得其标签名 + wrapper = tagHooks[tag] || tagHooks._default, + firstChild + wrapper.innerHTML = html + var els = wrapper.getElementsByTagName('script') + if (els.length) { + //使用innerHTML生成的script节点不会发出请求与执行text属性 + for (var i = 0, el; (el = els[i++]); ) { + if (scriptTypes[el.type]) { + var neo = script.cloneNode(false) //FF不能省略参数 + ap.forEach.call(el.attributes, function(attr) { + neo.setAttribute(attr.name, attr.value) + }) // jshint ignore:line + neo.text = el.text + el.parentNode.replaceChild(neo, el) + } + } + } + + while ((firstChild = wrapper.firstChild)) { + // 将wrapper上的节点转移到文档碎片上! + fragment.appendChild(firstChild) + } + return fragment +} + +Anot.innerHTML = function(node, html) { + var a = this.parseHTML(html) + this.clearHTML(node).appendChild(a) +} + +Anot.clearHTML = function(node) { + node.textContent = '' + while (node.firstChild) { + node.removeChild(node.firstChild) + } + return node +} +/********************************************************************* + * Anot的原型方法定义区 * + **********************************************************************/ + +function hyphen(target) { + //转换为连字符线风格 + return target.replace(/([a-z\d])([A-Z]+)/g, '$1-$2').toLowerCase() +} + +function camelize(target) { + //转换为驼峰风格 + if (target.indexOf('-') < 0 && target.indexOf('_') < 0) { + return target //提前判断,提高getStyle等的效率 + } + return target.replace(/[-_][^-_]/g, function(match) { + return match.charAt(1).toUpperCase() + }) +} + +'add,remove'.replace(rword, function(method) { + Anot.fn[method + 'Class'] = function(cls) { + var el = this[0] + //https://developer.mozilla.org/zh-CN/docs/Mozilla/Firefox/Releases/26 + if (cls && typeof cls === 'string' && el && el.nodeType === 1) { + cls.replace(/\S+/g, function(c) { + el.classList[method](c) + }) + } + return this + } +}) + +Anot.fn.mix({ + attr: function(name, value) { + if (arguments.length === 2) { + this[0].setAttribute(name, value) + return this + } else { + return this[0].getAttribute(name) + } + }, + data: function(name, value) { + var len = arguments.length + var dataset = this[0].dataset + name = hyphen(name || '') + if (!name) { + len = 0 + } + switch (len) { + case 2: + dataset[name] = value + return this + case 1: + var val = dataset[name] + return parseData(val) + case 0: + var ret = createMap() + for (var i in dataset) { + ret[i] = parseData(dataset[i]) + } + return ret + } + }, + removeData: function(name) { + name = 'data-' + hyphen(name) + this[0].removeAttribute(name) + return this + }, + css: function(name, value) { + if (Anot.isPlainObject(name)) { + for (var i in name) { + Anot.css(this, i, name[i]) + } + } else { + var ret = Anot.css(this, name, value) + } + return ret !== void 0 ? ret : this + }, + position: function() { + var offsetParent, + offset, + elem = this[0], + parentOffset = { + top: 0, + left: 0 + } + if (!elem) { + return + } + if (this.css('position') === 'fixed') { + offset = elem.getBoundingClientRect() + } else { + offsetParent = this.offsetParent() //得到真正的offsetParent + offset = this.offset() // 得到正确的offsetParent + if (offsetParent[0].tagName !== 'HTML') { + parentOffset = offsetParent.offset() + } + parentOffset.top += Anot.css(offsetParent[0], 'borderTopWidth', true) + parentOffset.left += Anot.css(offsetParent[0], 'borderLeftWidth', true) + // Subtract offsetParent scroll positions + parentOffset.top -= offsetParent.scrollTop() + parentOffset.left -= offsetParent.scrollLeft() + } + return { + top: offset.top - parentOffset.top - Anot.css(elem, 'marginTop', true), + left: offset.left - parentOffset.left - Anot.css(elem, 'marginLeft', true) + } + }, + offsetParent: function() { + var offsetParent = this[0].offsetParent + while (offsetParent && Anot.css(offsetParent, 'position') === 'static') { + offsetParent = offsetParent.offsetParent + } + return Anot(offsetParent || root) + }, + bind: function(type, fn, phase) { + if (this[0]) { + //此方法不会链 + return Anot.bind(this[0], type, fn, phase) + } + }, + unbind: function(type, fn, phase) { + if (this[0]) { + Anot.unbind(this[0], type, fn, phase) + } + return this + }, + val: function(value) { + var node = this[0] + if (node && node.nodeType === 1) { + var get = arguments.length === 0 + var access = get ? ':get' : ':set' + var fn = valHooks[getValType(node) + access] + if (fn) { + var val = fn(node, value) + } else if (get) { + return (node.value || '').replace(/\r/g, '') + } else { + node.value = value + } + } + return get ? val : this + } +}) + +Anot.parseJSON = JSON.parse + +var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/ +function parseData(data) { + try { + if (typeof data === 'object') return data + data = + data === 'true' + ? true + : data === 'false' + ? false + : data === 'null' + ? null + : +data + '' === data + ? +data + : rbrace.test(data) + ? JSON.parse(data) + : data + } catch (e) {} + return data +} + +Anot.fireDom = function(elem, type, opts) { + var hackEvent = DOC.createEvent('Events') + hackEvent.initEvent(type, true, true) + Anot.mix(hackEvent, opts) + elem.dispatchEvent(hackEvent) +} + +Anot.each( + { + scrollLeft: 'pageXOffset', + scrollTop: 'pageYOffset' + }, + function(method, prop) { + Anot.fn[method] = function(val) { + var node = this[0] || {}, + win = getWindow(node), + top = method === 'scrollTop' + if (!arguments.length) { + return win ? win[prop] : node[method] + } else { + if (win) { + win.scrollTo(!top ? val : win[prop], top ? val : win[prop]) + } else { + node[method] = val + } + } + } + } +) + +function getWindow(node) { + return node.window && node.document + ? node + : node.nodeType === 9 + ? node.defaultView + : false +} + +//=============================css相关================================== + +var cssHooks = (Anot.cssHooks = createMap()) +var prefixes = ['', '-webkit-', '-moz-', '-ms-'] //去掉opera-15的支持 +var cssMap = { + float: 'cssFloat' +} + +Anot.cssNumber = oneObject( + 'animationIterationCount,animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom' +) + +Anot.cssName = function(name, host, camelCase) { + if (cssMap[name]) { + return cssMap[name] + } + host = host || root.style + for (var i = 0, n = prefixes.length; i < n; i++) { + camelCase = camelize(prefixes[i] + name) + if (camelCase in host) { + return (cssMap[name] = camelCase) + } + } + return null +} + +cssHooks['@:set'] = function(node, name, value) { + node.style[name] = value +} + +cssHooks['@:get'] = function(node, name) { + if (!node || !node.style) { + throw new Error('getComputedStyle要求传入一个节点 ' + node) + } + var ret, + computed = getComputedStyle(node) + if (computed) { + ret = name === 'filter' ? computed.getPropertyValue(name) : computed[name] + if (ret === '') { + ret = node.style[name] //其他浏览器需要我们手动取内联样式 + } + } + return ret +} +cssHooks['opacity:get'] = function(node) { + var ret = cssHooks['@:get'](node, 'opacity') + return ret === '' ? '1' : ret +} + +'top,left'.replace(rword, function(name) { + cssHooks[name + ':get'] = function(node) { + var computed = cssHooks['@:get'](node, name) + return /px$/.test(computed) ? computed : Anot(node).position()[name] + 'px' + } +}) + +var cssShow = { + position: 'absolute', + visibility: 'hidden', + display: 'block' +} +var rdisplayswap = /^(none|table(?!-c[ea]).+)/ +function showHidden(node, array) { + //http://www.cnblogs.com/rubylouvre/archive/2012/10/27/2742529.html + if (node.offsetWidth <= 0) { + //opera.offsetWidth可能小于0 + var styles = getComputedStyle(node, null) + if (rdisplayswap.test(styles['display'])) { + var obj = { + node: node + } + for (var name in cssShow) { + obj[name] = styles[name] + node.style[name] = cssShow[name] + } + array.push(obj) + } + var _parent = node.parentNode + if (_parent && _parent.nodeType === 1) { + showHidden(_parent, array) + } + } +} + +'Width,Height'.replace(rword, function(name) { + //fix 481 + var method = name.toLowerCase(), + clientProp = 'client' + name, + scrollProp = 'scroll' + name, + offsetProp = 'offset' + name + cssHooks[method + ':get'] = function(node, which, override) { + var boxSizing = -4 + if (typeof override === 'number') { + boxSizing = override + } + which = name === 'Width' ? ['Left', 'Right'] : ['Top', 'Bottom'] + var ret = node[offsetProp] // border-box 0 + if (boxSizing === 2) { + // margin-box 2 + return ( + ret + + Anot.css(node, 'margin' + which[0], true) + + Anot.css(node, 'margin' + which[1], true) + ) + } + if (boxSizing < 0) { + // padding-box -2 + ret = + ret - + Anot.css(node, 'border' + which[0] + 'Width', true) - + Anot.css(node, 'border' + which[1] + 'Width', true) + } + if (boxSizing === -4) { + // content-box -4 + ret = + ret - + Anot.css(node, 'padding' + which[0], true) - + Anot.css(node, 'padding' + which[1], true) + } + return ret + } + cssHooks[method + '&get'] = function(node) { + var hidden = [] + showHidden(node, hidden) + var val = cssHooks[method + ':get'](node) + for (var i = 0, obj; (obj = hidden[i++]); ) { + node = obj.node + for (var n in obj) { + if (typeof obj[n] === 'string') { + node.style[n] = obj[n] + } + } + } + return val + } + Anot.fn[method] = function(value) { + //会忽视其display + var node = this[0] + if (arguments.length === 0) { + if (node.setTimeout) { + //取得窗口尺寸,IE9后可以用node.innerWidth /innerHeight代替 + return node['inner' + name] + } + if (node.nodeType === 9) { + //取得页面尺寸 + var doc = node.documentElement + //FF chrome html.scrollHeight< body.scrollHeight + //IE 标准模式 : html.scrollHeight> body.scrollHeight + //IE 怪异模式 : html.scrollHeight 最大等于可视窗口多一点? + return Math.max( + node.body[scrollProp], + doc[scrollProp], + node.body[offsetProp], + doc[offsetProp], + doc[clientProp] + ) + } + return cssHooks[method + '&get'](node) + } else { + return this.css(method, value) + } + } + Anot.fn['inner' + name] = function() { + return cssHooks[method + ':get'](this[0], void 0, -2) + } + Anot.fn['outer' + name] = function(includeMargin) { + return cssHooks[method + ':get']( + this[0], + void 0, + includeMargin === true ? 2 : 0 + ) + } +}) + +Anot.fn.offset = function() { + //取得距离页面左右角的坐标 + var node = this[0] + try { + var rect = node.getBoundingClientRect() + // Make sure element is not hidden (display: none) or disconnected + // https://github.com/jquery/jquery/pull/2043/files#r23981494 + if (rect.width || rect.height || node.getClientRects().length) { + var doc = node.ownerDocument + var root = doc.documentElement + var win = doc.defaultView + return { + top: rect.top + win.pageYOffset - root.clientTop, + left: rect.left + win.pageXOffset - root.clientLeft + } + } + } catch (e) { + return { + left: 0, + top: 0 + } + } +} + +//=============================val相关======================= + +function getValType(elem) { + var ret = elem.tagName.toLowerCase() + return ret === 'input' && /checkbox|radio/.test(elem.type) ? 'checked' : ret +} + +var valHooks = { + 'select:get': function(node, value) { + var option, + options = node.options, + index = node.selectedIndex, + one = node.type === 'select-one' || index < 0, + values = one ? null : [], + max = one ? index + 1 : options.length, + i = index < 0 ? max : one ? index : 0 + for (; i < max; i++) { + option = options[i] + //旧式IE在reset后不会改变selected,需要改用i === index判定 + //我们过滤所有disabled的option元素,但在safari5下,如果设置select为disable,那么其所有孩子都disable + //因此当一个元素为disable,需要检测其是否显式设置了disable及其父节点的disable情况 + if ((option.selected || i === index) && !option.disabled) { + value = option.value + if (one) { + return value + } + //收集所有selected值组成数组返回 + values.push(value) + } + } + return values + }, + 'select:set': function(node, values, optionSet) { + values = [].concat(values) //强制转换为数组 + for (var i = 0, el; (el = node.options[i++]); ) { + if ((el.selected = values.indexOf(el.value) > -1)) { + optionSet = true + } + } + if (!optionSet) { + node.selectedIndex = -1 + } + } +} +var keyMap = {} +var keys = [ + 'break,case,catch,continue,debugger,default,delete,do,else,false', + 'finally,for,function,if,in,instanceof,new,null,return,switch,this', + 'throw,true,try,typeof,var,void,while,with' /* 关键字*/, + 'abstract,boolean,byte,char,class,const,double,enum,export,extends', + 'final,float,goto,implements,import,int,interface,long,native', + 'package,private,protected,public,short,static,super,synchronized', + 'throws,transient,volatile' /*保留字*/, + 'arguments,let,yield,async,await,undefined' +].join(',') +keys.replace(/\w+/g, function(a) { + keyMap[a] = true +}) + +var ridentStart = /[a-z_$]/i +var rwhiteSpace = /[\s\uFEFF\xA0]/ +function getIdent(input, lastIndex) { + var result = [] + var subroutine = !!lastIndex + lastIndex = lastIndex || 0 + //将表达式中的标识符抽取出来 + var state = 'unknown' + var variable = '' + for (var i = 0; i < input.length; i++) { + var c = input.charAt(i) + if (c === "'" || c === '"') { + //字符串开始 + if (state === 'unknown') { + state = c + } else if (state === c) { + //字符串结束 + state = 'unknown' + } + } else if (c === '\\') { + if (state === "'" || state === '"') { + i++ + } + } else if (ridentStart.test(c)) { + //碰到标识符 + if (state === 'unknown') { + state = 'variable' + variable = c + } else if (state === 'maybePath') { + variable = result.pop() + variable += '.' + c + state = 'variable' + } else if (state === 'variable') { + variable += c + } + } else if (/\w/.test(c)) { + if (state === 'variable') { + variable += c + } + } else if (c === '.') { + if (state === 'variable') { + if (variable) { + result.push(variable) + variable = '' + state = 'maybePath' + } + } + } else if (c === '[') { + if (state === 'variable' || state === 'maybePath') { + if (variable) { + //如果前面存在变量,收集它 + result.push(variable) + variable = '' + } + var lastLength = result.length + var last = result[lastLength - 1] + var innerResult = getIdent(input.slice(i), i) + if (innerResult.length) { + //如果括号中存在变量,那么这里添加通配符 + result[lastLength - 1] = last + '.*' + result = innerResult.concat(result) + } else { + //如果括号中的东西是确定的,直接转换为其子属性 + var content = input.slice(i + 1, innerResult.i) + try { + var text = scpCompile(['return ' + content])() + result[lastLength - 1] = last + '.' + text + } catch (e) {} + } + state = 'maybePath' //]后面可能还接东西 + i = innerResult.i + } + } else if (c === ']') { + if (subroutine) { + result.i = i + lastIndex + addVar(result, variable) + return result + } + } else if (rwhiteSpace.test(c) && c !== '\r' && c !== '\n') { + if (state === 'variable') { + if (addVar(result, variable)) { + state = 'maybePath' // aaa . bbb 这样的情况 + } + variable = '' + } + } else { + addVar(result, variable) + state = 'unknown' + variable = '' + } + } + addVar(result, variable) + return result +} + +function addVar(array, element) { + if (element && !keyMap[element]) { + array.push(element) + return true + } +} + +function addAssign(vars, vmodel, name, binding) { + var ret = [] + var prefix = ' = ' + name + '.' + for (var i = vars.length, prop; (prop = vars[--i]); ) { + var arr = prop.split('.') + var first = arr[0] + + if (vmodel.hasOwnProperty(first)) { + // log(first, prop, prefix, vmodel) + ret.push(first + prefix + first) + binding.observers.push({ + v: vmodel, + p: prop, + type: Anot.type(vmodel[first]) + }) + vars.splice(i, 1) + } + } + return ret +} + +var rproxy = /(proxy\-[a-z]+)\-[\-0-9a-f]+$/ +var variablePool = new Cache(218) +//缓存求值函数,以便多次利用 +var evaluatorPool = new Cache(128) + +function getVars(expr) { + expr = expr.trim() + var ret = variablePool.get(expr) + if (ret) { + return ret.concat() + } + var array = getIdent(expr) + var uniq = {} + var result = [] + for (var i = 0, el; (el = array[i++]); ) { + if (!uniq[el]) { + uniq[el] = 1 + result.push(el) + } + } + return variablePool.put(expr, result).concat() +} + +function parseExpr(expr, vmodels, binding) { + var filters = binding.filters + if (typeof filters === 'string' && filters.trim() && !binding._filters) { + binding._filters = parseFilter(filters.trim()) + } + + var vars = getVars(expr) + var expose = new Date() - 0 + var assigns = [] + var names = [] + var args = [] + binding.observers = [] + + for (var i = 0, sn = vmodels.length; i < sn; i++) { + if (vars.length) { + var name = 'vm' + expose + '_' + i + names.push(name) + args.push(vmodels[i]) + assigns.push.apply(assigns, addAssign(vars, vmodels[i], name, binding)) + } + } + binding.args = args + var dataType = binding.type + var exprId = + vmodels.map(function(el) { + return String(el.$id).replace(rproxy, '$1') + }) + + expr + + dataType + // log(expr, '---------------', assigns) + var getter = evaluatorPool.get(exprId) //直接从缓存,免得重复生成 + if (getter) { + if (dataType === 'duplex') { + var setter = evaluatorPool.get(exprId + 'setter') + binding.setter = setter.apply(setter, binding.args) + } + return (binding.getter = getter) + } + + // expr的字段不可枚举时,补上一个随机变量, 避免抛出异常 + if (!assigns.length) { + assigns.push('fix' + expose) + } + + if (dataType === 'duplex') { + var nameOne = {} + assigns.forEach(function(a) { + var arr = a.split('=') + nameOne[arr[0].trim()] = arr[1].trim() + }) + expr = expr.replace(/[\$\w]+/, function(a) { + return nameOne[a] ? nameOne[a] : a + }) + /* jshint ignore:start */ + var fn2 = scpCompile( + names.concat( + '"use strict";\n return function(vvv){' + expr + ' = vvv\n}\n' + ) + ) + /* jshint ignore:end */ + evaluatorPool.put(exprId + 'setter', fn2) + binding.setter = fn2.apply(fn2, binding.args) + } + + if (dataType === 'on') { + //事件绑定 + if (expr.indexOf('(') === -1) { + expr += '.call(' + names[names.length - 1] + ', $event)' + } else { + expr = expr.replace('(', '.call(' + names[names.length - 1] + ', ') + } + names.push('$event') + expr = '\nreturn ' + expr + ';' //IE全家 Function("return ")出错,需要Function("return ;") + var lastIndex = expr.lastIndexOf('\nreturn') + var header = expr.slice(0, lastIndex) + var footer = expr.slice(lastIndex) + expr = header + '\n' + footer + } else { + // 对于非事件绑定的方法, 同样绑定到vm上 + binding.observers.forEach(function(it) { + if (it.type === 'function') { + // log(it, expr) + var reg = new RegExp(it.p + '\\(([^)]*)\\)', 'g') + expr = expr.replace(reg, function(s, m) { + m = m.trim() + return ( + it.p + + '.call(' + + names[names.length - 1] + + (m ? ', ' + m : '') + + ')' + ) + }) + } + }) + expr = '\nreturn ' + expr + ';' //IE全家 Function("return ")出错,需要Function("return ;") + } + + /* jshint ignore:start */ + getter = scpCompile( + names.concat( + "'use strict';\ntry{\n var " + + assigns.join(',\n ') + + expr + + '\n}catch(e){console.log(e)}' + ) + ) + /* jshint ignore:end */ + + return evaluatorPool.put(exprId, getter) +} + +function normalizeExpr(code) { + var hasExpr = rexpr.test(code) //比如:class="width{{w}}"的情况 + if (hasExpr) { + var array = scanExpr(code) + if (array.length === 1) { + return array[0].expr + } + return array + .map(function(el) { + return el.type ? '(' + el.expr + ')' : quote(el.expr) + }) + .join(' + ') + } else { + return code + } +} + +Anot.normalizeExpr = normalizeExpr +Anot.parseExprProxy = parseExpr + +var rthimRightParentheses = /\)\s*$/ +var rthimOtherParentheses = /\)\s*\|/g +var rquoteFilterName = /\|\s*([$\w]+)/g +var rpatchBracket = /"\s*\["/g +var rthimLeftParentheses = /"\s*\(/g +function parseFilter(filters) { + filters = + filters + .replace(rthimRightParentheses, '') //处理最后的小括号 + .replace(rthimOtherParentheses, function() { + //处理其他小括号 + return '],|' + }) + .replace(rquoteFilterName, function(a, b) { + //处理|及它后面的过滤器的名字 + return '[' + quote(b) + }) + .replace(rpatchBracket, function() { + return '"],["' + }) + .replace(rthimLeftParentheses, function() { + return '",' + }) + ']' + /* jshint ignore:start */ + return scpCompile(['return [' + filters + ']'])() + /* jshint ignore:end */ +} + +/********************************************************************* + * 编译系统 * + **********************************************************************/ + +var quote = JSON.stringify +/********************************************************************* + * 扫描系统 * + **********************************************************************/ + +//http://www.w3.org/TR/html5/syntax.html#void-elements +var stopScan = oneObject( + 'area,base,basefont,br,col,command,embed,hr,img,input,link,meta,param,source,track,wbr,noscript,script,style,textarea'.toUpperCase() +) + +function isRef(el) { + return el.hasAttribute('ref') ? el.getAttribute('ref') : null +} + +function checkScan(elem, callback, innerHTML) { + var id = setTimeout(function() { + var currHTML = elem.innerHTML + clearTimeout(id) + if (currHTML === innerHTML) { + callback() + } else { + checkScan(elem, callback, currHTML) + } + }) +} + +function getBindingCallback(elem, name, vmodels) { + var callback = elem.getAttribute(name) + if (callback) { + for (var i = 0, vm; (vm = vmodels[i++]); ) { + if (vm.hasOwnProperty(callback) && typeof vm[callback] === 'function') { + return vm[callback] + } + } + } +} + +function executeBindings(bindings, vmodels) { + for (var i = 0, binding; (binding = bindings[i++]); ) { + binding.vmodels = vmodels + directives[binding.type].init(binding) + + Anot.injectBinding(binding) + if (binding.getter && binding.element.nodeType === 1) { + //移除数据绑定,防止被二次解析 + //chrome使用removeAttributeNode移除不存在的特性节点时会报错 + binding.element.removeAttribute(binding.name) + } + } + bindings.length = 0 +} + +var roneTime = /^\s*::/ +var rmsAttr = /:(\w+)-?(.*)|@(.*)/ + +var events = oneObject( + 'animationend,blur,change,input,click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit' +) +var obsoleteAttrs = oneObject( + 'value,title,alt,checked,selected,disabled,readonly,loading,enabled,href,src' +) +function bindingSorter(a, b) { + return a.priority - b.priority +} + +var rnoCollect = /^(:\S+|data-\S+|on[a-z]+|style|class)$/ +var filterTypes = ['html', 'text', 'attr', 'data'] + +function scanAttr(elem, vmodels, match) { + var scanNode = true + if (vmodels.length) { + var attributes = elem.attributes + var bindings = [] + var uniq = {} + for (var i = 0, attr; (attr = attributes[i++]); ) { + var name = attr.name + if (uniq[name]) { + //IE8下:for BUG + continue + } + uniq[name] = 1 + if (attr.specified) { + if ((match = name.match(rmsAttr))) { + //如果是以指定前缀命名的 + var type = match[1] + var param = match[2] || '' + var eparam = match[3] || '' // 事件绑定的简写 + var value = attr.value + if (obsoleteAttrs[type]) { + param = type + type = 'attr' + } + if (eparam) { + param = eparam + type = 'on' + } + if (directives[type]) { + var newValue = value.replace(roneTime, '') + var oneTime = value !== newValue + var binding = { + type: type, + param: param, + element: elem, + name: name, + expr: newValue, + oneTime: oneTime, + uuid: '_' + ++bindingID, + priority: + (directives[type].priority || type.charCodeAt(0) * 10) + + (Number(param.replace(/\D/g, '')) || 0) + } + // 如果指令允许使用过滤器 + if (filterTypes.includes(type)) { + var filters = getToken(value).filters + binding.expr = binding.expr.replace(filters, '') + binding.filters = filters + .replace(rhasHtml, function() { + binding.type = 'html' + binding.group = 1 + return '' + }) + .trim() // jshint ignore:line + } else if (type === 'duplex') { + var hasDuplex = name + } else if (name === ':if-loop') { + binding.priority += 100 + } else if (name === ':attr-value') { + var hasAttrValue = name + } + bindings.push(binding) + } + } + } + } + if (bindings.length) { + bindings.sort(bindingSorter) + + if (hasDuplex && hasAttrValue && elem.type === 'text') { + log('warning!一个控件不能同时定义:attr-value与' + hasDuplex) + } + + for (i = 0; (binding = bindings[i]); i++) { + type = binding.type + if (rnoscanAttrBinding.test(type)) { + return executeBindings(bindings.slice(0, i + 1), vmodels) + } else if (scanNode) { + scanNode = !rnoscanNodeBinding.test(type) + } + } + executeBindings(bindings, vmodels) + } + } + if (scanNode && !stopScan[elem.tagName]) { + scanNodeList(elem, vmodels) //扫描子孙元素 + } +} + +var rnoscanAttrBinding = /^if|for$/ +var rnoscanNodeBinding = /^html|include$/ + +function scanNodeList(elem, vmodels) { + var nodes = Anot.slice(elem.childNodes) + scanNodeArray(nodes, vmodels) +} + +function scanNodeArray(nodes, vmodels) { + function _delay_component(name) { + setTimeout(function() { + Anot.component(name) + }) + } + for (var i = 0, node; (node = nodes[i++]); ) { + switch (node.nodeType) { + case 1: + var elem = node + if (elem.parentNode && elem.parentNode.nodeType === 1) { + // 非组件才检查 ref属性 + var ref = isRef(elem) + if (ref && vmodels.length) { + vmodels[0].$refs[ref] = elem + } + } + + scanTag(node, vmodels) //扫描元素节点 + + if (node.msHasEvent) { + Anot.fireDom(node, 'datasetchanged', { + bubble: node.msHasEvent + }) + } + + break + case 3: + if (rexpr.test(node.nodeValue)) { + scanText(node, vmodels, i) //扫描文本节点 + } + break + } + } +} + +function scanTag(elem, vmodels) { + //扫描顺序 skip(0) --> anot(1) --> :if(10) --> :for(90) + //--> :if-loop(110) --> :attr(970) ...--> :duplex(2000)垫后 + var skip = elem.getAttribute('skip') + var node = elem.getAttributeNode('anot') + var vm = vmodels.concat() + if (typeof skip === 'string') { + return + } else if (node) { + var newVmodel = Anot.vmodels[node.value] + var attrs = aslice.call(elem.attributes, 0) + + if (!newVmodel) { + return + } + + vm = [newVmodel] + + elem.removeAttribute(node.name) //removeAttributeNode不会刷新xx[anot]样式规则 + // 挂载VM对象到相应的元素上 + elem.__VM__ = newVmodel + hideProperty(newVmodel, '$elem', elem) + + if (vmodels.length) { + newVmodel.$up = vmodels[0] + vmodels[0].$children.push(newVmodel) + var props = {} + attrs.forEach(function(attr) { + if (/^:/.test(attr.name)) { + var name = attr.name.match(rmsAttr)[1] + var value = null + if (!name || Anot.directives[name] || events[name]) { + return + } + try { + value = parseExpr(attr.value, vmodels, {}).apply(0, vmodels) + value = toJson(value) + elem.removeAttribute(attr.name) + props[name] = value + } catch (error) { + log( + 'Props parse faild on (%s[class=%s]),', + elem.nodeName, + elem.className, + attr, + error + '' + ) + } + } + }) + // 一旦设定了 props的类型, 就必须传入正确的值 + for (var k in newVmodel.props) { + if (newVmodel.props[k] && newVmodel.props[k].type === 'PropsTypes') { + if (newVmodel.props[k].check(props[k])) { + newVmodel.props[k] = props[k] + delete props[k] + } else { + console.error( + new TypeError( + 'props.' + + k + + ' needs [' + + newVmodel.props[k].checkType + + '], but [' + + newVmodel.props[k].result + + '] given.' + ) + ) + } + } + } + Object.assign(newVmodel.props, props) + props = undefined + } + } + scanAttr(elem, vm) //扫描特性节点 + + if (newVmodel) { + setTimeout(function() { + if (typeof newVmodel.$mounted === 'function') { + newVmodel.$mounted() + } + delete newVmodel.$mounted + }) + } +} +var rhasHtml = /\|\s*html(?:\b|$)/, + r11a = /\|\|/g, + rlt = /</g, + rgt = />/g, + rstringLiteral = /(['"])(\\\1|.)+?\1/g, + rline = /\r?\n/g +function getToken(value) { + if (value.indexOf('|') > 0) { + var scapegoat = value.replace(rstringLiteral, function(_) { + return Array(_.length + 1).join('1') // jshint ignore:line + }) + var index = scapegoat.replace(r11a, '\u1122\u3344').indexOf('|') //干掉所有短路或 + if (index > -1) { + return { + type: 'text', + filters: value.slice(index).trim(), + expr: value.slice(0, index) + } + } + } + return { + type: 'text', + expr: value, + filters: '' + } +} + +function scanExpr(str) { + var tokens = [], + value, + start = 0, + stop + do { + stop = str.indexOf(openTag, start) + if (stop === -1) { + break + } + value = str.slice(start, stop) + if (value) { + // {{ 左边的文本 + tokens.push({ + expr: value + }) + } + start = stop + openTag.length + stop = str.indexOf(closeTag, start) + if (stop === -1) { + break + } + value = str.slice(start, stop) + if (value) { + //处理{{ }}插值表达式 + tokens.push(getToken(value.replace(rline, ''))) + } + start = stop + closeTag.length + } while (1) + value = str.slice(start) + if (value) { + //}} 右边的文本 + tokens.push({ + expr: value + }) + } + return tokens +} + +function scanText(textNode, vmodels, index) { + var bindings = [], + tokens = scanExpr(textNode.data) + if (tokens.length) { + for (var i = 0, token; (token = tokens[i++]); ) { + var node = DOC.createTextNode(token.expr) //将文本转换为文本节点,并替换原来的文本节点 + if (token.type) { + token.expr = token.expr.replace(roneTime, function() { + token.oneTime = true + return '' + }) // jshint ignore:line + token.element = node + token.filters = token.filters.replace(rhasHtml, function() { + token.type = 'html' + return '' + }) // jshint ignore:line + token.pos = index * 1000 + i + bindings.push(token) //收集带有插值表达式的文本 + } + anotFragment.appendChild(node) + } + textNode.parentNode.replaceChild(anotFragment, textNode) + if (bindings.length) executeBindings(bindings, vmodels) + } +} +//使用来自游戏界的双缓冲技术,减少对视图的冗余刷新 +var Buffer = function() { + this.queue = [] +} +Buffer.prototype = { + render: function(isAnimate) { + if (!this.locked) { + this.locked = isAnimate ? root.offsetHeight + 10 : 1 + var me = this + Anot.nextTick(function() { + me.flush() + }) + } + }, + flush: function() { + for (var i = 0, sub; (sub = this.queue[i++]); ) { + sub.update && sub.update() + } + this.locked = 0 + this.queue = [] + } +} + +var buffer = new Buffer() + + +var bools = [ + 'autofocus,autoplay,async,allowTransparency,checked,controls', + 'declare,disabled,defer,defaultChecked,defaultSelected', + 'contentEditable,isMap,loop,multiple,noHref,noResize,noShade', + 'open,readOnly,selected' +].join(',') +var boolMap = {} +bools.replace(rword, function(name) { + boolMap[name.toLowerCase()] = name +}) + +var attrDir = Anot.directive('attr', { + init: function(binding) { + //{{aaa}} --> aaa + //{{aaa}}/bbb.html --> (aaa) + "/bbb.html" + binding.expr = normalizeExpr(binding.expr.trim()) + if (binding.type === 'include') { + var elem = binding.element + effectBinding(elem, binding) + binding.includeRendered = getBindingCallback( + elem, + 'data-rendered', + binding.vmodels + ) + binding.includeLoaded = getBindingCallback( + elem, + 'data-loaded', + binding.vmodels + ) + // 是否直接替换当前容器 + var outer = (binding.includeReplace = elem.hasAttribute('replace')) + if (elem.hasAttribute('cache')) { + binding.templateCache = {} + } + binding.start = DOC.createComment(':include') + binding.end = DOC.createComment(':include-end') + if (outer) { + binding.element = binding.end + binding._element = elem + elem.parentNode.insertBefore(binding.start, elem) + elem.parentNode.insertBefore(binding.end, elem.nextSibling) + } else { + elem.insertBefore(binding.start, elem.firstChild) + elem.appendChild(binding.end) + } + } + }, + update: function(val) { + var elem = this.element + var obj = {} + + val = toJson(val) + + if (this.param) { + if (val && typeof val === 'object') { + if (Array.isArray(val)) { + obj[this.param] = val + } else { + if (Date.isDate(val)) { + obj[this.param] = val.toISOString() + } else { + obj[this.param] = val + } + } + } else { + obj[this.param] = val + } + } else { + if ( + !val || + typeof val !== 'object' || + Array.isArray(val) || + Date.isDate(val) + ) { + return + } + + obj = val + } + + for (var i in obj) { + if (i === 'style') { + elem.style.cssText = obj[i] + continue + } + if (i === 'href' || i === 'src') { + elem[i] = obj[i] + } else { + // 修正这些值的显示 + if (obj[i] === false || obj[i] === null || obj[i] === undefined) { + obj[i] = '' + } + + if ( + typeof elem[i] === 'boolean' || + typeof elem[boolMap[i]] === 'boolean' + ) { + var k = i + if (boolMap[i] && k !== boolMap[i]) { + k = boolMap[i] + } + //布尔属性必须使用el.xxx = true|false方式设值 + obj[i] = !!obj[i] + elem[k] = obj[i] + + if (!obj[i]) { + elem.removeAttribute(k) + continue + } + } + + //SVG只能使用setAttribute(xxx, yyy), HTML的固有属性必须elem.xxx = yyy + var isInnate = rsvg.test(elem) ? false : i in elem.cloneNode(false) + if (isInnate) { + elem[i] = obj[i] + } else { + if (typeof obj[i] === 'object') { + obj[i] = Date.isDate(obj[i]) + ? obj[i].toISOString() + : JSON.stringify(obj[i]) + } + elem.setAttribute(i, obj[i]) + } + } + } + } +}) +//类名定义 :class="{xx: yy}" :class="xx" +Anot.directive('class', { + init: function(binding) { + binding.expr = binding.expr.replace(/\n/g, ' ').replace(/\s+/g, ' ') + + if (binding.type === 'hover' || binding.type === 'active') { + var expr = new Function('return ' + binding.expr)() + + //确保只绑定一次 + if (!binding.hasBindEvent) { + var elem = binding.element + var $elem = Anot(elem) + var activate = 'mouseenter' //在移出移入时切换类名 + var abandon = 'mouseleave' + if (binding.type === 'active') { + //在聚焦失焦中切换类名 + elem.tabIndex = elem.tabIndex || -1 + activate = 'mousedown' + abandon = 'mouseup' + var fn0 = $elem.bind('mouseleave', function() { + $elem.removeClass(expr) + }) + } + } + + var fn1 = $elem.bind(activate, function() { + $elem.addClass(expr) + }) + var fn2 = $elem.bind(abandon, function() { + $elem.removeClass(expr) + }) + binding.rollback = function() { + $elem.unbind('mouseleave', fn0) + $elem.unbind(activate, fn1) + $elem.unbind(abandon, fn2) + } + binding.hasBindEvent = true + } + }, + update: function(val) { + if (this.type !== 'class') { + return + } + var obj = val + if (!obj || this.param) + return log( + 'class指令语法错误 %c %s="%s"', + 'color:#f00', + this.name, + this.expr + ) + + if (typeof obj === 'string') { + obj = {} + obj[val] = true + } + + if (!Anot.isPlainObject(obj)) { + obj = obj.$model + } + + for (var i in obj) { + this.element.classList.toggle(i, !!obj[i]) + } + } +}) + +'hover,active'.replace(rword, function(name) { + directives[name] = directives['class'] +}) +//样式定义 :css-width="200" +//:css="{width: 200}" +Anot.directive('css', { + init: directives.attr.init, + update: function(val) { + var $elem = Anot(this.element) + if (this.param) { + $elem.css(this.param, val) + } else { + if (typeof val !== 'object') { + return log( + ':css指令格式错误 %c %s="%s"', + 'color:#f00', + this.name, + this.expr + ) + } + var obj = val + if (!Anot.isPlainObject(obj)) { + obj = val.$model + } + $elem.css(obj) + } + } +}) +//兼容2种写法 :data-xx="yy", :data="{xx: yy}" +Anot.directive('data', { + priority: 100, + init: directives.attr.init, + update: function(val) { + var $el = Anot(this.element) + if (this.param) { + $el.data(this.param, val) + } else { + if (typeof val !== 'object') { + return log( + ':data指令格式错误 %c %s="%s"', + 'color:#f00', + this.name, + this.expr + ) + } + var obj = val + if (!Anot.isPlainObject(obj)) { + obj = val.$model + } + for (var i in obj) { + $el.data(i, obj[i]) + } + } + } +}) +//双工绑定 +var rduplexType = /^(?:checkbox|radio)$/ +var rduplexParam = /^(?:radio|checked)$/ +var rnoduplexInput = /^(file|button|reset|submit|checkbox|radio|range)$/ +var duplexBinding = Anot.directive('duplex', { + priority: 2000, + init: function(binding, hasCast) { + var elem = binding.element + var vmodels = binding.vmodels + binding.changed = getBindingCallback(elem, 'data-changed', vmodels) || noop + var params = [] + var casting = oneObject('string,number,boolean,checked') + if (elem.type === 'radio' && binding.param === '') { + binding.param = 'checked' + } + + binding.param.replace(rw20g, function(name) { + if (rduplexType.test(elem.type) && rduplexParam.test(name)) { + name = 'checked' + binding.isChecked = true + binding.xtype = 'radio' + } + + if (casting[name]) { + hasCast = true + } + Anot.Array.ensure(params, name) + }) + if (!hasCast) { + params.push('string') + } + binding.param = params.join('-') + if (!binding.xtype) { + binding.xtype = + elem.tagName === 'SELECT' + ? 'select' + : elem.type === 'checkbox' + ? 'checkbox' + : elem.type === 'radio' + ? 'radio' + : /^change/.test(elem.getAttribute('data-event')) + ? 'change' + : 'input' + } + elem.expr = binding.expr + //===================绑定事件====================== + var bound = (binding.bound = function(type, callback) { + elem.addEventListener(type, callback, false) + var old = binding.rollback + binding.rollback = function() { + elem.anotSetter = null + Anot.unbind(elem, type, callback) + old && old() + } + }) + function callback(value) { + binding.changed.call(this, value) + } + var composing = false + function compositionStart() { + composing = true + } + function compositionEnd() { + composing = false + setTimeout(updateVModel) + } + var updateVModel = function(e) { + var val = elem.value + //防止递归调用形成死循环 + //处理中文输入法在minlengh下引发的BUG + if (composing || val === binding.oldValue || binding.pipe === null) { + return + } + + var lastValue = binding.pipe( + val, + binding, + 'get' + ) + binding.oldValue = val + binding.setter(lastValue) + + callback.call(elem, lastValue) + Anot.fireDom(elem, 'change') + } + switch (binding.xtype) { + case 'radio': + bound('click', function() { + var lastValue = binding.pipe( + elem.value, + binding, + 'get' + ) + binding.setter(lastValue) + callback.call(elem, lastValue) + }) + break + case 'checkbox': + bound('change', function() { + var method = elem.checked ? 'ensure' : 'remove' + var array = binding.getter.apply(0, binding.vmodels) + if (!Array.isArray(array)) { + log(':duplex应用于checkbox上要对应一个数组') + array = [array] + } + var val = binding.pipe( + elem.value, + binding, + 'get' + ) + Anot.Array[method](array, val) + callback.call(elem, array) + }) + break + case 'change': + bound('change', updateVModel) + break + case 'input': + bound('input', updateVModel) + bound('keyup', updateVModel) + bound('compositionstart', compositionStart) + bound('compositionend', compositionEnd) + bound('DOMAutoComplete', updateVModel) + break + case 'select': + bound('change', function() { + var val = Anot(elem).val() //字符串或字符串数组 + if (Array.isArray(val)) { + val = val.map(function(v) { + return binding.pipe( + v, + binding, + 'get' + ) + }) + } else { + val = binding.pipe( + val, + binding, + 'get' + ) + } + if (val + '' !== binding.oldValue) { + try { + binding.setter(val) + } catch (ex) { + log(ex) + } + } + }) + bound('datasetchanged', function(e) { + if (e.bubble === 'selectDuplex') { + var value = binding._value + var curValue = Array.isArray(value) ? value.map(String) : value + '' + Anot(elem).val(curValue) + elem.oldValue = curValue + '' + callback.call(elem, curValue) + } + }) + break + } + if (binding.xtype === 'input' && !rnoduplexInput.test(elem.type)) { + if (elem.type !== 'hidden') { + bound('focus', function() { + elem.msFocus = true + }) + bound('blur', function() { + elem.msFocus = false + }) + } + elem.anotSetter = updateVModel //#765 + watchValueInTimer(function() { + if (root.contains(elem)) { + if (!elem.msFocus) { + updateVModel() + } + } else if (!elem.msRetain) { + return false + } + }) + } + }, + update: function(value) { + var elem = this.element, + binding = this, + curValue + if (!this.init) { + var cpipe = binding.pipe || (binding.pipe = pipe) + cpipe(null, binding, 'init') + this.init = 1 + } + switch (this.xtype) { + case 'input': + elem.value = value + break + case 'change': + curValue = this.pipe( + value, + this, + 'set' + ) //fix #673 + if (curValue !== this.oldValue) { + var fixCaret = false + if (elem.msFocus) { + try { + var start = elem.selectionStart + var end = elem.selectionEnd + if (start === end) { + var pos = start + fixCaret = true + } + } catch (e) {} + } + elem.value = this.oldValue = curValue + if (fixCaret && !elem.readOnly) { + elem.selectionStart = elem.selectionEnd = pos + } + } + break + case 'radio': + curValue = binding.isChecked ? !!value : value + '' === elem.value + elem.checked = curValue + break + case 'checkbox': + var array = [].concat(value) //强制转换为数组 + curValue = this.pipe( + elem.value, + this, + 'get' + ) + elem.checked = array.indexOf(curValue) > -1 + break + case 'select': + //必须变成字符串后才能比较 + binding._value = value + if (!elem.msHasEvent) { + elem.msHasEvent = 'selectDuplex' + //必须等到其孩子准备好才触发 + } else { + Anot.fireDom(elem, 'datasetchanged', { + bubble: elem.msHasEvent + }) + } + break + } + } +}) + +function fixNull(val) { + return val == null ? '' : val +} +Anot.duplexHooks = { + checked: { + get: function(val, binding) { + return !binding.oldValue + } + }, + string: { + get: function(val) { + //同步到VM + return val + }, + set: fixNull + }, + boolean: { + get: function(val) { + return val === 'true' + }, + set: fixNull + }, + number: { + get: function(val, binding) { + var number = +val + if (+val === number) { + return number + } + return 0 + }, + set: fixNull + } +} + +function pipe(val, binding, action, e) { + binding.param.replace(rw20g, function(name) { + var hook = Anot.duplexHooks[name] + if (hook && typeof hook[action] === 'function') { + val = hook[action](val, binding) + } + }) + return val +} + +var TimerID, + ribbon = [] + +Anot.tick = function(fn) { + if (ribbon.push(fn) === 1) { + TimerID = setInterval(ticker, 60) + } +} + +function ticker() { + for (var n = ribbon.length - 1; n >= 0; n--) { + var el = ribbon[n] + if (el() === false) { + ribbon.splice(n, 1) + } + } + if (!ribbon.length) { + clearInterval(TimerID) + } +} + +var watchValueInTimer = noop +new function() { + // jshint ignore:line + try { + //#272 IE9-IE11, firefox + var setters = {} + var aproto = HTMLInputElement.prototype + var bproto = HTMLTextAreaElement.prototype + function newSetter(value) { + // jshint ignore:line + setters[this.tagName].call(this, value) + if (!this.msFocus && this.anotSetter) { + this.anotSetter() + } + } + var inputProto = HTMLInputElement.prototype + Object.getOwnPropertyNames(inputProto) //故意引发IE6-8等浏览器报错 + setters['INPUT'] = Object.getOwnPropertyDescriptor(aproto, 'value').set + + Object.defineProperty(aproto, 'value', { + set: newSetter + }) + setters['TEXTAREA'] = Object.getOwnPropertyDescriptor(bproto, 'value').set + Object.defineProperty(bproto, 'value', { + set: newSetter + }) + } catch (e) { + //在chrome 43中 :duplex终于不需要使用定时器实现双向绑定了 + // http://updates.html5rocks.com/2015/04/DOM-attributes-now-on-the-prototype + // https://docs.google.com/document/d/1jwA8mtClwxI-QJuHT7872Z0pxpZz8PBkf2bGAbsUtqs/edit?pli=1 + watchValueInTimer = Anot.tick + } +}() // jshint ignore:line +/*-------------动画------------*/ + +Anot.directive('effect', { + priority: 5, + init: function(binding) { + var text = binding.expr, + className, + rightExpr + var colonIndex = text + .replace(rexprg, function(a) { + return a.replace(/./g, '0') + }) + .indexOf(':') //取得第一个冒号的位置 + if (colonIndex === -1) { + // 比如 :class/effect="aaa bbb ccc" 的情况 + className = text + rightExpr = true + } else { + // 比如 :class/effect-1="ui-state-active:checked" 的情况 + className = text.slice(0, colonIndex) + rightExpr = text.slice(colonIndex + 1) + } + if (!rexpr.test(text)) { + className = quote(className) + } else { + className = normalizeExpr(className) + } + binding.expr = '[' + className + ',' + rightExpr + ']' + }, + update: function(arr) { + var name = arr[0] + var elem = this.element + if (elem.getAttribute('data-effect-name') === name) { + return + } else { + elem.removeAttribute('data-effect-driver') + } + var inlineStyles = elem.style + var computedStyles = window.getComputedStyle + ? window.getComputedStyle(elem) + : null + var useAni = false + if (computedStyles && (supportTransition || supportAnimation)) { + //如果支持CSS动画 + var duration = + inlineStyles[transitionDuration] || computedStyles[transitionDuration] + if (duration && duration !== '0s') { + elem.setAttribute('data-effect-driver', 't') + useAni = true + } + + if (!useAni) { + duration = + inlineStyles[animationDuration] || computedStyles[animationDuration] + if (duration && duration !== '0s') { + elem.setAttribute('data-effect-driver', 'a') + useAni = true + } + } + } + + if (!useAni) { + if (Anot.effects[name]) { + elem.setAttribute('data-effect-driver', 'j') + useAni = true + } + } + if (useAni) { + elem.setAttribute('data-effect-name', name) + } + } +}) + +Anot.effects = {} +Anot.effect = function(name, callbacks) { + Anot.effects[name] = callbacks +} + +var supportTransition = false +var supportAnimation = false + +var transitionEndEvent +var animationEndEvent +var transitionDuration = Anot.cssName('transition-duration') +var animationDuration = Anot.cssName('animation-duration') +new function() { + // jshint ignore:line + var checker = { + TransitionEvent: 'transitionend', + WebKitTransitionEvent: 'webkitTransitionEnd', + OTransitionEvent: 'oTransitionEnd', + otransitionEvent: 'otransitionEnd' + } + var tran + //有的浏览器同时支持私有实现与标准写法,比如webkit支持前两种,Opera支持1、3、4 + for (var name in checker) { + if (window[name]) { + tran = checker[name] + break + } + try { + var a = document.createEvent(name) + tran = checker[name] + break + } catch (e) {} + } + if (typeof tran === 'string') { + supportTransition = true + transitionEndEvent = tran + } + + //大致上有两种选择 + //IE10+, Firefox 16+ & Opera 12.1+: animationend + //Chrome/Safari: webkitAnimationEnd + //http://blogs.msdn.com/b/davrous/archive/2011/12/06/introduction-to-css3-animat ions.aspx + //IE10也可以使用MSAnimationEnd监听,但是回调里的事件 type依然为animationend + // el.addEventListener("MSAnimationEnd", function(e) { + // alert(e.type)// animationend!!! + // }) + checker = { + AnimationEvent: 'animationend', + WebKitAnimationEvent: 'webkitAnimationEnd' + } + var ani + for (name in checker) { + if (window[name]) { + ani = checker[name] + break + } + } + if (typeof ani === 'string') { + supportTransition = true + animationEndEvent = ani + } +}() + +var effectPool = [] //重复利用动画实例 +function effectFactory(el, opts) { + if (!el || el.nodeType !== 1) { + return null + } + if (opts) { + var name = opts.effectName + var driver = opts.effectDriver + } else { + name = el.getAttribute('data-effect-name') + driver = el.getAttribute('data-effect-driver') + } + if (!name || !driver) { + return null + } + + var instance = effectPool.pop() || new Effect() + instance.el = el + instance.driver = driver + instance.useCss = driver !== 'j' + if (instance.useCss) { + opts && Anot(el).addClass(opts.effectClass) + instance.cssEvent = driver === 't' ? transitionEndEvent : animationEndEvent + } + instance.name = name + instance.callbacks = Anot.effects[name] || {} + + return instance +} + +function effectBinding(elem, binding) { + var name = elem.getAttribute('data-effect-name') + if (name) { + binding.effectName = name + binding.effectDriver = elem.getAttribute('data-effect-driver') + var stagger = +elem.getAttribute('data-effect-stagger') + binding.effectLeaveStagger = + +elem.getAttribute('data-effect-leave-stagger') || stagger + binding.effectEnterStagger = + +elem.getAttribute('data-effect-enter-stagger') || stagger + binding.effectClass = elem.className || NaN + } +} +function upperFirstChar(str) { + return str.replace(/^[\S]/g, function(m) { + return m.toUpperCase() + }) +} +var effectBuffer = new Buffer() +function Effect() {} //动画实例,做成类的形式,是为了共用所有原型方法 + +Effect.prototype = { + contrustor: Effect, + enterClass: function() { + return getEffectClass(this, 'enter') + }, + leaveClass: function() { + return getEffectClass(this, 'leave') + }, + // 共享一个函数 + actionFun: function(name, before, after) { + if (document.hidden) { + return + } + var me = this + var el = me.el + var isLeave = name === 'leave' + name = isLeave ? 'leave' : 'enter' + var oppositeName = isLeave ? 'enter' : 'leave' + callEffectHook(me, 'abort' + upperFirstChar(oppositeName)) + callEffectHook(me, 'before' + upperFirstChar(name)) + if (!isLeave) before(el) //这里可能做插入DOM树的操作,因此必须在修改类名前执行 + var cssCallback = function(cancel) { + el.removeEventListener(me.cssEvent, me.cssCallback) + if (isLeave) { + before(el) //这里可能做移出DOM树操作,因此必须位于动画之后 + Anot(el).removeClass(me.cssClass) + } else { + if (me.driver === 'a') { + Anot(el).removeClass(me.cssClass) + } + } + if (cancel !== true) { + callEffectHook(me, 'after' + upperFirstChar(name)) + after && after(el) + } + me.dispose() + } + if (me.useCss) { + if (me.cssCallback) { + //如果leave动画还没有完成,立即完成 + me.cssCallback(true) + } + + me.cssClass = getEffectClass(me, name) + me.cssCallback = cssCallback + + me.update = function() { + el.addEventListener(me.cssEvent, me.cssCallback) + if (!isLeave && me.driver === 't') { + //transtion延迟触发 + Anot(el).removeClass(me.cssClass) + } + } + Anot(el).addClass(me.cssClass) //animation会立即触发 + + effectBuffer.render(true) + effectBuffer.queue.push(me) + } else { + callEffectHook(me, name, cssCallback) + } + }, + enter: function(before, after) { + this.actionFun.apply(this, ['enter'].concat(Anot.slice(arguments))) + }, + leave: function(before, after) { + this.actionFun.apply(this, ['leave'].concat(Anot.slice(arguments))) + }, + dispose: function() { + //销毁与回收到池子中 + this.update = this.cssCallback = null + if (effectPool.unshift(this) > 100) { + effectPool.pop() + } + } +} + +function getEffectClass(instance, type) { + var a = instance.callbacks[type + 'Class'] + if (typeof a === 'string') return a + if (typeof a === 'function') return a() + return instance.name + '-' + type +} + +function callEffectHook(effect, name, cb) { + var hook = effect.callbacks[name] + if (hook) { + hook.call(effect, effect.el, cb) + } +} + +var applyEffect = function(el, dir /*[before, [after, [opts]]]*/) { + var args = aslice.call(arguments, 0) + if (typeof args[2] !== 'function') { + args.splice(2, 0, noop) + } + if (typeof args[3] !== 'function') { + args.splice(3, 0, noop) + } + var before = args[2] + var after = args[3] + var opts = args[4] + var effect = effectFactory(el, opts) + if (!effect) { + before() + after() + return false + } else { + var method = dir ? 'enter' : 'leave' + effect[method](before, after) + } +} + +Anot.mix(Anot.effect, { + apply: applyEffect, + append: function(el, _parent, after, opts) { + return applyEffect( + el, + 1, + function() { + _parent.appendChild(el) + }, + after, + opts + ) + }, + before: function(el, target, after, opts) { + return applyEffect( + el, + 1, + function() { + target.parentNode.insertBefore(el, target) + }, + after, + opts + ) + }, + remove: function(el, _parent, after, opts) { + return applyEffect( + el, + 0, + function() { + if (el.parentNode === _parent) _parent.removeChild(el) + }, + after, + opts + ) + } +}) +Anot.directive('html', { + update: function(val) { + var binding = this + var elem = this.element + var isHtmlFilter = elem.nodeType !== 1 + var _parent = isHtmlFilter ? elem.parentNode : elem + if (!_parent) return + val = val == null ? '' : val + + if (elem.nodeType === 3) { + var signature = generateID('html') + _parent.insertBefore(DOC.createComment(signature), elem) + binding.element = DOC.createComment(signature + ':end') + _parent.replaceChild(binding.element, elem) + elem = binding.element + } + if (typeof val !== 'object') { + //string, number, boolean + var fragment = Anot.parseHTML(String(val)) + } else if (val.nodeType === 11) { + //将val转换为文档碎片 + fragment = val + } else if (val.nodeType === 1 || val.item) { + var nodes = val.nodeType === 1 ? val.childNodes : val.item + fragment = anotFragment.cloneNode(true) + while (nodes[0]) { + fragment.appendChild(nodes[0]) + } + } + + nodes = Anot.slice(fragment.childNodes) + //插入占位符, 如果是过滤器,需要有节制地移除指定的数量,如果是html指令,直接清空 + if (isHtmlFilter) { + var endValue = elem.nodeValue.slice(0, -4) + while (true) { + var node = elem.previousSibling + if (!node || (node.nodeType === 8 && node.nodeValue === endValue)) { + break + } else { + _parent.removeChild(node) + } + } + _parent.insertBefore(fragment, elem) + } else { + Anot.clearHTML(elem).appendChild(fragment) + } + scanNodeArray(nodes, binding.vmodels) + } +}) +Anot.directive('text', { + update: function(val) { + var elem = this.element + val = val == null ? '' : val //不在页面上显示undefined null + if (elem.nodeType === 3) { + //绑定在文本节点上 + try { + //IE对游离于DOM树外的节点赋值会报错 + elem.data = val + } catch (e) {} + } else { + //绑定在特性节点上 + elem.textContent = val + } + } +}) +Anot.directive('if', { + priority: 10, + update: function(val) { + var binding = this + var elem = this.element + var stamp = (binding.stamp = Date.now()) + var par + var after = function() { + if (stamp !== binding.stamp) { + return + } + binding.recoverNode = null + } + if (binding.recoverNode) { + binding.recoverNode() // 还原现场,有移动节点的都需要还原现场 + } + + try { + if (!elem.parentNode) return + par = elem.parentNode + } catch (e) { + return + } + if (val) { + //插回DOM树 + function alway() { + // jshint ignore:line + if (elem.getAttribute(binding.name)) { + elem.removeAttribute(binding.name) + scanAttr(elem, binding.vmodels) + } + binding.rollback = null + } + if (elem.nodeType === 8) { + var keep = binding.keep + var hasEffect = Anot.effect.apply( + keep, + 1, + function() { + if (stamp !== binding.stamp) return + elem.parentNode.replaceChild(keep, elem) + elem = binding.element = keep //这时可能为null + if (keep.getAttribute('_required')) { + //#1044 + elem.required = true + elem.removeAttribute('_required') + } + if (elem.querySelectorAll) { + Anot.each(elem.querySelectorAll('[_required=true]'), function( + el + ) { + el.required = true + el.removeAttribute('_required') + }) + } + alway() + }, + after + ) + hasEffect = hasEffect === false + } + if (!hasEffect) alway() + } else { + //移出DOM树,并用注释节点占据原位置 + if (elem.nodeType === 1) { + if (elem.required === true) { + elem.required = false + elem.setAttribute('_required', 'true') + } + try { + //如果不支持querySelectorAll或:required,可以直接无视 + Anot.each(elem.querySelectorAll(':required'), function(el) { + elem.required = false + el.setAttribute('_required', 'true') + }) + } catch (e) {} + + var node = (binding.element = DOC.createComment(':if')), + pos = elem.nextSibling + binding.recoverNode = function() { + binding.recoverNode = null + if (node.parentNode !== par) { + par.insertBefore(node, pos) + binding.keep = elem + } + } + + Anot.effect.apply( + elem, + 0, + function() { + binding.recoverNode = null + if (stamp !== binding.stamp) return + elem.parentNode.replaceChild(node, elem) + binding.keep = elem //元素节点 + ifGroup.appendChild(elem) + binding.rollback = function() { + if (elem.parentNode === ifGroup) { + ifGroup.removeChild(elem) + } + } + }, + after + ) + } + } + } +}) +//将所有远程加载的模板,以字符串形式存放到这里 +var templatePool = (Anot.templateCache = {}) + +function getTemplateContainer(binding, id, text) { + var div = binding.templateCache && binding.templateCache[id] + if (div) { + var dom = DOC.createDocumentFragment(), + firstChild + while ((firstChild = div.firstChild)) { + dom.appendChild(firstChild) + } + return dom + } + return Anot.parseHTML(text) +} +function nodesToFrag(nodes) { + var frag = DOC.createDocumentFragment() + for (var i = 0, len = nodes.length; i < len; i++) { + frag.appendChild(nodes[i]) + } + return frag +} +Anot.directive('include', { + init: directives.attr.init, + update: function(val) { + if (!val) { + return + } + + var binding = this + var elem = this.element + var vmodels = binding.vmodels + var loaded = binding.includeLoaded // 加载完的回调 + var rendered = binding.includeRendered // 渲染完的回调 + var effectClass = binding.effectName && binding.effectClass // 是否开启动画 + var templateCache = binding.templateCache // 是否开启 缓存 + var outer = binding.includeReplace // 是否替换容器 + var target = outer ? elem.parentNode : elem + var _ele = binding._element // replace binding.element === binding.end + + binding.recoverNodes = binding.recoverNodes || Anot.noop + + var scanTemplate = function(text) { + var _stamp = (binding._stamp = Date.now()) // 过滤掉频繁操作 + if (loaded) { + var newText = loaded.apply(target, [text].concat(vmodels)) + if (typeof newText === 'string') { + text = newText + } + } + if (rendered) { + checkScan( + target, + function() { + rendered.call(target) + }, + NaN + ) + } + var lastID = binding.includeLastID || '_default' // 默认 + + binding.includeLastID = val + var leaveEl = + (templateCache && templateCache[lastID]) || + DOC.createElement(elem.tagName || binding._element.tagName) // 创建一个离场元素 + + if (effectClass) { + leaveEl.className = effectClass + target.insertBefore(leaveEl, binding.start) // 插入到start之前,防止被错误的移动 + } + + // cache or animate,移动节点 + ;(templateCache || {})[lastID] = leaveEl + var fragOnDom = binding.recoverNodes() // 恢复动画中的节点 + if (fragOnDom) { + target.insertBefore(fragOnDom, binding.end) + } + while (true) { + var node = binding.start.nextSibling + if (node && node !== leaveEl && node !== binding.end) { + leaveEl.appendChild(node) + } else { + break + } + } + + // 元素退场 + Anot.effect.remove( + leaveEl, + target, + function() { + if (templateCache) { + // write cache + if (_stamp === binding._stamp) ifGroup.appendChild(leaveEl) + } + }, + binding + ) + + var enterEl = target, + before = Anot.noop, + after = Anot.noop + + var fragment = getTemplateContainer(binding, val, text) + var nodes = Anot.slice(fragment.childNodes) + + if (outer && effectClass) { + enterEl = _ele + enterEl.innerHTML = '' // 清空 + enterEl.setAttribute('skip', '') + target.insertBefore(enterEl, binding.end.nextSibling) // 插入到bingding.end之后避免被错误的移动 + before = function() { + enterEl.insertBefore(fragment, null) // 插入节点 + } + after = function() { + binding.recoverNodes = Anot.noop + if (_stamp === binding._stamp) { + fragment = nodesToFrag(nodes) + target.insertBefore(fragment, binding.end) // 插入真实element + scanNodeArray(nodes, vmodels) + } + if (enterEl.parentNode === target) target.removeChild(enterEl) // 移除入场动画元素 + } + binding.recoverNodes = function() { + binding.recoverNodes = Anot.noop + return nodesToFrag(nodes) + } + } else { + before = function() { + //新添加元素的动画 + target.insertBefore(fragment, binding.end) + scanNodeArray(nodes, vmodels) + } + } + + Anot.effect.apply(enterEl, 'enter', before, after) + } + + if (templatePool[val]) { + Anot.nextTick(function() { + scanTemplate(templatePool[val]) + }) + } else { + fetch(val, { + method: 'get', + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + if (res.status >= 200 && res.status < 300) { + return res.text() + } else { + return Promise.reject( + `获取网络资源出错, ${res.status} (${res.statusText})` + ) + } + }) + .then(text => { + templatePool[val] = text + scanTemplate(text) + }) + .catch(err => { + log(':include load [' + val + '] error\n%c%s', 'color:#f30', err) + }) + } + } +}) +var rdash = /\(([^)]*)\)/ +var onDir = Anot.directive('on', { + priority: 3000, + init: function(binding) { + var value = binding.expr + binding.type = 'on' + var eventType = binding.param.replace(/-\d+$/, '') // :on-mousemove-10 + if (typeof onDir[eventType + 'Hook'] === 'function') { + onDir[eventType + 'Hook'](binding) + } + if (value.indexOf('(') > 0 && value.indexOf(')') > -1) { + var matched = (value.match(rdash) || ['', ''])[1].trim() + if (matched === '' || matched === '$event') { + // aaa() aaa($event)当成aaa处理 + value = value.replace(rdash, '') + } + } + binding.expr = value + }, + update: function(callback) { + var binding = this + var elem = this.element + callback = function(e) { + var fn = binding.getter || noop + return fn.apply(binding.args[0], binding.args.concat(e)) + } + + var eventType = binding.param.replace(/-\d+$/, '') // :on-mousemove-10 + if (eventType === 'scan') { + callback.call(elem, { + type: eventType + }) + } else if (typeof binding.specialBind === 'function') { + binding.specialBind(elem, callback) + } else { + var removeFn = Anot.bind(elem, eventType, callback) + } + binding.rollback = function() { + if (typeof binding.specialUnbind === 'function') { + binding.specialUnbind() + } else { + Anot.unbind(elem, eventType, removeFn) + } + } + } +}) +Anot.directive('for', { + priority: 90, + init: function(binding) { + var type = binding.type + binding.cache = {} //用于存放代理VM + binding.enterCount = 0 + + var elem = binding.element + if (elem.nodeType === 1) { + var vars = binding.expr.split(' in ') + binding.expr = vars.pop() + if (vars.length) { + vars = vars.pop().split(/\s+/) + } + binding.vars = vars + elem.removeAttribute(binding.name) + effectBinding(elem, binding) + var rendered = getBindingCallback(elem, 'data-rendered', binding.vmodels) + + var signature = generateID(type) + var start = DOC.createComment(signature + ':start') + var end = (binding.element = DOC.createComment(signature + ':end')) + binding.signature = signature + binding.start = start + binding.template = anotFragment.cloneNode(false) + + var _parent = elem.parentNode + _parent.replaceChild(end, elem) + _parent.insertBefore(start, end) + binding.template.appendChild(elem) + + binding.element = end + + if (rendered) { + var removeFn = Anot.bind(_parent, 'datasetchanged', function() { + rendered.apply(_parent, _parent.args) + Anot.unbind(_parent, 'datasetchanged', removeFn) + _parent.msRendered = rendered + }) + } + } + }, + update: function(value, oldValue) { + var binding = this + var xtype = this.xtype + + if (xtype === 'array') { + if (!this.vars.length) { + this.vars.push('$index', 'el') + } else if (this.vars.length === 1) { + this.vars.unshift('$index') + } + this.param = this.vars[1] + } else { + this.param = '__el__' + if (!this.vars.length) { + this.vars.push('$key', '$val') + } else if (this.vars.length === 1) { + this.vars.push('$val') + } + } + + this.enterCount += 1 + var init = !oldValue + if (init) { + binding.$outer = {} + var check0 = this.vars[0] + var check1 = this.vars[1] + if (xtype === 'array') { + check0 = '$first' + check1 = '$last' + } + for (var i = 0, v; (v = binding.vmodels[i++]); ) { + if (v.hasOwnProperty(check0) && v.hasOwnProperty(check1)) { + binding.$outer = v + break + } + } + } + var track = this.track + var action = 'move' + binding.$repeat = value + var fragments = [] + var transation = init && anotFragment.cloneNode(false) + var proxies = [] + var param = this.param + var retain = Anot.mix({}, this.cache) + var elem = this.element + var length = track.length + + var _parent = elem.parentNode + + //检查新元素数量 + var newCount = 0 + for (i = 0; i < length; i++) { + var keyOrId = track[i] + if (!retain[keyOrId]) newCount++ + } + var oldCount = 0 + for (i in retain) { + oldCount++ + } + var clear = (!length || newCount === length) && oldCount > 10 //当全部是新元素,且移除元素较多(10)时使用clear + + var kill = elem.previousSibling + var start = binding.start + + if (clear) { + while (kill !== start) { + _parent.removeChild(kill) + kill = elem.previousSibling + } + } + + for (i = 0; i < length; i++) { + keyOrId = track[i] //array为随机数, object 为keyName + var proxy = retain[keyOrId] + if (!proxy) { + // log(this) + proxy = getProxyVM(this) + proxy.$up = this.vmodels[0] + if (xtype === 'array') { + action = 'add' + proxy.$id = keyOrId + var valueItem = value[i] + proxy[param] = valueItem //index + if (Object(valueItem) === valueItem) { + hideProperty(valueItem, '$ups', valueItem.$ups || {}) + valueItem.$ups[param] = proxy + } + } else { + action = 'append' + proxy[check0] = keyOrId + proxy[check1] = value[keyOrId] //key + var tmp = {} + tmp[check0] = proxy[check0] + tmp[check1] = proxy[check1] + proxy[param] = tmp + } + this.cache[keyOrId] = proxy + var node = proxy.$anchor || (proxy.$anchor = elem.cloneNode(false)) + node.nodeValue = this.signature + shimController( + binding, + transation, + proxy, + fragments, + init && !binding.effectDriver + ) + decorateProxy(proxy, binding, xtype) + } else { + fragments.push({}) + retain[keyOrId] = true + } + + //重写proxy + if (this.enterCount === 1) { + //防止多次进入,导致位置不对 + proxy.$active = false + proxy.$oldIndex = proxy.$index + proxy.$active = true + proxy.$index = i + } + + if (xtype === 'array') { + proxy.$first = i === 0 + proxy.$last = i === length - 1 + proxy[this.vars[0]] = proxy.$index + } else { + proxy[check1] = toJson(value[keyOrId]) //这里是处理vm.object = newObject的情况 + } + proxies.push(proxy) + } + this.proxies = proxies + if (init && !binding.effectDriver) { + _parent.insertBefore(transation, elem) + fragments.forEach(function(fragment) { + scanNodeArray(fragment.nodes || [], fragment.vmodels) + //if(fragment.vmodels.length > 2) + fragment.nodes = fragment.vmodels = null + }) // jshint ignore:line + } else { + var staggerIndex = (binding.staggerIndex = 0) + for (keyOrId in retain) { + if (retain[keyOrId] !== true) { + action = 'del' + !clear && removeItem(retain[keyOrId].$anchor, binding, true) + // 相当于delete binding.cache[key] + proxyRecycler(this.cache, keyOrId, param) + retain[keyOrId] = null + } + } + + for (i = 0; i < length; i++) { + proxy = proxies[i] + keyOrId = xtype === 'array' ? proxy.$id : proxy.$key + var pre = proxies[i - 1] + var preEl = pre ? pre.$anchor : binding.start + if (!retain[keyOrId]) { + //如果还没有插入到DOM树,进行插入动画 + ;(function(fragment, preElement) { + var nodes = fragment.nodes + var vmodels = fragment.vmodels + if (nodes) { + staggerIndex = mayStaggerAnimate( + binding.effectEnterStagger, + function() { + _parent.insertBefore(fragment.content, preElement.nextSibling) + scanNodeArray(nodes, vmodels) + !init && animateRepeat(nodes, 1, binding) + }, + staggerIndex + ) + } + fragment.nodes = fragment.vmodels = null + })(fragments[i], preEl) // jshint ignore:line + } else if (proxy.$index !== proxy.$oldIndex) { + //进行移动动画 + ;(function(proxy2, preElement) { + staggerIndex = mayStaggerAnimate( + binding.effectEnterStagger, + function() { + var curNode = removeItem(proxy2.$anchor) + var inserted = Anot.slice(curNode.childNodes) + _parent.insertBefore(curNode, preElement.nextSibling) + animateRepeat(inserted, 1, binding) + }, + staggerIndex + ) + })(proxy, preEl) // jshint ignore:line + } + } + } + if (!value.$track) { + //如果是非监控对象,那么就将其$events清空,阻止其持续监听 + for (keyOrId in this.cache) { + proxyRecycler(this.cache, keyOrId, param) + } + } + + // :for --> duplex + ;(function(args) { + _parent.args = args + if (_parent.msRendered) { + //第一次事件触发,以后直接调用 + _parent.msRendered.apply(_parent, args) + } + })(kernel.newWatch ? arguments : [action]) + var id = setTimeout(function() { + clearTimeout(id) + //触发上层的select回调及自己的rendered回调 + Anot.fireDom(_parent, 'datasetchanged', { + bubble: _parent.msHasEvent + }) + }) + this.enterCount -= 1 + } +}) + +function animateRepeat(nodes, isEnter, binding) { + for (var i = 0, node; (node = nodes[i++]); ) { + if (node.className === binding.effectClass) { + Anot.effect.apply(node, isEnter, noop, noop, binding) + } + } +} + +function mayStaggerAnimate(staggerTime, callback, index) { + if (staggerTime) { + setTimeout(callback, ++index * staggerTime) + } else { + callback() + } + return index +} + +function removeItem(node, binding, flagRemove) { + var fragment = anotFragment.cloneNode(false) + var last = node + var breakText = last.nodeValue + var staggerIndex = binding && Math.max(+binding.staggerIndex, 0) + var nodes = Anot.slice(last.parentNode.childNodes) + var index = nodes.indexOf(last) + while (true) { + var pre = nodes[--index] //node.previousSibling + if (!pre || String(pre.nodeValue).indexOf(breakText) === 0) { + break + } + if (!flagRemove && binding && pre.className === binding.effectClass) { + node = pre + ;(function(cur) { + binding.staggerIndex = mayStaggerAnimate( + binding.effectLeaveStagger, + function() { + Anot.effect.apply( + cur, + 0, + noop, + function() { + fragment.appendChild(cur) + }, + binding + ) + }, + staggerIndex + ) + })(pre) // jshint ignore:line + } else { + fragment.insertBefore(pre, fragment.firstChild) + } + } + fragment.appendChild(last) + return fragment +} + +function shimController(data, transation, proxy, fragments, init) { + var content = data.template.cloneNode(true) + var nodes = Anot.slice(content.childNodes) + content.appendChild(proxy.$anchor) + init && transation.appendChild(content) + var itemName = data.param || 'el' + var valueItem = proxy[itemName], + nv + + nv = [proxy].concat(data.vmodels) + + var fragment = { + nodes: nodes, + vmodels: nv, + content: content + } + fragments.push(fragment) +} +// {} --> {xx: 0, yy: 1, zz: 2} add +// {xx: 0, yy: 1, zz: 2} --> {xx: 0, yy: 1, zz: 2, uu: 3} +// [xx: 0, yy: 1, zz: 2} --> {xx: 0, zz: 1, yy: 2} + +function getProxyVM(binding) { + var agent = binding.xtype === 'object' ? withProxyAgent : eachProxyAgent + var proxy = agent(binding) + var node = proxy.$anchor || (proxy.$anchor = binding.element.cloneNode(false)) + node.nodeValue = binding.signature + proxy.$outer = binding.$outer + return proxy +} + +function decorateProxy(proxy, binding, type) { + if (type === 'array') { + proxy.$remove = function() { + binding.$repeat.removeAt(proxy.$index) + } + var param = binding.param + proxy.$watch(param, function(val) { + var index = proxy.$index + binding.$repeat[index] = val + }) + } else { + var __k__ = binding.vars[0] + var __v__ = binding.vars[1] + proxy.$up.$watch(binding.expr + '.' + proxy[__k__], function(val) { + proxy[binding.param][__v__] = val + proxy[__v__] = val + }) + } +} + +var eachProxyPool = [] + +function eachProxyAgent(data, proxy) { + var itemName = data.param || 'el' + for (var i = 0, n = eachProxyPool.length; i < n; i++) { + var candidate = eachProxyPool[i] + if (candidate && candidate.hasOwnProperty(itemName)) { + eachProxyPool.splice(i, 1) + proxy = candidate + break + } + } + if (!proxy) { + proxy = eachProxyFactory(data) + } + return proxy +} + +function eachProxyFactory(data) { + var itemName = data.param || 'el' + var __k__ = data.vars[0] + var source = { + $outer: {}, + $index: 0, + $oldIndex: 0, + $anchor: null, + //----- + $first: false, + $last: false, + $remove: Anot.noop + } + source[__k__] = 0 + source[itemName] = NaN + var force = { + $last: 1, + $first: 1, + $index: 1 + } + force[__k__] = 1 + force[itemName] = 1 + var proxy = modelFactory( + { state: source }, + { + force: force + } + ) + proxy.$id = generateID('proxy-each') + return proxy +} + +var withProxyPool = [] + +function withProxyAgent(data) { + return withProxyPool.pop() || withProxyFactory(data) +} + +function withProxyFactory(data) { + var itemName = data.param || '__el__' + var __k__ = data.vars[0] + var __v__ = data.vars[1] + var source = { + $index: 0, + $oldIndex: 0, + $outer: {}, + $anchor: null + } + source[__k__] = '' + source[__v__] = NaN + source[itemName] = NaN + var force = { + __el__: 1, + $index: 1 + } + force[__k__] = 1 + force[__v__] = 1 + var proxy = modelFactory( + { state: source }, + { + force: force + } + ) + proxy.$id = generateID('proxy-with') + return proxy +} + +function proxyRecycler(cache, key, param) { + var proxy = cache[key] + if (proxy) { + var proxyPool = + proxy.$id.indexOf('proxy-each') === 0 ? eachProxyPool : withProxyPool + proxy.$outer = {} + + for (var i in proxy.$events) { + var a = proxy.$events[i] + if (Array.isArray(a)) { + a.length = 0 + if (i === param) { + proxy[param] = NaN + } else if (i === '$val') { + proxy.$val = NaN + } + } + } + + if (proxyPool.unshift(proxy) > kernel.maxRepeatSize) { + proxyPool.pop() + } + delete cache[key] + } +} +function parseDisplay(nodeName, val) { + //用于取得此类标签的默认display值 + var key = '_' + nodeName + if (!parseDisplay[key]) { + var node = DOC.createElement(nodeName) + root.appendChild(node) + + val = getComputedStyle(node, null).display + + root.removeChild(node) + parseDisplay[key] = val + } + return parseDisplay[key] +} + +Anot.parseDisplay = parseDisplay + +Anot.directive('visible', { + init: function(binding) { + effectBinding(binding.element, binding) + }, + update: function(val) { + var binding = this, + elem = this.element, + stamp + var noEffect = !this.effectName + if (!this.stamp) { + stamp = this.stamp = Date.now() + if (val) { + elem.style.display = binding.display || '' + if (Anot(elem).css('display') === 'none') { + elem.style.display = binding.display = parseDisplay(elem.nodeName) + } + } else { + elem.style.display = 'none' + } + return + } + stamp = this.stamp = +new Date() + if (val) { + Anot.effect.apply(elem, 1, function() { + if (stamp !== binding.stamp) return + var driver = elem.getAttribute('data-effect-driver') || 'a' + + if (noEffect) { + //不用动画时走这里 + elem.style.display = binding.display || '' + } + // "a", "t" + if (driver === 'a' || driver === 't') { + if (Anot(elem).css('display') === 'none') { + elem.style.display = binding.display || parseDisplay(elem.nodeName) + } + } + }) + } else { + Anot.effect.apply(elem, 0, function() { + if (stamp !== binding.stamp) return + elem.style.display = 'none' + }) + } + } +}) +/********************************************************************* + * 自带过滤器 * + **********************************************************************/ + +var rscripts = /]*>([\S\s]*?)<\/script\s*>/gim +var ron = /\s+(on[^=\s]+)(?:=("[^"]*"|'[^']*'|[^\s>]+))?/g +var ropen = /<\w+\b(?:(["'])[^"]*?(\1)|[^>])*>/gi +var rsanitize = { + a: /\b(href)\=("javascript[^"]*"|'javascript[^']*')/gi, + img: /\b(src)\=("javascript[^"]*"|'javascript[^']*')/gi, + form: /\b(action)\=("javascript[^"]*"|'javascript[^']*')/gi +} +var rsurrogate = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g +var rnoalphanumeric = /([^\#-~| |!])/g + +function numberFormat(number, decimals, point, thousands) { + //form http://phpjs.org/functions/number_format/ + //number 必需,要格式化的数字 + //decimals 可选,规定多少个小数位。 + //point 可选,规定用作小数点的字符串(默认为 . )。 + //thousands 可选,规定用作千位分隔符的字符串(默认为 , ),如果设置了该参数,那么所有其他参数都是必需的。 + number = (number + '').replace(/[^0-9+\-Ee.]/g, '') + var n = !isFinite(+number) ? 0 : +number, + prec = !isFinite(+decimals) ? 3 : Math.abs(decimals), + sep = thousands || ',', + dec = point || '.', + s = '', + toFixedFix = function(n, prec) { + var k = Math.pow(10, prec) + return '' + (Math.round(n * k) / k).toFixed(prec) + } + // Fix for IE parseFloat(0.55).toFixed(0) = 0; + s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.') + if (s[0].length > 3) { + s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep) + } + if ((s[1] || '').length < prec) { + s[1] = s[1] || '' + s[1] += new Array(prec - s[1].length + 1).join('0') + } + return s.join(dec) +} + +var filters = (Anot.filters = { + uppercase: function(str) { + return str.toUpperCase() + }, + lowercase: function(str) { + return str.toLowerCase() + }, + //字符串截取,超过指定长度以mark标识接上 + truncate: function(str, len, mark) { + len = len || 30 + mark = typeof mark === 'string' ? mark : '...' + return str.slice(0, len) + (str.length <= len ? '' : mark) + }, + //小值秒数转化为 时间格式 + time: function(str) { + str = str >> 0 + var s = str % 60 + var m = Math.floor(str / 60) + var h = Math.floor(m / 60) + m = m % 60 + m = m < 10 ? '0' + m : m + s = s < 10 ? '0' + s : s + + if (h > 0) { + h = h < 10 ? '0' + h : h + return h + ':' + m + ':' + s + } + return m + ':' + s + }, + $filter: function(val) { + for (var i = 1, n = arguments.length; i < n; i++) { + var array = arguments[i] + var fn = Anot.filters[array[0]] + if (typeof fn === 'function') { + var arr = [val].concat(array.slice(1)) + val = fn.apply(null, arr) + } + } + return val + }, + camelize: camelize, + //https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet + // chrome + // chrome + // IE67chrome + // IE67chrome + // IE67chrome + xss: function(str) { + return str.replace(rscripts, '').replace(ropen, function(a, b) { + var match = a.toLowerCase().match(/<(\w+)\s/) + if (match) { + //处理a标签的href属性,img标签的src属性,form标签的action属性 + var reg = rsanitize[match[1]] + if (reg) { + a = a.replace(reg, function(s, name, value) { + var quote = value.charAt(0) + return name + '=' + quote + 'javascript:void(0)' + quote // jshint ignore:line + }) + } + } + return a.replace(ron, ' ').replace(/\s+/g, ' ') //移除onXXX事件 + }) + }, + escape: function(str) { + //将字符串经过 str 转义得到适合在页面中显示的内容, 例如替换 < 为 < + return String(str) + .replace(/&/g, '&') + .replace(rsurrogate, function(value) { + var hi = value.charCodeAt(0) + var low = value.charCodeAt(1) + return '&#' + ((hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000) + ';' + }) + .replace(rnoalphanumeric, function(value) { + return '&#' + value.charCodeAt(0) + ';' + }) + .replace(//g, '>') + }, + currency: function(amount, symbol, fractionSize) { + return ( + (symbol || '\u00a5') + + numberFormat(amount, isFinite(fractionSize) ? fractionSize : 2) + ) + }, + number: numberFormat, + //日期格式化,类似php的date函数, + date: function(stamp, str) { + var oDate = stamp + + if (!Date.isDate(oDate)) { + var tmp = +oDate + if (tmp === tmp) { + oDate = tmp + } + + oDate = new Date(oDate) + if (oDate.toString() === 'Invalid Date') { + return 'Invalid Date' + } + } + return oDate.format(str) + } +}) + + +/********************************************************************* + * DOMReady * + **********************************************************************/ + + let readyList = [] + let isReady + let fireReady = function(fn) { + isReady = true + while ((fn = readyList.shift())) { + fn(Anot) + } + } + + if (DOC.readyState === 'complete') { + setTimeout(fireReady) //如果在domReady之外加载 + } else { + DOC.addEventListener('DOMContentLoaded', fireReady) + } + window.addEventListener('load', fireReady) + Anot.ready = function(fn) { + if (!isReady) { + readyList.push(fn) + } else { + fn(Anot) + } + } + window.Anot = Anot + return Anot +})() +export default _Anot diff --git a/src/lib/avatar/index.js b/src/lib/avatar/index.js index 19e4797..e43cf17 100644 --- a/src/lib/avatar/index.js +++ b/src/lib/avatar/index.js @@ -1 +1,15 @@ -"use strict";function arraySum(t){var e=0;return t.forEach(function(t){e+=+t}),e}export const create=(t,e)=>{if(!t)return this.defafultImg;(!e||e<100)&&(e=100);var l,a=document.createElement("canvas"),r=a.getContext("2d"),c=t.slice(-3),i=t.slice(-9,-6),f=t.slice(0,8).match(/([\w]{1})/g),n=t.slice(8,16).match(/([\w]{1})/g),s=t.slice(16,24).match(/([\w]{1})/g),m=e/10;a.width=e,a.height=e,f=f.map(t=>(t=parseInt(t,16))%8),n=n.map(t=>(t=parseInt(t,16))%4),s=s.map(t=>(t=parseInt(t,16))%4),l=arraySum(f)>32?c:i,r.fillStyle="#"+c,r.fillRect(0,0,e,e);for(var u=1;u<9;u++){var o=f[u-1],h=n[u-1],p=s[u-1];o+h>8&&(o=8-h),r.fillStyle="#"+i,r.fillRect((h+1)*m,u*m,o*m,m),r.fillStyle="#"+i,r.fillRect((9-h-o)*m,u*m,o*m,m),r.fillStyle="#"+l,r.fillRect((p+1)*m,u*m,m,m),r.fillStyle="#"+l,r.fillRect((8-p)*m,u*m,m,m)}return a.toDataURL()}; \ No newline at end of file +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +const COLORS=["#3fc2a7","#58d68d","#ac61ce","#66b1ff","#ff5061","#ffb618","#62778d"],COLOR_NAME=["teal","green","purple","blue","red","orange","dark"];var canvas=document.createElement("canvas"),ctx=canvas.getContext("2d"),size=500;function sum(e){var t=0;return e.forEach(e=>t+=e),t}function createImage(e){if(!e)return"./def.jpg";var t,s=COLORS[parseInt(e.slice(-1),16)%7],r=e.slice(0,8).split(""),i=e.slice(8,16).split(""),o=e.slice(16,24).split(""),a=size/10;r=r.map(e=>(e=parseInt(e,16))%8),i=i.map(e=>(e=parseInt(e,16))%4),o=o.map(e=>(e=parseInt(e,16))%4),t=sum(r)>32?s:"#fff",ctx.fillStyle=s,ctx.fillRect(0,0,size,size);for(var c=1;c<9;c++){var l=r[c-1],n=i[c-1],h=o[c-1];l+n>8&&(l=8-n),ctx.fillStyle="#fff",ctx.fillRect((n+1)*a,c*a,l*a,a),ctx.fillStyle="#fff",ctx.fillRect((9-n-l)*a,c*a,l*a,a),ctx.fillStyle=t,ctx.fillRect((h+1)*a,c*a,a,a),ctx.fillStyle=t,ctx.fillRect((8-h)*a,c*a,a,a)}return canvas.toDataURL("image/webp")}canvas.width=size,canvas.height=size;export default class Avatar extends HTMLElement{static get observedAttributes(){return["hash","src","fit"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{hash:"",src:"",fit:""},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__IMG__=this.root.lastElementChild;var e=this.textContent.slice(0,1);this.setAttribute("color",COLOR_NAME[e.charCodeAt(0)%7]),this.textContent=e}attributeChangedCallback(e,t,s){if(t!==s)switch(e){case"src":this.removeAttribute("hash"),this.__IMG__.src=s||"./def.jpg";break;case"hash":this.removeAttribute("src"),this.__IMG__.src=createImage(s);break;case"fit":s&&(this.__IMG__.style["object-fit"]=s)}}}; + +if(!customElements.get('wc-avatar')){ + customElements.define('wc-avatar', Avatar) +} diff --git a/src/lib/drag/core.js b/src/lib/drag/core.js new file mode 100644 index 0000000..0a4dcd9 --- /dev/null +++ b/src/lib/drag/core.js @@ -0,0 +1 @@ +"use strict";import{bind,unbind}from"../utils.js";const DEF_OPT={axis:"",limit:!1,overflow:!0};export default class Drag{constructor(t){this.$elem=t,this._init()}_init(){this.$elem.style.transform="";var{x:t,y:s}=this.$elem.getBoundingClientRect();this.pos={x:t,y:s,_x:0,_y:0}}by(t,s={}){this.$drag=t,this.opt=Object.assign(Object.create(null),DEF_OPT,s),!1!==this.opt.limit&&(this.opt.overflow=!1);var e=document.documentMode?"move":"grab";return e=window.sidebar?"-moz-"+e:"-webkit-"+e,t.style.cursor=e,this._handleResize=bind(window,"resize",this._init.bind(this)),this._handleMousedown=bind(t,"mousedown",t=>{if(this.disabled)return;var s=this.$elem.getBoundingClientRect();s.x-this.pos._x!==this.pos.x&&(this.pos.x=s.x-this.pos._x),s.y-this.pos._y!==this.pos.y&&(this.pos.y=s.y-this.pos._y);let e=t.pageX,i=t.pageY,o=document.documentElement.clientWidth,n=document.documentElement.clientHeight,h=s.width,d=s.height,p=[0,o-h,n-d,0];if("parent"===this.opt.limit){let t=this.$elem.parentNode.getBoundingClientRect();p=[t.top,t.right-h,t.bottom-d,t.left]}let l=bind(document,"mousemove",t=>{t.preventDefault();let o=t.pageX-e+(s.x-this.pos.x),n=t.pageY-i+(s.y-this.pos.y);"x"===this.opt.axis&&(n=0),"y"===this.opt.axis&&(o=0),!1===this.opt.overflow&&(op[1]-this.pos.x&&(o=p[1]-this.pos.x),np[2]-this.pos.y&&(n=p[2]-this.pos.y)),this.pos._x=o,this.pos._y=n,this.$elem.dispatchEvent(new CustomEvent("dragging",{detail:{offset:{x:this.pos.x+o,y:this.pos.y+n},move:{x:o,y:n}}})),this.$elem.style.transform=`translate(${o}px, ${n}px)`}),m=bind(document,"mouseup",t=>{this.$elem.dispatchEvent(new CustomEvent("dragged",{detail:{offset:{x:this.pos.x+this.pos._x,y:this.pos.y+this.pos._y},move:{x:this.pos._x,y:this.pos._y}}})),unbind(document,"mousemove",l),unbind(document,"mouseup",m)})}),this}on(t,s){if(t&&"function"==typeof s)return bind(this,t,s)}off(t,s){unbind(this,t,s)}destroy(){unbind(window,"resize",this._handleResize),unbind(this.$drag,"mousedown",this._handleMousedown),delete this.$elem,delete this.$drag}}; \ No newline at end of file diff --git a/src/lib/drag/doc.md b/src/lib/drag/doc.md deleted file mode 100644 index 0cd4766..0000000 --- a/src/lib/drag/doc.md +++ /dev/null @@ -1,85 +0,0 @@ -# 拖拽插件 -> 该插件可以让任意一个元素可以被拖拽,而不需要该元素是否具有定位属性。 -> 使用时,在目标元素上添加`:drag`属性即可以实现拖拽功能。 - -## 依赖 -> 依赖`Anot`框架 - -## 浏览器兼容性 -+ chrome -+ firefox -+ safari -+ IE10+ - - -## 用法 -> 只需要在要拖拽的元素上添加`:drag`即可; -> 如果要拖拽的元素不是当前元素,只需要给该属性增加一个值为想要拖拽元素的类名或ID。 -> 具体请看示例: -> **注意:** `拖拽的元素不是本身时,只会往父级一级一级找相匹配的` - -```html - - - - - - - - -
- -
-
-
- - - - - - -``` - - -## 额外参数 - -### `data-limit` -> 用于限制元素的拖动范围,默认没有限制。 可选值为 "window"和"parent", 分别为 "限制在可视区"和"限制在父级元素的范围" - -### `data-axis` -> 用于限制拖动的方向, 默认值为 "xy",即不限制方向。可选值为 "x"和"y", 即只能在"x轴"或"y轴"方向拖动。 - -### `data-beforedrag` -> 拖动前的回调,如果有设置回调方法, 则该回调的返回值,可决定该元素是否能被拖拽, 可用于在特殊场景下,临时禁用拖拽。 -> `注:` -> 1. 该回调方法,会传入3个参数, 第1个为被拖拽的元素(dom对象), 第2个参数为 该元素的x轴绝对坐标, 第3个元素为y轴绝对坐标; -> 2. 该回调方法, 返回false时, 本次拖拽将临时失效, 返回其他值,或没有返回值,则忽略。 - - -### `data-dragging` -> 元素被拖动时的回调。 -> `注:` -> 1.该回调方法,会传入3个参数, 第1个为被拖拽的元素(dom对象), 第2个参数为 该元素的x轴绝对坐标, 第3个元素为y轴绝对坐标; - - -### `data-dragged` -> 元素被拖动结束后的回调。 -> `注:` -> 1. 该回调方法,会传入3个参数, 第1个为被拖拽的元素(dom对象), 第2个参数为 该元素的x轴绝对坐标, 第3个元素为y轴绝对坐标; - - - - - - - - diff --git a/src/lib/drag/index.js b/src/lib/drag/index.js index 8b89daf..79ca08d 100644 --- a/src/lib/drag/index.js +++ b/src/lib/drag/index.js @@ -1 +1 @@ -"use strict";function getBindingCallback(e,t,i){var n=e.getAttribute(t);if(n)for(var a,o=0;a=i[o++];)if(a.hasOwnProperty(n)&&"function"==typeof a[n])return a[n]}Anot.ui.drag="1.0.0",Anot.directive("drag",{priority:1500,init:function(e){e.expr='"'+e.expr+'"';let t=document.documentMode?"move":"grab";window.sidebar?t="-moz-"+t:window.chrome&&(t="-webkit-"+t),Anot(e.element).css("cursor",t),e.beforedrag=getBindingCallback(e.element,"data-beforedrag",e.vmodels),e.dragging=getBindingCallback(e.element,"data-dragging",e.vmodels),e.dragged=getBindingCallback(e.element,"data-dragged",e.vmodels),e.overflow=!0,e.axis="xy",e.element.dataset.axis&&(e.axis=e.element.dataset.axis,delete e.element.dataset.axis),e.limit=!1,e.element.dataset.limit&&(e.limit=e.element.dataset.limit,e.overflow=!1,delete e.element.dataset.limit),delete e.element.dataset.beforedrag,delete e.element.dataset.dragging,delete e.element.dataset.dragged},update:function(e){let t,i,n,a,o,l,r,d,s,g,m,u,c,f,p,b=this,x=e?this.element.parentNode:this.element,v=Anot(this.element),h=Anot(document),w=null,y=null;for(;e&&x&&(x.classList||Anot.error(`${this.name}=${this.expr}, 解析异常[元素不存在]`),!x.classList.contains(e)&&x.id!==e);)x=x.parentNode;w=Anot(x),"parent"===this.limit&&(y=x.parentNode),v.bind("mousedown",function(e){let v=getComputedStyle(x),A=v.transform.replace(/matrix\((.*)\)/,"$1"),C=w.offset();if("0s"!==v.transitionDuration&&(p=v.transitionDuration,x.style.transitionDuration="0s"),(A="none"!==A?A.split(", "):[1,0,0,1,0,0])[4]-=0,A[5]-=0,t=A[4],i=A[5],c=h.scrollTop(),f=h.scrollLeft(),o=C.left-t-f,l=C.top-i-c,n=e.pageX,a=e.pageY,m=window.innerWidth,u=window.innerHeight,s=x.clientWidth,g=x.clientHeight,b.beforedrag){if(!1===b.beforedrag.call(b.vmodels[0],x,o+t,l+i))return}let k=[0,u-g,0,m-s];if("parent"===b.limit){let e=getComputedStyle(y).transform.replace(/matrix\((.*)\)/,"$1"),t=Anot(y).offset();e="none"!==e?e.split(", "):[1,0,0,1,0,0];let i=t.left-e[4]-f,n=t.top-e[5]-c;k=[n,n+y.clientHeight-g,i,i+y.clientWidth-s]}let D=h.bind("mousemove",function(e){e.preventDefault(),"y"!==b.axis&&(A[4]=e.pageX-n+t),"x"!==b.axis&&(A[5]=e.pageY-a+i),r=o+A[4],d=l+A[5],b.overflow||("y"!==b.axis&&(r<=k[2]&&(r=k[2],A[4]=r-o),r>=k[3]&&(r=k[3],A[4]=r-o)),"x"!==b.axis&&(d<=k[0]&&(d=k[0],A[5]=d-l),d>=k[1]&&(d=k[1],A[5]=d-l))),w.css({transform:"matrix("+A.join(", ")+")"}),b.dragging&&b.dragging.call(b.vmodels[0],x,r,d)}),B=h.bind("mouseup",function(e){h.unbind("mousemove",D),h.unbind("mouseup",B),x.style.transitionDuration=p,b.dragged&&b.dragged.call(b.vmodels[0],x,r,d,A[4],A[5])})})}}); \ No newline at end of file +"use strict";import Drag from"./core.js";Anot.directive("drag",{priority:1500,init:function(e){e.expr='"'+e.expr+'"',e.overflow=!0,e.axis="xy",e.element.dataset.axis&&(e.axis=e.element.dataset.axis,delete e.element.dataset.axis),e.limit=!1,e.element.dataset.limit&&(e.limit=e.element.dataset.limit,e.overflow=!1,delete e.element.dataset.limit)},update:function(e){var t=this.element;if(e)for(t=this.element.parentNode;t&&(t.classList||Anot.error(`${this.name}=${this.expr}, 解析异常[元素不存在]`),!t.classList.contains(e)&&t.id!==e);)t=t.parentNode;new Drag(t).by(this.element,{limit:this.limit,axis:this.axis,overflow:this.overflow})}}); \ No newline at end of file diff --git a/src/lib/form/button.js b/src/lib/form/button.js new file mode 100644 index 0000000..1b6972d --- /dev/null +++ b/src/lib/form/button.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import"../icon/index.js";const IS_FIREFOX=!!window.sidebar;export default class Button extends HTMLElement{static get observedAttributes(){return["icon","autofocus","loading","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{icon:"",autofocus:"",loading:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.hasAttribute("circle")&&(this.textContent=""),this.__BTN__=this.root.children[1],this.__ICO__=this.__BTN__.children[0]}get loading(){return this.props.loading}set loading(o){var t=typeof o;o!==this.props.loading&&("boolean"===t&&o||"boolean"!==t?(this.props.loading=!0,this.__ICO__.setAttribute("is","loading"),this.setAttribute("loading","")):(this.props.loading=!1,this.__ICO__.setAttribute("is",this.props.icon),this.removeAttribute("loading")))}get disabled(){return this.props.disabled}set disabled(o){var t=typeof o;o!==this.props.disabled&&("boolean"===t&&o||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=(o=>{this.props.loading||this.props.disabled?o.stopPropagation():this.dispatchEvent(new CustomEvent("active"))}),this.__BTN__.addEventListener("click",this._handleClick,!1)}disconnectedCallback(){this.__BTN__.removeEventListener("click",this._handleClick)}attributeChangedCallback(o,t,e){if(t!==e)switch(o){case"icon":this.props.icon=e,e?this.props.loading||this.__ICO__.setAttribute("is",e):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__BTN__.setAttribute("autofocus",""),IS_FIREFOX&&setTimeout(o=>{this.__BTN__.focus()},10);break;case"loading":case"disabled":this[o]=!0}}}; + +if(!customElements.get('wc-button')){ + customElements.define('wc-button', Button) +} diff --git a/src/lib/form/cascader.js b/src/lib/form/cascader.js new file mode 100644 index 0000000..50a9bf3 --- /dev/null +++ b/src/lib/form/cascader.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + + + +if(!customElements.get('wc-')){ + customElements.define('wc-', ) +} diff --git a/src/lib/form/checkbox.js b/src/lib/form/checkbox.js new file mode 100644 index 0000000..af63000 --- /dev/null +++ b/src/lib/form/checkbox.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import"../icon/index.js";export default class Checkbox extends HTMLElement{static get observedAttributes(){return["label","color","value","checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",color:"",value:[],checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild,this.__ICO__=this.__SWITCH__.children[0]}get value(){return this.props.value}set value(e){if(!Array.isArray(e))throw TypeError(":duplex指令需要传入一个数组, 当前为: "+typeof e);this.props.value=e,this.checked=this.props.value.includes(this.props.label)}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e;var{value:o,checked:t,label:l,color:r}=this.props;this.__SWITCH__.classList.toggle("checked",t),this.__ICO__.setAttribute("is","checkbox-"+(t?"on":"off"));var c=o.indexOf(l);t?(this.__ICO__.setAttribute("color",r),c<0&&o.push(l)):(this.__ICO__.removeAttribute("color"),~c&&o.splice(c,1))}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this.addEventListener("click",e=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))},!1)}attributeChangedCallback(e,o,t){if(o!==t)switch(e){case"label":case"color":this.props[e]=t;break;case"checked":case"disabled":this[e]=!0}}}; + +if(!customElements.get('wc-checkbox')){ + customElements.define('wc-checkbox', Checkbox) +} diff --git a/src/lib/form/index.js b/src/lib/form/index.js deleted file mode 100644 index 5b279ce..0000000 --- a/src/lib/form/index.js +++ /dev/null @@ -1 +0,0 @@ -importCss("/css/form.css");const log=console.log;Anot.ui.form="0.1.0",Anot.component("button",{__init__(e,s,t){s.text=this.text(),s.style={"border-radius":e.radius},this.classList.add("do-fn-noselect"),this.classList.add("do-button"),this.classList.add(e.color||"grey"),this.setAttribute(":click","onClick"),this.setAttribute(":class","{disabled: disabled}"),this.setAttribute(":css","style"),e.size&&this.classList.add(e.size),e.hasOwnProperty("disabled")&&(s.disabled=!0),delete e.disabled,delete e.color,delete e.size,t()},render(e){let s="";return this.props.icon&&(s=``),`${s}`},state:{text:"",disabled:!1,style:{}},props:{click:Anot.PropsTypes.isFunction()},skip:["style"],watch:{},methods:{onClick(){this.disabled||"function"==typeof this.props.click&&this.props.click(this.props.prop)}}}),Anot.component("radio",{__init__(e,s,t){e.hasOwnProperty("disabled")&&(s.disabled=!0),e.hasOwnProperty("checked")&&null===s.value&&(s.value=e.label),s.text=this.text(),s.checked=s.value===e.label,this.classList.add("do-radio"),this.classList.add("do-fn-noselect"),this.classList.add(e.color||"grey"),this.setAttribute(":class","{disabled: disabled, checked: checked}"),this.setAttribute(":click","onClick"),delete e.disabled,delete e.color,t()},render:()=>'\n \n \n ',state:{value:null,text:"",checked:!1,disabled:!1},props:{label:""},watch:{value(e){this.checked=this.props.label===e}},methods:{onClick(){this.disabled||this.checked||(this.checked=!0,this.value=this.props.label)}}}),Anot.component("switch",{__init__(e,s,t){e.hasOwnProperty("disabled")&&(s.disabled=!0),e.hasOwnProperty("checked")&&null===s.value&&(s.value=!0),s.value=!!s.value,this.classList.add("do-switch"),this.classList.add("do-fn-noselect"),this.classList.add(e.color||"grey"),this.setAttribute(":class","{disabled: disabled, checked: value}"),this.setAttribute(":click","onClick"),delete e.disabled,delete e.color,t()},render:()=>'\n \n ',state:{value:null,disabled:!1},methods:{onClick(){this.disabled||(this.value=!this.value)}}}),Anot.component("checkbox",{__init__(e,s,t){Array.isArray(s.value)||(this.parentNode.removeChild(this),Anot.error("多选框的传入值必须一个数组",TypeError)),e.hasOwnProperty("disabled")&&(s.disabled=!0),e.hasOwnProperty("checked")&&Anot.Array.ensure(s.value,e.label),s.text=this.text(),s.checked=s.value.indexOf(e.label)>-1,this.classList.add("do-checkbox"),this.classList.add("do-fn-noselect"),this.classList.add(e.color||"grey"),this.setAttribute(":class","{disabled: disabled, checked: checked}"),this.setAttribute(":click","onClick"),delete e.disabled,delete e.color,t()},render:()=>'\n \n \n \n \n ',state:{value:[],text:"",checked:!1,disabled:!1},props:{label:""},watch:{"value.*"(e,s,t,i){this.checked=this.value.indexOf(this.props.label)>-1},"value.length"(e,s,t,i){this.checked=this.value.indexOf(this.props.label)>-1},value(e,s,t,i){this.checked=this.value.indexOf(this.props.label)>-1}},methods:{onClick(){if(this.disabled)return;let{label:e}=this.props,s=this.value.$model;for(let t in s)if(s[t]===e)return this.checked=!1,void this.value.removeAt.call(this.value,t);this.checked=!0,this.value.push(e)}}}),Anot.component("input",{__init__(e,s,t){e.hasOwnProperty("disabled")&&(s.disabled=!0),e.iconR&&(s.pos="right",e.icon=e.iconR,delete e.iconR),this.classList.add("do-input"),this.classList.add("do-fn-noselect"),this.classList.add(e.color||"grey"),e.icon&&this.classList.add("icon-"+s.pos),this.setAttribute(":class","{disabled: disabled, active: active}"),this.setAttribute(":css","{width: props.width}"),delete e.disabled,delete e.color,t()},render(){let{icon:e,placeholder:s}=this.props;return'\n \n '+(e?``:"")},state:{pos:"left",value:"",disabled:!1,active:!1},skip:["pos"],props:{type:"text",width:180,placeholder:"",default:"",submit:Anot.PropsTypes.isFunction()},methods:{onFocus(){this.active=!0},onBlur(){this.active=!1},onKeyup(e){this.disabled||13===e.keyCode&&"function"==typeof this.props.submit&&this.props.submit()}}});export default Anot; \ No newline at end of file diff --git a/src/lib/form/input.js b/src/lib/form/input.js new file mode 100644 index 0000000..a229544 --- /dev/null +++ b/src/lib/form/input.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";const IS_FIREFOX=!!window.sidebar,TYPES=["text","textarea","password"],INPUTS={text:'',textarea:''};export default class Input extends HTMLElement{static get observedAttributes(){return["value","icon","type","label","placeholder","mvidx","autofocus","readonly","disabled"]}constructor(){super();var e,t=this.getAttribute("type");"textarea"!==t&&(t="text"),e=INPUTS[t],Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:"",icon:"",type:"text",label:"",placeholder:"",mvidx:null,autofocus:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=`
${e}
    `,this.props.type=t,this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__ICO__=this.__OUTER__.children[2],this.__APPEND__=this.__OUTER__.children[3],this.__LIST__=this.__OUTER__.children[4]}get readonly(){return this.props.readonly}set readonly(e){var t=typeof e;e!==this.props.readonly&&("boolean"===t&&e||"boolean"!==t?(this.props.readonly=!0,this.setAttribute("readonly",""),this.__INPUT__.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly"),this.__INPUT__.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.__INPUT__.value}set value(e){this.__INPUT__.value=e}get type(){return this.__INPUT__.type}set type(e){"textarea"!==e&&(this.__INPUT__.type=e)}_moveSelect(e){var{list:t}=this.props;if(t&&t.length){e.preventDefault();var i=38===e.keyCode?-1:1,s=Array.from(this.__LIST__.firstElementChild.firstElementChild.children);null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=i,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__LIST__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.list[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),this._handleChange(t),this.__LIST__.classList.remove("show"),this.props.mvidx=null}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append","");var{type:i}=this.props;this._handleSubmit=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly){if((38===e.keyCode||40===e.keyCode)&&"text"===this.type)return this._moveSelect(e);if(13===e.keyCode){if("text"===this.type&&null!==this.props.mvidx)return this._fetchSelect(this.props.mvidx,e);("text"===i||"textarea"===i&&(e.ctrlKey||e.metaKey))&&this.dispatchEvent(new CustomEvent("submit",{detail:this.value}))}}}),this._handleWheel=ebind(this.__INPUT__,"wheel"),"text"===i&&(this._handleChange=bind(this.__INPUT__,"input",e=>{e.preventDefault(),this.dispatchEvent(new CustomEvent("fetch-suggest",{detail:{value:this.value,send:e=>{this.props.list=e,this._parseSuggestion()}}}))}),this._parseSuggestion=bind(this.__INPUT__,"click",e=>{var{list:t}=this.props;let{x:i,y:s,width:o}=this.getBoundingClientRect();if(t&&t.length){var a=t.map((e,t)=>`
  • ${e.value}
  • `).join("");this.__LIST__.firstElementChild.firstElementChild.innerHTML=a,this.__LIST__.classList.toggle("show",!0),this.__LIST__.style.cssText=`left:${i}px;top:${s+50}px;width:${o}px;`}else this.__LIST__.classList.toggle("show",!1)}),this._inactiveFn=clickOutside(this,e=>{this.__LIST__.classList.remove("show")}),this._handleSelect=bind(this.__LIST__,"click",e=>{"LI"===e.target.tagName&&(this._fetchSelect(e.target.dataset.idx,e),this.dispatchEvent(new CustomEvent("input")))}))}disconnectedCallback(){unbind(this.__INPUT__,"wheel",this._handleWheel),unbind(this.__INPUT__,"keydown",this._handleSubmit),unbind(this.__INPUT__,"input",this._handleChange),unbind(document,"mousedown",this._inactiveFn),unbind(this.__LIST__,"click",this._handleSelect)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"icon":this.props.icon=i,i?this.__ICO__.setAttribute("is",i):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__INPUT__.setAttribute("autofocus",""),IS_FIREFOX&&setTimeout(e=>{this.__INPUT__.focus()},10);break;case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"type":~TYPES.indexOf(i)?this.type=i:this.type="text";break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}}; + +if(!customElements.get('wc-input')){ + customElements.define('wc-input', Input) +} diff --git a/src/lib/form/progress.js b/src/lib/form/progress.js new file mode 100644 index 0000000..c346f77 --- /dev/null +++ b/src/lib/form/progress.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +export default class Progress extends HTMLElement{static get observedAttributes(){return["value","max"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:0,max:1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__THUMB__=this.root.children[1].lastElementChild}get value(){return this.props.value}set value(e){this.props.value=+e,this.calculate()}calculate(){var{max:e,value:a}=this.props;this.__THUMB__.style.width=`${100*a/e}%`}connectedCallback(){this.calculate()}attributeChangedCallback(e,a,l){if(a!==l)switch(e){case t:var t=+l;(t!=t||t<1)&&(t=1),this.props.max=t,this.calculate();break;case"value":var r=+l;r==r&&(this.props.value=r,this.calculate())}}}; + +if(!customElements.get('wc-progress')){ + customElements.define('wc-progress', Progress) +} diff --git a/src/lib/form/radio.js b/src/lib/form/radio.js new file mode 100644 index 0000000..9c7d75a --- /dev/null +++ b/src/lib/form/radio.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import{bind,unbind}from"../utils.js";export default class Radio extends HTMLElement{static get observedAttributes(){return["label","checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild}get value(){return this.props.label}set value(e){this.checked=this.props.label===e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||this.checked||(this.checked=!0,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,o,t){if(o!==t)switch(e){case"label":this.props.label=t;break;case"checked":case"disabled":this[e]=!0}}}; + +if(!customElements.get('wc-radio')){ + customElements.define('wc-radio', Radio) +} diff --git a/src/lib/form/select.js b/src/lib/form/select.js new file mode 100644 index 0000000..02774dc --- /dev/null +++ b/src/lib/form/select.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";function parseOptions(e,t){let i="";for(let s of e)if(s.list){i+=`
    ${s.name}
    `;for(let e of s.list)t.DICT[e.value]=e,e.disabled||t.LIST.push(e),i+=`
    ${e.label}
    `}else s.disabled||t.LIST.push(s),t.DICT[s.value]=s,i+=`
    ${s.label}
    `;return i}export default class Select extends HTMLElement{static get observedAttributes(){return["label","placeholder","multi","value","options","mvidx","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",placeholder:"",multi:"",value:"",options:"",mvidx:null,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
    ",this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__ICO__=this.__OUTER__.children[2],this.__APPEND__=this.__OUTER__.children[3],this.__OPTG__=this.__OUTER__.children[4]}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.props.value}set value(e){var{DICT:t,active:i}=this.props;this.props.value=e,this.__INPUT__.value=t&&t[e]&&t[e].label||e,i||this._updateStyle()}_renderOptions(e){this.props.DICT={},this.props.LIST=[];var t=this.__OPTG__.firstElementChild.firstElementChild;t.innerHTML=parseOptions(e,this.props),this.props.ITEMS=Array.from(t.children).filter(e=>"DD"===e.tagName&&!e.hasAttribute("disabled")),this.value=this.props.value}_moveSelect(e){var{LIST:t,DICT:i,ITEMS:s}=this.props;if(t&&t.length){e.preventDefault();var o=38===e.keyCode?-1:1;null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=o,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__OPTG__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_updateStyle(e){var{LIST:t,ITEMS:i,value:s}=this.props;if(t&&t.length){if(void 0===e)for(let i,o=-1;i=t[++o];)if(s===i.value){e=o;break}this.props.mvidx=e,i.forEach((t,i)=>{i===e?t.setAttribute("focus",""):t.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.LIST[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),t&&this._updateStyle(e),this.props.active=!1,this.__OPTG__.classList.remove("show")}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());function i(){var{x:e,y:t,width:i}=this.getBoundingClientRect(),s=this.getAttribute("size");this.props.active=!0,t+=s&&"mini"===s?32:50,this.__OPTG__.style.cssText=`left:${e}px;top:${t}px;width:${i}px;`}e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append",""),this._handleKeydown=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly)return 38===e.keyCode||40===e.keyCode?this.props.active?this._moveSelect(e):(i.call(this),void this.__OPTG__.classList.toggle("show",!0)):13===e.keyCode&&null!==this.props.mvidx&&this.props.active?this._fetchSelect(this.props.mvidx):void 0}),this._activeFn=bind(this.__INPUT__,"click",e=>{var{options:t}=this.props;i.call(this),this.__OPTG__.classList.toggle("show")}),this._handleSelect=bind(this.__OPTG__,"click",e=>{"DD"!==e.target.tagName||e.target.hasAttribute("disabled")||(this._fetchSelect(+e.target.dataset.idx,!0),this.dispatchEvent(new CustomEvent("input")))}),this._inactiveFn=clickOutside(this,e=>{this.__OPTG__.classList.toggle("show",!1),this.props.active=!1})}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"options":if(i){try{this._renderOptions(JSON.parse(i))}catch(e){}this.removeAttribute("options")}break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}disconnectedCallback(){unbind(this.__INPUT__,"keydown",this._handleKeydown),unbind(this.__INPUT__,"click",this._activeFn),unbind(document,"mousedown",this._inactiveFn),unbind(this.__OPTG__,"click",this._handleSelect)}}; + +if(!customElements.get('wc-select')){ + customElements.define('wc-select', Select) +} diff --git a/src/lib/form/switch.js b/src/lib/form/switch.js new file mode 100644 index 0000000..d151795 --- /dev/null +++ b/src/lib/form/switch.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import{bind,unbind}from"../utils.js";export default class Switch extends HTMLElement{static get observedAttributes(){return["checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild}get value(){return this.props.checked}set value(e){this.checked=e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"checked":case"disabled":this[e]=!0}}}; + +if(!customElements.get('wc-switch')){ + customElements.define('wc-switch', Switch) +} diff --git a/src/lib/layer/index.js b/src/lib/layer/index.js index e9c256c..87b8374 100644 --- a/src/lib/layer/index.js +++ b/src/lib/layer/index.js @@ -1 +1 @@ -"use strict";import "../drag/index.js";importCss("/css/layer-normal.css");Anot.ui.layer="1.0.0-normal";const log=console.log,LANGUAGES={en:{TITLE:"Dialog",YES_BTN:"OK",NO_BTN:"Cancel",ERROR:"The layer instance is not exists",NEED_CONTAINER:'layer "tips" require a DOM object as container'},zh:{TITLE:"提示",YES_BTN:"确定",NO_BTN:"取消",ERROR:"要关闭的layer实例不存在",NEED_CONTAINER:"tips类型需要指定一个元素节点作为容器"},"zh-TW":{TITLE:"提示",YES_BTN:"確定",NO_BTN:"取消",ERROR:"要關閉的layer實例不存在",NEED_CONTAINER:"tips类型需要指定一個元素節點作爲容器"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let layerDom={},layerObj={},unique=null,lid=0,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{},btns:[lang.YES_BTN,lang.NO_BTN]};const $doc=Anot(document),uuid=function(){return"layer-"+lid++},close=function(e){if("string"!=typeof e&&"number"!=typeof e)return Anot.error(lang.ERROR);if(/^layerwrap\-/.test(e)||layerObj["layerwrap-"+e])try{if(e=(layerObj["layerwrap-"+e]?"layerwrap-":"")+e,!layerObj[e].show)return;layerObj[e].parentElem.replaceChild(layerObj[e].wrap,layerDom[e][0]),layerObj[e].wrap.style.display="none",layerObj[e].show=!1}catch(e){}else{unique=null;try{layerDom[e][0].classList.add("shift"),layerDom[e][1].classList.add("shift"),layerDom[e][0].style.opacity="",layerDom[e][1].style.opacity=0,setTimeout(function(){layerDom[e][0].parentNode.removeChild(layerDom[e][0]),delete layerDom[e],delete Anot.vmodels[e]},200)}catch(e){}}document.body.style.overflow=""},fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};class __layer__{get dot(){return{1:1,2:5,3:5,4:9}}constructor(e){if(e){let{yes:t,no:o,success:s}=e;delete e.yes,delete e.no,delete e.success,this.__init__({state:{...e},props:{yes:t,no:o,success:s}}).append().show()}this.timeout=null}__init__(e){let t=e.$id||uuid();return this.init={$id:t,state:{...defconf,...e.state},props:e.props,skip:["area","shift","offset","mask","maskClose","container","follow"],methods:{shake(){this.$refs.layer.classList.add("scale"),setTimeout(()=>{this.$refs.layer.classList.remove("scale")},100)},onMaskClick:function(){this.type<4&&!this.maskClose?this.shake():this.maskClose&&this.close()},handleConfirm:function(){if(3===this.type&&!this.prompt)return this.shake();if("function"==typeof this.props.yes){let e=[this.$id];3===this.type&&e.unshift(this.prompt),this.props.yes.apply(this,e)}else this.close()},handleCancel:function(){"function"==typeof this.props.no?this.props.no.call(this,this.$id):this.close()},close:function(){close(this.$id)},cancelBubble:function(e){e.cancelBubble=!0}},mounted:function(){"function"==typeof this.props.success&&this.props.success.call(this)}},4===this.init.state.type&&(this.init.methods.autoSize=function(){let{layer:e,frame:t}=this.$refs;t.onload=function(){try{let o=t.contentWindow.document.body,{clientWidth:s,clientHeight:n}=o;e.style.cssText+=`width: ${s}px;height: ${n}px;`,t.style.cssText+=`height: ${n}px;`}catch(e){}}}),this}create(){let{state:e,$id:t}=this.init,o=document.createElement("div"),s=document.createElement("div");if(o.setAttribute("anot",t),o.setAttribute(":click","onMaskClick"),o.classList.add("do-layer"),e.mask&&(o.classList.add("mask"),e.container&&e.container!==document.body&&o.classList.add("inner")),e.maskColor&&(o.style.background=e.maskColor),s.classList.add("layer-box"),s.classList.add("skin-normal"),e.extraClass&&(s.classList.add(e.extraClass),delete e.extraClass),e.shift){fixOffset(e.shift);for(let t in e.shift){let o=e.shift[t];o+=isFinite(o)?"px":"",s.style.cssText+=`${t}: ${o};`}}e.toast?s.classList.add("type-toast"):s.classList.add("type-"+e.type),s.setAttribute("ref","layer"),s.setAttribute(":click","cancelBubble"),s.style.cssText+="border-radius:"+e.radius+"px",e.menubar||e.fixed||(s.setAttribute(":drag",""),s.setAttribute("data-limit","window"));var n="";"auto"!==e.area[0]&&(n+="width: "+e.area[0]+";"),"auto"!==e.area[1]&&(n+="height: "+e.area[1]+";");let i="";return 5===e.type&&(i+=''),s.innerHTML=`\n ${this.mkMenubar()}\n \n\n ${6===e.type?this.mkLoading(e.load):""}\n
    \n ${this.mkCtrl()}\n ${i}\n `,delete e.wrap,o.appendChild(s),[o,s]}mkLoading(e){return`\n
    \n \n ${(1===e?'':"").repeat(this.dot[e])}\n \n
    \n `}mkMenubar(){let{menubar:e,fixed:t}=this.init.state,o="";return e&&(o=`\n
    \n
    \n `),o}mkCtrl(){let{type:e}=this.init.state;if(e>3)return"";{let t="",o='\n \n ';return e>1&&(o='\n \n '+o),t=`\n
    \n ${o}\n
    \n `}}append(){let{state:e,$id:t}=this.init,o=e.container;return e.type<4&&(unique&&close(unique),unique=t),layerDom[t]=this.create(),delete e.toast,this.toast=!0,o||(o=document.body),o.appendChild(layerDom[t][0]),this.vm=Anot(this.init),this}show(){let{state:e,$id:t}=this.init,o=(this.vm,e.container);setTimeout(function(){let s={background:e.background},n=Anot(layerDom[t][1]);if(5===e.type){let i=getComputedStyle(layerDom[t][1]);s.color=e.color,s.opacity=1;let a=Anot(o),r=a[0].querySelector(".arrow"),l=a.innerWidth(),c=a.innerHeight(),d=a.offset().left-$doc.scrollLeft(),p=a.offset().top-$doc.scrollTop(),y=parseInt(i.width),f=parseInt(i.height),u=["top"];Anot(layerDom[t][1]).css(s),a.bind("mouseenter",t=>{let o={visibility:"visible"};d=a.offset().left-$doc.scrollLeft(),(p=a.offset().top-$doc.scrollTop())+18window.innerWidth?(o.left=d+.3*l-y,u[1]="left"):o.left=d+.7*l,r.classList.add("offset-"+u.join("-")),n.css(o)}),a.bind("mouseleave",()=>{setTimeout(()=>{r.classList.remove("offset-"+u.join("-")),u=["top"],r.style.borderBottomColor="",r.style.borderTopColor="",layerDom[t][1].style.visibility="hidden"},100)})}else{let o={opacity:1};e.offset&&(fixOffset(e.offset),Object.assign(o,e.offset)),n.css(s),setTimeout(()=>{document.body.style.overflow="hidden",layerDom[t][1].classList.add("shift"),setTimeout(e=>{n.css(o),setTimeout(e=>{try{layerDom[t][1].classList.remove("shift")}catch(e){}},500)},50)},50)}},4),e.type>3&&(e.timeout>0?(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{clearTimeout(this.timeout),close(t),6===e.type&&this.vm.props.yes.call(this.vm,t)},e.timeout)):6===e.type&&this.vm.props.yes.call(this.vm,t))}}const _layer={alert(e,t,o){let s={content:e,fixed:!0};return"function"==typeof t?s.yes=t:(t&&(s.title=t+""),o&&"function"==typeof o&&(s.yes=o)),_layer.open(s)},confirm(e,t,o,s){let n={content:e,fixed:!0,type:2};return"function"==typeof t?(n.yes=t,"function"==typeof o&&(n.no=o)):(t&&(n.title=t+""),o&&"function"==typeof o&&(n.yes=o),s&&"function"==typeof s&&(n.no=s)),_layer.open(n)},frame(e,t={}){let o={content:``,menubar:!1,maskClose:!0,type:4,...t};return _layer.open(o)},toast(e,t="info",o=2500){switch("number"==typeof t&&(o=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let s={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:o,offset:{top:50},fixed:!0,toast:!0};return _layer.open(s)},load:(e,t,o)=>(e=(e>>>=0)<1?1:e>4?4:e,"function"==typeof t?(o=t,t=null):(t instanceof HTMLElement||(t=null),"function"!=typeof o&&(o=Anot.noop)),_layer.open({container:t,type:6,load:e,yes:o,menubar:!1,background:"none",fixed:!0})),tips:(e,t,o={})=>t instanceof HTMLElement?(o.background||(o.background="rgba(0,0,0,.5)"),o.color||(o.color="#fff"),Object.assign(o,{container:t,content:e,type:5,fixed:!0,mask:!1,menubar:!1,timeout:0}),_layer.open(o)):Anot.error(lang.NEED_CONTAINER),prompt(e,t){if("function"!=typeof t)return console.error("argument [callback] requires a function, but "+typeof t+" given");let o={type:3,prompt:"",title:e,content:'',fixed:!0,yes:t};return _layer.open(o)},close:close,open(e){if("string"==typeof e){if(layerObj[e="layerwrap-"+e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id},version:Anot.ui.layer};Anot.directive("layer",{priority:8090,init:function(e){e.element.removeAttribute(e.name),e.param&&"tips"===e.param||(e.param="",e.element.style.display="none")},update:function(e){if(!e)return console.error(`SyntaxError: Unexpected [${this.name}=${this.expr}]`);let t=Object.assign({type:7,wrap:!0},this.element.dataset);if(this.param){if("tips"===this.param){let o=document.createElement("div"),s=document.createElement("span"),n=document.createElement("i"),i=Anot(this.element),{position:a}=getComputedStyle(this.element);o.className="do-layer__tips",s.className="layer-content",n.className="arrow",s.textContent=e,o.appendChild(s),o.appendChild(n),"static"===a&&(this.element.style.position="relative"),this.element.appendChild(o);let r={};t.color&&(r.color=t.color),t.color&&(r.background=t.background);let l=i.innerWidth(),c=i.innerHeight(),d=["top"];Anot(o).css(r),i.bind("mouseenter",e=>{let s={visibility:"visible"},a=o.clientWidth,r=o.clientHeight,{left:p,top:y}=i.offset(),f=p-$doc.scrollLeft();y-$doc.scrollTop()window.innerWidth?(s.left=.3*l-a,d[1]="left"):s.left=.7*l,n.classList.add("offset-"+d.join("-")),Anot(o).css(s)}),i.bind("mouseleave",()=>{setTimeout(()=>{n.classList.remove("offset-"+d.join("-")),d=["top"],n.style.borderBottomColor="",n.style.borderTopColor="",o.style.visibility="hidden"},100)})}}else{let o={$id:"layerwrap-"+e,state:t,props:{}};t.hasOwnProperty("area")&&(t.area=t.area.split(",")),t.hasOwnProperty("shift")&&(t.shift=fixOffset(new Function(`return ${t.shift}`)())),t.hasOwnProperty("offset")&&(t.offset=fixOffset(new Function(`return ${t.offset}`)())),t.hasOwnProperty("btns")&&(t.btns=t.btns.split(",")),t.hasOwnProperty("menubar")||(t.menubar=!1);let s=(new __layer__).__init__(o);for(let e in this.element.dataset)delete this.element.dataset[e];layerObj[s.init.$id]={obj:s,parentElem:this.element.parentNode,wrap:this.element,show:!1},layerDom[s.init.$id]=s.create()}}}),window.layer=_layer;export default _layer; \ No newline at end of file +"use strict";import"../drag/index.js";Anot.ui.layer="1.0.0-normal";const log=console.log,LANGUAGES={en:{TITLE:"Dialog",YES_BTN:"OK",NO_BTN:"Cancel",ERROR:"The layer instance is not exists",NEED_CONTAINER:'layer "tips" require a DOM object as container'},zh:{TITLE:"提示",YES_BTN:"确定",NO_BTN:"取消",ERROR:"要关闭的layer实例不存在",NEED_CONTAINER:"tips类型需要指定一个元素节点作为容器"},"zh-TW":{TITLE:"提示",YES_BTN:"確定",NO_BTN:"取消",ERROR:"要關閉的layer實例不存在",NEED_CONTAINER:"tips类型需要指定一個元素節點作爲容器"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let layerDom={},layerObj={},unique=null,lid=0,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{},btns:[lang.YES_BTN,lang.NO_BTN]};const $doc=Anot(document),uuid=function(){return"layer-"+lid++},close=function(e){if("string"!=typeof e&&"number"!=typeof e)return Anot.error(lang.ERROR);if(/^layerwrap\-/.test(e)||layerObj["layerwrap-"+e])try{if(e=(layerObj["layerwrap-"+e]?"layerwrap-":"")+e,!layerObj[e].show)return;layerObj[e].parentElem.replaceChild(layerObj[e].wrap,layerDom[e][0]),layerObj[e].wrap.style.display="none",layerObj[e].show=!1}catch(e){}else unique=null,layerDom[e]&&(layerDom[e][0].classList.add("shift"),layerDom[e][1].classList.add("shift"),layerDom[e][0].style.opacity="",layerDom[e][1].style.opacity=0,setTimeout(function(){try{layerDom[e][0].parentNode.removeChild(layerDom[e][0]),delete layerDom[e],delete Anot.vmodels[e]}catch(e){}},200));document.body.style.overflow=""},fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};class __layer__{get dot(){return{1:1,2:5,3:5,4:9}}constructor(e){if(e){let{yes:t,no:o,success:s}=e;delete e.yes,delete e.no,delete e.success,this.__init__({state:{...e},props:{yes:t,no:o,success:s}}).append().show()}this.timeout=null}__init__(e){let t=e.$id||uuid();return this.init={$id:t,state:{...defconf,...e.state},props:e.props,skip:["area","shift","offset","mask","maskClose","container","follow"],methods:{shake(){this.$refs.layer.classList.add("scale"),setTimeout(()=>{this.$refs.layer.classList.remove("scale")},100)},onMaskClick:function(e){e.target===e.currentTarget&&(this.type<4&&!this.maskClose?this.shake():this.maskClose&&this.close())},handleConfirm:function(){if(3===this.type&&!this.prompt)return this.shake();if("function"==typeof this.props.yes){let e=[this.$id];3===this.type&&e.unshift(this.prompt),this.props.yes.apply(this,e)}else this.close()},handleCancel:function(){"function"==typeof this.props.no?this.props.no.call(this,this.$id):this.close()},close:function(){close(this.$id)}},mounted:function(){"function"==typeof this.props.success&&this.props.success.call(this)}},4===this.init.state.type&&(this.init.methods.autoSize=function(){let{layer:e,frame:t}=this.$refs;t.onload=function(){try{let o=t.contentWindow.document.body,{clientWidth:s,clientHeight:n}=o;e.style.cssText+=`width: ${s}px;height: ${n}px;`,t.style.cssText+=`height: ${n}px;`}catch(e){}}}),this}create(){let{state:e,$id:t}=this.init,o=document.createElement("div"),s=document.createElement("div");if(o.setAttribute("anot",t),o.setAttribute(":on-click","onMaskClick"),o.classList.add("do-layer"),e.mask&&(o.classList.add("mask"),e.container&&e.container!==document.body&&o.classList.add("inner")),e.maskColor&&(o.style.background=e.maskColor),s.classList.add("layer-box"),s.classList.add("skin-normal"),e.extraClass&&(s.classList.add(e.extraClass),delete e.extraClass),e.shift){fixOffset(e.shift);for(let t in e.shift){let o=e.shift[t];o+=isFinite(o)?"px":"",s.style.cssText+=`${t}: ${o};`}}e.toast?s.classList.add("type-toast"):s.classList.add("type-"+e.type),s.setAttribute("ref","layer"),s.style.cssText+="border-radius:"+e.radius+"px",e.menubar||e.fixed||(s.setAttribute(":drag",""),s.setAttribute("data-limit","window"));var n="";"auto"!==e.area[0]&&(n+="width: "+e.area[0]+";"),"auto"!==e.area[1]&&(n+="height: "+e.area[1]+";");let i="";return 5===e.type&&(i+=''),s.innerHTML=`\n ${this.mkMenubar()}\n \n\n ${6===e.type?this.mkLoading(e.load):""}\n \n ${this.mkCtrl()}\n ${i}\n `,delete e.wrap,o.appendChild(s),[o,s]}mkLoading(e){return`\n
    \n \n ${(1===e?'':"").repeat(this.dot[e])}\n \n
    \n `}mkMenubar(){let{menubar:e,fixed:t}=this.init.state,o="";return e&&(o=`\n
    \n
    \n `),o}mkCtrl(){let{type:e}=this.init.state;if(e>3)return"";{let t="",o='\n \n ';return e>1&&(o='\n \n '+o),t=`\n
    \n ${o}\n
    \n `}}append(){let{state:e,$id:t}=this.init,o=e.container;return e.type<4&&(unique&&close(unique),unique=t),layerDom[t]=this.create(),delete e.toast,this.toast=!0,o||(o=document.body),o.appendChild(layerDom[t][0]),this.vm=Anot(this.init),this}show(){let e=this.vm,{state:t,$id:o}=this.init,s=t.container;setTimeout(function(){let n={background:t.background},i=Anot(layerDom[o][1]);if(5===t.type){let e=getComputedStyle(layerDom[o][1]);n.color=t.color,n.opacity=1;let a=Anot(s),r=a[0].querySelector(".arrow"),l=a.innerWidth(),c=a.innerHeight(),d=a.offset().left-$doc.scrollLeft(),p=a.offset().top-$doc.scrollTop(),y=parseInt(e.width),f=parseInt(e.height),u=["top"];Anot(layerDom[o][1]).css(n),a.bind("mouseenter",e=>{let o={visibility:"visible"};d=a.offset().left-$doc.scrollLeft(),(p=a.offset().top-$doc.scrollTop())+18window.innerWidth?(o.left=d+.3*l-y,u[1]="left"):o.left=d+.7*l,r.classList.add("offset-"+u.join("-")),i.css(o)}),a.bind("mouseleave",()=>{setTimeout(()=>{r.classList.remove("offset-"+u.join("-")),u=["top"],r.style.borderBottomColor="",r.style.borderTopColor="",layerDom[o][1].style.visibility="hidden"},100)})}else{let s={opacity:1};t.offset&&(fixOffset(t.offset),Object.assign(s,t.offset)),i.css(n),setTimeout(()=>{document.body.style.overflow="hidden",layerDom[o][1].classList.add("shift"),setTimeout(t=>{i.css(s),e&&e.$refs.input&&e.$refs.input.focus(),setTimeout(e=>{try{layerDom[o][1].classList.remove("shift")}catch(e){}},500)},50)},50)}},4),t.type>3&&(t.timeout>0?(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{clearTimeout(this.timeout),close(o),6===t.type&&this.vm.props.yes.call(this.vm,o)},t.timeout)):6===t.type&&this.vm.props.yes.call(this.vm,o))}}const _layer={alert(e,t,o){let s={content:e,fixed:!0};return"function"==typeof t?s.yes=t:(t&&(s.title=t+""),o&&"function"==typeof o&&(s.yes=o)),_layer.open(s)},confirm(e,t,o,s){let n={content:e,fixed:!0,type:2};return"function"==typeof t?(n.yes=t,"function"==typeof o&&(n.no=o)):(t&&(n.title=t+""),o&&"function"==typeof o&&(n.yes=o),s&&"function"==typeof s&&(n.no=s)),_layer.open(n)},frame(e,t={}){let o={content:``,menubar:!1,maskClose:!0,type:4,...t};return _layer.open(o)},toast(e,t="info",o=2500){switch("number"==typeof t&&(o=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let s={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:o,offset:{top:50},fixed:!0,toast:!0};return _layer.open(s)},load:(e,t,o)=>(e=(e>>>=0)<1?1:e>4?4:e,"function"==typeof t?(o=t,t=null):(t instanceof HTMLElement||(t=null),"function"!=typeof o&&(o=Anot.noop)),_layer.open({container:t,type:6,load:e,yes:o,menubar:!1,background:"none",fixed:!0})),tips:(e,t,o={})=>t instanceof HTMLElement?(o.background||(o.background="rgba(0,0,0,.5)"),o.color||(o.color="#fff"),Object.assign(o,{container:t,content:e,type:5,fixed:!0,mask:!1,menubar:!1,timeout:0}),_layer.open(o)):Anot.error(lang.NEED_CONTAINER),prompt(e,t){if("function"!=typeof t)return console.error("argument [callback] requires a function, but "+typeof t+" given");let o={type:3,prompt:"",title:e,content:'',fixed:!0,yes:t};return _layer.open(o)},close:close,open(e){if("string"==typeof e){if(layerObj[e="layerwrap-"+e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id},version:Anot.ui.layer};Anot.directive("layer",{priority:8090,init:function(e){e.element.removeAttribute(e.name),e.param&&"tips"===e.param||(e.param="",e.element.style.display="none")},update:function(e){if(!e)return console.error(`SyntaxError: Unexpected [${this.name}=${this.expr}]`);let t=Object.assign({type:7,wrap:!0},this.element.dataset);if(this.param){if("tips"===this.param){let o=document.createElement("div"),s=document.createElement("span"),n=document.createElement("i"),i=Anot(this.element),{position:a}=getComputedStyle(this.element);o.className="do-layer__tips",s.className="layer-content",n.className="arrow",s.textContent=e,o.appendChild(s),o.appendChild(n),"static"===a&&(this.element.style.position="relative"),this.element.appendChild(o);let r={};t.color&&(r.color=t.color),t.color&&(r.background=t.background);let l=i.innerWidth(),c=i.innerHeight(),d=["top"];Anot(o).css(r),i.bind("mouseenter",e=>{let s={visibility:"visible"},a=o.clientWidth,r=o.clientHeight,{left:p,top:y}=i.offset(),f=p-$doc.scrollLeft();y-$doc.scrollTop()window.innerWidth?(s.left=.3*l-a,d[1]="left"):s.left=.7*l,n.classList.add("offset-"+d.join("-")),Anot(o).css(s)}),i.bind("mouseleave",()=>{setTimeout(()=>{n.classList.remove("offset-"+d.join("-")),d=["top"],n.style.borderBottomColor="",n.style.borderTopColor="",o.style.visibility="hidden"},100)})}}else{let o={$id:"layerwrap-"+e,state:t,props:{}};t.hasOwnProperty("area")&&(t.area=t.area.split(",")),t.hasOwnProperty("shift")&&(t.shift=fixOffset(new Function(`return ${t.shift}`)())),t.hasOwnProperty("offset")&&(t.offset=fixOffset(new Function(`return ${t.offset}`)())),t.hasOwnProperty("btns")&&(t.btns=t.btns.split(",")),t.hasOwnProperty("menubar")||(t.menubar=!1);let s=(new __layer__).__init__(o);for(let e in this.element.dataset)delete this.element.dataset[e];layerObj[s.init.$id]={obj:s,parentElem:this.element.parentNode,wrap:this.element,show:!1},layerDom[s.init.$id]=s.create()}}}),window.layer=_layer;export default _layer; \ No newline at end of file diff --git a/src/lib/layer/next.js b/src/lib/layer/next.js new file mode 100644 index 0000000..c79deb8 --- /dev/null +++ b/src/lib/layer/next.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import"../form/input.js";import Drag from"../drag/core.js";import{nextTick,bind,unbind,clickOutside}from"../utils.js";const LANGUAGES={en:{TITLE:"Dialog",BTNS:["Cancel","OK"],ERROR:"The layer instance is not exists"},zh:{TITLE:"提示",BTNS:["取消","确定"],ERROR:"要关闭的layer实例不存在"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let unique=null,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{}};const UNIQUE_TYPES=["alert","confirm","prompt"],fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};function createLayer(e){var t=document.createElement("wc-layer");return e.mask&&t.setAttribute("mask",""),t.title=e.title,e.btns&&e.btns.length?t.props.btns=e.btns:t.props.btns=lang.BTNS.concat(),e.intercept&&"function"==typeof e.intercept&&(t.props.intercept=e.intercept),t.props.background=e.background,t.props.mask=e.mask,t.props.maskClose=e.maskClose,t.props.maskColor=e.maskColor,t.type=e.type,t.innerHTML=e.content,document.body.appendChild(t),UNIQUE_TYPES.includes(e.type)&&(unique&&unique.close(),unique=t),t.promise}const _layer={alert:(e,t=lang.TITLE)=>createLayer({type:"alert",title:t,content:e,fixed:!0,mask:!0}),confirm:(e,t=lang.TITLE,r)=>("function"==typeof t&&(r=t,t=lang.TITLE),createLayer({type:"confirm",title:t,content:e,fixed:!0,mask:!0,intercept:r})),prompt:(e=lang.TITLE,t)=>createLayer({type:"prompt",title:e,content:'',fixed:!0,mask:!0,intercept:t}),frame:(e,t={})=>createLayer({...t,type:"frame",content:``,fixed:!0,mask:!0,maskClose:!0}),toast(e,t="info",r=2500){switch("number"==typeof t&&(r=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let i={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:r,offset:{top:50},fixed:!0,toast:!0};return _layer.open(i)},open(e){if("string"==typeof e){if(e="layerwrap-"+e,layerObj[e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id}};function renderBtns(e){var t="";return e.forEach((e,r)=>{t+=``}),t}class Layer extends HTMLElement{static get observedAttributes(){return["btns","type","title","fixed"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{btns:[],type:"msg",title:"",fixed:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
    ",this.__TITLE__=this.root.children[1].firstElementChild,this.__BODY__=this.root.children[1].children[1],this.__CTRL__=this.root.children[1].lastElementChild,this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}set title(e){e?(this.__TITLE__.textContent=e,this.__TITLE__.style.display=""):this.__TITLE__.style.display="none"}set type(e){var{btns:t}=this.props;switch(e){case"alert":for(;t.length>1;)t.splice(0,1);break;case"confirm":case"prompt":for(;t.length>2;)t.splice(0,1);break;case"toast":case"frame":t=[];break;default:e="common"}this.props.type=e,t.length?(this.__CTRL__.innerHTML=renderBtns(t),this.__CTRL__.style.display=""):this.__CTRL__.style.display="none",this.setAttribute("type",e)}set fixed(e){this.props.fixed=!!e,UNIQUE_TYPES.includes(this.props.type)||(this.props.fixed?this._dragIns&&(this._dragIns.destroy(),this._dragIns=null):(this._dragIns=new Drag(this.root.children[1]).by(this.__TITLE__,{overflow:!1}),this.removeAttribute("fixed")))}_intercept(e){this.props.intercept?this.props.intercept(e,t=>{delete this.props.intercept,this.resolve(e),this.close()}):(this.resolve(e),this.close())}close(){this._dragIns&&this._dragIns.destroy(),UNIQUE_TYPES.includes(this.props.type)&&(unique=null),delete this.promise,unbind(this.__CTRL__,"click",this._handleBtnClick),this.parentNode.removeChild(this)}connectedCallback(){this._handleBtnClick=bind(this.__CTRL__,"click",e=>{if("BUTTON"===e.target.tagName){var t=+e.target.dataset.idx,{intercept:r,type:i}=this.props;switch(i){case"alert":this.resolve(),this.close();break;case"confirm":case"prompt":if(0===t)this.reject(),this.close();else{let e="prompt"===i?this.__INPUT__.value:null;this._intercept(e)}break;default:this.resolve(t),this.close()}}}),"prompt"===this.props.type&&(this.__INPUT__=this.__BODY__.firstElementChild.assignedNodes().pop(),this._handleSubmit=bind(this.__INPUT__,"submit",e=>{this._intercept(e.detail)})),this.props.mask&&(this._handlMask=clickOutside(this.root.children[1],e=>{this.props.maskClose?this.close():UNIQUE_TYPES.includes(this.props.type)&&(this.root.children[1].classList.toggle("scale",!0),setTimeout(e=>{this.root.children[1].classList.remove("scale")},100))}))}disconnectedCallback(){unbind(document,"mousedown",this._handlMask)}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"title":case"type":this[e]=r;break;case"fixed":this.fixed=!0}}}window.layer=_layer;export default _layer; + +if(!customElements.get('wc-layer')){ + customElements.define('wc-layer', Layer) +} diff --git a/src/lib/pager/index.js b/src/lib/pager/index.js index 66b4d80..f178af6 100644 --- a/src/lib/pager/index.js +++ b/src/lib/pager/index.js @@ -1 +1,15 @@ -"use strict";importCss("/css/pager.css");function calculate({currPage:t,maxPageShow:e,totalPage:a}){let s=[],r=0,o=t1&&s.push("..."),a-t0&&s.push(e);return t+o1?e.pageList.pushArray(calculate({currPage:t,totalPage:a,maxPageShow:s})):e.pageList.pushArray([1])}Anot.ui.pager="1.0.0";const tmpls={home:'',end:'',prev:'',next:'',pager:'',curr:'',total:'共 {{totalPage}} 页 {{totalItem}} 条',jumper:'
    前往\n 页\n
    ',slot:""};export default Anot.component("pager",{__init__:function(t,e,a){this.classList.add("do-pager"),this.classList.add("do-fn-noselect"),this.setAttribute(":class","{{classList.join(' ')}}"),t.theme=+t.theme||1,t.simpleMode&&(t.theme=1),e.classList=e.classList.concat("skin-"+t.theme,t.color||"plain",t.size||"mini"),t.total&&(e.totalItem=+t.total),t.pageSize&&(e.pageSize=+t.pageSize),t.layout||(t.layout="total,home,prev,pager,next,end,jumper"),2===t.theme&&(t.radius=null),delete t.total,delete t.pageSize,delete t.color,delete t.size,a()},render:function(t){let{layout:e,theme:a,simpleMode:s}=this.props;return s?e=["prev","curr","next"]:(e=e.replace(/\s/g,""),2===a&&(e=e.replace(/total|jumper/g,"")),e=e.split(",")),(e=e.map(e=>"slot"!==e?tmpls[e]||"":t&&t.extra?t.extra.join(""):void 0)).join("\n")},componentWillMount:function(){const{currPage:t,totalPage:e,props:a}=this;this.pageList.clear(),this.pageList.pushArray(calculate({currPage:t,totalPage:e,maxPageShow:a.maxPageShow}))},componentDidMount:function(){"function"==typeof this.props.created&&this.props.created(this)},state:{classList:[],currPage:1,totalItem:1,pageSize:20,inputPage:1,pageList:[]},computed:{totalPage:function(){return Math.ceil(this.totalItem/this.pageSize)}},props:{url:null,maxPageShow:5,simpleMode:!1,radius:3,pageChanged:Anot.PropsTypes.isFunction(),created:Anot.PropsTypes.isFunction()},skip:["classList"],methods:{parseUrl(t){return(t>>>=0)<1||!this.props.url||this.currPage===t?"":this.props.url.replace("{id}",t)},go(t,e){let{inputPage:a,totalPage:s,currPage:r}=this,o=e&&e.target||null;if(!(o&&o.disabled||r===t))if(t&&o){if("..."!==t){let e=o.dataset.to;e?location.href=e:t>>>=0,update(t,this)}}else if(null===t){if(a>>>=0,e&&13===e.keyCode){if(a<1||r===a)return this.inputPage=r;a>s&&(a=s),this.inputPage=a,update(a,this)}}else update(t>>>=0,this)},setSize(t){t=+t,this.pageSize!==t&&(this.pageSize=+t,update(1,this))},setTotal(t){t=+t,this.totalItem!==t&&(this.totalItem=+t,update(1,this))}}}); \ No newline at end of file +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +function calculate(t,e,r){var o,a=[],s=0,i=t<3?6-t:2;if(e<2||r)return a.push({to:t,txt:t}),a;t-i>1&&e>5&&(o=(o=t-2*i)<1?1:o,a.push({to:o,txt:"..."}));e-t0&&a.push({to:n,txt:n});t+ie?e:o,a.push({to:o,txt:"..."}));return a}export default class Pager extends HTMLElement{static get observedAttributes(){return["layout","total","curr","pagesize","simple"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{layout:"home, prev, next, end",total:0,curr:1,pagesize:20,simple:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
    ',this.__LAYOUT__=this.root.children[1],this.__HOME__=this.__LAYOUT__.children[0],this.__PREV__=this.__LAYOUT__.children[1],this.__PAGE__=this.__LAYOUT__.children[2],this.__NEXT__=this.__LAYOUT__.children[3],this.__END__=this.__LAYOUT__.children[4]}update(){var{curr:t,totalpage:e,simple:r}=this.props,o=calculate(t,e,r);this.__PAGE__.innerHTML=o.map(e=>``).join("")}connectedCallback(){var{pagesize:t,total:e}=this.props;this.props.totalpage=Math.ceil(e/t),this.update(),this.__LAYOUT__.addEventListener("click",t=>{if("BUTTON"===t.target.tagName){var{curr:e,totalpage:r}=this.props,o=t.target.dataset.page,a=+o;if(a==a){if(a===e)return}else switch(o){case"prev":if((a=e-1)<1)return;break;case"next":if((a=e+1)>r)return;break;case"end":if(r===e)return;a=r}this.props.curr=a,this.update(),this.dispatchEvent(new CustomEvent("pick",{detail:a}))}},!1)}attributeChangedCallback(t,e,r){if(e!==r)switch(t){case"total":case"pagesize":case"curr":this.props[t]=+r||this.props[t];var{pagesize:o,total:a}=this.props;this.props.totalpage=Math.ceil(a/o),this.update();break;case"simple":this.props.simple=!0}}}; + +if(!customElements.get('wc-pager')){ + customElements.define('wc-pager', Pager) +} diff --git a/src/lib/request/index.js b/src/lib/request/index.js index 5a615eb..9cd1ce5 100644 --- a/src/lib/request/index.js +++ b/src/lib/request/index.js @@ -1 +1 @@ -"use strict";import Format from "./lib/format.js";import format from "./lib/format.js";const rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,log=console.log,noop=function(t,e){this.defer.resolve(e)};let isLocal=!1;try{isLocal=rlocalProtocol.test(location.ptyperotocol)}catch(t){}let originAnchor=document.createElement("a");originAnchor.href=location.href;const NOBODY_METHODS=["GET","HEAD"],ERRORS={10001:"Argument url is required",10012:"Parse error",10100:"Request canceled",10104:"Request pending...",10200:"Ok",10204:"No content",10304:"Not modified",10500:"Internal Server Error",10504:"Connected timeout"},FORM_TYPES={form:"application/x-www-form-urlencoded; charset=UTF-8",json:"application/json; charset=UTF-8",text:"text/plain; charset=UTF-8"},convert={text:t=>t,xml:(t,e)=>void 0!==e?e:Format.parseXML(t),html:t=>Format.parseHTML(t),json:t=>JSON.parse(t),script:t=>Format.parseJS(t)};class _Request{constructor(t="",e="GET",s={}){if(!t)throw new Error(ERRORS[10001]);return t=t.replace(/#.*$/,"").replace(/^\/\//,location.protocol+"//"),e=e.toUpperCase(),this.xhr=new XMLHttpRequest,this.defer=Promise.defer(),this.opt={url:t,method:e,headers:{},data:{},dataType:"text",withCredentials:!1},this.defer.promise.abort=(()=>{this.cancel=!0,this.xhr.abort()}),this.__next__(Object.assign({},request.__INIT__,s)),this.defer.promise}__next__(t){t.headers&&Object.assign(this.opt.headers,t.headers);let e=!1;if(t.formType)switch(t.formType){case"form":this.__set__("form");break;case"json":this.__set__("json");break;case"form-data":this.opt.method="POST",e=!0;break;default:NOBODY_METHODS.includes(this.opt.method)?this.__set__("form"):this.__set__("text")}else this.__set__("form");if(t.cache&&NOBODY_METHODS.includes(this.opt.method)&&(this.opt.cache=!0),t.timeout=t.timeout>>>0,t.timeout>0&&(this.opt.timeout=t.timeout),t.data){switch(typeof t.data){case"number":case"string":this.__set__("text"),this.opt.data=t.data;break;case"object":"FORM"===t.data.nodeName?(this.opt.method=t.data.method.toUpperCase()||"POST",this.opt.data=Format.parseForm(t.data),(e=this.opt.data.constructor===FormData)&&delete this.opt.headers["content-type"]):t.data.constructor===FormData?(e=!0,this.opt.method="POST",delete this.opt.headers["content-type"],this.opt.data=t.data):this.opt.data=e?Format.mkFormData(t.data):t.data}}t.withCredentials&&(this.opt.withCredentials=!0);try{let t=document.createElement("a");t.href=this.opt.url,this.opt.crossDomain=originAnchor.protocol!==t.protocol||originAnchor.host!==t.host}catch(t){}this.opt.crossDomain?this.opt.withCredentials&&(this.xhr.withCredentials=!0,this.opt.headers["X-Requested-With"]="XMLHttpRequest"):this.opt.headers["X-Requested-With"]="XMLHttpRequest",!NOBODY_METHODS.includes(this.opt.method)?e||("json"===t.formType?this.opt.data=JSON.stringify(this.opt.data):this.opt.data=Format.param(this.opt.data)):(this.opt.data=Format.param(this.opt.data),this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+this.opt.data,!1===this.opt.cache&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+"_="+Math.random())),t.dataType&&(this.opt.dataType=t.dataType.toLowerCase()),this.xhr.responseType=this.opt.dataType,this.xhr.onreadystatechange=(t=>{this.opt.timeout>0&&(this.opt["time"+this.xhr.readyState]=t.timeStamp,4===this.xhr.readyState&&(this.opt.isTimeout=this.opt.time4-this.opt.time1>this.opt.timeout)),4===this.xhr.readyState&&this.__dispatch__(this.opt.isTimeout)}),this.xhr.open(this.opt.method,this.opt.url,!0);for(let t in this.opt.headers)this.xhr.setRequestHeader(t,this.opt.headers[t]);this.xhr.send(this.opt.data),this.opt.timeout&&this.opt.timeout>0&&(this.xhr.timeout=this.opt.timeout)}__set__(t){this.opt.headers["content-type"]=FORM_TYPES[t]}__dispatch__(t){let e={status:200,statusText:"ok",text:"",body:"",error:null};if(this.cancel)return this.__cancel__(e);if(t)return this.__timeout__(e);let s=this.xhr.status>=200&&this.xhr.status<400,o=this.xhr.getAllResponseHeaders().split("\n")||[],r="";for(let t of o)if(t=t.trim()){if("content-type"===(t=t.split(":")).shift().toLowerCase()){r=t.join(":").trim().toLowerCase();break}}switch(s?(e.status=this.xhr.status,204===e.status?e.statusText=ERRORS[10204]:304===e.status&&(e.statusText=ERRORS[10304])):(e.status=this.xhr.status||500,e.statusText=this.xhr.statusText||ERRORS[10500],e.error=new Error(e.statusText)),this.opt.dataType){case"arraybuffer":case"blob":case"document":case"json":e.text=e.body=this.xhr.response;break;default:try{let t=r.match(/json|xml|script|html/);t=t&&t[0].toLowerCase()||"text",e.text=this.xhr.response,e.body=convert[t](e.text,this.xhr.response)}catch(t){e.error=t,e.statusText=ERRORS[10012]}}this.__success__(s,e)}__success__(t,e){t?this.defer.resolve(e):this.defer.reject(e),delete this.xhr,delete this.opt,delete this.defer}__cancel__(t){t.status=0,t.statusText=ERRORS[10100],t.error=new Error(ERRORS[10100]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}__timeout__(t){t.status=504,t.statusText=ERRORS[10504],t.error=new Error(ERRORS[10504]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}}window.request||(window.request={get:(t,e={})=>new _Request(t,"GET",e),post:(t,e={})=>new _Request(t,"POST",e),upload(t,e={}){return e.formType="form-data",this.post(t,e)},download(t,e={}){return e.dataType="blob",this.get(t,e)},open:(t,e="GET",s={})=>("object"==typeof e&&(s=e,e="GET"),new _Request(t,e,s)),version:"2.0.0-normal",init(t={}){this.__INIT__=t}},Anot.ui.request=request.version);export default request; \ No newline at end of file +"use strict";import Format from"./lib/format.js";const rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,log=console.log,noop=function(t,e){this.defer.resolve(e)};let isLocal=!1;try{isLocal=rlocalProtocol.test(location.protocol)}catch(t){}let originAnchor=document.createElement("a");originAnchor.href=location.href;const NOBODY_METHODS=["GET","HEAD"],ERRORS={10001:"Argument url is required",10012:"Parse error",10100:"Request canceled",10104:"Request pending...",10200:"Ok",10204:"No content",10304:"Not modified",10500:"Internal Server Error",10504:"Connected timeout"},FORM_TYPES={form:"application/x-www-form-urlencoded; charset=UTF-8",json:"application/json; charset=UTF-8",text:"text/plain; charset=UTF-8"},convert={text:t=>t,xml:(t,e)=>void 0!==e?e:Format.parseXML(t),html:t=>Format.parseHTML(t),json:t=>JSON.parse(t),script:t=>Format.parseJS(t)};class _Request{constructor(t="",e="GET",s={}){if(!t)throw new Error(ERRORS[10001]);return t=t.replace(/#.*$/,""),request.BASE_URL&&(/^([a-z]+:|\/\/)/.test(t)||(t=request.BASE_URL+t)),e=e.toUpperCase(),this.xhr=new XMLHttpRequest,this.defer=Promise.defer(),this.opt={url:t,method:e,headers:{},data:{},dataType:"text",withCredentials:!1},this.defer.promise.abort=(()=>{this.cancel=!0,this.xhr.abort()}),this.__next__(Object.assign({},request.__INIT__,s)),this.defer.promise}__next__(t){t.headers&&Object.assign(this.opt.headers,t.headers);let e=!1;if(t.formType)switch(t.formType){case"form":this.__set__("form");break;case"json":this.__set__("json");break;case"form-data":this.opt.method="POST",e=!0;break;default:NOBODY_METHODS.includes(this.opt.method)?this.__set__("form"):this.__set__("text")}else this.__set__("form");if(t.cache&&NOBODY_METHODS.includes(this.opt.method)&&(this.opt.cache=!0),t.timeout=t.timeout>>>0,t.timeout>0&&(this.opt.timeout=t.timeout),t.data){switch(typeof t.data){case"number":case"string":this.__set__("text"),this.opt.data=t.data;break;case"object":"FORM"===t.data.nodeName?(this.opt.method=t.data.method.toUpperCase()||"POST",this.opt.data=Format.parseForm(t.data),(e=this.opt.data.constructor===FormData)&&delete this.opt.headers["content-type"]):t.data.constructor===FormData?(e=!0,this.opt.method="POST",delete this.opt.headers["content-type"],this.opt.data=t.data):this.opt.data=e?Format.mkFormData(t.data):t.data}}t.withCredentials&&(this.opt.withCredentials=!0);try{let t=document.createElement("a");t.href=this.opt.url,this.opt.crossDomain=originAnchor.protocol!==t.protocol||originAnchor.host!==t.host}catch(t){}this.opt.crossDomain?this.opt.withCredentials&&(this.xhr.withCredentials=!0,this.opt.headers["X-Requested-With"]="XMLHttpRequest"):this.opt.headers["X-Requested-With"]="XMLHttpRequest",!NOBODY_METHODS.includes(this.opt.method)?e||("json"===t.formType?this.opt.data=JSON.stringify(this.opt.data):this.opt.data=Format.param(this.opt.data)):(this.opt.data=Format.param(this.opt.data),this.opt.data&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+this.opt.data),!1===this.opt.cache&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+"_="+Math.random())),t.dataType&&(this.opt.dataType=t.dataType.toLowerCase()),this.xhr.responseType=this.opt.dataType,this.xhr.onreadystatechange=(t=>{this.opt.timeout>0&&(this.opt["time"+this.xhr.readyState]=t.timeStamp,4===this.xhr.readyState&&(this.opt.isTimeout=this.opt.time4-this.opt.time1>this.opt.timeout)),4===this.xhr.readyState&&this.__dispatch__(this.opt.isTimeout)}),this.xhr.open(this.opt.method,this.opt.url,!0);for(let t in this.opt.headers)this.xhr.setRequestHeader(t,this.opt.headers[t]);this.xhr.send(this.opt.data),this.opt.timeout&&this.opt.timeout>0&&(this.xhr.timeout=this.opt.timeout)}__set__(t){this.opt.headers["content-type"]=FORM_TYPES[t]}__dispatch__(t){let e={status:200,statusText:"ok",text:"",body:"",error:null};if(this.cancel)return this.__cancel__(e);if(t)return this.__timeout__(e);let s=this.xhr.status>=200&&this.xhr.status<400,o=this.xhr.getAllResponseHeaders().split("\n")||[],r="";for(let t of o)if(t=t.trim()){if("content-type"===(t=t.split(":")).shift().toLowerCase()){r=t.join(":").trim().toLowerCase();break}}switch(s?(e.status=this.xhr.status,204===e.status?e.statusText=ERRORS[10204]:304===e.status&&(e.statusText=ERRORS[10304])):(e.status=this.xhr.status||500,e.statusText=this.xhr.statusText||ERRORS[10500],e.error=new Error(e.statusText)),this.opt.dataType){case"arraybuffer":case"blob":case"document":case"json":e.text=e.body=this.xhr.response;break;default:try{let t=r.match(/json|xml|script|html/);t=t&&t[0].toLowerCase()||"text",e.text=this.xhr.response,e.body=convert[t](e.text,this.xhr.response)}catch(t){e.error=t,e.statusText=ERRORS[10012]}}this.__success__(s,e)}__success__(t,e){t?this.defer.resolve(e):this.defer.reject(e),delete this.xhr,delete this.opt,delete this.defer}__cancel__(t){t.status=0,t.statusText=ERRORS[10100],t.error=new Error(ERRORS[10100]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}__timeout__(t){t.status=504,t.statusText=ERRORS[10504],t.error=new Error(ERRORS[10504]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}}window.request||(window.request={get:(t,e={})=>new _Request(t,"GET",e),post:(t,e={})=>new _Request(t,"POST",e),upload(t,e={}){return e.formType="form-data",this.post(t,e)},download(t,e={}){return e.dataType="blob",this.get(t,e)},open:(t,e="GET",s={})=>("object"==typeof e&&(s=e,e="GET"),new _Request(t,e,s)),version:"2.0.0-normal",init(t={}){this.__INIT__=t}},Anot.ui.request=request.version);export default request; \ No newline at end of file diff --git a/src/lib/utils.js b/src/lib/utils.js new file mode 100644 index 0000000..51fe828 --- /dev/null +++ b/src/lib/utils.js @@ -0,0 +1 @@ +function noop(){}export const nextTick=function(){let t=[];let n=document.createTextNode("\x3c!-- --\x3e");new MutationObserver(function(){let n=t.length;for(let e=0;e{if(e)if(e.path){for(var o=e.path.concat();o.length>3;)if(o.shift()===t)return}else{var r=e.explicitOriginalTarget||e.target;if(t===r||t.contains(r)||t.root&&t.root.contains(r))return}n(e)})}; \ No newline at end of file From a259a4693b969cf863ffcc54d8debf7b5a526b1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 2 Sep 2019 00:05:51 +0800 Subject: [PATCH 3/6] =?UTF-8?q?UI=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/var.scss | 7 +- src/index.html | 2 - src/js/app.js | 4 +- src/js/modules/profile.js | 4 +- src/lib/css/elem-ui.css | 1 - src/lib/css/form.css | 1 - src/lib/css/layer-normal.css | 1 - src/lib/css/pager.css | 1 - src/lib/css/reset-basic.css | 61 ++++- src/lib/icon/index.js | 15 ++ src/lib/icon/svg.js | 1 + src/lib/request/index.js | 448 +++++++++++++++++++++++++++++++++- src/lib/request/lib/format.js | 226 ++++++++++++++++- src/lib/scroll/index.js | 15 ++ 14 files changed, 771 insertions(+), 16 deletions(-) delete mode 100644 src/lib/css/elem-ui.css delete mode 100644 src/lib/css/form.css delete mode 100644 src/lib/css/layer-normal.css delete mode 100644 src/lib/css/pager.css create mode 100644 src/lib/icon/index.js create mode 100644 src/lib/icon/svg.js create mode 100644 src/lib/scroll/index.js diff --git a/src/css/var.scss b/src/css/var.scss index bfe91b5..ae2d183 100644 --- a/src/css/var.scss +++ b/src/css/var.scss @@ -1,14 +1,13 @@ $ct: #3fc2a7 #19b491 #16967a; $cg: #58d68d #2ecc71 #27ae60; $cpp: #ac61ce #9b59b6 #8e44ad; -$cb: #52a3de #2d8dd6 #2776b1; +$cb: #66b1ff #409eff #3a8ee6; $cr: #ff5061 #eb3b48 #ce3742; $co: #ffb618 #f39c12 #e67e22; $cp: #f3f5fb #e8ebf4 #dae1e9; -$cgr: #98acae #8a9b9c #748182; +$cgr: #aabac3 #90a3ae #7e909a; $cd: #62778d #526273 #425064; @mixin ts($c: all, $t: .2s, $m: ease-in-out){ transition:$c $t $m; -} - +} \ No newline at end of file diff --git a/src/index.html b/src/index.html index 5099b4f..fa85a24 100644 --- a/src/index.html +++ b/src/index.html @@ -3,11 +3,9 @@ - - diff --git a/src/js/app.js b/src/js/app.js index 5292776..7df4261 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -5,8 +5,8 @@ */ import '/lib/anot.js' -import layer from '/lib/layer/index.js' -import store from '/lib/store/index.js' +import '/lib/layer/next.js' +import '/lib/store/index.js' import AudioPlayer from '/lib/audio/index.js' import Lyrics from '/lib/lyrics/index.js' diff --git a/src/js/modules/profile.js b/src/js/modules/profile.js index 1c7157d..499e8df 100644 --- a/src/js/modules/profile.js +++ b/src/js/modules/profile.js @@ -6,7 +6,9 @@ 'use strict' -import '/lib/form/index.js' +import '/lib/form/input.js' +import '/lib/form/button.js' +import '/lib/form/select.js' const { remote: { app, dialog }, diff --git a/src/lib/css/elem-ui.css b/src/lib/css/elem-ui.css deleted file mode 100644 index a0f7d6a..0000000 --- a/src/lib/css/elem-ui.css +++ /dev/null @@ -1 +0,0 @@ -.do-ui-button{display:inline-block;height:16px;padding:2px 5px;line-height:12px;border:0;border-radius:2px;text-align:center;font-size:12px;background:#e8ebf4;color:#98acae;cursor:pointer;transition:all .2s ease-in-out}.do-ui-button.medium{min-width:80px;height:30px;padding:0 8px;line-height:30px;font-size:14px}.do-ui-button.large{min-width:130px;height:45px;padding:0 13px;line-height:45px;border-radius:3px;font-size:18px}.do-ui-button:hover{background:#f3f5fb}.do-ui-button:active{background:#dae1e9}.do-ui-button.teal{background:#19b491;color:#fff}.do-ui-button.teal:hover{background:#3fc2a7}.do-ui-button.teal:active{background:#16967a}.do-ui-button.green{background:#2ecc71;color:#fff}.do-ui-button.green:hover{background:#58d68d}.do-ui-button.green:active{background:#27ae60}.do-ui-button.blue{background:#2d8dd6;color:#fff}.do-ui-button.blue:hover{background:#52a3de}.do-ui-button.blue:active{background:#2776b1}.do-ui-button.purple{background:#9b59b6;color:#fff}.do-ui-button.purple:hover{background:#ac61ce}.do-ui-button.purple:active{background:#8e44ad}.do-ui-button.red{background:#eb3b48;color:#fff}.do-ui-button.red:hover{background:#ff5061}.do-ui-button.red:active{background:#ce3742}.do-ui-button.orange{background:#f39c12;color:#fff}.do-ui-button.orange:hover{background:#ffb618}.do-ui-button.orange:active{background:#e67e22}.do-ui-button.grey{background:#8a9b9c;color:#fff}.do-ui-button.grey:hover{background:#98acae}.do-ui-button.grey:active{background:#748182}.do-ui-button.dark{background:#526273;color:#fff}.do-ui-button.dark:hover{background:#62778d}.do-ui-button.dark:active{background:#425064}.do-ui-button.disabled{background:#f3f5fb;color:#dae1e9;cursor:not-allowed}.do-ui-input{width:auto;height:30px;padding:0 5px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:13px;transition:all .2s ease-in-out;color:#526273}.do-ui-input:focus{background:#fff;border-color:#526273}.do-ui-input::placeholder{color:#98acae}.do-ui-input:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-textarea{width:auto;height:120px;padding:5px 8px;background:#f3f5fb;border:2px solid transparent;border-radius:5px;font-size:14px;transition:all .2s ease-in-out;color:#526273}.do-ui-textarea:focus{background:#fff;border-color:#526273}.do-ui-textarea:disabled{border-color:transparent;background:#fff8ed;color:#98acae;cursor:not-allowed}.do-ui-select{position:relative;display:inline-block;width:auto;min-width:100px;height:30px;color:#98acae}.do-ui-select select{width:100%;height:100%;padding:5px 13px;line-height:1;background:#f3f5fb;border-radius:5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:2px solid transparent;outline:none;color:#526273;font-size:13px}.do-ui-select select:focus{background:#fff;border-color:#526273}.do-ui-select select::-ms-expand{display:none}.do-ui-select select:disabled{border-color:transparent;background:#fff8ed;color:#dae1e9}.do-ui-select .trigon{position:absolute;right:7px;top:0;width:15px;height:30px;padding:7px 0;font-size:12px;text-align:center}.do-ui-select .trigon i{float:left;width:15px;height:12px;line-height:12px}.do-ui-select .trigon i:nth-child(2){margin-top:-6px}.do-ui-radio,.do-ui-checkbox{display:inline-block;position:relative;width:auto;height:auto;padding:0 5px 0 35px;line-height:30px;color:#62778d;font-size:13px}.do-ui-radio>input,.do-ui-checkbox>input{position:absolute;left:7px;top:5px;width:20px;height:20px;border-radius:50%;border:1px solid #dae1e9;background:#fff;-webkit-appearance:none;-moz-appearance:none;appearance:none}.do-ui-radio>input:checked,.do-ui-checkbox>input:checked{box-shadow:0 0 5px #52a3de}.do-ui-radio>input:checked::after,.do-ui-checkbox>input:checked::after{display:block;width:12px;height:12px;margin:3px;border-radius:50%;background:#98acae;content:""}.do-ui-radio>input:disabled,.do-ui-checkbox>input:disabled{background:#fff8ed;box-shadow:none;cursor:not-allowed}.do-ui-radio>input:disabled:checked::after,.do-ui-checkbox>input:disabled:checked::after{background:#98acae}.do-ui-radio.disabled,.do-ui-checkbox.disabled{color:#dae1e9;cursor:not-allowed}.do-ui-checkbox>input{border-radius:3px}.do-ui-checkbox>input:checked::after{width:100%;height:100%;margin:0;line-height:18px;font-size:18px;text-align:center;color:#98acae;background:none;content:"✓"}.do-ui-checkbox>input:disabled:checked::after{color:#98acae;background:none}.do-ui-quote{display:inline-block;position:relative;min-height:60px;margin:10px 0;padding:15px 10px 5px 50px;border:1px solid #dae1e9;border-radius:10px;background:#f3f5fb;color:#98acae;font-size:14px;word-break:break-all}.do-ui-quote i{position:absolute;left:8px;top:0;font-size:30px;line-height:1.5;color:#dae1e9}.do-ui-warn,.do-ui-mark{display:inline-block;position:relative;min-height:40px;margin:5px 0;padding:5px 8px 5px 30px;border:1px solid #ffb618;border-radius:5px;background:#fffbed;color:#e67e22;font-size:14px;word-break:break-all}.do-ui-warn p,.do-ui-mark p{margin:0 !important}.do-ui-warn i,.do-ui-mark i{position:absolute;left:5px;top:2px;font-size:20px;line-height:1.5}.do-ui-mark{border-color:#19b491;color:#16967a;background:#edfbf8} diff --git a/src/lib/css/form.css b/src/lib/css/form.css deleted file mode 100644 index 6fb314c..0000000 --- a/src/lib/css/form.css +++ /dev/null @@ -1 +0,0 @@ -.do-button{overflow:hidden;position:relative;display:inline-block;width:auto;height:30px;padding:0 10px;line-height:30px;text-align:center;cursor:pointer;font-size:14px}.do-button::before{position:absolute;left:-50%;top:-50%;display:block;width:200%;height:200%;border-radius:50%;background:rgba(220,220,220,0.5);content:"";opacity:0;-webkit-transform:scale(0, 0);transform:scale(0, 0);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),-webkit-transform 1.3s cubic-bezier(0.23, 1, 0.32, 1);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1),-webkit-transform 1.3s cubic-bezier(0.23, 1, 0.32, 1)}.do-button:hover::before{opacity:1;-webkit-transform:scale(1, 0.8);transform:scale(1, 0.8)}.do-button:active::before{background:rgba(0,0,0,0.1)}.do-button__text,.do-button__icon{position:relative;display:inline-block}.do-button__icon{font-size:20px;vertical-align:top}.do-button.small{height:20px;padding:0 5px;line-height:20px;font-size:12px}.do-button.small i{font-size:16px}.do-button.medium{min-width:100px;height:35px;line-height:35px;font-size:16px}.do-button.medium i{padding-right:5px;font-size:24px}.do-button.large{min-width:160px;height:50px;padding:0 13px;line-height:50px;font-size:18px}.do-button.large i{padding-right:10px;font-size:28px}.do-button.teal{color:#19b491}.do-button.green{color:#2ecc71}.do-button.blue{color:#2d8dd6}.do-button.purple{color:#9b59b6}.do-button.red{color:#eb3b48}.do-button.orange{color:#f39c12}.do-button.plain{color:#dae1e9}.do-button.grey{color:#8a9b9c}.do-button.dark{color:#526273}.do-button.disabled{color:#e8ebf4;cursor:not-allowed}.do-button.disabled::before{display:none}.do-radio{position:relative;display:inline-block;width:auto;height:30px;padding-right:10px;line-height:30px;text-align:center;cursor:default;font-size:14px}.do-radio__box{float:left;width:20px;height:20px;margin:5px;margin-left:0;border:1px solid #8a9b9c;border-radius:50%}.do-radio.checked .do-radio__box::after{display:block;width:14px;height:14px;margin:2px;border-radius:50%;content:""}.do-radio.teal .do-radio__box{border-color:#19b491}.do-radio.teal .do-radio__box::after{background:#19b491}.do-radio.teal{color:#19b491}.do-radio.green .do-radio__box{border-color:#2ecc71}.do-radio.green .do-radio__box::after{background:#2ecc71}.do-radio.green{color:#2ecc71}.do-radio.blue .do-radio__box{border-color:#2d8dd6}.do-radio.blue .do-radio__box::after{background:#2d8dd6}.do-radio.blue{color:#2d8dd6}.do-radio.purple .do-radio__box{border-color:#9b59b6}.do-radio.purple .do-radio__box::after{background:#9b59b6}.do-radio.purple{color:#9b59b6}.do-radio.red .do-radio__box{border-color:#eb3b48}.do-radio.red .do-radio__box::after{background:#eb3b48}.do-radio.red{color:#eb3b48}.do-radio.orange .do-radio__box{border-color:#f39c12}.do-radio.orange .do-radio__box::after{background:#f39c12}.do-radio.orange{color:#f39c12}.do-radio.plain .do-radio__box{border-color:#dae1e9}.do-radio.plain .do-radio__box::after{background:#dae1e9}.do-radio.plain{color:#dae1e9}.do-radio.grey .do-radio__box{border-color:#8a9b9c}.do-radio.grey .do-radio__box::after{background:#8a9b9c}.do-radio.grey{color:#8a9b9c}.do-radio.dark .do-radio__box{border-color:#526273}.do-radio.dark .do-radio__box::after{background:#526273}.do-radio.dark{color:#526273}.do-radio.disabled{color:#dae1e9;cursor:not-allowed;text-decoration:line-through}.do-radio.disabled.checked{color:#62778d}.do-radio.disabled .do-radio__box{border-color:#dae1e9}.do-radio.disabled .do-radio__box::after{background:#dae1e9}.do-switch{position:relative;display:inline-block;width:45px;height:30px;padding-right:10px;cursor:default}.do-switch__label{position:relative;display:inline-block;width:100%;height:14px;margin:7px 0;background:#dae1e9;border-radius:7px}.do-switch__dot{position:absolute;left:0;top:-3px;width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,0.3)}.do-switch:hover .do-switch__dot{-webkit-transform:scale(1.1);transform:scale(1.1)}.do-switch.disabled{cursor:not-allowed}.do-switch.disabled:hover .do-switch__dot{-webkit-transform:scale(1);transform:scale(1)}.do-switch.checked .do-switch__dot{left:auto;right:0}.do-switch.teal.checked .do-switch__dot{background:#19b491}.do-switch.teal.checked .do-switch__label{background:#3fc2a7a0}.do-switch.green.checked .do-switch__dot{background:#2ecc71}.do-switch.green.checked .do-switch__label{background:#58d68da0}.do-switch.blue.checked .do-switch__dot{background:#2d8dd6}.do-switch.blue.checked .do-switch__label{background:#52a3dea0}.do-switch.purple.checked .do-switch__dot{background:#9b59b6}.do-switch.purple.checked .do-switch__label{background:#ac61cea0}.do-switch.red.checked .do-switch__dot{background:#eb3b48}.do-switch.red.checked .do-switch__label{background:#ff5061a0}.do-switch.orange.checked .do-switch__dot{background:#f39c12}.do-switch.orange.checked .do-switch__label{background:#ffb618a0}.do-switch.plain.checked .do-switch__dot{background:#dae1e9}.do-switch.plain.checked .do-switch__label{background:#e8ebf4}.do-switch.grey.checked .do-switch__dot{background:#8a9b9c}.do-switch.grey.checked .do-switch__label{background:#98acaea0}.do-switch.dark.checked .do-switch__dot{background:#526273}.do-switch.dark.checked .do-switch__label{background:#62778da0}.do-switch.disabled.checked .do-switch__dot{background:#fff}.do-switch.disabled .do-switch__label::before,.do-switch.disabled.checked .do-switch__label::before{display:block;position:absolute;top:5px;width:8px;height:4px;border-radius:2px;background:#fff;content:""}.do-switch.disabled .do-switch__label::before{right:5px}.do-switch.disabled.checked .do-switch__label::before{left:5px}.do-checkbox{position:relative;display:inline-block;width:auto;height:30px;padding-right:10px;line-height:30px;text-align:center;cursor:default;font-size:14px}.do-checkbox__box{float:left;width:18px;height:18px;margin:6px;margin-left:0;line-height:16px;border:1px solid #8a9b9c;border-radius:3px;font-size:16px;text-align:center}.do-checkbox.checked .do-checkbox__box{color:#fff;font-weight:bold}.do-checkbox.grey{color:#8a9b9c}.do-checkbox.grey .do-checkbox__box{border-color:#8a9b9c}.do-checkbox.grey.checked .do-checkbox__box{background:#8a9b9c}.do-checkbox.dark{color:#526273}.do-checkbox.dark .do-checkbox__box{border-color:#526273}.do-checkbox.dark.checked .do-checkbox__box{background:#526273}.do-checkbox.teal{color:#19b491}.do-checkbox.teal .do-checkbox__box{border-color:#19b491}.do-checkbox.teal.checked .do-checkbox__box{background:#19b491}.do-checkbox.green{color:#2ecc71}.do-checkbox.green .do-checkbox__box{border-color:#2ecc71}.do-checkbox.green.checked .do-checkbox__box{background:#2ecc71}.do-checkbox.blue{color:#2d8dd6}.do-checkbox.blue .do-checkbox__box{border-color:#2d8dd6}.do-checkbox.blue.checked .do-checkbox__box{background:#2d8dd6}.do-checkbox.purple{color:#9b59b6}.do-checkbox.purple .do-checkbox__box{border-color:#9b59b6}.do-checkbox.purple.checked .do-checkbox__box{background:#9b59b6}.do-checkbox.orange{color:#f39c12}.do-checkbox.orange .do-checkbox__box{border-color:#f39c12}.do-checkbox.orange.checked .do-checkbox__box{background:#f39c12}.do-checkbox.plain{color:#dae1e9}.do-checkbox.plain .do-checkbox__box{border-color:#dae1e9}.do-checkbox.plain.checked .do-checkbox__box{background:#dae1e9}.do-checkbox.red{color:#eb3b48}.do-checkbox.red .do-checkbox__box{border-color:#eb3b48}.do-checkbox.red.checked .do-checkbox__box{background:#eb3b48}.do-checkbox.disabled{cursor:not-allowed;color:#dae1e9;text-decoration:line-through}.do-checkbox.disabled .do-checkbox__box{border-color:#dae1e9}.do-checkbox.disabled.checked{color:#62778d}.do-checkbox.disabled.checked .do-checkbox__box{background:#dae1e9}.do-input{position:relative;display:inline-block;width:180px;height:30px;line-height:30px;border-bottom:1px solid #e8ebf4;cursor:default;font-size:14px}.do-input.icon-left{padding-left:30px}.do-input.icon-right{padding-right:30px}.do-input__holder{visibility:hidden;position:absolute;bottom:0;left:0;width:100%;height:30px;padding:0 5px;color:#dae1e9;transition:bottom .2s ease-in-out}.do-input__holder.visible{visibility:visible}.do-input__input{position:relative;width:100%;height:30px;padding:0 5px;border:0;background:none;font-size:14px;color:#526273}.do-input__icon{position:absolute;bottom:0;width:30px;height:30px;text-align:center;font-size:20px}.do-input::after{position:absolute;left:50%;bottom:-1px;width:0;height:2px;content:"";transition:left .15s linear,width .15s linear}.do-input.active .do-input__holder{bottom:20px}.do-input.active::after{left:0;width:100%}.do-input.icon-left .do-input__icon{left:0}.do-input.icon-right .do-input__icon{right:0}.do-input.icon-left .do-input__holder{padding-left:30px}.do-input.icon-right .do-input__holder{padding-right:30px}.do-input.grey{color:#8a9b9c}.do-input.grey::after{background:#98acae}.do-input.dark{color:#526273}.do-input.dark::after{background:#62778d}.do-input.teal{color:#19b491}.do-input.teal::after{background:#3fc2a7}.do-input.green{color:#2ecc71}.do-input.green::after{background:#58d68d}.do-input.red{color:#eb3b48}.do-input.red::after{background:#ff5061}.do-input.blue{color:#2d8dd6}.do-input.blue::after{background:#52a3de}.do-input.purple{color:#9b59b6}.do-input.purple::after{background:#ac61ce}.do-input.orange{color:#f39c12}.do-input.orange::after{background:#ffb618}.do-input.disabled{background:#fff8ed;color:#dae1e9}.do-input.disabled .do-input__input{cursor:not-allowed;color:#dae1e9} diff --git a/src/lib/css/layer-normal.css b/src/lib/css/layer-normal.css deleted file mode 100644 index 8c5438a..0000000 --- a/src/lib/css/layer-normal.css +++ /dev/null @@ -1 +0,0 @@ -.do-layer{display:flex;justify-content:center;align-items:center;width:auto;height:auto}.do-layer a{text-decoration:none}.do-layer .layer-box{flex:0 auto;position:absolute;z-index:65535;opacity:0}.do-layer .layer-box.shift{transition:all .5s ease-out}.do-layer .layer-box.scale{transform:scale(1.02);transition:transform .1s linear}.do-layer .layer-box.skin-normal{padding:15px 10px;border-radius:3px;color:#666;font-size:14px;box-shadow:0 5px 20px rgba(0,0,0,0.3)}.do-layer .layer-box.skin-normal .layer-title{width:100%;height:43px;padding:0 10px;line-height:43px;font-size:16px;color:#526273}.do-layer .layer-box.skin-normal .layer-content{position:relative;width:100%;height:auto;min-height:50px;word-break:break-all;word-wrap:break-word}.do-layer .layer-box.skin-normal .layer-content .prompt-value{width:100%;height:30px;padding:0 8px;border:1px solid #ddd;border-radius:3px}.do-layer .layer-box.skin-normal .layer-content .prompt-value.alert{border-color:#eb3b48}.do-layer .layer-box.skin-normal .layer-content .prompt-value:focus{border-color:#19b491}.do-layer .layer-box.skin-normal .layer-content .msg-box{line-height:30px}.do-layer .layer-box.skin-normal .layer-ctrl{width:100%;height:40px;padding:5px 0;line-height:30px;font-size:14px;color:#454545;text-align:right}.do-layer .layer-box.skin-normal .layer-ctrl a{overflow:hidden;position:relative;display:inline-block;width:auto;min-width:60px;height:30px;margin-left:5px;padding:0 10px;color:#19b491;text-align:center;cursor:pointer}.do-layer .layer-box.skin-normal .layer-ctrl a::before{position:absolute;left:-50%;top:-50%;z-index:-1;display:block;width:200%;height:200%;border-radius:50%;background:#f3f5fb;content:"";opacity:0;transform:scale(0, 0);transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1)}.do-layer .layer-box.skin-normal .layer-ctrl a:hover::before{opacity:1;transform:scale(1, 0.8)}.do-layer .layer-box.skin-normal .layer-ctrl a:active{background:#e8ebf4}.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3{max-width:600px;min-width:300px}.do-layer .layer-box.type-1 .layer-content,.do-layer .layer-box.type-2 .layer-content,.do-layer .layer-box.type-3 .layer-content{padding:10px}.do-layer .layer-box.type-4{padding:0}.do-layer .layer-box.type-4 .frame-box{display:block;width:100%;height:100%;margin:0;padding:0;border:0;resize:none}.do-layer .layer-box.type-5{visibility:hidden;position:fixed;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;color:#fff;background:rgba(0,0,0,0.5);box-shadow:none}.do-layer .layer-box.type-5 i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer .layer-box.type-5 i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer .layer-box.type-5 .layer-content{min-height:20px;margin:0}.do-layer .layer-box.type-6{z-index:65539;box-shadow:none;background:transparent}.do-layer .layer-box.type-6 .layer-content{display:flex;justify-content:center;align-items:center}.do-layer .layer-box.type-toast{position:fixed;min-width:10px;padding:0;background:transparent}.do-layer .layer-box.type-toast .layer-content{min-height:40px;height:40px}.do-layer .layer-box.type-toast .toast-box{display:inline-block;position:relative;min-height:40px;padding:5px 12px 5px 50px;line-height:28px;border-radius:3px;word-break:break-all}.do-layer .layer-box.type-toast .toast-box.style-info{border:1px solid #19b491;background:#edfbf8;color:#16967a}.do-layer .layer-box.type-toast .toast-box.style-warn{border:1px solid #f39c12;background:#fffbed;color:#e67e22}.do-layer .layer-box.type-toast .toast-box.style-deny{border:1px solid #eb3b48;background:#fffbed;color:#ce3742}.do-layer .layer-box.type-toast .toast-box>i{position:absolute;left:12px;top:5px;line-height:28px;font-size:26px}.do-layer .layer-box .loading{position:relative;width:100px;height:100px;margin:auto}.do-layer .layer-box .loading .dot-box{position:absolute;display:block}.do-layer .layer-box .loading.style-1 .dot-box{width:70%;height:70%;margin:15%;line-height:70px;font-size:70px;text-align:center;animation:circle .8s infinite linear}.do-layer .layer-box .loading.style-1 .dot-box i{display:block;width:100%;height:100%}.do-layer .layer-box .loading.style-2{height:40px}.do-layer .layer-box .loading.style-2 .dot-box{display:flex;justify-content:center;width:100%;height:100%}.do-layer .layer-box .loading.style-2 .dot-box i{float:left;display:block;width:6px;height:100%;margin:0 3px;background:#16967a;animation:bounce 1s infinite ease-in-out;transform:scaleY(0.6)}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-2 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-3{width:50px;height:50px}.do-layer .layer-box .loading.style-3 .dot-box{width:100%;height:100%}.do-layer .layer-box .loading.style-3 .dot-box i{position:absolute;display:block;width:100%;height:100%;animation:circle2 2s infinite ease-in-out;transform:rotate(45deg);opacity:.5}.do-layer .layer-box .loading.style-3 .dot-box i::before{display:block;width:8px;height:8px;background:#16967a;border-radius:50%;content:""}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(2){animation-delay:.1s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(3){animation-delay:.2s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(4){animation-delay:.3s}.do-layer .layer-box .loading.style-3 .dot-box i:nth-child(5){animation-delay:.4s}.do-layer .layer-box .loading.style-4{width:60px;height:60px}.do-layer .layer-box .loading.style-4 .dot-box i{float:left;display:block;width:20px;height:20px;background:#16967a;animation:grid 1.5s infinite linear}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(4),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(8){animation-delay:.2s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(1),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(5),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(9){animation-delay:.3s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(2),.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(6){animation-delay:.4s}.do-layer .layer-box .loading.style-4 .dot-box i:nth-child(3){animation-delay:.5s}.do-layer.mask{position:fixed;z-index:65534;left:0;top:0;width:100%;height:100%;background:transparent}.do-layer.mask.shift{transition:all .5s ease-out}.do-layer.mask.inner{position:absolute}.do-layer:active{z-index:65536}.do-layer__tips{visibility:hidden;position:absolute;z-index:65534;min-width:75px;max-width:600px;padding:10px;line-height:1.5;border-radius:3px;font-size:14px;color:#fff;background:rgba(0,0,0,0.5)}.do-layer__tips i.arrow{position:absolute;width:0;height:0;border:6px solid transparent;content:""}.do-layer__tips i.offset-top{left:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom{left:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-top-left{right:5px;bottom:-14px;border-top:8px solid rgba(0,0,0,0.5)}.do-layer__tips i.offset-bottom-left{right:5px;top:-14px;border-bottom:8px solid rgba(0,0,0,0.5)}.do-layer__tips .layer-content{min-height:20px;margin:0}@keyframes circle{to{transform:rotate(360deg)}}@keyframes circle2{70%,to{transform:rotate(405deg);opacity:1}}@keyframes bounce{25%{transform:scaleY(1)}50%{transform:scaleY(0.6)}}@keyframes grid{36%{transform:scale(0.1);opacity:.3}60%{transform:scale(1);opacity:1}}@media screen and (max-width: 480px){.do-layer .layer-box.type-1,.do-layer .layer-box.type-2,.do-layer .layer-box.type-3,.do-layer .layer-box.type-4,.do-layer .layer-box.type-7{width:90%}} diff --git a/src/lib/css/pager.css b/src/lib/css/pager.css deleted file mode 100644 index 41af290..0000000 --- a/src/lib/css/pager.css +++ /dev/null @@ -1 +0,0 @@ -.do-pager{display:block;height:auto;text-align:center;font-size:14px;color:#8a9b9c}.do-pager.mini{line-height:30px}.do-pager.mini .button,.do-pager.mini .page{min-width:30px;height:30px}.do-pager.medium{line-height:35px}.do-pager.medium .button,.do-pager.medium .page{min-width:35px;height:35px}.do-pager.large{line-height:40px}.do-pager.large .button,.do-pager.large .page{min-width:40px;height:40px}.do-pager .button,.do-pager .page{display:inline-block;border:0;color:#8a9b9c;text-decoration:none;cursor:pointer;vertical-align:top;font-size:14px;font-weight:100;-webkit-appearance:none;-moz-appearance:none;appearance:none}.do-pager .button{font-size:18px}.do-pager .curr,.do-pager .disabled{cursor:default}.do-pager.skin-1{width:100%}.do-pager.skin-1 .page,.do-pager.skin-1 .button,.do-pager.skin-1 .disabled,.do-pager.skin-1 .curr{padding:0 8px;margin:0 3px}.do-pager.skin-1 .curr{font-weight:bold;font-size:15px}.do-pager.skin-1 .page.disabled{min-width:0;padding:0;background:none;color:#8a9b9c}.do-pager.skin-1 .page.disabled:hover,.do-pager.skin-1 .page.disabled:active{background:none}.do-pager.skin-1 .page.curr{background:none;color:#8a9b9c}.do-pager.skin-1 .page.curr:hover,.do-pager.skin-1 .page.curr:active{background:none}.do-pager.skin-1 .button[disabled]{cursor:not-allowed}.do-pager.skin-1 .total-box,.do-pager.skin-1 .input-box{display:inline-block;padding:0 8px}.do-pager.skin-1 .input-box input{display:inline-block;width:40px;height:30px;padding:0 3px;font-size:14px;background:#fff;border:1px solid #ddd;text-align:center}.do-pager.skin-2{float:right;width:auto}.do-pager.skin-2 .page,.do-pager.skin-2 .button,.do-pager.skin-2 .disabled,.do-pager.skin-2 .curr{float:left;margin:0;padding:0 5px;color:#fff}.do-pager.skin-2 .page.disabled{display:none}.do-pager.skin-2 .button[disabled]{cursor:not-allowed}.do-pager.skin-2 .input-box{display:none}.do-pager.skin-2 .total-box{float:left;display:inline-block;padding:0 8px}.do-pager.plain .page,.do-pager.plain .button{background:#e8ebf4;color:#8a9b9c}.do-pager.plain .page:hover,.do-pager.plain .button:hover{background:#f3f5fb}.do-pager.plain .page:active,.do-pager.plain .button:active{background:#dae1e9}.do-pager.plain .button[disabled]{background:#e8ebf4}.do-pager.plain.skin-2 .curr{background:#dae1e9}.do-pager.grey .page,.do-pager.grey .button{background:#8a9b9c;color:#fff}.do-pager.grey .page:hover,.do-pager.grey .button:hover{background:#98acae}.do-pager.grey .page:active,.do-pager.grey .button:active{background:#748182}.do-pager.grey .button[disabled]{background:#8a9b9c}.do-pager.grey.skin-2 .curr{background:#748182}.do-pager.dark .page,.do-pager.dark .button{background:#526273;color:#fff}.do-pager.dark .page:hover,.do-pager.dark .button:hover{background:#526273}.do-pager.dark .page:active,.do-pager.dark .button:active{background:#425064}.do-pager.dark .button[disabled]{background:#526273}.do-pager.dark.skin-2 .curr{background:#425064}.do-pager.red .page,.do-pager.red .button{background:#eb3b48;color:#fff}.do-pager.red .page:hover,.do-pager.red .button:hover{background:#ff5061}.do-pager.red .page:active,.do-pager.red .button:active{background:#ce3742}.do-pager.red .button[disabled]{background:#eb3b48}.do-pager.red.skin-2 .curr{background:#ce3742}.do-pager.orange .page,.do-pager.orange .button{background:#f39c12;color:#fff}.do-pager.orange .page:hover,.do-pager.orange .button:hover{background:#ffb618}.do-pager.orange .page:active,.do-pager.orange .button:active{background:#e67e22}.do-pager.orange .button[disabled]{background:#f39c12}.do-pager.orange.skin-2 .curr{background:#e67e22}.do-pager.green .page,.do-pager.green .button{background:#2ecc71;color:#fff}.do-pager.green .page:hover,.do-pager.green .button:hover{background:#58d68d}.do-pager.green .page:active,.do-pager.green .button:active{background:#27ae60}.do-pager.green .button[disabled]{background:#2ecc71}.do-pager.green.skin-2 .curr{background:#27ae60}.do-pager.teal .page,.do-pager.teal .button{background:#19b491;color:#fff}.do-pager.teal .page:hover,.do-pager.teal .button:hover{background:#3fc2a7}.do-pager.teal .page:active,.do-pager.teal .button:active{background:#16967a}.do-pager.teal .button[disabled]{background:#19b491}.do-pager.teal.skin-2 .curr{background:#16967a}.do-pager.blue .page,.do-pager.blue .button{background:#2d8dd6;color:#fff}.do-pager.blue .page:hover,.do-pager.blue .button:hover{background:#52a3de}.do-pager.blue .page:active,.do-pager.blue .button:active{background:#2776b1}.do-pager.blue .button[disabled]{background:#2d8dd6}.do-pager.blue.skin-2 .curr{background:#2776b1}.do-pager.purple .page,.do-pager .button .page{background:#9b59b6;color:#fff}.do-pager.purple .page:hover,.do-pager .button .page:hover{background:#ac61ce}.do-pager.purple .page:active,.do-pager .button .page:active{background:#8e44ad}.do-pager.purple .button[disabled],.do-pager .button .button[disabled]{background:#9b59b6}.do-pager.purple.skin-2 .curr,.do-pager .button.skin-2 .curr{background:#8e44ad} diff --git a/src/lib/css/reset-basic.css b/src/lib/css/reset-basic.css index 5031c4d..4546277 100644 --- a/src/lib/css/reset-basic.css +++ b/src/lib/css/reset-basic.css @@ -1 +1,60 @@ -@font-face{font-family:"uifont";src:url("data:application/x-font-woff;charset=utf-8;base64,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") format("woff")}*{margin:0;padding:0;vertical-align:baseline;box-sizing:border-box}::before,::after{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,textarea,button:focus,input:focus,textarea:focus{outline:none}::-moz-focus-inner{border:none;outline:none}body{font-family:Helvetica, Arial,"WenQuanYi Micro Hei","PingFang SC","Hiragino Sans GB","Segoe UI", "Microsoft Yahei", sans-serif;-webkit-font-smoothing:antialiased;text-size-adjust:100%;-webkit-tap-highlight-color:transparent}code,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}[anot],[\:repeat],[\:if],[is-widget],slot{visibility:hidden}.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;-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}[class^="do-icon-"],[class*=" do-icon-"]{display:inline-block;font-family:"uifont" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.do-icon-app1:before{content:"\e6cc"}.do-icon-apple:before{content:"\e6cd"}.do-icon-bad:before{content:"\e6ce"}.do-icon-android:before{content:"\e6cf"}.do-icon-app2:before{content:"\e6d0"}.do-icon-bell:before{content:"\e6d1"}.do-icon-calendar:before{content:"\e6d2"}.do-icon-book:before{content:"\e6d3"}.do-icon-camera:before{content:"\e6d4"}.do-icon-chart:before{content:"\e6d5"}.do-icon-close:before{content:"\e6d6"}.do-icon-chat:before{content:"\e6d7"}.do-icon-client:before{content:"\e6d8"}.do-icon-dbl-left:before{content:"\e6d9"}.do-icon-dbl-right:before{content:"\e6da"}.do-icon-deny:before{content:"\e6db"}.do-icon-download:before{content:"\e6dc"}.do-icon-edit:before{content:"\e6dd"}.do-icon-email:before{content:"\e6de"}.do-icon-face:before{content:"\e6df"}.do-icon-female:before{content:"\e6e0"}.do-icon-fire:before{content:"\e6e1"}.do-icon-donate:before{content:"\e6e2"}.do-icon-first:before{content:"\e6e3"}.do-icon-eye:before{content:"\e6e4"}.do-icon-floppy:before{content:"\e6e5"}.do-icon-fly:before{content:"\e6e6"}.do-icon-folder-close:before{content:"\e6e7"}.do-icon-folder-open:before{content:"\e6e8"}.do-icon-font:before{content:"\e6e9"}.do-icon-get:before{content:"\e6ea"}.do-icon-git:before{content:"\e6eb"}.do-icon-gift:before{content:"\e6ec"}.do-icon-github:before{content:"\e6ed"}.do-icon-good:before{content:"\e6ee"}.do-icon-google:before{content:"\e6ef"}.do-icon-headset:before{content:"\e6f0"}.do-icon-happy:before{content:"\e6f1"}.do-icon-help:before{content:"\e6f2"}.do-icon-home:before{content:"\e6f3"}.do-icon-icon-list:before{content:"\e6f4"}.do-icon-info:before{content:"\e6f5"}.do-icon-layout:before{content:"\e6f6"}.do-icon-left:before{content:"\e6f7"}.do-icon-link:before{content:"\e6f8"}.do-icon-list:before{content:"\e6f9"}.do-icon-live:before{content:"\e6fa"}.do-icon-loading:before{content:"\e6fb"}.do-icon-lock:before{content:"\e6fc"}.do-icon-linux:before{content:"\e6fd"}.do-icon-logout:before{content:"\e6fe"}.do-icon-maximize:before{content:"\e6ff"}.do-icon-maximized:before{content:"\e700"}.do-icon-male:before{content:"\e701"}.do-icon-menu-dot:before{content:"\e702"}.do-icon-menu-left:before{content:"\e703"}.do-icon-menu-right:before{content:"\e704"}.do-icon-minimize:before{content:"\e705"}.do-icon-mute:before{content:"\e706"}.do-icon-osx:before{content:"\e707"}.do-icon-phone:before{content:"\e708"}.do-icon-picture:before{content:"\e709"}.do-icon-pipe:before{content:"\e70a"}.do-icon-pin:before{content:"\e70b"}.do-icon-position:before{content:"\e70c"}.do-icon-plus:before{content:"\e70d"}.do-icon-plugin:before{content:"\e70e"}.do-icon-post:before{content:"\e70f"}.do-icon-qr:before{content:"\e710"}.do-icon-quote:before{content:"\e711"}.do-icon-right:before{content:"\e712"}.do-icon-sad:before{content:"\e713"}.do-icon-safe:before{content:"\e714"}.do-icon-search:before{content:"\e715"}.do-icon-second:before{content:"\e716"}.do-icon-setting:before{content:"\e717"}.do-icon-share:before{content:"\e718"}.do-icon-sign:before{content:"\e719"}.do-icon-star-full:before{content:"\e71a"}.do-icon-star:before{content:"\e71b"}.do-icon-tag:before{content:"\e71c"}.do-icon-talk:before{content:"\e71e"}.do-icon-third:before{content:"\e71f"}.do-icon-time:before{content:"\e720"}.do-icon-trigon-down:before{content:"\e721"}.do-icon-trash:before{content:"\e722"}.do-icon-track:before{content:"\e723"}.do-icon-trigon-up:before{content:"\e724"}.do-icon-txt:before{content:"\e725"}.do-icon-unmute:before{content:"\e726"}.do-icon-vip:before{content:"\e727"}.do-icon-windows:before{content:"\e728"}.do-icon-upload:before{content:"\e729"}.do-icon-warn:before{content:"\e72a"}.do-icon-user:before{content:"\e72b"}.do-icon-backward:before{content:"\e71d"} +@charset "UTF-8"; +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2014-10-10 00:45:09 + * + * doui的CSS规范 + * + * 不能出现大写,以连字符风格命名 + * 表示状态的应该用do-st-*命名 + * 表示功能的应该用do-fn-*命名 + * 表示页面模块的应该用do-mod-modname 命名 + * 表示UI组件的应该用do-uiname命名, 它的子元素应该全部包在 .do-uiname这个根类下 + * 如 .do-layer .body { ... } + * + * 样式规则的出现顺序 + * 1 display float position overflow z-index 表示定位/布局的属性 + * 2 width height margin padding border 表示盒子模型的属性 + * 3 line-height font-size vertical-align text-align user-select outline ....排版相关的属性 + * 4 color background opacity cursor ...表示装饰相关的属性 + * 5 content list-style quotes ... 内容生成相关的属性 + * + */ + + +* {margin: 0;padding: 0;vertical-align: baseline;box-sizing:border-box;} +::before,::after {box-sizing:border-box;} +/* HTML5 display-role reset for older browsers */ +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,textarea,button:focus,input:focus,textarea:focus {outline:none;} +::-moz-focus-inner { + border:none;outline:none; +} +body {font-family:Helvetica, Arial,"WenQuanYi Micro Hei","PingFang SC","Hiragino Sans GB","Segoe UI", "Microsoft Yahei", sans-serif;-webkit-font-smoothing: antialiased;text-size-adjust: 100%;-webkit-tap-highlight-color: transparent;} +code,pre,samp {font-family:Menlo,Monaco,Consolas,"Courier New",monospace;} +[anot],[\:repeat],[\:if],[is-widget],slot {visibility:hidden;} + +.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;} + +[class^="do-icon-"], [class*=" do-icon-"] {display:inline-block;font-family:"uifont" !important;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;} + + diff --git a/src/lib/icon/index.js b/src/lib/icon/index.js new file mode 100644 index 0000000..dcacff8 --- /dev/null +++ b/src/lib/icon/index.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import SVG_DICT from"./svg.js";export default class Icon extends HTMLElement{static get observedAttributes(){return["is"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{is:""},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__ICO__=this.root.lastElementChild,this.drawPath()}drawPath(){var{is:o}=this.props,t=SVG_DICT[o];this.__ICO__&&o&&t&&(this.__ICO__.innerHTML="loading"===o?t:``,this.__ICO__.classList.toggle("load","loading"===o))}get is(){return this.props.is}set is(o){this.props.is=o,this.drawPath()}attributeChangedCallback(o,t,e){if(t!==e)switch(o){case"is":this.is=e,e||this.removeAttribute("is")}}}; + +if(!customElements.get('wc-icon')){ + customElements.define('wc-icon', Icon) +} diff --git a/src/lib/icon/svg.js b/src/lib/icon/svg.js new file mode 100644 index 0000000..670e221 --- /dev/null +++ b/src/lib/icon/svg.js @@ -0,0 +1 @@ +"use strict";export default{at:"M532.7 417.9c-22.6 0-39.8 9.5-51.7 28.4-11.8 19-19.6 47.4-23.3 85.3-1.9 25.2 0 44.2 5.8 57.1 5.8 12.9 15.3 19.4 28.2 19.4 11.8 0 22.2-3.2 31.4-9.5s17.4-17.9 24.3-34.9l13.1-142.2c-4.7-1.1-9.5-1.9-14-2.6-4.8-0.8-9.3-1-13.8-1zM512 64C264.5 64 64 264.5 64 512s200.5 448 448 448 448-200.5 448-448S759.5 64 512 64z m275.3 434.9c-1.9 46.1-16.4 85.9-43.1 119.8-26.7 33.6-66.8 50.4-119.8 50.4-17.7 0-33-4.7-45.7-14.2-12.9-9.5-22-23-27.1-40.5-8.8 17.9-20.2 31.2-33.8 40.1-13.6 8.8-29.5 13.4-47.8 13.4-32.5 0-57.3-12.5-74.5-37.3s-23.5-57.7-19-98.9c5.6-52.6 21.5-94.8 47.8-126.4s58.2-47.4 95.6-47.4c26.3 0 47.6 2.8 63.5 8.2 15.9 5.4 33.6 12.3 52.8 23.7l-1.1-0.2h1.7l-16.6 179.6c-1.1 18.3 0.2 31.4 3.7 38.3 3.7 6.9 8.4 10.6 14.4 10.6 24.3 0 43.9-11 58.6-33.6 14.6-22.6 22.8-50.8 24.6-85.3 3.4-71.1-11-126.4-43.5-166.1-32.5-39.6-82.5-59.7-150.1-59.7-65.7 0-118 21.3-156.8 64.2s-59.7 101-63.1 174.9c-3.7 71.9 12.1 128.8 47.2 170.4 35.1 41.8 85.5 62.7 151.4 62.7 18.3 0 37.3-1.9 57.1-5.8 19.6-3.9 36.8-8.8 51-14.6l12.5 52.1c-14.6 8.8-33.2 15.7-55.8 20.7-22.6 5-44.6 7.3-66.1 7.3-87.9 0-155.7-26.1-203.1-78.4-47.4-52.1-69.4-123.6-65.7-214.5 3.9-90 32.1-161.3 84.2-214.1 52.3-52.8 121.7-79 208.3-79 85.1 0 150.3 25 195.4 74.7 45.6 49.8 66.3 118.1 62.9 204.9z",attach:"M872.7 458.8L499.9 831.6c-74.6 74.6-196.6 74.6-271.1 0-74.6-74.6-74.6-196.6 0-271.1l389.7-389.7c47.4-47.4 122-47.4 169.5 0 47.4 47.4 47.4 122 0 169.5L398.2 730c-18.6 18.6-49.1 18.6-67.8 0-18.6-18.6-18.6-49.1 0-67.8l322-322-50.8-50.8-322 322c-47.4 47.4-47.4 122 0 169.5 47.4 47.4 122 47.4 169.5 0l389.7-389.7c74.6-74.6 74.6-196.6 0-271.1s-196.6-74.6-271.1 0L178 509.7C74.6 613 74.6 779.1 178 882.5s269.4 103.4 372.8 0l372.8-372.8-50.9-50.9z",bell:"M512 911.1c-37.2 0-69.8-25.6-79.1-60.5H384c9.3 62.8 62.8 109.4 128 109.4s118.7-48.9 128-109.4h-48.9c-9.3 34.9-41.9 60.5-79.1 60.5z m336-238.2c0-9-4.5-18-13.5-20.3-2.3 0-121.8-65.4-121.8-241.3 2.3-51.9-20.3-162.4-124-196.2-2.3 0-2.3 0-4.5-2.3 11.3-15.8 20.3-36.1 20.3-56.4 0-49.6-40.6-92.5-92.5-92.5s-92.5 40.6-92.5 92.5c0 20.3 6.8 40.6 20.3 56.4-2.3 0-4.5 0-4.5 2.3C331.6 248.9 309 357.2 311.3 409c0 175.9-115 239-121.8 243.5-6.8 4.5-13.5 11.3-13.5 20.3v121.8c0 6.8 2.3 13.5 6.8 18s11.3 6.8 15.8 6.8h626.9c6.8 0 13.5-2.3 15.8-6.8 4.5-4.5 6.8-11.3 6.8-18V672.9zM512 111c24.6 0 44.8 20.2 44.8 44.8 0 24.6-20.2 44.8-44.8 44.8-24.6 0-44.8-20.2-44.8-44.8 0-24.6 20.2-44.8 44.8-44.8zM242 761v-80.1c33.8-23.8 124.5-101.8 124.5-266.3 0-4.3-2.1-112.6 86.5-142.9 6.3-2.2 27.4-8.7 59.1-8.7 31.6 0 52.7 6.5 59.1 8.7 88.6 30.3 86.5 138.6 86.5 142.9 0 164.6 90.7 242.5 124.5 266.3V761H242z",calendar:"M315.3 323.8c-18 0-32.7-14.1-32.7-31.3V128.2c0-17.3 14.7-31.3 32.7-31.3 18 0 32.7 14.1 32.7 31.3v164.3c-0.1 17.2-14.7 31.3-32.7 31.3z m528.5 603.4H180.2C116.1 927.2 64 876 64 813.2V300.8c0-62.9 52.1-114 116.2-114h38.9c18 0 32.7 14.1 32.7 31.3 0 17.3-14.7 31.3-32.7 31.3h-38.9c-28.1 0-50.9 23-50.9 51.3v512.4c0 28.3 22.8 51.3 50.9 51.3h663.5c28.1 0 50.9-23 50.9-51.3V300.8c0-28.3-22.8-51.3-50.9-51.3H810c-18 0-32.7-14.1-32.7-31.3 0-17.3 14.7-31.3 32.7-31.3h33.7c64.1 0 116.2 51.1 116.2 114v512.4c0.1 62.7-52 113.9-116.1 113.9zM708.7 323.8c-18 0-32.7-14.1-32.7-31.3V128.2c0-17.3 14.7-31.3 32.7-31.3 18 0 32.7 14.1 32.7 31.3v164.3c0 17.2-14.7 31.3-32.7 31.3z m43.8 393.1h-481c-18 0-32.7-14.1-32.7-31.3 0-17.3 14.7-31.3 32.7-31.3h480.9c18 0 32.7 14.1 32.7 31.3 0 17.3-14.6 31.3-32.6 31.3z m0-205.3h-481c-18 0-32.7-14.1-32.7-31.3 0-17.3 14.7-31.3 32.7-31.3h480.9c18 0 32.7 14.1 32.7 31.3 0 17.2-14.6 31.3-32.6 31.3z m-131.2-267H399.9c-18 0-32.7-14.1-32.7-31.3 0-17.3 14.7-31.3 32.7-31.3h221.4c18 0 32.7 14.1 32.7 31.3 0 17.2-14.7 31.3-32.7 31.3z",camera:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m271.5 719.5C711 856.1 614.6 896 512 896s-199-39.9-271.5-112.5C167.9 711 128 614.6 128 512s39.9-199 112.5-271.5C313 167.9 409.4 128 512 128s199 39.9 271.5 112.5C856.1 313 896 409.4 896 512s-39.9 199-112.5 271.5zM400.1 212.1c-81.3 30.3-146.9 92.8-181.4 171.9H512L400.1 212.1zM825.6 576c4.3-21.1 6.4-42.5 6.4-64 0-73.2-24.6-140.7-66-194.7L622 576h203.6zM719.9 268.8C664 220.9 591.4 192 512 192c-15.9 0-31.6 1.2-46.9 3.4L621.7 448l98.2-179.2zM198.4 448c-4.3 21.1-6.4 42.5-6.4 64 0 73.3 24.6 140.8 66.1 194.7L402 448H198.4z m425.5 363.9c81.3-30.3 146.9-92.8 181.4-171.9H512l111.9 171.9z m-319.8-56.7C360 803.1 432.6 832 512 832c15.9 0 31.6-1.2 46.9-3.4L402.3 576l-98.2 179.2z",chart:"M321.4 812.4h-108V548h108v264.4z m165.2 0h-108V283.6h108v528.8z m165.2 0h-108V415.8h108v396.6z m158.9 0h-108V213.6h108v598.8zM960 876.8c0-10.6-8.4-19.2-18.7-19.2H82.7c-10.3 0-18.7 8.6-18.7 19.2S72.4 896 82.7 896h858.7c10.2 0 18.6-8.6 18.6-19.2zM85.3 128H80c-8.8 0-16 7.2-16 16v736c0 8.8 7.2 16 16 16h5.3c8.8 0 16-7.2 16-16V144c0-8.8-7.2-16-16-16z","checkbox-on":"M860.4 64H163.6C108.8 64 64 108.8 64 163.6v696.9c0 54.8 44.8 99.6 99.6 99.6h696.9c54.8 0 99.6-44.8 99.6-99.6V163.6C960 108.8 915.2 64 860.4 64z m-448 696.9L163.6 512l69.7-69.7 179.2 179.2 378.3-378.3 69.7 69.7-448.1 448z","checkbox-off":"M860.2 163.6v696.8H163.6V163.6h696.6m0-99.6H163.6C108.8 64 64 108.8 64 163.6v696.8c0 54.8 44.8 99.6 99.6 99.6h696.8c54.8 0 99.6-44.8 99.6-99.6V163.6c-0.2-54.8-45-99.6-99.8-99.6z",close:"M925.9 960c-9.1 0-17.7-3.5-24.1-10L512 560.2 122.2 950c-6.4 6.4-15 10-24.1 10-9.1 0-17.7-3.5-24.1-10-13.3-13.3-13.3-34.9 0-48.2L463.8 512 74 122.2C60.7 108.9 60.7 87.3 74 74c13.3-13.3 34.9-13.3 48.2 0L512 463.8 901.8 74c13.3-13.3 34.9-13.3 48.2 0 13.3 13.3 13.3 34.9 0 48.2L560.2 512 950 901.8c13.3 13.3 13.3 34.9 0 48.2-6.4 6.5-15 10-24.1 10z",color:"M512 64C283.2 64 96 265.6 96 512s187.2 448 416 448c39.3 0 69.3-32.3 69.3-74.7 0-19.9-6.9-37.3-18.5-49.8-11.6-12.4-18.5-29.9-18.5-49.8 0-42.3 30-74.7 69.3-74.7h83.2c127.1 0 231.1-112 231.1-248.9C928 243.2 740.8 64 512 64zM256 512c-36.3 0-64-27.7-64-64s27.7-64 64-64 64 27.7 64 64-27.7 64-64 64z m128-192c-36.3 0-64-27.7-64-64s27.7-64 64-64 64 27.7 64 64-27.7 64-64 64z m256 0c-36.3 0-64-27.7-64-64s27.7-64 64-64 64 27.7 64 64-27.7 64-64 64z m128 192c-36.3 0-64-27.7-64-64s27.7-64 64-64 64 27.7 64 64-27.7 64-64 64z","dbl-left":"M536.2 948.6L76.3 539.7l-0.3-0.3c-7.7-7.4-12-17.2-12-27.6 0-12.4 6.1-23.9 16.8-31.6L536.3 75.3c8.1-7.3 19-11.3 30.5-11.3 24.2 0 43.9 18.1 43.9 40.3 0 11.1-4.8 21.4-13.4 29L171.2 512l426.1 378.7c8.5 7.6 13.4 18.1 13.4 29 0 22.2-19.7 40.3-43.9 40.3-11.3 0-22.2-4-30.6-11.4z m349.4 0l-460-408.9-0.3-0.3c-7.7-7.4-12-17.2-12-27.6 0-12.4 6.1-23.9 16.8-31.6L885.6 75.3c8.2-7.3 19-11.3 30.5-11.3 24.2 0 43.9 18.1 43.9 40.3 0 11.1-4.8 21.4-13.4 29L520.5 512l426.1 378.7c8.5 7.6 13.4 18.1 13.4 29 0 22.2-19.7 40.3-43.9 40.3-11.3 0-22.2-4-30.5-11.4z","dbl-right":"M457.2 960c-24.2 0-43.9-18.1-43.9-40.3 0-10.9 4.9-21.4 13.4-29L852.8 512 426.7 133.2c-8.6-7.5-13.4-17.8-13.4-29 0-22.2 19.7-40.3 43.9-40.3 11.5 0 22.4 4 30.6 11.3l455.5 404.9c10.7 7.7 16.8 19.2 16.8 31.6 0 10.4-4.3 20.2-12 27.6l-0.3 0.3-460 409c-8.4 7.4-19.3 11.4-30.6 11.4z m-349.3 0C83.7 960 64 941.9 64 919.7c0-10.9 4.9-21.4 13.4-29L503.5 512 77.4 133.2c-8.6-7.5-13.4-17.8-13.4-29C64 82.1 83.7 64 107.9 64c11.5 0 22.4 4 30.6 11.3L594 480.2c10.7 7.7 16.8 19.2 16.8 31.6 0 10.4-4.3 20.2-12 27.6l-0.3 0.3-460.1 408.9c-8.3 7.4-19.2 11.4-30.5 11.4z",download:"M639.8 187.8H384.2v60.8h255.7v-60.8z m0-59.4H384.2v31.8h255.7v-31.8z m224.6 237.3H639.8v-87.3H384.2v87.3H161.8l349 340.1 353.6-340.1z m19.4 289.6l-30.7 151.2H170.8l-30.6-151.2H64v240.3h896V655.3h-76.2z",edit:"M835 298.7L685.5 154.2l74.8-72.3c24.8-23.9 64.9-23.9 89.6 0l59.8 57.8c24.8 24 24.8 62.8 0 86.8L835 298.7zM400.8 718.5L251.4 574l406.3-389.8 149.4 144.5-406.3 389.8zM131.3 837l90.9-234.9 148.2 143.3L131.3 837z m791.4 123H101.3C80.8 960 64 943.2 64 922.7c0-20.5 16.8-37.3 37.3-37.3h821.3c20.5 0 37.3 16.8 37.3 37.3 0.1 20.5-16.7 37.3-37.2 37.3z",eye:"M512 210c-203.6 0-376.8 124.8-448 302 71.2 177.2 244.4 302 448 302s376.8-124.8 448-302c-71.2-177.2-244.4-302-448-302z m0 503.4c-112 0-203.6-90.6-203.6-201.4S400 310.6 512 310.6 715.6 401.2 715.6 512 624 713.4 512 713.4z m0-322.2c-67.2 0-122.2 54.4-122.2 120.8s55 120.8 122.2 120.8S634.2 578.4 634.2 512s-55-120.8-122.2-120.8z","eye-off":"M512.1 289.6c112.4 0 203.8 90.6 203.8 202.2 0 26.2-5.2 51-14.6 74l119 118c61.6-51 110-116.8 139.8-192-70.6-177.4-244.5-303.1-448.3-303.1-57 0-111.6 10.2-162.2 28.2l88 87.4c23.1-9.3 48.1-14.7 74.5-14.7zM104.8 179.5l93 92.2 18.8 18.6C148.8 342.2 95.8 411.8 64 491.8c70.4 177.4 244.3 303.1 448.1 303.1 63.2 0 123.4-12.2 178.4-34l17.2 17 119.4 118 51.8-51.4-722.5-716.4-51.6 51.4z m225.1 223.3l63.2 62.6c-2 8.4-3.2 17.4-3.2 26.2 0 67 54.6 121.2 122.2 121.2 9 0 18-1.2 26.4-3.2l63.2 62.6c-27.2 13.4-57.4 21.4-89.6 21.4-112.4 0-203.8-90.6-203.8-202.2 0-31.6 8.2-61.4 21.6-88.6z m175.6-31.4l128.4 127.4 0.8-6.4c0-67-54.6-121.2-122.2-121.2l-7 0.2z","finger-print":"M156.2 411.2c-4.8 0-9.8-1.2-14.2-3.8-13.4-7.8-18-24.8-10.2-38.2C167.4 309.2 275.6 169 512 169c102.4 0 192.2 27.2 266.8 80.8 61.4 44 95.8 93.8 112.2 117.8 8.8 12.8 5.4 30-7.4 38.8-12.8 8.6-30.4 5.4-39.2-7.4-29.8-43.2-120.2-174.4-332.4-174.4-207.2 0-300.8 120.8-331.4 172.6-5.2 9.2-14.6 14-24.4 14zM631 960c12.6 0 24-8.4 27.4-21 3.8-14.8-5.2-30-20.4-33.8C501 870.8 443.8 729 439.4 717.8c-1.4-4.6-7.4-27.4-9.4-55.6-2-27-0.6-64.2 17.4-88 13.2-17.4 34.4-25.8 64.6-25.8 55 0 64.2 27.2 78.6 83.6 14 55 33.2 130.4 140 135.8 41 2 78-16.4 104-51.6 39-52.8 46.4-133.6 18.8-205.6-21.6-56.4-63.2-112.8-114-154.8-65.6-54-144.2-82.6-227.4-82.6-180 0-299.6 123.2-338.4 245.4C138 631.4 181.2 795 183 802c4 14.8 19.6 23.8 34.6 19.8 15-3.8 24-19.2 20-34-0.4-1.4-40.8-154.8-10-252.4 16.6-52.4 51.2-103.4 94.8-139.6C375 352.2 440.6 329 512 329c167.2 0 262 131.8 288.8 201.8 20.8 54 16 115.4-11.6 153-10.2 13.8-28.2 30-55.6 28.6-62.4-3.2-73.2-34.4-88.2-93.8-7.2-28.6-14.6-58.2-33-82.2-22.4-29.4-55-43.6-100.2-43.6-48.6 0-85.4 16.2-109.6 48-52.8 69.6-18.4 188.4-17 193.4l0.4 1.6c2.6 7.2 66.6 180.4 238 223.4 2.4 0.6 4.6 0.8 7 0.8z m-220-12.8c6.8 0 13.8-2.6 19-7.4 11.4-10.4 12-28.2 1.4-39.4-60.4-64-94.6-135.6-107.4-225.6-6.4-52.8 2.6-132.6 49-184.4 32.2-36 79-54.2 138.8-54.2 69.2 0 121.6 31.2 156 92.6 27.4 48.8 33 98.8 33 99.4 1.6 15.2 15.6 26.4 31 24.8s26.8-15.2 25.2-30.6c-0.2-2.4-6.6-60.6-38.8-119-44.4-80.4-115.6-123-206.2-123-76.6 0-137.6 24.6-181 73-58.8 65.6-70.8 161-62.6 228.4v0.6c14.6 101.8 53.4 183.2 122 256 5.6 5.8 13 8.8 20.6 8.8zM727 867c12.8 0 26.2-0.8 39.8-2.4 15.4-1.6 26.6-15.4 24.8-30.8-1.8-15.4-15.8-26.4-31.2-24.6-61.6 7-111.6-5-149-35.2-63.2-51.2-71.4-140.2-71.6-141.8-1.2-15.4-14.6-26.8-30.2-25.6s-27.2 14.6-26 30c0.4 4.6 9.6 113.4 91.6 180.2C616 850.2 667 867 727 867z m64.6-716c0 15.4-12.6 27.8-28.2 27.8-6.4 0-12.2-2-17-5.6l-0.4 0.4 0.2 0.2c-0.8-0.4-72.6-54-234.2-54s-233.4 53.4-234.2 54l0.2-0.2c-4.6 3.2-10.2 5.2-16.4 5.2-15.6 0-28.2-12.4-28.2-27.8 0-8.2 3.6-15.6 9.4-20.8 0 0 0.2 0 0.4-0.2 1-1 2.2-1.8 3.4-2.6C265 114.6 348.2 64 512 64c156 0 239 45.8 262.4 61.2 10.2 4.2 17.2 14.2 17.2 25.8z",fire:"M622.5 959.8c-29.2-27.3-63-64.1-77.5-99.5-35.2-86 0-170.6 0-170.6s-113.8 12-167.3 155c-15.6 41.7 4.2 84.7 27 115.4C245.3 918.4 129 787.8 129 632.8c0-85.6 69.4-139.2 128-199.1 33.8-34.5 64-170.6 64-170.6s49.6 59.6 64 142.2c19.3 111.3 0 142.2 0 142.2s94.4-64.9 96-199C482.7 197.2 385 64 385 64s223.5 111.6 279.9 255.2c67.1 171 40.1 342 40.1 342s65.6-38 96-85.3c33.5-52.1 32-113.7 32-113.7s62.5 92 64 170.6c2.9 154.7-115 285.2-274.5 327z",first:"M733.2 611.4c-4.8-10.3-18.1-15.2-29.8-10.8-11.6 4.3-17.2 16.3-12.4 26.6L771.9 801l-148.4-26.7c-9.1-1.6-18.5 1.9-23.7 8.9l-83.3 113.3-4.2 6.5-4.9-6.4L424.2 784c-5.1-6.9-14.5-10.4-23.7-8.6l-148.4 28.1 81.1-174.6c4.8-10.4-0.7-22.2-12.3-26.5-11.6-4.2-25 0.7-29.8 11.1l-97.6 210.2c-3.2 7-1.9 14.9 3.5 20.7 5.4 5.8 13.9 8.4 22.2 6.8L394.6 818l98.2 133c2.6 3.5 6.2 6.1 10.3 7.6 1.9 0.7 4 1.1 6.1 1.3 0.2 0 3.7 0.1 4.6 0.1h0.3c6.8-0.6 13-3.9 16.8-9.1L629.4 817l175.4 31.5c4.6 0.8 9.2 0.4 13.3-1.2 3.4-1.3 6.4-3.3 8.8-5.9 5.4-5.8 6.7-13.8 3.5-20.7l-97.2-209.3zM512 64c-156.9 0-284.5 127.6-284.5 284.5S355.1 632.9 512 632.9s284.5-127.6 284.5-284.5S668.9 64 512 64z m20.9 127.4v320.2h-42.8V284.3h-74.7v-31.9c27.6 0 46.9-3.5 57.8-10.5 12.4-8.2 21.9-25.1 28.2-50.6h31.5z",fly:"M471.7 926.5h-57.9V728.6c0-16.6 3.4-39.9 29.6-72.3 13.7-16.9 285-330.6 383.7-444.7l-675 362.6 217.9 77-16.7 54.4-9.5-3.3c-9.6-3.3-236.2-81.6-258.3-91.9-12.9-6-21-17.9-21.5-31.8-0.6-16.6 9.2-32.2 26.3-41.7 26.9-15 765.6-403.4 809.7-426.6 4.6-3.8 22.3-17.2 41.3-11.4l1.2 0.4 1.1 0.7c18.5 11.5 16.9 28.5 16 38.7-0.2 2-0.4 3.9-0.4 5.3v2.5l-0.9 1.6c-5.1 16.6-50.8 251.5-84.3 423.4-27 138.8-43.9 225.1-46.5 235.5-3.8 20.4-14.1 36.9-28.5 45.2-11.7 6.7-25 7.7-38.6 2.8-25.3-6.2-242.8-78.3-252.2-81.4l-10-3.3 23.8-59 8.7 2.9c91.7 31 230.8 77.5 244.2 80.8h0.9c2.3-13.5 12.7-68.5 58.8-307.2 20.7-106.9 41.5-214.6 52.1-269.3C771 355.9 503.6 673 481 698.6c-5 9.3-9.3 17.6-9.3 29.9v198z","folder-open":"M107.6 845.9l10.9 1.2c1.3 0.1 2.6 0.2 3.9 0.2H783c14.3 0 27-9 30.7-21.9l120.9-417.9c2.6-9 0.6-18.3-5.5-25.7-6.1-7.3-15.2-11.5-25.2-11.5h-94.5v-43.2c0-17.3-15.2-31.4-33.9-31.4H375.3c-4.6 0-9-1.7-12.3-4.7l-54-50c-6.4-5.9-14.9-9.2-23.9-9.2H117.3c-18.7 0-33.8 14.1-33.8 31.4v552.6c0 14.2 10.2 26.2 24.1 30.1z m679.3 20.9H117.6C88 866.8 64 842.7 64 813.1V210.9c0-29.6 24-53.7 53.6-53.7h168.7c14.3 0 27.8 5.6 37.9 15.8l53.7 53.9h401.4c29.6 0 53.6 24.1 53.6 53.7v27.6h75.5c16.2 0 31.1 7.4 40.9 20.2 9.8 12.8 13 29.1 8.9 44.7L836.7 828.5c-6.1 22.5-26.5 38.3-49.8 38.3z m20-18.8H92.1c-5.2 0-9.9-2.4-13.1-6.5-3.1-4.1-4.1-9.3-2.8-14.3L207 334.6c1.9-7.2 8.5-12.3 15.9-12.3h714.8c5.2 0 10 2.4 13.1 6.5 3.1 4.1 4.1 9.3 2.8 14.3L822.8 835.8c-1.9 7.2-8.5 12.2-15.9 12.2zM83 804.5V203.6c0-10.2 8.3-18.5 18.4-18.5H280c4.9 0 9.6 1.9 13 5.4l57.5 58.1c6.8 6.9 15.8 10.6 25.5 10.6h426c10.2 0 18.4 8.3 18.4 18.5v50.1H235.5c-15.3 0-28.7 10.4-32.7 25.4L83 804.5zM119.5 213v413.2l74.3-279.8c6-22.5 26.3-38.3 49.5-38.3h530.1v-25.5h-398c-14.3 0-27.6-5.6-37.7-15.8L284.2 213H119.5z","folder-close":"M902.7 923.3h-776c-34.3 0-62.1-27.9-62.1-62.3V162.9c0-34.3 27.9-62.3 62.1-62.3h195.6c16.6 0 32.2 6.5 44 18.3l62.2 62.5h465.4c4.2 0.1 31.1 1 50.4 23.6 17.6 20.5 16.3 44.3 16 49v624.9c-6.9 26.2-30.6 44.4-57.6 44.4z m-607.9-452h332.4c7.1 0 12.8-5.2 12.8-11.7 0-6.5-5.7-11.7-12.8-11.7H294.8c-7.1 0-12.8 5.2-12.8 11.7 0 6.5 5.7 11.7 12.8 11.7z m0 128.3h434.4c7.1 0 12.8-5.2 12.8-11.7 0-6.5-5.7-11.7-12.8-11.7H294.8c-7.1 0-12.8 5.2-12.8 11.7 0 6.4 5.7 11.7 12.8 11.7z m0 128.1h434.4c7.1 0 12.8-5.2 12.8-11.7 0-6.5-5.7-11.7-12.8-11.7H294.8c-7.1 0-12.8 5.2-12.8 11.7 0 6.5 5.7 11.7 12.8 11.7z",home:"M837.2 960H620.4c-18.2 0-33.1-15.1-33.1-33.6V693H436.7v233.3c0 18.5-14.8 33.6-33.1 33.6H186.8c-18.2 0-33.1-15.1-33.1-33.6v-356c0-18.5 14.8-33.6 33.1-33.6 18.2 0 33.1 15.1 33.1 33.6v322.3h150.7V659.4c0-18.5 14.8-33.6 33.1-33.6h216.8c18.2 0 33.1 15.1 33.1 33.6v233.3h150.7V570.4c0-18.5 14.8-33.6 33.1-33.6 18.2 0 33.1 15.1 33.1 33.6v356c-0.3 18.5-15.1 33.6-33.3 33.6zM97 557.1c-8.9 0-17.2-3.5-23.5-10-12.7-13-12.7-34.3 0-47.3L488.5 74c6.3-6.4 14.6-10 23.5-10s17.2 3.5 23.5 10l415 425.9c12.7 13.1 12.7 34.3 0 47.3-6.3 6.4-14.6 10-23.5 10s-17.2-3.5-23.5-10L512 145.4 120.5 547.2c-6.3 6.4-14.6 9.9-23.5 9.9z m710.5-258.3c-18.2 0-33.1-15.1-33.1-33.6v-55.4h-53.7c-18.2 0-33.1-15.1-33.1-33.6s14.8-33.6 33.1-33.6h86.7c18.2 0 33.1 15.1 33.1 33.6v89c0 18.5-14.8 33.6-33 33.6z",image:"M915.1 280.3l-165-8-9.6-107.6c-2-22.6-22.2-38.4-45.8-36.6l-591.8 48.6c-23.6 2-40.6 21-38.8 43.4l42.4 471.6c2 22.6 22.4 38.4 45.8 36.6l30-2.4-4.8 91.6c-1.2 25.2 18.4 45.6 44.8 47l660.2 31.4c26.4 1.2 48.2-17.2 49.6-42.4l27.8-526.6c1.2-25-18.6-45.4-44.8-46.6z m-709.8 10.6l-14.2 269.6-35 49.4-32.2-356v-2c2-10 8.8-18 19.2-18.8l522-42.8c10.4-0.8 19.4 6 21 15.8 0 0.4 0.6 0.4 0.6 0.8 0 0.2 0.6 0.4 0.6 0.8l5.4 61.6-438-21c-26.4-0.8-48.2 17.6-49.4 42.6z m668 473.8l-169.6-199-74.8 68.6-138.4-161.6-245.4 261.4 20.8-398.2v-0.8c2-10.8 12.4-18.6 23.8-18l582.4 28c11.6 0.6 20.6 9.4 20.8 20.4 0 0.4 0.6 0.6 0.6 1l-20.2 398.2z",key:"M497.4 443.1C466.8 356.5 378.7 288 281.5 288 158.3 288 64 388.8 64 512s98.6 224 221.8 224c97.1 0 181.1-68.5 211.5-155.1h221.4v137.8h148.8V580.9H960V443.1H497.4zM287.9 608.9c-52.9 0-96.1-43.2-96.1-96.1s43.2-96.1 96.1-96.1 96.1 43.2 96.1 96.1-43.2 96.1-96.1 96.1z",left:"M710.9 948.6L251 539.7l-0.3-0.3c-7.7-7.4-12-17.2-12-27.6 0-12.4 6.1-23.9 16.8-31.6L710.9 75.3C719.1 68 730 64 741.5 64c24.2 0 43.9 18.1 43.9 40.3 0 11.1-4.8 21.4-13.4 29L345.8 512 772 890.8c8.5 7.6 13.4 18.1 13.4 29 0 22.2-19.7 40.3-43.9 40.3-11.4-0.1-22.2-4.1-30.6-11.5z",load:"M587.6 587.9c25.3-25.3 202.5 88.6 234.2 120.2 31.7 31.6 38 88.5 6.4 120.1-31.6 31.6-82.2 31.6-113.9-0.1-31.7-31.6-152-215-126.7-240.2zM436 434.8c-25.3 25.3-202.5-88.6-234.2-120.2-31.7-31.6-38-88.5-6.4-120.1 31.6-31.6 82.2-31.6 113.9 0.1 31.7 31.6 152 214.9 126.7 240.2z m-31.8 77.7c0 35.7-205.9 80.4-250.7 80.4-44.8 0-89.5-35.7-89.5-80.4s35.8-80.4 80.6-80.4c44.7 0 259.6 44.7 259.6 80.4z m31.9 76.8c25.3 25.3-88.7 202.3-120.3 233.9-31.7 31.6-88.6 38-120.2 6.4-31.6-31.6-31.6-82.2 0-113.8 31.7-31.6 215.2-151.8 240.5-126.5z m75.9 30.9c35.8 0 80.5 205.7 80.5 250.4 0 44.7-35.8 89.4-80.5 89.4s-80.5-35.8-80.5-80.5 44.7-259.3 80.5-259.3z m107.8-107.7c0-35.7 205.9-80.4 250.7-80.4 44.8 0 89.5 35.7 89.5 80.4s-35.8 80.4-80.6 80.4c-44.7 0-259.6-44.7-259.6-80.4z m-33.6-75.9c-25.3-25.3 88.7-202.3 120.3-233.9 31.7-31.6 88.6-38 120.2-6.4 31.6 31.6 31.6 82.1-0.1 113.8-31.6 31.6-215.1 151.8-240.4 126.5zM512 403.8c-35.8 0-80.5-205.7-80.5-250.4 0-44.7 35.8-89.4 80.5-89.4s80.5 35.8 80.5 80.5-44.7 259.3-80.5 259.3z",loading:'',mail:"M960 280.9v472.3c0 37.9-31 68.9-68.9 68.9H132.9c-37.9 0-68.9-31-68.9-68.9V280.9c0-3.9 4.5-5.8 7.3-3l232 236.1c1.5 1.7 1.5 4.3 0 6L141.1 692.7c-11 11-11 28.6 0 39.6 5.4 5.4 12.7 8.2 19.8 8.2s14.4-2.8 19.8-8.2l161.5-172.1c1.7-1.7 4.5-1.7 6.2 0l37.9 38.6c33.4 33.8 78.6 53.8 126.2 53.6 47-0.2 90.7-18.7 123.6-52.1l39.4-40.1c1.7-1.7 4.5-1.7 6.2 0l161.5 172.1c5.4 5.4 12.7 8.2 19.8 8.2s14.4-2.8 19.8-8.2c11-11 11-28.6 0-39.6L720.9 520c-1.7-1.7-1.7-4.3 0-6l231.8-236.1c2.6-2.6 7.3-0.9 7.3 3zM512 596.2c31.9 0 61.8-12.5 84.2-35.3l337.9-344c-11.8-9.5-26.5-15.1-42.6-15.1H132.7c-16.2 0-31 5.6-42.6 15.1l337.9 344c22.2 22.6 52.1 35.3 84 35.3z",option:"M64 768h544v64H64v-64z m736 0h160v64H800v-64z m-32 127c0 35.9-28.7 65-64 65s-64-29.1-64-65V705c0-35.9 28.7-65 64-65s64 29.1 64 65v190zM64 480h160v64H64v-64z m352 0h544v64H416v-64z m-32 127c0 35.9-28.7 65-64 65s-64-29.1-64-65V417c0-35.9 28.7-65 64-65s64 29.1 64 65v190zM64 192h544v64H64v-64z m736 0h160v64H800v-64z m-32 127c0 35.9-28.7 65-64 65s-64-29.1-64-65V129c0-35.9 28.7-65 64-65s64 29.1 64 65v190z",phone:"M717.7 64H306.3C261 64 224 100.7 224 145.5v733.1c0 44.8 37 81.5 82.3 81.5h411.4c45.3 0 82.3-36.7 82.3-81.5V145.5c0-44.8-37-81.5-82.3-81.5zM728 832H296V163h432v669z m-168 64c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48z",pie:"M64 480C64 250.2 250.2 64 480 64c10.8 0 22 0.4 32 1.2V512H65.2c-0.8-10-1.2-21.2-1.2-32z m155.6 324.4C295.8 899.2 412.8 960 544 960c229.8 0 416-186.2 416-416 0-131.2-60.8-248.2-155.6-324.4-63.4-51-142.4-83.8-228.4-90.4V576H129.2c6.6 86 39.4 165 90.4 228.4z",pin:"M115.8 960c-13.7 0-26.6-5.4-36.4-15.2l-0.5 0.4 0.4-0.5c-18.3-18.4-20.4-46.7-5-67.2l179-242.4-138.8-138.8c-16.5-16.5-19.8-42.3-8-62.8l0.2-0.3c4.5-7.1 21.7-31.7 54.6-51.1 19.1-11.3 40.3-18.7 62.8-22.1 27.3-4.2 56.9-2.4 87.8 5.2 1.8 0.2 3.8 0.4 5.8 0.6h0.5c6 0.5 11.9 1.1 18.5 2.1 25.2 4.1 72.8-18 113.2-52.4 38.6-32.9 64.5-72 64.5-97.5 0-6.4-0.2-13.3-0.3-20-1.1-26.3-2.9-70.2 29.8-102.8 38.6-38.7 99.8-41.8 142.2-7.3 1 0.8 1.9 1.7 2.9 2.7l0.4 0.4c23.8 23.3 238 237.5 239.5 239 20.1 20.1 31.2 46.8 31.2 75.3 0 28.4-11 55.2-31.1 75.3-32.5 32.6-76.8 30.7-103.4 29.6h-1.4c-6-0.1-12.2-0.3-18.1-0.3-24.3 0-53.9 17.6-83.3 49.7-19.7 21.4-37.5 47.6-50 73.8-11.1 23.1-17.1 44.2-16.1 56.5 0.9 8.6 2.6 22.9 3 25.8 32.8 133.7-57.3 195.1-67.6 201.7l-0.1 0.1c-20.7 12.5-46.9 9.4-63.7-7.4L374.7 756.6c-11.6-11.6-11.6-30.6 0-42.2 5.6-5.6 13.1-8.8 21.1-8.8 8 0 15.5 3.1 21.1 8.8L565.4 863c6.5-5.2 17.3-15.3 26.2-31.2 16.2-29 19.3-64 9.5-104.2v-0.2c-0.6-2.8-3-23.4-3.9-31.8v-0.2c-1.9-22.6 5.5-53 20.7-85.6 15-32.1 36.6-64.3 60.9-90.7 28.9-31.5 74.5-69 127.2-69 7.1 0 15 0.2 21.4 0.3h0.2c26.5 1.1 46.2 0.9 59.2-12.1 8.8-8.8 13.6-20.5 13.6-33s-4.9-24.3-13.8-33.2C884.4 370 658 143.7 647.3 133.3c-17.8-14.2-44.6-12.5-61.2 4.1-13.1 13.2-13.4 32.6-12.3 58.7v0.1c0.2 7.2 0.3 14.7 0.3 21.8 0 43.9-31.9 97.3-85.5 142.9-23.9 20.4-51.2 38.1-76.8 49.8-31.9 14.6-60.3 20-84.6 16.1-5.1-0.8-9.9-1.2-14.1-1.6-2.7-0.2-5.4-0.5-8-0.8-2.6-0.1-5.1-0.6-7.7-1.4-83-20.4-123.9 20.5-136.1 36.1L313.6 611c10.5 10.5 11.8 26.9 2.9 38.9L152.7 871.6 316.2 752c6.4-4.7 14.3-6.6 22.2-5.4 7.9 1.2 14.8 5.5 19.5 11.9 9.7 13.3 6.7 32-6.5 41.7L146.2 949.9c-8.9 6.6-19.4 10.1-30.4 10.1z",plus:"M512 960c-21.2 0-38.4-17.2-38.4-38.4V550.3H102.3C81.2 550.4 64 533.2 64 512c0-21.2 17.2-38.4 38.4-38.4h371.3V102.3c0-21.1 17.2-38.4 38.4-38.4s38.4 17.2 38.4 38.4v371.3h371.3c21.1 0 38.4 17.2 38.4 38.4 0 10.3-4 19.9-11.2 27.1-7.2 7.2-16.9 11.2-27.1 11.2H550.6v371.3c0 10.3-4 19.9-11.2 27.1-7.5 7.3-17.1 11.3-27.4 11.3z",qr:"M395 64H64v329.2h331V64z m-48.5 282.2h-235V111h235v235.2z m258.8 495.4h353.3v-46.9H605.3v46.9zM300.1 158.2H158.9V301h141.2V158.2zM629 64v330.7h331V64H629z m282.5 282.9h-235V111h235v235.9z m47.8 353.6h-165v46.8h164.9v-46.8zM723.9 464.4H512.1v94.7h211.8v-94.7z m-329.6-22.8H64.7v46.8h329.5v-46.8zM582.4 64.9h-46.9v211.8h46.9V64.9z m376.9 541.4H511.8v46.1h447.5v-46.1zM441.4 417.1h46.8V64.9h-46.8v352.2z m94 329.8h-46.8v165.3h-0.2v47.6h0.2v0.2h46.8v-0.2H700v-47.6H535.4V746.9z m331.1-589.4H723.9v142.8h142.6V157.5z m92.8 259.1H817.9v48.3H911V558h48.3V416.6z m-95 541.9h95v-94.3h-95v94.3z m-705.4-93.3h141.2V723.8H158.9v141.4z m117.9-283.1h164v-46.9h-164v46.9zM64 959.6h330.3V628.9H64v330.7z m47.5-283.7h235v235.9h-235V675.9z m93.9-93.8v-46.9H65v46.9h140.4z",quote:"M297.6 530.1h140.2V960H64V634.7C64 279.4 188.6 89.1 437.8 64v161.2c-93.4 30.1-140.2 116.1-140.2 258.5v46.4z m522.2 0H960V960H586.2V634.7c0-355.3 124.5-545.6 373.7-570.7v161.2c-93.4 30.1-140.2 116.1-140.2 258.5V530h0.1z","radio-on":"M512 288c-123.2 0-224 100.8-224 224s100.8 224 224 224 224-100.8 224-224-100.8-224-224-224z m0-224C265.6 64 64 265.6 64 512s201.6 448 448 448 448-201.6 448-448S758.4 64 512 64z m0 806.4c-197.1 0-358.4-161.3-358.4-358.4S314.9 153.6 512 153.6 870.4 314.9 870.4 512 709.1 870.4 512 870.4z","radio-off":"M512 64C265.6 64 64 265.6 64 512s201.6 448 448 448 448-201.6 448-448S758.4 64 512 64z m0 806.4c-197.1 0-358.4-161.3-358.4-358.4S314.9 153.6 512 153.6 870.4 314.9 870.4 512 709.1 870.4 512 870.4z",right:"M282.5 960c-24.2 0-43.9-18.1-43.9-40.3 0-10.9 4.9-21.4 13.4-29L678.2 512 252 133.2c-8.6-7.5-13.4-17.8-13.4-29 0-22.2 19.7-40.3 43.9-40.3 11.5 0 22.4 4 30.6 11.3l455.5 404.9c10.7 7.7 16.8 19.2 16.8 31.6 0 10.4-4.3 20.2-12 27.6l-0.3 0.3-460 409c-8.4 7.4-19.2 11.4-30.6 11.4z",second:"M512 64c-156.8 0-284.3 127.5-284.3 284.3S355.2 632.6 512 632.6s284.3-127.5 284.3-284.3S668.8 64 512 64z m-61.2 242.5h-40.1c0-45.5 14.1-77.7 42.3-96.5 18.2-12.1 41-18.2 68.3-18.2 28.5 0 52.3 8.7 71.5 25.9 19.1 17.3 28.7 40.5 28.7 69.6 0 26.4-8.2 48.3-24.6 65.5-11.2 11.8-31.6 25.6-61 41.4l-33.2 18.2c-19.4 10.6-33.8 22.3-43.2 35.1-6.7 8.8-10.6 17.6-11.8 26.4h173.9v37.8H402.5c0-30.9 7.1-57.2 21.4-78.7 12.1-18.2 30-34.3 53.7-48.2l42.3-24.6c21.8-12.8 36-22.3 42.3-28.7 10.9-11.5 16.4-26.9 16.4-46 0-15.2-4.5-27.9-13.7-38.2-11.5-13-28.1-19.6-49.6-19.6-20.3 0-36 6.2-46.9 18.7-11.7 13.7-17.6 33.7-17.6 60.1z m282.3 305.1c-4.8-10.3-18.1-15.2-29.7-10.8-11.6 4.3-17.2 16.2-12.4 26.6l80.8 173.8-148.3-26.7c-9.1-1.6-18.5 1.9-23.7 8.9l-83.3 113.3-4.2 6.5-4.9-6.4-83.1-112.5c-5.1-6.9-14.5-10.4-23.7-8.6l-148.3 28.1 81.1-174.5c4.8-10.4-0.7-22.2-12.3-26.5-11.6-4.2-24.9 0.7-29.8 11.1l-97.6 210c-3.2 7-1.9 14.9 3.5 20.7 5.4 5.8 13.9 8.4 22.2 6.8l175.3-33.2L492.9 951c2.6 3.5 6.2 6.1 10.3 7.6 1.9 0.7 4 1.1 6.1 1.3 0.2 0 3.7 0.1 4.6 0.1h0.3c6.8-0.6 13-3.9 16.8-9.1L629.3 817l175.3 31.5c4.6 0.8 9.2 0.4 13.3-1.2 3.4-1.3 6.4-3.3 8.8-5.9 5.4-5.8 6.7-13.8 3.5-20.7l-97.1-209.1z",share:"M809.6 960c-82.9 0-150.4-67.5-150.4-150.4 0-6.2 0.4-12.2 1.1-18.2L337.1 615.2c-27.3 38.5-72.1 63.6-122.8 63.6-82.8 0-150.3-67.4-150.3-150.3s67.5-150.4 150.4-150.4c49.7 0 93.9 24.3 121.3 61.5l246.8-167.5c-7.4-17.8-11.5-37.3-11.5-57.7C571 131.5 638.5 64 721.4 64s150.4 67.5 150.4 150.4-67.5 150.4-150.4 150.4c-46 0-87.2-20.8-114.8-53.4L357 480.7c5 15 7.8 31.1 7.8 47.8 0 15.2-2.3 30-6.5 43.9l315.8 172.2c24.3-50.4 75.9-85.3 135.5-85.3 82.9 0 150.4 67.5 150.4 150.4S892.5 960 809.6 960z m-0.5-245.2c-52.8 0-95.8 42.9-95.8 95.7 0 52.8 43 95.7 95.8 95.7s95.7-42.9 95.7-95.7c0.1-52.8-42.9-95.7-95.7-95.7z m-88.7-598c-53.4 0-96.8 43.4-96.8 96.8s43.4 96.8 96.8 96.8 96.8-43.4 96.8-96.8-43.4-96.8-96.8-96.8zM214.3 433.6c-53 0-96.2 43.1-96.2 96.2 0 53 43.1 96.2 96.2 96.2 53 0 96.2-43.1 96.2-96.2 0-53-43.2-96.2-96.2-96.2z",star:"M891.9 355.6l-218.6-15.8c-4.6-0.4-8.6-3.1-10.2-7.5l-83.3-203.8C568.4 100.4 542.5 83 512.1 83c-30.3 0-56 17.4-67.7 45.7l-83.4 204c-1.8 4.2-5.7 7.2-10.2 7.5L132.5 356c-29.6 1.7-54.8 21.1-64.4 49.8-9.9 29-1.6 59.5 21.7 79.5l168.9 140.3c3.5 2.9 5.1 7.7 4 12.1l-51.5 211.9c-6 22-1.8 44.8 11.5 62.6 13.7 18 35.1 28.8 57.5 28.8 13.9 0 27.4-4.2 38.5-11.8l184.6-115.5c3.9-2.4 8.7-2.4 12.6 0l186.4 115.1c11.7 7.9 25.2 12.1 38.9 12.1 21 0 41.8-10.1 55.3-27.2 14.1-17.6 19.2-40.6 14.1-63.5L759 637.9c-1.1-4.5 0.5-9.3 4-12.3l171.4-140.7c23-19.8 31.2-50.3 21.5-79.3-9.4-28.7-34.8-48.3-64-50z m-4.8 97.5l-163 133.8a54.911 54.911 0 0 0-18.3 55.1L755 844c2.6 11.9-2.1 20.1-5.2 24-4.9 6.1-12.2 10-19.5 10-4.5 0-9-1.4-13.9-4.7L538.2 763c-8.5-5.3-18.3-8.1-28.3-8-10.1 0-20 2.8-28.5 8.2L304.8 873.5c-11.3 7.5-26.4 4.2-34.4-6.3-3.3-4.4-6.8-11.9-3.7-22.9L316 641.8c4.9-20.1-2.3-41.6-18.1-54.7L137.3 453.6c-12.7-11-9.2-25.2-7.8-29.2 1.4-4 7.1-17.5 23.8-18.4l208.2-15c20.5-1.5 38.4-14.5 46.1-33.6l79.5-194.3c6.4-15.7 20.9-17 25-17 4.2 0 18.6 1.2 25 17l79.5 194.3c7.7 19.1 25.6 32.1 46.1 33.6l208.5 15.2c16.3 0.9 22.1 14.3 23.5 18.4 1.1 3.6 4.6 17.8-7.6 28.5z","star-half":"M891.9 355.6l-218.6-15.8c-4.6-0.4-8.6-3.1-10.2-7.5l-83.3-203.8C568.4 100.4 542.5 83 512.1 83c-30.3 0-56 17.4-67.7 45.7l-83.4 204c-1.8 4.2-5.7 7.2-10.2 7.5L132.5 356c-29.6 1.7-54.8 21.1-64.4 49.8-9.9 29-1.6 59.5 21.7 79.5l168.9 140.3c3.5 2.9 5.1 7.7 4 12.1l-51.5 211.9c-6 22-1.8 44.8 11.5 62.6 13.7 18 35.1 28.8 57.5 28.8 13.9 0 27.4-4.2 38.5-11.8l184.6-115.5c3.9-2.4 8.7-2.4 12.6 0l186.4 115.1c11.7 7.9 25.2 12.1 38.9 12.1 21 0 41.8-10.1 55.3-27.2 14.1-17.6 19.2-40.6 14.1-63.5L759 637.9c-1.1-4.5 0.5-9.3 4-12.3l171.4-140.7c23-19.8 31.2-50.3 21.5-79.3-9.4-28.7-34.8-48.3-64-50z m-4.8 97.5l-163 133.8a54.911 54.911 0 0 0-18.3 55.1L755 844c2.6 11.9-2.1 20.1-5.2 24-4.9 6.1-12.2 10-19.5 10-4.5 0-9-1.4-13.9-4.7C648.3 831.1 580.2 789.1 512 747V147c-0.1-0.3-0.2-0.7 0-1 1.1-1.8 10.8 0.7 17.4 6.2 2 1.7 5.4 5 7.8 10.9l79.5 194.3c7.7 19.1 25.6 32.1 46.1 33.6l208.5 15.2c16.3 0.9 22.1 14.3 23.5 18.4 0.7 2.1 3.2 10.8-1.1 20-2.1 4.1-4.8 6.9-6.6 8.5z","star-full":"M891.9 355.6l-218.6-15.8c-4.6-0.4-8.6-3.1-10.2-7.5l-83.3-203.8C568.4 100.4 542.5 83 512.1 83c-30.3 0-56 17.4-67.7 45.7l-83.4 204c-1.8 4.2-5.7 7.2-10.2 7.5L132.5 356c-29.6 1.7-54.8 21.1-64.4 49.8-9.9 29-1.6 59.5 21.7 79.5l168.9 140.3c3.5 2.9 5.1 7.7 4 12.1l-51.5 211.9c-6 22-1.8 44.8 11.5 62.6 13.7 18 35.1 28.8 57.5 28.8 13.9 0 27.4-4.2 38.5-11.8l184.6-115.5c3.9-2.4 8.7-2.4 12.6 0l186.4 115.1c11.7 7.9 25.2 12.1 38.9 12.1 21 0 41.8-10.1 55.3-27.2 14.1-17.6 19.2-40.6 14.1-63.5L759 637.9c-1.1-4.5 0.5-9.3 4-12.3l171.4-140.7c23-19.8 31.2-50.3 21.5-79.3-9.4-28.7-34.8-48.3-64-50z",tag:"M64 599.7c0-28.1 10.9-54.5 30.8-74.4L525.3 94.8c25.8-25.8 62.5-36.3 98-28.1l207.3 47.8c39 8.9 69.9 39.9 78.9 78.9l47.8 207.2c8.1 35.2-2.6 72.6-28.1 98.1L498.7 929.2c-19.9 19.9-46.3 30.8-74.4 30.8-28.1 0-54.5-10.9-74.4-30.8L94.8 674.1C74.9 654.2 64 627.8 64 599.7zM649.7 288c0 22.4 8.7 43.5 24.6 59.4 15.9 15.9 37 24.6 59.4 24.6s43.5-8.7 59.4-24.6c15.9-15.9 24.6-37 24.6-59.4 0-22.5-8.7-43.6-24.6-59.4-32.8-32.8-86-32.8-118.8 0-15.9 15.8-24.6 36.9-24.6 59.4z",talk:"M902.8 110H407.2c-31.5 0-57.2 25.1-57.2 55.9v391c0 30.8 25.6 55.9 57.2 55.9h344.7l60.2 92.1c11.5 13.2 33.5 5.2 33.5-12.1v-80h57.2c31.5 0 57.2-25.1 57.2-55.9v-391c0-30.9-25.6-55.9-57.2-55.9zM483.5 411.3c-21.1 0-38.1-16.7-38.1-37.2 0-20.6 17.1-37.2 38.1-37.2 21.1 0 38.1 16.7 38.1 37.2 0 20.5-17.1 37.2-38.1 37.2z m171.5 0c-21.1 0-38.1-16.7-38.1-37.2 0-20.6 17.1-37.2 38.1-37.2 21.1 0 38.1 16.7 38.1 37.2 0 20.5-17 37.2-38.1 37.2z m171.6 0c-21.1 0-38.1-16.7-38.1-37.2 0-20.6 17.1-37.2 38.1-37.2 21.1 0 38.1 16.7 38.1 37.2 0 20.5-17.1 37.2-38.1 37.2zM292.7 616.1V312.6H121.2c-31.5 0-57.2 25.1-57.2 55.9v391c0 30.8 25.7 55.9 57.2 55.9h57.2v80c0 17.3 22.1 25.2 33.5 12.1l60.2-92.1h344.7c31.5 0 57.2-25.1 57.2-55.9V672H349.9c-31.5-0.1-57.2-25.1-57.2-55.9z",third:"M512 64c-156.8 0-284.3 127.5-284.3 284.3S355.2 632.6 512 632.6s284.3-127.5 284.3-284.3S668.8 64 512 64z m-23.9 295.3v-33.2l20.4 0.9c17.1 0 30.7-3.5 40.8-10.6 12.4-8.9 18.6-22.3 18.6-40.3 0-12.4-3.7-22.9-11.1-31.5-10-11.8-25.6-17.7-46.5-17.7-23.9 0-40.9 8.4-51 25.3-6.5 10.9-9.8 24.8-9.8 41.7h-38.1c0-28.1 6.5-50.8 19.5-68.3 16.8-22.4 43.9-33.7 81.1-33.7 29.5 0 53 7.6 70.3 22.8 17.3 15.2 25.9 34.9 25.9 59.2 0 18.3-4.4 33.4-13.3 45.2-7.1 9.5-16 15.8-26.6 19.1 16.5 5.9 29 14.2 37.2 24.8 9.8 12.4 14.6 28.7 14.6 48.8 0 28.1-8.7 51.1-26.1 69.1-20.1 20.7-48.8 31-86 31-9.8 0-17.9-0.6-24.4-1.8-10.6-2.1-21.7-6.1-33.2-12-16.6-8.6-28.4-20.7-35.7-36.3-7.2-15.7-10.9-33.5-10.9-53.6h40.3c0 19.5 3.7 34.6 11.1 45.2 10.6 15.7 29.1 23.5 55.4 23.5 20.1 0 36.4-5.5 49-16.6 12.6-11.1 18.8-25.6 18.8-43.7 0-23-8.7-39.1-26.1-48.3-11.2-5.9-26.7-8.9-46.5-8.9h-17.7z m245 252.3c-4.8-10.3-18.1-15.2-29.7-10.8-11.6 4.3-17.2 16.2-12.4 26.6l80.8 173.8-148.3-26.7c-9.1-1.6-18.5 1.9-23.7 8.9l-83.3 113.3-4.2 6.5-4.9-6.4-83.1-112.5c-5.1-6.9-14.5-10.4-23.7-8.6l-148.3 28.1 81.1-174.5c4.8-10.4-0.7-22.2-12.3-26.5-11.6-4.2-24.9 0.7-29.8 11.1l-97.6 210c-3.2 7-1.9 14.9 3.5 20.7 5.4 5.8 13.9 8.4 22.2 6.8l175.3-33.2L492.9 951c2.6 3.5 6.2 6.1 10.3 7.6 1.9 0.7 4 1.1 6.1 1.3 0.2 0 3.7 0.1 4.6 0.1h0.3c6.8-0.6 13-3.9 16.8-9.1L629.3 817l175.3 31.5c4.6 0.8 9.2 0.4 13.3-1.2 3.4-1.3 6.4-3.3 8.8-5.9 5.4-5.8 6.7-13.8 3.5-20.7l-97.1-209.1z",upload:"M392 325.7s-54.2-68.6-127.7-12.6c-65.8 53.5-54.2 151.3-54.2 151.3S64 501.9 64 697.9c3.3 195.8 158.7 197.8 158.7 197.8l233.3 0.3V686.4H344.2L512 476.9l167.9 209.6H568V896l226.6-0.3s144.7 0.2 165-186.1c9.7-203.7-139.8-243.8-139.8-243.8s17-301.5-192.9-335.9C446.8 105.7 392 325.7 392 325.7z",wallet:"M384.5 682.6V341.4c0-47 39.4-85.4 88.5-85.4h408.1v-42.6c0-47-39.2-85.4-87.6-85.4H155.2c-49.1 0-91.2 37-91.2 84v600c0 47 42.1 84 91.2 84h638.1c48.7 0 87.6-38.4 87.6-85.4V768H472.7c-48.9 0-88.2-38.4-88.2-85.4zM448 355.7v312.6c0 19.6 16.8 35.7 37.4 35.7h437.2c20.6 0 37.4-16.1 37.4-35.7V355.7c0-19.6-16.8-35.7-37.4-35.7H485.4c-20.6 0-37.4 16.1-37.4 35.7z m195.9 227.4c-43 2.7-78.4-32.8-75.8-75.8 2.2-35.4 31-64.2 66.6-66.7 43-2.7 78.4 32.8 75.8 75.8-2.5 35.7-31.2 64.5-66.6 66.7z"}; \ No newline at end of file diff --git a/src/lib/request/index.js b/src/lib/request/index.js index 9cd1ce5..a97aa5d 100644 --- a/src/lib/request/index.js +++ b/src/lib/request/index.js @@ -1 +1,447 @@ -"use strict";import Format from"./lib/format.js";const rlocalProtocol=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,log=console.log,noop=function(t,e){this.defer.resolve(e)};let isLocal=!1;try{isLocal=rlocalProtocol.test(location.protocol)}catch(t){}let originAnchor=document.createElement("a");originAnchor.href=location.href;const NOBODY_METHODS=["GET","HEAD"],ERRORS={10001:"Argument url is required",10012:"Parse error",10100:"Request canceled",10104:"Request pending...",10200:"Ok",10204:"No content",10304:"Not modified",10500:"Internal Server Error",10504:"Connected timeout"},FORM_TYPES={form:"application/x-www-form-urlencoded; charset=UTF-8",json:"application/json; charset=UTF-8",text:"text/plain; charset=UTF-8"},convert={text:t=>t,xml:(t,e)=>void 0!==e?e:Format.parseXML(t),html:t=>Format.parseHTML(t),json:t=>JSON.parse(t),script:t=>Format.parseJS(t)};class _Request{constructor(t="",e="GET",s={}){if(!t)throw new Error(ERRORS[10001]);return t=t.replace(/#.*$/,""),request.BASE_URL&&(/^([a-z]+:|\/\/)/.test(t)||(t=request.BASE_URL+t)),e=e.toUpperCase(),this.xhr=new XMLHttpRequest,this.defer=Promise.defer(),this.opt={url:t,method:e,headers:{},data:{},dataType:"text",withCredentials:!1},this.defer.promise.abort=(()=>{this.cancel=!0,this.xhr.abort()}),this.__next__(Object.assign({},request.__INIT__,s)),this.defer.promise}__next__(t){t.headers&&Object.assign(this.opt.headers,t.headers);let e=!1;if(t.formType)switch(t.formType){case"form":this.__set__("form");break;case"json":this.__set__("json");break;case"form-data":this.opt.method="POST",e=!0;break;default:NOBODY_METHODS.includes(this.opt.method)?this.__set__("form"):this.__set__("text")}else this.__set__("form");if(t.cache&&NOBODY_METHODS.includes(this.opt.method)&&(this.opt.cache=!0),t.timeout=t.timeout>>>0,t.timeout>0&&(this.opt.timeout=t.timeout),t.data){switch(typeof t.data){case"number":case"string":this.__set__("text"),this.opt.data=t.data;break;case"object":"FORM"===t.data.nodeName?(this.opt.method=t.data.method.toUpperCase()||"POST",this.opt.data=Format.parseForm(t.data),(e=this.opt.data.constructor===FormData)&&delete this.opt.headers["content-type"]):t.data.constructor===FormData?(e=!0,this.opt.method="POST",delete this.opt.headers["content-type"],this.opt.data=t.data):this.opt.data=e?Format.mkFormData(t.data):t.data}}t.withCredentials&&(this.opt.withCredentials=!0);try{let t=document.createElement("a");t.href=this.opt.url,this.opt.crossDomain=originAnchor.protocol!==t.protocol||originAnchor.host!==t.host}catch(t){}this.opt.crossDomain?this.opt.withCredentials&&(this.xhr.withCredentials=!0,this.opt.headers["X-Requested-With"]="XMLHttpRequest"):this.opt.headers["X-Requested-With"]="XMLHttpRequest",!NOBODY_METHODS.includes(this.opt.method)?e||("json"===t.formType?this.opt.data=JSON.stringify(this.opt.data):this.opt.data=Format.param(this.opt.data)):(this.opt.data=Format.param(this.opt.data),this.opt.data&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+this.opt.data),!1===this.opt.cache&&(this.opt.url+=(/\?/.test(this.opt.url)?"&":"?")+"_="+Math.random())),t.dataType&&(this.opt.dataType=t.dataType.toLowerCase()),this.xhr.responseType=this.opt.dataType,this.xhr.onreadystatechange=(t=>{this.opt.timeout>0&&(this.opt["time"+this.xhr.readyState]=t.timeStamp,4===this.xhr.readyState&&(this.opt.isTimeout=this.opt.time4-this.opt.time1>this.opt.timeout)),4===this.xhr.readyState&&this.__dispatch__(this.opt.isTimeout)}),this.xhr.open(this.opt.method,this.opt.url,!0);for(let t in this.opt.headers)this.xhr.setRequestHeader(t,this.opt.headers[t]);this.xhr.send(this.opt.data),this.opt.timeout&&this.opt.timeout>0&&(this.xhr.timeout=this.opt.timeout)}__set__(t){this.opt.headers["content-type"]=FORM_TYPES[t]}__dispatch__(t){let e={status:200,statusText:"ok",text:"",body:"",error:null};if(this.cancel)return this.__cancel__(e);if(t)return this.__timeout__(e);let s=this.xhr.status>=200&&this.xhr.status<400,o=this.xhr.getAllResponseHeaders().split("\n")||[],r="";for(let t of o)if(t=t.trim()){if("content-type"===(t=t.split(":")).shift().toLowerCase()){r=t.join(":").trim().toLowerCase();break}}switch(s?(e.status=this.xhr.status,204===e.status?e.statusText=ERRORS[10204]:304===e.status&&(e.statusText=ERRORS[10304])):(e.status=this.xhr.status||500,e.statusText=this.xhr.statusText||ERRORS[10500],e.error=new Error(e.statusText)),this.opt.dataType){case"arraybuffer":case"blob":case"document":case"json":e.text=e.body=this.xhr.response;break;default:try{let t=r.match(/json|xml|script|html/);t=t&&t[0].toLowerCase()||"text",e.text=this.xhr.response,e.body=convert[t](e.text,this.xhr.response)}catch(t){e.error=t,e.statusText=ERRORS[10012]}}this.__success__(s,e)}__success__(t,e){t?this.defer.resolve(e):this.defer.reject(e),delete this.xhr,delete this.opt,delete this.defer}__cancel__(t){t.status=0,t.statusText=ERRORS[10100],t.error=new Error(ERRORS[10100]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}__timeout__(t){t.status=504,t.statusText=ERRORS[10504],t.error=new Error(ERRORS[10504]),this.defer.reject(t),delete this.xhr,delete this.opt,delete this.defer}}window.request||(window.request={get:(t,e={})=>new _Request(t,"GET",e),post:(t,e={})=>new _Request(t,"POST",e),upload(t,e={}){return e.formType="form-data",this.post(t,e)},download(t,e={}){return e.dataType="blob",this.get(t,e)},open:(t,e="GET",s={})=>("object"==typeof e&&(s=e,e="GET"),new _Request(t,e,s)),version:"2.0.0-normal",init(t={}){this.__INIT__=t}},Anot.ui.request=request.version);export default request; \ No newline at end of file +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2018-03-25 23:59:13 + * @version $Id$ + */ + +'use strict' +import Format from "./lib/format.js" + +// 本地协议/头 判断正则 +const rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/ +const log = console.log + +const noop = function(e, res) { + this.defer.resolve(res) +} + +let isLocal = false +try { + isLocal = rlocalProtocol.test(location.protocol) +} catch (e) {} + +let originAnchor = document.createElement('a') +originAnchor.href = location.href + +const NOBODY_METHODS = ['GET', 'HEAD'] +const ERRORS = { + 10001: 'Argument url is required', + 10012: 'Parse error', + 10100: 'Request canceled', + 10104: 'Request pending...', + 10200: 'Ok', + 10204: 'No content', + 10304: 'Not modified', + 10500: 'Internal Server Error', + 10504: 'Connected timeout' +} + +const FORM_TYPES = { + form: 'application/x-www-form-urlencoded; charset=UTF-8', + json: 'application/json; charset=UTF-8', + text: 'text/plain; charset=UTF-8' +} + +const convert = { + text(val) { + return val + }, + xml(val, xml) { + return xml !== undefined ? xml : Format.parseXML(val) + }, + html(val) { + return Format.parseHTML(val) + }, + json(val) { + return JSON.parse(val) + }, + script(val) { + return Format.parseJS(val) + } +} + +class _Request { + constructor(url = '', method = 'GET', param = {}) { + if (!url) { + throw new Error(ERRORS[10001]) + } + + // url规范化 + url = url.replace(/#.*$/, '') + + if (request.BASE_URL) { + if (!/^([a-z]+:|\/\/)/.test(url)) { + url = request.BASE_URL + url + } + } + + method = method.toUpperCase() + + this.xhr = new XMLHttpRequest() + this.defer = Promise.defer() + this.opt = { + url, + method, + headers: {}, + data: {}, + dataType: 'text', + withCredentials: false // 跨域选项,是否验证凭证 + } + + // 取消网络请求 + this.defer.promise.abort = () => { + this.cancel = true + this.xhr.abort() + } + this.__next__(Object.assign({}, request.__INIT__, param)) + return this.defer.promise + } + + __next__(param) { + /* -------------------------------------------------------------- */ + /* ------------------------ 1»» 配置头信息 ---------------------- */ + /* -------------------------------------------------------------- */ + if (param.headers) { + Object.assign(this.opt.headers, param.headers) + } + + /* -------------------------------------------------------------- */ + /* --------- 2»» 设置表单类型, 其中 form-data不能手动设置 ---------- */ + /* -------------------------------------------------------------- */ + let hasAttach = false + if (param.formType) { + switch (param.formType) { + case 'form': + this.__set__('form') + break + case 'json': + this.__set__('json') + break + case 'form-data': + this.opt.method = 'POST' + hasAttach = true + break + default: + if (NOBODY_METHODS.includes(this.opt.method)) { + this.__set__('form') + } else { + this.__set__('text') + } + } + } else { + this.__set__('form') + } + + /* -------------------------------------------------------------- */ + /* ------------------- 3»» 设置缓存 ---------------------------- */ + /* -------------------------------------------------------------- */ + if (param.cache) { + if (NOBODY_METHODS.includes(this.opt.method)) { + this.opt.cache = true + } + } + + /* -------------------------------------------------------------- */ + /* ------------------- 4»» 设置超时时间(毫秒) --------------------- */ + /* -------------------------------------------------------------- */ + param.timeout = param.timeout >>> 0 + if (param.timeout > 0) { + this.opt.timeout = param.timeout + } + + /* -------------------------------------------------------------- */ + /* -------------------------- 5»» 请求的内容 --------------------- */ + /* -------------------------------------------------------------- */ + if (param.data) { + let type = typeof param.data + + switch (type) { + case 'number': + case 'string': + this.__set__('text') + this.opt.data = param.data + break + case 'object': + // 解析表单DOM + if (param.data.nodeName === 'FORM') { + this.opt.method = param.data.method.toUpperCase() || 'POST' + + this.opt.data = Format.parseForm(param.data) + hasAttach = this.opt.data.constructor === FormData + + if (hasAttach) { + delete this.opt.headers['content-type'] + } + // 如果是一个 FormData对象 + // 则直接改为POST + } else if (param.data.constructor === FormData) { + hasAttach = true + this.opt.method = 'POST' + delete this.opt.headers['content-type'] + this.opt.data = param.data + } else { + // 有附件,则改为FormData + if (hasAttach) { + this.opt.data = Format.mkFormData(param.data) + } else { + this.opt.data = param.data + } + } + } + } + + /* -------------------------------------------------------------- */ + /* -------------------------- 6»» 处理跨域 --------------------- */ + /* -------------------------------------------------------------- */ + if (param.withCredentials) { + this.opt.withCredentials = true + } + try { + let anchor = document.createElement('a') + anchor.href = this.opt.url + + this.opt.crossDomain = + originAnchor.protocol !== anchor.protocol || + originAnchor.host !== anchor.host + } catch (err) {} + + // 6.1»» 进一步处理跨域 + // 非跨域或跨域但支持Cors时自动加上一条header信息,用以标识这是ajax请求 + // 如果是跨域,开启Cors会需要服务端额外返回一些headers + + if (this.opt.crossDomain) { + if (this.opt.withCredentials) { + this.xhr.withCredentials = true + this.opt.headers['X-Requested-With'] = 'XMLHttpRequest' + } + } else { + this.opt.headers['X-Requested-With'] = 'XMLHttpRequest' + } + + /* -------------------------------------------------------------- */ + /* ------------- 7»» 根据method类型, 处理g表单数据 ---------------- */ + /* -------------------------------------------------------------- */ + // 是否允许发送body + let allowBody = !NOBODY_METHODS.includes(this.opt.method) + if (allowBody) { + if (!hasAttach) { + if (param.formType === 'json') { + this.opt.data = JSON.stringify(this.opt.data) + } else { + this.opt.data = Format.param(this.opt.data) + } + } + } else { + // 否则拼接到url上 + this.opt.data = Format.param(this.opt.data) + + if (this.opt.data) { + this.opt.url += (/\?/.test(this.opt.url) ? '&' : '?') + this.opt.data + } + + if (this.opt.cache === false) { + this.opt.url += + (/\?/.test(this.opt.url) ? '&' : '?') + '_=' + Math.random() + } + } + + /* -------------------------------------------------------------- */ + /* ------------- 8»» 设置响应的数据类型 ---------------- */ + /* -------------------------------------------------------------- */ + // arraybuffer | blob | document | json | text + if (param.dataType) { + this.opt.dataType = param.dataType.toLowerCase() + } + this.xhr.responseType = this.opt.dataType + + /* -------------------------------------------------------------- */ + /* ------------- 9»» 构造请求 ---------------- */ + /* -------------------------------------------------------------- */ + + // response ready + this.xhr.onreadystatechange = ev => { + if (this.opt.timeout > 0) { + this.opt['time' + this.xhr.readyState] = ev.timeStamp + if (this.xhr.readyState === 4) { + this.opt.isTimeout = + this.opt.time4 - this.opt.time1 > this.opt.timeout + } + } + + if (this.xhr.readyState !== 4) { + return + } + + this.__dispatch__(this.opt.isTimeout) + } + + // 9.1»» 初始化xhr + this.xhr.open(this.opt.method, this.opt.url, true) + + // 9.2»» 设置头信息 + for (let i in this.opt.headers) { + this.xhr.setRequestHeader(i, this.opt.headers[i]) + } + + // 9.3»» 发起网络请求 + this.xhr.send(this.opt.data) + + // 9.4»» 超时处理 + if (this.opt.timeout && this.opt.timeout > 0) { + this.xhr.timeout = this.opt.timeout + } + } + + __set__(type) { + this.opt.headers['content-type'] = FORM_TYPES[type] + } + + __dispatch__(isTimeout) { + let result = { + status: 200, + statusText: 'ok', + text: '', + body: '', + error: null + } + + // 主动取消 + if (this.cancel) { + return this.__cancel__(result) + } + + // 超时 + if (isTimeout) { + return this.__timeout__(result) + } + + // 是否请求成功(resful规范) + let isSucc = this.xhr.status >= 200 && this.xhr.status < 400 + + let headers = this.xhr.getAllResponseHeaders().split('\n') || [] + let contentType = '' + + //处理返回的 Header, 拿到content-type + for (let it of headers) { + it = it.trim() + if (it) { + it = it.split(':') + let tmp = it.shift().toLowerCase() + if (tmp === 'content-type') { + contentType = it + .join(':') + .trim() + .toLowerCase() + break + } + } + } + + if (isSucc) { + result.status = this.xhr.status + if (result.status === 204) { + result.statusText = ERRORS[10204] + } else if (result.status === 304) { + result.statusText = ERRORS[10304] + } + } else { + result.status = this.xhr.status || 500 + result.statusText = this.xhr.statusText || ERRORS[10500] + result.error = new Error(result.statusText) + } + // log(this.opt.dataType, this.xhr) + switch (this.opt.dataType) { + case 'arraybuffer': + case 'blob': + case 'document': + case 'json': + result.text = result.body = this.xhr.response + break + // text + default: + try { + //处理返回的数据 + let dataType = contentType.match(/json|xml|script|html/) + + dataType = (dataType && dataType[0].toLowerCase()) || 'text' + + result.text = this.xhr.response + result.body = convert[dataType](result.text, this.xhr.response) + } catch (err) { + result.error = err + result.statusText = ERRORS[10012] + } + break + } + this.__success__(isSucc, result) + } + + __success__(isSucc, result) { + if (isSucc) { + this.defer.resolve(result) + } else { + this.defer.reject(result) + } + delete this.xhr + delete this.opt + delete this.defer + } + + __cancel__(result) { + result.status = 0 + result.statusText = ERRORS[10100] + result.error = new Error(ERRORS[10100]) + + this.defer.reject(result) + + delete this.xhr + delete this.opt + delete this.defer + } + + __timeout__(result) { + result.status = 504 + result.statusText = ERRORS[10504] + result.error = new Error(ERRORS[10504]) + + this.defer.reject(result) + + delete this.xhr + delete this.opt + delete this.defer + } +} + +if (!window.request) { + window.request = { + get(url, param = {}) { + return new _Request(url, 'GET', param) + }, + post(url, param = {}) { + return new _Request(url, 'POST', param) + }, + upload(url, param = {}) { + param.formType = 'form-data' + return this.post(url, param) + }, + download(url, param = {}) { + param.dataType = 'blob' + return this.get(url, param) + }, + open(url, method = 'GET', param = {}) { + if (typeof method === 'object') { + param = method + method = 'GET' + } + return new _Request(url, method, param) + }, + version: '2.0.0-normal', + init(param = {}) { + this.__INIT__ = param + } + } + Anot.ui.request = request.version +} + +export default request diff --git a/src/lib/request/lib/format.js b/src/lib/request/lib/format.js index 4f48fb0..ce5d8a7 100644 --- a/src/lib/request/lib/format.js +++ b/src/lib/request/lib/format.js @@ -1 +1,225 @@ -"use strict";function serialize(e,t,r){let o;if(Array.isArray(t))t.forEach(function(t,a){o=e?`${e}[${Array.isArray(t)?a:""}]`:a,"object"==typeof t?serialize(o,t,r):r(o,t)});else for(let a in t)o=e?`${e}[${a}]`:a,"object"==typeof t[a]?serialize(o,t[a],r):r(o,t[a])}const toS=Object.prototype.toString,doc=window.document,encode=encodeURIComponent,decode=decodeURIComponent,TagHooks=function(){this.option=doc.createElement("select"),this.thead=doc.createElement("table"),this.td=doc.createElement("tr"),this.area=doc.createElement("map"),this.tr=doc.createElement("tbody"),this.col=doc.createElement("colgroup"),this.legend=doc.createElement("fieldset"),this._default=doc.createElement("div"),this.g=doc.createElementNS("http://www.w3.org/2000/svg","svg"),this.optgroup=this.option,this.tbody=this.tfoot=this.colgroup=this.caption=this.thead,this.th=this.td,"circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use".replace(/,/g,e=>{this[e]=this.g})},Helper={tagHooks:new TagHooks,rtagName:/<([\w:]+)/,rxhtml:/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,scriptTypes:{"text/javascript":1,"text/ecmascript":1,"application/ecmascript":1,"application/javascript":1},rhtml:/<|&#?\w+;/};export default{parseJS:function(code){if(code=(code+"").trim(),code)if(1===code.indexOf("use strict")){let e=doc.createElement("script");e.text=code,doc.head.appendChild(e).parentNode.removeChild(e)}else eval(code)},parseXML:function(e,t,r){try{t=(new DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&t.documentElement&&!t.getElementsByTagName("parsererror").length||console.error("Invalid XML: "+e),t},parseHTML:function(e){let t=doc.createDocumentFragment().cloneNode(!1);if("string"!=typeof e)return t;if(!Helper.rhtml.test(e))return t.appendChild(document.createTextNode(e)),t;e=e.replace(Helper.rxhtml,"<$1>").trim();let r=(Helper.rtagName.exec(e)||["",""])[1].toLowerCase(),o=Helper.tagHooks[r]||Helper.tagHooks._default,a=null;o.innerHTML=e;let i=o.getElementsByTagName("script");if(i.length)for(let e,t=0;e=i[t++];)if(Helper.scriptTypes[e.type]){let t=doc.createElement("script").cloneNode(!1);e.attributes.forEach(function(e){t.setAttribute(e.name,e.value)}),t.text=e.text,e.parentNode.replaceChild(t,e)}for(;a=o.firstChild;)t.appendChild(a);return t},parseForm:function(e){let t={},r=!1;for(let o,a=0;o=e.elements[a++];)switch(o.type){case"select-one":case"select-multiple":if(o.name.length&&!o.disabled)for(let e,r=0;e=o.options[r++];)e.selected&&(t[o.name]=e.value||e.text);break;case"file":o.name.length&&!o.disabled&&(t[o.name]=o.files[0],r=!0);break;case void 0:case"submit":case"reset":case"button":break;case"radio":case"checkbox":if(!o.checked)break;default:o.name.length&&!o.disabled&&(t[o.name]=o.value)}return r?this.mkFormData(t):t},mkFormData(e){let t=new FormData;for(let r in e){let o=e[r];Array.isArray(o)?o.forEach(function(e){t.append(r+"[]",e)}):t.append(r,e[r])}return t},param:function(e){if(!e||"string"==typeof e||"number"==typeof e)return e;let t=[];return"object"==typeof e&&serialize("",e,function(e,r){/native code/.test(r)||(r="function"==typeof r?r():r,r="[object File]"!==toS.call(r)?encode(r):r,t.push(encode(e)+"="+r))}),t.join("&")}}; \ No newline at end of file +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2016-11-26 16:35:45 + * + */ + +'use strict' + +function serialize(p, obj, q) { + let k + if (Array.isArray(obj)) { + obj.forEach(function(it, i) { + k = p ? `${p}[${Array.isArray(it) ? i : ''}]` : i + // k = p ? p + '[' + (Array.isArray(it) ? i : '') + ']' : i + if (typeof it === 'object') { + serialize(k, it, q) + } else { + q(k, it) + } + }) + } else { + for (let i in obj) { + k = p ? `${p}[${i}]` : i + // k = p ? p + '[' + i + ']' : i + if (typeof obj[i] === 'object') { + serialize(k, obj[i], q) + } else { + q(k, obj[i]) + } + } + } +} + +const toS = Object.prototype.toString +const doc = window.document +const encode = encodeURIComponent +const decode = decodeURIComponent + +const TagHooks = function() { + this.option = doc.createElement('select') + this.thead = doc.createElement('table') + this.td = doc.createElement('tr') + this.area = doc.createElement('map') + this.tr = doc.createElement('tbody') + this.col = doc.createElement('colgroup') + this.legend = doc.createElement('fieldset') + this._default = doc.createElement('div') + this.g = doc.createElementNS('http://www.w3.org/2000/svg', 'svg') + + this.optgroup = this.option + this.tbody = this.tfoot = this.colgroup = this.caption = this.thead + this.th = this.td + + 'circle,defs,ellipse,image,line,path,polygon,polyline,rect,symbol,text,use'.replace( + /,/g, + m => { + this[m] = this.g //处理svg + } + ) +} + +const Helper = { + tagHooks: new TagHooks(), + rtagName: /<([\w:]+)/, + rxhtml: /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + scriptTypes: { + 'text/javascript': 1, + 'text/ecmascript': 1, + 'application/ecmascript': 1, + 'application/javascript': 1 + }, + rhtml: /<|&#?\w+;/ +} + +export default { + parseJS: function(code) { + code = (code + '').trim() + if (code) { + if (code.indexOf('use strict') === 1) { + let 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) { + let fragment = doc.createDocumentFragment().cloneNode(false) + + if (typeof html !== 'string') { + return fragment + } + + if (!Helper.rhtml.test(html)) { + fragment.appendChild(document.createTextNode(html)) + return fragment + } + + html = html.replace(Helper.rxhtml, '<$1>').trim() + let tag = (Helper.rtagName.exec(html) || ['', ''])[1].toLowerCase() + let wrap = Helper.tagHooks[tag] || Helper.tagHooks._default + let firstChild = null + + //使用innerHTML生成的script节点不会触发请求与执行text属性 + wrap.innerHTML = html + let script = wrap.getElementsByTagName('script') + if (script.length) { + for (let i = 0, el; (el = script[i++]); ) { + if (Helper.scriptTypes[el.type]) { + let tmp = doc.createElement('script').cloneNode(false) + el.attributes.forEach(function(attr) { + tmp.setAttribute(attr.name, attr.value) + }) + tmp.text = el.text + el.parentNode.replaceChild(tmp, el) + } + } + } + + while ((firstChild = wrap.firstChild)) { + fragment.appendChild(firstChild) + } + + return fragment + }, + parseForm: function(form) { + let data = {} + let hasAttach = false + for (let i = 0, field; (field = form.elements[i++]); ) { + switch (field.type) { + case 'select-one': + case 'select-multiple': + if (field.name.length && !field.disabled) { + for (let 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] + hasAttach = true + } + 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 + } + } + } + // 如果有附件, 改为FormData + if (hasAttach) { + return this.mkFormData(data) + } else { + return data + } + }, + mkFormData(data) { + let form = new FormData() + for (let i in data) { + let el = data[i] + if (Array.isArray(el)) { + el.forEach(function(it) { + form.append(i + '[]', it) + }) + } else { + form.append(i, data[i]) + } + } + return form + }, + param: function(obj) { + if (!obj || typeof obj === 'string' || typeof obj === 'number') { + return obj + } + + let arr = [] + let 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('&') + } +} diff --git a/src/lib/scroll/index.js b/src/lib/scroll/index.js new file mode 100644 index 0000000..f21254e --- /dev/null +++ b/src/lib/scroll/index.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-01 23:16:06 + * @version v2.0.1 + * + */ + +'use strict' + +import{bind,ebind,unbind}from"../utils.js";const IS_FF=!!window.sidebar;export default class Scroll extends HTMLElement{static get observedAttributes(){return[]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
    ',this.__BOX__=this.root.children[1],this.__X__=this.root.children[2].children[0],this.__Y__=this.root.children[3].children[0]}get scrollTop(){return this.__BOX__.scrollTop}set scrollTop(t){if((t=+t)==t){var{sh:s,oh:i,yh:e}=this.props;this.__BOX__.scrollTop=t;var o=this.__BOX__.scrollTop/(s-i)*(i-e);this.props.thumbY=o,this.__Y__.style.transform=`translateY(${o}px)`}}get scrollLeft(){return this.__BOX__.scrollLeft}set scrollLeft(t){if(n=+n,n==n){var{sw:s,ow:i,xw:e}=this.props;this.__BOX__.scrollLeft=n;var o=this.__BOX__.scrollLeft/(s-i)*(i-e);this.props.thumbX=o,this.__X__.style.transform=`translateX(${o}px)`}}get scrollHeight(){return this.__BOX__.scrollHeight}_fetchScrollX(t){var{sw:s,ow:i,xw:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollLeft=t/(i-e)*(s-i),this.__X__.style.transform=`translateX(${t}px)`,t}_fetchScrollY(t){var{sh:s,oh:i,yh:e}=this.props;return t<0?t=0:t>i-e&&(t=i-e),this.__BOX__.scrollTop=t/(i-e)*(s-i),this.__Y__.style.transform=`translateY(${t}px)`,t}connectedCallback(){this._initFn=bind(this.__BOX__,"mouseenter",t=>{var s=this.__BOX__.offsetWidth,i=this.__BOX__.scrollWidth,e=this.__BOX__.offsetHeight,o=this.__BOX__.scrollHeight,r=e*e/o>>0,h=s*s/i>>0;r<50&&(r=50),h<50&&(h=50),h===s&&(h=0),r===e&&(r=0),this.props.oh=e,this.props.sh=o,this.props.ow=s,this.props.sw=i,this.props.yh=r,this.props.xw=h,this.__X__.style.width=h+"px",this.__Y__.style.height=r+"px"}),this._wheelFn=ebind(this.__BOX__,"wheel",t=>{t.preventDefault();var{sh:s,oh:i,yh:e,sw:o,ow:r,xw:h}=this.props;if(h||e){var l,_;if(IS_FF)l=t.deltaMode?10*t.deltaX:t.deltaX,_=t.deltaMode?10*t.deltaY:t.deltaY;else{var n=Math.abs(t.wheelDelta);n<120?(l=t.deltaX,_=t.deltaY):(l=t.deltaX/(n/120),_=t.deltaY/(n/120))}if(this.__BOX__.scrollTop+=_,this.__BOX__.scrollLeft+=l,h){var a=this.__BOX__.scrollLeft/(o-r)*(r-h);this.props.thumbX=a,this.__X__.style.transform=`translateX(${a}px)`}if(e){var p=this.__BOX__.scrollTop/(s-i)*(i-e);this.props.thumbY=p,this.__Y__.style.transform=`translateY(${p}px)`}}});var t,s,i,e,o=o=>{var{thumbY:r,thumbX:h}=this.props;null!==t&&(i=this._fetchScrollX(h+o.pageX-t)),null!==s&&(e=this._fetchScrollY(r+o.pageY-s))},r=h=>{t=null,s=null,this.props.thumbX=i,this.props.thumbY=e,unbind(document,"mousemove",o),unbind(document,"mouseup",r)};bind(this.__Y__,"mousedown",t=>{s=t.pageY,this.props.thumbY||(this.props.thumbY=0),bind(document,"mousemove",o),bind(document,"mouseup",r)}),bind(this.__X__,"mousedown",s=>{t=s.pageX,this.props.thumbX||(this.props.thumbX=0),bind(document,"mousemove",o),bind(document,"mouseup",r)})}disconnectedCallback(){unbind(this.__BOX__,"mouseenter",this._initFn),unbind(this.__BOX__,"wheel",this._wheelFn)}}; + +if(!customElements.get('wc-scroll')){ + customElements.define('wc-scroll', Scroll) +} From a8f57fccbaaf40c0e2673d1c86ffe17d03cf8fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sat, 7 Sep 2019 23:37:53 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/drag/core.js | 2 +- src/lib/form/button.js | 4 ++-- src/lib/form/cascader.js | 15 --------------- src/lib/form/checkbox.js | 4 ++-- src/lib/form/input.js | 4 ++-- src/lib/form/number.js | 15 +++++++++++++++ src/lib/form/progress.js | 4 ++-- src/lib/form/radio.js | 4 ++-- src/lib/form/select.js | 4 ++-- src/lib/form/switch.js | 4 ++-- src/lib/icon/index.js | 4 ++-- src/lib/layer/Release.md | 30 ------------------------------ src/lib/layer/index.js | 16 +++++++++++++++- src/lib/layer/next.js | 15 --------------- src/lib/scroll/index.js | 2 +- 15 files changed, 48 insertions(+), 79 deletions(-) delete mode 100644 src/lib/form/cascader.js create mode 100644 src/lib/form/number.js delete mode 100644 src/lib/layer/Release.md delete mode 100644 src/lib/layer/next.js diff --git a/src/lib/drag/core.js b/src/lib/drag/core.js index 0a4dcd9..f4a9f6e 100644 --- a/src/lib/drag/core.js +++ b/src/lib/drag/core.js @@ -1 +1 @@ -"use strict";import{bind,unbind}from"../utils.js";const DEF_OPT={axis:"",limit:!1,overflow:!0};export default class Drag{constructor(t){this.$elem=t,this._init()}_init(){this.$elem.style.transform="";var{x:t,y:s}=this.$elem.getBoundingClientRect();this.pos={x:t,y:s,_x:0,_y:0}}by(t,s={}){this.$drag=t,this.opt=Object.assign(Object.create(null),DEF_OPT,s),!1!==this.opt.limit&&(this.opt.overflow=!1);var e=document.documentMode?"move":"grab";return e=window.sidebar?"-moz-"+e:"-webkit-"+e,t.style.cursor=e,this._handleResize=bind(window,"resize",this._init.bind(this)),this._handleMousedown=bind(t,"mousedown",t=>{if(this.disabled)return;var s=this.$elem.getBoundingClientRect();s.x-this.pos._x!==this.pos.x&&(this.pos.x=s.x-this.pos._x),s.y-this.pos._y!==this.pos.y&&(this.pos.y=s.y-this.pos._y);let e=t.pageX,i=t.pageY,o=document.documentElement.clientWidth,n=document.documentElement.clientHeight,h=s.width,d=s.height,p=[0,o-h,n-d,0];if("parent"===this.opt.limit){let t=this.$elem.parentNode.getBoundingClientRect();p=[t.top,t.right-h,t.bottom-d,t.left]}let l=bind(document,"mousemove",t=>{t.preventDefault();let o=t.pageX-e+(s.x-this.pos.x),n=t.pageY-i+(s.y-this.pos.y);"x"===this.opt.axis&&(n=0),"y"===this.opt.axis&&(o=0),!1===this.opt.overflow&&(op[1]-this.pos.x&&(o=p[1]-this.pos.x),np[2]-this.pos.y&&(n=p[2]-this.pos.y)),this.pos._x=o,this.pos._y=n,this.$elem.dispatchEvent(new CustomEvent("dragging",{detail:{offset:{x:this.pos.x+o,y:this.pos.y+n},move:{x:o,y:n}}})),this.$elem.style.transform=`translate(${o}px, ${n}px)`}),m=bind(document,"mouseup",t=>{this.$elem.dispatchEvent(new CustomEvent("dragged",{detail:{offset:{x:this.pos.x+this.pos._x,y:this.pos.y+this.pos._y},move:{x:this.pos._x,y:this.pos._y}}})),unbind(document,"mousemove",l),unbind(document,"mouseup",m)})}),this}on(t,s){if(t&&"function"==typeof s)return bind(this,t,s)}off(t,s){unbind(this,t,s)}destroy(){unbind(window,"resize",this._handleResize),unbind(this.$drag,"mousedown",this._handleMousedown),delete this.$elem,delete this.$drag}}; \ No newline at end of file +"use strict";import{bind,unbind}from"../utils.js";const DEF_OPT={axis:"",limit:!1,overflow:!0};export default class Drag{constructor(t){this.$elem=t,this._init()}_init(){this.$elem.style.transform="";var{x:t,y:s}=this.$elem.getBoundingClientRect();this.pos={x:t,y:s,_x:0,_y:0}}by(t,s={}){return this.$drag=t,this.opt=Object.assign(Object.create(null),DEF_OPT,s),!1!==this.opt.limit&&(this.opt.overflow=!1),t.style.cursor="move",this._handleResize=bind(window,"resize",this._init.bind(this)),this._handleMousedown=bind(t,"mousedown",t=>{if(this.disabled)return;var s=this.$elem.getBoundingClientRect();s.x-this.pos._x!==this.pos.x&&(this.pos.x=s.x-this.pos._x),s.y-this.pos._y!==this.pos.y&&(this.pos.y=s.y-this.pos._y);let e=t.pageX,i=t.pageY,o=document.documentElement.clientWidth,n=document.documentElement.clientHeight,h=s.width,d=s.height,p=[0,o-h,n-d,0];if("parent"===this.opt.limit){let t=this.$elem.parentNode.getBoundingClientRect();p=[t.top,t.right-h,t.bottom-d,t.left]}let l=bind(document,"mousemove",t=>{t.preventDefault();let o=t.pageX-e+(s.x-this.pos.x),n=t.pageY-i+(s.y-this.pos.y);"x"===this.opt.axis&&(n=0),"y"===this.opt.axis&&(o=0),!1===this.opt.overflow&&(op[1]-this.pos.x&&(o=p[1]-this.pos.x),np[2]-this.pos.y&&(n=p[2]-this.pos.y)),this.pos._x=o,this.pos._y=n,this.$elem.dispatchEvent(new CustomEvent("dragging",{detail:{offset:{x:this.pos.x+o,y:this.pos.y+n},move:{x:o,y:n}}})),this.$elem.style.transform=`translate(${o}px, ${n}px)`}),m=bind(document,"mouseup",t=>{this.$elem.dispatchEvent(new CustomEvent("dragged",{detail:{offset:{x:this.pos.x+this.pos._x,y:this.pos.y+this.pos._y},move:{x:this.pos._x,y:this.pos._y}}})),unbind(document,"mousemove",l),unbind(document,"mouseup",m)})}),this}on(t,s){if(t&&"function"==typeof s)return bind(this,t,s)}off(t,s){unbind(this,t,s)}destroy(){unbind(window,"resize",this._handleResize),unbind(this.$drag,"mousedown",this._handleMousedown),delete this.$elem,delete this.$drag}}; \ No newline at end of file diff --git a/src/lib/form/button.js b/src/lib/form/button.js index 1b6972d..21af530 100644 --- a/src/lib/form/button.js +++ b/src/lib/form/button.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import"../icon/index.js";const IS_FIREFOX=!!window.sidebar;export default class Button extends HTMLElement{static get observedAttributes(){return["icon","autofocus","loading","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{icon:"",autofocus:"",loading:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.hasAttribute("circle")&&(this.textContent=""),this.__BTN__=this.root.children[1],this.__ICO__=this.__BTN__.children[0]}get loading(){return this.props.loading}set loading(o){var t=typeof o;o!==this.props.loading&&("boolean"===t&&o||"boolean"!==t?(this.props.loading=!0,this.__ICO__.setAttribute("is","loading"),this.setAttribute("loading","")):(this.props.loading=!1,this.__ICO__.setAttribute("is",this.props.icon),this.removeAttribute("loading")))}get disabled(){return this.props.disabled}set disabled(o){var t=typeof o;o!==this.props.disabled&&("boolean"===t&&o||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=(o=>{this.props.loading||this.props.disabled?o.stopPropagation():this.dispatchEvent(new CustomEvent("active"))}),this.__BTN__.addEventListener("click",this._handleClick,!1)}disconnectedCallback(){this.__BTN__.removeEventListener("click",this._handleClick)}attributeChangedCallback(o,t,e){if(t!==e)switch(o){case"icon":this.props.icon=e,e?this.props.loading||this.__ICO__.setAttribute("is",e):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__BTN__.setAttribute("autofocus",""),IS_FIREFOX&&setTimeout(o=>{this.__BTN__.focus()},10);break;case"loading":case"disabled":this[o]=!0}}}; +import"../icon/index.js";const IS_FIREFOX=!!window.sidebar;export default class Button extends HTMLElement{static get observedAttributes(){return["icon","autofocus","loading","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{icon:"",autofocus:"",loading:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.hasAttribute("circle")&&(this.textContent=""),this.__BTN__=this.root.children[1],this.__ICO__=this.__BTN__.children[0]}get loading(){return this.props.loading}set loading(o){var t=typeof o;o!==this.props.loading&&("boolean"===t&&o||"boolean"!==t?(this.props.loading=!0,this.__ICO__.setAttribute("is","loading"),this.setAttribute("loading","")):(this.props.loading=!1,this.__ICO__.setAttribute("is",this.props.icon),this.removeAttribute("loading")))}get disabled(){return this.props.disabled}set disabled(o){var t=typeof o;o!==this.props.disabled&&("boolean"===t&&o||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=(o=>{this.props.loading||this.props.disabled?o.stopPropagation():this.dispatchEvent(new CustomEvent("active"))}),this.__BTN__.addEventListener("click",this._handleClick,!1)}disconnectedCallback(){this.__BTN__.removeEventListener("click",this._handleClick)}attributeChangedCallback(o,t,e){if(null!==e&&t!==e)switch(o){case"icon":this.props.icon=e,e?this.props.loading||this.__ICO__.setAttribute("is",e):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__BTN__.setAttribute("autofocus",""),IS_FIREFOX&&setTimeout(o=>{this.__BTN__.focus()},10);break;case"loading":case"disabled":this[o]=!0}}}; if(!customElements.get('wc-button')){ customElements.define('wc-button', Button) diff --git a/src/lib/form/cascader.js b/src/lib/form/cascader.js deleted file mode 100644 index 50a9bf3..0000000 --- a/src/lib/form/cascader.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * - * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 - * @version v2.0.1 - * - */ - -'use strict' - - - -if(!customElements.get('wc-')){ - customElements.define('wc-', ) -} diff --git a/src/lib/form/checkbox.js b/src/lib/form/checkbox.js index af63000..b08554b 100644 --- a/src/lib/form/checkbox.js +++ b/src/lib/form/checkbox.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import"../icon/index.js";export default class Checkbox extends HTMLElement{static get observedAttributes(){return["label","color","value","checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",color:"",value:[],checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild,this.__ICO__=this.__SWITCH__.children[0]}get value(){return this.props.value}set value(e){if(!Array.isArray(e))throw TypeError(":duplex指令需要传入一个数组, 当前为: "+typeof e);this.props.value=e,this.checked=this.props.value.includes(this.props.label)}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e;var{value:o,checked:t,label:l,color:r}=this.props;this.__SWITCH__.classList.toggle("checked",t),this.__ICO__.setAttribute("is","checkbox-"+(t?"on":"off"));var c=o.indexOf(l);t?(this.__ICO__.setAttribute("color",r),c<0&&o.push(l)):(this.__ICO__.removeAttribute("color"),~c&&o.splice(c,1))}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this.addEventListener("click",e=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))},!1)}attributeChangedCallback(e,o,t){if(o!==t)switch(e){case"label":case"color":this.props[e]=t;break;case"checked":case"disabled":this[e]=!0}}}; +import"../icon/index.js";import{bind,unbind}from"../utils.js";export default class Checkbox extends HTMLElement{static get observedAttributes(){return["label","color","value","checked","readonly","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",color:"",value:[],checked:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild,this.__ICO__=this.__SWITCH__.children[0]}get value(){return this.props.value}set value(e){if(!Array.isArray(e))throw TypeError(":duplex指令需要传入一个数组, 当前为: "+typeof e);this.props.value=e,this.checked=this.props.value.includes(this.props.label)}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e;var{value:o,checked:t,label:l,color:r}=this.props;this.__SWITCH__.classList.toggle("checked",t),this.__ICO__.setAttribute("is","checkbox-"+(t?"on":"off"));var c=o.indexOf(l);t?(this.__ICO__.setAttribute("color",r),c<0&&o.push(l)):(this.__ICO__.removeAttribute("color"),~c&&o.splice(c,1))}get readonly(){return this.props.readonly}set readonly(e){var o=typeof e;e!==this.props.readonly&&("boolean"===o&&e||"boolean"!==o?(this.props.readonly=!0,this.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handlClick=bind(this,"click",e=>{e.preventDefault(),this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handlClick)}attributeChangedCallback(e,o,t){if(null!==t&&o!==t)switch(e){case"label":case"color":this.props[e]=t;break;case"checked":case"readonly":case"disabled":this[e]=!0}}}; if(!customElements.get('wc-checkbox')){ customElements.define('wc-checkbox', Checkbox) diff --git a/src/lib/form/input.js b/src/lib/form/input.js index a229544..ec4f472 100644 --- a/src/lib/form/input.js +++ b/src/lib/form/input.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";const IS_FIREFOX=!!window.sidebar,TYPES=["text","textarea","password"],INPUTS={text:'',textarea:''};export default class Input extends HTMLElement{static get observedAttributes(){return["value","icon","type","label","placeholder","mvidx","autofocus","readonly","disabled"]}constructor(){super();var e,t=this.getAttribute("type");"textarea"!==t&&(t="text"),e=INPUTS[t],Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:"",icon:"",type:"text",label:"",placeholder:"",mvidx:null,autofocus:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=`
    ${e}
      `,this.props.type=t,this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__ICO__=this.__OUTER__.children[2],this.__APPEND__=this.__OUTER__.children[3],this.__LIST__=this.__OUTER__.children[4]}get readonly(){return this.props.readonly}set readonly(e){var t=typeof e;e!==this.props.readonly&&("boolean"===t&&e||"boolean"!==t?(this.props.readonly=!0,this.setAttribute("readonly",""),this.__INPUT__.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly"),this.__INPUT__.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.__INPUT__.value}set value(e){this.__INPUT__.value=e}get type(){return this.__INPUT__.type}set type(e){"textarea"!==e&&(this.__INPUT__.type=e)}_moveSelect(e){var{list:t}=this.props;if(t&&t.length){e.preventDefault();var i=38===e.keyCode?-1:1,s=Array.from(this.__LIST__.firstElementChild.firstElementChild.children);null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=i,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__LIST__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.list[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),this._handleChange(t),this.__LIST__.classList.remove("show"),this.props.mvidx=null}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append","");var{type:i}=this.props;this._handleSubmit=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly){if((38===e.keyCode||40===e.keyCode)&&"text"===this.type)return this._moveSelect(e);if(13===e.keyCode){if("text"===this.type&&null!==this.props.mvidx)return this._fetchSelect(this.props.mvidx,e);("text"===i||"textarea"===i&&(e.ctrlKey||e.metaKey))&&this.dispatchEvent(new CustomEvent("submit",{detail:this.value}))}}}),this._handleWheel=ebind(this.__INPUT__,"wheel"),"text"===i&&(this._handleChange=bind(this.__INPUT__,"input",e=>{e.preventDefault(),this.dispatchEvent(new CustomEvent("fetch-suggest",{detail:{value:this.value,send:e=>{this.props.list=e,this._parseSuggestion()}}}))}),this._parseSuggestion=bind(this.__INPUT__,"click",e=>{var{list:t}=this.props;let{x:i,y:s,width:o}=this.getBoundingClientRect();if(t&&t.length){var a=t.map((e,t)=>`
    • ${e.value}
    • `).join("");this.__LIST__.firstElementChild.firstElementChild.innerHTML=a,this.__LIST__.classList.toggle("show",!0),this.__LIST__.style.cssText=`left:${i}px;top:${s+50}px;width:${o}px;`}else this.__LIST__.classList.toggle("show",!1)}),this._inactiveFn=clickOutside(this,e=>{this.__LIST__.classList.remove("show")}),this._handleSelect=bind(this.__LIST__,"click",e=>{"LI"===e.target.tagName&&(this._fetchSelect(e.target.dataset.idx,e),this.dispatchEvent(new CustomEvent("input")))}))}disconnectedCallback(){unbind(this.__INPUT__,"wheel",this._handleWheel),unbind(this.__INPUT__,"keydown",this._handleSubmit),unbind(this.__INPUT__,"input",this._handleChange),unbind(document,"mousedown",this._inactiveFn),unbind(this.__LIST__,"click",this._handleSelect)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"icon":this.props.icon=i,i?this.__ICO__.setAttribute("is",i):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__INPUT__.setAttribute("autofocus",""),IS_FIREFOX&&setTimeout(e=>{this.__INPUT__.focus()},10);break;case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"type":~TYPES.indexOf(i)?this.type=i:this.type="text";break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}}; +import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";const TYPES=["text","textarea","password"],INPUTS={text:'',textarea:''};export default class Input extends HTMLElement{static get observedAttributes(){return["value","icon","type","label","placeholder","mvidx","autofocus","readonly","disabled"]}constructor(){super();var e,t=this.getAttribute("type");"textarea"!==t&&(t="text"),e=INPUTS[t],Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:"",icon:"",type:"text",label:"",placeholder:"",mvidx:null,autofocus:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=`
      ${e}
        `,this.props.type=t,this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__ICO__=this.__OUTER__.children[2],this.__APPEND__=this.__OUTER__.children[3],this.__LIST__=this.__OUTER__.children[4]}get readonly(){return this.props.readonly}set readonly(e){var t=typeof e;e!==this.props.readonly&&("boolean"===t&&e||"boolean"!==t?(this.props.readonly=!0,this.setAttribute("readonly",""),this.__INPUT__.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly"),this.__INPUT__.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.__INPUT__.value}set value(e){this.__INPUT__.value=e}get type(){return this.__INPUT__.type}set type(e){"textarea"!==e&&(this.__INPUT__.type=e)}_moveSelect(e){var{list:t}=this.props;if(t&&t.length){e.preventDefault();var i=38===e.keyCode?-1:1,s=Array.from(this.__LIST__.firstElementChild.firstElementChild.children);null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=i,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__LIST__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.list[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),this._handleChange(t),this.__LIST__.classList.remove("show"),this.props.mvidx=null}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append","");var{type:i}=this.props;this._handleSubmit=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly){if((38===e.keyCode||40===e.keyCode)&&"text"===this.type)return this._moveSelect(e);if(13===e.keyCode){if("text"===this.type&&null!==this.props.mvidx)return this._fetchSelect(this.props.mvidx,e);("text"===i||"textarea"===i&&(e.ctrlKey||e.metaKey))&&this.dispatchEvent(new CustomEvent("submit",{detail:this.value}))}}}),this._handleWheel=ebind(this.__INPUT__,"wheel"),"text"===i&&(this._handleChange=bind(this.__INPUT__,"input",e=>{e.preventDefault(),this.dispatchEvent(new CustomEvent("fetch-suggest",{detail:{value:this.value,send:e=>{this.props.list=e,this._parseSuggestion()}}}))}),this._parseSuggestion=bind(this.__INPUT__,"click",e=>{var{list:t}=this.props;let{x:i,y:s,width:o}=this.getBoundingClientRect();if(t&&t.length){var l=t.map((e,t)=>`
      • ${e.value}
      • `).join("");this.__LIST__.firstElementChild.firstElementChild.innerHTML=l,this.__LIST__.classList.toggle("show",!0),this.__LIST__.style.cssText=`left:${i}px;top:${s+50}px;width:${o}px;`}else this.__LIST__.classList.toggle("show",!1)}),this._inactiveFn=clickOutside(this,e=>{this.__LIST__.classList.remove("show")}),this._handleSelect=bind(this.__LIST__,"click",e=>{"LI"===e.target.tagName&&(this._fetchSelect(e.target.dataset.idx,e),this.dispatchEvent(new CustomEvent("input")))}))}disconnectedCallback(){unbind(this.__INPUT__,"wheel",this._handleWheel),unbind(this.__INPUT__,"keydown",this._handleSubmit),unbind(this.__INPUT__,"input",this._handleChange),unbind(document,"mousedown",this._inactiveFn),unbind(this.__LIST__,"click",this._handleSelect)}attributeChangedCallback(e,t,i){if(null!==i&&t!==i)switch(e){case"icon":this.props.icon=i,i?this.__ICO__.setAttribute("is",i):(this.removeAttribute("icon"),this.__ICO__.removeAttribute("is"));break;case"autofocus":this.__INPUT__.setAttribute("autofocus",""),setTimeout(e=>{this.__INPUT__.focus()},10);break;case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"type":~TYPES.indexOf(i)?this.type=i:this.type="text";break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}}; if(!customElements.get('wc-input')){ customElements.define('wc-input', Input) diff --git a/src/lib/form/number.js b/src/lib/form/number.js new file mode 100644 index 0000000..30a145c --- /dev/null +++ b/src/lib/form/number.js @@ -0,0 +1,15 @@ +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-07 23:35:03 + * @version v2.0.1 + * + */ + +'use strict' + +import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind}from"../utils.js";export default class Number extends HTMLElement{static get observedAttributes(){return["value","max","min","step","autofocus","readonly","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:0,max:null,min:null,step:1,autofocus:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
        - \x3c!-- --\x3e + \x3c!-- --\x3e
        ",this.__OUTER__=this.root.children[1],this.__INPUT__=this.__OUTER__.children[1]}get readonly(){return this.props.readonly}set readonly(e){var t=typeof e;e!==this.props.readonly&&("boolean"===t&&e||"boolean"!==t?(this.props.readonly=!0,this.setAttribute("readonly",""),this.__INPUT__.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly"),this.__INPUT__.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.props.value}set value(e){var t=+e;e=t==t?t:0,this.props.value=e,this.__INPUT__.value=this.props.value,this._checkActionEnable()}_checkActionEnable(){var{max:e,min:t,value:i}=this.props;null!==e&&this.__OUTER__.children[2].classList.toggle("disabled",i>=e),null!==t&&this.__OUTER__.children[0].classList.toggle("disabled",i<=t)}_updateValue(e){var{max:t,min:i,value:s,step:a}=this.props;if("+"===e){if(null!==t&&ts-a)return;s-=a}this.props.value=+s.toFixed(2),this.__INPUT__.value=this.props.value,this._checkActionEnable(),this.dispatchEvent(new CustomEvent("input"))}connectedCallback(){this._handleSubmit=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly)return 38===e.keyCode||40===e.keyCode?(e.preventDefault(),this._updateValue(38===e.keyCode?"+":"-")):void(13===e.keyCode&&(e.preventDefault(),this.dispatchEvent(new CustomEvent("submit",{detail:this.value}))))}),this._handleChange=ebind(this.__INPUT__,"change",e=>{isFinite(this.__INPUT__.value)?(this.props.value=+this.__INPUT__.value,this.__INPUT__.value.endsWith(".")||(this.__INPUT__.value=this.props.value)):this.__INPUT__.value=this.props.value=0,this.dispatchEvent(new CustomEvent("input"))}),this._handleAction=bind(this.__OUTER__,"click",e=>{if(!this.disabled&&!this.readonly){var t=e.target;if("SPAN"===t.tagName||"SPAN"===t.parentNode){var i=t.dataset.act||t.parentNode.dataset.act;this._updateValue(i)}}})}disconnectedCallback(){unbind(this.__INPUT__,"keydown",this._handleSubmit)}attributeChangedCallback(e,t,i){if(null!==i&&t!==i)switch(e){case"autofocus":this.__INPUT__.setAttribute("autofocus",""),setTimeout(e=>{this.__INPUT__.focus()},10);break;case"value":this.value=i>>0;break;case"step":case"max":case"min":var s=+i;s==s&&(this.props[e]=s),this._checkActionEnable();break;case"readonly":case"disabled":this[e]=!0}}}; + +if(!customElements.get('wc-number')){ + customElements.define('wc-number', Number) +} diff --git a/src/lib/form/progress.js b/src/lib/form/progress.js index c346f77..34e6d5a 100644 --- a/src/lib/form/progress.js +++ b/src/lib/form/progress.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -export default class Progress extends HTMLElement{static get observedAttributes(){return["value","max"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:0,max:1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__THUMB__=this.root.children[1].lastElementChild}get value(){return this.props.value}set value(e){this.props.value=+e,this.calculate()}calculate(){var{max:e,value:a}=this.props;this.__THUMB__.style.width=`${100*a/e}%`}connectedCallback(){this.calculate()}attributeChangedCallback(e,a,l){if(a!==l)switch(e){case t:var t=+l;(t!=t||t<1)&&(t=1),this.props.max=t,this.calculate();break;case"value":var r=+l;r==r&&(this.props.value=r,this.calculate())}}}; +export default class Progress extends HTMLElement{static get observedAttributes(){return["value","max"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{value:0,max:1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__THUMB__=this.root.children[1].lastElementChild}get value(){return this.props.value}set value(e){this.props.value=+e,this.calculate()}calculate(){var{max:e,value:a}=this.props;this.__THUMB__.style.width=`${100*a/e}%`}connectedCallback(){this.calculate()}attributeChangedCallback(e,a,l){if(null!==l&&a!==l)switch(e){case t:var t=+l;(t!=t||t<1)&&(t=1),this.props.max=t,this.calculate();break;case"value":var r=+l;r==r&&(this.props.value=r,this.calculate())}}}; if(!customElements.get('wc-progress')){ customElements.define('wc-progress', Progress) diff --git a/src/lib/form/radio.js b/src/lib/form/radio.js index 9c7d75a..970236f 100644 --- a/src/lib/form/radio.js +++ b/src/lib/form/radio.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import{bind,unbind}from"../utils.js";export default class Radio extends HTMLElement{static get observedAttributes(){return["label","checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild}get value(){return this.props.label}set value(e){this.checked=this.props.label===e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||this.checked||(this.checked=!0,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,o,t){if(o!==t)switch(e){case"label":this.props.label=t;break;case"checked":case"disabled":this[e]=!0}}}; +import{bind,unbind}from"../utils.js";export default class Radio extends HTMLElement{static get observedAttributes(){return["label","checked","readonly","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",checked:!1,readonly:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild}get value(){return this.props.label}set value(e){this.checked=this.props.label===e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get readonly(){return this.props.readonly}set readonly(e){var o=typeof e;e!==this.props.readonly&&("boolean"===o&&e||"boolean"!==o?(this.props.readonly=!0,this.setAttribute("readonly","")):(this.props.readonly=!1,this.removeAttribute("readonly")))}get disabled(){return this.props.disabled}set disabled(e){var o=typeof e;e!==this.props.disabled&&("boolean"===o&&e||"boolean"!==o?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||this.readonly||this.checked||(this.checked=!0,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,o,t){if(null!==t&&o!==t)switch(e){case"label":this.props.label=t;break;case"checked":case"readonly":case"disabled":this[e]=!0}}}; if(!customElements.get('wc-radio')){ customElements.define('wc-radio', Radio) diff --git a/src/lib/form/select.js b/src/lib/form/select.js index 02774dc..d3ec65e 100644 --- a/src/lib/form/select.js +++ b/src/lib/form/select.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";function parseOptions(e,t){let i="";for(let s of e)if(s.list){i+=`
        ${s.name}
        `;for(let e of s.list)t.DICT[e.value]=e,e.disabled||t.LIST.push(e),i+=`
        ${e.label}
        `}else s.disabled||t.LIST.push(s),t.DICT[s.value]=s,i+=`
        ${s.label}
        `;return i}export default class Select extends HTMLElement{static get observedAttributes(){return["label","placeholder","multi","value","options","mvidx","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",placeholder:"",multi:"",value:"",options:"",mvidx:null,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
        ",this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__ICO__=this.__OUTER__.children[2],this.__APPEND__=this.__OUTER__.children[3],this.__OPTG__=this.__OUTER__.children[4]}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.props.value}set value(e){var{DICT:t,active:i}=this.props;this.props.value=e,this.__INPUT__.value=t&&t[e]&&t[e].label||e,i||this._updateStyle()}_renderOptions(e){this.props.DICT={},this.props.LIST=[];var t=this.__OPTG__.firstElementChild.firstElementChild;t.innerHTML=parseOptions(e,this.props),this.props.ITEMS=Array.from(t.children).filter(e=>"DD"===e.tagName&&!e.hasAttribute("disabled")),this.value=this.props.value}_moveSelect(e){var{LIST:t,DICT:i,ITEMS:s}=this.props;if(t&&t.length){e.preventDefault();var o=38===e.keyCode?-1:1;null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=o,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__OPTG__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_updateStyle(e){var{LIST:t,ITEMS:i,value:s}=this.props;if(t&&t.length){if(void 0===e)for(let i,o=-1;i=t[++o];)if(s===i.value){e=o;break}this.props.mvidx=e,i.forEach((t,i)=>{i===e?t.setAttribute("focus",""):t.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.LIST[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),t&&this._updateStyle(e),this.props.active=!1,this.__OPTG__.classList.remove("show")}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());function i(){var{x:e,y:t,width:i}=this.getBoundingClientRect(),s=this.getAttribute("size");this.props.active=!0,t+=s&&"mini"===s?32:50,this.__OPTG__.style.cssText=`left:${e}px;top:${t}px;width:${i}px;`}e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append",""),this._handleKeydown=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly)return 38===e.keyCode||40===e.keyCode?this.props.active?this._moveSelect(e):(i.call(this),void this.__OPTG__.classList.toggle("show",!0)):13===e.keyCode&&null!==this.props.mvidx&&this.props.active?this._fetchSelect(this.props.mvidx):void 0}),this._activeFn=bind(this.__INPUT__,"click",e=>{var{options:t}=this.props;i.call(this),this.__OPTG__.classList.toggle("show")}),this._handleSelect=bind(this.__OPTG__,"click",e=>{"DD"!==e.target.tagName||e.target.hasAttribute("disabled")||(this._fetchSelect(+e.target.dataset.idx,!0),this.dispatchEvent(new CustomEvent("input")))}),this._inactiveFn=clickOutside(this,e=>{this.__OPTG__.classList.toggle("show",!1),this.props.active=!1})}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"options":if(i){try{this._renderOptions(JSON.parse(i))}catch(e){}this.removeAttribute("options")}break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}disconnectedCallback(){unbind(this.__INPUT__,"keydown",this._handleKeydown),unbind(this.__INPUT__,"click",this._activeFn),unbind(document,"mousedown",this._inactiveFn),unbind(this.__OPTG__,"click",this._handleSelect)}}; +import"../scroll/index.js";import"../icon/index.js";import{ebind,bind,unbind,clickOutside}from"../utils.js";function parseOptions(e,t){let i="";for(let s of e)if(s.list){i+=`
        ${s.name}
        `;for(let e of s.list)t.DICT[e.value]=e,e.disabled||t.LIST.push(e),i+=`
        ${e.label}
        `}else s.disabled||t.LIST.push(s),t.DICT[s.value]=s,i+=`
        ${s.label}
        `;return i}export default class Select extends HTMLElement{static get observedAttributes(){return["label","placeholder","multi","value","options","mvidx","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{label:"",placeholder:"",multi:"",value:"",options:"",mvidx:null,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
        ",this.__OUTER__=this.root.children[1],this.__PREPEND__=this.__OUTER__.children[0],this.__INPUT__=this.__OUTER__.children[1],this.__APPEND__=this.__OUTER__.children[3],this.__OPTG__=this.__OUTER__.children[4]}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled",""),this.__INPUT__.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled"),this.__INPUT__.removeAttribute("disabled")))}get value(){return this.props.value}set value(e){var{DICT:t,active:i}=this.props;this.props.value=e,this.__INPUT__.value=t&&t[e]&&t[e].label||e,i||this._updateStyle()}_renderOptions(e){this.props.DICT={},this.props.LIST=[];var t=this.__OPTG__.firstElementChild.firstElementChild;t.innerHTML=parseOptions(e,this.props),this.props.ITEMS=Array.from(t.children).filter(e=>"DD"===e.tagName&&!e.hasAttribute("disabled")),this.value=this.props.value}_moveSelect(e){var{LIST:t,DICT:i,ITEMS:s}=this.props;if(t&&t.length){e.preventDefault();var o=38===e.keyCode?-1:1;null===this.props.mvidx?this.props.mvidx=0:this.props.mvidx+=o,this.props.mvidx<0?this.props.mvidx=0:this.props.mvidx>s.length-1&&(this.props.mvidx=s.length-1),s.forEach((e,t)=>{t===this.props.mvidx?(this.__OPTG__.firstElementChild.scrollTop=e.offsetTop-150,e.setAttribute("focus","")):e.removeAttribute("focus")})}}_updateStyle(e){var{LIST:t,ITEMS:i,value:s}=this.props;if(t&&t.length){if(void 0===e)for(let i,o=-1;i=t[++o];)if(s===i.value){e=o;break}this.props.mvidx=e,i.forEach((t,i)=>{i===e?t.setAttribute("focus",""):t.removeAttribute("focus")})}}_fetchSelect(e,t){var i=this.props.LIST[e];this.value=i.value,this.dispatchEvent(new CustomEvent("select",{detail:i})),t&&this._updateStyle(e),this.props.active=!1,this.__OPTG__.classList.remove("show")}connectedCallback(){for(var e=this.__PREPEND__.assignedNodes(),t=this.__APPEND__.assignedNodes();e.length>1;)this.removeChild(e.pop());for(;t.length>1;)this.removeChild(t.pop());function i(){var{x:e,y:t,width:i}=this.getBoundingClientRect(),s=this.getAttribute("size");this.props.active=!0,t+=s&&"mini"===s?32:50,this.__OPTG__.style.cssText=`left:${e}px;top:${t}px;width:${i}px;`}e.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("prepend",""),t.length&&"textarea"!==this.props.type&&this.__OUTER__.setAttribute("append",""),this._handleKeydown=ebind(this.__INPUT__,"keydown",e=>{if(!this.disabled&&!this.readonly)return 38===e.keyCode||40===e.keyCode?this.props.active?this._moveSelect(e):(i.call(this),void this.__OPTG__.classList.toggle("show",!0)):13===e.keyCode&&null!==this.props.mvidx&&this.props.active?this._fetchSelect(this.props.mvidx):void 0}),this._activeFn=bind(this.__INPUT__,"click",e=>{var{options:t}=this.props;i.call(this),this.__OPTG__.classList.toggle("show")}),this._handleSelect=bind(this.__OPTG__,"click",e=>{"DD"!==e.target.tagName||e.target.hasAttribute("disabled")||(this._fetchSelect(+e.target.dataset.idx,!0),this.dispatchEvent(new CustomEvent("input")))}),this._inactiveFn=clickOutside(this,e=>{this.__OPTG__.classList.toggle("show",!1),this.props.active=!1})}attributeChangedCallback(e,t,i){if(null!==i&&t!==i)switch(e){case"label":case"placeholder":this.__INPUT__.setAttribute("placeholder",i);break;case"options":if(i){try{this._renderOptions(JSON.parse(i))}catch(e){}this.removeAttribute("options")}break;case"value":this.value=i;break;case"readonly":case"disabled":this[e]=!0}}disconnectedCallback(){unbind(this.__INPUT__,"keydown",this._handleKeydown),unbind(this.__INPUT__,"click",this._activeFn),unbind(document,"mousedown",this._inactiveFn),unbind(this.__OPTG__,"click",this._handleSelect)}}; if(!customElements.get('wc-select')){ customElements.define('wc-select', Select) diff --git a/src/lib/form/switch.js b/src/lib/form/switch.js index d151795..0aa81c7 100644 --- a/src/lib/form/switch.js +++ b/src/lib/form/switch.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import{bind,unbind}from"../utils.js";export default class Switch extends HTMLElement{static get observedAttributes(){return["checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__SWITCH__=this.root.lastElementChild}get value(){return this.props.checked}set value(e){this.checked=e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"checked":case"disabled":this[e]=!0}}}; +import{bind,unbind}from"../utils.js";export default class Switch extends HTMLElement{static get observedAttributes(){return["checked","disabled"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{checked:!1,disabled:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
        ",this.__SWITCH__=this.root.lastElementChild.firstElementChild}get value(){return this.props.checked}set value(e){this.checked=e}get checked(){return this.props.checked}set checked(e){this.props.checked=!!e,this.__SWITCH__.classList.toggle("checked",this.props.checked)}get disabled(){return this.props.disabled}set disabled(e){var t=typeof e;e!==this.props.disabled&&("boolean"===t&&e||"boolean"!==t?(this.props.disabled=!0,this.setAttribute("disabled","")):(this.props.disabled=!1,this.removeAttribute("disabled")))}connectedCallback(){this._handleClick=bind(this,"click",e=>{this.disabled||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("input")))})}disconnectedCallback(){unbind(this,"click",this._handleClick)}attributeChangedCallback(e,t,i){if(null!==i&&t!==i)switch(e){case"checked":case"disabled":this[e]=!0}}}; if(!customElements.get('wc-switch')){ customElements.define('wc-switch', Switch) diff --git a/src/lib/icon/index.js b/src/lib/icon/index.js index dcacff8..93ab04b 100644 --- a/src/lib/icon/index.js +++ b/src/lib/icon/index.js @@ -1,14 +1,14 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ 'use strict' -import SVG_DICT from"./svg.js";export default class Icon extends HTMLElement{static get observedAttributes(){return["is"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{is:""},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__ICO__=this.root.lastElementChild,this.drawPath()}drawPath(){var{is:o}=this.props,t=SVG_DICT[o];this.__ICO__&&o&&t&&(this.__ICO__.innerHTML="loading"===o?t:``,this.__ICO__.classList.toggle("load","loading"===o))}get is(){return this.props.is}set is(o){this.props.is=o,this.drawPath()}attributeChangedCallback(o,t,e){if(t!==e)switch(o){case"is":this.is=e,e||this.removeAttribute("is")}}}; +import SVG_DICT from"./svg.js";export default class Icon extends HTMLElement{static get observedAttributes(){return["is"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{is:""},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML=" ",this.__ICO__=this.root.lastElementChild,this.drawPath()}get is(){return this.props.is}drawPath(){var{is:o}=this.props,t=SVG_DICT[o];this.__ICO__&&o&&t&&(this.__ICO__.innerHTML="loading"===o?t:``,this.__ICO__.classList.toggle("load","loading"===o))}attributeChangedCallback(o,t,e){if(null!==e&&t!==e)switch(o){case"is":this.props.is=e,e?this.drawPath():this.removeAttribute("is")}}}; if(!customElements.get('wc-icon')){ customElements.define('wc-icon', Icon) diff --git a/src/lib/layer/Release.md b/src/lib/layer/Release.md deleted file mode 100644 index ef9aba3..0000000 --- a/src/lib/layer/Release.md +++ /dev/null @@ -1,30 +0,0 @@ -v1.0.0-base / 2017-09-20 -================== - + 统一字体图标 - + 精简动画类型 - + 优化样式 - -v0.0.4-base / 2017-04-20 -================== - + 优化offset的处理 - + 优化样式 - - -v0.0.3-base / 2017-04-15 -================== - + 重构wrap方式创建弹窗实例的实现 - - -v0.0.2-base / 2017-04-13 -================== - + 修复:layer方式创建实例时,漏掉自身的bug; - + 修复layer.open()方法打开已有实例时不返回id的bug; - + 修复layer.close()方法关闭实例时,未修改实例状态的bug; - + 修改特殊模式下的实例的最小宽度为10px; - + 优化:layer方式创建实例的逻辑处理; - + 优化layer.alert()方法参数的处理; - - -v0.0.1-base / 2017-04-06 -================== - + 完成layer base版移植 \ No newline at end of file diff --git a/src/lib/layer/index.js b/src/lib/layer/index.js index 87b8374..4dc8edc 100644 --- a/src/lib/layer/index.js +++ b/src/lib/layer/index.js @@ -1 +1,15 @@ -"use strict";import"../drag/index.js";Anot.ui.layer="1.0.0-normal";const log=console.log,LANGUAGES={en:{TITLE:"Dialog",YES_BTN:"OK",NO_BTN:"Cancel",ERROR:"The layer instance is not exists",NEED_CONTAINER:'layer "tips" require a DOM object as container'},zh:{TITLE:"提示",YES_BTN:"确定",NO_BTN:"取消",ERROR:"要关闭的layer实例不存在",NEED_CONTAINER:"tips类型需要指定一个元素节点作为容器"},"zh-TW":{TITLE:"提示",YES_BTN:"確定",NO_BTN:"取消",ERROR:"要關閉的layer實例不存在",NEED_CONTAINER:"tips类型需要指定一個元素節點作爲容器"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let layerDom={},layerObj={},unique=null,lid=0,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{},btns:[lang.YES_BTN,lang.NO_BTN]};const $doc=Anot(document),uuid=function(){return"layer-"+lid++},close=function(e){if("string"!=typeof e&&"number"!=typeof e)return Anot.error(lang.ERROR);if(/^layerwrap\-/.test(e)||layerObj["layerwrap-"+e])try{if(e=(layerObj["layerwrap-"+e]?"layerwrap-":"")+e,!layerObj[e].show)return;layerObj[e].parentElem.replaceChild(layerObj[e].wrap,layerDom[e][0]),layerObj[e].wrap.style.display="none",layerObj[e].show=!1}catch(e){}else unique=null,layerDom[e]&&(layerDom[e][0].classList.add("shift"),layerDom[e][1].classList.add("shift"),layerDom[e][0].style.opacity="",layerDom[e][1].style.opacity=0,setTimeout(function(){try{layerDom[e][0].parentNode.removeChild(layerDom[e][0]),delete layerDom[e],delete Anot.vmodels[e]}catch(e){}},200));document.body.style.overflow=""},fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};class __layer__{get dot(){return{1:1,2:5,3:5,4:9}}constructor(e){if(e){let{yes:t,no:o,success:s}=e;delete e.yes,delete e.no,delete e.success,this.__init__({state:{...e},props:{yes:t,no:o,success:s}}).append().show()}this.timeout=null}__init__(e){let t=e.$id||uuid();return this.init={$id:t,state:{...defconf,...e.state},props:e.props,skip:["area","shift","offset","mask","maskClose","container","follow"],methods:{shake(){this.$refs.layer.classList.add("scale"),setTimeout(()=>{this.$refs.layer.classList.remove("scale")},100)},onMaskClick:function(e){e.target===e.currentTarget&&(this.type<4&&!this.maskClose?this.shake():this.maskClose&&this.close())},handleConfirm:function(){if(3===this.type&&!this.prompt)return this.shake();if("function"==typeof this.props.yes){let e=[this.$id];3===this.type&&e.unshift(this.prompt),this.props.yes.apply(this,e)}else this.close()},handleCancel:function(){"function"==typeof this.props.no?this.props.no.call(this,this.$id):this.close()},close:function(){close(this.$id)}},mounted:function(){"function"==typeof this.props.success&&this.props.success.call(this)}},4===this.init.state.type&&(this.init.methods.autoSize=function(){let{layer:e,frame:t}=this.$refs;t.onload=function(){try{let o=t.contentWindow.document.body,{clientWidth:s,clientHeight:n}=o;e.style.cssText+=`width: ${s}px;height: ${n}px;`,t.style.cssText+=`height: ${n}px;`}catch(e){}}}),this}create(){let{state:e,$id:t}=this.init,o=document.createElement("div"),s=document.createElement("div");if(o.setAttribute("anot",t),o.setAttribute(":on-click","onMaskClick"),o.classList.add("do-layer"),e.mask&&(o.classList.add("mask"),e.container&&e.container!==document.body&&o.classList.add("inner")),e.maskColor&&(o.style.background=e.maskColor),s.classList.add("layer-box"),s.classList.add("skin-normal"),e.extraClass&&(s.classList.add(e.extraClass),delete e.extraClass),e.shift){fixOffset(e.shift);for(let t in e.shift){let o=e.shift[t];o+=isFinite(o)?"px":"",s.style.cssText+=`${t}: ${o};`}}e.toast?s.classList.add("type-toast"):s.classList.add("type-"+e.type),s.setAttribute("ref","layer"),s.style.cssText+="border-radius:"+e.radius+"px",e.menubar||e.fixed||(s.setAttribute(":drag",""),s.setAttribute("data-limit","window"));var n="";"auto"!==e.area[0]&&(n+="width: "+e.area[0]+";"),"auto"!==e.area[1]&&(n+="height: "+e.area[1]+";");let i="";return 5===e.type&&(i+=''),s.innerHTML=`\n ${this.mkMenubar()}\n \n\n ${6===e.type?this.mkLoading(e.load):""}\n \n ${this.mkCtrl()}\n ${i}\n `,delete e.wrap,o.appendChild(s),[o,s]}mkLoading(e){return`\n
        \n \n ${(1===e?'':"").repeat(this.dot[e])}\n \n
        \n `}mkMenubar(){let{menubar:e,fixed:t}=this.init.state,o="";return e&&(o=`\n
        \n
        \n `),o}mkCtrl(){let{type:e}=this.init.state;if(e>3)return"";{let t="",o='\n \n ';return e>1&&(o='\n \n '+o),t=`\n
        \n ${o}\n
        \n `}}append(){let{state:e,$id:t}=this.init,o=e.container;return e.type<4&&(unique&&close(unique),unique=t),layerDom[t]=this.create(),delete e.toast,this.toast=!0,o||(o=document.body),o.appendChild(layerDom[t][0]),this.vm=Anot(this.init),this}show(){let e=this.vm,{state:t,$id:o}=this.init,s=t.container;setTimeout(function(){let n={background:t.background},i=Anot(layerDom[o][1]);if(5===t.type){let e=getComputedStyle(layerDom[o][1]);n.color=t.color,n.opacity=1;let a=Anot(s),r=a[0].querySelector(".arrow"),l=a.innerWidth(),c=a.innerHeight(),d=a.offset().left-$doc.scrollLeft(),p=a.offset().top-$doc.scrollTop(),y=parseInt(e.width),f=parseInt(e.height),u=["top"];Anot(layerDom[o][1]).css(n),a.bind("mouseenter",e=>{let o={visibility:"visible"};d=a.offset().left-$doc.scrollLeft(),(p=a.offset().top-$doc.scrollTop())+18window.innerWidth?(o.left=d+.3*l-y,u[1]="left"):o.left=d+.7*l,r.classList.add("offset-"+u.join("-")),i.css(o)}),a.bind("mouseleave",()=>{setTimeout(()=>{r.classList.remove("offset-"+u.join("-")),u=["top"],r.style.borderBottomColor="",r.style.borderTopColor="",layerDom[o][1].style.visibility="hidden"},100)})}else{let s={opacity:1};t.offset&&(fixOffset(t.offset),Object.assign(s,t.offset)),i.css(n),setTimeout(()=>{document.body.style.overflow="hidden",layerDom[o][1].classList.add("shift"),setTimeout(t=>{i.css(s),e&&e.$refs.input&&e.$refs.input.focus(),setTimeout(e=>{try{layerDom[o][1].classList.remove("shift")}catch(e){}},500)},50)},50)}},4),t.type>3&&(t.timeout>0?(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{clearTimeout(this.timeout),close(o),6===t.type&&this.vm.props.yes.call(this.vm,o)},t.timeout)):6===t.type&&this.vm.props.yes.call(this.vm,o))}}const _layer={alert(e,t,o){let s={content:e,fixed:!0};return"function"==typeof t?s.yes=t:(t&&(s.title=t+""),o&&"function"==typeof o&&(s.yes=o)),_layer.open(s)},confirm(e,t,o,s){let n={content:e,fixed:!0,type:2};return"function"==typeof t?(n.yes=t,"function"==typeof o&&(n.no=o)):(t&&(n.title=t+""),o&&"function"==typeof o&&(n.yes=o),s&&"function"==typeof s&&(n.no=s)),_layer.open(n)},frame(e,t={}){let o={content:``,menubar:!1,maskClose:!0,type:4,...t};return _layer.open(o)},toast(e,t="info",o=2500){switch("number"==typeof t&&(o=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let s={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:o,offset:{top:50},fixed:!0,toast:!0};return _layer.open(s)},load:(e,t,o)=>(e=(e>>>=0)<1?1:e>4?4:e,"function"==typeof t?(o=t,t=null):(t instanceof HTMLElement||(t=null),"function"!=typeof o&&(o=Anot.noop)),_layer.open({container:t,type:6,load:e,yes:o,menubar:!1,background:"none",fixed:!0})),tips:(e,t,o={})=>t instanceof HTMLElement?(o.background||(o.background="rgba(0,0,0,.5)"),o.color||(o.color="#fff"),Object.assign(o,{container:t,content:e,type:5,fixed:!0,mask:!1,menubar:!1,timeout:0}),_layer.open(o)):Anot.error(lang.NEED_CONTAINER),prompt(e,t){if("function"!=typeof t)return console.error("argument [callback] requires a function, but "+typeof t+" given");let o={type:3,prompt:"",title:e,content:'',fixed:!0,yes:t};return _layer.open(o)},close:close,open(e){if("string"==typeof e){if(layerObj[e="layerwrap-"+e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id},version:Anot.ui.layer};Anot.directive("layer",{priority:8090,init:function(e){e.element.removeAttribute(e.name),e.param&&"tips"===e.param||(e.param="",e.element.style.display="none")},update:function(e){if(!e)return console.error(`SyntaxError: Unexpected [${this.name}=${this.expr}]`);let t=Object.assign({type:7,wrap:!0},this.element.dataset);if(this.param){if("tips"===this.param){let o=document.createElement("div"),s=document.createElement("span"),n=document.createElement("i"),i=Anot(this.element),{position:a}=getComputedStyle(this.element);o.className="do-layer__tips",s.className="layer-content",n.className="arrow",s.textContent=e,o.appendChild(s),o.appendChild(n),"static"===a&&(this.element.style.position="relative"),this.element.appendChild(o);let r={};t.color&&(r.color=t.color),t.color&&(r.background=t.background);let l=i.innerWidth(),c=i.innerHeight(),d=["top"];Anot(o).css(r),i.bind("mouseenter",e=>{let s={visibility:"visible"},a=o.clientWidth,r=o.clientHeight,{left:p,top:y}=i.offset(),f=p-$doc.scrollLeft();y-$doc.scrollTop()window.innerWidth?(s.left=.3*l-a,d[1]="left"):s.left=.7*l,n.classList.add("offset-"+d.join("-")),Anot(o).css(s)}),i.bind("mouseleave",()=>{setTimeout(()=>{n.classList.remove("offset-"+d.join("-")),d=["top"],n.style.borderBottomColor="",n.style.borderTopColor="",o.style.visibility="hidden"},100)})}}else{let o={$id:"layerwrap-"+e,state:t,props:{}};t.hasOwnProperty("area")&&(t.area=t.area.split(",")),t.hasOwnProperty("shift")&&(t.shift=fixOffset(new Function(`return ${t.shift}`)())),t.hasOwnProperty("offset")&&(t.offset=fixOffset(new Function(`return ${t.offset}`)())),t.hasOwnProperty("btns")&&(t.btns=t.btns.split(",")),t.hasOwnProperty("menubar")||(t.menubar=!1);let s=(new __layer__).__init__(o);for(let e in this.element.dataset)delete this.element.dataset[e];layerObj[s.init.$id]={obj:s,parentElem:this.element.parentNode,wrap:this.element,show:!1},layerDom[s.init.$id]=s.create()}}}),window.layer=_layer;export default _layer; \ No newline at end of file +/** + * + * @authors yutent (yutent@doui.cc) + * @date 2019-09-07 23:35:03 + * @version v2.0.1 + * + */ + +'use strict' + +import"../form/input.js";import Drag from"../drag/core.js";import{nextTick,bind,unbind,clickOutside}from"../utils.js";const LANGUAGES={en:{TITLE:"Dialog",BTNS:["Cancel","OK"]},zh:{TITLE:"提示",BTNS:["取消","确定"]}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let uniqueInstance=null,toastInstance=null;const UNIQUE_TYPES=["alert","confirm","prompt"];function renderBtns(t){var e="";return t.forEach((t,s)=>{e+=``}),e}class Layer extends HTMLElement{static get observedAttributes(){return["left","right","top","bottom","from","to","btns","type","title","blur","background","mask","mask-close","mask-color","fixed"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{left:"auto",right:"auto",top:"auto",bottom:"auto",from:Object.create(null),to:Object.create(null),btns:[],type:"",title:"",blur:!1,background:null,mask:!1,"mask-close":!1,"mask-color":null,fixed:!0},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML='
        ',this.__TITLE__=this.root.children[1].firstElementChild,this.__BODY__=this.root.children[1].children[1],this.__CTRL__=this.root.children[1].lastElementChild,this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}set title(t){this.props.title=t,t?(this.__TITLE__.firstElementChild?this.__TITLE__.insertBefore(document.createTextNode(t),this.__TITLE__.firstElementChild):this.__TITLE__.textContent=t,this.__TITLE__.style.display="flex"):this.__TITLE__.style.display=""}set type(t){var{btns:e}=this.props;if(t&&!this._handleBtnClick){switch(t){case"alert":for(;e.length>1;)e.splice(0,1);break;case"confirm":case"prompt":for(;e.length>2;)e.splice(0,1);break;case"toast":case"notify":case"frame":if("notify"===t){var s=document.createElement("wc-icon");s.setAttribute("is","close"),this.__TITLE__.appendChild(s)}e=[];break;default:t="common"}this.props.type=t,e.length?(this.__CTRL__.innerHTML=renderBtns(e),this.__CTRL__.style.display="flex"):this.__CTRL__.style.display="",this.setAttribute(t,"")}}set fixed(t){this.props.fixed=!!t,this._updateFixedStat()}_updateFixedStat(){UNIQUE_TYPES.includes(this.props.type)||(this.props.fixed?this._dragIns&&(this._dragIns.destroy(),this._dragIns=null):(this._dragIns=new Drag(this.root.children[1]).by(this.__TITLE__,{overflow:!!this.props.hasOwnProperty("overflow")&&this.props.overflow}),this.removeAttribute("fixed")))}_intercept(t){this.props.intercept?this.props.intercept(t,e=>{delete this.props.intercept,this.resolve(t),this.close()}):(this.resolve(t),this.close())}close(t){if(!1===this.wrapped)if(this._dragIns&&this._dragIns.destroy(),UNIQUE_TYPES.includes(this.props.type)&&(uniqueInstance=null),delete this.promise,unbind(this.__CTRL__,"click",this._handleBtnClick),this.props.from&&!t){let t="opacity:0;";for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;this.root.children[1].style.cssText+=t,this.timer=setTimeout(()=>{this.parentNode.removeChild(this)},200)}else clearTimeout(this.timer),this.parentNode.removeChild(this);else this.removeAttribute("common")}show(){!1!==this.wrapped&&this.setAttribute("common","")}connectedCallback(){this.type=this.props.type,this.title=this.props.title,this._handleBtnClick=bind(this.__CTRL__,"click",t=>{if("BUTTON"===t.target.tagName){var e=+t.target.dataset.idx,{type:s}=this.props;switch(s){case"alert":this.resolve(),this.close();break;case"confirm":case"prompt":if(0===e)this.reject(),this.close();else{let t="prompt"===s?this.__INPUT__.value:null;this._intercept(t)}break;default:this._intercept(e)}}}),"prompt"===this.props.type&&(this.__INPUT__=this.__BODY__.firstElementChild.assignedNodes().pop(),this._handleSubmit=bind(this.__INPUT__,"submit",t=>{this._intercept(t.detail)})),this.props.mask&&this.setAttribute("mask",""),this._updateFixedStat(),this.props.mask&&(this._handlMask=clickOutside(this.root.children[1],t=>{this.props["mask-close"]?(!1===this.wrapped&&this.reject(null),this.close()):UNIQUE_TYPES.includes(this.props.type)&&(this.root.children[1].classList.toggle("scale",!0),setTimeout(t=>{this.root.children[1].classList.remove("scale")},100))}),this.props["mask-color"]&&(this.style.backgroundColor=this.props["mask-color"])),this.props.blur&&this.root.children[1].classList.toggle("blur",!0);let t=this.props.from?"":"opacity:1;";if(this.props.background&&(t+=`background: ${this.props.background};`),(this.props.radius||0===this.props.radius)&&(t+=`border-radius: ${this.props.radius};`),this.props.size)for(let e in this.props.size)t+=`${e}:${this.props.size[e]};`;if(this.props.from){for(let e in this.props.from)t+=`${e}:${this.props.from[e]};`;setTimeout(t=>{let e="opacity:1;";for(let t in this.props.to)e+=`${t}:${this.props.to[t]};`;this.root.children[1].style.cssText+=e},50)}t&&(this.root.children[1].style.cssText+=t),"toast"===this.props.type&&(this.timer=setTimeout(()=>{toastInstance=null,this.close()},3e3)),"notify"===this.props.type&&(this._handleClose=bind(this.__TITLE__,"click",t=>{"WC-ICON"===t.target.tagName&&this.close()}))}disconnectedCallback(){unbind(document,"mousedown",this._handlMask),unbind(this.__TITLE__,"click",this._handleClose)}attributeChangedCallback(t,e,s){if(null!==s&&e!==s)switch(t){case"title":case"type":this[t]=s;break;case"mask-color":case"background":this.props[t]=s;break;case"mask":case"mask-close":case"blur":this.props[t]=!0;break;case"left":case"right":case"top":case"bottom":null!==s&&(this.props.from[t]=s,this.props.to=this.props.from,this.removeAttribute(t));break;case"fixed":this.fixed=!0}}}function _layer(t){var e=document.createElement("wc-layer");if("toast"===t.type){var{type:s,content:o}=t;t={type:s,content:o,from:{top:0},to:{top:"30px"}},toastInstance&&toastInstance.close(!0),toastInstance=e}else e.props.mask=t.mask,!1===t.btns?e.props.btns=[]:t.btns&&t.btns.length?e.props.btns=t.btns:e.props.btns=lang.BTNS.concat(),t.intercept&&"function"==typeof t.intercept&&(e.props.intercept=t.intercept),e.props.mask=t.mask,e.props["mask-close"]=t["mask-close"],t.hasOwnProperty("overflow")&&(e.props.overflow=t.overflow),e.props["mask-color"]=t["mask-color"],e.props.blur=t.blur,e.props.radius=t.radius,e.props.background=t.background,t.size&&"object"==typeof t.size&&(e.props.size=t.size),UNIQUE_TYPES.includes(t.type)&&(uniqueInstance&&uniqueInstance.close(!0),uniqueInstance=e);return t.to&&"object"==typeof t.to&&(e.props.to=t.to,t.from&&"object"==typeof t.from?e.props.from=t.from:e.props.from=t.to),e.props.type=t.type,e.props.fixed=t.fixed,e.props.title=t.title,e.innerHTML=t.content,e.wrapped=!1,document.body.appendChild(e),e.promise}Object.assign(_layer,{alert(t,e=lang.TITLE){return this({type:"alert",title:e,content:t,mask:!0})},confirm(t,e=lang.TITLE,s){return"function"==typeof e&&(s=e,e=lang.TITLE),this({type:"confirm",title:e,content:t,mask:!0,intercept:s})},prompt(t=lang.TITLE,e){return this({type:"prompt",title:t,content:'',mask:!0,intercept:e})},frame(t,e={}){return this({...e,type:"frame",content:``,mask:!0,"mask-close":!0})},notify(t){return this({type:"notify",title:"通知",content:t,blur:!0,from:{right:"-300px",top:0},to:{right:0}})},toast(t,e="info"){switch(e){case"info":case"warn":case"error":break;default:e="info"}return this({content:`\n
        \n \n ${t}\n
        `,type:"toast"})}}),window.layer=_layer;export default _layer; + +if(!customElements.get('wc-layer')){ + customElements.define('wc-layer', Layer) +} diff --git a/src/lib/layer/next.js b/src/lib/layer/next.js deleted file mode 100644 index c79deb8..0000000 --- a/src/lib/layer/next.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * - * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 - * @version v2.0.1 - * - */ - -'use strict' - -import"../form/input.js";import Drag from"../drag/core.js";import{nextTick,bind,unbind,clickOutside}from"../utils.js";const LANGUAGES={en:{TITLE:"Dialog",BTNS:["Cancel","OK"],ERROR:"The layer instance is not exists"},zh:{TITLE:"提示",BTNS:["取消","确定"],ERROR:"要关闭的layer实例不存在"}};LANGUAGES["zh-CN"]=LANGUAGES.zh;const lang=LANGUAGES[window.__ENV_LANG__||navigator.language]||LANGUAGES.en;let unique=null,defconf={type:1,background:"#fff",mask:!0,maskClose:!1,maskColor:null,radius:"0px",area:["auto","auto"],title:lang.TITLE,menubar:!0,content:"",fixed:!1,shift:{},offset:{}};const UNIQUE_TYPES=["alert","confirm","prompt"],fixOffset=function(e){for(let t in e)"auto"===e[t]||!e[t]&&0!==e[t]?delete e[t]:isFinite(e[t])&&(e[t]+="px");return e};function createLayer(e){var t=document.createElement("wc-layer");return e.mask&&t.setAttribute("mask",""),t.title=e.title,e.btns&&e.btns.length?t.props.btns=e.btns:t.props.btns=lang.BTNS.concat(),e.intercept&&"function"==typeof e.intercept&&(t.props.intercept=e.intercept),t.props.background=e.background,t.props.mask=e.mask,t.props.maskClose=e.maskClose,t.props.maskColor=e.maskColor,t.type=e.type,t.innerHTML=e.content,document.body.appendChild(t),UNIQUE_TYPES.includes(e.type)&&(unique&&unique.close(),unique=t),t.promise}const _layer={alert:(e,t=lang.TITLE)=>createLayer({type:"alert",title:t,content:e,fixed:!0,mask:!0}),confirm:(e,t=lang.TITLE,r)=>("function"==typeof t&&(r=t,t=lang.TITLE),createLayer({type:"confirm",title:t,content:e,fixed:!0,mask:!0,intercept:r})),prompt:(e=lang.TITLE,t)=>createLayer({type:"prompt",title:e,content:'',fixed:!0,mask:!0,intercept:t}),frame:(e,t={})=>createLayer({...t,type:"frame",content:``,fixed:!0,mask:!0,maskClose:!0}),toast(e,t="info",r=2500){switch("number"==typeof t&&(r=t,t="info"),t){case"info":case"warn":break;case"error":t="deny";break;default:t="info"}let i={content:`\n \n \n ${e}\n `,menubar:!1,mask:!1,type:7,shift:{top:0},timeout:r,offset:{top:50},fixed:!0,toast:!0};return _layer.open(i)},open(e){if("string"==typeof e){if(e="layerwrap-"+e,layerObj[e])return layerObj[e].show?e:(layerObj[e].show=!0,layerObj[e].parentElem.appendChild(layerDom[e][0]),layerDom[e][0].querySelector(".layer-content").appendChild(layerObj[e].wrap),layerObj[e].wrap.style.display="",Anot.vmodels[e]||Anot(layerObj[e].obj.init),layerObj[e].obj.show(),e);throw new Error(lang.ERROR)}return new __layer__(e).init.$id}};function renderBtns(e){var t="";return e.forEach((e,r)=>{t+=``}),t}class Layer extends HTMLElement{static get observedAttributes(){return["btns","type","title","fixed"]}constructor(){super(),Object.defineProperty(this,"root",{value:this.attachShadow({mode:"open"}),writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(this,"props",{value:{btns:[],type:"msg",title:"",fixed:!1},writable:!0,enumerable:!1,configurable:!0}),this.root.innerHTML="
        ",this.__TITLE__=this.root.children[1].firstElementChild,this.__BODY__=this.root.children[1].children[1],this.__CTRL__=this.root.children[1].lastElementChild,this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}set title(e){e?(this.__TITLE__.textContent=e,this.__TITLE__.style.display=""):this.__TITLE__.style.display="none"}set type(e){var{btns:t}=this.props;switch(e){case"alert":for(;t.length>1;)t.splice(0,1);break;case"confirm":case"prompt":for(;t.length>2;)t.splice(0,1);break;case"toast":case"frame":t=[];break;default:e="common"}this.props.type=e,t.length?(this.__CTRL__.innerHTML=renderBtns(t),this.__CTRL__.style.display=""):this.__CTRL__.style.display="none",this.setAttribute("type",e)}set fixed(e){this.props.fixed=!!e,UNIQUE_TYPES.includes(this.props.type)||(this.props.fixed?this._dragIns&&(this._dragIns.destroy(),this._dragIns=null):(this._dragIns=new Drag(this.root.children[1]).by(this.__TITLE__,{overflow:!1}),this.removeAttribute("fixed")))}_intercept(e){this.props.intercept?this.props.intercept(e,t=>{delete this.props.intercept,this.resolve(e),this.close()}):(this.resolve(e),this.close())}close(){this._dragIns&&this._dragIns.destroy(),UNIQUE_TYPES.includes(this.props.type)&&(unique=null),delete this.promise,unbind(this.__CTRL__,"click",this._handleBtnClick),this.parentNode.removeChild(this)}connectedCallback(){this._handleBtnClick=bind(this.__CTRL__,"click",e=>{if("BUTTON"===e.target.tagName){var t=+e.target.dataset.idx,{intercept:r,type:i}=this.props;switch(i){case"alert":this.resolve(),this.close();break;case"confirm":case"prompt":if(0===t)this.reject(),this.close();else{let e="prompt"===i?this.__INPUT__.value:null;this._intercept(e)}break;default:this.resolve(t),this.close()}}}),"prompt"===this.props.type&&(this.__INPUT__=this.__BODY__.firstElementChild.assignedNodes().pop(),this._handleSubmit=bind(this.__INPUT__,"submit",e=>{this._intercept(e.detail)})),this.props.mask&&(this._handlMask=clickOutside(this.root.children[1],e=>{this.props.maskClose?this.close():UNIQUE_TYPES.includes(this.props.type)&&(this.root.children[1].classList.toggle("scale",!0),setTimeout(e=>{this.root.children[1].classList.remove("scale")},100))}))}disconnectedCallback(){unbind(document,"mousedown",this._handlMask)}attributeChangedCallback(e,t,r){if(t!==r)switch(e){case"title":case"type":this[e]=r;break;case"fixed":this.fixed=!0}}}window.layer=_layer;export default _layer; - -if(!customElements.get('wc-layer')){ - customElements.define('wc-layer', Layer) -} diff --git a/src/lib/scroll/index.js b/src/lib/scroll/index.js index f21254e..73ceeda 100644 --- a/src/lib/scroll/index.js +++ b/src/lib/scroll/index.js @@ -1,7 +1,7 @@ /** * * @authors yutent (yutent@doui.cc) - * @date 2019-09-01 23:16:06 + * @date 2019-09-07 23:35:03 * @version v2.0.1 * */ From d1dcba771185809fad233bbd3a3748cbdaaa86a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 8 Sep 2019 23:54:49 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8D=87=E7=BA=A7electron=E5=88=B06.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 ++++++-- src/js/app.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cddfd9f..fcc0a80 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "iofs": "^1.1.0" }, "devDependencies": { - "electron": "^4.0.2", + "electron": "^6.0.0", "electron-builder": "^20.38.5" }, "build": { @@ -29,7 +29,11 @@ "buildResources": "icons", "output": "build" }, - "files": ["src/**/*", "node_modules/iofs/*", "node_modules/crypto.js/*"], + "files": [ + "src/**/*", + "node_modules/iofs/*", + "node_modules/crypto.js/*" + ], "mac": { "category": "public.app-category.music", "target": "dmg", diff --git a/src/js/app.js b/src/js/app.js index 7df4261..3b30985 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -5,7 +5,7 @@ */ import '/lib/anot.js' -import '/lib/layer/next.js' +import '/lib/layer/index.js' import '/lib/store/index.js' import AudioPlayer from '/lib/audio/index.js' import Lyrics from '/lib/lyrics/index.js' From b72a8d4780961a12fd5f2141e225c1031406601a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 9 Sep 2019 00:56:32 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B06.x=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/app.js | 7 +++---- src/main.js | 4 +++- src/tools/windows.js | 19 +++++++++++++------ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/js/app.js b/src/js/app.js index 3b30985..c28372c 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -25,15 +25,14 @@ const log = console.log const fs = require('iofs') const path = require('path') -const { remote, ipcRenderer, screen } = require('electron') +const { remote, ipcRenderer } = require('electron') const { createDesktopLrcWindow, createMiniWindow } = remote.require( './tools/windows' ) -const MAIN_SCREEN = screen.getPrimaryDisplay() const WIN = remote.getCurrentWindow() -const __LRC__ = createDesktopLrcWindow(MAIN_SCREEN) -const __MINI__ = createMiniWindow(MAIN_SCREEN) +const __LRC__ = createDesktopLrcWindow(screen) +const __MINI__ = createMiniWindow(screen) const PLAY_MODE = { 0: 'all', diff --git a/src/main.js b/src/main.js index 6c94640..83e4daf 100644 --- a/src/main.js +++ b/src/main.js @@ -41,7 +41,9 @@ const ROOT = __dirname app.commandLine.appendSwitch('--lang', 'zh-CN') app.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required') -protocol.registerStandardSchemes(['app'], { secure: true }) +protocol.registerSchemesAsPrivileged([ + { scheme: 'app', privileges: { secure: true, standard: true } } +]) /* ----------------------------------------------------- */ diff --git a/src/tools/windows.js b/src/tools/windows.js index bac8561..7c017d5 100644 --- a/src/tools/windows.js +++ b/src/tools/windows.js @@ -22,7 +22,8 @@ exports.createMainWindow = function(icon) { icon, webPreferences: { webSecurity: false, - experimentalFeatures: true + experimentalFeatures: true, + nodeIntegration: true }, show: false }) @@ -74,12 +75,15 @@ exports.createDesktopLrcWindow = function(screen) { resizable: false, alwaysOnTop: true, skipTaskbar: true, - x: (screen.size.width - 1024) / 2, - y: screen.size.height - 100, + x: (screen.width - 1024) / 2, + y: screen.height - 100, transparent: true, hasShadow: false, thickFrame: false, - show: false + show: false, + webPreferences: { + nodeIntegration: true + } }) win.loadURL('app://local/desktop-lrc.html') @@ -98,10 +102,13 @@ exports.createMiniWindow = function(screen) { resizable: false, alwaysOnTop: true, skipTaskbar: true, - x: screen.size.width - 320, + x: screen.width - 320, y: 0, thickFrame: false, - show: false + show: false, + webPreferences: { + nodeIntegration: true + } }) win.loadURL('app://local/mini-win.html')