From 047f9d9da01890116e6abb669347f2145a4bb6a5 Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Wed, 16 Dec 2009 00:44:43 -0500 Subject: [PATCH] manage path_prefix in css with relative urls, set relative_url_root in layout and call it in Javascript files, update helper code to use routes so path_prefix is calculated --- app/helpers/admin/pages_helper.rb | 4 +-- app/views/admin/pages/_fields.html.haml | 2 +- app/views/layouts/application.html.haml | 5 ++-- public/javascripts/admin/application.js | 23 +++++++-------- public/javascripts/admin/popup.js | 12 ++++---- public/javascripts/admin/status.js | 14 +++++----- public/javascripts/admin/tabcontrol.js | 3 +- public/stylesheets/admin/main.css | 34 +++++++++++------------ public/stylesheets/sass/admin/_reset.sass | 6 ++-- 9 files changed, 53 insertions(+), 50 deletions(-) diff --git a/app/helpers/admin/pages_helper.rb b/app/helpers/admin/pages_helper.rb index 90786efda..ee17ee43f 100644 --- a/app/helpers/admin/pages_helper.rb +++ b/app/helpers/admin/pages_helper.rb @@ -77,7 +77,7 @@ def page_edit_javascripts function loadTagReference(part) { var pageType = $F('page_class_name'); if (!tagReferenceWindows[pageType]) - tagReferenceWindows[pageType] = new Popup.AjaxWindow("/admin/references/tags?class_name=" + encodeURIComponent(pageType), {reload: false}); + tagReferenceWindows[pageType] = new Popup.AjaxWindow("#{admin_reference_path('tags')}?class_name=" + encodeURIComponent(pageType), {reload: false}); var window = tagReferenceWindows[pageType]; if(lastPageType != pageType) { $('tag_reference_link_' + part).highlight(); @@ -94,7 +94,7 @@ def page_edit_javascripts function loadFilterReference(part) { var filter = $F("part_" + part + "_filter_id"); if (filter != "") { - if (!filterWindows[filter]) filterWindows[filter] = new Popup.AjaxWindow("/admin/references/filters?filter_name="+encodeURIComponent(filter), {reload: false}); + if (!filterWindows[filter]) filterWindows[filter] = new Popup.AjaxWindow("#{admin_reference_path('filters')}?filter_name="+encodeURIComponent(filter), {reload: false}); var window = filterWindows[filter]; if(lastFilter != filter) { window.show(); diff --git a/app/views/admin/pages/_fields.html.haml b/app/views/admin/pages/_fields.html.haml index 20d17a6a2..ef6e7fd91 100644 --- a/app/views/admin/pages/_fields.html.haml +++ b/app/views/admin/pages/_fields.html.haml @@ -21,7 +21,7 @@ #tabs.tabs #tab_toolbar %a.popup{:href=> '#add_part_popup', :title=>"Add Part"} - %img{:src=>"/images/admin/add_tab.png", :alt=>"Add Part", :title=>""}/ + = image('add_tab', :alt=>"Add Part", :title=>"") #pages.pages = render :partial => 'admin/page_parts/page_part', :collection => @page.parts = render_region :parts_bottom diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4970e99d7..af714d495 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -5,6 +5,7 @@ %title= @page_title || default_page_title - @stylesheets.uniq.each do |stylesheet| = stylesheet_link_tag stylesheet + %script{:type=>"text/javascript"}="var relative_url_root = '#{ActionController::Base.relative_url_root}';" = javascript_include_tag %w(admin/prototype admin/effects admin/lowpro admin/cookie admin/popup admin/status admin/utility admin/codearea admin/tabcontrol admin/ruledtable admin/sitemap admin/shortcuts admin/application), :cache => 'admin/all' - @javascripts.uniq.each do |javascript| = javascript_include_tag javascript @@ -25,14 +26,14 @@ - nav_tabs.each do |tab| - if tab.visible?(current_user) %li{:class=>('current' if current_tab?(tab))} - %a{:href=>(tab.first.url if tab.first)} + %a{:href=>(tab.first.relative_url if tab.first)} = tab.name - if current_tab?(tab) %ul#nav_sub - tab.each do |sub_item| - if sub_item.visible?(current_user) %li - %a{:href => sub_item.url, :class => current_item?(sub_item) ? 'current' : ''}> + %a{:href => sub_item.relative_url, :class => current_item?(sub_item) ? 'current' : ''}> %span = sub_item.name #header_bottom diff --git a/public/javascripts/admin/application.js b/public/javascripts/admin/application.js index 1a9df5c0c..3e385afc4 100644 --- a/public/javascripts/admin/application.js +++ b/public/javascripts/admin/application.js @@ -1,17 +1,18 @@ +if(typeof(relative_url_root) === 'undefined'){var relative_url_root = '';} // Popup Images -Popup.BorderImage = '/images/admin/popup_border_background.png'; -Popup.BorderTopLeftImage = '/images/admin/popup_border_top_left.png'; -Popup.BorderTopRightImage = '/images/admin/popup_border_top_right.png'; -Popup.BorderBottomLeftImage = '/images/admin/popup_border_bottom_left.png'; -Popup.BorderBottomRightImage = '/images/admin/popup_border_bottom_right.png'; +Popup.BorderImage = relative_url_root + '/images/admin/popup_border_background.png'; +Popup.BorderTopLeftImage = relative_url_root + '/images/admin/popup_border_top_left.png'; +Popup.BorderTopRightImage = relative_url_root + '/images/admin/popup_border_top_right.png'; +Popup.BorderBottomLeftImage = relative_url_root + '/images/admin/popup_border_bottom_left.png'; +Popup.BorderBottomRightImage = relative_url_root + '/images/admin/popup_border_bottom_right.png'; // Status Images -Status.SpinnerImage = '/images/admin/status_spinner.gif'; -Status.BackgroundImage = '/images/admin/status_background.png'; -Status.TopLeftImage = '/images/admin/status_top_left.png'; -Status.TopRightImage = '/images/admin/status_top_right.png'; -Status.BottomLeftImage = '/images/admin/status_bottom_left.png'; -Status.BottomRightImage = '/images/admin/status_bottom_right.png'; +Status.SpinnerImage = relative_url_root + '/images/admin/status_spinner.gif'; +Status.BackgroundImage = relative_url_root + '/images/admin/status_background.png'; +Status.TopLeftImage = relative_url_root + '/images/admin/status_top_left.png'; +Status.TopRightImage = relative_url_root + '/images/admin/status_top_right.png'; +Status.BottomLeftImage = relative_url_root + '/images/admin/status_bottom_left.png'; +Status.BottomRightImage = relative_url_root + '/images/admin/status_bottom_right.png'; Event.addBehavior.reassignAfterAjax = true; diff --git a/public/javascripts/admin/popup.js b/public/javascripts/admin/popup.js index cf193ce1e..c942cdd62 100644 --- a/public/javascripts/admin/popup.js +++ b/public/javascripts/admin/popup.js @@ -44,14 +44,14 @@ * DEALINGS IN THE SOFTWARE. * */ - +if(typeof(relative_url_root) === 'undefined'){var relative_url_root = '';} var Popup = { BorderThickness: 8, - BorderImage: '/images/popup_border_background.png', - BorderTopLeftImage: '/images/popup_border_top_left.png', - BorderTopRightImage: '/images/popup_border_top_right.png', - BorderBottomLeftImage: '/images/popup_border_bottom_left.png', - BorderBottomRightImage: '/images/popup_border_bottom_right.png' + BorderImage: relative_url_root+'/images/admin/popup_border_background.png', + BorderTopLeftImage: relative_url_root+'/images/admin/popup_border_top_left.png', + BorderTopRightImage: relative_url_root+'/images/admin/popup_border_top_right.png', + BorderBottomLeftImage: relative_url_root+'/images/admin/popup_border_bottom_left.png', + BorderBottomRightImage: relative_url_root+'/images/admin/popup_border_bottom_right.png' }; Popup.borderImages = function() { diff --git a/public/javascripts/admin/status.js b/public/javascripts/admin/status.js index 5a7df3dfd..192995a83 100644 --- a/public/javascripts/admin/status.js +++ b/public/javascripts/admin/status.js @@ -41,17 +41,17 @@ * DEALINGS IN THE SOFTWARE. * */ - +if(typeof(relative_url_root) === 'undefined'){var relative_url_root = '';} var Status = { CornerThickness: 12, - SpinnerImage: '/images/status_spinner.gif', + SpinnerImage: relative_url_root+'/images/admin/status_spinner.gif', SpinnerImageWidth: 32, SpinnerImageHeight: 33, - BackgroundImage: '/images/status_background.png', - TopLeftImage: '/images/status_top_left.png', - TopRightImage: '/images/status_top_right.png', - BottomLeftImage: '/images/status_bottom_left.png', - BottomRightImage: '/images/status_bottom_right.png' + BackgroundImage: relative_url_root+'/images/admin/status_background.png', + TopLeftImage: relative_url_root+'/images/admin/status_top_left.png', + TopRightImage: relative_url_root+'/images/admin/status_top_right.png', + BottomLeftImage: relative_url_root+'/images/admin/status_bottom_left.png', + BottomRightImage: relative_url_root+'/images/admin/status_bottom_right.png' }; Status.BackgroundImages = function() { diff --git a/public/javascripts/admin/tabcontrol.js b/public/javascripts/admin/tabcontrol.js index 570433a25..4b35cf7ac 100644 --- a/public/javascripts/admin/tabcontrol.js +++ b/public/javascripts/admin/tabcontrol.js @@ -1,3 +1,4 @@ +if(typeof(relative_url_root) === 'undefined'){relative_url_root = '';} var TabControlBehavior = Behavior.create({ initialize: function() { new TabControl(this.element); @@ -134,7 +135,7 @@ TabControl.Tab = Class.create({ }, toElement: function() { - this.element = $a({'href': '#'}, $span(this.caption), $img({'src': '/images/admin/tab_close.png', 'class': 'close', 'alt': 'Remove part', 'title': 'Remove part'})).addClassName('tab'); + this.element = $a({'href': '#'}, $span(this.caption), $img({'src': relative_url_root+'/images/admin/tab_close.png', 'class': 'close', 'alt': 'Remove part', 'title': 'Remove part'})).addClassName('tab'); return this.element; } }); diff --git a/public/stylesheets/admin/main.css b/public/stylesheets/admin/main.css index 0a38adc43..edd8f5105 100644 --- a/public/stylesheets/admin/main.css +++ b/public/stylesheets/admin/main.css @@ -108,7 +108,7 @@ body.login #content { #header { font-size: 90%; - background: #c00 url(/images/admin/navigation_background.gif) repeat-x; + background: #c00 url(../../images/admin/navigation_background.gif) repeat-x; width: 100%; position: relative; height: auto; } @@ -126,7 +126,7 @@ body.login #content { #view_site { font-size: 90%; - background: url(/images/admin/view_site.png) no-repeat; + background: url(../../images/admin/view_site.png) no-repeat; display: block; position: absolute; right: 12px; @@ -155,7 +155,7 @@ ul#navigation { -moz-border-radius-topright: 6px; border-top-left-radius: 6px; border-top-right-radius: 6px; - background: url(/images/admin/navigation_tabs.png) left top repeat-x; + background: url(../../images/admin/navigation_tabs.png) left top repeat-x; color: #edd; display: block; height: 30px; @@ -173,7 +173,7 @@ ul#navigation { ul#navigation li.dimmed a { background-position: 0 -48px; } ul#navigation ul#nav_sub { - background: url(/images/admin/navigation_secondary_background.png) repeat-x; + background: url(../../images/admin/navigation_secondary_background.png) repeat-x; font-size: 95%; clear: both; left: 0; @@ -187,7 +187,7 @@ ul#navigation { ul#navigation ul#nav_sub li { margin: 0; } ul#navigation ul#nav_sub li a { - background: url(/images/admin/navigation_secondary_background.png) repeat-x; + background: url(../../images/admin/navigation_secondary_background.png) repeat-x; color: #555; display: -moz-inline-stack; display: inline-block; @@ -200,14 +200,14 @@ ul#navigation { background-position: left -40px; color: #444; } ul#navigation ul#nav_sub li a.current { - background: url(/images/admin/navigation_secondary_background.png) left -80px repeat-x; + background: url(../../images/admin/navigation_secondary_background.png) left -80px repeat-x; color: #333; font-weight: bold; } ul#navigation ul#nav_sub li a.current:hover { background-position: left -120px; color: #222; } ul#navigation ul#nav_sub li a span { - background: url(/images/admin/navigation_secondary_separator.gif) right bottom no-repeat; + background: url(../../images/admin/navigation_secondary_separator.gif) right bottom no-repeat; display: block; margin: 0; padding: 0 26px; @@ -218,7 +218,7 @@ ul#navigation { height: 38px; position: relative; } #header_bottom div { - background: url(/images/admin/navigation_shadow.png) repeat-x; + background: url(../../images/admin/navigation_shadow.png) repeat-x; position: absolute; top: 38px; width: 100%; @@ -328,11 +328,11 @@ img.avatar { #content form p.more_or_less a:hover, #content form p.more_or_less a:active, #content form p.more_or_less a:focus { text-decoration: underline; } #content form p.more_or_less #more_extended_metadata { - background: #7e7e7e url(/images/admin/metadata_toggle.png) no-repeat 90% 8px; } + background: #7e7e7e url(../../images/admin/metadata_toggle.png) no-repeat 90% 8px; } #content form p.more_or_less #less_extended_metadata { - background: #7e7e7e url(/images/admin/metadata_toggle.png) no-repeat 85% -22px; } + background: #7e7e7e url(../../images/admin/metadata_toggle.png) no-repeat 85% -22px; } #content form #extended_metadata { - background: #7e7e7e url(/images/admin/navigation_shadow.png) repeat-x; + background: #7e7e7e url(../../images/admin/navigation_shadow.png) repeat-x; border-bottom-right-radius: 6px; -moz-border-bottom-right-radius: 6px; -webkit-border-bottom-right-radius: 6px; @@ -370,7 +370,7 @@ img.avatar { .box { color: #333; - background: #f5f1e2 url(/images/admin/vertical_tan_gradient.png) top left repeat-x; + background: #f5f1e2 url(../../images/admin/vertical_tan_gradient.png) top left repeat-x; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; @@ -449,7 +449,7 @@ body.reversed #content form p label { font-weight: bold; text-shadow: #666 1px 1px 0; } body.reversed #content form .buttons { - background: white url(/images/admin/buttons_background.png) bottom repeat-x; + background: white url(../../images/admin/buttons_background.png) bottom repeat-x; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; @@ -464,7 +464,7 @@ body.reversed #content .box { -webkit-box-shadow: 1px 1px 3px #666; } body.login #content #login { - background: #f5f1e2 url(/images/admin/vertical_tan_gradient.png) center -15px repeat-x; + background: #f5f1e2 url(../../images/admin/vertical_tan_gradient.png) center -15px repeat-x; border: 0.35em solid #efead3; border-radius: 10px; -moz-border-radius: 10px; @@ -487,7 +487,7 @@ body.login #content #login { body.login #content #login .buttons { margin: 1.75em 0 1em; } body.login #content p.version { - background: url(/images/admin/login_shadow.png) top center no-repeat; + background: url(../../images/admin/login_shadow.png) top center no-repeat; color: #666; font-size: 80%; padding-top: 10px; @@ -673,7 +673,7 @@ table.index th { #actions li { display: inline; } #actions a { - background: #eee url(/images/admin/buttons_background.png) repeat-x; + background: #eee url(../../images/admin/buttons_background.png) repeat-x; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; @@ -871,7 +871,7 @@ div.popup .reference table h2, div.popup .reference table h3, div.popup .referen clear: both; } #tab_control .pages .page { padding: 20px; - background: url(/images/admin/vertical_tan_gradient.png) top left repeat-x #f5f1e2; } + background: url(../../images/admin/vertical_tan_gradient.png) top left repeat-x #f5f1e2; } #tab_control .pages .page p { margin-top: 0; } #tab_control .pages .page label { diff --git a/public/stylesheets/sass/admin/_reset.sass b/public/stylesheets/sass/admin/_reset.sass index 4ff65e422..dc70d6252 100644 --- a/public/stylesheets/sass/admin/_reset.sass +++ b/public/stylesheets/sass/admin/_reset.sass @@ -20,17 +20,17 @@ ol, ul blockquote, q quotes: none -/* remember to define focus styles! */ +/* remember to define focus styles! *:focus outline: 0 -/* remember to highlight inserts somehow! */ +/* remember to highlight inserts somehow! ins text-decoration: none del text-decoration: line-through -/* tables still need 'cellspacing="0"' in the markup */ +/* tables still need 'cellspacing="0"' in the markup table border-collapse: collapse border-spacing: 0 \ No newline at end of file