Skip to content

Commit

Permalink
manage path_prefix in css with relative urls, set relative_url_root i…
Browse files Browse the repository at this point in the history
…n layout and call it in Javascript files, update helper code to use routes so path_prefix is calculated
  • Loading branch information
saturnflyer committed Dec 16, 2009
1 parent 547fbce commit 047f9d9
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 50 deletions.
4 changes: 2 additions & 2 deletions app/helpers/admin/pages_helper.rb
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/pages/_fields.html.haml
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/views/layouts/application.html.haml
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions 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;

Expand Down
12 changes: 6 additions & 6 deletions public/javascripts/admin/popup.js
Expand Up @@ -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() {
Expand Down
14 changes: 7 additions & 7 deletions public/javascripts/admin/status.js
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion 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);
Expand Down Expand Up @@ -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;
}
});
Expand Down
34 changes: 17 additions & 17 deletions public/stylesheets/admin/main.css
Expand Up @@ -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; }
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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%;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions public/stylesheets/sass/admin/_reset.sass
Expand Up @@ -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

0 comments on commit 047f9d9

Please sign in to comment.