2 class Pettanr.AppHelper
\r
4 @icon_tag: (name, opt = {}) ->
\r
5 title = if opt['object']
\r
6 name + ' ID:' + opt['object'].get(id).toString()
\r
9 size = if opt['size']
\r
10 parseInt(opt['size'])
\r
13 "<img src=\"" + '/images/' + Pettanr.underscore(name) + '.gif' + "\" width=" + size.toString() + " height=" + size.toString() + " alt=\"" + name + ' Icon' + "title=\"" + title + ">"
\r
15 class Pettanr.AppController
\r
17 #>> https://gist.github.com/davidjbeveridge/3813724
\r
18 @xeach: (arr, func, index=0) ->
\r
19 if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else []
\r
21 @camelize: (input) ->
\r
22 pieces = input.split(/[\W_-]/)
\r
23 @xeach(pieces, @capitalize).join("")
\r
25 @capitalize: (input) ->
\r
26 input.charAt(0).toUpperCase() + input.slice(1)
\r
28 @lowercase: (input) ->
\r
31 @underscore: (input) ->
\r
32 pieces = input.replace(/([A-Z])/g, '_$1').split(/[\W_-]/).filter (n) -> !!n
\r
33 @xeach(pieces, @lowercase ).join("_")
\r
35 @is_a_string: (str) ->
\r
36 if (str instanceof String) or (typeof str == "string")
\r