Skip to content

Commit

Permalink
ICL-22910 Multiple packery initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatsov committed Oct 23, 2019
1 parent 7b7b0e2 commit 6e6bf63
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 55 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ bower_components/
_includes/
_site/
coverage/

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
87 changes: 61 additions & 26 deletions dist/packery.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* angular-packery
* http://github.com/sungard-labs/angular-packery
* Version: 1.0.4
* Version: 1.0.6
* License: MIT
*/

Expand All @@ -20,6 +20,7 @@
draggable: true,
handle: '.widget-header',
timeout: 8000,
instantiatedEventName: 'packeryInstantiated',
acceptedAttributes: [
'containerStyle',
'columnWidth',
Expand All @@ -32,13 +33,14 @@
'itemSelector',
'rowHeight',
'percentPosition',
'transitionDuration'
'transitionDuration',
'instantiatedEventName'
]
};

var packeryService = function ($rootScope) {
var created = [],
packeryObj;
packeryObj;

var uniqueId = function (obj, list) {
for (var i = 0; i < list.length; i++) {
Expand All @@ -61,7 +63,7 @@
packery: packeryObj
});
el.data('Packery', packeryObj);
$rootScope.$emit('packeryInstantiated', packeryObj);
$rootScope.$emit(opts.instantiatedEventName, packeryObj);
}

return packeryObj;
Expand Down Expand Up @@ -101,14 +103,14 @@
angular.element(handle).on('mouseenter', function () {
el.addClass('hovered');
}).
on('mouseleave', function () {
el.removeClass('hovered');
});
on('mouseleave', function () {
el.removeClass('hovered');
});
};

this.createAttrObj = function (scope) {
var obj = {},
attrs = config.acceptedAttributes;
attrs = config.acceptedAttributes;

for (var i = 0; i < attrs.length; i++) {
var attr = scope[attrs[i]];
Expand Down Expand Up @@ -157,7 +159,11 @@
controller: 'PackeryController',
transclude: true,
replace: true,
templateUrl: 'template/packery/packery.html',
templateUrl: function (element, attrs) {
var template = attrs.template || 'packery';

return 'template/packery/' + template + '.html';
},
scope: {
containerStyle: '=?', // Type: Object, null
columnWidth: '@?', // Type: Number, Selector String
Expand All @@ -171,9 +177,10 @@
rowHeight: '@?', // Type: Number, Selector String
percentPosition: '@?', // Type: Boolean
transitionDuration: '@?', // Type: String
instantiatedEventName: '@?', // Type: String

draggable: '@?', // Type: Boolean
handle: '@?' // Type: Boolean
handle: '@?' // Type: Selector String

// Let's come back to this one...
// stamp: '@?',
Expand All @@ -189,6 +196,7 @@
scope.percentPosition = scope.percentPosition || config.percentPosition;
scope.draggable = angular.isDefined(scope.draggable) ? scope.draggable : config.draggable;
scope.handle = scope.handle || config.handle;
scope.instantiatedEventName = scope.instantiatedEventName || config.instantiatedEventName;

// Quick fix so 'false' strings don't evaluate to true
// @TODO: Check for attribute itself, not value of attribute
Expand Down Expand Up @@ -229,6 +237,15 @@
};
};

var stackPackeryObjectTemplateDirective = function () {
return {
restrict: 'EA',
templateUrl: 'template/packery/stack-packery-object.html',
transclude: true,
replace: true
};
};

var packeryObjectDirective = function ($timeout) {
return {
require: '^packery',
Expand All @@ -252,29 +269,47 @@

var packeryTemplates = function ($templateCache) {
$templateCache
.put('template/packery/packery.html', [
'<div class="packery-wrapper">',
'<div class="packery-sizer"></div>',
'<div class="gutter-sizer"></div>',
'<div class="packery-container" ng-transclude></div>',
'</div>'
].join(''));
.put('template/packery/packery.html', [
'<div class="packery-wrapper">',
'<div class="packery-sizer"></div>',
'<div class="gutter-sizer"></div>',
'<div class="packery-container" ng-transclude></div>',
'</div>'
].join(''));

$templateCache.put('template/packery/packery-object.html',
'<div class="packery-object" ng-transclude></div>'
'<div class="packery-object" ng-transclude></div>'
);

$templateCache
.put('template/packery/stack-packery.html', [
'<div class="stack-packery-wrapper">',
'<div class="stack-packery-sizer"></div>',
'<div class="stack-gutter-sizer"></div>',
'<div class="stack-packery-container" ng-transclude></div>',
'</div>'
].join(''));

$templateCache.put('template/packery/stack-packery-object.html',
'<div class="stack-packery-object" ng-transclude></div>'
);
};


angular
.module('angular-packery', moduleDependencies)
.constant('packeryConfig', moduleConfig)
.service('packeryService', ['$rootScope', packeryService])
.controller('PackeryController', ['$rootScope', 'packeryConfig', 'packeryService', packeryController])
.directive('packery', ['packeryConfig', 'packeryService', packeryDirective])
.directive('packeryObject', [packeryObjectTemplateDirective])
.directive('packeryObject', ['$timeout', packeryObjectDirective]);
.module('angular-packery', moduleDependencies)
.constant('packeryConfig', moduleConfig)
.service('packeryService', ['$rootScope', packeryService])
.controller('PackeryController', ['$rootScope', 'packeryConfig', 'packeryService', packeryController])
.directive('packery', ['packeryConfig', 'packeryService', packeryDirective])
.directive('packeryObject', [packeryObjectTemplateDirective])
.directive('packeryObject', ['$timeout', packeryObjectDirective])

.directive('stackPackery', ['packeryConfig', 'packeryService', packeryDirective])
.directive('stackPackeryObject', [stackPackeryObjectTemplateDirective])
.directive('stackPackeryObject', ['$timeout', packeryObjectDirective]);

angular
.module('packeryTemplates', []).run(['$templateCache', packeryTemplates]);
.module('packeryTemplates', []).run(['$templateCache', packeryTemplates]);

})();
4 changes: 2 additions & 2 deletions dist/packery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-packery",
"version": "1.0.5",
"version": "1.0.6",
"author": "http://github.com/sungard-labs/angular-packery/graphs/contributors",
"homepage": "http://github.com/sungard-labs/angular-packery",
"repository": {
Expand Down
Loading

0 comments on commit 6e6bf63

Please sign in to comment.