Permalink
Browse files

Fix request var declaration; build

  • Loading branch information...
1 parent ac3dbc7 commit b56b542dffceac145203f378ce8de451dd41d451 @pyrsmk committed Mar 31, 2012
Showing with 41 additions and 44 deletions.
  1. +1 −1 README.markdown
  2. +0 −1 molt-2.4.0.W.min.js
  3. +0 −1 molt-2.4.0.min.js
  4. +1 −0 molt-2.4.3.W.min.js
  5. +1 −0 molt-2.4.3.min.js
  6. +2 −2 src/molt.js
  7. +1 −1 src/package.json
  8. +35 −38 unit/ender.js
View
@@ -1,4 +1,4 @@
-molt 2.4.2
+molt 2.4.3
==========
The idea to develop molt comes from a few observations:
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,7 +1,7 @@
/*
molt, image updater for responsive designs
- Version : 2.4.2
+ Version : 2.4.3
Author : Aurélien Delogu (dev@dreamysource.fr)
Homepage : https://github.com/pyrsmk/molt
License : MIT
@@ -24,7 +24,7 @@
triggers=[],
listeners=[],
nodes=[],
- i;
+ i,
/*
Refresh image nodes
View
@@ -1,7 +1,7 @@
{
"name" : "molt",
"description" : "Image updater for responsive designs",
- "version" : "2.4.0",
+ "version" : "2.4.3",
"author" : "Aurélien Delogu <pyrsmk@dreamysource.fr> (http://dreamysource.fr)",
"repository" : {
"type" : "git",
View
@@ -119,10 +119,10 @@
/*
molt, image updater for responsive designs
- Version: 2.4.0
- Author: Aurélien Delogu (dev@dreamysource.fr)
- Homepage: https://github.com/pyrsmk/molt
- License: MIT
+ Version : 2.4.3
+ Author : Aurélien Delogu (dev@dreamysource.fr)
+ Homepage : https://github.com/pyrsmk/molt
+ License : MIT
*/
(function(def){
@@ -133,83 +133,77 @@
this.molt=def;
}
}(function(){
-
+
/*
Array nodes: molt images
*/
var getAttribute='getAttribute',
+ data='data-',
triggers=[],
listeners=[],
nodes=[],
i,
-
+
/*
Refresh image nodes
*/
refresh=function(){
var j,
k,
- l,
url,
- display,
node,
+ mode,
modes,
- mapping,
- width=W(),
- stack;
+ width=W();
// Browse molt images
i=-1;
while(node=nodes[++i]){
// Guess the current mode for that image
- modes=(url=node.getAttribute('data-url')).match(/\{\s*(.*?)\s*\}/)[1].split(/\s*,\s*/);
- for(l=0;l<modes.length;l++){
- mapping = modes[l].split(":");
- if(mapping.length===1){
- modes[l] = [mapping[0], mapping[0]];
- }else{
- modes[l] = [mapping[0], mapping[1]];
- }
- }
+ modes=(url=node.getAttribute(data+'url')).match(/\{\s*(.*?)\s*\}/)[1].split(/\s*,\s*/);
j=modes.length;
- while(j){
- if(width>modes[--j][0].match(/^!?(.+)/)[1]){
+ while(j--){
+ mode=modes[j].split(':');
+ if(mode.length==1){
+ mode[1]=mode[0];
+ }
+ if(width>mode[0].match(/^!?(.+)/)[1]){
break;
}
}
// Negative mode
- if(modes[j][0].charAt(0)=='!'){
+ if(mode[0].charAt(0)=='!'){
// Hide image
node.style.display='none';
}
// Normal mode
else{
// Show image
if(node.style.display=='none'){
- if(display=node.getAttribute('data-display')){
- node.style.display=display;
+ if(k=node.getAttribute(data+'display')){
+ node.style.display=k;
}
else{
node.style.display='inline';
}
}
// Refresh src
- node.src=url.replace(/\{.+\}/g,modes[j][1]);
+ node.src=url.replace(/\{.+\}/g,mode[1]);
// Call node listeners
k=triggers.length;
- while(k){
- if(triggers[--k]==node){
- listeners[k].apply(node,[modes[j][1]]);
+ while(k--){
+ if(triggers[k]==node){
+ listeners[k].apply(node,[mode[1]]);
}
}
}
}
};
-
+
return {
-
+
/*
Add a listener to the stack
-
+
Object node : node to listen
Function callback : function to call when the node has been refreshed
*/
@@ -223,20 +217,23 @@
*/
discover:function(){
// Discover images
- var imgs=document.getElementsByTagName('img'),
- i=imgs.length;
- while(i){
+ var img,
+ imgs=document.getElementsByTagName('img'),
+ discovered='discovered';
+ i=-1;
+ while(img=imgs[++i]){
// Only accept images with data-url attribute set
- if(imgs[--i][getAttribute]('data-url')){
- nodes.push(imgs[i]);
+ if(img[getAttribute](data+'url') && !img[getAttribute](data+discovered)){
+ img.setAttribute(data+discovered,discovered);
+ nodes.push(img);
}
}
// Update images
refresh();
// Catch events
W(refresh);
+ return nodes;
}
-
};
}()));

0 comments on commit b56b542

Please sign in to comment.