Sha256: a74f9bcdb8f7fa91cbc3f2f39c4d775c69b43d48112720465c72da7f34158d99

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

@Joosy = Object.extended
  debug: false
  Modules: {}
  Resource: {}
  Templaters: {}

Joosy.namespace = (name, generator=false) ->
  name  = name.split '.'
  space = window
  for part in name
    space = space[part] ?= {}

  if generator
    generator = generator.apply space
  for key, klass of space
    if space.hasOwnProperty(key) &&
       Joosy.Module.hasAncestor klass, Joosy.Module
      klass.__namespace__ = name

Joosy.helpers = (name, generator) ->
  Joosy.namespace "Joosy.Helpers.#{name}", generator

Joosy.test = ->
  text = "Hi :). I'm Joosy. And everything is just fine!"

  if console
    console.log text
  else
    alert text

Joosy.uuid = ->
  'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace /[xy]/g, (c) ->
    r = Math.random() * 16 | 0
    v = if c is 'x' then r else r & 3 | 8
    v.toString 16
  .toUpperCase()

Joosy.preloadImages = (images, callback) ->
  unless Object.isArray(images)
    images = [images]
  if images.length == 0
    callback()

  ticks   = images.length
  result  = []
  checker = ->
    if (ticks -= 1) == 0
      callback?()

  for p in images
    result.push $('<img/>').load(checker).attr('src', p)

  result

Joosy.buildUrl = (url, params) ->
  paramsString = []

  Object.each params, (key, value) ->
    paramsString.push "#{key}=#{value}"

  hash = url.match(/(\#.*)?$/)[0]
  url  = url.replace /\#.*$/, ''
  if !paramsString.isEmpty() && !url.has(/\?/)
    url  = url + "?"

  paramsString = paramsString.join '&'
  if !paramsString.isBlank() && url.last() != '?'
    paramsString = '&' + paramsString

  url + paramsString + hash

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joosy-0.1.0.RC2 app/assets/javascripts/joosy/core/joosy.js.coffee