Sha256: 9c6fa76f4e174f77a5acfe5446eb4b1c693f9942e8e7258ffe2a124f9c8f9408

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

if defined?(ActionView) and defined?(ActionView::Base)

  class ActionView::Base
    
    def whowish_word_javascript_and_css(force = false)
      
      return "" if @whowish_word_edit_mode != true and force == false
      
      script_text = <<-HTML
        <script type="text/javascript">
          $w(function() {
            $w.whowishWord();
          });
        </script>
      HTML
      
      return javascript_include_tag("/whowish_word_js").sub('.js', '').html_safe + \
              stylesheet_link_tag("/whowish_word_css").sub('.css', '').html_safe + \
              script_text.html_safe
    end

    def global_word_for(namespace, id, *variables)
      
      if @whowish_word_edit_mode == true
        return WhowishWord.word_for_in_edit_mode(namespace, id, *variables)
      else
        return WhowishWord.word_for(namespace, id, *variables)
      end
      
    end
    
    def global_word_for_attr(namespace, id, *variables)
      
      if @whowish_word_edit_mode == true
        return WhowishWord.word_for_attr_in_edit_mode(namespace, id, *variables)
      else
        return WhowishWord.word_for_attr(namespace, id, *variables)
      end
      
    end
  
    def word_for(id, *variables)
      
      namespace = get_relative_view_path(@whowish_word_page)
      global_word_for(namespace, id, *variables)
      
    end
    
    def word_for_attr(id, *variables)
      
      namespace = get_relative_view_path(@whowish_word_page)
      global_word_for_attr(namespace, id, *variables)
      
    end
    
    private
      def get_relative_view_path(full_path)
        result = @whowish_word_page.match(/[\/\\](([^\/\\]+)[\/\\]([^\/\\]+))\Z/)
        return result[1]
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whowish_word-0.2.7 lib/whowish_word/action_view/base.rb