##// END OF EJS Templates
Moves jstoolbar script include tags to head....
Jean-Philippe Lang -
r5118:70d765e906a5
parent child
Show More
@@ -1,46 +1,47
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 module Redmine
18 module Redmine
19 module WikiFormatting
19 module WikiFormatting
20 module Textile
20 module Textile
21 module Helper
21 module Helper
22 def wikitoolbar_for(field_id)
22 def wikitoolbar_for(field_id)
23 # Is there a simple way to link to a public resource?
23 # Is there a simple way to link to a public resource?
24 url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html"
24 url = "#{Redmine::Utils.relative_url_root}/help/wiki_syntax.html"
25
25
26 help_link = l(:setting_text_formatting) + ': ' +
26 help_link = l(:setting_text_formatting) + ': ' +
27 link_to(l(:label_help), url,
27 link_to(l(:label_help), url,
28 :onclick => "window.open(\"#{ url }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;")
28 :onclick => "window.open(\"#{ url }\", \"\", \"resizable=yes, location=no, width=300, height=640, menubar=no, status=no, scrollbars=yes\"); return false;")
29
29
30 javascript_include_tag('jstoolbar/jstoolbar') +
31 javascript_include_tag('jstoolbar/textile') +
32 javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
33 javascript_tag("var wikiToolbar = new jsToolBar($('#{field_id}')); wikiToolbar.setHelpLink('#{help_link}'); wikiToolbar.draw();")
30 javascript_tag("var wikiToolbar = new jsToolBar($('#{field_id}')); wikiToolbar.setHelpLink('#{help_link}'); wikiToolbar.draw();")
34 end
31 end
35
32
36 def initial_page_content(page)
33 def initial_page_content(page)
37 "h1. #{@page.pretty_title}"
34 "h1. #{@page.pretty_title}"
38 end
35 end
39
36
40 def heads_for_wiki_formatter
37 def heads_for_wiki_formatter
41 stylesheet_link_tag 'jstoolbar'
38 @@heads_for_wiki_formatter ||=
39 javascript_include_tag('jstoolbar/jstoolbar') +
40 javascript_include_tag('jstoolbar/textile') +
41 javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") +
42 stylesheet_link_tag('jstoolbar')
42 end
43 end
43 end
44 end
44 end
45 end
45 end
46 end
46 end
47 end
@@ -1,40 +1,49
1 require File.expand_path('../../test_helper', __FILE__)
1 require File.expand_path('../../test_helper', __FILE__)
2
2
3 class LayoutTest < ActionController::IntegrationTest
3 class LayoutTest < ActionController::IntegrationTest
4 fixtures :all
4 fixtures :all
5
5
6 test "browsing to a missing page should render the base layout" do
6 test "browsing to a missing page should render the base layout" do
7 get "/users/100000000"
7 get "/users/100000000"
8
8
9 assert_response :not_found
9 assert_response :not_found
10
10
11 # UsersController uses the admin layout by default
11 # UsersController uses the admin layout by default
12 assert_select "#admin-menu", :count => 0
12 assert_select "#admin-menu", :count => 0
13 end
13 end
14
14
15 test "browsing to an unauthorized page should render the base layout" do
15 test "browsing to an unauthorized page should render the base layout" do
16 change_user_password('miscuser9', 'test')
16 change_user_password('miscuser9', 'test')
17
17
18 log_user('miscuser9','test')
18 log_user('miscuser9','test')
19
19
20 get "/admin"
20 get "/admin"
21 assert_response :forbidden
21 assert_response :forbidden
22 assert_select "#admin-menu", :count => 0
22 assert_select "#admin-menu", :count => 0
23 end
23 end
24
24
25 def test_top_menu_and_search_not_visible_when_login_required
25 def test_top_menu_and_search_not_visible_when_login_required
26 with_settings :login_required => '1' do
26 with_settings :login_required => '1' do
27 get '/'
27 get '/'
28 assert_select "#top-menu > ul", 0
28 assert_select "#top-menu > ul", 0
29 assert_select "#quick-search", 0
29 assert_select "#quick-search", 0
30 end
30 end
31 end
31 end
32
32
33 def test_top_menu_and_search_visible_when_login_not_required
33 def test_top_menu_and_search_visible_when_login_not_required
34 with_settings :login_required => '0' do
34 with_settings :login_required => '0' do
35 get '/'
35 get '/'
36 assert_select "#top-menu > ul"
36 assert_select "#top-menu > ul"
37 assert_select "#quick-search"
37 assert_select "#quick-search"
38 end
38 end
39 end
39 end
40
41 def test_wiki_formatter_header_tags
42 Role.anonymous.add_permission! :add_issues
43
44 get '/projects/ecookbook/issues/new'
45 assert_tag :script,
46 :attributes => {:src => %r{^/javascripts/jstoolbar/textile.js}},
47 :parent => {:tag => 'head'}
48 end
40 end
49 end
General Comments 0
You need to be logged in to leave comments. Login now