Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Clean license wording

  • Loading branch information...
commit 0ab7d73e4a4c1bbab090b9a6d490b5b2f89e38ac 1 parent 0491779
@pure authored
View
1  .gitignore
@@ -2,4 +2,3 @@
commit.sh
js/*.html
bugs/*
-compiler.jar
View
21 README.md
@@ -9,5 +9,22 @@
<p>&nbsp;</p>
-&copy; 2011 Michael Cvilic - BeeBole. All Rights Reserved
-PURE is an Open Source Software. You can use, redistribute and/or modify it under the terms of the MIT Licence.
+<p>Copyright &copy; 2011 Michael Cvilic - BeeBole</p>
+
+<p>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>
+of this software and associated documentation files (the "Software"), to deal<br/>
+in the Software without restriction, including without limitation the rights<br/>
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>
+copies of the Software, and to permit persons to whom the Software is<br/>
+furnished to do so, subject to the following conditions:</p>
+
+<p>The above copyright notice and this permission notice shall be included in<br/>
+all copies or substantial portions of the Software.</p>
+
+<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>
+THE SOFTWARE.</p>
View
1  js/demo.js
@@ -2,7 +2,6 @@
var loadLib, runAll, run, transform;
(function(){
- //java -jar compiler.jar --js libs/pure.js --js_output_file libs/pure_min.js
var currLib = 'jquery'; //default lib
loadLib = function(lib){
View
4 js/examples.js
@@ -47,8 +47,8 @@ var ex04 = {
return ' ' + oddEven + ' ' + firstLast;
},
'td':'player',
- 'td@style': '"cursor:pointer"',
- 'td@onclick':'"clickLine(this);"'
+ 'td@style': 'cursor:pointer',
+ 'td@onclick':'clickLine(this);'
},
sort:function(a, b){
return a > b ? 1 : -1;
View
3,496 libs/prototype.js
2,352 additions, 1,144 deletions not shown
View
6 v3_preview/pure2.html
@@ -30,7 +30,8 @@
href:'beebole.com',
site:'hello',
animals:[
- {name:'cat', food:['mouse', 'meat']}, {name:'mouse', food:['cheese', 'grains']}, {name:'dog', food:['bones', 'meat']}
+ {name:'cat', food:['mouse', 'meat']},
+ {name:'mouse', food:['cheese', 'grains']}
]
},
directive = {
@@ -38,9 +39,6 @@
'animal<-animals':{
'li.food':{
'food<-animal.food':{
- '.':function(){
- return this;
- }
}
}
}
View
26 v3_preview/pure3.html
@@ -7,16 +7,16 @@
<script src="pure3.js"></script>
</head>
<body>
- <div style="display:none">
+ <div>
<div class="template">
<a href="http://"></a>
<span></span>
<input type="button" />
<ul>
<li class="animal">
- <span class="name"></span>
+ <span class="name">a</span>
<ol>
- <li class="food"></li>
+ <li class="food">f</li>
</ol>
</li>
</ul>
@@ -44,27 +44,23 @@
'input@value':'anyText',*/
'li.animal':{
'animal<-animals':{
- 'span.name':'animal.name',
- '@id':function(a){
+/* '@id':function(a){
return this.name[0];
- }
-
-
+ },*/
/*'li.food':{
'food<-animal.food':{
- '.':function(){
- return this;
- }
+ '.':'food'
}
- }*/
+ },*/
+ 'span.name':'animal.name'
}
}
},
template = $p('div.template')[0].cloneNode(true), //!templates are not copied by default anymore
- rfn = $p(template).compile(directive); //!the compiled function returns a DOM node, not a string anymore
- document.getElementById('result').appendChild( rfn(data) );
-
+ rfn = $p(template).compile(directive); //!the compiled function returns a DOM node, not a string anymore
+ document.getElementById('result').appendChild( rfn(data) );
+
</script>
</body>
View
43 v3_preview/pure3.js
@@ -220,36 +220,51 @@ $p.core = function(sel, ctxt, plugins){
},
loopDef = getLoopDef( change ),
- innerCompiled = compiler( node, loopDef.change ),
+ nodeToLoop = node.cloneNode(true),
+ innerCompiled = compiler( nodeToLoop, loopDef.change ),
getLoopCtxt = dataReader( loopDef.loopSpec.arrayName ),
- pa = node.parentNode,
-
- makeAction = function( ctxt ){
+ makeAction = function( ctxt, node, pa ){
var dfrag = document.createDocumentFragment(),
- items = getLoopCtxt( ctxt ),
+ items = getLoopCtxt(ctxt),
i = 0, ii = items.length,
- tempCtxt = {context: ctxt},
+ tempCtxt = {context:ctxt},
saved = {
item: ctxt.item,
items: ctxt.items,
pos: ctxt.pos
},
- loopCtxt = tempCtxt[ loopDef.loopSpec.itemName ] = {};
+ loopCtxt = tempCtxt[loopDef.loopSpec.itemName] = {};
tempCtxt.items = loopCtxt.items = items;
for( ; i < ii; i++ ){
- tempCtxt.item = loopCtxt.item = items[ i ];
+ tempCtxt.item = loopCtxt.item = items[i];
tempCtxt.node = loopCtxt.node = node;
tempCtxt.pos = loopCtxt.pos = i;
- dfrag.appendChild( innerCompiled.call( tempCtxt.item, tempCtxt ) );
+ dfrag.appendChild( innerCompiled.call( tempCtxt.item, tempCtxt, true ) );
}
-
pa.replaceChild( dfrag.cloneNode( true ), node );
};
-
+
actions.push( function( ctxt ){
- return makeAction( ctxt );
+ var dfrag = document.createDocumentFragment(),
+ items = getLoopCtxt(ctxt),
+ i = 0, ii = items.length,
+ tempCtxt = {context:ctxt},
+ loopCtxt = tempCtxt[loopDef.loopSpec.itemName] = {},
+ innerCompiled = compiler( nodeToLoop.cloneNode(true), loopDef.change );
+
+ tempCtxt.items = loopCtxt.items = items;
+
+ for( ; i < ii; i++ ){
+ tempCtxt.item = loopCtxt.item = items[i];
+ tempCtxt.node = loopCtxt.node = node;
+ tempCtxt.pos = loopCtxt.pos = i;
+ dfrag.appendChild( innerCompiled( tempCtxt ) );
+ }
+
+ node.parentNode.replaceChild( dfrag.cloneNode( true ), node );
+
});
};
@@ -268,7 +283,7 @@ $p.core = function(sel, ctxt, plugins){
while(i--){
if(typeof change === 'object'){
- loopNode( change, nodes[ i ]);
+ loopNode( change, nodes[ i ].cloneNode(true), nodes[i]);
}else{
setActions( selSpec, change, nodes[ i ] );
}
@@ -282,7 +297,7 @@ $p.core = function(sel, ctxt, plugins){
for( ; i < ii; i++ ){
actions[ i ]( data );
}
- return root.cloneNode(true);
+ return root;
};
},
Please sign in to comment.
Something went wrong with that request. Please try again.