Feature #17607

More than one ContextMenu on single page

Added by Jan Strnádek almost 3 years ago. Updated almost 3 years ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Core Plugins
Target version:Candidate for next major release
Resolution:

Description

We have to use multiple queries on single page ( it's quite ugly code yet :) ) and we found problem - multiple context menus in one page (practically in multiple tabs), current behaviour is dimensioned for one menu. We rewrote it as Jquery plugin. We're thinking, the new version can be easy extends with other abilities (for example - handling window resizing and change position of menu elements, different events).

Example (output) javascript:

//<![CDATA[
$('#issue_list').contextMenu({ url: '/issues/context_menu''});
//]]>

Example helper:

  def context_tab_menu(url, el)
    unless @context_tab_menu_included
      content_for :header_tags do
        javascript_include_tag('context_menu') +
          stylesheet_link_tag('context_menu')
      end
      if l(:direction) == 'rtl'
        content_for :header_tags do
          stylesheet_link_tag('context_menu_rtl')
        end
      end
      @context_tab_menu_included = true
    end
    javascript_tag "$('#{el}').contextMenu({ url: '#{ url_for(url) }'});" 
  end

Template:

<%= context_tab_menu issues_context_menu_path, '#issue_list' %>

Note: The first element is div around form element it's because we're using ajax to refresh query result (multiple queries), we have to bind context menu handler on it.

context_menu.js - Context Menu javascript (6.48 KB) Jan Strnádek, 2014-08-04 13:07

History

#1 Updated by Etienne Massip almost 3 years ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF