Sha256: a106aec12267f3f8d40419b2f13bd93158d6de82b30e8025fa665af7129726b5

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module DynamicMenu
  require 'engine' if defined?(Rails)
  
  module MenuItems
    def newmenuitem(name,link,method=:get,confirm="Are you sure?")
      if !defined?(@actionMenuItems)
        @actionMenuItems = Array.new
      end
      genlink = ""
      
      if method==:delete
        genlink += "<a href=\"#{link}\" data-confirm=\"#{confirm}\" data-method=\"delete\" rel=\"nofollow\">
         #{name}</a>".html_safe
      elsif link==:submit
        genlink += "<a href=\"#\" onclick=\"$('form').submit(); return false;\">#{name}</a>".html_safe
               genlink += "<script type=\"text/javascript\">
               $(document).ready(function(){
               $('html').keypress(function(e){
               if(e.which == 13){
               $('form').submit();
              return false;
              }
             });
             });</script>".html_safe
       elsif link == :back
          genlink = "<a href=\"#\" id=\"jcheats-back\">#{name}</a>".html_safe
          genlink += "<script type=\"text/javascript\">
                $(\"#jcheats-back\").live(\"click\",
                 function(){
                  var ref = document.referrer;
                  document.location=ref;
                   });
              </script>".html_safe
       else
          genlink = "<a href=\"#{link}\">#{name}</a>".html_safe
      end      
      @actionMenuItems << genlink
    end
    
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dynamic_menu-2.0.0 lib/dynamic_menu.rb