chr 0.3.5 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +2 -0
  3. data/.gitignore +6 -1
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +18 -0
  6. data/README.md +4 -0
  7. data/Rakefile +17 -2
  8. data/app/assets/javascripts/chr.coffee +13 -26
  9. data/app/assets/javascripts/chr/{core/chr.coffee → chr.coffee} +4 -1
  10. data/app/assets/javascripts/chr/{core/chr_router.coffee → chr_router.coffee} +0 -0
  11. data/app/assets/javascripts/chr/{core/item.coffee → item.coffee} +2 -1
  12. data/app/assets/javascripts/chr/{core/list.coffee → list.coffee} +1 -1
  13. data/app/assets/javascripts/chr/{core/list_config.coffee → list_config.coffee} +0 -0
  14. data/app/assets/javascripts/chr/{core/list_pagination.coffee → list_pagination.coffee} +15 -4
  15. data/app/assets/javascripts/chr/{core/list_reorder.coffee → list_reorder.coffee} +0 -0
  16. data/app/assets/javascripts/chr/{core/list_search.coffee → list_search.coffee} +1 -1
  17. data/app/assets/javascripts/chr/{core/module.coffee → module.coffee} +0 -0
  18. data/app/assets/javascripts/chr/{core/utils.coffee → utils.coffee} +0 -0
  19. data/app/assets/javascripts/chr/{core/view.coffee → view.coffee} +21 -9
  20. data/app/assets/javascripts/chr/{core/view_local-storage.coffee → view_local-storage.coffee} +0 -0
  21. data/app/assets/javascripts/{chr/store/array-store.coffee → stores/array.coffee} +0 -0
  22. data/app/assets/javascripts/{chr/store/object-store.coffee → stores/object.coffee} +0 -0
  23. data/app/assets/javascripts/{chr/store/rails-array-store.coffee → stores/rails-array.coffee} +0 -0
  24. data/app/assets/javascripts/{chr/store → stores}/rails-form-object-parser.coffee +4 -1
  25. data/app/assets/javascripts/{chr/store/rails-object-store.coffee → stores/rails-object.coffee} +0 -0
  26. data/app/assets/javascripts/{chr/store/rest-array-store.coffee → stores/rest-array.coffee} +5 -2
  27. data/app/assets/javascripts/{chr/store/rest-object-store.coffee → stores/rest-object.coffee} +0 -0
  28. data/app/assets/stylesheets/{_chr.scss → chr.scss} +2 -7
  29. data/app/assets/stylesheets/chr/{_icons.scss → icons.scss} +0 -0
  30. data/app/assets/stylesheets/chr/{_main.scss → main.scss} +10 -3
  31. data/app/assets/stylesheets/chr/{_mixins.scss → mixins.scss} +0 -77
  32. data/app/assets/stylesheets/chr/{_settings.scss → settings.scss} +1 -1
  33. data/bin/chr +13 -0
  34. data/bin/rake +16 -0
  35. data/bin/setup +13 -0
  36. data/chr.gemspec +41 -21
  37. data/docs/tests.md +64 -0
  38. data/lib/chr.rb +10 -2
  39. data/lib/chr/app_builder.rb +385 -0
  40. data/lib/chr/generators/app_generator.rb +213 -0
  41. data/lib/chr/version.rb +3 -1
  42. data/lib/generators/chr/controller_generator.rb +18 -0
  43. data/templates/Gemfile.erb +38 -0
  44. data/templates/Procfile +1 -0
  45. data/templates/README.md.erb +45 -0
  46. data/templates/_analytics.html.erb +9 -0
  47. data/templates/_flashes.html.erb +7 -0
  48. data/templates/_javascript.html.erb +12 -0
  49. data/templates/application.coffee +2 -0
  50. data/templates/application.scss +1 -0
  51. data/templates/application.yml +6 -0
  52. data/templates/application_gitignore +14 -0
  53. data/templates/application_layout.html.erb.erb +29 -0
  54. data/templates/asset_sync.rb +28 -0
  55. data/templates/bin_setup.erb +36 -0
  56. data/templates/body_class_helper.rb +19 -0
  57. data/templates/bundler_audit.rake +12 -0
  58. data/templates/carrierwave.rb +23 -0
  59. data/templates/character_admin.coffee.erb +28 -0
  60. data/templates/character_admin.scss +3 -0
  61. data/templates/character_admin_index.html.erb +2 -0
  62. data/templates/character_admin_layout.html.erb +21 -0
  63. data/templates/character_base_controller.rb +16 -0
  64. data/templates/development_seeds.rb +12 -0
  65. data/templates/devise_overrides_passwords_controller.rb +10 -0
  66. data/templates/devise_overrides_passwords_edit.html.erb +30 -0
  67. data/templates/devise_overrides_passwords_new.html.erb +21 -0
  68. data/templates/devise_overrides_sessions_controller.rb +12 -0
  69. data/templates/devise_overrides_sessions_new.html.erb +31 -0
  70. data/templates/errors.rb +34 -0
  71. data/templates/json_encoding.rb +1 -0
  72. data/templates/newrelic.yml.erb +34 -0
  73. data/templates/puma.rb +18 -0
  74. data/templates/routes.rb +90 -0
  75. data/templates/sample.env +6 -0
  76. data/templates/secrets.yml +14 -0
  77. data/templates/smtp.rb +9 -0
  78. data/templates/staging.rb +5 -0
  79. data/test/factories/article_factory.rb +19 -0
  80. data/test/files/test.jpg +0 -0
  81. data/test/integration/article_fullsize_test.rb +33 -0
  82. data/test/integration/article_test.rb +33 -0
  83. data/test/integration/magazine_article_test.rb +33 -0
  84. data/test/integration/restricted_article_test.rb +33 -0
  85. data/test/integration/sport_article_test.rb +34 -0
  86. data/test/rails_app/Rakefile +6 -0
  87. data/test/rails_app/app/assets/javascripts/admin.coffee +137 -0
  88. data/test/rails_app/app/assets/javascripts/application.js +1 -0
  89. data/test/rails_app/app/assets/stylesheets/admin.scss +1 -0
  90. data/test/rails_app/app/assets/stylesheets/application.css +1 -0
  91. data/test/rails_app/app/controllers/admin/articles_controller.rb +7 -0
  92. data/test/rails_app/app/controllers/admin/base_controller.rb +8 -0
  93. data/test/rails_app/app/controllers/application_controller.rb +5 -0
  94. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  95. data/test/rails_app/app/models/article.rb +46 -0
  96. data/test/rails_app/app/uploaders/article_image_uploader.rb +16 -0
  97. data/test/rails_app/app/views/admin/index.html.erb +4 -0
  98. data/test/rails_app/app/views/layouts/admin.html.erb +17 -0
  99. data/test/rails_app/app/views/layouts/application.html.erb +14 -0
  100. data/test/rails_app/bin/bundle +3 -0
  101. data/test/rails_app/bin/rails +8 -0
  102. data/test/rails_app/bin/rake +8 -0
  103. data/test/rails_app/bin/setup +29 -0
  104. data/test/rails_app/bin/spring +15 -0
  105. data/test/rails_app/config.ru +4 -0
  106. data/test/rails_app/config/application.rb +36 -0
  107. data/test/rails_app/config/boot.rb +3 -0
  108. data/test/rails_app/config/environment.rb +5 -0
  109. data/test/rails_app/config/environments/development.rb +38 -0
  110. data/test/rails_app/config/environments/production.rb +76 -0
  111. data/test/rails_app/config/environments/test.rb +46 -0
  112. data/test/rails_app/config/initializers/assets.rb +12 -0
  113. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  114. data/test/rails_app/config/initializers/carrierwave.rb +5 -0
  115. data/test/rails_app/config/initializers/cookies_serializer.rb +3 -0
  116. data/test/rails_app/config/initializers/filter_parameter_logging.rb +4 -0
  117. data/test/rails_app/config/initializers/inflections.rb +16 -0
  118. data/test/rails_app/config/initializers/mime_types.rb +4 -0
  119. data/test/rails_app/config/initializers/session_store.rb +3 -0
  120. data/test/rails_app/config/initializers/wrap_parameters.rb +9 -0
  121. data/test/rails_app/config/locales/en.yml +23 -0
  122. data/test/rails_app/config/mongoid.yml +9 -0
  123. data/test/rails_app/config/routes.rb +8 -0
  124. data/test/rails_app/config/secrets.yml +22 -0
  125. data/test/rails_app/db/seeds.rb +7 -0
  126. data/test/rails_app/public/404.html +67 -0
  127. data/test/rails_app/public/422.html +67 -0
  128. data/test/rails_app/public/500.html +66 -0
  129. data/{app/assets/javascripts/form/input-date.coffee → test/rails_app/public/favicon.ico} +0 -0
  130. data/test/rails_app/public/robots.txt +5 -0
  131. data/test/support/character_front_end.rb +196 -0
  132. data/test/support/chr/item.rb +32 -0
  133. data/test/support/chr/list.rb +31 -0
  134. data/test/support/chr/list_pagination.rb +163 -0
  135. data/test/support/chr/list_reorder.rb +46 -0
  136. data/test/support/chr/list_search.rb +41 -0
  137. data/test/support/chr/view.rb +112 -0
  138. data/test/support/stores/array.rb +20 -0
  139. data/test/support/stores/rest-array.rb +34 -0
  140. data/test/test_helper.rb +68 -0
  141. metadata +373 -80
  142. data/Gruntfile.coffee +0 -101
  143. data/app/assets/javascripts/form/expandable-group.coffee +0 -30
  144. data/app/assets/javascripts/form/form.coffee +0 -221
  145. data/app/assets/javascripts/form/input-checkbox.coffee +0 -83
  146. data/app/assets/javascripts/form/input-color.coffee +0 -55
  147. data/app/assets/javascripts/form/input-file.coffee +0 -144
  148. data/app/assets/javascripts/form/input-form.coffee +0 -171
  149. data/app/assets/javascripts/form/input-form_reorder.coffee +0 -67
  150. data/app/assets/javascripts/form/input-hidden.coffee +0 -57
  151. data/app/assets/javascripts/form/input-list.coffee +0 -154
  152. data/app/assets/javascripts/form/input-list_reorder.coffee +0 -39
  153. data/app/assets/javascripts/form/input-list_typeahead.coffee +0 -55
  154. data/app/assets/javascripts/form/input-password.coffee +0 -32
  155. data/app/assets/javascripts/form/input-select.coffee +0 -84
  156. data/app/assets/javascripts/form/input-select2.coffee +0 -33
  157. data/app/assets/javascripts/form/input-string.coffee +0 -160
  158. data/app/assets/javascripts/form/input-text.coffee +0 -43
  159. data/app/assets/javascripts/input-html.coffee +0 -81
  160. data/app/assets/javascripts/input-markdown.coffee +0 -93
  161. data/app/assets/javascripts/input-redactor.coffee +0 -1
  162. data/app/assets/javascripts/redactor/input-redactor.coffee +0 -53
  163. data/app/assets/javascripts/redactor/input-redactor_character.coffee +0 -83
  164. data/app/assets/javascripts/redactor/input-redactor_images.coffee +0 -166
  165. data/app/assets/javascripts/vendor/ace.js +0 -18280
  166. data/app/assets/javascripts/vendor/jquery.scrollparent.js +0 -14
  167. data/app/assets/javascripts/vendor/jquery.textarea_autosize.js +0 -55
  168. data/app/assets/javascripts/vendor/jquery.typeahead.js +0 -1782
  169. data/app/assets/javascripts/vendor/marked.js +0 -1272
  170. data/app/assets/javascripts/vendor/mode-html.js +0 -2436
  171. data/app/assets/javascripts/vendor/mode-markdown.js +0 -2820
  172. data/app/assets/javascripts/vendor/redactor.fixedtoolbar.js +0 -107
  173. data/app/assets/javascripts/vendor/select2.js +0 -5274
  174. data/app/assets/stylesheets/_input-redactor.scss +0 -35
  175. data/app/assets/stylesheets/form/_expandable-group.scss +0 -16
  176. data/app/assets/stylesheets/form/_input-select2.scss +0 -94
  177. data/app/assets/stylesheets/form/_main.scss +0 -180
  178. data/app/assets/stylesheets/vendor/select2.css +0 -258
  179. data/bower.json +0 -38
  180. data/dist/chr.js +0 -5949
  181. data/dist/input-ace.js +0 -24946
  182. data/dist/input-redactor.js +0 -1
  183. data/lib/mongoid/character.rb +0 -30
  184. data/package.json +0 -10
@@ -1,39 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT LIST REORDER
11
- # -----------------------------------------------------------------------------
12
-
13
- @inputListReorder =
14
-
15
- # PRIVATE ===============================================
16
-
17
- _bind_reorder: ->
18
- list = @$items.get(0)
19
- new Slip(list)
20
-
21
- list.addEventListener 'slip:beforeswipe', (e) -> e.preventDefault()
22
-
23
- list.addEventListener 'slip:beforewait', ((e) ->
24
- if $(e.target).hasClass("icon-reorder") then e.preventDefault()
25
- ), false
26
-
27
- list.addEventListener 'slip:beforereorder', ((e) ->
28
- if not $(e.target).hasClass("icon-reorder") then e.preventDefault()
29
- ), false
30
-
31
- list.addEventListener 'slip:reorder', ((e) =>
32
- e.target.parentNode.insertBefore(e.target, e.detail.insertBefore)
33
- @_update_input_value()
34
- return false
35
- ), false
36
-
37
-
38
-
39
-
@@ -1,55 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT LIST TYPEAHEAD
11
- # -----------------------------------------------------------------------------
12
-
13
- @inputListTypeahead =
14
-
15
- # PRIVATE ===============================================
16
-
17
- _create_typeahead_el: (placeholder) ->
18
- # typeahead input for adding new items
19
- @typeaheadInput =$ "<input type='text' placeholder='#{ placeholder }' />"
20
- @$el.append @typeaheadInput
21
-
22
-
23
- _bind_typeahead: ->
24
- limit = @config.typeahead.limit || 5
25
- dataSource = new Bloodhound
26
- datumTokenizer: Bloodhound.tokenizers.obj.whitespace(@config.titleFieldName)
27
- queryTokenizer: Bloodhound.tokenizers.whitespace
28
- remote:
29
- url: @config.typeahead.url
30
- # exclude objects that are already in the list
31
- filter: (parsedResponse) =>
32
- data = []
33
- for o in parsedResponse
34
- @_normalize_object(o) ; if ! @objects[o._id] then data.push(o)
35
- return data
36
- limit: limit
37
-
38
- dataSource.initialize()
39
-
40
- @typeaheadInput.typeahead({
41
- hint: false
42
- highlight: true
43
- }, {
44
- name: @config.klassName
45
- displayKey: @config.titleFieldName
46
- source: dataSource.ttAdapter()
47
- })
48
-
49
- @typeaheadInput.on 'typeahead:selected', (e, object, dataset) =>
50
- @_render_item(object)
51
- @typeaheadInput.typeahead('val', '')
52
-
53
-
54
-
55
-
@@ -1,32 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT PASSWORD
11
- # -----------------------------------------------------------------------------
12
- class @InputPassword extends InputString
13
-
14
- # PRIVATE ===============================================
15
-
16
- _add_input: ->
17
- @$input =$ "<input type='password' name='#{ @name }' value='#{ @value }' />"
18
- @$input.on 'keyup', (e) => @$input.trigger('change')
19
- @$el.append @$input
20
-
21
-
22
- # PUBLIC ================================================
23
-
24
- updateValue: (@value) ->
25
- @$input.val(@value)
26
-
27
-
28
- chr.formInputs['password'] = InputPassword
29
-
30
-
31
-
32
-
@@ -1,84 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT SELECT
11
- # -----------------------------------------------------------------------------
12
-
13
- class @InputSelect extends InputString
14
-
15
- # PRIVATE ===============================================
16
-
17
- _create_el: ->
18
- @$el =$ "<div class='input-#{ @config.type } input-#{ @config.klass } input-#{ @config.klassName }'>"
19
-
20
-
21
- _add_input: ->
22
- @$input =$ """<select name='#{ @name }'></select>"""
23
- @$el.append @$input
24
-
25
- @_add_options()
26
-
27
-
28
- _add_options: ->
29
- if @config.optionsHashFieldName
30
- @value = String(@value)
31
- if @object
32
- @config.optionsHash = @object[@config.optionsHashFieldName]
33
- else
34
- @config.optionsHash = { '': '--' }
35
-
36
- if @config.collection
37
- @_add_collection_options()
38
-
39
- else if @config.optionsList
40
- @_add_list_options()
41
-
42
- else if @config.optionsHash
43
- @_add_hash_options()
44
-
45
-
46
- _add_collection_options: ->
47
- for o in @config.collection.data
48
- title = o[@config.collection.titleField]
49
- value = o[@config.collection.valueField]
50
- @_add_option(title, value)
51
-
52
-
53
- _add_list_options: ->
54
- data = @config.optionsList
55
- for o in data
56
- @_add_option(o, o)
57
-
58
-
59
- _add_hash_options: ->
60
- data = @config.optionsHash
61
- for value, title of data
62
- @_add_option(title, value)
63
-
64
-
65
- _add_option: (title, value) ->
66
- selected = if @value == value then 'selected' else ''
67
- $option =$ """<option value='#{ value }' #{ selected }>#{ title }</option>"""
68
- @$input.append $option
69
-
70
-
71
- # PUBLIC ================================================
72
-
73
- updateValue: (@value, @object) ->
74
- @$input.html('')
75
- @_add_options()
76
-
77
- @$input.val(@value).prop('selected', true)
78
-
79
-
80
- chr.formInputs['select'] = InputSelect
81
-
82
-
83
-
84
-
@@ -1,33 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT SELECT 2
11
- # -----------------------------------------------------------------------------
12
- #
13
- # Dependencies:
14
- #= require vendor/select2
15
- #
16
- # -----------------------------------------------------------------------------
17
-
18
- class @InputSelect2 extends InputSelect
19
- initialize: ->
20
- @config.beforeInitialize?(this)
21
-
22
- # https://select2.github.io/options.html
23
- options = @config.pluginOptions || {}
24
- @$input.select2(options)
25
-
26
- @config.onInitialize?(this)
27
-
28
-
29
- chr.formInputs['select2'] = InputSelect2
30
-
31
-
32
-
33
-
@@ -1,160 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT STRING
11
- # -----------------------------------------------------------------------------
12
- # Basic string input implementation, this is base class for many chr inputs.
13
- # This input also serves as a demo for implementing other input types.
14
- #
15
- # Public methods:
16
- # initialize() - run input plugin initializations if any
17
- # hash(hash) - update hash with inputs: hash[name] = value
18
- # updateValue(@value) - update inputs value
19
- # showErrorMessage(message) - show error (validation) message for input
20
- # hideErrorMessage() - hide error message
21
- #
22
- # Dependencies:
23
- #= require vendor/jquery.typeahead
24
- #
25
- # -----------------------------------------------------------------------------
26
- class @InputString
27
- constructor: (@name, @value, @config, @object) ->
28
- @_create_el()
29
- @_add_label()
30
- @_add_input()
31
- @_add_placeholder()
32
- @_add_disabled()
33
- @_add_required()
34
- @_add_limit()
35
-
36
- return this
37
-
38
-
39
- # PRIVATE ===============================================
40
-
41
- _safe_value: ->
42
- if typeof(@value) == 'object'
43
- return JSON.stringify(@value)
44
- else
45
- return _escapeHtml(@value)
46
-
47
-
48
- _create_el: ->
49
- @$el =$ "<label for='#{ @name }' class='input-#{ @config.type } input-#{ @config.klass } input-#{ @config.klassName }'>"
50
-
51
-
52
- _add_label: ->
53
- @$label =$ "<span class='label'>#{ @config.label }</span>"
54
- @$errorMessage =$ "<span class='error-message'></span>"
55
- @$label.append(@$errorMessage)
56
- @$el.append(@$label)
57
-
58
-
59
- _add_input: ->
60
- @$input =$ "<input type='text' name='#{ @name }' value='#{ @_safe_value() }' />"
61
- # trigger change event on keyup so value is cached while typing
62
- @$input.on 'keyup', (e) => @$input.trigger('change')
63
- @$el.append @$input
64
-
65
-
66
- if @config.options and $.isArray(@config.options)
67
- data = new Bloodhound
68
- datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value')
69
- queryTokenizer: Bloodhound.tokenizers.whitespace
70
- local: $.map @config.options, (opt) -> { value: opt }
71
-
72
- data.initialize()
73
-
74
- @$input.typeahead({
75
- hint: true
76
- highlight: true
77
- minLength: 1
78
- },
79
- {
80
- name: 'options'
81
- displayKey: 'value'
82
- source: data.ttAdapter()
83
- })
84
-
85
-
86
- _add_placeholder: ->
87
- if @config.klass in [ 'placeholder', 'stacked' ]
88
- @$input.attr 'placeholder', @config.label
89
-
90
- if @config.placeholder
91
- @$input.attr 'placeholder', @config.placeholder
92
-
93
-
94
- _add_disabled: ->
95
- if @config.disabled
96
- @$input.prop('disabled', true)
97
- @$el.addClass('input-disabled')
98
-
99
-
100
- _add_required: ->
101
- if @config.required
102
- @$el.addClass('input-required')
103
-
104
-
105
- _add_limit: ->
106
- if @config.limit
107
- @$charCounter =$ "<span class='input-character-counter'></span>"
108
- @$errorMessage.before @$charCounter
109
- @$input.on 'keyup', =>
110
- @_update_character_counter()
111
- @_update_character_counter()
112
-
113
-
114
- _update_character_counter: ->
115
- characters = @$input.val().length
116
- left = @config.limit - characters
117
-
118
- if left >= 0
119
- @$charCounter.html("(#{ left } left)")
120
-
121
- else
122
- @$charCounter.html("(#{ left })")
123
-
124
-
125
- if characters > @config.limit
126
- @$charCounter.addClass('exceeds')
127
- else
128
- @$charCounter.removeClass('exceeds')
129
-
130
-
131
- # PUBLIC ================================================
132
-
133
- initialize: ->
134
- @config.onInitialize?(this)
135
-
136
-
137
- hash: (hash={}) ->
138
- hash[@config.klassName] = @$input.val()
139
- return hash
140
-
141
-
142
- updateValue: (@value) ->
143
- @$input.val(@value)
144
-
145
-
146
- showErrorMessage: (message) ->
147
- @$el.addClass('error')
148
- @$errorMessage.html(message)
149
-
150
-
151
- hideErrorMessage: ->
152
- @$el.removeClass('error')
153
- @$errorMessage.html('')
154
-
155
-
156
- chr.formInputs['string'] = InputString
157
-
158
-
159
-
160
-
@@ -1,43 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Author: Alexander Kravets <alex@slatestudio.com>,
3
- # Slate Studio (http://www.slatestudio.com)
4
- #
5
- # Coding Guide:
6
- # https://github.com/thoughtbot/guides/tree/master/style/coffeescript
7
- # -----------------------------------------------------------------------------
8
-
9
- # -----------------------------------------------------------------------------
10
- # INPUT TEXT
11
- # -----------------------------------------------------------------------------
12
- #
13
- # Dependencies:
14
- #= require vendor/jquery.scrollparent
15
- #= require vendor/jquery.textarea_autosize
16
- #
17
- # -----------------------------------------------------------------------------
18
- class @InputText extends InputString
19
-
20
- # PRIVATE ===============================================
21
-
22
- _add_input: ->
23
- @$input =$ "<textarea class='autosize' name='#{ @name }' rows=1>#{ @_safe_value() }</textarea>"
24
- # trigger change event on keyup so value is cached while typing
25
- @$input.on 'keyup', (e) => @$input.trigger('change')
26
- @$el.append @$input
27
-
28
-
29
- # PUBLIC ================================================
30
-
31
- initialize: ->
32
- @config.beforeInitialize?(this)
33
-
34
- @$input.textareaAutoSize()
35
-
36
- @config.onInitialize?(this)
37
-
38
-
39
- chr.formInputs['text'] = InputText
40
-
41
-
42
-
43
-