Skip to content
Browse files

List of ids moved to admin config page

  • Loading branch information...
1 parent 0d8182e commit fac95cdb37ad02199f06366b6f2f9c653908819e @alexshuhin alexshuhin committed
View
5 app/views/admin/editor_settings/edit.html.erb
@@ -11,6 +11,11 @@
<label><%= t('rich_editor_engine') %>:</label>
<%= select_tag 'preferences[current_editor]', options_for_select(SpreeEditor::EditorEngines, Spree::Editor::Config[:current_editor]) %>
</p>
+ <p>
+ <label><%= t('rich_editor_ids') %>:</label>
+ <%= text_field_tag 'preferences[ids]', Spree::Editor::Config[:ids] %>
+ <small><%= t('rich_editor_ids_description') %></small>
+ </p>
<p class="form-buttons">
<%= button t('update') %>
<%= t("or") %> <%= link_to t("cancel"), admin_editor_settings_url %>
View
4 app/views/admin/editor_settings/show.html.erb
@@ -11,6 +11,10 @@
<td><%= t('rich_editor_engine') %>:</td>
<td><%= Spree::Editor::Config[:current_editor] %></td>
</tr>
+ <tr>
+ <td><%= t('rich_editor_ids') %>:</td>
+ <td><%= Spree::Editor::Config[:ids] %></td>
+ </tr>
</table>
<p><%= link_to_with_icon 'edit', t("edit"), edit_admin_editor_settings_path %></p>
View
5 app/views/shared/_rich_editor_javascript.html.erb
@@ -1,7 +1,8 @@
<% is_enabled = Spree::Editor::Config[:enabled] %>
<% current_editor = Spree::Editor::Config[:current_editor] %>
+<% ids = Spree::Editor::Config[:ids].split %>
-<% if RICH_EDITOR_IDS and RICH_EDITOR_IDS.any? and is_enabled and not current_editor.empty? %>
+<% if is_enabled and ids.any? %>
<%= render :partial => "shared/editor_engines/#{Spree::Editor::Config[:current_editor].underscore}",
- :locals => { :ids => RICH_EDITOR_IDS } %>
+ :locals => { :ids => ids } %>
<% end %>
View
18 app/views/shared/editor_engines/_yui_rich_editor.html.erb
@@ -13,15 +13,13 @@
<script type="text/javascript">
$(function() {
- (function() {
- var myConfig = { dompath: true };
- var ids = [<%= ids.map{|id| "'#{id}'"}.join(', ') %>]
- $.each(ids, function(index, id) {
- if ($('#' + id)) {
- var myEditor = new YAHOO.widget.SimpleEditor(id, myConfig);
- myEditor.render();
- }
- });
- })();
+ var myConfig = { dompath: true };
+ var ids = [<%= ids.map{|id| "'#{id}'"}.join(', ') %>]
+ $.each(ids, function(index, id) {
+ if ($('#' + id)) {
+ var myEditor = new YAHOO.widget.SimpleEditor(id, myConfig);
+ myEditor.render();
+ }
+ });
});
</script>
View
1 config/initializers/editor_config.rb
@@ -1 +0,0 @@
-# define RICH_EDITOR_IDS constant to apply Rich Editor to listed textarea ids
View
4 config/locales/en.yml
@@ -3,4 +3,6 @@ en:
enable_rich_editor: "Enable Rich Editor"
rich_editor: "Rich Editor"
rich_editor_description: "Configure Rich Editor settings."
- rich_editor_engine: "Rich Editor engine"
+ rich_editor_engine: "Rich Editor engine"
+ rich_editor_ids: "Rich Editor Identificators"
+ rich_editor_ids_description: "List ids splitted by spaces here"
View
1 lib/editor_configuration.rb
@@ -1,4 +1,5 @@
class EditorConfiguration < Configuration
preference :enabled, :boolean, :default => true
preference :current_editor, :string, :default => 'YUIRichEditor'
+ preference :ids, :string, :default => 'product_description'
end

0 comments on commit fac95cd

Please sign in to comment.
Something went wrong with that request. Please try again.