return unless User.current.logged?
projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq
if projects.any?
- s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
- "<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
- '<option value="" disabled="disabled">---</option>'
- s << project_tree_options_for_select(projects, :selected => @project) do |p|
- { :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
+ options =
+ ("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
+ '<option value="" disabled="disabled">---</option>').html_safe
+
+ options << project_tree_options_for_select(projects, :selected => @project) do |p|
+ { :value => project_path(:id => p, :jump => current_menu_item) }
end
- s << '</select>'
- s.html_safe
+
+ select_tag('project_quick_jump_box', options, :onchange => 'if (this.value != \'\') { window.location = this.value; }')
end
end
def project_tree_options_for_select(projects, options = {})
s = ''
project_tree(projects) do |project, level|
- name_prefix = (level > 0 ? (' ' * 2 * level + '» ') : '').html_safe
+ name_prefix = (level > 0 ? ' ' * 2 * level + '» ' : '').html_safe
tag_options = {:value => project.id}
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
tag_options[:selected] = 'selected'