<commit_before>'use strict';


angular.module('webActivitiesApp.toolbar', [])

.service('ToolbarService', ['$rootScope','framework', '$q', function($rootScope, framework, $q) {
	
	
	var toolbarActions = [];
	
	
	framework.uiCommunicator.on('displayActivity', function(event, o) {
		showActivityActions(o.activity);
	});
	
	framework.uiCommunicator.on('hideActivity', function(event, o) {
		hideActivityActions(o.activity);
	});
	
	framework.uiCommunicator.on('destroyActivity', function(event, o) {
		
	});
	
	var showActivityActions = function(activity) {
		$.each(toolbarActions,function(i,o) {
			if (o.activityId && o.activityId==activity.instanceId) {
				o.hide=false;
			}
		});
	};
	
	var hideActivityActions = function(activity) {
		$.each(toolbarActions,function(i,o) {
			if (o.activityId && o.activityId==activity.instanceId) {
				o.hide=true;
			}
		});
	};

	var bus = framework.bus.createBus();
	
	//utility method to sync an array spostare su Bus
	var syncTopic = function(topicName,arrayTosync,onChange) {
		bus.subscribeTopic(topicName, function(added,removed) {
			$.each(added,function(i,a) {
				arrayTosync.push(a);
			});
			$.each(removed,function(i,a) {
				var index = toolbarActions.indexOf(a);
				if (index!=-1) {
					arrayTosync.splice(index,1);
				}
			});
			onChange();
		});
	};
	
	syncTopic("com.newt.system.toolbar.actions",toolbarActions,function() {
		$rootScope.$apply();
	});
	
	return {
		toolbarActions : toolbarActions
	};
	
}])

.controller('ToolbarCtrl', [ '$rootScope', '$scope', 'framework', '$q', 'ToolbarService', function($rootScope, $scope, framework, $q, ToolbarService) {
	
	// Functions
	$scope.activityStack = function() {
		if (framework.getActivityStack() == null) {
			return [];
		}
		var clone = framework.getActivityStack().slice(0);
		return clone.reverse();
	};
	
	$scope.toolbarActions = ToolbarService.toolbarActions;
	$scope.maxBreadcrumbSize = 3;
	
	
}])

//END
;<commit_msg>Rimesso apposto merge (parziale)<commit_after>'use strict';


angular.module('webActivitiesApp.toolbar', [])

.service('ToolbarService', ['$rootScope','framework', '$q', function($rootScope, framework, $q) {
	
	var toolbarActionsPubs = [];
	
	framework.uiCommunicator.on('displayActivity', function(event, o) {
		showActivityActions(o.activity);
	});
	
	framework.uiCommunicator.on('hideActivity', function(event, o) {
		hideActivityActions(o.activity);
	});
	
	var showActivityActions = function(activity) {
		var activityId = activity.instanceId;
		$.each(toolbarActionsPubs,function(i,o) {
			if (o.publisherId && o.publisherId===activityId) {
				o.obj.hide=false;
			}
		});
	};
	
	var hideActivityActions = function(activity) {
		var activityId = activity.instanceId;
		$.each(toolbarActionsPubs,function(i,o) {
			if (o.publisherId && o.publisherId===activityId) {
				o.obj.hide=true;
			}
		});
	};
	
	framework.internalBus().syncTopic("com.newt.system.toolbar.actions",toolbarActionsPubs,function() {
		$rootScope.$apply();
	},true);
	
	return {
		toolbarActions : toolbarActionsPubs
	};
	
}])

.controller('ToolbarCtrl', [ '$rootScope', '$scope', 'framework', '$q', 'ToolbarService', function($rootScope, $scope, framework, $q, ToolbarService) {
	
	// Functions
	$scope.activityStack = function() {
		if (framework.getActivityStack() == null) {
			return [];
		}
		var clone = framework.getActivityStack().slice(0);
		return clone.reverse();
	};
	
	$scope.toolbarActions = ToolbarService.toolbarActions;
	$scope.maxBreadcrumbSize = 3;
	
}])

//END
;


{'fraction_non_alphanumeric': 0.1710863986313088, 'fraction_numerical': 0.001710863986313088, 'mean_word_length': 4.639871382636656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7528006', 'n_tokens_mistral': 1296, 'n_tokens_neox': 1148, 'n_words': 176}