<commit_before>dojo.provide("dijit.ProgressBar");

dojo.require("dojo.fx");
dojo.require("dojo.number");

dojo.require("dijit.base.Widget");
dojo.require("dijit.base.TemplatedWidget");
dojo.require("dijit.util.sniff");

dojo.declare(
	"dijit.ProgressBar",
	[dijit.base.Widget, dijit.base.TemplatedWidget],
	null,
	{
		// summary:
		// a progress widget, with some calculation and server polling capabilities
		//
		// description: 
		// (implementation) four overlapped divs:
		// (1) lower z-index
		// (4) higher z-index
		// back and front percent label have the same content: when the vertical line (*)
		// partially hides the backLabel, the frontLabel becomes visible
		// 
		//  ___________________________(1)_domNode____________________________________
		// |__(3)_internalProgress____________                                        |
		// |                                  | <--- (*)                              |
		// |     (4) frontLabel        | (2) backLabel                  |
		// |__________________________________|                                       |
		// |__________________________________________________________________________| 
		//
		// usage:
		// <div dojoType="ProgressBar"
		//   duration="..."
		//   places="0"
		//   annotate="true|false" orientation="vertical" 
		//   progress="..." maximum="..."></div>
	
		// progress: String (Percentage or Number)
		// initial progress value. 
		// with "%": percentual value, 0% <= progress <= 100%
		// or without "%": absolute value, 0 <= progress <= maximum
		progress: "0",

		// maximum: Float
		// max sample number
		maximum: 100,

		// orientation: String
		// whether bar grows along the x-axis (default) or y- axis (vertical)
		orientation: "",

		// annotate: Boolean
		// if true, the percent label is visible
		annotate: false,

		// places: Number
		// number of places to show in values; 0 by default
		places: 0,

		// duration: Integer
		// duration of the animation
		duration: 1000,

		templatePath: dojo.moduleUrl("dijit", "templates/ProgressBar.html"),		

		// public functions
		postCreate: function(){
			dijit.ProgressBar.superclass.postCreate.apply(this, arguments);
			if(this.orientation == "vertical"){
//TODO: if !this.domNode.className?
				this.domNode.className += " "+"dijitProgressBarVertical";
				this._dimension = "height";
			}else{
				this._dimension = "width";
			}
			//TODO: can this be accomplished in the template layout?
			this.frontLabel.style.width = dojo.getComputedStyle(this.domNode).width; 
			this.update();
		},

		update: function(/*Object?*/attributes){
			// summary: update progress information
			//
			// attributes: may provide progress and/or maximum properties on this parameter,
			//	see attribute specs for details.
			dojo.mixin(this, attributes||{});
			var percent;
			if(String(this.progress).indexOf("%") != -1){
				percent = Math.min(parseFloat(this.progress)/100, 1);
				this.progress = percent * this.maximum;
			}else{
				this.progress = Math.min(this.progress, this.maximum);
				percent = this.progress / this.maximum;
			}

			if(!this._animationStopped){return;}

			this._setWaiValueNow(this.report(percent));

			var pixels = percent * parseInt(dojo.getComputedStyle(this.domNode)[this._dimension]);
			this.internalProgress.style[this._dimension] = pixels + 'px';

			var display = this.annotate ? "block" : "none";
			dojo.forEach(["front", "back"], function(name){
				var labelNode = this[name+"Label"];
				var text = this.report(percent);
				if(labelNode.firstChild){
					labelNode.firstChild.nodeValue = text;
				}else{
					labelNode.appendChild(dojo.doc.createTextNode(text));
				}
				dojo.style(labelNode, "display", display);

// move this out of update, or perhaps replace with css or template layout?
				var dim = dojo.contentBox(labelNode);
				var labelBottom = (parseInt(dojo.getComputedStyle(this.domNode).height) - dim.h)/2;
				labelNode.style.bottom = labelBottom + 'px';
			}, this);

			this.onChange();
		},

		report: function(/*float*/percent){
			// Generates message to overlay, shown if annotate is true; may be overridden by user
			return dojo.number.format(percent, {type: "percent", places: this.places, locale: this.lang});
		},

		_animationStopped: true,

		_setupAnimation: function(){
			var self = this;
			this._animation = dojo.fx.slideTo({node: this.internalProgress,
				top: 0,
				left: parseInt(dojo.getComputedStyle(this.domNode).width)-parseInt(dojo.getComputedStyle(this.internalProgress).width),
				duration: this.duration});<commit_msg>refs #3071 #2839  One possible workaround for the arrow-image problem (3071), as well as Tundraification of the Progress bar.  See those bugs for more details<commit_after>dojo.provide("dijit.ProgressBar");

dojo.require("dojo.fx");
dojo.require("dojo.number");

dojo.require("dijit.base.Widget");
dojo.require("dijit.base.TemplatedWidget");
dojo.require("dijit.util.sniff");

dojo.declare(
	"dijit.ProgressBar",
	[dijit.base.Widget, dijit.base.TemplatedWidget],
	null,
	{
		// summary:
		// a progress widget, with some calculation and server polling capabilities
		//
		// description: 
		// (implementation) four overlapped divs:
		// (1) lower z-index
		// (4) higher z-index
		// empty and full percent label have the same content: when the vertical line (*)
		// partially hides the emptyLabel, the fullLabel becomes visible
		// 
		//  ___________________________(1)_domNode____________________________________
		// |__(3)_internalProgress____________                                        |
		// |                                  | <--- (*)                              |
		// |            (4) fullLabel        | (2) emptyLabel                         |
		// |__________________________________|                                       |
		// |__________________________________________________________________________| 
		//
		// usage:
		// <div dojoType="ProgressBar"
		//   duration="..."
		//   places="0"
		//   annotate="true|false" orientation="vertical" 
		//   progress="..." maximum="..."></div>
	
		// progress: String (Percentage or Number)
		// initial progress value. 
		// with "%": percentual value, 0% <= progress <= 100%
		// or without "%": absolute value, 0 <= progress <= maximum
		progress: "0",

		// maximum: Float
		// max sample number
		maximum: 100,

		// orientation: String
		// whether bar grows along the x-axis (default) or y- axis (vertical)
		orientation: "",

		// annotate: Boolean
		// if true, the percent label is visible
		annotate: false,

		// places: Number
		// number of places to show in values; 0 by default
		places: 0,

		// duration: Integer
		// duration of the animation
		duration: 1000,

		templatePath: dojo.moduleUrl("dijit", "templates/ProgressBar.html"),		

		// public functions
		postCreate: function(){
			dijit.ProgressBar.superclass.postCreate.apply(this, arguments);
			if(this.orientation == "vertical"){
//TODO: if !this.domNode.className?
				this.domNode.className += " "+"dijitProgressBarVertical";
				this._dimension = "height";
			}else{
				this._dimension = "width";
			}
			//TODO: can this be accomplished in the template layout?
			// MOW: don't think so because it needs to be set to the absolute size
			//		of the dom node, not the size of the containing element (the full part)
			this.fullLabel.style.width = dojo.getComputedStyle(this.domNode).width; 
			this.update();
		},

		update: function(/*Object?*/attributes){
			// summary: update progress information
			//
			// attributes: may provide progress and/or maximum properties on this parameter,
			//	see attribute specs for details.
			dojo.mixin(this, attributes||{});
			var percent;
			if(String(this.progress).indexOf("%") != -1){
				percent = Math.min(parseFloat(this.progress)/100, 1);
				this.progress = percent * this.maximum;
			}else{
				this.progress = Math.min(this.progress, this.maximum);
				percent = this.progress / this.maximum;
			}

			if(!this._animationStopped){return;}

			this._setWaiValueNow(this.report(percent));

			var pixels = percent * parseInt(dojo.getComputedStyle(this.domNode)[this._dimension]);
			this.internalProgress.style[this._dimension] = pixels + 'px';

			var display = this.annotate ? "block" : "none";
			dojo.forEach(["full", "empty"], function(name){
				var labelNode = this[name+"Label"];
				var text = this.report(percent);
				if(labelNode.firstChild){
					labelNode.firstChild.nodeValue = text;
				}else{
					labelNode.appendChild(dojo.doc.createTextNode(text));
				}
				dojo.style(labelNode, "display", display);

// move this out of update, or perhaps replace with css or template layout?
				var dim = dojo.contentBox(labelNode);
				var labelBottom = (parseInt(dojo.getComputedStyle(this.domNode).height) - dim.h)/2;
				labelNode.style.bottom = labelBottom + 'px';
			}, this);

			this.onChange();
		},

		report: function(/*float*/percent){
			// Generates message to overlay, shown if annotate is true; may be overridden by user
			return dojo.number.format(percent, {type: "percent", places: this.places, locale: this.lang});
		},

		_animationStopped: true,

		_setupAnimation: function(){
			var self = this;
			this._animation = dojo.fx.slideTo({node: this.internalProgress,
				top: 0,
				left: parseInt(dojo.getComputedStyle(this.domNode).width)-parseInt(dojo.getComputedStyle(this.internalProgress).width),
				duration: this.duration});
{'fraction_non_alphanumeric': 0.13859704977183487, 'fraction_numerical': 0.0074286320704658815, 'mean_word_length': 3.0515907136715392, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5580555', 'n_tokens_mistral': 3229, 'n_tokens_neox': 2737, 'n_words': 681}