diff options
Diffstat (limited to 'Resources/friendship/ui/FriendSelector.js')
| -rw-r--r-- | Resources/friendship/ui/FriendSelector.js | 36 | 
1 files changed, 28 insertions, 8 deletions
| diff --git a/Resources/friendship/ui/FriendSelector.js b/Resources/friendship/ui/FriendSelector.js index 958de5b..ad85c4a 100644 --- a/Resources/friendship/ui/FriendSelector.js +++ b/Resources/friendship/ui/FriendSelector.js @@ -25,34 +25,54 @@  		});  		done_button.addEventListener('click', function() { -			// Refresh the like list -			 +			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(); -		// Sort friends list alphabetically -		// +		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 < fs.data.friends.length; i++) { +		for (var i = 0; i < friends.length; i++) {  			var row = Ti.UI.createTableViewRow({  				selectionStyle: 'none'  			});  			var name = Ti.UI.createLabel({ -				text: fs.data.friends[i].name, +				text: friends[i].name,  				font: {fontSize: 16, fontWeight: 'bold'},  				left: 45  			});  			var avatar = Ti.UI.createImageView({ -				image: fs.data.friends[i].pic_square, +				image: friends[i].pic,  				height: 35,  				width: 35,  				left: 5  			});  			var switch_button = Ti.UI.createSwitch({  				right: 5, -				value: false +				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); | 
