修复各项bug及优化组件结构
parent
e5aee134f3
commit
aca7d5f8ce
|
@ -29,7 +29,7 @@ define(['yua'], function(){
|
||||||
|
|
||||||
//取得拖动的3种状态回调
|
//取得拖动的3种状态回调
|
||||||
//按下,且拖拽之前
|
//按下,且拖拽之前
|
||||||
binding. beforedrag = getBindingCallback(binding.element, 'data-beforedrag', binding.vmodels)
|
binding.beforedrag = getBindingCallback(binding.element, 'data-beforedrag', binding.vmodels)
|
||||||
//拖拽过程
|
//拖拽过程
|
||||||
binding.dragging = getBindingCallback(binding.element, 'data-dragging', binding.vmodels)
|
binding.dragging = getBindingCallback(binding.element, 'data-dragging', binding.vmodels)
|
||||||
// 拖拽结束,且释放鼠标
|
// 拖拽结束,且释放鼠标
|
||||||
|
|
|
@ -810,7 +810,7 @@ Renderer.prototype.code = function(code, lang, escaped) {
|
||||||
// + '</section>'
|
// + '</section>'
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<pre class="do-ui-blockcode">'
|
return '<pre :skip class="do-ui-blockcode">'
|
||||||
+ output
|
+ output
|
||||||
+ '</pre>';
|
+ '</pre>';
|
||||||
};
|
};
|
||||||
|
@ -888,7 +888,7 @@ Renderer.prototype.em = function(text) {
|
||||||
|
|
||||||
Renderer.prototype.codespan = function(txt) {
|
Renderer.prototype.codespan = function(txt) {
|
||||||
txt = txt.replace(/&/g, '&')
|
txt = txt.replace(/&/g, '&')
|
||||||
return '<code class="do-ui-inlinecode">' + txt + '</code>';
|
return '<code :skip class="do-ui-inlinecode">' + txt + '</code>';
|
||||||
};
|
};
|
||||||
|
|
||||||
Renderer.prototype.br = function() {
|
Renderer.prototype.br = function() {
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @authors yutent (yutent@doui.cc)
|
||||||
|
* @date 2017-08-02 21:50:34
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
define(['css!./highlight'], function() {
|
define(['css!./highlight'], function() {
|
||||||
|
|
||||||
var _self = window;
|
var _self = window;
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,11 @@
|
||||||
define(['./core', 'css!./highlight'], function(Prism) {
|
/**
|
||||||
|
*
|
||||||
|
* @authors yutent (yutent@doui.cc)
|
||||||
|
* @date 2017-08-02 21:50:34
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
define(['./base', 'css!./highlight'], function(Prism) {
|
||||||
|
|
||||||
Prism.languages.actionscript = Prism.languages.extend('javascript', {
|
Prism.languages.actionscript = Prism.languages.extend('javascript', {
|
||||||
'keyword': /\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,
|
'keyword': /\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,
|
|
@ -1,32 +0,0 @@
|
||||||
@charset "UTF-8";
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @authors yutent (yutent@doui.cc)
|
|
||||||
* @date 2017-02-13 13:53:38
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*代码块*/
|
|
||||||
.do-ui-blockcode {position:relative;border:1px solid #ddd;margin:15px 0;}
|
|
||||||
.do-ui-blockcode::before {position:relative;display:block;width:100%;height:25px;padding:0 8px;background:#eee;border-bottom:1px solid #ddd;line-height:25px;content:"代码示例";box-sizing: border-box;}
|
|
||||||
.do-ui-blockcode section {position:relative;}
|
|
||||||
.do-ui-blockcode .linenum {display:block;position:absolute;z-index:1;left:0;top:0;width:40px;height:100%;background:#eee;border-right:1px solid #ddd;text-align:center;}
|
|
||||||
|
|
||||||
/*语法高亮*/
|
|
||||||
.do-ui-blockcode .lang {position:relative;display:block;overflow-x:auto;z-index:0;padding:0 8px 0 50px;color:#383a42;background:#fafafa;word-wrap:break-word;white-space:pre-wrap;}
|
|
||||||
.do-ui-blockcode .lang .c-comment{color: #8e908c;font-style:italic;}
|
|
||||||
.do-ui-blockcode .lang .c-smartyx {color: #607d8b;}
|
|
||||||
.do-ui-blockcode .lang .c-important {color: #f5871f;font-style:italic;}
|
|
||||||
.do-ui-blockcode .lang .c-punctuation {color: #986756;}
|
|
||||||
.do-ui-blockcode .lang .c-regex {color: #c82829;}
|
|
||||||
.do-ui-blockcode .lang .c-boolean,.do-ui-blockcode .lang .c-number {color: #f5871f;}
|
|
||||||
.do-ui-blockcode .lang .c-function {color:#009688;}
|
|
||||||
.do-ui-blockcode .lang .c-class-name,.do-ui-blockcode .lang .c-build-in {color:#3aa9f3;}
|
|
||||||
.do-ui-blockcode .lang .c-class-name,.do-ui-blockcode .lang .c-build-in {font-style:italic;font-weight:bold;}
|
|
||||||
.do-ui-blockcode .lang .c-attr-name {color: #eab700;}
|
|
||||||
.do-ui-blockcode .lang .c-string,.do-ui-blockcode .lang .c-attr-value {color: #5ab302;}
|
|
||||||
.do-ui-blockcode .lang .c-tag,.do-ui-blockcode .lang .c-keyword,.do-ui-blockcode .lang .c-operator {color: #d81406;}
|
|
||||||
.do-ui-blockcode .lang .c-keyword {font-style:italic;}
|
|
||||||
|
|
||||||
/*行内代码*/
|
|
||||||
.do-ui-inlinecode {margin:0 2px;padding:0 5px;color:#d14;border:1px solid #ddd;border-radius:3px;}
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
@charset "UTF-8";
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @authors yutent (yutent@doui.cc)
|
||||||
|
* @date 2017-02-13 13:53:38
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*代码块*/
|
||||||
|
.do-ui-blockcode {position: relative;border: 1px solid #ddd;margin: 15px 0;padding: 8px 0;line-height: 1.5;background: #fafafa;
|
||||||
|
|
||||||
|
|
||||||
|
/*语法高亮*/
|
||||||
|
.lang {position: relative;display: block;padding: 0 8px;color: #383a42;word-wrap: break-word;white-space: pre-wrap;font-family: Courier;
|
||||||
|
|
||||||
|
.c-comment{color: #8e908c;font-style:italic;}
|
||||||
|
.c-smartyx {color: #607d8b;}
|
||||||
|
.c-important {color: #f5871f;font-style:italic;}
|
||||||
|
.c-punctuation {color: #986756;}
|
||||||
|
.c-regex {color: #c82829;}
|
||||||
|
|
||||||
|
.c-boolean,
|
||||||
|
.c-number {color: #f5871f;}
|
||||||
|
.c-function {color:#009688;}
|
||||||
|
|
||||||
|
.c-class-name,
|
||||||
|
.c-build-in {color:#3aa9f3;}
|
||||||
|
|
||||||
|
.c-class-name,
|
||||||
|
.c-build-in {font-style:italic;font-weight:bold;}
|
||||||
|
|
||||||
|
.c-attr-name,
|
||||||
|
.c-property {color: #c79f0f;font-weight:bold;}
|
||||||
|
|
||||||
|
.c-property {font-style:italic;}
|
||||||
|
|
||||||
|
.c-string,
|
||||||
|
.c-attr-value {color: #5ab302;}
|
||||||
|
|
||||||
|
.c-tag,
|
||||||
|
.c-keyword,
|
||||||
|
.c-selector,
|
||||||
|
.c-operator {color: #d81406;}
|
||||||
|
|
||||||
|
.c-keyword {font-style:italic;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*行内代码*/
|
||||||
|
.do-ui-inlinecode {margin:0 2px;padding:0 5px;color:#d14;border:1px solid #ddd;border-radius:3px;}
|
|
@ -0,0 +1 @@
|
||||||
|
define(["yua"],function(){function t(){this.table={get:[]},this.errorFn=null,this.history=null,this.hash="",this.started=!1,this.init={}}function e(t){return!t||t===window.name||"_self"===t||"top"===t&&window==window.top}var r={prefix:/^(#!|#)[\/]?/,historyOpen:!0,allowReload:!0},i=!0,a=/(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g;return t.prototype={error:function(t){this.errorFn=t},config:function(t){if(this.started)return console.error("Router config has been set");this.started=!0,t.allowReload||(t.historyOpen=!0),this.init=yua.mix({},r,t)},_getRegExp:function(t,e){var r=t.replace(a,function(t,e,r,i,a){var n="([\\w.-]";return e||r?n+"+)":(/^\{[\d\,]+\}$/.test(a)||(n="("),n+a+")")});return r=r.replace(/(([^\\])([\/]+))/g,"$2\\/").replace(/(([^\\])([\.]+))/g,"$2\\.").replace(/(([^\\])([\-]+))/g,"$2\\-").replace(/(\(.*)(\\[\-]+)(.*\))/g,"$1-$3"),r="^"+r+"$",e.regexp=new RegExp(r),e},_add:function(t,e,r){this.started||this.config({});var i=this.table[t.toLowerCase()];if("/"===e.charAt(0)){e=e.replace(/^[\/]+|[\/]+$|\s+/g,"");var a={};a.rule=e,a.callback=r,yua.Array.ensure(i,this._getRegExp(e,a))}else console.error('char "/" must be in front of router rule')},_route:function(t,e){var e=e.trim(),r=this.table[t],i=this.init;if(i.allowReload||e!==this.history){i.historyOpen&&(this.history=e,yua.ls&&yua.ls("lastHash",e));for(var a,n=0;a=r[n++];){var o=e.match(a.regexp);if(o)return o.shift(),a.callback.apply(a,o)}this.errorFn&&this.errorFn(e)}},on:function(t,e){var r=this;Array.isArray(t)?t.forEach(function(t){r._add("get",t,e)}):this._add("get",t,e)}},yua.bind(window,"load",function(){if(yua.router.started){var t=yua.router.init.prefix,e=location.hash;e=e.replace(t,"").trim(),yua.router._route("get",e)}}),"onhashchange"in window&&window.addEventListener("hashchange",function(t){if(i){var e=yua.router.init.prefix,r=location.hash.replace(e,"").trim();yua.router._route("get",r)}}),yua.bind(document,"mousedown",function(t){if(!(("defaultPrevented"in t?t.defaultPrevented:!1===t.returnValue)||t.ctrlKey||t.metaKey||2===t.which)){for(var r=t.target;"A"!==r.nodeName;)if(!(r=r.parentNode)||"BODY"===r.tagName)return;if(e(r.target)){if(!yua.router.started)return;var a=r.getAttribute("href")||r.getAttribute("xlink:href"),n=yua.router.init.prefix;if(null===a||!n.test(a))return;yua.router.hash=a.replace(n,"").trim(),t.preventDefault(),location.hash=a,i=!1}}}),yua.bind(document,"mouseup",function(){i||(yua.router._route("get",yua.router.hash),i=!0)}),yua.ui.router="0.0.1",yua.router=new t});
|
|
@ -10,7 +10,7 @@
|
||||||
define(['yua', 'css!./skin/def.css'], function(){
|
define(['yua', 'css!./skin/def.css'], function(){
|
||||||
|
|
||||||
//储存版本信息
|
//储存版本信息
|
||||||
yua.ui.tree = '0.0.1'
|
yua.ui.tree = '0.0.2'
|
||||||
|
|
||||||
var box = '<ul>{li}</ul>',
|
var box = '<ul>{li}</ul>',
|
||||||
ul = '<ul :class="{open: {it}.open}">{li}</ul>',
|
ul = '<ul :class="{open: {it}.open}">{li}</ul>',
|
||||||
|
@ -18,6 +18,7 @@ define(['yua', 'css!./skin/def.css'], function(){
|
||||||
+ '<em :click="$toggle({it})"></em>'
|
+ '<em :click="$toggle({it})"></em>'
|
||||||
+ '<span :click="$select({it})" :class="{active: {it}.id === currItem}" :text="{it}.name"></span>'
|
+ '<span :click="$select({it})" :class="{active: {it}.id === currItem}" :text="{it}.name"></span>'
|
||||||
+ '{child}</li>';
|
+ '{child}</li>';
|
||||||
|
var keyPath = {};
|
||||||
|
|
||||||
|
|
||||||
function repeat(arr, name){
|
function repeat(arr, name){
|
||||||
|
@ -44,17 +45,17 @@ define(['yua', 'css!./skin/def.css'], function(){
|
||||||
})
|
})
|
||||||
arr.forEach(function(it){
|
arr.forEach(function(it){
|
||||||
tmp[it.id] = it
|
tmp[it.id] = it
|
||||||
|
keyPath[it.id] = ''
|
||||||
var parentItem = tmp[it.pid]
|
var parentItem = tmp[it.pid]
|
||||||
delete it.pid
|
|
||||||
|
|
||||||
if(!parentItem){
|
if(!parentItem){
|
||||||
return farr.push(tmp[it.id])
|
return farr.push(tmp[it.id])
|
||||||
}
|
}
|
||||||
|
keyPath[it.id] += keyPath[parentItem.id] + parentItem.id + ','
|
||||||
parentItem.open = !!parentItem.open
|
parentItem.open = !!parentItem.open
|
||||||
parentItem.children = parentItem.children || []
|
parentItem.children = parentItem.children || []
|
||||||
parentItem.children.push(it)
|
parentItem.children.push(it)
|
||||||
})
|
})
|
||||||
tmp = arr = null
|
|
||||||
return farr
|
return farr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,12 +68,44 @@ define(['yua', 'css!./skin/def.css'], function(){
|
||||||
vm.$onClick(obj)
|
vm.$onClick(obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vm.$update = function(arr){
|
vm.$reset = function(arr){
|
||||||
vm.treeArr.clear()
|
vm.treeArr.clear()
|
||||||
|
vm.treeHTML = ''
|
||||||
|
|
||||||
vm.treeArr.pushArray(format(arr))
|
vm.treeArr.pushArray(format(arr))
|
||||||
vm.currItem = -1
|
vm.currItem = -1
|
||||||
var tpl = repeat(vm.treeArr.$model, 'treeArr')
|
var tpl = repeat(vm.treeArr.$model, 'treeArr')
|
||||||
vm.treeHTML = box.replace('{li}', tpl)
|
yua.nextTick(function(){
|
||||||
|
vm.treeHTML = box.replace('{li}', tpl)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
vm.$update = function(id, obj){
|
||||||
|
var path = keyPath[id],
|
||||||
|
tmpid = null,
|
||||||
|
tmpobj = null
|
||||||
|
|
||||||
|
path += id
|
||||||
|
path = path.split(',')
|
||||||
|
|
||||||
|
while(tmpid = +path.shift()){
|
||||||
|
if(!tmpobj){
|
||||||
|
tmpobj = vm.treeArr
|
||||||
|
}else{
|
||||||
|
tmpobj = tmpobj.children
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i = 0, it; it = tmpobj[i++];){
|
||||||
|
if(it.id === tmpid){
|
||||||
|
tmpobj = it
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(var j in obj){
|
||||||
|
tmpobj[j] = obj[j]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
$ready: function(vm){
|
$ready: function(vm){
|
||||||
|
@ -84,6 +117,7 @@ define(['yua', 'css!./skin/def.css'], function(){
|
||||||
treeArr: [],
|
treeArr: [],
|
||||||
$select: yua.noop,
|
$select: yua.noop,
|
||||||
$update: yua.noop,
|
$update: yua.noop,
|
||||||
|
$reset: yua.noop,
|
||||||
$onSuccess: yua.noop,
|
$onSuccess: yua.noop,
|
||||||
$onClick: yua.noop,
|
$onClick: yua.noop,
|
||||||
$toggle: function(obj){
|
$toggle: function(obj){
|
||||||
|
|
|
@ -160,10 +160,6 @@ yua.type = function (obj) { //取得目标的类型
|
||||||
typeof obj
|
typeof obj
|
||||||
}
|
}
|
||||||
|
|
||||||
yua.isFunction = function (fn) {
|
|
||||||
return serialize.call(fn) === "[object Function]"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/
|
/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/
|
||||||
yua.isPlainObject = function (obj) {
|
yua.isPlainObject = function (obj) {
|
||||||
|
@ -208,7 +204,7 @@ yua.mix = yua.fn.mix = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
//确保接受方为一个复杂的数据类型
|
//确保接受方为一个复杂的数据类型
|
||||||
if (typeof target !== "object" && !yua.isFunction(target)) {
|
if (typeof target !== "object" && yua.type(target) !== 'function') {
|
||||||
target = {}
|
target = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +441,7 @@ if(!Date.prototype.format){
|
||||||
{
|
{
|
||||||
value: function(str){
|
value: function(str){
|
||||||
str = str || 'Y-m-d H:i:s'
|
str = str || 'Y-m-d H:i:s'
|
||||||
var week = ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'],
|
var week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||||
dt = {
|
dt = {
|
||||||
'fullyear': this.getFullYear(),
|
'fullyear': this.getFullYear(),
|
||||||
'year': this.getYear(),
|
'year': this.getYear(),
|
||||||
|
@ -3051,7 +3047,7 @@ function scanAttr(elem, vmodels, match) {
|
||||||
uuid: "_" + (++bindingID),
|
uuid: "_" + (++bindingID),
|
||||||
priority: (directives[type].priority || type.charCodeAt(0) * 10) + (Number(param.replace(/\D/g, "")) || 0)
|
priority: (directives[type].priority || type.charCodeAt(0) * 10) + (Number(param.replace(/\D/g, "")) || 0)
|
||||||
}
|
}
|
||||||
if (type === "html" || type === "text") {
|
if (type === "html" || type === "text" || type === "attr") {
|
||||||
|
|
||||||
var filters = getToken(value).filters
|
var filters = getToken(value).filters
|
||||||
binding.expr = binding.expr.replace(filters, "")
|
binding.expr = binding.expr.replace(filters, "")
|
||||||
|
@ -3661,9 +3657,10 @@ var attrDir = yua.directive("attr", {
|
||||||
//类名定义, :class="xx:yy" :class="{xx: yy}" :class="xx" :class="{{xx}}"
|
//类名定义, :class="xx:yy" :class="{xx: yy}" :class="xx" :class="{{xx}}"
|
||||||
yua.directive("class", {
|
yua.directive("class", {
|
||||||
init: function (binding) {
|
init: function (binding) {
|
||||||
|
var expr = [];
|
||||||
if(!/^\{.*\}$/.test(binding.expr)){
|
if(!/^\{.*\}$/.test(binding.expr)){
|
||||||
|
|
||||||
var expr = binding.expr.split(':')
|
expr = binding.expr.split(':')
|
||||||
expr[1] = expr[1] && expr[1].trim() || 'true'
|
expr[1] = expr[1] && expr[1].trim() || 'true'
|
||||||
var arr = expr[0].split(/\s+/)
|
var arr = expr[0].split(/\s+/)
|
||||||
binding.expr = '{' + arr.map(function(it){
|
binding.expr = '{' + arr.map(function(it){
|
||||||
|
@ -3686,16 +3683,16 @@ yua.directive("class", {
|
||||||
activate = "mousedown"
|
activate = "mousedown"
|
||||||
abandon = "mouseup"
|
abandon = "mouseup"
|
||||||
var fn0 = $elem.bind("mouseleave", function () {
|
var fn0 = $elem.bind("mouseleave", function () {
|
||||||
binding.toggleClass && $elem.removeClass(binding.newClass)
|
$elem.removeClass(expr[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fn1 = $elem.bind(activate, function () {
|
var fn1 = $elem.bind(activate, function () {
|
||||||
binding.toggleClass && $elem.addClass(binding.newClass)
|
$elem.addClass(expr[0])
|
||||||
})
|
})
|
||||||
var fn2 = $elem.bind(abandon, function () {
|
var fn2 = $elem.bind(abandon, function () {
|
||||||
binding.toggleClass && $elem.removeClass(binding.newClass)
|
$elem.removeClass(expr[0])
|
||||||
})
|
})
|
||||||
binding.rollback = function () {
|
binding.rollback = function () {
|
||||||
$elem.unbind("mouseleave", fn0)
|
$elem.unbind("mouseleave", fn0)
|
||||||
|
@ -3707,6 +3704,9 @@ yua.directive("class", {
|
||||||
|
|
||||||
},
|
},
|
||||||
update: function (val) {
|
update: function (val) {
|
||||||
|
if(this.type !== 'class'){
|
||||||
|
return
|
||||||
|
}
|
||||||
var obj = val
|
var obj = val
|
||||||
if(!obj || this.param)
|
if(!obj || this.param)
|
||||||
return log('class指令语法错误 %c %s="%s"', 'color:#f00', this.name, this.expr)
|
return log('class指令语法错误 %c %s="%s"', 'color:#f00', this.name, this.expr)
|
||||||
|
@ -4993,8 +4993,8 @@ yua.directive("repeat", {
|
||||||
elem.removeAttribute(binding.name)
|
elem.removeAttribute(binding.name)
|
||||||
effectBinding(elem, binding)
|
effectBinding(elem, binding)
|
||||||
binding.param = binding.param || "el"
|
binding.param = binding.param || "el"
|
||||||
binding.sortedCallback = getBindingCallback(elem, "data-with-sorted", binding.vmodels)
|
binding.sortedCallback = getBindingCallback(elem, "data-repeat-sortby", binding.vmodels)
|
||||||
var rendered = getBindingCallback(elem, "data-" + type + "-rendered", binding.vmodels)
|
var rendered = getBindingCallback(elem, "data-repeat-rendered", binding.vmodels)
|
||||||
|
|
||||||
var signature = generateID(type)
|
var signature = generateID(type)
|
||||||
var start = DOC.createComment(signature + ":start")
|
var start = DOC.createComment(signature + ":start")
|
||||||
|
@ -5002,19 +5002,12 @@ yua.directive("repeat", {
|
||||||
binding.signature = signature
|
binding.signature = signature
|
||||||
binding.start = start
|
binding.start = start
|
||||||
binding.template = yuaFragment.cloneNode(false)
|
binding.template = yuaFragment.cloneNode(false)
|
||||||
if (type === "repeat") {
|
|
||||||
var parent = elem.parentNode
|
var parent = elem.parentNode
|
||||||
parent.replaceChild(end, elem)
|
parent.replaceChild(end, elem)
|
||||||
parent.insertBefore(start, end)
|
parent.insertBefore(start, end)
|
||||||
binding.template.appendChild(elem)
|
binding.template.appendChild(elem)
|
||||||
} else {
|
|
||||||
while (elem.firstChild) {
|
|
||||||
binding.template.appendChild(elem.firstChild)
|
|
||||||
}
|
|
||||||
elem.appendChild(start)
|
|
||||||
elem.appendChild(end)
|
|
||||||
parent = elem
|
|
||||||
}
|
|
||||||
binding.element = end
|
binding.element = end
|
||||||
|
|
||||||
if (rendered) {
|
if (rendered) {
|
||||||
|
|
45
js/yua.js
45
js/yua.js
|
@ -160,10 +160,6 @@ yua.type = function (obj) { //取得目标的类型
|
||||||
typeof obj
|
typeof obj
|
||||||
}
|
}
|
||||||
|
|
||||||
yua.isFunction = function (fn) {
|
|
||||||
return serialize.call(fn) === "[object Function]"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/
|
/*判定是否是一个朴素的javascript对象(Object),不是DOM对象,不是BOM对象,不是自定义类的实例*/
|
||||||
yua.isPlainObject = function (obj) {
|
yua.isPlainObject = function (obj) {
|
||||||
|
@ -207,7 +203,7 @@ yua.mix = yua.fn.mix = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
//确保接受方为一个复杂的数据类型
|
//确保接受方为一个复杂的数据类型
|
||||||
if (typeof target !== "object" && !yua.isFunction(target)) {
|
if (typeof target !== "object" && yua.type(target) !== 'function') {
|
||||||
target = {}
|
target = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +440,7 @@ if(!Date.prototype.format){
|
||||||
{
|
{
|
||||||
value: function(str){
|
value: function(str){
|
||||||
str = str || 'Y-m-d H:i:s'
|
str = str || 'Y-m-d H:i:s'
|
||||||
var week = ['Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'],
|
var week = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||||
dt = {
|
dt = {
|
||||||
'fullyear': this.getFullYear(),
|
'fullyear': this.getFullYear(),
|
||||||
'year': this.getYear(),
|
'year': this.getYear(),
|
||||||
|
@ -3050,7 +3046,7 @@ function scanAttr(elem, vmodels, match) {
|
||||||
uuid: "_" + (++bindingID),
|
uuid: "_" + (++bindingID),
|
||||||
priority: (directives[type].priority || type.charCodeAt(0) * 10) + (Number(param.replace(/\D/g, "")) || 0)
|
priority: (directives[type].priority || type.charCodeAt(0) * 10) + (Number(param.replace(/\D/g, "")) || 0)
|
||||||
}
|
}
|
||||||
if (type === "html" || type === "text") {
|
if (type === "html" || type === "text" || type === "attr") {
|
||||||
|
|
||||||
var filters = getToken(value).filters
|
var filters = getToken(value).filters
|
||||||
binding.expr = binding.expr.replace(filters, "")
|
binding.expr = binding.expr.replace(filters, "")
|
||||||
|
@ -3665,9 +3661,10 @@ var attrDir = yua.directive("attr", {
|
||||||
//类名定义, :class="xx:yy" :class="{xx: yy}" :class="xx" :class="{{xx}}"
|
//类名定义, :class="xx:yy" :class="{xx: yy}" :class="xx" :class="{{xx}}"
|
||||||
yua.directive("class", {
|
yua.directive("class", {
|
||||||
init: function (binding) {
|
init: function (binding) {
|
||||||
|
var expr = [];
|
||||||
if(!/^\{.*\}$/.test(binding.expr)){
|
if(!/^\{.*\}$/.test(binding.expr)){
|
||||||
|
|
||||||
var expr = binding.expr.split(':')
|
expr = binding.expr.split(':')
|
||||||
expr[1] = expr[1] && expr[1].trim() || 'true'
|
expr[1] = expr[1] && expr[1].trim() || 'true'
|
||||||
var arr = expr[0].split(/\s+/)
|
var arr = expr[0].split(/\s+/)
|
||||||
binding.expr = '{' + arr.map(function(it){
|
binding.expr = '{' + arr.map(function(it){
|
||||||
|
@ -3690,16 +3687,16 @@ yua.directive("class", {
|
||||||
activate = "mousedown"
|
activate = "mousedown"
|
||||||
abandon = "mouseup"
|
abandon = "mouseup"
|
||||||
var fn0 = $elem.bind("mouseleave", function () {
|
var fn0 = $elem.bind("mouseleave", function () {
|
||||||
binding.toggleClass && $elem.removeClass(binding.newClass)
|
$elem.removeClass(expr[0])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fn1 = $elem.bind(activate, function () {
|
var fn1 = $elem.bind(activate, function () {
|
||||||
binding.toggleClass && $elem.addClass(binding.newClass)
|
$elem.addClass(expr[0])
|
||||||
})
|
})
|
||||||
var fn2 = $elem.bind(abandon, function () {
|
var fn2 = $elem.bind(abandon, function () {
|
||||||
binding.toggleClass && $elem.removeClass(binding.newClass)
|
$elem.removeClass(expr[0])
|
||||||
})
|
})
|
||||||
binding.rollback = function () {
|
binding.rollback = function () {
|
||||||
$elem.unbind("mouseleave", fn0)
|
$elem.unbind("mouseleave", fn0)
|
||||||
|
@ -3711,6 +3708,9 @@ yua.directive("class", {
|
||||||
|
|
||||||
},
|
},
|
||||||
update: function (val) {
|
update: function (val) {
|
||||||
|
if(this.type !== 'class'){
|
||||||
|
return
|
||||||
|
}
|
||||||
var obj = val
|
var obj = val
|
||||||
if(!obj || this.param)
|
if(!obj || this.param)
|
||||||
return log('class指令语法错误 %c %s="%s"', 'color:#f00', this.name, this.expr)
|
return log('class指令语法错误 %c %s="%s"', 'color:#f00', this.name, this.expr)
|
||||||
|
@ -4997,8 +4997,8 @@ yua.directive("repeat", {
|
||||||
elem.removeAttribute(binding.name)
|
elem.removeAttribute(binding.name)
|
||||||
effectBinding(elem, binding)
|
effectBinding(elem, binding)
|
||||||
binding.param = binding.param || "el"
|
binding.param = binding.param || "el"
|
||||||
binding.sortedCallback = getBindingCallback(elem, "data-with-sorted", binding.vmodels)
|
binding.sortedCallback = getBindingCallback(elem, "data-repeat-sortby", binding.vmodels)
|
||||||
var rendered = getBindingCallback(elem, "data-" + type + "-rendered", binding.vmodels)
|
var rendered = getBindingCallback(elem, "data-repeat-rendered", binding.vmodels)
|
||||||
|
|
||||||
var signature = generateID(type)
|
var signature = generateID(type)
|
||||||
var start = DOC.createComment(signature + ":start")
|
var start = DOC.createComment(signature + ":start")
|
||||||
|
@ -5006,19 +5006,12 @@ yua.directive("repeat", {
|
||||||
binding.signature = signature
|
binding.signature = signature
|
||||||
binding.start = start
|
binding.start = start
|
||||||
binding.template = yuaFragment.cloneNode(false)
|
binding.template = yuaFragment.cloneNode(false)
|
||||||
if (type === "repeat") {
|
|
||||||
var parent = elem.parentNode
|
var parent = elem.parentNode
|
||||||
parent.replaceChild(end, elem)
|
parent.replaceChild(end, elem)
|
||||||
parent.insertBefore(start, end)
|
parent.insertBefore(start, end)
|
||||||
binding.template.appendChild(elem)
|
binding.template.appendChild(elem)
|
||||||
} else {
|
|
||||||
while (elem.firstChild) {
|
|
||||||
binding.template.appendChild(elem.firstChild)
|
|
||||||
}
|
|
||||||
elem.appendChild(start)
|
|
||||||
elem.appendChild(end)
|
|
||||||
parent = elem
|
|
||||||
}
|
|
||||||
binding.element = end
|
binding.element = end
|
||||||
|
|
||||||
if (rendered) {
|
if (rendered) {
|
||||||
|
|
Reference in New Issue