leocaseiro / angular-chosen

AngularJS Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a AngularJS way
http://leocaseiro.github.io/angular-chosen/
MIT License
681 stars 248 forks source link

Update Chosen options list #258

Closed VanTanev closed 5 years ago

VanTanev commented 6 years ago

As #257 pointed out, we do not have a good list for chosen options right now.

Chosen doesn't have a good way to programmatically get the options. There is no public method for getting the defaults, but instead defaults are applied as instance variables on init.

So... Maybe scraping the options page is good enough:

Array.from(
  document.querySelectorAll('table:first-of-type tr td:first-of-type')
)
.map(node => node.textContent)
.map(option => option.replace(/_(\w)/g, (_, letter) => letter.toUpperCase()))

produces

[
  "allowSingleDeselect",
  "disableSearch",
  "disableSearchThreshold",
  "enableSplitWordSearch",
  "inheritSelectClasses",
  "maxSelectedOptions",
  "noResultsText",
  "placeholderTextMultiple",
  "placeholderTextSingle",
  "searchContains",
  "groupSearch",
  "singleBackstrokeDelete",
  "width",
  "displayDisabledOptions",
  "displaySelectedOptions",
  "includeGroupLabelInSelected",
  "maxShownResults",
  "caseSensitiveSearch",
  "hideResultsOnSelect",
  "rtl"
]

The question is, should we keep the options that used to exist with some older version of Chosen? How do we even verify what those were? @leocaseiro do you have any input?

leocaseiro commented 5 years ago

If the scraping works without the previous options, I think it's good to remove them.