tellform/public/modules/forms/base/directives/on-finish-render.client.directive.js

27 lines
846 B
JavaScript
Raw Normal View History

2015-07-06 04:29:05 +00:00
'use strict';
angular.module('forms').directive('onFinishRender', function ($rootScope) {
2015-07-06 04:29:05 +00:00
return {
restrict: 'A',
2015-08-04 21:06:16 +00:00
link: function (scope, element, attrs) {
2016-06-05 00:48:49 +00:00
2015-08-04 21:06:16 +00:00
//Don't do anything if we don't have a ng-repeat on the current element
2015-11-06 17:41:55 +00:00
if(!element.attr('ng-repeat') && !element.attr('data-ng-repeat')){
2015-08-04 21:06:16 +00:00
return;
}
var broadcastMessage = attrs.onFinishRender || 'ngRepeat';
2015-10-30 18:40:02 +00:00
if(scope.$first && !scope.$last) {
2015-08-21 00:17:14 +00:00
scope.$evalAsync(function () {
$rootScope.$broadcast(broadcastMessage+' Started');
2015-07-28 22:29:07 +00:00
});
} else if(scope.$last) {
2015-08-21 00:17:14 +00:00
scope.$evalAsync(function () {
$rootScope.$broadcast(broadcastMessage+' Finished');
2015-07-28 22:29:07 +00:00
});
2015-07-06 04:29:05 +00:00
}
}
};
2015-07-06 04:29:05 +00:00
});