From c802f0a88620170e79e164e1c91cd8c07312b5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20de=20Villamil?= Date: Fri, 30 Aug 2013 19:08:46 +0200 Subject: [PATCH] Adds a per textfilter toolbar (markdown, textile, none). TODO: * The markdown and textile links use html ones, too lazy. * Change the toolbar when you change the filter (JS sucks). * Rewrite the whole thing to make it less 2003 ish. --- app/views/admin/content/_form.html.erb | 4 +- app/views/admin/feedback/article.html.erb | 2 +- app/views/admin/feedback/edit.html.erb | 4 +- app/views/admin/notes/new.html.erb | 2 +- app/views/admin/pages/_form.html.erb | 2 +- public/javascripts/administration.js | 183 +++++++--------------- 6 files changed, 67 insertions(+), 130 deletions(-) diff --git a/app/views/admin/content/_form.html.erb b/app/views/admin/content/_form.html.erb index 200afc5eea..b0dac3a3a1 100644 --- a/app/views/admin/content/_form.html.erb +++ b/app/views/admin/content/_form.html.erb @@ -36,7 +36,7 @@
'> - +
> @@ -44,7 +44,7 @@
> - <%= text_area('article', 'body_and_extended', {:class => 'input-block-level', :height => '300px'}) if current_user.editor == 'simple' %> + <%= text_area('article', 'body_and_extended', {:class => 'input-block-level', :height => '360px'}) if current_user.editor == 'simple' %> <%= render 'admin/shared/macros' if current_user.editor == 'simple' %>
diff --git a/app/views/admin/feedback/article.html.erb b/app/views/admin/feedback/article.html.erb index 580554ef46..62b33ede4e 100644 --- a/app/views/admin/feedback/article.html.erb +++ b/app/views/admin/feedback/article.html.erb @@ -50,7 +50,7 @@
- + <%= text_area 'comment', 'body', { :rows => '10', :class => 'span6'} %>
diff --git a/app/views/admin/feedback/edit.html.erb b/app/views/admin/feedback/edit.html.erb index 8bb34571d4..91fb42ca9c 100644 --- a/app/views/admin/feedback/edit.html.erb +++ b/app/views/admin/feedback/edit.html.erb @@ -28,8 +28,8 @@
- - <%= text_area 'comment', 'body', { :rows => '10', :class => 'large'} %> + + <%= text_area 'comment', 'body', { :rows => '10', :class => 'input-block-level'} %>
diff --git a/app/views/admin/notes/new.html.erb b/app/views/admin/notes/new.html.erb index 3035e07d8e..62c292947d 100644 --- a/app/views/admin/notes/new.html.erb +++ b/app/views/admin/notes/new.html.erb @@ -5,7 +5,7 @@ <%= form_tag :action=>"edit", :id => @note.id do %>
- +
<%= text_area('note', 'body', {:class => 'input-block-level', :rows => '7', :placeholder => _("Compose new note")}) %> diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index 656d5f96f3..6b29b37d17 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -32,7 +32,7 @@
'> - +
> <%= ckeditor_textarea('page', 'body', {:class => 'large', :height => '300px', :rows => '20'}) if current_user.editor == 'visual' %> diff --git a/public/javascripts/administration.js b/public/javascripts/administration.js index 6079f6db72..2b62c4f466 100644 --- a/public/javascripts/administration.js +++ b/public/javascripts/administration.js @@ -82,125 +82,55 @@ function edButton(id, display, tagStart, tagEnd, access, open) { this.open = open; // set to -1 if tag does not need to be closed } -edButtons.push( - new edButton( - 'ed_bold' - ,'b' - ,'' - ,'' - ,'b' - ) -); - -edButtons.push( - new edButton( - 'ed_italic' - ,'i' - ,'' - ,'' - ,'i' - ) -); - -edButtons.push( - new edButton( - 'ed_link' - ,'link' - ,'' - ,'' - ,'a' - ) -); // special case - -edButtons.push( - new edButton( - 'ed_img' - ,'img' - ,'' - ,'' - ,'m' - ,-1 - ) -); // special case - -edButtons.push( - new edButton( - 'ed_ul' - ,'ul' - ,'
    \n' - ,'
\n\n' - ,'u' - ) -); - -edButtons.push( - new edButton( - 'ed_ol' - ,'ol' - ,'
    \n' - ,'
\n\n' - ,'o' - ) -); - -edButtons.push( - new edButton( - 'ed_li' - ,'li' - ,'\t
  • ' - ,'
  • \n' - ,'l' - ) -); - -edButtons.push( - new edButton( - 'ed_block' - ,'b-quote' - ,'
    ' - ,'
    ' - ,'q' - ) -); - -edButtons.push( - new edButton( - 'ed_del' - ,'del' - ,'' - ,'' - ) -); - -edButtons.push( - new edButton( - 'ed_code' - ,'code' - ,'' - ,'' - ,'c' - ) -); - -edButtons.push( - new edButton( - 'ed_more' - ,'more' - ,'\n\n' - ,'' - ,'' - ) -); - -edButtons.push( - new edButton( - 'ed_publifycode' - ,'publify:code' - ,'' - ,'\n\n\n' - ,'publify:code' - ) -); +function get_buttons(textfilter) { + switch (textfilter) { + case "textile": + edButtons.push(new edButton('ed_bold', 'b', '**', '**', 'b')); + edButtons.push(new edButton('ed_italic', 'i', '_', '_', 'i')); + edButtons.push(new edButton('ed_link', 'link', '', '', 'a')); + edButtons.push(new edButton('ed_img', 'img', '!', '!', 'm' ,-1)); + edButtons.push(new edButton('ed_li', 'li', '* ', '', 'l', -1)); + edButtons.push(new edButton('ed_block', 'b-quote', '>', '', 'q', -1)); + edButtons.push(new edButton('ed_del', 'del', '', '')); + edButtons.push(new edButton('ed_code', 'code', '@', '@', 'c')); + edButtons.push(new edButton('ed_more', 'more', '\n\n', '', '')); + edButtons.push(new edButton('ed_publifycode', 'publify:code', '', '\n\n\n', 'publify:code')); + break; + + case "markdown": + case "markdown smartypants": + edButtons.push(new edButton('ed_bold', 'b', '**', '**', 'b')); + edButtons.push(new edButton('ed_italic', 'i', '_', '_', 'i')); + edButtons.push(new edButton('ed_link', 'link', '', '', 'a')); + edButtons.push(new edButton('ed_img', 'img', '', '', 'm' ,-1)); + edButtons.push(new edButton('ed_li', 'li', '* ', '', 'l', -1)); + edButtons.push(new edButton('ed_ol', 'ol', '#', '', 'o', -1)); + edButtons.push(new edButton('ed_block', 'b-quote', '>', '', 'q', -1)); + edButtons.push(new edButton('ed_del', 'del', '', '')); + edButtons.push(new edButton('ed_code', 'code', '`', '`', 'c')); + edButtons.push(new edButton('ed_more', 'more', '\n\n', '', '')); + edButtons.push(new edButton('ed_publifycode', 'publify:code', '', '\n\n\n', 'publify:code')); + break; + + default: + edButtons.push(new edButton('ed_bold', 'b', '', '', 'b')); + edButtons.push(new edButton('ed_italic', 'i', '', '', 'i')); + edButtons.push(new edButton('ed_link', 'link', '', '', 'a')); + edButtons.push(new edButton('ed_img', 'img', '', '', 'm' ,-1)); + edButtons.push(new edButton('ed_ul', 'ul', '
      \n', '
    \n\n', 'u')); + edButtons.push(new edButton('ed_ol', 'ol', '
      \n', '
    \n\n', 'o')); + edButtons.push(new edButton('ed_li', 'li', '\t
  • ', '
  • \n', 'l')); + edButtons.push(new edButton('ed_block', 'b-quote', '
    ', '
    ', 'q')); + edButtons.push(new edButton('ed_del', 'del', '', '')); + edButtons.push(new edButton('ed_code', 'code', '', '', 'c')); + edButtons.push(new edButton('ed_more', 'more', '\n\n', '', '')); + edButtons.push(new edButton('ed_publifycode', 'publify:code', '', '\n\n\n', 'publify:code')); + break; + } + + +} + var extendedStart = edButtons.length; @@ -330,11 +260,18 @@ function edSpell(which) { } } -function edToolbar(which) { +function edToolbar(which, textfilter) { + get_buttons(textfilter); + document.write('
    '); for (i = 0; i < extendedStart; i++) { edShowButton(which, edButtons[i], i); } + + for (i = extendedStart; i < edButtons.length; i++) { + edShowButton(which, edButtons[i], i); + } + if (edShowExtraCookie()) { document.write( '' @@ -347,9 +284,9 @@ function edToolbar(which) { + '' ); } - for (i = extendedStart; i < edButtons.length; i++) { - edShowButton(which, edButtons[i], i); - } + + + // edShowLinks(); document.write('
    '); edOpenTags[which] = new Array();