Skip to content
Browse files

less return points

  • Loading branch information...
1 parent e592da8 commit 29a54266423cf18f1ecd69374dbd129974884399 @archiloque committed Apr 28, 2012
Showing with 3 additions and 8 deletions.
  1. +2 −7 jquery.compactWall.js
  2. +1 −1 jquery.compactWall.min.js
View
9 jquery.compactWall.js
@@ -98,7 +98,6 @@
(slots[slotIndex + 1][2] + block[0]),
slots[slotIndex + 1][2]
]);
- return r;
} else {
var availableWidth = slot[3] - block[1];
if (availableWidth >= minBlockWidth) {
@@ -108,12 +107,11 @@
block[0],
availableWidth
]);
- return r;
} else {
r.splice(slotIndex, 1);
- return r;
}
}
+ return r;
}
function smallerNarrower(slots, slotIndex, slot, block) {
@@ -141,7 +139,6 @@
slots[slotIndex + 1][3]
]
);
- return r;
} else {
// current slot is not the first one
// increase the size of next one
@@ -153,7 +150,6 @@
slots[slotIndex + 1][3]
]
);
- return r;
}
} else {
var availableWidth = (slot[3] - block[1]);
@@ -170,7 +166,6 @@
block[0],
availableWidth
]);
- return r;
} else {
r.splice(slotIndex, 1,
[
@@ -179,9 +174,9 @@
(slot[2] - block[0]),
slot[3]
]);
- return r;
}
}
+ return r;
}
function smallerSameWidth(slots, slotIndex, slot, block) {
View
2 jquery.compactWall.min.js
@@ -5,4 +5,4 @@
*
* Licensed under the MIT license.
* Copyright 2012 Julien Kirch
- */(function(a){a.fn.compactWall=function(b,c){return this.each(function(d,e){function m(a,b){var c=a.slice(0);return c.splice(b,1),c}function n(a,b,c,d){var e=a.slice(0);if(a.length>b+1&&a[b+1][1]==c[1]+d[0]&&a[b+1][3]==c[3]-d[1])return e.splice(b,1,[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][2]]),e;var f=c[3]-d[1];return f>=j?(e.splice(b,1,[c[0],c[1]+d[1],d[0],f]),e):(e.splice(b,1),e)}function o(a,b,c,d){var e=a.slice(0);if(a.length>b+1&&a[b+1][1]==c[1]+d[1]&&a[b+1][3]==c[3]-d[1])return b==0?(e.splice(0,2,[c[0]+d[0],0,Number.POSITIVE_INFINITY,c[3]],[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][3]]),e):(e.splice(b,1,[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][3]]),e);var f=c[3]-d[1];return f>=j?(e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]],[c[0],c[1]+d[1],d[0],f]),e):(e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]]),e)}function p(a,b,c,d){var e=a.slice(0);return e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]]),e}function q(a,b){var c=null,d=b[0],e=b.slice(1),f=a[1];for(var g=a[0].length-1;g>=0;g--){var h=a[0][g];if(h[0]+d[0]<l&&h[2]>=d[0]&&h[3]>=d[1]){var i=[d,h],j=h[0]+d[0],k=a[2]>j?a[2]:j;if(e.length==0){if(k<=l){l=k;var r=f.slice(0);r.splice(-1,0,i),c=[[],r,k]}}else{var s=[];h[2]==d[0]?h[3]==d[1]?s=m(a[0],g):s=n(a[0],g,h,d):d[1]==h[3]?s=p(a[0],g,h,d):s=o(a[0],g,h,d);var r=f.slice(0);r.splice(-1,0,i);var t=q([s,r,k],e);t&&t[2]<=l&&(c=t)}}}return c}function r(a){return q([[[0,0,Number.POSITIVE_INFINITY,k]],[],0],a)}if(b.length==0)return;var f=a.extend({containerWidth:a(e).innerWidth()},c),g=[];for(var h=0;h<b.length;h++){var i=a(b[h]);g.push([i.outerHeight(!0),i.outerWidth(!0),i])}g=g.sort(function(a,b){return b[1]==a[1]?b[0]-a[0]:b[1]-a[1]});var j=g[g.length-1][1],k=f.containerWidth,l=Number.POSITIVE_INFINITY,s=r(g);if(s){for(var t=0;t<s[1].length;t++){var u=s[1][t];a(u[0][2]).css("position","absolute").css("top",u[1][0]).css("left",u[1][1])}a(e).css("position","relative").css("height",s[2])}})}})(jQuery);
+ */(function(a){a.fn.compactWall=function(b,c){return this.each(function(d,e){function m(a,b){var c=a.slice(0);return c.splice(b,1),c}function n(a,b,c,d){var e=a.slice(0);if(a.length>b+1&&a[b+1][1]==c[1]+d[0]&&a[b+1][3]==c[3]-d[1])e.splice(b,1,[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][2]]);else{var f=c[3]-d[1];f>=j?e.splice(b,1,[c[0],c[1]+d[1],d[0],f]):e.splice(b,1)}return e}function o(a,b,c,d){var e=a.slice(0);if(a.length>b+1&&a[b+1][1]==c[1]+d[1]&&a[b+1][3]==c[3]-d[1])b==0?e.splice(0,2,[c[0]+d[0],0,Number.POSITIVE_INFINITY,c[3]],[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][3]]):e.splice(b,1,[a[b+1][0],a[b+1][1],a[b+1][2]+d[0],a[b+1][3]]);else{var f=c[3]-d[1];f>=j?e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]],[c[0],c[1]+d[1],d[0],f]):e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]])}return e}function p(a,b,c,d){var e=a.slice(0);return e.splice(b,1,[c[0]+d[0],c[1],c[2]-d[0],c[3]]),e}function q(a,b){var c=null,d=b[0],e=b.slice(1),f=a[1];for(var g=a[0].length-1;g>=0;g--){var h=a[0][g];if(h[0]+d[0]<l&&h[2]>=d[0]&&h[3]>=d[1]){var i=[d,h],j=h[0]+d[0],k=a[2]>j?a[2]:j;if(e.length==0){if(k<=l){l=k;var r=f.slice(0);r.splice(-1,0,i),c=[[],r,k]}}else{var s=[];h[2]==d[0]?h[3]==d[1]?s=m(a[0],g):s=n(a[0],g,h,d):d[1]==h[3]?s=p(a[0],g,h,d):s=o(a[0],g,h,d);var r=f.slice(0);r.splice(-1,0,i);var t=q([s,r,k],e);t&&t[2]<=l&&(c=t)}}}return c}function r(a){return q([[[0,0,Number.POSITIVE_INFINITY,k]],[],0],a)}if(b.length==0)return;var f=a.extend({containerWidth:a(e).innerWidth()},c),g=[];for(var h=0;h<b.length;h++){var i=a(b[h]);g.push([i.outerHeight(!0),i.outerWidth(!0),i])}g=g.sort(function(a,b){return b[1]==a[1]?b[0]-a[0]:b[1]-a[1]});var j=g[g.length-1][1],k=f.containerWidth,l=Number.POSITIVE_INFINITY,s=r(g);if(s){for(var t=0;t<s[1].length;t++){var u=s[1][t];a(u[0][2]).css("position","absolute").css("top",u[1][0]).css("left",u[1][1])}a(e).css("position","relative").css("height",s[2])}})}})(jQuery);

0 comments on commit 29a5426

Please sign in to comment.
Something went wrong with that request. Please try again.