Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
kristianmandrup committed Jul 2, 2012
1 parent 1527a50 commit 5b2f718
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 47 deletions.
5 changes: 4 additions & 1 deletion www/Content.js
Expand Up @@ -2,7 +2,7 @@
Ext.define('FriendlyRent.view.search.Content', {
extend: 'Ext.Panel',
alias: 'widget.search_content',
requires: ['FriendlyRent.view.search.criteria.Location', 'FriendlyRent.view.search.criteria.Radius'],
requires: ['FriendlyRent.view.search.criteria.Location', 'FriendlyRent.view.search.criteria.Radius', 'FriendlyRent.view.search.criteria.PropertyType'],
config: {
layout: 'vbox',
items: [
Expand All @@ -12,6 +12,9 @@ Ext.define('FriendlyRent.view.search.Content', {
}, {
xtype: 'search_criteria_radius',
name: 'radius'
}, {
xtype: 'search_criteria_property_type',
name: 'property_type'
}
]
}
Expand Down
10 changes: 10 additions & 0 deletions www/PropertyType.js
@@ -0,0 +1,10 @@

Ext.define('FriendlyRent.view.search.criteria.PropertyType', {
extend: 'Ext.field.SliderText',
alias: 'widget.search_criteria_property_type',
config: {
label: 'Property type',
autoValues: true,
valueMap: ['Any', 'Room', 'Apartment', 'House', 'Independent house', 'House boat']
}
});
4 changes: 2 additions & 2 deletions www/Radius.js
Expand Up @@ -6,9 +6,9 @@ Ext.define('FriendlyRent.view.search.criteria.Radius', {

({
config: {
label: 'Radius',
value: 5,
minValue: 1,
maxValue: 50,
label: 'Radius'
maxValue: 50
}
});
5 changes: 4 additions & 1 deletion www/app/view/search/Content.js
Expand Up @@ -2,7 +2,7 @@
Ext.define('FriendlyRent.view.search.Content', {
extend: 'Ext.Panel',
alias: 'widget.search_content',
requires: ['FriendlyRent.view.search.criteria.Location', 'FriendlyRent.view.search.criteria.Radius'],
requires: ['FriendlyRent.view.search.criteria.Location', 'FriendlyRent.view.search.criteria.Radius', 'FriendlyRent.view.search.criteria.PropertyType'],
config: {
layout: 'vbox',
items: [
Expand All @@ -12,6 +12,9 @@ Ext.define('FriendlyRent.view.search.Content', {
}, {
xtype: 'search_criteria_radius',
name: 'radius'
}, {
xtype: 'search_criteria_property_type',
name: 'property_type'
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion www/app/view/search/criteria/PropertyType.js
@@ -1,7 +1,7 @@

Ext.define('FriendlyRent.view.search.criteria.PropertyType', {
extend: 'Ext.field.SliderText',
alias: 'widget.search.criteria.property_type',
alias: 'widget.search_criteria_property_type',
config: {
label: 'Property type',
autoValues: true,
Expand Down
4 changes: 2 additions & 2 deletions www/app/view/search/criteria/Radius.js
Expand Up @@ -6,9 +6,9 @@ Ext.define('FriendlyRent.view.search.criteria.Radius', {

({
config: {
label: 'Radius',
value: 5,
minValue: 1,
maxValue: 50,
label: 'Radius'
maxValue: 50
}
});
42 changes: 25 additions & 17 deletions www/lib/plugins/SliderFieldInput.js
Expand Up @@ -14,17 +14,7 @@ Ext.define('Ext.field.SliderInput', {
config: {
cls: Ext.baseCSSPrefix + 'slider-field-input',
tabIndex: -1,
helperPosition: 'right',
valueMapper: function(value) {
var valueMap = this.valueMap;
if (valueMap) {
console.log('mapped value', value);
return valueMap[value];
} else {
console.log('value', value);
return value;
}
}
helperPosition: 'right'
},

proxyConfig: {
Expand All @@ -41,12 +31,17 @@ Ext.define('Ext.field.SliderInput', {
config.value = config.values;
}

if (config.hasOwnProperty('valueMap')) {
if (config.autoValues == true) {
config.value = config.defaultValue || 0;
config.minValue = 0;
config.maxValue = config.valueMap.size -1;
config.increment = 1;
// console.log('setup values', this.config.valueMap);
if (this.config.valueMap) {
// console.log('has valuemap:', this.config.autoValues);
if (this.config.autoValues == true) {
// console.log('has autovalues');
this.config.value = this.config.defaultValue || 0;
this.config.minValue = 0;
this.config.maxValue = this.config.valueMap.length -1;
// console.log('default', this.config.value);
// console.log('min', this.config.minValue);
// console.log('max', this.config.maxValue);
}
}

Expand All @@ -65,6 +60,19 @@ Ext.define('Ext.field.SliderInput', {
});
},

valueMapper: function(value, scope) {
var valueMap = this.config.valueMap;
// console.log('Input Valuemap', valueMap)
if (valueMap) {
// console.log('mapped value', value);
return valueMap[value];
} else {
// console.log('orig value', value);
return value;
}
},


getElementConfig: function() {
var self = this;
var originalConfig = self.callParent();
Expand Down
47 changes: 29 additions & 18 deletions www/lib/plugins/SliderFieldText.js
Expand Up @@ -9,14 +9,7 @@ Ext.define('Ext.field.SliderText', {
config: {
cls: Ext.baseCSSPrefix + 'slider-field-text',
tabIndex: -1,
helperPosition: 'right',
valueMapper: function(value) {
if (self.config.valueMap) {
self.config.valueMap[value];
} else {
value;
}
}
helperPosition: 'right'
},

proxyConfig: {
Expand All @@ -32,13 +25,17 @@ Ext.define('Ext.field.SliderText', {
if (config.hasOwnProperty('values')) {
config.value = config.values;
}

if (config.hasOwnProperty('valueMap')) {
if (config.autoValues == true) {
config.value = config.defaultValue || 0;
config.minValue = 0;
config.maxValue = config.valueMap.size -1;
config.increment = 1;
// console.log('setup values', this.config.valueMap);
if (this.config.valueMap) {
// console.log('has valuemap:', this.config.autoValues);
if (this.config.autoValues == true) {
// console.log('has autovalues');
this.config.value = this.config.defaultValue || 0;
this.config.minValue = 0;
this.config.maxValue = this.config.valueMap.length -1;
// console.log('default', this.config.value);
// console.log('min', this.config.minValue);
// console.log('max', this.config.maxValue);
}
}

Expand Down Expand Up @@ -78,9 +75,10 @@ Ext.define('Ext.field.SliderText', {
},

setHelperValue: function(value) {
var valueMapper = self.config.valueMapper;
var value = valueMapper ? valueMapper(value) : value;
this.helperInput.dom.text = value;
var value = this.valueMapper(value)
// console.log('value:', value);
// console.log('helperInput', this.helperInput);
this.helperInput.dom.innerText = value;
},

// @private
Expand Down Expand Up @@ -123,6 +121,19 @@ Ext.define('Ext.field.SliderText', {
return this.getValue();
},

valueMapper: function(value) {
// console.log('Config', config)
var valueMap = this.config.valueMap;
// console.log('Text Valuemap', valueMap)
if (valueMap) {
// console.log('mapped value', value);
return valueMap[value];
} else {
// console.log('orig value', value);
return value;
}
},

reset: function() {
var config = this.config,
initialValue = (this.config.hasOwnProperty('values')) ? config.values : config.value;
Expand Down
5 changes: 5 additions & 0 deletions www/src/app/view/search/Content.coffee
Expand Up @@ -4,6 +4,7 @@ Ext.define 'FriendlyRent.view.search.Content'
requires: [
'FriendlyRent.view.search.criteria.Location'
'FriendlyRent.view.search.criteria.Radius'
'FriendlyRent.view.search.criteria.PropertyType'
]
config:
layout: 'vbox'
Expand All @@ -15,5 +16,9 @@ Ext.define 'FriendlyRent.view.search.Content'
{
xtype: 'search_criteria_radius'
name: 'radius'
}
{
xtype: 'search_criteria_property_type'
name: 'property_type'
}
]
6 changes: 3 additions & 3 deletions www/src/app/view/search/criteria/PropertyType.coffee
@@ -1,7 +1,7 @@
Ext.define 'FriendlyRent.view.search.criteria.PropertyType'
extend: 'Ext.field.SliderText'
alias: 'widget.search.criteria.property_type'
extend: 'Ext.field.SliderText'
alias: 'widget.search_criteria_property_type'
config:
label: 'Property type'
autoValues: true
autoValues: true
valueMap: ['Any', 'Room', 'Apartment', 'House', 'Independent house', 'House boat']
5 changes: 3 additions & 2 deletions www/src/app/view/search/criteria/Radius.coffee
@@ -1,8 +1,9 @@
Ext.define 'FriendlyRent.view.search.criteria.Radius'
extend: 'Ext.field.SliderInput'
alias: 'widget.search_criteria_radius'
alias: 'widget.search_criteria_radius'
config:
label: 'Radius'
value: 5
minValue: 1
maxValue: 50
label: 'Radius'

0 comments on commit 5b2f718

Please sign in to comment.