diff options
| author | Anqi Xu | 2012-06-24 12:45:05 -0400 | 
|---|---|---|
| committer | Anqi Xu | 2012-06-24 12:45:05 -0400 | 
| commit | 1a9c58f10c98565124141840a61a34494f4d4579 (patch) | |
| tree | e826e48c78367f0fe3678075516c5ecae57a403f /Resources/friendship/ui/FriendSelector.js | |
| parent | e06955279665f5ead6414c2f23485997e77dbad9 (diff) | |
| parent | 3c1f3dc92d5ffad081afc560f24d0610f64d60bf (diff) | |
| download | LikeFeed-1a9c58f10c98565124141840a61a34494f4d4579.tar.bz2 | |
Merge branch 'master' of github.com:teddywing/LikeFeed
Conflicts:
	tiapp.xml
Diffstat (limited to 'Resources/friendship/ui/FriendSelector.js')
| -rw-r--r-- | Resources/friendship/ui/FriendSelector.js | 89 | 
1 files changed, 89 insertions, 0 deletions
| diff --git a/Resources/friendship/ui/FriendSelector.js b/Resources/friendship/ui/FriendSelector.js new file mode 100644 index 0000000..ad85c4a --- /dev/null +++ b/Resources/friendship/ui/FriendSelector.js @@ -0,0 +1,89 @@ +(function() { +	fs.ui.friendSelectorButton = function() { +		var button = Ti.UI.createButton({ +			title: 'fff' +		}); +		 +		button.addEventListener('click', function() { +			fs.ui.createFriendSelector().open(); +		}); +		 +		return button; +	}; +	 +	fs.ui.createFriendSelector = function() { +		var done_button = Ti.UI.createButton({ +			title: 'Done', +			style: Titanium.UI.iPhone.SystemButtonStyle.DONE +		}); +		 +		var win = Ti.UI.createWindow({ +			title: 'Filter Friends', +			barColor: fs.ui.styles.navBarColour, +			modal: true, +			rightNavButton: done_button +		}); +		 +		done_button.addEventListener('click', function() { +			var friend_ids = Array(); +			for (key in fs.data.friends) { +				if (fs.data.friends[key].selected) { +					friend_ids.push(fs.data.friends[key].uid); +				} +			} +			if (friend_ids.length > 0) { +				fs.ui.refreshLikeList(friend_ids); +			} +					 +			win.close(); +		}); +		 +		friend_table = Ti.UI.createTableView(); +		 +		var friends = []; +	 +		for (var key in fs.data.friends) { +			friends.push(fs.data.friends[key]); +		} +		friends.sort(function(a, b) { +	    	a = a.name; +	    	b = b.name; +	    	return a > b ? 1 : (a < b ? -1 : 0); +		}); +		 +		for (var i = 0; i < friends.length; i++) { +			var row = Ti.UI.createTableViewRow({ +				selectionStyle: 'none' +			}); +			var name = Ti.UI.createLabel({ +				text: friends[i].name, +				font: {fontSize: 16, fontWeight: 'bold'}, +				left: 45 +			}); +			var avatar = Ti.UI.createImageView({ +				image: friends[i].pic, +				height: 35, +				width: 35, +				left: 5 +			}); +			var switch_button = Ti.UI.createSwitch({ +				right: 5, +				value: fs.data.friends[friends[i].uid.toString()].selected, +				SP_uidString: friends[i].uid.toString(), +			}); +			switch_button.addEventListener("change", function(e) { +				fs.data.friends[this.SP_uidString].selected = e.value; +			}); +			 +			row.add(avatar); +			row.add(name); +			row.add(switch_button); +			 +			friend_table.appendRow(row); +		} +		 +		win.add(friend_table); +		 +		return win; +	}; +})(); | 
