locomotive_cms 2.1.4 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/Gemfile +1 -5
  2. data/app/assets/images/locomotive/icons/flags/zh-CN.png +0 -0
  3. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/css/inputcontrol.css +3 -0
  4. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/lib/inputcontrol-plugin.js +94 -0
  5. data/app/assets/javascripts/aloha/plugins/custom/inputcontrol/package.json +1 -0
  6. data/app/assets/javascripts/locomotive.js +2 -1
  7. data/app/assets/javascripts/locomotive/models/content_type.js.coffee +6 -2
  8. data/app/assets/javascripts/locomotive/models/page.js.coffee +1 -1
  9. data/app/assets/javascripts/locomotive/models/site.js.coffee +1 -1
  10. data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +17 -7
  11. data/app/assets/javascripts/locomotive/utils/tinymce_settings.js.coffee +6 -0
  12. data/app/assets/javascripts/locomotive/views/application_view.js.coffee +13 -2
  13. data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +19 -2
  14. data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +1 -1
  15. data/app/assets/javascripts/locomotive/views/content_entries/index_view.js.coffee +2 -2
  16. data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +2 -1
  17. data/app/assets/javascripts/locomotive/views/content_types/custom_field_entry_view.js.coffee +3 -0
  18. data/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +2 -1
  19. data/app/assets/javascripts/locomotive/views/editable_elements/edit_all_view.js.coffee +3 -6
  20. data/app/assets/javascripts/locomotive/views/editable_elements/text_view.js.coffee +47 -0
  21. data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +1 -1
  22. data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +2 -1
  23. data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +2 -2
  24. data/app/assets/javascripts/locomotive/views/shared/fields/belongs_to_view.js.coffee +32 -0
  25. data/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee +2 -2
  26. data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +2 -2
  27. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +2 -0
  28. data/app/assets/javascripts/locomotive/views/snippets/_form_view.js.coffee +2 -1
  29. data/app/assets/javascripts/locomotive/views/theme_assets/_form_view.js.coffee +2 -1
  30. data/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee +0 -1
  31. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/es.js +1 -0
  32. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/et.js +1 -0
  33. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/it.js +1 -0
  34. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/ja.js +1 -0
  35. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nb.js +1 -0
  36. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/nl.js +1 -0
  37. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/no.js +1 -0
  38. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pl.js +1 -0
  39. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/pt.js +1 -0
  40. data/app/assets/javascripts/tinymce/plugins/locomotive_media/langs/zh-cn.js +1 -0
  41. data/app/assets/stylesheets/locomotive.css +1 -0
  42. data/app/assets/stylesheets/locomotive/backoffice/codemirror_changes.css.scss +2 -0
  43. data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +17 -3
  44. data/app/controllers/locomotive/content_entries_controller.rb +6 -2
  45. data/app/controllers/locomotive/public/content_entries_controller.rb +6 -0
  46. data/app/helpers/locomotive/base_helper.rb +8 -0
  47. data/app/helpers/locomotive/sites_helper.rb +6 -0
  48. data/app/models/locomotive/content_entry.rb +35 -5
  49. data/app/models/locomotive/content_type.rb +26 -8
  50. data/app/models/locomotive/editable_element.rb +15 -1
  51. data/app/models/locomotive/editable_file.rb +0 -2
  52. data/app/models/locomotive/editable_long_text.rb +3 -3
  53. data/app/models/locomotive/editable_short_text.rb +3 -64
  54. data/app/models/locomotive/editable_text.rb +84 -0
  55. data/app/models/locomotive/extensions/content_entry/csv.rb +7 -3
  56. data/app/models/locomotive/extensions/page/editable_elements.rb +3 -5
  57. data/app/models/locomotive/extensions/site/locales.rb +20 -0
  58. data/app/models/locomotive/extensions/site/timezone.rb +35 -0
  59. data/app/models/locomotive/site.rb +20 -16
  60. data/app/models/locomotive/theme_asset.rb +1 -1
  61. data/app/presenters/locomotive/content_entry_presenter.rb +1 -1
  62. data/app/presenters/locomotive/{editable_short_text_presenter.rb → editable_text_presenter.rb} +14 -2
  63. data/app/views/locomotive/current_site/_form.html.haml +1 -0
  64. data/app/views/locomotive/custom_fields/types/_belongs_to.html.haml +6 -5
  65. data/app/views/locomotive/pages/_editable_elements.html.haml +1 -1
  66. data/app/views/locomotive/shared/_head.html.haml +2 -0
  67. data/app/views/locomotive/shared/_main_app_head_before_backbone.html.haml +1 -0
  68. data/config/locales/admin_ui.de.yml +1 -0
  69. data/config/locales/admin_ui.en.yml +1 -0
  70. data/config/locales/admin_ui.et.yml +1 -0
  71. data/config/locales/admin_ui.fr.yml +1 -0
  72. data/config/locales/admin_ui.ja.yml +1 -0
  73. data/config/locales/admin_ui.nb.yml +2 -0
  74. data/config/locales/admin_ui.pl.yml +1 -0
  75. data/config/locales/admin_ui.pt-BR.yml +2 -1
  76. data/config/locales/admin_ui.ru.yml +24 -4
  77. data/config/locales/admin_ui.zh-CN.yml +347 -0
  78. data/config/locales/carrierwave.zh-CN.yml +4 -0
  79. data/config/locales/default.zh-CN.yml +116 -0
  80. data/config/locales/devise.nb.yml +1 -0
  81. data/config/locales/devise.zh-CN.yml +64 -0
  82. data/config/locales/flash.zh-CN.yml +115 -0
  83. data/config/locales/formtastic.en.yml +1 -0
  84. data/config/locales/formtastic.ru.yml +4 -1
  85. data/config/locales/formtastic.zh-CN.yml +112 -0
  86. data/features/backoffice/content_types/localized.feature +63 -0
  87. data/features/backoffice/pages.feature +3 -1
  88. data/features/backoffice/site.feature +7 -0
  89. data/features/public/contact_form.feature +11 -0
  90. data/features/public/content_entries.feature +13 -0
  91. data/features/public/pages.feature +24 -0
  92. data/features/step_definitions/page_steps.rb +6 -0
  93. data/features/step_definitions/web_steps.rb +24 -7
  94. data/lib/generators/locomotive/install/templates/locomotive.rb +2 -2
  95. data/lib/generators/locomotive/install/templates/mongoid.yml +23 -29
  96. data/lib/locomotive.rb +1 -4
  97. data/lib/locomotive/configuration.rb +3 -3
  98. data/lib/locomotive/dependencies.rb +1 -0
  99. data/lib/locomotive/engine.rb +2 -1
  100. data/lib/locomotive/liquid/drops/page.rb +1 -1
  101. data/lib/locomotive/liquid/filters/date.rb +3 -1
  102. data/lib/locomotive/liquid/filters/misc.rb +4 -0
  103. data/lib/locomotive/liquid/filters/text.rb +4 -0
  104. data/lib/locomotive/liquid/tags/editable.rb +1 -2
  105. data/lib/locomotive/liquid/tags/editable/text.rb +79 -0
  106. data/lib/locomotive/liquid/tags/inline_editor.rb +1 -1
  107. data/lib/locomotive/liquid/tags/link_to.rb +72 -13
  108. data/lib/locomotive/liquid/tags/with_scope.rb +3 -3
  109. data/lib/locomotive/middlewares.rb +0 -1
  110. data/lib/locomotive/mongoid/patches.rb +0 -16
  111. data/lib/locomotive/render.rb +1 -1
  112. data/lib/locomotive/version.rb +1 -1
  113. data/lib/tasks/locomotive.rake +15 -9
  114. data/mongodb/migrate/20130326201349_rename_entry_to_content_entry.rb +1 -1
  115. data/mongodb/migrate/20130621135025_create_editable_texts.rb +42 -0
  116. data/mongodb/migrate/20130627101548_localize_slugs_of_content_entries.rb +43 -0
  117. data/spec/dummy/config/initializers/locomotive.rb +1 -1
  118. data/spec/dummy/config/initializers/session_store.rb +1 -1
  119. data/spec/lib/locomotive/liquid/drops/page_spec.rb +1 -1
  120. data/spec/lib/locomotive/liquid/filters/misc_spec.rb +26 -0
  121. data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +85 -0
  122. data/spec/lib/locomotive/liquid/tags/link_to_spec.rb +111 -0
  123. data/spec/lib/locomotive/liquid/tags/with_scope_spec.rb +6 -0
  124. data/spec/models/locomotive/content_entry_spec.rb +27 -7
  125. data/spec/models/locomotive/{editable_short_text_spec.rb → editable_text_spec.rb} +53 -8
  126. data/spec/models/locomotive/extensions/page/editable_elements_spec.rb +6 -6
  127. data/spec/models/locomotive/site_spec.rb +52 -32
  128. data/vendor/assets/images/select2-spinner.gif +0 -0
  129. data/vendor/assets/images/select2.png +0 -0
  130. data/vendor/assets/images/select2x2.png +0 -0
  131. data/vendor/assets/javascripts/locomotive/liquid_mode.js +1 -1
  132. data/vendor/assets/javascripts/select2/select2.js +3054 -0
  133. data/vendor/assets/stylesheets/select2/select2.css.scss +652 -0
  134. metadata +77 -33
  135. data/app/assets/javascripts/locomotive/views/editable_elements/long_text_view.js.coffee +0 -36
  136. data/app/assets/javascripts/locomotive/views/editable_elements/short_text_view.js.coffee +0 -22
  137. data/app/presenters/locomotive/editable_long_text_presenter.rb +0 -5
  138. data/lib/locomotive/liquid/tags/editable/long_text.rb +0 -33
  139. data/lib/locomotive/liquid/tags/editable/short_text.rb +0 -41
  140. data/lib/locomotive/middlewares/fonts.rb +0 -42
  141. data/lib/locomotive/session_store.rb +0 -64
  142. data/spec/lib/locomotive/liquid/tags/editable/short_text_spec.rb +0 -46
  143. data/spec/models/locomotive/editable_long_text_spec.rb +0 -50
data/Gemfile CHANGED
@@ -45,16 +45,13 @@ group :test do
45
45
  # gem 'autotest', platforms: :mri
46
46
  # gem 'ZenTest', platforms: :mri
47
47
 
48
- # gem 'growl-glue'
49
48
  gem 'poltergeist', '~> 1.1.0'
50
49
  gem 'shoulda-matchers', '~> 1.5.2'
51
50
 
52
51
  gem 'factory_girl_rails', '~> 4.2.1'
53
52
  gem 'pickle'
54
53
 
55
- gem 'capybara', '~> 2.0.2' #, require: false
56
-
57
- # gem 'xpath', '~> 0.1.4'
54
+ gem 'capybara', '~> 2.0.2'
58
55
 
59
56
  gem 'json_spec'
60
57
 
@@ -62,6 +59,5 @@ group :test do
62
59
 
63
60
  gem 'mocha', '~> 0.13.0', require: false
64
61
 
65
-
66
62
  # gem 'debugger', git: 'git://github.com/cldwalker/debugger.git'
67
63
  end
@@ -0,0 +1,3 @@
1
+ .aloha-input-invalid {
2
+ border: 1px solid red;
3
+ }
@@ -0,0 +1,94 @@
1
+ /*!
2
+ * Aloha Editor
3
+ * Copyright (c) 2010 Gentics Software GmbH
4
+ * aloha-sales@gentics.com
5
+ * Author Nicolas Karageuzian
6
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
7
+ # https://github.com/temistokles/Aloha-Plugin-InputControl
8
+ */
9
+
10
+ define(
11
+ ['aloha/plugin', 'aloha'],
12
+ function (plugin, Aloha) {
13
+ "use strict";
14
+
15
+ /**
16
+ * register the plugin with unique name
17
+ */
18
+ return plugin.create('inputcontrol', {
19
+ _constructor: function(){
20
+ this._super('inputcontrol');
21
+ },
22
+ /**
23
+ * Initialize the plugin and set initialize flag on true
24
+ */
25
+ init: function () {
26
+ var inputmask = this;
27
+ inputmask.bindEvents();
28
+ },
29
+
30
+ config: {
31
+ "enableFilter": false,
32
+ "allowchars": new RegExp('.'), // allows any character (default)
33
+ "enableMask": false
34
+ },
35
+ bindEvents: function() {
36
+ var inputmask = this;
37
+ Aloha.bind('aloha-editable-created', function(event, editable){
38
+ var edConfig = inputmask.getEditableConfig(editable.obj);
39
+ if (edConfig.enableFilter) {
40
+ //filtering is enabled, watching keypress (to get the unicode charcode)
41
+ editable.obj.keypress(function(event){ // listen for keypress (then get the unicode char)
42
+ var
43
+ k = event.which, chr,
44
+ result = true;
45
+ chr = String.fromCharCode(k);
46
+ if (edConfig.allowchars instanceof RegExp){
47
+ Aloha.Log.debug(Aloha, "Keycode : [" + k + "] char : '" + chr + "'");
48
+ result = result && edConfig.allowchars.test(chr);
49
+ }
50
+ return result;
51
+ });
52
+ }
53
+ if (edConfig.disableEnter) {
54
+ editable.obj.unbind('keydown'); // unbinding aloha preprocess
55
+ editable.obj.keydown(function(event) {
56
+ if (event.keyCode === 13) {
57
+ return false;
58
+ }
59
+ return true; //Aloha.Markup.preProcessKeyStrokes();
60
+ });
61
+ }
62
+ if (edConfig.enableMask) { // TODO: debug in here
63
+ editable.obj.blur(function (event){
64
+ var $this = $(this);
65
+ if (edConfig.type === Number) {
66
+ if (new Number($this.text()).toString() === "NaN") {
67
+ $this.addClass('aloha-input-invalid');
68
+ } else {
69
+ $this.removeClass('aloha-input-invalid');
70
+ }
71
+ }
72
+ if (typeof edConfig.maxlength === "number") {
73
+ if (edConfig.striphtml) {
74
+ if ($this.text().length >= edConfig.maxlength) {
75
+ $this.addClass('aloha-input-invalid');
76
+ } else {
77
+ $this.removeClass('aloha-input-invalid');
78
+ }
79
+ } else {
80
+ if ($this.html().length >= edConfig.maxlength) {
81
+ $this.addClass('aloha-input-invalid');
82
+ } else {
83
+ $this.removeClass('aloha-input-invalid');
84
+ }
85
+ }
86
+ }
87
+ return true;
88
+ });
89
+ }
90
+ });
91
+ }
92
+
93
+ });
94
+ });
@@ -11,7 +11,8 @@
11
11
  //= require backbone
12
12
  //= require codemirror
13
13
  //= require tinymce-jquery
14
- //= require codemirror/utils/overlay
14
+ //= require select2/select2
15
+ //= require codemirror/addons/mode/overlay
15
16
  //= require codemirror/modes/css
16
17
  //= require codemirror/modes/javascript
17
18
  //= require codemirror/modes/xml
@@ -8,8 +8,12 @@ class Locomotive.Models.ContentType extends Backbone.Model
8
8
  @_normalize()
9
9
 
10
10
  _normalize: ->
11
- @set
12
- entries_custom_fields: new Locomotive.Models.CustomFieldsCollection(@get('entries_custom_fields'))
11
+ fields = @get('entries_custom_fields')
12
+ fields = [] if !fields?
13
+
14
+ if _.isArray(fields)
15
+ @set
16
+ entries_custom_fields: new Locomotive.Models.CustomFieldsCollection(fields)
13
17
 
14
18
  find_entries_custom_field: (name) ->
15
19
  @get('entries_custom_fields').find((field) => field.get('name') == name)
@@ -16,7 +16,7 @@ class Locomotive.Models.Page extends Backbone.Model
16
16
 
17
17
  toJSON: ->
18
18
  _.tap super, (hash) =>
19
- _.each ['fullpath', 'localized_fullpaths', 'templatized_from_parent', 'target_klass_name_text', 'content_type_id_text', 'edit_url', 'parent_id_text', 'response_type_text', 'translated_in'], (key) => delete hash[key]
19
+ _.each ['fullpath', 'localized_fullpaths', 'templatized_from_parent', 'template_changed', 'escaped_raw_template', 'target_klass_name_text', 'content_type_id_text', 'edit_url', 'parent_id_text', 'response_type_text', 'translated_in'], (key) => delete hash[key]
20
20
 
21
21
  delete hash['editable_elements']
22
22
  hash.editable_elements = @get('editable_elements').toJSONForSave() if @get('editable_elements')? && @get('editable_elements').length > 0
@@ -20,7 +20,7 @@ class Locomotive.Models.Site extends Backbone.Model
20
20
 
21
21
  toJSON: ->
22
22
  _.tap super, (hash) =>
23
- _.each ['locales_text'], (key) => delete hash[key]
23
+ _.each ['locales_text', 'timezone_name_text'], (key) => delete hash[key]
24
24
  delete hash.memberships
25
25
  hash.memberships_attributes = @get('memberships').toJSONForSave() if @get('memberships')? && @get('memberships').length > 0
26
26
  delete hash.domains
@@ -9,19 +9,29 @@ window.Aloha.settings =
9
9
  plugins:
10
10
 
11
11
  format:
12
- config: [ 'b', 'i', 'u','del','sub','sup', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat']
12
+ config: ['b', 'i', 'u', 'del', 'sub', 'sup', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat']
13
13
  editables:
14
- '.editable-short-text' : [ 'b', 'i', 'u' ]
14
+ '.editable-single-text': ['b', 'i', 'u', 'del', 'sub', 'sup']
15
15
 
16
- link:
17
- config: [ 'a' ]
16
+ inputcontrol:
18
17
  editables:
19
- '.editable-short-text': [ ]
18
+ '.editable-single-text':
19
+ disableEnter: true
20
+
21
+ link:
22
+ config: ['a']
20
23
 
21
24
  list:
22
- config: [ 'ul' ]
25
+ config: ['ul']
26
+ editables:
27
+ '.editable-single-text': []
28
+
29
+ align:
30
+ config:
31
+ alignment: ['right','left','center','justify']
23
32
  editables:
24
- '.editable-short-text': [ ]
33
+ '.editable-single-text':
34
+ alignment: []
25
35
 
26
36
  image:
27
37
  ui:
@@ -26,9 +26,15 @@ window.Locomotive.tinyMCE =
26
26
  theme_advanced_buttons3: ''
27
27
  theme_advanced_toolbar_location: 'top'
28
28
  theme_advanced_toolbar_align: 'left'
29
+ theme_advanced_resizing_min_height: 20
30
+ theme_advanced_path: false
31
+ theme_advanced_statusbar_location: false
29
32
  height: '20'
30
33
  width: '709'
31
34
  convert_urls: false
35
+ forced_root_block: false
36
+ force_br_newlines: true
37
+ force_p_newlines: false
32
38
 
33
39
  popupSettings:
34
40
  theme: 'advanced'
@@ -13,8 +13,7 @@ class Locomotive.Views.ApplicationView extends Backbone.View
13
13
 
14
14
  @enable_content_locale_picker()
15
15
 
16
- window.Locomotive.tinyMCE.defaultSettings.language = window.locale # set the default tinyMCE language
17
- window.Locomotive.tinyMCE.minimalSettings.language = window.locale
16
+ @set_locale_for_tinymce_widgets()
18
17
 
19
18
  # render page view
20
19
  if @options.view?
@@ -83,6 +82,18 @@ class Locomotive.Views.ApplicationView extends Backbone.View
83
82
  locale = $(@).data('locale')
84
83
  window.addParameterToURL 'content_locale', locale
85
84
 
85
+ set_locale_for_tinymce_widgets: ->
86
+ # tinyMCE likes only lowercase locales
87
+ tinymce_locale = window.locale.toLowerCase()
88
+
89
+ # pt-BR does not exist, pt does though
90
+ tinymce_locale = 'pt' if tinymce_locale == 'pt-br'
91
+
92
+ # set the default tinyMCE language
93
+ window.Locomotive.tinyMCE.defaultSettings.language = tinymce_locale
94
+ window.Locomotive.tinyMCE.minimalSettings.language = tinymce_locale
95
+ window.Locomotive.tinyMCE.popupSettings.language = tinymce_locale
96
+
86
97
  unique_dialog_zindex: ->
87
98
  # returns the number of jQuery UI modals created in order to set a valid zIndex for each of them.
88
99
  # Each modal window should have a different zIndex, otherwise there will be conflicts between them.
@@ -10,6 +10,8 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
10
10
 
11
11
  _file_field_views: []
12
12
 
13
+ _belongs_to_field_views: []
14
+
13
15
  _has_many_field_views: []
14
16
 
15
17
  _many_to_many_field_views: []
@@ -39,6 +41,8 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
39
41
 
40
42
  @enable_select_fields()
41
43
 
44
+ @enable_belongs_to_fields()
45
+
42
46
  @enable_file_fields()
43
47
 
44
48
  @enable_has_many_fields()
@@ -93,14 +97,27 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
93
97
  unless option.destroyed()
94
98
  $select.append(new Option(option.get('name'), option.get('id'), false, option.get('id') == @model.get("#{name}_id")))
95
99
 
100
+ enable_belongs_to_fields: ->
101
+ prefix = if @namespace? then "#{@namespace}_" else ''
102
+
103
+ _.each @model.get('belongs_to_custom_fields'), (name) =>
104
+ $el = @$("##{prefix}#{@model.paramRoot}_#{name}_id")
105
+
106
+ if $el.length > 0
107
+ view = new Locomotive.Views.Shared.Fields.BelongsToView model: @model, name: name, el: $el
108
+
109
+ @_belongs_to_field_views.push(view)
110
+
111
+ view.render()
112
+
96
113
  enable_file_fields: ->
114
+ prefix = if @namespace? then "#{@namespace}_" else ''
115
+
97
116
  _.each @model.get('file_custom_fields'), (name) =>
98
117
  view = new Locomotive.Views.Shared.Fields.FileView model: @model, name: name, namespace: @namespace
99
118
 
100
119
  @_file_field_views.push(view)
101
120
 
102
- prefix = if @namespace? then "#{@namespace}_" else ''
103
-
104
121
  @$("##{prefix}#{@model.paramRoot}_#{name}_input label").after(view.render().el)
105
122
 
106
123
  enable_has_many_fields: ->
@@ -88,4 +88,4 @@ class Locomotive.Views.ContentEntries.PopupFormView extends Locomotive.Views.Con
88
88
  # disabled in a popup form
89
89
 
90
90
  tinyMCE_settings: ->
91
- _.extend { language: window.locale }, window.Locomotive.tinyMCE.popupSettings
91
+ window.Locomotive.tinyMCE.popupSettings
@@ -30,7 +30,7 @@ class Locomotive.Views.ContentEntries.IndexView extends Backbone.View
30
30
  error: @.on_failed_sort
31
31
 
32
32
  on_successful_sort: (data, status, xhr) ->
33
- $.growl('success', xhr.getResponseHeader('X-Message'))
33
+ $.growl('success', decodeURIComponent $.parseJSON xhr.getResponseHeader('X-Message'))
34
34
 
35
35
  on_failed_sort: (data, status, xhr) ->
36
- $.growl('error', xhr.getResponseHeader('X-Message'))
36
+ $.growl('error', decodeURIComponent $.parseJSON xhr.getResponseHeader('X-Message'))
@@ -49,7 +49,8 @@ class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.For
49
49
  passDelay: 50
50
50
  tabMode: 'shift'
51
51
  theme: 'default'
52
- onChange: (editor) => @model.set(raw_item_template: editor.getValue())
52
+
53
+ @editor.on 'change', (editor, change) => @model.set(raw_item_template: editor.getValue())
53
54
 
54
55
  after_inputs_fold: ->
55
56
  @editor.refresh()
@@ -49,7 +49,10 @@ class Locomotive.Views.ContentTypes.CustomFieldEntryView extends Backbone.View
49
49
  when 'belongs_to'
50
50
  @$('li.input.localized').hide()
51
51
  @$('li.input.class-name').show()
52
+ when 'image'
53
+ @$('li.input.unique').hide()
52
54
  when 'has_many', 'many_to_many'
55
+ @$('li.input.unique').hide()
53
56
  @$('li.input.localized').hide()
54
57
  @$('li.input.class-name').show()
55
58
  @$('li.input.inverse-of').show()
@@ -64,7 +64,8 @@ class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.Form
64
64
  passDelay: 50
65
65
  tabMode: 'shift'
66
66
  theme: 'default'
67
- onChange: (editor) => @model.set(robots_txt: editor.getValue())
67
+
68
+ @editor.on 'change', (editor, change) => @model.set(robots_txt: editor.getValue())
68
69
 
69
70
  save: (event) ->
70
71
  # if @model.includes_domain(window.location.host)
@@ -9,8 +9,6 @@ class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
9
9
  _editable_elements_views: []
10
10
 
11
11
  render: ->
12
- window.bar = @
13
-
14
12
  if @collection.isEmpty()
15
13
  $(@el).hide()
16
14
  else
@@ -45,10 +43,9 @@ class Locomotive.Views.EditableElements.EditAllView extends Backbone.View
45
43
  element.set(index: index)
46
44
 
47
45
  view_class = switch element.get('type')
48
- when 'EditableShortText' then Locomotive.Views.EditableElements.ShortTextView
49
- when 'EditableLongText' then Locomotive.Views.EditableElements.LongTextView
50
- when 'EditableFile' then Locomotive.Views.EditableElements.FileView
51
- when 'EditableControl' then Locomotive.Views.EditableElements.ControlView
46
+ when 'EditableText' then Locomotive.Views.EditableElements.TextView
47
+ when 'EditableFile' then Locomotive.Views.EditableElements.FileView
48
+ when 'EditableControl' then Locomotive.Views.EditableElements.ControlView
52
49
 
53
50
  view = new view_class(model: element)
54
51
  @$("#block-#{block.index} > fieldset > ol").append(view.render().el)
@@ -0,0 +1,47 @@
1
+ Locomotive.Views.EditableElements ||= {}
2
+
3
+ class Locomotive.Views.EditableElements.TextView extends Backbone.View
4
+
5
+ tagName: 'li'
6
+
7
+ className: 'text input html'
8
+
9
+ default_line_height: 20
10
+
11
+ render: ->
12
+ $(@el).html(ich.editable_text_input(@model.toJSON()))
13
+
14
+ return @
15
+
16
+ after_render: ->
17
+ if @model.get('format') == 'html'
18
+ @$('textarea').tinymce(@tinymce_settings())
19
+ else
20
+ @$('textarea').bind 'keyup', (event) =>
21
+ input = $(event.target)
22
+ @model.set(content: input.val())
23
+
24
+ tinymce_settings: ->
25
+ base_settings = window.Locomotive.tinyMCE.defaultSettings
26
+
27
+ if @model.get('line_break') == false
28
+ base_settings = window.Locomotive.tinyMCE.minimalSettings
29
+
30
+ _.extend {}, base_settings,
31
+ height: @model.get('rows') * @default_line_height
32
+ oninit: ((editor) =>
33
+ $.cmd 'S', (() =>
34
+ @model.set(content: editor.getBody().innerHTML)
35
+ $(@el).parents('form').trigger('submit')
36
+ ), [], ignoreCase: true, document: editor.dom.doc),
37
+ onchange_callback: (editor) =>
38
+ @model.set(content: editor.getBody().innerHTML)
39
+
40
+ refresh: ->
41
+ # do nothing
42
+
43
+ remove: ->
44
+ if @model.get('format') == 'html'
45
+ @$('textarea').tinymce().remove()
46
+
47
+ super
@@ -78,7 +78,7 @@ class Locomotive.Views.InlineEditor.ToolbarView extends Backbone.View
78
78
 
79
79
  editable_elements: ->
80
80
  if @options.target[0].contentWindow.Aloha
81
- @options.target[0].contentWindow.Aloha.jQuery('.editable-long-text, .editable-short-text')
81
+ @options.target[0].contentWindow.Aloha.jQuery('.editable-text')
82
82
  else
83
83
  null
84
84
 
@@ -89,7 +89,8 @@ class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
89
89
  passDelay: 50
90
90
  tabMode: 'shift'
91
91
  theme: 'default'
92
- onChange: (editor) => @model.set(raw_template: editor.getValue())
92
+
93
+ @editor.on 'change', (editor, change) => @model.set(raw_template: editor.getValue())
93
94
 
94
95
  after_inputs_fold: ->
95
96
  @editor.refresh()