首页 > 代码库 > Rails 添加css javascript 结合easyui

Rails 添加css javascript 结合easyui

<% content_for :header_tags do  %>
    <%=stylesheet_link_tag ‘bar.css‘, :plugin=>‘redmine_standard‘ %>
    <%=javascript_include_tag ‘bar.css‘, :plugin=>‘redmine_standard‘ %>
<%    end  %>

 

 

<% content_for :header_tags do  %>
    <%=stylesheet_link_tag ‘easyui.css‘, :easyui=>‘jquery-easyui-1.3.6/themes/default‘ %>
    <%=stylesheet_link_tag ‘icon.css‘, :easyui=>‘jquery-easyui-1.3.6/themes‘ %>
    <%=javascript_include_tag ‘jquery.min.js‘, :easyui=>‘jquery-easyui-1.3.6‘ %>
    <%=javascript_include_tag ‘jquery.easyui.min.js‘, :easyui=>‘jquery-easyui-1.3.6‘ %>
<% end  %>

 

 def javascript_include_tag(*sources)
    options = sources.last.is_a?(Hash) ? sources.pop : {}
    plugin = options.delete(:plugin)
    easyui = options.delete(:easyui)
    sources = sources.map do |source|
      if easyui
        "/#{easyui}/#{source}"
      elsif plugin
        "/plugin_assets/#{plugin}/javascripts/#{source}"
      else
        source
      end
    end
    # if plugin = options.delete(:plugin)
    #   sources = sources.map do |source|
    #     if plugin
    #       "/plugin_assets/#{plugin}/javascripts/#{source}"
    #     else
    #       source
    #     end
    #   end
    # end
    super sources, options
  end

 

  def stylesheet_link_tag(*sources)
    options = sources.last.is_a?(Hash) ? sources.pop : {}
    plugin = options.delete(:plugin)
    easyui = options.delete(:easyui)
    sources = sources.map do |source|
      if easyui
        "/#{easyui}/#{source}"
      elsif plugin
        "/plugin_assets/#{plugin}/stylesheets/#{source}"
      elsif current_theme && current_theme.stylesheets.include?(source)
        current_theme.stylesheet_path(source)
      else
        source
      end
    end
    super sources, options
  end