2012-07-26 10:00:00 +02:00
|
|
|
(function(a,b,c,d){function e(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var f=e.prototype;f.init=function(){this.set(),this.original_coords=this.get()},f.set=function(a,b){var c=this.el;c&&!a&&(this.data=c.offset(),this.data.width=c.width(),this.data.height=c.height());if(c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return this.coords.x1=e.left,this.coords.y1=e.top,this.coords.x2=e.left+e.width,this.coords.y2=e.top+e.height,this.coords.cx=e.left+e.width/2,this.coords.cy=e.top+e.height/2,this.coords.width=e.width,this.coords.height=e.height,this.coords.el=c||!1,this},f.update=function(b){if(!b&&!this.el)return this;if(b){var c=a.extend({},this.data,b);return this.data=c,this.set(!0,!0)}return this.set(!0),this},f.get=function(){return this.coords},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new e(this,arguments[0]);return this.data("coords",a),a}})(jQuery,window,document),function(a,b,c,d){function f(b,c,d){this.options=a.extend(e,d),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],typeof c=="string"||c instanceof jQuery?this.$colliders=a(c,this.options.colliders_context).not(this.$element):this.colliders=a(c),this.init()}var e={colliders_context:c.body},g=f.prototype;g.init=function(){this.find_collisions()},g.overlaps=function(a,b){var c=!1,d=!1;if(b.x1>=a.x1&&b.x1<=a.x2||b.x2>=a.x1&&b.x2<=a.x2||a.x1>=b.x1&&a.x2<=b.x2)c=!0;if(b.y1>=a.y1&&b.y1<=a.y2||b.y2>=a.y1&&b.y2<=a.y2||a.y1>=b.y1&&a.y2<=b.y2)d=!0;return c&&d},g.detect_overlapping_region=function(a,b){var c="",d="";return a.y1>b.cy&&a.y1<b.y2&&(c="N"),a.y2>b.y1&&a.y2<b.cy&&(c="S"),a.x1>b.cx&&a.x1<b.x2&&(d="W"),a.x2>b.x1&&a.x2<b.cx&&(d="E"),c+d||"C"},g.calculate_overlapped_area_coords=function(b,c){var d=Math.max(b.x1,c.x1),e=Math.max(b.y1,c.y1),f=Math.min(b.x2,c.x2),g=Math.min(b.y2,c.y2);return a({left:d,top:e,width:f-d,height:g-e}).coords().get()},g.calculate_overlapped_area=function(a){return a.width*a.height},g.manage_colliders_start_stop=function(b,c,d){var e=this.last_colliders_coords;for(var f=0,g=e.length;f<g;f++)a.inArray(e[f],b)===-1&&c.call(this,e[f]);for(var h=0,i=b.length;h<i;h++)a.inArray(b[h],e)===-1&&d.call(this,b[h])},g.find_collisions=function(b){var c=this,d=[],e=[],f=this.colliders||this.$colliders,g=f.length,h=c.$element.coords().update(b||!1).get();while(g--){var i=c.$colliders?a(f[g]):f[g],j=i.isCoords?i:i.coords(),k=j.get(),l=c.overlaps(h,k);if(!l)continue;var m=c.detect_overlapping_region(h,k);if(m==="C"){var n=c.calculate_overlapped_area_coords(h,k),o=c.calculate_overlapped_area(n),p={area:o,area_coords:n,region:m,coords:k,player_coords:h,el:i};c.options.on_overlap&&c.options.on_overlap.call(this,p),d.push(j),e.push(p)}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(d,c.options.on_overlap_stop,c.options.on_overlap_start),this.last_colliders_coords=d,e},g.get_closest_colliders=function(a){var b=this.find_collisions(a),c=100;return b.sort(function(a,b){return a.area<=c?1:a.region==="C"&&b.region==="C"?a.coords.y1<b.coords.y1||a.coords.x1<b.coords.x1?-1:1:a.area<b.area?1:1}),b},a.fn.collision=function(a,b){return new f(this,a,b)}}(jQuery,window,document),function(a,b){a.debounce=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)};c&&!d&&a.apply(e,f),clearTimeout(d),d=setTimeout(g,b)}},a.throttle=function(a,b){var c,d,e,f,g,h,i=debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var j=function(){e=null,g&&a.apply(c,d),i()};return e||(e=setTimeout(j,b)),f?g=!0:h=a.apply(c,d),i(),f=!0,h}}}(window),function(a,b,c,d){function h(b,c){this.options=a.extend({},e,c),this.$container=a(b),this.$dragitems=a(this.options.items,this.$container),this.is_dragging=!1,this.player_min_left=0+this.options.offset_left,this.init()}var e={items:".gs_w",distance:1,limit:!0,offset_left:0,autoscroll:!0},f=a(c.body),g=a(b),i=h.prototype;i.init=function(){this.calculate_positions(),this.$container.c
|