<commit_before>angular.module('progressButton', [])
	.directive('progressButton', function() {
		return {
			scope: true,
			link: function(scope, element, attrs) {
				scope.$parent[attrs.progressButton] = scope

				scope.progressStart = function() {
					var button = element
					
					lastProgress = new Date().getTime()

					if(element.hasClass('in-progress')) {
						return
					}

					button.on('progress', function() {
						lastProgress = new Date().getTime()
					})

					var interval = window.setInterval(function() {
						if(new Date().getTime() > (2000 + lastProgress)) {
							scope.progressIncrement(0.05)
						}
					}, 500)

					button.on('progress-finish', function() {
						window.clearInterval(interval)
					})

					scope.progressIncrement(0.1)
				}

				scope.progressFinish = function() {
					scope.progressSet(1)
				}

				scope.progressIncrement = function(value) {
					value = value || 0.1

					emitEvent(element, 'progress', { value: value })
				}

				scope.progressSet = function(value) {
					var finish = false

					if(value >= 1) finish = true

					emitEvent(element, 'progress', { value: value, absolute: true, finish: finish })
				}

				scope.progressTimed = function(seconds, callback) {
					var button = element
					var bar = angular.element(button[0].querySelectorAll('.tz-bar'))

					if(button.hasClass('in-progress')) {
						return
					}

					bar.css('transition', seconds + 's linear')
					scope.progressSet(0.99)

					window.setTimeout(function() {
						bar.css('transition', '')
						scope.progressFinish()

						if(typeof callback === 'function') {
							callback()
						}
					}, seconds * 1000)
				}

				var progressInitialize = function() {
					var button = element
					var progress = 0

					button.addClass('progress-button')

					attrs.progressType = attrs.progressType || 'background-horizontal'
					attrs.loadingText = attrs.loadingText || 'Loading..'
					attrs.finishedText = attrs.finishedText || 'Done!'

					button.attr('data-progress-type', attrs.progressType)
					button.attr('data-loading-text', attrs.loadingText)
					button.attr('data-finished-text', attrs.finishedText)

					button.append(angular.element('<span class="tz-bar ' + attrs.progressType + '">'))
					var bar = angular.element(button[0].querySelectorAll('.tz-bar'))

					button.on('progress', function(e) {
						if(!button.hasClass('in-progress')) {
							bar.css('display', '')
							progress = 0
							button.removeClass('finished').addClass('in-progress')
						}

						if(e.detail.absolute) {
							progress = e.detail.value
						} else {
							progress += e.detail.value
						}

						if(progress >= 1) {
							progress = 1
						}

						if(e.detail.finish) {
							button.removeClass('in-progress').addClass('finished')<commit_msg>Use originalEvent if the event object was modified by jQuery<commit_after>angular.module('progressButton', [])
	.directive('progressButton', function() {
		return {
			scope: true,
			link: function(scope, element, attrs) {
				scope.$parent[attrs.progressButton] = scope

				scope.progressStart = function() {
					var button = element
					
					lastProgress = new Date().getTime()

					if(element.hasClass('in-progress')) {
						return
					}

					button.on('progress', function() {
						lastProgress = new Date().getTime()
					})

					var interval = window.setInterval(function() {
						if(new Date().getTime() > (2000 + lastProgress)) {
							scope.progressIncrement(0.05)
						}
					}, 500)

					button.on('progress-finish', function() {
						window.clearInterval(interval)
					})

					scope.progressIncrement(0.1)
				}

				scope.progressFinish = function() {
					scope.progressSet(1)
				}

				scope.progressIncrement = function(value) {
					value = value || 0.1

					emitEvent(element, 'progress', { value: value })
				}

				scope.progressSet = function(value) {
					var finish = false

					if(value >= 1) finish = true

					emitEvent(element, 'progress', { value: value, absolute: true, finish: finish })
				}

				scope.progressTimed = function(seconds, callback) {
					var button = element
					var bar = angular.element(button[0].querySelectorAll('.tz-bar'))

					if(button.hasClass('in-progress')) {
						return
					}

					bar.css('transition', seconds + 's linear')
					scope.progressSet(0.99)

					window.setTimeout(function() {
						bar.css('transition', '')
						scope.progressFinish()

						if(typeof callback === 'function') {
							callback()
						}
					}, seconds * 1000)
				}

				var progressInitialize = function() {
					var button = element
					var progress = 0

					button.addClass('progress-button')

					attrs.progressType = attrs.progressType || 'background-horizontal'
					attrs.loadingText = attrs.loadingText || 'Loading..'
					attrs.finishedText = attrs.finishedText || 'Done!'

					button.attr('data-progress-type', attrs.progressType)
					button.attr('data-loading-text', attrs.loadingText)
					button.attr('data-finished-text', attrs.finishedText)

					button.append(angular.element('<span class="tz-bar ' + attrs.progressType + '">'))
					var bar = angular.element(button[0].querySelectorAll('.tz-bar'))

					button.on('progress', function(e) {
						e = e.originalEvent || e

						if(!button.hasClass('in-progress')) {
							bar.css('display', '')
							progress = 0
							button.removeClass('finished').addClass('in-progress')
						}

						if(e.detail.absolute) {
							progress = e.detail.value
						} else {
							progress += e.detail.value
						}

						if(progress >= 1) {
							progress = 1
						}

						if(e.detail.finish) {
							button.removeClass('in-progress').addClass('finished')
{'fraction_non_alphanumeric': 0.14698162729658792, 'fraction_numerical': 0.010148731408573928, 'mean_word_length': 2.6948933419521657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1157148', 'n_tokens_mistral': 2393, 'n_tokens_neox': 1653, 'n_words': 299}