Skip to content

Commit

Permalink
update avalon
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Sep 9, 2014
1 parent 031e41b commit ae319c8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 87 deletions.
22 changes: 12 additions & 10 deletions avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1799,12 +1799,10 @@
if (remove) { //如果它没有在DOM树
list.splice(i, 1)
if (fn.proxies) {
for (var p = 0, proxy; proxy = fn.proxies[p++]; ) {
recycleEachProxy(proxy)
}
fn.proxies = fn.callbackElemeent = fn.element = fn.parent = fn.template = fn.startRepeat = fn.endRepeat = null
recycleEachProxies(fn.proxies)
fn.proxies = fn.callbackElement = fn.parent = fn.template = fn.startRepeat = fn.endRepeat = null
}
// console.log(fn.proxies)
fn.element = fn.node = null
log("debug: remove " + fn.name)
} else if (typeof fn === "function") {
fn.apply(0, args) //强制重新计算自身
Expand Down Expand Up @@ -2604,9 +2602,7 @@
break
case "del": //将pos后的el个元素删掉(pos, el都是数字)
var removed = proxies.splice(pos, el)
for (var i = 0, proxy; proxy = removed[i++]; ) {
recycleEachProxy(proxy)
}
recycleEachProxies(removed)
expelFromSanctuary(removeView(locatedNode, group, el))
break
case "index": //将proxies中的第pos个起的所有元素重新索引(pos为数字,el用作循环变量)
Expand All @@ -2630,8 +2626,8 @@
} else {
transation = parent
}
recycleEachProxies(proxies)
expelFromSanctuary(transation)
proxies.length = 0
break
case "move": //将proxies中的第pos个元素移动el位置上(pos, el都是数字)
var t = proxies.splice(pos, 1)[0]
Expand Down Expand Up @@ -2910,7 +2906,7 @@
if (type === "repeat") {
var startRepeat = DOC.createComment("ms-repeat-start")
var endRepeat = DOC.createComment("ms-repeat-end")
data.element = data.parent = elem.parentNode
data.element = data.parent = elem.parentNode//?
data.startRepeat = startRepeat
data.endRepeat = endRepeat
elem.removeAttribute(data.name)
Expand Down Expand Up @@ -3856,6 +3852,12 @@
proxy.$id = "$proxy$" + data.type + Math.random()
return proxy
}
function recycleEachProxies(array){
for(var i = 0, el; el = array[i++];){
recycleEachProxy(el)
}
array.length = 0
}
function recycleEachProxy(proxy) {
var obj = proxy.$accessors, name = proxy.$itemName;
["$index", "$last", "$first"].forEach(function(prop) {
Expand Down
128 changes: 51 additions & 77 deletions test4.html
Original file line number Diff line number Diff line change
@@ -1,78 +1,52 @@
<!DOCTYPE html>

<html>
<head>
<title>中国站长天空-网页特效-时间特效-</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
<!--把下面代码加到<head>与</head>之间-->
<xml:namespace ns="urn:schemas-microsoft-com:vml" prefix="v" />
<object id="VMLRender" codebase="vgx.dll" classid="CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E">
</object>
<style>
<!--
v\:* { behavior: url(#VMLRender); }
-->
</style>
<script language="JavaScript1.2">
<!--
/*
DHTML analog clock II
*/
//specify clock size in pixels
var clocksize=135
function updatePointers() {
var now = new Date();
secondsPointer.style.rotation = now.getSeconds() * 6;
minutesPointer.style.rotation = now.getMinutes() * 6 + now.getSeconds() / 10;
hoursPointer.style.rotation = now.getHours() * 30 + now.getMinutes() / 2;
}
if (document.all&&window.print){
window.attachEvent("onload", initVMLClock);
window.attachEvent("onresize", resizeObjects);
}
function initVMLClock() {
resizeObjects();
updatePointers();
window.setInterval("updatePointers()", 1000);
}
function resizeObjects() {
var size = Math.min(clocksize, clocksize);
clock.style.pixelWidth = size - 2*(size * 0.045);
clock.style.pixelHeight = size - 2*(size * 0.045);

clock.childNodes.item(0).childNodes.item(0).weight = size * 0.01;
secondsPointer.childNodes.item(0).childNodes.item(0).weight = size * 0.001;
minutesPointer.childNodes.item(0).childNodes.item(0).weight = size * 0.002;
hoursPointer.childNodes.item(0).childNodes.item(0).weight = size * 0.004;
}
function toggle(sId) {
var el = document.getElementById(sId);
el.style.display = (el.style.display == "none") ? "block" : "none";
}
//-->
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<v:group id="clock" coordsize="100 100" style="position: relative;">
<v:oval style="width: 100%; height: 100%">
<v:stroke weight="10px" color="gray"/>
<!-- I removed this gradient fill to match the WebFX color theme
<v:fill type="gradient" color="white" color2="#eeeeff" angle="225deg"/>-->
</v:oval>
<v:group id="secondsPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,5">
<v:stroke weight="2px" endcap="round" color="navy"/>
</v:line>
</v:group>
<v:group id="minutesPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,8">
<v:stroke weight="4px" endcap="round" color="navy"/>
</v:line>
</v:group>
<v:group id="hoursPointer" style="width: 100%; height: 100%; position: absolute; top: 0px; left: 0px;">
<v:line from="50,50" to="50,18">
<v:stroke weight="7px" endcap="round" color="navy"/>
</v:line>
</v:group>
</v:group>
</body>
</html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="avalon.repeat.js"></script>
<script>
avalon.define("xxx", function(vm) {
vm.data = [{checked: false}, {checked: false}, {checked: false}]
vm.allchecked = false
vm.$one = "yyyyyyyyyyy"
vm.checkAll = function() {

var vmodel = avalon.vmodels.xxx
var bool = vmodel.allchecked = this.checked
vmodel.data.forEach(function(el) {
el.checked = bool
})
}
vm.checkOne = function($index) {
var vmodel = avalon.vmodels.xxx
avalon.bind("click", this, function() {
setTimeout(function() {
console.log($index)
if (!this.checked) {
vmodel.allchecked = false
} else {
vmodel.allchecked = vmodel.data.every(function(el) {
return el.checked
})
}
})
})

}
})
</script>
</head>
<body>

<table ms-controller="xxx" border="1">
<tr>
<td><input type="checkbox" ms-duplex-radio="allchecked" data-duplex-changed="checkAll"/>全选{{$one}}</td>
</tr>
<tr ms-repeat="data">
<td><input type="checkbox" ms-duplex-radio="el.checked" ms-scan="checkOne(el,$index)"/>xxxxxxxxxxxx</td>
</tr>
</table>
</body>
</html>

0 comments on commit ae319c8

Please sign in to comment.