Ext.define('Ext.ux.itemreference.Button', {
	extend: 'Ext.button.Button',
	alias: ['widget.ip2iconbutton', 'widget.ip2IconButton'],

	handleMouseEvents: true,
	listeners: {
		mouseover: function(b) {
			var elm = document.getElementById(b.id + '-btnIconEl');
			if (b.icon == 'edit') {
				Ext.DomHelper.applyStyles(elm, 'background-position-x: -16px;');
			}
			else {
				Ext.DomHelper.applyStyles(elm, 'background-position-x: -15px;');
			}
		},
		mouseout: function(b) {
			var elm = document.getElementById(b.id + '-btnIconEl');
			Ext.DomHelper.applyStyles(elm, 'background-position-x: 0px;');
		}
	},

	initComponent: function() {
		var me = this;

		if (me.icon && Ext.isString(me.icon)) {
			me.iconCls = 'ip2-ux-icon-' + me.icon.toLowerCase();
			if (Ext.isBoolean(me.text)) {
				switch (me.icon.toUpperCase()) {
					case 'ADD':
						me.text = ip2.i18n('add');
						break;
					case 'EDIT':
						me.text = ip2.i18n('update');
						break;
					case 'DELETE':
						me.text = ip2.i18n('delete');
						break;
				}
			}
		}

		if (!me.text || me.text.length == 0) {
			me.width = 20;
			me.scale = 'ip2';
		}

		me.callParent();
	}
});
