Sha256: dc38598876195d1aa5a346dfd90d3001eeda63f23622cdfe80413914a06f0d05

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

module ApplicationHelper
  include WithStudentPathNavigation

  # html-escapes an string even if it is html-safe
  def html_rescape(html)
    html_escape html.to_str
  end

  def profile_picture
    profile_picture_for current_user
  end

  def profile_picture_for(user, height = 40)
    image_tag(user.profile_picture, height: height, class: 'img-circle', onError: "this.onerror = null; this.src = '#{image_url('user_shape.png')}'")
  end

  def paginate(object, options = {})
    "<div class=\"text-center\">#{super(object, {theme: 'twitter-bootstrap-3'}.merge(options))}</div>".html_safe
  end

  def last_box_class(trailing_boxes)
    trailing_boxes ? '' : 'mu-last-box'
  end

  def corollary_box(with_corollary, trailing_boxes = false)
    if with_corollary.corollary.present?
      %Q{
        <div class="#{last_box_class trailing_boxes}">
          <p>#{with_corollary.corollary_html}</p>
        </div>
      }.html_safe
    end
  end

  def chapter_finished(chapter)
    t :chapter_finished_html, chapter: link_to_path_element(chapter) if chapter
  end

  def span_toggle(hidden_text, active_text, active, **options)
    %Q{
      <span class="#{'hidden' if active} #{options[:class]}">#{hidden_text}</span>
      <span class="#{'hidden' unless active} #{options[:class]}">#{active_text}</span>
    }.html_safe
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mumuki-laboratory-7.7.6 app/helpers/application_helper.rb
mumuki-laboratory-7.7.5 app/helpers/application_helper.rb
mumuki-laboratory-7.7.4 app/helpers/application_helper.rb
mumuki-laboratory-7.8.0 app/helpers/application_helper.rb
mumuki-laboratory-7.7.3 app/helpers/application_helper.rb
mumuki-laboratory-7.7.2 app/helpers/application_helper.rb
mumuki-laboratory-7.7.1 app/helpers/application_helper.rb
mumuki-laboratory-7.7.0 app/helpers/application_helper.rb