diff --git a/app/helpers/tinymce_helper.rb b/app/helpers/tinymce_helper.rb index 87e078d..c17c97c 100644 --- a/app/helpers/tinymce_helper.rb +++ b/app/helpers/tinymce_helper.rb @@ -20,18 +20,9 @@ module TinymceHelper :image_advtab => true, :language => tinymce_language - options[:toolbar1] = "fullscreen | insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" - if options[:mode] == 'simple' - options[:menubar] = false - else - options[:menubar] = 'edit insert view tools' - options[:toolbar2] = 'print preview code media | table' - - options[:toolbar2] += ' | macros' - macros_with_buttons.each do |macro| - options[:toolbar2] += " #{macro.identifier}" - end - end + options[:toolbar1] = toolbar1(options[:mode]) + options[:menubar] = menubar(options[:mode]) + options[:toolbar2] = toolbar2(options[:mode]) options[:macros_setup] = macros_with_buttons.map do |macro| <<-EOS @@ -49,4 +40,29 @@ module TinymceHelper "noosfero.tinymce.init(#{options.to_json})" end + def menubar mode + if mode =='restricted' || mode == 'simple' + return false + end + return 'edit insert view tools' + end + + def toolbar1 mode + if mode == 'restricted' + return "bold italic underline | link" + end + return "fullscreen | insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" + end + + def toolbar2 mode + if mode.blank? + toolbar2 = 'print preview code media | table' + toolbar2 += ' | macros' + macros_with_buttons.each do |macro| + toolbar2 += " #{macro.identifier}" + end + return toolbar2 + end + end + end diff --git a/features/step_definitions/tiny_mce_steps.rb b/features/step_definitions/tiny_mce_steps.rb new file mode 100644 index 0000000..e3ef335 --- /dev/null +++ b/features/step_definitions/tiny_mce_steps.rb @@ -0,0 +1,9 @@ +Then /^The tinymce "(.+)" should be "(.+)"$/ do |item, content| + item_value = page.evaluate_script("tinyMCE.activeEditor.getParam('#{item}');") + assert_equal item_value.to_s, content +end + +Then /^The tinymce "(.+)" should contain "(.+)"$/ do |item, content| + item_value = page.evaluate_script("tinyMCE.activeEditor.getParam('#{item}');") + assert_include item_value.to_s, content +end diff --git a/features/tiny_mce.feature b/features/tiny_mce.feature new file mode 100644 index 0000000..e114987 --- /dev/null +++ b/features/tiny_mce.feature @@ -0,0 +1,19 @@ +Feature: Create tinyMCE article + As an ordinary user + I want to create an tinymce + + Background: + Given the following users + | login | name | + | joaosilva | joao silva | + Given I am logged in as "joaosilva" + + @selenium + Scenario: mce complete mode should show on message creation + Given I am on joaosilva's control panel + And I follow "Manage Content" + And I follow "New content" + And I follow "Text article with visual editor" + Then The tinymce "toolbar1" should be "fullscreen | insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" + And The tinymce "menubar" should be "edit insert view tools" + And The tinymce "toolbar2" should contain "print preview code media | table" diff --git a/plugins/environment_notification/features/message_edition.feature b/plugins/environment_notification/features/message_edition.feature new file mode 100644 index 0000000..13a1763 --- /dev/null +++ b/plugins/environment_notification/features/message_edition.feature @@ -0,0 +1,14 @@ +Feature: Create envronment notification message + As an admin user + I want to create an environment notification + In order to notificate users + + @selenium + Scenario: mce restricted mode should show on message creation + Given I am logged in as admin + And I follow "Administration" + And I follow "Plugins" + And I follow "Configuration" + And I follow "New Notification" + Then The tinymce "toolbar1" should be "bold italic underline | link" + Then The tinymce "menubar" should be "false" diff --git a/plugins/environment_notification/public/environment_notification_plugin.js b/plugins/environment_notification/public/environment_notification_plugin.js index d11b622..0556aa1 100644 --- a/plugins/environment_notification/public/environment_notification_plugin.js +++ b/plugins/environment_notification/public/environment_notification_plugin.js @@ -53,17 +53,6 @@ } }, - mceRestrict: function() { - tinyMCE.init({ - menubar : false, - selector: "textarea", - plugins: [ - "autolink link" - ], - toolbar: "bold italic underline | link" - }); - }, - showPopup: function() { if($('.action-home-index').length > 0) { jQuery(function($){ @@ -83,10 +72,6 @@ $(".environment-notification-plugin-notification-bar .notification-close").on("click", environment_notification_plugin.closeNotification); $(".environment-notification-plugin-notification-bar .notification-hide").on("click", environment_notification_plugin.hideNotification); - if($('.environment-notification-plugin-message').length > 0){ - environment_notification_plugin.mceRestrict(); - } - if($('.environment-notification-plugin-notification-bar').length > 0){ environment_notification_plugin.hideUserNotification(); } @@ -96,4 +81,4 @@ } }); -})($); \ No newline at end of file +})($); diff --git a/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb b/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb index 418f420..f441219 100644 --- a/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb +++ b/plugins/environment_notification/views/environment_notification_plugin_admin/_form.html.erb @@ -1,11 +1,12 @@