gridster.js-rails 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +14 -0
- data/bower.json +2 -2
- data/lib/gridster.js-rails/version.rb +1 -1
- data/package.json +3 -3
- data/vendor/assets/javascripts/jquery.collision.js +1 -0
- data/vendor/assets/javascripts/jquery.coords.js +1 -0
- data/vendor/assets/javascripts/jquery.draggable.js +1 -0
- data/vendor/assets/javascripts/{jquery.gridster.js → jquery.dsmorse-gridster.js} +136 -55
- data/vendor/assets/javascripts/jquery.dsmorse-gridster.min.js +2 -0
- data/vendor/assets/javascripts/{jquery.gridster.with-extras.js → jquery.dsmorse-gridster.with-extras.js} +136 -55
- data/vendor/assets/javascripts/jquery.dsmorse-gridster.with-extras.min.js +2 -0
- data/vendor/assets/javascripts/utils.js +1 -0
- data/vendor/assets/stylesheets/{jquery.gridster.min.css → jquery.dsmorse-gridster.min.css} +1 -1
- metadata +25 -21
- data/vendor/assets/javascripts/jquery.gridster.min.js +0 -2
- data/vendor/assets/javascripts/jquery.gridster.with-extras.min.js +0 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1aeb46f070b5f67aaa802bf6fbed5b6c629dec55
|
|
4
|
+
data.tar.gz: 5c0d1fd00e3c7347959087207cefcac36a703531
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b56f060fcaf94d825e61fbcde42221ff187b0b24679d2f4200d966809ab8167734f085c7f9e9bfaf5977279954e0c8f89f7fa9e0b3e9233cc8f92f642855485e
|
|
7
|
+
data.tar.gz: '0397ceaa0ddea9437783af3f746257c03a24a034249f0f43b25eef8bf954ab927037822a7a1536d57d26ee594b247cf574dbc64481c12fd0fd5a8fa348ebaade'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
<a name="v0.7.0"></a>
|
|
2
|
+
## v0.7.0 (2016-02-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* Apply fix from #22 to vertical positioning ([dfc64916](http://github.com/dsmorse/gridster.js/commit/dfc649168c5b6a2a230b90a47e19621a6937fc7c))
|
|
8
|
+
* convert from JQury to DOM ([4936ef82](http://github.com/dsmorse/gridster.js/commit/4936ef82c04690fde118c3d54b798ceaf7c376e6))
|
|
9
|
+
* **fn.generate_stylesheet:** only return new stylesheet if colWidth and this.$wrapper.width() are > 0 ([f513793a](http://github.com/dsmorse/gridster.js/commit/f513793a8c0ec63509f6296325a8a7a6e34179f5))
|
|
10
|
+
* **gridster:** Add additiona error checking on widgets removal ([2b0f9963](http://github.com/dsmorse/gridster.js/commit/2b0f9963ef80c9acc6f66545eb53597836e2ebec))
|
|
11
|
+
|
|
1
12
|
<a name="v0.6.10"></a>
|
|
2
13
|
### v0.6.10 (2015-05-31)
|
|
3
14
|
* Add Ruby on Rails support
|
data/README.md
CHANGED
|
@@ -28,6 +28,20 @@ As of result of the inactivity over the last year in the [Ducksboard](https://gi
|
|
|
28
28
|
for current support. He will GLADLY accept pull requests, and will be working to merge existing
|
|
29
29
|
Pull Requests from Ducksboard repo.
|
|
30
30
|
|
|
31
|
+
## Install with NPM
|
|
32
|
+
|
|
33
|
+
This fork of Gridster can be installed via [NPM](https://npmjs.com/package/dsmorse-gridster);
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install dsmorse-gridster
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
or to save.
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm install dsmorse-gridster --save
|
|
43
|
+
```
|
|
44
|
+
|
|
31
45
|
## Ruby on Rails integration
|
|
32
46
|
|
|
33
47
|
This artifact is published to [rubygems.org](https://rubygems.org/gems/gridster.js-rails) to be consumed by ruby on rails applications.
|
data/bower.json
CHANGED
data/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "gridster",
|
|
2
|
+
"name": "dsmorse-gridster",
|
|
3
3
|
"title": "gridster.js",
|
|
4
4
|
"description": "a drag-and-drop multi-column jQuery grid plugin",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.8.0",
|
|
6
6
|
"homepage": "https://dsmorse.github.io/gridster.js/",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "ducksboard"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"grunt-contrib-cssmin": "~0.10.0",
|
|
33
33
|
"grunt-contrib-jshint": "~0.10.0",
|
|
34
34
|
"grunt-contrib-less": "^1.2.0",
|
|
35
|
-
"grunt-contrib-qunit": "^0.
|
|
35
|
+
"grunt-contrib-qunit": "^2.0.0",
|
|
36
36
|
"grunt-contrib-uglify": "~0.6.0",
|
|
37
37
|
"grunt-contrib-watch": "~0.6.1",
|
|
38
38
|
"grunt-contrib-yuidoc": "~0.7.0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! gridster.js - v0.8.0 - 2018-07-24 - * https://dsmorse.github.io/gridster.js/ - Copyright (c) 2018 ducksboard; Licensed MIT */ !function(a,b){"use strict";"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-collision",["jquery","gridster-coords"],b):a.GridsterCollision=b(a.$||a.jQuery,a.GridsterCoords)}(this,function(a,b){"use strict";function c(b,c,e){this.options=a.extend(d,e),this.$element=b,this.last_colliders=[],this.last_colliders_coords=[],this.set_colliders(c),this.init()}var d={colliders_context:document.body,overlapping_region:"C"};c.defaults=d;var e=c.prototype;return e.init=function(){this.find_collisions()},e.overlaps=function(a,b){var c=!1,d=!1;return(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),(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),c&&d},e.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"},e.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()},e.calculate_overlapped_area=function(a){return a.width*a.height},e.manage_colliders_start_stop=function(b,c,d){for(var e=this.last_colliders_coords,f=0,g=e.length;g>f;f++)-1===a.inArray(e[f],b)&&c.call(this,e[f]);for(var h=0,i=b.length;i>h;h++)-1===a.inArray(b[h],e)&&d.call(this,b[h])},e.find_collisions=function(b){for(var c=this,d=this.options.overlapping_region,e=[],f=[],g=this.colliders||this.$colliders,h=g.length,i=c.$element.coords().update(b||!1).get();h--;){var j=c.$colliders?a(g[h]):g[h],k=j.isCoords?j:j.coords(),l=k.get(),m=c.overlaps(i,l);if(m){var n=c.detect_overlapping_region(i,l);if(n===d||"all"===d){var o=c.calculate_overlapped_area_coords(i,l),p=c.calculate_overlapped_area(o);if(0!==p){var q={area:p,area_coords:o,region:n,coords:l,player_coords:i,el:j};c.options.on_overlap&&c.options.on_overlap.call(this,q),e.push(k),f.push(q)}}}}return(c.options.on_overlap_stop||c.options.on_overlap_start)&&this.manage_colliders_start_stop(e,c.options.on_overlap_start,c.options.on_overlap_stop),this.last_colliders_coords=e,f},e.get_closest_colliders=function(a){var b=this.find_collisions(a);return b.sort(function(a,b){return"C"===a.region&&"C"===b.region?a.coords.y1<b.coords.y1||a.coords.x1<b.coords.x1?-1:1:(a.area<b.area,1)}),b},e.set_colliders=function(b){"string"==typeof b||b instanceof a?this.$colliders=a(b,this.options.colliders_context).not(this.$element):this.colliders=a(b)},a.fn.collision=function(a,b){return new c(this,a,b)},c});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! gridster.js - v0.8.0 - 2018-07-24 - * https://dsmorse.github.io/gridster.js/ - Copyright (c) 2018 ducksboard; Licensed MIT */ !function(a,b){"use strict";"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-coords",["jquery"],b):a.GridsterCoords=b(a.$||a.jQuery)}(this,function(a){"use strict";function b(b){return b[0]&&a.isPlainObject(b[0])?this.data=b[0]:this.el=b,this.isCoords=!0,this.coords={},this.init(),this}var c=b.prototype;return c.init=function(){this.set(),this.original_coords=this.get()},c.set=function(a,b){var c=this.el;if(c&&!a&&(this.data=c.offset(),this.data.width=c[0].scrollWidth,this.data.height=c[0].scrollHeight),c&&a&&!b){var d=c.offset();this.data.top=d.top,this.data.left=d.left}var e=this.data;return void 0===e.left&&(e.left=e.x1),void 0===e.top&&(e.top=e.y1),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},c.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},c.get=function(){return this.coords},c.destroy=function(){this.el.removeData("coords"),delete this.el},a.fn.coords=function(){if(this.data("coords"))return this.data("coords");var a=new b(this);return this.data("coords",a),a},b});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! gridster.js - v0.8.0 - 2018-07-24 - * https://dsmorse.github.io/gridster.js/ - Copyright (c) 2018 ducksboard; Licensed MIT */ !function(a,b){"use strict";"object"==typeof exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define("gridster-draggable",["jquery"],b):a.GridsterDraggable=b(a.$||a.jQuery)}(this,function(a){"use strict";function b(b,d){this.options=a.extend({},c,d),this.$document=a(document),this.$container=a(b),this.$scroll_container=this.options.scroll_container===window?a(window):this.$container.closest(this.options.scroll_container),this.is_dragging=!1,this.player_min_left=0+this.options.offset_left,this.player_min_top=0+this.options.offset_top,this.id=i(),this.ns=".gridster-draggable-"+this.id,this.init()}var c={items:"li",distance:1,limit:{width:!0,height:!1},offset_left:0,autoscroll:!0,ignore_dragging:["INPUT","TEXTAREA","SELECT","BUTTON"],handle:null,container_width:0,move_element:!0,helper:!1,remove_helper:!0},d=a(window),e={x:"left",y:"top"},f=!!("ontouchstart"in window),g=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},h=0,i=function(){return++h+""};b.defaults=c;var j=b.prototype;return j.init=function(){var b=this.$container.css("position");this.calculate_dimensions(),this.$container.css("position","static"===b?"relative":b),this.disabled=!1,this.events(),d.bind(this.nsEvent("resize"),throttle(a.proxy(this.calculate_dimensions,this),200))},j.nsEvent=function(a){return(a||"")+this.ns},j.events=function(){this.pointer_events={start:this.nsEvent("touchstart")+" "+this.nsEvent("mousedown"),move:this.nsEvent("touchmove")+" "+this.nsEvent("mousemove"),end:this.nsEvent("touchend")+" "+this.nsEvent("mouseup")},this.$container.on(this.nsEvent("selectstart"),a.proxy(this.on_select_start,this)),this.$container.on(this.pointer_events.start,this.options.items,a.proxy(this.drag_handler,this)),this.$document.on(this.pointer_events.end,a.proxy(function(a){this.is_dragging=!1,this.disabled||(this.$document.off(this.pointer_events.move),this.drag_start&&this.on_dragstop(a))},this))},j.get_actual_pos=function(a){return a.position()},j.get_mouse_pos=function(a){if(a.originalEvent&&a.originalEvent.touches){var b=a.originalEvent;a=b.touches.length?b.touches[0]:b.changedTouches[0]}return{left:a.clientX,top:a.clientY}},j.get_offset=function(a){a.preventDefault();var b=this.get_mouse_pos(a),c=Math.round(b.left-this.mouse_init_pos.left),d=Math.round(b.top-this.mouse_init_pos.top),e=Math.round(this.el_init_offset.left+c-this.baseX+this.$scroll_container.scrollLeft()-this.scroll_container_offset_x),f=Math.round(this.el_init_offset.top+d-this.baseY+this.$scroll_container.scrollTop()-this.scroll_container_offset_y);return this.options.limit.width&&(e>this.player_max_left?e=this.player_max_left:e<this.player_min_left&&(e=this.player_min_left)),this.options.limit.height&&(f>this.player_max_top?f=this.player_max_top:f<this.player_min_top&&(f=this.player_min_top)),{position:{left:e,top:f},pointer:{left:b.left,top:b.top,diff_left:c+(this.$scroll_container.scrollLeft()-this.scroll_container_offset_x),diff_top:d+(this.$scroll_container.scrollTop()-this.scroll_container_offset_y)}}},j.get_drag_data=function(a){var b=this.get_offset(a);return b.$player=this.$player,b.$helper=this.helper?this.$helper:this.$player,b},j.set_limits=function(a){return a||(a=this.$container.width()),this.player_max_left=a-this.player_width+-this.options.offset_left,this.player_max_top=this.options.container_height-this.player_height+-this.options.offset_top,this.options.container_width=a,this},j.scroll_in=function(a,b){var c,d=e[a],f=50,h=30,i="scroll"+g(d),j="x"===a,k=j?this.scroller_width:this.scroller_height;c=this.$scroll_container===window?j?this.$scroll_container.width():this.$scroll_container.height():j?this.$scroll_container[0].scrollWidth:this.$scroll_container[0].scrollHeight;var l,m=j?this.$player.width():this.$player.height(),n=this.$scroll_container[i](),o=n,p=o+k,q=p-f,r=o+f,s=o+b.pointer[d],t=c-k+m;return s>=q&&(l=n+h,t>l&&(this.$scroll_container[i](l),this["scroll_offset_"+a]+=h)),r>=s&&(l=n-h,l>0&&(this.$scroll_container[i](l),this["scroll_offset_"+a]-=h)),this},j.manage_scroll=function(a){this.scroll_in("x",a),this.scroll_in("y",a)},j.calculate_dimensions=function(){this.scroller_height=this.$scroll_container.height(),this.scroller_width=this.$scroll_container.width()},j.drag_handler=function(b){if(!this.disabled&&(1===b.which||f)&&!this.ignore_drag(b)){var c=this,d=!0;return this.$player=a(b.currentTarget),this.el_init_pos=this.get_actual_pos(this.$player),this.mouse_init_pos=this.get_mouse_pos(b),this.offsetY=this.mouse_init_pos.top-this.el_init_pos.top,this.$document.on(this.pointer_events.move,function(a){var b=c.get_mouse_pos(a),e=Math.abs(b.left-c.mouse_init_pos.left),f=Math.abs(b.top-c.mouse_init_pos.top);return e>c.options.distance||f>c.options.distance?d?(d=!1,c.on_dragstart.call(c,a),!1):(c.is_dragging===!0&&c.on_dragmove.call(c,a),!1):!1}),f?void 0:!1}},j.on_dragstart=function(a){if(a.preventDefault(),this.is_dragging)return this;this.drag_start=this.is_dragging=!0;var b=this.$container.offset();return this.baseX=Math.round(b.left),this.baseY=Math.round(b.top),"clone"===this.options.helper?(this.$helper=this.$player.clone().appendTo(this.$container).addClass("helper"),this.helper=!0):this.helper=!1,this.scroll_container_offset_y=this.$scroll_container.scrollTop(),this.scroll_container_offset_x=this.$scroll_container.scrollLeft(),this.el_init_offset=this.$player.offset(),this.player_width=this.$player.width(),this.player_height=this.$player.height(),this.set_limits(this.options.container_width),this.options.start&&this.options.start.call(this.$player,a,this.get_drag_data(a)),!1},j.on_dragmove=function(a){var b=this.get_drag_data(a);this.options.autoscroll&&this.manage_scroll(b),this.options.move_element&&(this.helper?this.$helper:this.$player).css({position:"absolute",left:b.position.left,top:b.position.top});var c=this.last_position||b.position;return b.prev_position=c,this.options.drag&&this.options.drag.call(this.$player,a,b),this.last_position=b.position,!1},j.on_dragstop=function(a){var b=this.get_drag_data(a);return this.drag_start=!1,this.options.stop&&this.options.stop.call(this.$player,a,b),this.helper&&this.options.remove_helper&&this.$helper.remove(),!1},j.on_select_start=function(a){return this.disabled||this.ignore_drag(a)?void 0:!1},j.enable=function(){this.disabled=!1},j.disable=function(){this.disabled=!0},j.destroy=function(){this.disable(),this.$container.off(this.ns),this.$document.off(this.ns),d.off(this.ns),a.removeData(this.$container,"drag")},j.ignore_drag=function(b){return this.options.handle?!a(b.target).is(this.options.handle):a.isFunction(this.options.ignore_dragging)?this.options.ignore_dragging(b):this.options.resize?!a(b.target).is(this.options.items):a(b.target).is(this.options.ignore_dragging.join(", "))},a.fn.gridDraggable=function(a){return new b(this,a)},a.fn.dragg=function(c){return this.each(function(){a.data(this,"drag")||a.data(this,"drag",new b(this,c))})},b});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! gridster.js - v0.
|
|
1
|
+
/*! gridster.js - v0.8.0 - 2018-07-24
|
|
2
2
|
* https://dsmorse.github.io/gridster.js/
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2018 ducksboard; Licensed MIT */
|
|
4
4
|
|
|
5
5
|
;(function(root, factory) {
|
|
6
6
|
'use strict';
|
|
@@ -471,7 +471,7 @@
|
|
|
471
471
|
var defaults = {
|
|
472
472
|
items: 'li',
|
|
473
473
|
distance: 1,
|
|
474
|
-
limit: true,
|
|
474
|
+
limit: {width: true, height: false},
|
|
475
475
|
offset_left: 0,
|
|
476
476
|
autoscroll: true,
|
|
477
477
|
ignore_dragging: ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'], // or function
|
|
@@ -535,6 +535,7 @@
|
|
|
535
535
|
$(window) : this.$container.closest(this.options.scroll_container);
|
|
536
536
|
this.is_dragging = false;
|
|
537
537
|
this.player_min_left = 0 + this.options.offset_left;
|
|
538
|
+
this.player_min_top = 0 + this.options.offset_top;
|
|
538
539
|
this.id = uniqId();
|
|
539
540
|
this.ns = '.gridster-draggable-' + this.id;
|
|
540
541
|
this.init();
|
|
@@ -616,12 +617,19 @@
|
|
|
616
617
|
this.$scroll_container.scrollTop() -
|
|
617
618
|
this.scroll_container_offset_y);
|
|
618
619
|
|
|
619
|
-
if (this.options.limit) {
|
|
620
|
+
if (this.options.limit.width) {
|
|
620
621
|
if (left > this.player_max_left) {
|
|
621
622
|
left = this.player_max_left;
|
|
622
623
|
} else if(left < this.player_min_left) {
|
|
623
624
|
left = this.player_min_left;
|
|
624
625
|
}
|
|
626
|
+
}
|
|
627
|
+
if (this.options.limit.height) {
|
|
628
|
+
if (top > this.player_max_top) {
|
|
629
|
+
top = this.player_max_top;
|
|
630
|
+
} else if (top < this.player_min_top) {
|
|
631
|
+
top = this.player_min_top;
|
|
632
|
+
}
|
|
625
633
|
}
|
|
626
634
|
|
|
627
635
|
return {
|
|
@@ -653,7 +661,9 @@
|
|
|
653
661
|
fn.set_limits = function(container_width) {
|
|
654
662
|
container_width || (container_width = this.$container.width());
|
|
655
663
|
this.player_max_left = (container_width - this.player_width +
|
|
656
|
-
-
|
|
664
|
+
-this.options.offset_left);
|
|
665
|
+
this.player_max_top = (this.options.container_height - this.player_height +
|
|
666
|
+
-this.options.offset_top);
|
|
657
667
|
|
|
658
668
|
this.options.container_width = container_width;
|
|
659
669
|
|
|
@@ -793,6 +803,7 @@
|
|
|
793
803
|
this.scroll_container_offset_x = this.$scroll_container.scrollLeft();
|
|
794
804
|
this.el_init_offset = this.$player.offset();
|
|
795
805
|
this.player_width = this.$player.width();
|
|
806
|
+
this.player_height = this.$player.height();
|
|
796
807
|
|
|
797
808
|
this.set_limits(this.options.container_width);
|
|
798
809
|
|
|
@@ -929,6 +940,10 @@
|
|
|
929
940
|
extra_cols: 0,
|
|
930
941
|
min_cols: 1,
|
|
931
942
|
max_cols: Infinity,
|
|
943
|
+
limit: {
|
|
944
|
+
width: true,
|
|
945
|
+
height: false
|
|
946
|
+
},
|
|
932
947
|
min_rows: 1,
|
|
933
948
|
max_rows: 15,
|
|
934
949
|
autogenerate_stylesheet: true,
|
|
@@ -977,7 +992,8 @@
|
|
|
977
992
|
handle_class: 'gs-resize-handle',
|
|
978
993
|
max_size: [Infinity, Infinity],
|
|
979
994
|
min_size: [1, 1]
|
|
980
|
-
}
|
|
995
|
+
},
|
|
996
|
+
ignore_self_occupied: false
|
|
981
997
|
};
|
|
982
998
|
|
|
983
999
|
/**
|
|
@@ -1090,7 +1106,12 @@
|
|
|
1090
1106
|
|
|
1091
1107
|
this.generated_stylesheets = [];
|
|
1092
1108
|
this.$style_tags = $([]);
|
|
1093
|
-
|
|
1109
|
+
|
|
1110
|
+
if (typeof (this.options.limit) === typeof (true)) {
|
|
1111
|
+
console.log('limit: bool is deprecated, consider using limit: { width: boolean, height: boolean} instead');
|
|
1112
|
+
this.options.limit = { width: this.options.limit, height: this.options.limit };
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1094
1115
|
this.options.auto_init && this.init();
|
|
1095
1116
|
}
|
|
1096
1117
|
|
|
@@ -1311,6 +1332,10 @@
|
|
|
1311
1332
|
|
|
1312
1333
|
if (!col && !row) {
|
|
1313
1334
|
pos = this.next_position(size_x, size_y);
|
|
1335
|
+
if(pos === false)
|
|
1336
|
+
{
|
|
1337
|
+
return false;
|
|
1338
|
+
}
|
|
1314
1339
|
} else {
|
|
1315
1340
|
pos = {
|
|
1316
1341
|
col: col,
|
|
@@ -1767,22 +1792,24 @@
|
|
|
1767
1792
|
|
|
1768
1793
|
this.update_widget_dimensions($widget, new_wgd);
|
|
1769
1794
|
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1795
|
+
if (this.options.shift_widgets_up) {
|
|
1796
|
+
if (empty_cols.length) {
|
|
1797
|
+
var cols_to_remove_holes = [
|
|
1798
|
+
empty_cols[0], new_wgd.row,
|
|
1799
|
+
empty_cols[empty_cols.length - 1] - empty_cols[0] + 1,
|
|
1800
|
+
Math.min(old_size_y, new_wgd.size_y),
|
|
1801
|
+
$widget
|
|
1802
|
+
];
|
|
1777
1803
|
|
|
1778
|
-
|
|
1779
|
-
|
|
1804
|
+
this.remove_empty_cells.apply(this, cols_to_remove_holes);
|
|
1805
|
+
}
|
|
1780
1806
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1807
|
+
if (empty_rows.length) {
|
|
1808
|
+
var rows_to_remove_holes = [
|
|
1809
|
+
new_wgd.col, new_wgd.row, new_wgd.size_x, new_wgd.size_y, $widget
|
|
1810
|
+
];
|
|
1811
|
+
this.remove_empty_cells.apply(this, rows_to_remove_holes);
|
|
1812
|
+
}
|
|
1786
1813
|
}
|
|
1787
1814
|
|
|
1788
1815
|
this.move_widget_up($widget);
|
|
@@ -2206,7 +2233,8 @@
|
|
|
2206
2233
|
offset_left: this.options.widget_margins[0],
|
|
2207
2234
|
offset_top: this.options.widget_margins[1],
|
|
2208
2235
|
container_width: (this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0]),
|
|
2209
|
-
|
|
2236
|
+
container_height: (this.rows * this.min_widget_height) + ((this.rows + 1) * this.options.widget_margins[0]),
|
|
2237
|
+
limit: { width: this.options.limit.width, height: this.options.limit.height },
|
|
2210
2238
|
start: function (event, ui) {
|
|
2211
2239
|
self.$widgets.filter('.player-revert')
|
|
2212
2240
|
.removeClass('player-revert');
|
|
@@ -2247,7 +2275,7 @@
|
|
|
2247
2275
|
container_width: this.container_width,
|
|
2248
2276
|
move_element: false,
|
|
2249
2277
|
resize: true,
|
|
2250
|
-
limit: this.options.max_cols !== Infinity,
|
|
2278
|
+
limit: { width: this.options.max_cols !== Infinity || this.options.limit.width, height: this.options.max_rows !== Infinity || this.options.limit.height },
|
|
2251
2279
|
scroll_container: this.options.scroll_container,
|
|
2252
2280
|
start: $.proxy(this.on_start_resize, this),
|
|
2253
2281
|
stop: $.proxy(function (event, ui) {
|
|
@@ -2304,10 +2332,12 @@
|
|
|
2304
2332
|
this.player_grid_data = this.$player.coords().grid;
|
|
2305
2333
|
this.placeholder_grid_data = $.extend({}, this.player_grid_data);
|
|
2306
2334
|
|
|
2307
|
-
this.
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2335
|
+
var highestRow = this.get_highest_occupied_cell().row;
|
|
2336
|
+
if ((highestRow + this.player_grid_data.size_y) <= this.options.max_rows)
|
|
2337
|
+
{
|
|
2338
|
+
this.set_dom_grid_height(this.$el.height() + (this.player_grid_data.size_y * this.min_widget_height));
|
|
2339
|
+
}
|
|
2340
|
+
this.set_dom_grid_width(this.cols);
|
|
2311
2341
|
|
|
2312
2342
|
var pgd_sizex = this.player_grid_data.size_x;
|
|
2313
2343
|
var cols_diff = this.cols - this.highest_col;
|
|
@@ -2435,23 +2465,27 @@
|
|
|
2435
2465
|
this.$changed = this.$changed.add(this.$player);
|
|
2436
2466
|
|
|
2437
2467
|
//If widget has new position, clean previous grid
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2468
|
+
var grid = this.placeholder_grid_data.el.coords().grid;
|
|
2469
|
+
if (grid.col !== this.placeholder_grid_data.col || grid.row !== this.placeholder_grid_data.row) {
|
|
2470
|
+
this.update_widget_position(grid, false);
|
|
2471
|
+
|
|
2472
|
+
// move the cells down if there is an overlap and we are in static mode
|
|
2473
|
+
if (this.options.collision.wait_for_mouseup) {
|
|
2474
|
+
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
|
|
2475
|
+
if (this.is_widget(tcol, trow)) {
|
|
2476
|
+
// get number of cells to move
|
|
2477
|
+
var destinyRow = this.placeholder_grid_data.row + this.placeholder_grid_data.size_y;
|
|
2478
|
+
|
|
2448
2479
|
var currentOverlappedRow = parseInt(this.gridmap[tcol][trow][0].getAttribute('data-row'));
|
|
2449
2480
|
var cellsToMove = destinyRow - currentOverlappedRow;
|
|
2450
|
-
this.move_widget_down(this.is_widget(tcol, trow), cellsToMove);
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2481
|
+
var failed = !this.move_widget_down(this.is_widget(tcol, trow), cellsToMove);
|
|
2482
|
+
if (failed) {
|
|
2483
|
+
this.set_placeholder(this.placeholder_grid_data.el.coords().grid.col, this.placeholder_grid_data.el.coords().grid.row);
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2455
2489
|
|
|
2456
2490
|
this.cells_occupied_by_player = this.get_cells_occupied(this.placeholder_grid_data);
|
|
2457
2491
|
|
|
@@ -3231,9 +3265,7 @@
|
|
|
3231
3265
|
*/
|
|
3232
3266
|
fn.is_empty = function (col, row) {
|
|
3233
3267
|
if (typeof this.gridmap[col] !== 'undefined') {
|
|
3234
|
-
if (
|
|
3235
|
-
this.gridmap[col][row] === false
|
|
3236
|
-
) {
|
|
3268
|
+
if (!this.gridmap[col][row]) {
|
|
3237
3269
|
return true;
|
|
3238
3270
|
}
|
|
3239
3271
|
return false;
|
|
@@ -3301,7 +3333,15 @@
|
|
|
3301
3333
|
return false;
|
|
3302
3334
|
}
|
|
3303
3335
|
|
|
3336
|
+
// Consider player cell as not occupied (i.e. awailable for swap) if it is occupied by player
|
|
3337
|
+
if (this.is_player(col, row)) {
|
|
3338
|
+
return false;
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3304
3341
|
if (this.gridmap[col][row]) {
|
|
3342
|
+
if(this.options.ignore_self_occupied) {
|
|
3343
|
+
return this.$player.data() !== $(this.gridmap[col][row]).data();
|
|
3344
|
+
}
|
|
3305
3345
|
return true;
|
|
3306
3346
|
}
|
|
3307
3347
|
return false;
|
|
@@ -3925,6 +3965,10 @@
|
|
|
3925
3965
|
|
|
3926
3966
|
el_grid_data = $widget.coords().grid;
|
|
3927
3967
|
actual_row = el_grid_data.row;
|
|
3968
|
+
if (actual_row + ($widget.coords().grid.size_y - 1) + y_units > this.options.max_rows)
|
|
3969
|
+
{
|
|
3970
|
+
return false;
|
|
3971
|
+
}
|
|
3928
3972
|
moved = [];
|
|
3929
3973
|
y_diff = y_units;
|
|
3930
3974
|
|
|
@@ -3932,24 +3976,32 @@
|
|
|
3932
3976
|
return false;
|
|
3933
3977
|
}
|
|
3934
3978
|
|
|
3979
|
+
this.failed = false;
|
|
3935
3980
|
if ($.inArray($widget, moved) === -1) {
|
|
3936
3981
|
|
|
3937
3982
|
var widget_grid_data = $widget.coords().grid;
|
|
3938
3983
|
var next_row = actual_row + y_units;
|
|
3939
3984
|
var $next_widgets = this.widgets_below($widget);
|
|
3940
3985
|
|
|
3941
|
-
this.remove_from_gridmap(widget_grid_data);
|
|
3986
|
+
//this.remove_from_gridmap(widget_grid_data);
|
|
3942
3987
|
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3988
|
+
$next_widgets.each($.proxy(function (i, widget) {
|
|
3989
|
+
if (this.failed !== true) {
|
|
3990
|
+
var $w = $(widget);
|
|
3991
|
+
var wd = $w.coords().grid;
|
|
3992
|
+
var tmp_y = this.displacement_diff(
|
|
3993
|
+
wd, widget_grid_data, y_diff);
|
|
3948
3994
|
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3995
|
+
if (tmp_y > 0) {
|
|
3996
|
+
this.failed = this.move_widget_down($w, tmp_y) === false;
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3952
3999
|
}, this));
|
|
4000
|
+
if (this.failed)
|
|
4001
|
+
{
|
|
4002
|
+
return false;
|
|
4003
|
+
}
|
|
4004
|
+
this.remove_from_gridmap(widget_grid_data);
|
|
3953
4005
|
|
|
3954
4006
|
widget_grid_data.row = next_row;
|
|
3955
4007
|
this.update_widget_position(widget_grid_data, $widget);
|
|
@@ -3958,6 +4010,7 @@
|
|
|
3958
4010
|
|
|
3959
4011
|
moved.push($widget);
|
|
3960
4012
|
}
|
|
4013
|
+
return true;
|
|
3961
4014
|
};
|
|
3962
4015
|
|
|
3963
4016
|
|
|
@@ -4976,7 +5029,7 @@
|
|
|
4976
5029
|
};
|
|
4977
5030
|
|
|
4978
5031
|
fn.get_num_widgets = function () {
|
|
4979
|
-
return this.$widgets.
|
|
5032
|
+
return this.$widgets.length;
|
|
4980
5033
|
};
|
|
4981
5034
|
|
|
4982
5035
|
/**
|
|
@@ -5010,6 +5063,34 @@
|
|
|
5010
5063
|
this.drag_api.set_limits((this.cols * this.min_widget_width) + ((this.cols + 1) * this.options.widget_margins[0]));
|
|
5011
5064
|
}
|
|
5012
5065
|
};
|
|
5066
|
+
|
|
5067
|
+
fn.set_new_num_rows = function (rows) {
|
|
5068
|
+
var max_rows = this.options.max_rows;
|
|
5069
|
+
|
|
5070
|
+
var actual_rows = this.$widgets.map(function () {
|
|
5071
|
+
return $(this).attr('data-row');
|
|
5072
|
+
}).get();
|
|
5073
|
+
|
|
5074
|
+
actual_rows.length || (actual_rows = [0]);
|
|
5075
|
+
|
|
5076
|
+
var min_rows = Math.max.apply(Math, actual_rows);
|
|
5077
|
+
|
|
5078
|
+
this.rows = Math.max(min_rows, rows, this.options.min_rows);
|
|
5079
|
+
|
|
5080
|
+
if (max_rows !== Infinity && (max_rows < min_rows || max_rows < this.rows)) {
|
|
5081
|
+
max_rows = this.rows;
|
|
5082
|
+
}
|
|
5083
|
+
this.min_rows = min_rows;
|
|
5084
|
+
this.max_rows = max_rows;
|
|
5085
|
+
this.options.max_rows = max_rows;
|
|
5086
|
+
var height = (this.rows * this.min_widget_height) + ((this.rows + 1) * this.options.widget_margins[1]);
|
|
5087
|
+
|
|
5088
|
+
if (this.drag_api) {
|
|
5089
|
+
this.drag_api.options.container_height = height;
|
|
5090
|
+
}
|
|
5091
|
+
this.container_height = height;
|
|
5092
|
+
this.generate_faux_grid(this.rows, this.cols);
|
|
5093
|
+
};
|
|
5013
5094
|
|
|
5014
5095
|
|
|
5015
5096
|
/**
|