Sha256: fedf04e658d6c3e157fbaed71140e35087e50f20d8aad57d67b154565b321e52

Contents?: true

Size: 1006 Bytes

Versions: 5

Compression:

Stored size: 1006 Bytes

Contents

Morris = window.Morris = {}

$ = jQuery

# Very simple event-emitter class.
#
# @private
class Morris.EventEmitter
  on: (name, handler) ->
    unless @handlers?
      @handlers = {}
    unless @handlers[name]?
      @handlers[name] = []
    @handlers[name].push(handler)
    @

  fire: (name, args...) ->
    if @handlers? and @handlers[name]?
      for handler in @handlers[name]
        handler(args...)

# Make long numbers prettier by inserting commas.
#
# @example
#   Morris.commas(1234567) -> '1,234,567'
Morris.commas = (num) ->
  if num?
    ret = if num < 0 then "-" else ""
    absnum = Math.abs(num)
    intnum = Math.floor(absnum).toFixed(0)
    ret += intnum.replace(/(?=(?:\d{3})+$)(?!^)/g, ',')
    strabsnum = absnum.toString()
    if strabsnum.length > intnum.length
      ret += strabsnum.slice(intnum.length)
    ret
  else
    '-'

# Zero-pad numbers to two characters wide.
#
# @example
#   Morris.pad2(1) -> '01'
Morris.pad2 = (number) -> (if number < 10 then '0' else '') + number

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
radius-rails-3.1.4 app/assets/components/morris.js/lib/morris.coffee
rails_modular_admin-1.0.0 app/assets/node_modules/morris.js/lib/morris.coffee
rails_modular_admin-0.4.0 app/assets/node_modules/morris.js/lib/morris.coffee
jinda_lte-0.0.1 lib/generators/jinda_lte/templates/app/assets/jinda_assets/bower_components/morris.js/lib/morris.coffee
jinda_bsb-0.0.1 lib/generators/jinda_bsb/templates/app/assets/jinda_assets/plugins/morrisjs/lib/morris.coffee