Sha256: 7fae921ae0bb8ff8895c4173f994a40d56c4e2aced52c951aad6607907eb379e

Contents?: true

Size: 1.63 KB

Versions: 13

Compression:

Stored size: 1.63 KB

Contents

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
#
#= require fullcalendar
#= require jquery.boxy
#= require sprintf
#= require scheduler

SocialStream.Events.tools = {}

SocialStream.Events.tools.currentRGB = () ->
  [ parseInt(SocialStream.Events.current.eventColor[1..2], 16),
  parseInt(SocialStream.Events.current.eventColor[3..4], 16),
  parseInt(SocialStream.Events.current.eventColor[5..6], 16) ]

SocialStream.Events.tools.colorRange = () ->
  min = 0

  for color in SocialStream.Events.tools.currentRGB()
    if color < min
      min = color
  
  parseInt 2 * (255 - min) / 3

SocialStream.Events.tools.increaseColor = (delta) ->
   (if (color + delta) > 255 then 255 else (color + delta)) for color in SocialStream.Events.tools.currentRGB()
  

SocialStream.Events.tools.eventColorScale = (index) ->
  range = SocialStream.Events.tools.colorRange()

  delta = range * (index + 1) / (SocialStream.Events.current.roomIndex.length + 1)

  delta = parseInt(delta)

  newColor = SocialStream.Events.tools.increaseColor(delta)

  sprintf "#%02x%02x%02x", newColor[0], newColor[1], newColor[2]
  

SocialStream.Events.tools.eventColor = (roomId) ->
  currentColor = SocialStream.Events.current.eventColor

  if not roomId? or not SocialStream.Events.current.roomIndex? or SocialStream.Events.current.roomIndex.length == 0
    return currentColor

  currentRoomIndex = SocialStream.Events.current.roomIndex.indexOf(roomId)

  SocialStream.Events.tools.eventColorScale(currentRoomIndex)

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
social_stream-0.26.0 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-events-0.12.0 app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.25.2 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.25.1 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.25.0 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-events-0.11.0 app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.24.1 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-events-0.10.1 app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.24.0 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-events-0.10.0 app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.23.4 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-0.23.3 events/app/assets/javascripts/social_stream.events.tools.js.coffee
social_stream-events-0.9.2 app/assets/javascripts/social_stream.events.tools.js.coffee