2 class Pettanr.AppHelper
\r
6 @full_url: (filename) ->
\r
7 request.protocol + request.host_with_port + filename
\r
10 l = label.split('.')
\r
15 I18n.t('activerecord.models.' + Pettanr[label].item_name())
\r
17 I18n.t('activerecord.models.attribtes.' + Pettanr[l.first].item_name() + '.' + l.last)
\r
19 @t_select_items: (items) ->
\r
23 @t_selected_item: (name, index) ->
\r
24 I18n.t(Manifest.manifest().system_resources.select_items[name][index][0])
\r
26 @icon_tag: (name, opt = {}) ->
\r
27 title = if opt['object']
\r
28 name + ' ID:' + opt['object'].get(id).toString()
\r
31 size = if opt['size']
\r
32 parseInt(opt['size'])
\r
35 "<img src=\"" + '/images/' + Pettanr.underscore(name) + '.gif' + "\" width=" + size.toString() + " height=" + size.toString() + " alt=\"" + name + ' Icon' + "title=\"" + title + ">"
\r
37 class Pettanr.AppController
\r
39 #>> https://gist.github.com/davidjbeveridge/3813724
\r
40 @xeach: (arr, func, index=0) ->
\r
41 if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else []
\r
43 @camelize: (input) ->
\r
44 pieces = input.split(/[\W_-]/)
\r
45 @xeach(pieces, @capitalize).join("")
\r
47 @capitalize: (input) ->
\r
48 input.charAt(0).toUpperCase() + input.slice(1)
\r
50 @lowercase: (input) ->
\r
53 @underscore: (input) ->
\r
54 pieces = input.replace(/([A-Z])/g, '_$1').split(/[\W_-]/).filter (n) -> !!n
\r
55 @xeach(pieces, @lowercase ).join("_")
\r
57 @is_a_string: (str) ->
\r
58 if (str instanceof String) or (typeof str == "string")
\r