import Ember from "ember";
import nearestParent from "../computed/nearest-parent";
import stringify from "../computed/stringify";
import ScrollSandbox from "../mixins/scroll_sandbox";

var set = Ember.set;
var reads = Ember.computed.reads;
var not = Ember.computed.not;

var SelectList = Ember.View.extend(ScrollSandbox, {

  tagName: 'ul',

  classNames: ['select-menu_list'],

  attributeBindings: ['aria-hidden',
                      'aria-labelledby',
                      'aria-disabled',
                      'aria-activedescendant'],

  registerView: function () {
    set(this, 'menu.list', this);
  }.on('didInsertElement'),

  menu: nearestParent("select-menu"),
  popup: nearestParent("popup-menu"),

  isHidden: not('popup.isVisible'),

  // .............................................
  // WAI ARIA attributes
  //

  ariaRole: 'listbox',
  "aria-hidden": stringify("isHidden"),
  "aria-labelledby": reads('menu.label.elementId'),
  "aria-disabled": stringify("menu.disabled"),
  "aria-activedescendant": reads("menu.activeDescendant.elementId")

});

export default SelectList;

@@ -182,29 +182,8 @@
 %22;%0A%0A
-var set = Ember.set;%0A
 var 
@@ -249,24 +249,28 @@
 %0A%0Avar Select
+Menu
 List = Ember
@@ -359,267 +359,8 @@
 %5D,%0A%0A
-  attributeBindings: %5B'aria-hidden',%0A                      'aria-labelledby',%0A                      'aria-disabled',%0A                      'aria-activedescendant'%5D,%0A%0A  registerView: function () %7B%0A    set(this, 'menu.list', this);%0A  %7D.on('didInsertElement'),%0A%0A
   me
@@ -551,16 +551,182 @@
 s%0A  //%0A%0A
+  attributeBindings: %5B'aria-hidden',%0A                      'aria-labelledby',%0A                      'aria-disabled',%0A                      'aria-activedescendant'%5D,%0A%0A
   ariaRo
@@ -974,14 +974,18 @@
 t Select
+Menu
 List;%0A

make the select menu list just a configuration list