<commit_before>var isAndroid = (Ti.Platform.osname == 'android');

var NAVBAR_HEIGHT = 44;
var TAB_HEIGHT = 54;

var colors = {
	navBackground : '#d5d5d5',
	shade1 : '#aeaeae',
	shade2 : '#c8c8c8',
	titleColor : 'white',
	titleColorOffset : 'black'
};

// An object that understands how to watch properties
var SmartObject = function() {
	return this;
};

SmartObject.prototype.watch = function(prop, handler) {
	var oldval = this[prop], newval = oldval, getter = function() {
		return newval;
	};
	var setter = function(val) {
		oldval = newval;
		return newval = handler.call(this, prop, oldval, val);
	};
	if (
	delete this[prop]) {// can't watch constants
		if (SmartObject.defineProperty) {// ECMAScript 5
			SmartObject.defineProperty(this, prop, {
				get : getter,
				set : setter,
				enumerable : false,
				configurable : true
			});
		} else if (SmartObject.prototype.__defineGetter__ && SmartObject.prototype.__defineSetter__) {// legacy
			SmartObject.prototype.__defineGetter__.call(this, prop, getter);
			SmartObject.prototype.__defineSetter__.call(this, prop, setter);
		}
	}
};

// object.unwatch
SmartObject.prototype.unwatch = function(prop) {
	var val = this[prop];
	delete this[prop];
	// remove accessors
	this[prop] = val;
};

// Propercase for Getters and Setters
function toProperCase(str) {
	return str.replace(/\w\S*/g, function(txt) {
		return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
	});
}

var navBarProperties = ['barColor', 'title', 'titleControl', 'barImage', 'rightNavButton', 'leftNavButton'];

var createBackButton = function(title) {

	var button = Ti.UI.createButton({
		title : title,
		backgroundImage : '/images/backbutton.png'
	});
	return button;
};

var defaultButtonStyles = {
	title : "",
	image : "",
	backgroundImage : "",
	width : 60,
	height : Ti.UI.FILL,
	borderWidth : 0,
	backgroundColor : 'transparent',
	font : {
		fontSize : 10,
		fontWeight : 'bold'
	},
	color : 'white'
};

var applyButtonStyles = function(button, newButton) {
	for (x in defaultButtonStyles) {
		if (newButton[x]) {
			button[x] = newButton[x];
		} else {
			button[x] = defaultButtonStyles[x];
		}
	}
};

var XNavBar = function(params) {

	var self = this;

	var navBar = Ti.UI.createView({
		height : NAVBAR_HEIGHT,
		top : 0
	});

	var title = Ti.UI.createLabel({
		textAlign : 'center',
		color : colors.titleColor,
		font : {
			fontSize : 18
		},
		text : params.title
	});

	var titleShadow = Ti.UI.createLabel({
		textAlign : 'center',
		color : colors.titleColorOffset,
		top : -2,
		left : 3,
		bottom : 0,
		right : 0,
		font : {
			fontSize : 18
		},
		text : params.title,
		opacity : 0.35
	});

	var rightNavButton = Ti.UI.createButton(defaultButtonStyles);
	rightNavButton.right = 0;

	rightNavButton.addEventListener('click', function() {
		if (self.rightNavButton) {
			self.rightNavButton.fireEvent('click');
		}
	});

	var leftNavButton = Ti.UI.createButton(defaultButtonStyles);
	leftNavButton.left = 0;

	leftNavButton.addEventListener('click', function() {
		if (self.leftNavButton) {
			self.leftNavButton.fireEvent('click');
		}
	});

	// titleControl (will be a view of some sort)
	var titleControl;

	self._view = navBar;
	navBar.add(titleShadow);
	navBar.add(title);
	navBar.add(rightNavButton);
	navBar.add(leftNavButton)

	self.watch('visible', function(id, oldval, newval) {
		navBar.visible = newval;
		return newval;
	});

	self.watch('title', function(id, oldval, newval) {
		title.text = newval;
		titleShadow.text = newval;
		return newval;
	});

	self.watch('barColor', function(id, oldval, newval) {
		if (!newval) {
			newval = colors.navBackground;
		}
		navBar.backgroundColor = newval;
		return newval;
	});

	self.barColor = colors.navBackground;

	self.watch('barImage', function(id, oldval, newval) {
		navBar.backgroundImage = newval;<commit_msg>Make navButtons resize correctly and stayed centered<commit_after>var isAndroid = (Ti.Platform.osname == 'android');

var NAVBAR_HEIGHT = 44;
var TAB_HEIGHT = 54;

var colors = {
	navBackground : '#d5d5d5',
	shade1 : '#aeaeae',
	shade2 : '#c8c8c8',
	titleColor : 'white',
	titleColorOffset : 'black'
};

// An object that understands how to watch properties
var SmartObject = function() {
	return this;
};

SmartObject.prototype.watch = function(prop, handler) {
	var oldval = this[prop], newval = oldval, getter = function() {
		return newval;
	};
	var setter = function(val) {
		oldval = newval;
		return newval = handler.call(this, prop, oldval, val);
	};
	if (
	delete this[prop]) {// can't watch constants
		if (SmartObject.defineProperty) {// ECMAScript 5
			SmartObject.defineProperty(this, prop, {
				get : getter,
				set : setter,
				enumerable : false,
				configurable : true
			});
		} else if (SmartObject.prototype.__defineGetter__ && SmartObject.prototype.__defineSetter__) {// legacy
			SmartObject.prototype.__defineGetter__.call(this, prop, getter);
			SmartObject.prototype.__defineSetter__.call(this, prop, setter);
		}
	}
};

// object.unwatch
SmartObject.prototype.unwatch = function(prop) {
	var val = this[prop];
	delete this[prop];
	// remove accessors
	this[prop] = val;
};

// Propercase for Getters and Setters
function toProperCase(str) {
	return str.replace(/\w\S*/g, function(txt) {
		return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
	});
}

var navBarProperties = ['barColor', 'title', 'titleControl', 'barImage', 'rightNavButton', 'leftNavButton'];

var createBackButton = function(title) {

	var button = Ti.UI.createButton({
		title : title,
		backgroundImage : '/images/backbutton.png'
	});
	return button;
};

var defaultButtonStyles = {
	title : "",
	image : "",
	backgroundImage : "",
	width : Ti.UI.FILL,
	height : Ti.UI.FILL,
	borderWidth : 0,
	backgroundColor : 'transparent',
	font : {
		fontSize : 10,
		fontWeight : 'bold'
	},
	color : 'white'
};

var applyButtonStyles = function(button, newButton) {
	for (x in defaultButtonStyles) {
		if (newButton[x]) {
			button[x] = newButton[x];
		} else {
			button[x] = defaultButtonStyles[x];
		}
	}
};

var XNavBar = function(params) {

	var self = this;

	var navBar = Ti.UI.createView({
		height : NAVBAR_HEIGHT,
		top : 0
	});

	var title = Ti.UI.createLabel({
		textAlign : 'center',
		color : colors.titleColor,
		font : {
			fontSize : 18
		},
		text : params.title
	});

	var titleShadow = Ti.UI.createLabel({
		textAlign : 'center',
		color : colors.titleColorOffset,
		top : -2,
		left : 3,
		bottom : 0,
		right : 0,
		font : {
			fontSize : 18
		},
		text : params.title,
		opacity : 0.35
	});

	var rightNavContainer = Ti.UI.createView({
		right : 0,
		width : 60
	});

	var rightNavButton = Ti.UI.createButton(defaultButtonStyles);
	rightNavContainer.add(rightNavButton);

	rightNavButton.addEventListener('click', function() {
		if (self.rightNavButton) {
			self.rightNavButton.fireEvent('click');
		}
	});

	var leftNavContainer = Ti.UI.createView({
		left : 0,
		width : 60
	});
	var leftNavButton = Ti.UI.createButton(defaultButtonStyles);
	leftNavContainer.add(leftNavButton);

	leftNavButton.addEventListener('click', function() {
		if (self.leftNavButton) {
			self.leftNavButton.fireEvent('click');
		}
	});

	// titleControl (will be a view of some sort)
	var titleControl;

	self._view = navBar;
	navBar.add(titleShadow);
	navBar.add(title);
	navBar.add(rightNavContainer);
	navBar.add(leftNavContainer)

	self.watch('visible', function(id, oldval, newval) {
		navBar.visible = newval;
		return newval;
	});

	self.watch('title', function(id, oldval, newval) {
		title.text = newval;
		titleShadow.text = newval;
		return newval;
	});

	self.watch('barColor', function(id, oldval, newval) {
		if (!newval) {
			newval = colors.navBackground;
		}
		navBar.backgroundColor = newval;
		return newval;
	});

	self.barColor = colors.navBackground;

	self.watch('barImage', function(id, oldval, newval) {
		navBar.backgroundImage = newval;
{'fraction_non_alphanumeric': 0.14520617252719453, 'fraction_numerical': 0.00885403491019479, 'mean_word_length': 4.004430379746835, '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': '1627108', 'n_tokens_mistral': 3011, 'n_tokens_neox': 2752, 'n_words': 597}