Skip to content

Commit

Permalink
Genericize selectable for use in mm-group
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykoerber committed Aug 19, 2015
1 parent 7c9f349 commit 9bc25e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/mm-group/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,4 @@
});
</script>
</body>
</html>
</html>
47 changes: 23 additions & 24 deletions src/mm-group/mm-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,24 @@
attached: function() {
this.type = this._getType();

this.async(function() {
switch(this.type) {
case "mm-button":
// ***********************
// TODO: Why no tap listener?
// ***********************
// this.addEventListener('tap', this._updateSelectedItem.bind(this), false);
this.addEventListener('click', this._updateSelectedItem);
break;
case "mm-radio":
this.addEventListener('selected', this._radioSelected);
break;
default:
return;
}
});
// ***********************
// TODO: Move to attached/detached so we can cleanup?
// ***********************

switch(this.type) {
case "mm-button":
// ***********************
// TODO: Why no tap listener?
// ***********************
// this.addEventListener('tap', this._updateSelectedItem.bind(this), false);
this.addEventListener('click', this._updateSelectedItem.bind(this), false);
break;
case "mm-radio":
this.addEventListener('selected', this._radioSelected);
break;
default:
return;
}
},

detached: function() {
Expand Down Expand Up @@ -142,14 +144,11 @@
// ***********************
},

_selectedIndexChanged: function(newIndex, oldIndex) {
if(typeof newIndex === 'number') {
var newSelected = this.items[newIndex],
oldSelected = this.items[oldIndex],
value = newSelected.value ? newSelected.value : newSelected.textContent.trim();

if(this.value !== value) this.value = value;
newSelected.toggleAttribute("selected");
_updateSelectedItem: function(e) {
// var target = Polymer.dom(e).localTarget;
var target = Polymer.dom(e).path[0];

console.log("_updateSelectedItem: ", e);

this.fire('selected', {
item: newSelected,
Expand Down

0 comments on commit 9bc25e0

Please sign in to comment.