atlas_assets 0.5.10 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/docs/_posts/2014-03-12-drop.md +115 -0
- data/lib/assets/javascripts/atlas_assets.js +4 -1
- data/lib/assets/javascripts/libraries/drop.js +1751 -0
- data/lib/assets/javascripts/libraries/select.coffee +424 -0
- data/lib/assets/stylesheets/atlas_assets/drop-theme-arrows-bounce-dark.scss +222 -0
- data/lib/assets/stylesheets/atlas_assets/drop-theme-arrows-bounce.scss +230 -0
- data/lib/assets/stylesheets/atlas_assets/drop-theme-arrows.scss +120 -0
- data/lib/assets/stylesheets/atlas_assets/drop-theme-basic.scss +29 -0
- data/lib/assets/stylesheets/atlas_assets/select-theme-defaults.scss +155 -0
- data/lib/assets/stylesheets/atlas_assets.scss +7 -0
- data/lib/atlas_assets/version.rb +1 -1
- metadata +10 -2
| @@ -0,0 +1,424 @@ | |
| 1 | 
            +
            {extend, addClass, removeClass, hasClass, getBounds, Evented} = Tether.Utils
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ENTER = 13
         | 
| 4 | 
            +
            ESCAPE = 27
         | 
| 5 | 
            +
            SPACE = 32
         | 
| 6 | 
            +
            UP = 38
         | 
| 7 | 
            +
            DOWN = 40
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            touchDevice = 'ontouchstart' of document.documentElement
         | 
| 10 | 
            +
            clickEvent = if touchDevice then 'touchstart' else 'click'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            useNative = ->
         | 
| 13 | 
            +
              touchDevice and (innerWidth <= 640 or innerHeight <= 640)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            isRepeatedChar = (str) ->
         | 
| 16 | 
            +
              Array::reduce.call str, (a, b) ->
         | 
| 17 | 
            +
                if a is b then b else false
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            getFocusedSelect = ->
         | 
| 20 | 
            +
              document.querySelector('.select-target-focused')?.selectInstance
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            searchText = ''
         | 
| 23 | 
            +
            searchTextTimeout = undefined
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            lastCharacter = undefined
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            document.addEventListener 'keypress', (e) ->
         | 
| 28 | 
            +
              return unless select = getFocusedSelect()
         | 
| 29 | 
            +
              return if e.charCode is 0
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              if e.keyCode is SPACE
         | 
| 32 | 
            +
                e.preventDefault()
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              clearTimeout searchTextTimeout
         | 
| 35 | 
            +
              searchTextTimeout = setTimeout ->
         | 
| 36 | 
            +
                searchText = ''
         | 
| 37 | 
            +
              , 500
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              searchText += String.fromCharCode e.charCode
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              options = select.findOptionsByPrefix(searchText)
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              if options.length is 1
         | 
| 44 | 
            +
                # We have an exact match, choose it
         | 
| 45 | 
            +
                select.selectOption options[0]
         | 
| 46 | 
            +
                return
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              if searchText.length > 1 and isRepeatedChar(searchText)
         | 
| 49 | 
            +
                # They hit the same char over and over, maybe they want to cycle through
         | 
| 50 | 
            +
                # the options that start with that char
         | 
| 51 | 
            +
                repeatedOptions = select.findOptionsByPrefix(searchText[0])
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                if repeatedOptions.length
         | 
| 54 | 
            +
                  selected = repeatedOptions.indexOf select.getChosen()
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  # Pick the next thing (if something with this prefix wasen't selected we'll end up with the first option)
         | 
| 57 | 
            +
                  selected += 1
         | 
| 58 | 
            +
                  selected = selected % repeatedOptions.length
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  select.selectOption repeatedOptions[selected]
         | 
| 61 | 
            +
                  return
         | 
| 62 | 
            +
             | 
| 63 | 
            +
              if options.length
         | 
| 64 | 
            +
                # We have multiple things that start with this prefix.  Based on the behavior of native select,
         | 
| 65 | 
            +
                # this is considered after the repeated case.
         | 
| 66 | 
            +
                select.selectOption options[0]
         | 
| 67 | 
            +
                return
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              # No match at all, do nothing
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            document.addEventListener 'keydown', (e) ->
         | 
| 72 | 
            +
              # We consider this independently of the keypress handler so we can intercept keys that have
         | 
| 73 | 
            +
              # built-in functions.
         | 
| 74 | 
            +
              return unless select = getFocusedSelect()
         | 
| 75 | 
            +
             | 
| 76 | 
            +
              if e.keyCode in [UP, DOWN, ESCAPE]
         | 
| 77 | 
            +
                e.preventDefault()
         | 
| 78 | 
            +
             | 
| 79 | 
            +
              if select.isOpen()
         | 
| 80 | 
            +
                switch e.keyCode
         | 
| 81 | 
            +
                  when UP, DOWN
         | 
| 82 | 
            +
                    select.moveHighlight e.keyCode
         | 
| 83 | 
            +
                  when ENTER
         | 
| 84 | 
            +
                    select.selectHighlightedOption()
         | 
| 85 | 
            +
                  when ESCAPE
         | 
| 86 | 
            +
                    select.close()
         | 
| 87 | 
            +
                    select.target.focus()
         | 
| 88 | 
            +
              else
         | 
| 89 | 
            +
                if e.keyCode in [UP, DOWN, SPACE]
         | 
| 90 | 
            +
                  select.open()
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            class Select extends Evented
         | 
| 93 | 
            +
              @defaults:
         | 
| 94 | 
            +
                alignToHighlighed: 'auto'
         | 
| 95 | 
            +
                className: 'select-theme-default'
         | 
| 96 | 
            +
             | 
| 97 | 
            +
              constructor: (@options) ->
         | 
| 98 | 
            +
                @options = extend {}, Select.defaults, @options
         | 
| 99 | 
            +
                @select = @options.el
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                if @select.selectInstance?
         | 
| 102 | 
            +
                  throw new Error "This element has already been turned into a Select"
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                @setupTarget()
         | 
| 105 | 
            +
                @renderTarget()
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                @setupDrop()
         | 
| 108 | 
            +
                @renderDrop()
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                @setupSelect()
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                @setupTether()
         | 
| 113 | 
            +
                @bindClick()
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                @bindMutationEvents()
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                @value = @select.value
         | 
| 118 | 
            +
             | 
| 119 | 
            +
              useNative: ->
         | 
| 120 | 
            +
                @options.useNative is true or (useNative() and @options.useNative isnt false)
         | 
| 121 | 
            +
             | 
| 122 | 
            +
              setupTarget: ->
         | 
| 123 | 
            +
                @target = document.createElement 'a'
         | 
| 124 | 
            +
                @target.href = 'javascript:;'
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                addClass @target, 'select-target'
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                tabIndex = @select.getAttribute('tabindex') or 0
         | 
| 129 | 
            +
                @target.setAttribute 'tabindex', tabIndex
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                if @options.className
         | 
| 132 | 
            +
                  addClass @target, @options.className
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                @target.selectInstance = @
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                @target.addEventListener 'click', =>
         | 
| 137 | 
            +
                  if not @isOpen()
         | 
| 138 | 
            +
                    @target.focus()
         | 
| 139 | 
            +
                  else
         | 
| 140 | 
            +
                    @target.blur()
         | 
| 141 | 
            +
             | 
| 142 | 
            +
                @target.addEventListener 'focus', =>
         | 
| 143 | 
            +
                  addClass @target, 'select-target-focused'
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                @target.addEventListener 'blur', (e) =>
         | 
| 146 | 
            +
                  if @isOpen()
         | 
| 147 | 
            +
                    if e.relatedTarget and not @drop.contains(e.relatedTarget)
         | 
| 148 | 
            +
                      @close()
         | 
| 149 | 
            +
             | 
| 150 | 
            +
                  removeClass @target, 'select-target-focused'
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                @select.parentNode.insertBefore(@target, @select.nextSibling)
         | 
| 153 | 
            +
             | 
| 154 | 
            +
              setupDrop: ->
         | 
| 155 | 
            +
                @drop = document.createElement 'div'
         | 
| 156 | 
            +
                addClass @drop, 'select'
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                if @options.className
         | 
| 159 | 
            +
                  addClass @drop, @options.className
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                document.body.appendChild @drop
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                @drop.addEventListener 'click', (e) =>
         | 
| 164 | 
            +
                  if hasClass(e.target, 'select-option')
         | 
| 165 | 
            +
                    @pickOption e.target
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                @drop.addEventListener 'mousemove', (e) =>
         | 
| 168 | 
            +
                  if hasClass(e.target, 'select-option')
         | 
| 169 | 
            +
                    @highlightOption e.target
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                @content = document.createElement 'div'
         | 
| 172 | 
            +
                addClass @content, 'select-content'
         | 
| 173 | 
            +
                @drop.appendChild @content
         | 
| 174 | 
            +
             | 
| 175 | 
            +
              open: ->
         | 
| 176 | 
            +
                addClass @target, 'select-open'
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                if @useNative()
         | 
| 179 | 
            +
                  @select.style.display = 'block'
         | 
| 180 | 
            +
             | 
| 181 | 
            +
                  setTimeout =>
         | 
| 182 | 
            +
                    event = document.createEvent("MouseEvents")
         | 
| 183 | 
            +
                    event.initEvent("mousedown", true, true)
         | 
| 184 | 
            +
                    @select.dispatchEvent event
         | 
| 185 | 
            +
             | 
| 186 | 
            +
                  return
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                addClass @drop, 'select-open'
         | 
| 189 | 
            +
             | 
| 190 | 
            +
                setTimeout =>
         | 
| 191 | 
            +
                  @tether.enable()
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                selectedOption = @drop.querySelector('.select-option-selected')
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                return unless selectedOption
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                @highlightOption selectedOption
         | 
| 198 | 
            +
                @scrollDropContentToOption selectedOption
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                positionSelectStyle = =>
         | 
| 201 | 
            +
                  if hasClass(@drop, 'tether-abutted-left') or hasClass(@drop, 'tether-abutted-bottom')
         | 
| 202 | 
            +
                    dropBounds = getBounds @drop
         | 
| 203 | 
            +
                    optionBounds = getBounds selectedOption
         | 
| 204 | 
            +
             | 
| 205 | 
            +
                    offset = dropBounds.top - (optionBounds.top + optionBounds.height)
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                    @drop.style.top = (parseFloat(@drop.style.top) or 0) + offset + 'px'
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                if @options.alignToHighlighted is 'always' or (@options.alignToHighlighted is 'auto' and @content.scrollHeight <= @content.clientHeight)
         | 
| 210 | 
            +
                  setTimeout positionSelectStyle
         | 
| 211 | 
            +
             | 
| 212 | 
            +
                @trigger 'open'
         | 
| 213 | 
            +
             | 
| 214 | 
            +
              close: ->
         | 
| 215 | 
            +
                removeClass @target, 'select-open'
         | 
| 216 | 
            +
             | 
| 217 | 
            +
                if @useNative()
         | 
| 218 | 
            +
                  @select.style.display = 'none'
         | 
| 219 | 
            +
                  return
         | 
| 220 | 
            +
             | 
| 221 | 
            +
                @tether.disable()
         | 
| 222 | 
            +
             | 
| 223 | 
            +
                removeClass @drop, 'select-open'
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                @trigger 'close'
         | 
| 226 | 
            +
             | 
| 227 | 
            +
              toggle: ->
         | 
| 228 | 
            +
                if @isOpen()
         | 
| 229 | 
            +
                  @close()
         | 
| 230 | 
            +
                else
         | 
| 231 | 
            +
                  @open()
         | 
| 232 | 
            +
             | 
| 233 | 
            +
              isOpen: ->
         | 
| 234 | 
            +
                hasClass @drop, 'select-open'
         | 
| 235 | 
            +
             | 
| 236 | 
            +
              bindClick: ->
         | 
| 237 | 
            +
                @target.addEventListener clickEvent, (e) =>
         | 
| 238 | 
            +
                  e.preventDefault()
         | 
| 239 | 
            +
                  @toggle()
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                document.addEventListener clickEvent, (event) =>
         | 
| 242 | 
            +
                  return unless @isOpen()
         | 
| 243 | 
            +
             | 
| 244 | 
            +
                  # Clicking inside dropdown
         | 
| 245 | 
            +
                  if event.target is @drop or @drop.contains(event.target)
         | 
| 246 | 
            +
                    return
         | 
| 247 | 
            +
             | 
| 248 | 
            +
                  # Clicking target
         | 
| 249 | 
            +
                  if event.target is @target or @target.contains(event.target)
         | 
| 250 | 
            +
                    return
         | 
| 251 | 
            +
             | 
| 252 | 
            +
                  @close()
         | 
| 253 | 
            +
             | 
| 254 | 
            +
              setupTether: ->
         | 
| 255 | 
            +
                @tether = new Tether
         | 
| 256 | 
            +
                  element: @drop
         | 
| 257 | 
            +
                  target: @target
         | 
| 258 | 
            +
                  attachment: 'top left'
         | 
| 259 | 
            +
                  targetAttachment: 'bottom left'
         | 
| 260 | 
            +
                  classPrefix: 'select'
         | 
| 261 | 
            +
                  constraints: [
         | 
| 262 | 
            +
                    to: 'window'
         | 
| 263 | 
            +
                    attachment: 'together'
         | 
| 264 | 
            +
                  ]
         | 
| 265 | 
            +
             | 
| 266 | 
            +
              renderTarget: ->
         | 
| 267 | 
            +
                @target.innerHTML = ''
         | 
| 268 | 
            +
             | 
| 269 | 
            +
                for option in @select.querySelectorAll('option')
         | 
| 270 | 
            +
                  if option.selected
         | 
| 271 | 
            +
                    @target.innerHTML = option.innerHTML
         | 
| 272 | 
            +
                    break
         | 
| 273 | 
            +
             | 
| 274 | 
            +
                @target.appendChild document.createElement 'b'
         | 
| 275 | 
            +
             | 
| 276 | 
            +
              renderDrop: ->
         | 
| 277 | 
            +
                optionList = document.createElement 'ul'
         | 
| 278 | 
            +
                addClass optionList, 'select-options'
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                for el in @select.querySelectorAll('option')
         | 
| 281 | 
            +
                  option = document.createElement 'li'
         | 
| 282 | 
            +
                  addClass option, 'select-option'
         | 
| 283 | 
            +
             | 
| 284 | 
            +
                  option.setAttribute 'data-value', el.value
         | 
| 285 | 
            +
                  option.innerHTML = el.innerHTML
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                  if el.selected
         | 
| 288 | 
            +
                    addClass option, 'select-option-selected'
         | 
| 289 | 
            +
             | 
| 290 | 
            +
                  optionList.appendChild option
         | 
| 291 | 
            +
             | 
| 292 | 
            +
                @content.innerHTML = ''
         | 
| 293 | 
            +
                @content.appendChild optionList
         | 
| 294 | 
            +
             | 
| 295 | 
            +
              update: =>
         | 
| 296 | 
            +
                @renderDrop()
         | 
| 297 | 
            +
                @renderTarget()
         | 
| 298 | 
            +
             | 
| 299 | 
            +
              setupSelect: ->
         | 
| 300 | 
            +
                @select.selectInstance = @
         | 
| 301 | 
            +
             | 
| 302 | 
            +
                addClass @select, 'select-select'
         | 
| 303 | 
            +
             | 
| 304 | 
            +
                @select.addEventListener 'change', @update
         | 
| 305 | 
            +
             | 
| 306 | 
            +
              bindMutationEvents: ->
         | 
| 307 | 
            +
                if window.MutationObserver?
         | 
| 308 | 
            +
                  @observer = new MutationObserver @update
         | 
| 309 | 
            +
                  @observer.observe @select,
         | 
| 310 | 
            +
                    childList: true
         | 
| 311 | 
            +
                    attributes: true
         | 
| 312 | 
            +
                    characterData: true
         | 
| 313 | 
            +
                    subtree: true
         | 
| 314 | 
            +
                else
         | 
| 315 | 
            +
                  @select.addEventListener 'DOMSubtreeModified', @update
         | 
| 316 | 
            +
             | 
| 317 | 
            +
              findOptionsByPrefix: (text) ->
         | 
| 318 | 
            +
                options = @drop.querySelectorAll('.select-option')
         | 
| 319 | 
            +
             | 
| 320 | 
            +
                text = text.toLowerCase()
         | 
| 321 | 
            +
             | 
| 322 | 
            +
                Array::filter.call options, (option) ->
         | 
| 323 | 
            +
                  option.innerHTML.toLowerCase().substr(0, text.length) is text
         | 
| 324 | 
            +
             | 
| 325 | 
            +
              findOptionsByValue: (val) ->
         | 
| 326 | 
            +
                options = @drop.querySelectorAll('.select-option')
         | 
| 327 | 
            +
             | 
| 328 | 
            +
                Array::filter.call options, (option) ->
         | 
| 329 | 
            +
                  option.getAttribute('data-value') is val
         | 
| 330 | 
            +
             | 
| 331 | 
            +
              getChosen: ->
         | 
| 332 | 
            +
                if @isOpen()
         | 
| 333 | 
            +
                  @drop.querySelector('.select-option-highlight')
         | 
| 334 | 
            +
                else
         | 
| 335 | 
            +
                  @drop.querySelector('.select-option-selected')
         | 
| 336 | 
            +
             | 
| 337 | 
            +
              selectOption: (option) ->
         | 
| 338 | 
            +
                if @isOpen()
         | 
| 339 | 
            +
                  @highlightOption option
         | 
| 340 | 
            +
                  @scrollDropContentToOption option
         | 
| 341 | 
            +
                else
         | 
| 342 | 
            +
                  @pickOption option, false
         | 
| 343 | 
            +
             | 
| 344 | 
            +
              resetSelection: ->
         | 
| 345 | 
            +
                @selectOption @drop.querySelector('.select-option')
         | 
| 346 | 
            +
             | 
| 347 | 
            +
              highlightOption: (option) ->
         | 
| 348 | 
            +
                highlighted = @drop.querySelector('.select-option-highlight')
         | 
| 349 | 
            +
                if highlighted?
         | 
| 350 | 
            +
                  removeClass highlighted, 'select-option-highlight'
         | 
| 351 | 
            +
             | 
| 352 | 
            +
                addClass option, 'select-option-highlight'
         | 
| 353 | 
            +
             | 
| 354 | 
            +
                @trigger 'highlight', {option}
         | 
| 355 | 
            +
             | 
| 356 | 
            +
              moveHighlight: (directionKeyCode) ->
         | 
| 357 | 
            +
                unless highlighted = @drop.querySelector('.select-option-highlight')
         | 
| 358 | 
            +
                  @highlightOption @drop.querySelector('.select-option')
         | 
| 359 | 
            +
                  return
         | 
| 360 | 
            +
             | 
| 361 | 
            +
                options = @drop.querySelectorAll('.select-option')
         | 
| 362 | 
            +
             | 
| 363 | 
            +
                highlightedIndex = Array::indexOf.call options, highlighted
         | 
| 364 | 
            +
                return unless highlightedIndex >= 0
         | 
| 365 | 
            +
             | 
| 366 | 
            +
                if directionKeyCode is UP
         | 
| 367 | 
            +
                  highlightedIndex -= 1
         | 
| 368 | 
            +
                else
         | 
| 369 | 
            +
                  highlightedIndex += 1
         | 
| 370 | 
            +
             | 
| 371 | 
            +
                if highlightedIndex < 0 or highlightedIndex >= options.length
         | 
| 372 | 
            +
                  return
         | 
| 373 | 
            +
             | 
| 374 | 
            +
                newHighlight = options[highlightedIndex]
         | 
| 375 | 
            +
             | 
| 376 | 
            +
                @highlightOption newHighlight
         | 
| 377 | 
            +
                @scrollDropContentToOption newHighlight
         | 
| 378 | 
            +
             | 
| 379 | 
            +
              scrollDropContentToOption: (option) ->
         | 
| 380 | 
            +
                if @content.scrollHeight > @content.clientHeight
         | 
| 381 | 
            +
                  contentBounds = getBounds @content
         | 
| 382 | 
            +
                  optionBounds = getBounds option
         | 
| 383 | 
            +
             | 
| 384 | 
            +
                  @content.scrollTop = optionBounds.top - (contentBounds.top - @content.scrollTop)
         | 
| 385 | 
            +
             | 
| 386 | 
            +
              selectHighlightedOption: ->
         | 
| 387 | 
            +
                @pickOption @drop.querySelector('.select-option-highlight')
         | 
| 388 | 
            +
             | 
| 389 | 
            +
              pickOption: (option, close=true) ->
         | 
| 390 | 
            +
                @value = @select.value = option.getAttribute 'data-value'
         | 
| 391 | 
            +
                @triggerChange()
         | 
| 392 | 
            +
             | 
| 393 | 
            +
                if close
         | 
| 394 | 
            +
                  setTimeout =>
         | 
| 395 | 
            +
                    @close()
         | 
| 396 | 
            +
                    @target.focus()
         | 
| 397 | 
            +
             | 
| 398 | 
            +
              triggerChange: ->
         | 
| 399 | 
            +
                event = document.createEvent("HTMLEvents")
         | 
| 400 | 
            +
                event.initEvent("change", true, false)
         | 
| 401 | 
            +
                @select.dispatchEvent event
         | 
| 402 | 
            +
             | 
| 403 | 
            +
                @trigger 'change', {value: @select.value}
         | 
| 404 | 
            +
             | 
| 405 | 
            +
              change: (val) ->
         | 
| 406 | 
            +
                options = @findOptionsByValue val
         | 
| 407 | 
            +
             | 
| 408 | 
            +
                if not options.length
         | 
| 409 | 
            +
                  throw new Error "Select Error: An option with the value \"#{ val }\" doesn't exist"
         | 
| 410 | 
            +
             | 
| 411 | 
            +
                @pickOption options[0], false
         | 
| 412 | 
            +
             | 
| 413 | 
            +
            Select.init = (options={}) ->
         | 
| 414 | 
            +
              if document.readyState is 'loading'
         | 
| 415 | 
            +
                document.addEventListener 'DOMContentLoaded', -> Select.init(options)
         | 
| 416 | 
            +
                return
         | 
| 417 | 
            +
             | 
| 418 | 
            +
              options.selector ?= 'select'
         | 
| 419 | 
            +
             | 
| 420 | 
            +
              for el in document.querySelectorAll(options.selector)
         | 
| 421 | 
            +
                if not el.selectInstance
         | 
| 422 | 
            +
                  new Select extend {el}, options
         | 
| 423 | 
            +
             | 
| 424 | 
            +
            window.Select = Select
         | 
| @@ -0,0 +1,222 @@ | |
| 1 | 
            +
            .drop-element, .drop-element:after, .drop-element:before, .drop-element *, .drop-element *:after, .drop-element *:before {
         | 
| 2 | 
            +
              -webkit-box-sizing: border-box;
         | 
| 3 | 
            +
              -moz-box-sizing: border-box;
         | 
| 4 | 
            +
              box-sizing: border-box; }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            .drop-element {
         | 
| 7 | 
            +
              position: absolute;
         | 
| 8 | 
            +
              display: none; }
         | 
| 9 | 
            +
              .drop-element.drop-open {
         | 
| 10 | 
            +
                display: block; }
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            .drop-element.drop-theme-arrows-bounce-dark {
         | 
| 13 | 
            +
              max-width: 100%;
         | 
| 14 | 
            +
              max-height: 100%; }
         | 
| 15 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark .drop-content {
         | 
| 16 | 
            +
                -webkit-border-radius: 5px;
         | 
| 17 | 
            +
                -moz-border-radius: 5px;
         | 
| 18 | 
            +
                -ms-border-radius: 5px;
         | 
| 19 | 
            +
                -o-border-radius: 5px;
         | 
| 20 | 
            +
                border-radius: 5px;
         | 
| 21 | 
            +
                position: relative;
         | 
| 22 | 
            +
                font-family: inherit;
         | 
| 23 | 
            +
                background: black;
         | 
| 24 | 
            +
                color: white;
         | 
| 25 | 
            +
                padding: 1em;
         | 
| 26 | 
            +
                font-size: 1.1em;
         | 
| 27 | 
            +
                line-height: 1.5em; }
         | 
| 28 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark .drop-content:before {
         | 
| 29 | 
            +
                  content: "";
         | 
| 30 | 
            +
                  display: block;
         | 
| 31 | 
            +
                  position: absolute;
         | 
| 32 | 
            +
                  width: 0;
         | 
| 33 | 
            +
                  height: 0;
         | 
| 34 | 
            +
                  border-color: transparent;
         | 
| 35 | 
            +
                  border-width: 12px;
         | 
| 36 | 
            +
                  border-style: solid; }
         | 
| 37 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-center .drop-content {
         | 
| 38 | 
            +
                margin-bottom: 12px; }
         | 
| 39 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-center .drop-content:before {
         | 
| 40 | 
            +
                  top: 100%;
         | 
| 41 | 
            +
                  left: 50%;
         | 
| 42 | 
            +
                  margin-left: -12px;
         | 
| 43 | 
            +
                  border-top-color: black; }
         | 
| 44 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-center .drop-content {
         | 
| 45 | 
            +
                margin-top: 12px; }
         | 
| 46 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-center .drop-content:before {
         | 
| 47 | 
            +
                  bottom: 100%;
         | 
| 48 | 
            +
                  left: 50%;
         | 
| 49 | 
            +
                  margin-left: -12px;
         | 
| 50 | 
            +
                  border-bottom-color: black; }
         | 
| 51 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-right.drop-element-attached-middle .drop-content {
         | 
| 52 | 
            +
                margin-right: 12px; }
         | 
| 53 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-right.drop-element-attached-middle .drop-content:before {
         | 
| 54 | 
            +
                  left: 100%;
         | 
| 55 | 
            +
                  top: 50%;
         | 
| 56 | 
            +
                  margin-top: -12px;
         | 
| 57 | 
            +
                  border-left-color: black; }
         | 
| 58 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-left.drop-element-attached-middle .drop-content {
         | 
| 59 | 
            +
                margin-left: 12px; }
         | 
| 60 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-left.drop-element-attached-middle .drop-content:before {
         | 
| 61 | 
            +
                  right: 100%;
         | 
| 62 | 
            +
                  top: 50%;
         | 
| 63 | 
            +
                  margin-top: -12px;
         | 
| 64 | 
            +
                  border-right-color: black; }
         | 
| 65 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-bottom .drop-content {
         | 
| 66 | 
            +
                margin-top: 12px; }
         | 
| 67 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-bottom .drop-content:before {
         | 
| 68 | 
            +
                  bottom: 100%;
         | 
| 69 | 
            +
                  left: 12px;
         | 
| 70 | 
            +
                  border-bottom-color: black; }
         | 
| 71 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-bottom .drop-content {
         | 
| 72 | 
            +
                margin-top: 12px; }
         | 
| 73 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-bottom .drop-content:before {
         | 
| 74 | 
            +
                  bottom: 100%;
         | 
| 75 | 
            +
                  right: 12px;
         | 
| 76 | 
            +
                  border-bottom-color: black; }
         | 
| 77 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-top .drop-content {
         | 
| 78 | 
            +
                margin-bottom: 12px; }
         | 
| 79 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-top .drop-content:before {
         | 
| 80 | 
            +
                  top: 100%;
         | 
| 81 | 
            +
                  left: 12px;
         | 
| 82 | 
            +
                  border-top-color: black; }
         | 
| 83 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-top .drop-content {
         | 
| 84 | 
            +
                margin-bottom: 12px; }
         | 
| 85 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-top .drop-content:before {
         | 
| 86 | 
            +
                  top: 100%;
         | 
| 87 | 
            +
                  right: 12px;
         | 
| 88 | 
            +
                  border-top-color: black; }
         | 
| 89 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-left .drop-content {
         | 
| 90 | 
            +
                margin-right: 12px; }
         | 
| 91 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-left .drop-content:before {
         | 
| 92 | 
            +
                  top: 12px;
         | 
| 93 | 
            +
                  left: 100%;
         | 
| 94 | 
            +
                  border-left-color: black; }
         | 
| 95 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-right .drop-content {
         | 
| 96 | 
            +
                margin-left: 12px; }
         | 
| 97 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-right .drop-content:before {
         | 
| 98 | 
            +
                  top: 12px;
         | 
| 99 | 
            +
                  right: 100%;
         | 
| 100 | 
            +
                  border-right-color: black; }
         | 
| 101 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-left .drop-content {
         | 
| 102 | 
            +
                margin-right: 12px; }
         | 
| 103 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-left .drop-content:before {
         | 
| 104 | 
            +
                  bottom: 12px;
         | 
| 105 | 
            +
                  left: 100%;
         | 
| 106 | 
            +
                  border-left-color: black; }
         | 
| 107 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-right .drop-content {
         | 
| 108 | 
            +
                margin-left: 12px; }
         | 
| 109 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-right .drop-content:before {
         | 
| 110 | 
            +
                  bottom: 12px;
         | 
| 111 | 
            +
                  right: 100%;
         | 
| 112 | 
            +
                  border-right-color: black; }
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            .drop-element.drop-theme-arrows-bounce-dark {
         | 
| 115 | 
            +
              -webkit-transform: translateZ(0);
         | 
| 116 | 
            +
              -moz-transform: translateZ(0);
         | 
| 117 | 
            +
              -ms-transform: translateZ(0);
         | 
| 118 | 
            +
              -o-transform: translateZ(0);
         | 
| 119 | 
            +
              transform: translateZ(0);
         | 
| 120 | 
            +
              -webkit-transition: opacity 0.1s;
         | 
| 121 | 
            +
              -moz-transition: opacity 0.1s;
         | 
| 122 | 
            +
              -o-transition: opacity 0.1s;
         | 
| 123 | 
            +
              transition: opacity 0.1s;
         | 
| 124 | 
            +
              opacity: 0; }
         | 
| 125 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark .drop-content {
         | 
| 126 | 
            +
                -webkit-transition: -webkit-transform 0.3s cubic-bezier(0, 0, 0.265, 1.55);
         | 
| 127 | 
            +
                -moz-transition: -moz-transform 0.3s cubic-bezier(0, 0, 0.265, 1.55);
         | 
| 128 | 
            +
                -o-transition: -o-transform 0.3s cubic-bezier(0, 0, 0.265, 1.55);
         | 
| 129 | 
            +
                transition: transform 0.3s cubic-bezier(0, 0, 0.265, 1.55);
         | 
| 130 | 
            +
                -webkit-transform: scale(0) translateZ(0);
         | 
| 131 | 
            +
                -moz-transform: scale(0) translateZ(0);
         | 
| 132 | 
            +
                -ms-transform: scale(0) translateZ(0);
         | 
| 133 | 
            +
                -o-transform: scale(0) translateZ(0);
         | 
| 134 | 
            +
                transform: scale(0) translateZ(0); }
         | 
| 135 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-open {
         | 
| 136 | 
            +
                display: none; }
         | 
| 137 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-open-transitionend {
         | 
| 138 | 
            +
                display: block; }
         | 
| 139 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-after-open {
         | 
| 140 | 
            +
                -webkit-transition: none;
         | 
| 141 | 
            +
                -moz-transition: none;
         | 
| 142 | 
            +
                -o-transition: none;
         | 
| 143 | 
            +
                transition: none;
         | 
| 144 | 
            +
                opacity: 1; }
         | 
| 145 | 
            +
                .drop-element.drop-theme-arrows-bounce-dark.drop-after-open .drop-content {
         | 
| 146 | 
            +
                  -webkit-transform: scale(1) translateZ(0);
         | 
| 147 | 
            +
                  -moz-transform: scale(1) translateZ(0);
         | 
| 148 | 
            +
                  -ms-transform: scale(1) translateZ(0);
         | 
| 149 | 
            +
                  -o-transform: scale(1) translateZ(0);
         | 
| 150 | 
            +
                  transform: scale(1) translateZ(0); }
         | 
| 151 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-center .drop-content {
         | 
| 152 | 
            +
                -webkit-transform-origin: 50% calc(100% + 12px);
         | 
| 153 | 
            +
                -moz-transform-origin: 50% calc(100% + 12px);
         | 
| 154 | 
            +
                -ms-transform-origin: 50% calc(100% + 12px);
         | 
| 155 | 
            +
                -o-transform-origin: 50% calc(100% + 12px);
         | 
| 156 | 
            +
                transform-origin: 50% calc(100% + 12px); }
         | 
| 157 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-center .drop-content {
         | 
| 158 | 
            +
                -webkit-transform-origin: 50% -12px;
         | 
| 159 | 
            +
                -moz-transform-origin: 50% -12px;
         | 
| 160 | 
            +
                -ms-transform-origin: 50% -12px;
         | 
| 161 | 
            +
                -o-transform-origin: 50% -12px;
         | 
| 162 | 
            +
                transform-origin: 50% -12px; }
         | 
| 163 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-right.drop-element-attached-middle .drop-content {
         | 
| 164 | 
            +
                -webkit-transform-origin: calc(100% + 12px) 50%;
         | 
| 165 | 
            +
                -moz-transform-origin: calc(100% + 12px) 50%;
         | 
| 166 | 
            +
                -ms-transform-origin: calc(100% + 12px) 50%;
         | 
| 167 | 
            +
                -o-transform-origin: calc(100% + 12px) 50%;
         | 
| 168 | 
            +
                transform-origin: calc(100% + 12px) 50%; }
         | 
| 169 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-left.drop-element-attached-middle .drop-content {
         | 
| 170 | 
            +
                -webkit-transform-origin: -12px 50%;
         | 
| 171 | 
            +
                -moz-transform-origin: -12px 50%;
         | 
| 172 | 
            +
                -ms-transform-origin: -12px 50%;
         | 
| 173 | 
            +
                -o-transform-origin: -12px 50%;
         | 
| 174 | 
            +
                transform-origin: -12px 50%; }
         | 
| 175 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-bottom .drop-content {
         | 
| 176 | 
            +
                -webkit-transform-origin: 0 -12px;
         | 
| 177 | 
            +
                -moz-transform-origin: 0 -12px;
         | 
| 178 | 
            +
                -ms-transform-origin: 0 -12px;
         | 
| 179 | 
            +
                -o-transform-origin: 0 -12px;
         | 
| 180 | 
            +
                transform-origin: 0 -12px; }
         | 
| 181 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-bottom .drop-content {
         | 
| 182 | 
            +
                -webkit-transform-origin: 100% -12px;
         | 
| 183 | 
            +
                -moz-transform-origin: 100% -12px;
         | 
| 184 | 
            +
                -ms-transform-origin: 100% -12px;
         | 
| 185 | 
            +
                -o-transform-origin: 100% -12px;
         | 
| 186 | 
            +
                transform-origin: 100% -12px; }
         | 
| 187 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-top .drop-content {
         | 
| 188 | 
            +
                -webkit-transform-origin: 0 calc(100% + 12px);
         | 
| 189 | 
            +
                -moz-transform-origin: 0 calc(100% + 12px);
         | 
| 190 | 
            +
                -ms-transform-origin: 0 calc(100% + 12px);
         | 
| 191 | 
            +
                -o-transform-origin: 0 calc(100% + 12px);
         | 
| 192 | 
            +
                transform-origin: 0 calc(100% + 12px); }
         | 
| 193 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-top .drop-content {
         | 
| 194 | 
            +
                -webkit-transform-origin: 100% calc(100% + 12px);
         | 
| 195 | 
            +
                -moz-transform-origin: 100% calc(100% + 12px);
         | 
| 196 | 
            +
                -ms-transform-origin: 100% calc(100% + 12px);
         | 
| 197 | 
            +
                -o-transform-origin: 100% calc(100% + 12px);
         | 
| 198 | 
            +
                transform-origin: 100% calc(100% + 12px); }
         | 
| 199 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-right.drop-target-attached-left .drop-content {
         | 
| 200 | 
            +
                -webkit-transform-origin: calc(100% + 12px) 0;
         | 
| 201 | 
            +
                -moz-transform-origin: calc(100% + 12px) 0;
         | 
| 202 | 
            +
                -ms-transform-origin: calc(100% + 12px) 0;
         | 
| 203 | 
            +
                -o-transform-origin: calc(100% + 12px) 0;
         | 
| 204 | 
            +
                transform-origin: calc(100% + 12px) 0; }
         | 
| 205 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-top.drop-element-attached-left.drop-target-attached-right .drop-content {
         | 
| 206 | 
            +
                -webkit-transform-origin: -12px 0;
         | 
| 207 | 
            +
                -moz-transform-origin: -12px 0;
         | 
| 208 | 
            +
                -ms-transform-origin: -12px 0;
         | 
| 209 | 
            +
                -o-transform-origin: -12px 0;
         | 
| 210 | 
            +
                transform-origin: -12px 0; }
         | 
| 211 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-right.drop-target-attached-left .drop-content {
         | 
| 212 | 
            +
                -webkit-transform-origin: calc(100% + 12px) 100%;
         | 
| 213 | 
            +
                -moz-transform-origin: calc(100% + 12px) 100%;
         | 
| 214 | 
            +
                -ms-transform-origin: calc(100% + 12px) 100%;
         | 
| 215 | 
            +
                -o-transform-origin: calc(100% + 12px) 100%;
         | 
| 216 | 
            +
                transform-origin: calc(100% + 12px) 100%; }
         | 
| 217 | 
            +
              .drop-element.drop-theme-arrows-bounce-dark.drop-element-attached-bottom.drop-element-attached-left.drop-target-attached-right .drop-content {
         | 
| 218 | 
            +
                -webkit-transform-origin: -12px 100%;
         | 
| 219 | 
            +
                -moz-transform-origin: -12px 100%;
         | 
| 220 | 
            +
                -ms-transform-origin: -12px 100%;
         | 
| 221 | 
            +
                -o-transform-origin: -12px 100%;
         | 
| 222 | 
            +
                transform-origin: -12px 100%; }
         |