Skip to content

Commit

Permalink
Merge eb626bc into dcd8b46
Browse files Browse the repository at this point in the history
  • Loading branch information
anitagraham committed Dec 31, 2014
2 parents dcd8b46 + eb626bc commit 55f1c91
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 131 deletions.
Binary file added core/app/assets/images/refinery/icons/arrow_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 14 additions & 5 deletions core/app/assets/javascripts/refinery/admin.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,12 @@ var page_options = {
this.enable_parts = enable_parts;
this.new_part_url = new_part_url;
this.del_part_url = del_part_url;
this.show_options();
this.option_links = $('#page_option_links').find('span');

option_fields = $('#page_option_links').find('span');
option_links = option_fields.find('a.toggle_visibility')
option_divs = $('#page_options').find('div.PageOption');
this.hide_options();

$(document).ready($.proxy(function(){
// hide the tabs that are supposed to be hidden.
Expand All @@ -565,13 +570,17 @@ var page_options = {
}
},

show_options: function(){
$('#toggle_advanced_options').click(function(e){
hide_options: function(){
animate_options = {opacity: 'toggle', height: 'toggle'};
animate_timing = 250;
option_links.on('click', function(e){
e.preventDefault();
$('#more_options').animate({opacity: 'toggle', height: 'toggle'}, 250);
href = $(this).attr('href')
$(href).animate(animate_options, animate_timing);
$(this).parent('span').toggleClass('open');

$('html,body').animate({
scrollTop: $('#toggle_advanced_options').parent().offset().top
scrollTop: $('#page_option_links').parent().offset().top
}, 250);
});
},
Expand Down
68 changes: 50 additions & 18 deletions core/app/assets/stylesheets/refinery/layout.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -699,17 +699,8 @@ label.stripped {
#records.files .record .title.pdf, #dialog_main #resource_file_area .pages_list ul li a.page_link.pdf {
background-image: image_url('refinery/icons/pdf.png');
}
#records.files .record .title.jpg,
#records.files .record .title.gif,
#records.files .record .title.jpeg,
#records.files .record .title.png,
#records.files .record .title.tiff,
#dialog_main #resource_file_area .pages_list ul li a.page_link.jpg,
#dialog_main #resource_file_area .pages_list ul li a.page_link.jpeg,
#dialog_main #resource_file_area .pages_list ul li a.page_link.gif,
#dialog_main #resource_file_area .pages_list ul li a.page_link.png,
#dialog_main #resource_file_area .pages_list ul li a.page_link.tiff {
background-image: image_url('refinery/icons/img.png');
#records.files .record .title.jpg, #records.files .record .title.gif, #records.files .record .title.jpeg, #records.files .record .title.png, #records.files .record .title.tiff, #dialog_main #resource_file_area .pages_list ul li a.page_link.jpg, #dialog_main #resource_file_area .pages_list ul li a.page_link.jpeg, #dialog_main #resource_file_area .pages_list ul li a.page_link.gif, #dialog_main #resource_file_area .pages_list ul li a.page_link.png, #dialog_main #resource_file_area .pages_list ul li a.page_link.tiff {
background-image: image_url('refinery/icons/img.png');
}

#records.files .record .title.doc, #records.files .record .title.pages, #records.files .record .title.docx, #dialog_main #resource_file_area .pages_list ul li a.page_link.doc, #dialog_main #resource_file_area .pages_list ul li a.page_link.docx, #dialog_main #resource_file_area .pages_list ul li a.page_link.pages {
Expand Down Expand Up @@ -849,7 +840,7 @@ body.dialog form {
width: 100% !important;
}
.visual_editor_dialog_table {
height: 250px;
height: 250px;
}
.dialog {
#dialog_main {
Expand Down Expand Up @@ -1128,12 +1119,12 @@ ul#page_parts_controls img {
clear:left;
}
a#toggle_advanced_options {
background: image_url('refinery/icons/page_white_gear.png') no-repeat 0px 3px;
padding: 5px 5px 5px 22px;
border-bottom: none;
background: image_url('refinery/icons/page_white_gear.png') no-repeat 0px 3px;
padding: 5px 5px 5px 22px;
border-bottom: none;
}
a#toggle_advanced_options:hover {
border-bottom:1px dotted #727272;
border-bottom:1px dotted #727272;
}
/* dialog stuff */
#dialog_frame {
Expand Down Expand Up @@ -1327,10 +1318,10 @@ input.button, a.button, #content a.button, span.button-wrapper, span.button-wrap
}
/* for those pesky IE browsers */
span.button-wrapper {
padding: 0px;
padding: 0px;
}
span.button-wrapper input {
display: inherit;
display: inherit;
}
/* fixes firefox display */
input.button {
Expand Down Expand Up @@ -1437,6 +1428,47 @@ input.button.close_dialog:active, a.button.close_dialog:active, #content a.butto
#upgrade_wrapper li a {
line-height: 20px;
}
#current_locale li a {
position: relative;
}
#current_locale li a span {
position: absolute;
right: 9px;
border-bottom: 1px dotted #727272;
}
#other_locales li:first-child {
margin-top: 0px;
}
/* Plugin page options */
section#page_option_links {
@include form-actions;
span.options_field {
background: image_url('refinery/icons/arrow_down.png') no-repeat right;
&.open {background: image_url('refinery/icons/arrow_up.png') no-repeat right;}
float:left;
margin: 10px;
margin-right:30px;
padding-right:18px;
a.toggle_visibility {
padding:2px;
padding-left: 18px;
height:18px;
border-bottom: none;
background: image_url('refinery/icons/page_white_gear.png') left top no-repeat;
&:hover {border-bottom:1px dotted #727272;}
}
}
#draft_field {
position: relative;
float:right;
right: 0;
margin-top:10px;
padding-right:5px
}
}
section#page_options div.PageOption {
display:none;
}


/* Locale picker */
Expand Down
58 changes: 35 additions & 23 deletions core/lib/refinery/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module Refinery
class Plugin

attr_accessor :name, :class_name, :controller, :directory, :url,
:always_allow_access, :menu_match, :hide_from_menu,
:pathname
:dashboard, :always_allow_access, :menu_match,
:hide_from_menu, :pathname, :plugin_activity, :options_template

def self.register(&block)
yield(plugin = self.new)
Expand All @@ -13,10 +13,18 @@ def self.register(&block)
# Set defaults.
plugin.menu_match ||= %r{refinery/#{plugin.name}(/.+?)?$}
plugin.always_allow_access ||= false
plugin.dashboard ||= false
plugin.class_name ||= plugin.name.camelize

# add the new plugin to the collection of registered plugins
::Refinery::Plugins.registered << plugin

# add the new plugin to the collection of registered plugins unless it is a duplicate name
if plugin.name.in?Refinery::Plugins.registered.names
Rails.logger.error "Tried to register duplicate plugin: #{plugin.name}"
else
::Refinery::Plugins.registered << plugin
end


end

# Returns the internationalized version of the title
Expand All @@ -29,18 +37,24 @@ def description
::I18n.translate(['refinery', 'plugins', name, 'description'].join('.'))
end

# Retrieve information about how to access the latest activities of this plugin.
def activity
self.plugin_activity ||= []
end

# Stores information that can be used to retrieve the latest activities of this plugin
def activity=(activities)
Refinery.deprecate('Refinery::Plugin#activity=', when: '3.1')
[activities].flatten.each { |activity| add_activity(activity) }
end

def dashboard=(dashboard)
Refinery.deprecate('Refinery::Plugin#dashboard=', when: '3.1')
# Given a record's class name, find the related activity object.
def activity_by_class_name(class_name)
self.activity.select{ |a| a.class_name == class_name.to_s.camelize }
end

# Used to highlight the current tab in the admin interface
def highlighted?(params)
!!(params[:controller].try(:gsub, "admin/", "") =~ menu_match)
!!(params[:controller].try(:gsub, "admin/", "") =~ menu_match) || (dashboard && params[:action] == 'error_404')
end

def pathname=(value)
Expand All @@ -50,7 +64,13 @@ def pathname=(value)

# Returns a hash that can be used to create a url that points to the administration part of the plugin.
def url
@url ||= build_url
@url ||= if controller.present?
{ :controller => "refinery/admin/#{controller}" }
elsif directory.present?
{ :controller => "refinery/admin/#{directory.split('/').pop}" }
else
{ :controller => "refinery/admin/#{name}" }
end

if @url.is_a?(Hash)
{:only_path => true}.merge(@url)
Expand All @@ -61,25 +81,17 @@ def url
end
end

# Make this protected, so that only Plugin.register can use it.
protected
# Make this protected, so that only Plugin.register can use it.
protected

def add_activity(options)
(self.plugin_activity ||= []) << Activity::new(options)
end

def initialize
# provide a default pathname to where this plugin is using its lib directory.
depth = RUBY_VERSION >= "1.9.2" ? 4 : 3
self.pathname ||= Pathname.new(caller(depth).first.match("(.*)#{File::SEPARATOR}lib")[1])
end

private

def build_url
if controller.present?
{ :controller => "refinery/admin/#{controller}" }
elsif directory.present?
{ :controller => "refinery/admin/#{directory.split('/').pop}" }
else
{ :controller => "refinery/admin/#{name}" }
end
end
end
end
17 changes: 17 additions & 0 deletions pages/app/helpers/refinery/admin/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ def page_meta_information(page)
def page_title_with_translations(page)
page.title.presence || page.translations.detect { |t| t.title.present?}.title
end

def render_page_options(form)
# add a toggle option for each plugin that has registered a page menu
# save as draft is included with the links
titles = ['Page', 'SEO']
templates = ['form_advanced_options', 'form_advanced_seo']
Refinery::Plugins.registered.each do |p|
if p.options_template
titles.push p.plugin_activity ? p.plugin_activity.first.class_name.demodulize : p.name
templates.push p.options_template
end
end
links = render 'form_page_option_links', {titles: titles, f:form}
tabs = render 'form_page_option_section', {templates: templates, f:form}
return links << tabs
end

end
end
end
2 changes: 1 addition & 1 deletion pages/app/views/refinery/admin/pages/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%= render 'form_page_parts', :f => f %>
</div>

<%= render 'form_advanced_options', :f => f %>
<%= render_page_options(f) %>
<%= render '/refinery/admin/form_actions', :f => f,
:continue_editing => true,
Expand Down
Loading

0 comments on commit 55f1c91

Please sign in to comment.