|
79 | 79 | this.grid.length = 0; |
80 | 80 | this.grid = null; |
81 | 81 | } |
| 82 | + this.$element = null; |
82 | 83 | }; |
83 | 84 |
|
84 | 85 | /** |
|
557 | 558 |
|
558 | 559 | return function(scope, $elem, attrs, gridster) { |
559 | 560 | gridster.loaded = false; |
| 561 | + gridster.$element = $elem; |
560 | 562 |
|
561 | 563 | scope.gridsterClass = function() { |
562 | 564 | return { |
|
641 | 643 | scope.$watch(function() { |
642 | 644 | return gridster.isMobile; |
643 | 645 | }, function() { |
644 | | - $rootScope.$broadcast('gridster-mobile-changed'); |
| 646 | + $rootScope.$broadcast('gridster-mobile-changed', gridster); |
645 | 647 | }); |
646 | 648 |
|
647 | | - scope.$watch('config.draggable', function() { |
648 | | - $rootScope.$broadcast('gridster-draggable-changed'); |
| 649 | + scope.$watch(function() { |
| 650 | + return gridster.draggable; |
| 651 | + }, function() { |
| 652 | + $rootScope.$broadcast('gridster-draggable-changed', gridster); |
649 | 653 | }, true); |
650 | 654 |
|
651 | | - scope.$watch('config.resizable', function() { |
652 | | - $rootScope.$broadcast('gridster-resizable-changed'); |
| 655 | + scope.$watch(function() { |
| 656 | + return gridster.resizable; |
| 657 | + }, function(resizable) { |
| 658 | + $rootScope.$broadcast('gridster-resizable-changed', gridster); |
653 | 659 | }, true); |
654 | 660 |
|
655 | 661 | var updateHeight = function() { |
656 | 662 | $elem.css('height', (gridster.gridHeight * gridster.curRowHeight) + (gridster.outerMargin ? gridster.margins[0] : -gridster.margins[0]) + 'px'); |
657 | 663 | }; |
658 | 664 |
|
659 | | - scope.$watch('gridster.gridHeight', updateHeight); |
| 665 | + scope.$watch(function() { |
| 666 | + return gridster.gridHeight; |
| 667 | + }, updateHeight); |
660 | 668 |
|
661 | | - scope.$watch('gridster.movingItem', function() { |
| 669 | + scope.$watch(function() { |
| 670 | + return gridster.movingItem; |
| 671 | + }, function() { |
662 | 672 | gridster.updateHeight(gridster.movingItem ? gridster.movingItem.sizeY : 0); |
663 | 673 | }); |
664 | 674 |
|
|
682 | 692 | $elem.addClass('gridster-loaded'); |
683 | 693 | } |
684 | 694 |
|
685 | | - scope.$parent.$broadcast('gridster-resized', [width, $elem[0].offsetHeight]); |
| 695 | + $rootScope.$broadcast('gridster-resized', [width, $elem[0].offsetHeight], gridster); |
686 | 696 | } |
687 | 697 |
|
688 | 698 | // track element width changes any way we can |
|
1562 | 1572 | savedDraggable = gridster.draggable.enabled; |
1563 | 1573 | if (savedDraggable) { |
1564 | 1574 | gridster.draggable.enabled = false; |
1565 | | - scope.$broadcast('gridster-draggable-changed'); |
| 1575 | + scope.$broadcast('gridster-draggable-changed', gridster); |
1566 | 1576 | } |
1567 | 1577 |
|
1568 | 1578 | // Get the current mouse position. |
|
1681 | 1691 | // restore draggable setting to its original state |
1682 | 1692 | if (gridster.draggable.enabled !== savedDraggable) { |
1683 | 1693 | gridster.draggable.enabled = savedDraggable; |
1684 | | - scope.$broadcast('gridster-draggable-changed'); |
| 1694 | + scope.$broadcast('gridster-draggable-changed', gridster); |
1685 | 1695 | } |
1686 | 1696 |
|
1687 | 1697 | mOffX = mOffY = 0; |
|
1926 | 1936 | } |
1927 | 1937 | }); |
1928 | 1938 |
|
1929 | | - scope.$broadcast('gridster-item-initialized', [item.sizeY, item.sizeX, item.getElementSizeY(), item.getElementSizeX()]); |
| 1939 | + scope.$broadcast('gridster-item-initialized', item); |
1930 | 1940 |
|
1931 | 1941 | function positionChanged() { |
1932 | 1942 | // call setPosition so the element and gridster controller are updated |
|
1957 | 1967 | if (changedX || changedY) { |
1958 | 1968 | item.gridster.moveOverlappingItems(item); |
1959 | 1969 | gridster.layoutChanged(); |
| 1970 | + $rootScope.$broadcast('gridster-item-resized', item); |
1960 | 1971 | } |
1961 | | - |
1962 | | - $rootScope.$broadcast('gridster-item-size-changed', item.sizeX, item.sizeY); |
1963 | 1972 | } |
| 1973 | + |
1964 | 1974 | scope.$watch(function() { |
1965 | 1975 | return item.sizeY + ',' + item.sizeX + ',' + item.minSizeX + ',' + item.maxSizeX + ',' + item.minSizeY + ',' + item.maxSizeY; |
1966 | 1976 | }, sizeChanged); |
|
1999 | 2009 |
|
2000 | 2010 | $el.on(whichTransitionEvent(), function() { |
2001 | 2011 | scope.$apply(function() { |
2002 | | - scope.$broadcast('gridster-item-transition-end'); |
| 2012 | + scope.$broadcast('gridster-item-transition-end', item); |
2003 | 2013 | }); |
2004 | 2014 | }); |
2005 | 2015 |
|
|
0 commit comments