Created
March 12, 2010 11:24
-
-
Save ranguard/330240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// factory and fu are helper classes | |
show_list({ | |
title: 'Max price', | |
key: 'price_to', | |
view: view_price_options, | |
list: list, | |
is_price : true, | |
left: factory.total_width() - 130 | |
}); | |
function show_list(conf) { | |
fu.debug('show_list'); | |
var list = conf.list; | |
var number_in_list = list.length; | |
var button_height = 30; | |
var scroll_width = 120; | |
var local_view = factory.createScrollView({ | |
top: 35, | |
left: conf.left, | |
width: scroll_width, | |
height: 300, | |
backgroundColor: '#cccccc', | |
borderRadius:5, | |
contentHeight: (number_in_list * (button_height + 10)) + 30 | |
}); | |
var local_top = 10; | |
factory.addLabel({ | |
text: conf.title, | |
label_height: 20, | |
width: scroll_width, | |
top: local_top, | |
win: local_view | |
}); | |
local_top += 20; | |
var all_buttons = []; | |
var text_color = colors.text_default; | |
if(search_conf[conf.key]) { | |
text_color = colors.text_unselected; | |
} | |
for(var i=0; i<number_in_list; i++) { | |
var title = conf.is_price ? fu.priceOut(list[i]) : list[i]; | |
local_top += 10; | |
var button = factory.createButton({ | |
title: title, | |
value: list[i], | |
width: scroll_width - 20, | |
left: 10, | |
height: button_height, | |
top: local_top, | |
color: text_color, | |
style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED | |
}); | |
local_top += button_height; | |
if(search_conf[conf.key] && search_conf[conf.key] == list[i]) { | |
button.color = colors.text_selected; | |
} | |
all_buttons.push(button); | |
button.addEventListener('click', function(e) | |
{ | |
search_conf[conf.key] = e.source.value; | |
// Reset all buttons | |
for(var i=0; i<all_buttons.length; i++) { | |
all_buttons[i].color = colors.text_unselected; | |
} | |
e.source.color = colors.text_selected; | |
}); | |
local_view.add(button); | |
} | |
conf.view.add(local_view); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment