Sha256: a69f1b97ad59ae393eb6760b0e36827ad701724c3a22a500372df9a1cc7448c7

Contents?: true

Size: 1.69 KB

Versions: 16

Compression:

Stored size: 1.69 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") + \
              stylesheet_link_tag("/whowish_word.css") + \
              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

16 entries across 16 versions & 1 rubygems

Version Path
whowish_word-0.2.6 lib/whowish_word/action_view/base.rb
whowish_word-0.2.5 lib/whowish_word/action_view/base.rb
whowish_word-0.2.3 lib/whowish_word/action_view/base.rb
whowish_word-0.2.2 lib/whowish_word/action_view/base.rb
whowish_word-0.2.1 lib/whowish_word/action_view/base.rb
whowish_word-0.2.0 lib/whowish_word/action_view/base.rb
whowish_word-0.1.9 lib/whowish_word/action_view/base.rb
whowish_word-0.1.8 lib/whowish_word/action_view/base.rb
whowish_word-0.1.7 lib/whowish_word/action_view/base.rb
whowish_word-0.1.6 lib/whowish_word/action_view/base.rb
whowish_word-0.1.5 lib/whowish_word/action_view/base.rb
whowish_word-0.1.4 lib/whowish_word/action_view/base.rb
whowish_word-0.1.3 lib/whowish_word/action_view/base.rb
whowish_word-0.1.2 lib/whowish_word/action_view/base.rb
whowish_word-0.1.1 lib/whowish_word/action_view/base.rb
whowish_word-0.1.0 lib/whowish_word/action_view/base.rb