Sha256: fffbbdd92fc4020f4e92111eae02187a40f9241918c097b80987e4b4f163b37c

Contents?: true

Size: 754 Bytes

Versions: 1

Compression:

Stored size: 754 Bytes

Contents

class iconly.Package
  constructor: (@fileInputSelector, @messageSelector) ->
    $(document).on 'change', @fileInputSelector, (e) => @_addFiles(e)

  _addFiles: (e) ->
    @_showMessage $.map(e.target.files, (f) => @_badge(f.name))

  _showMessage: (fileNames) ->
    $(@messageSelector).html """
      <h4 class="mt-0">#{fileNames.length} #{@_pluralize(fileNames.length, 'file')} selected</h4>
      #{fileNames.join('')}
    """

  _badge: (fileName) ->
    """
      <span class="badge badge-pale">#{fileName}</span>
    """

  _pluralize: (count, text) ->
    message = text
    message += 's' if count != 1
    message

  @start: (fileInputSelector, messageSelector) ->
    iconly.package ||= new iconly.Package(fileInputSelector, messageSelector)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iconly-1.0.0 app/assets/javascripts/iconly/package.coffee