module ArtfullyOseHelper
include LinkHelper
include ActionView::Helpers::NumberHelper
def check_mark(size=nil, alt=nil)
case size
when :huge
icon_tag('117-todo@2x', {:alt => alt})
when :big
icon_tag('117-todo', {:alt => alt})
else
"✓".html_safe
end
end
def build_order_location(order)
order.location
end
def channel_checkbox(channel)
channel.to_s.eql?("storefront") ? "Storefront & Widgets" : channel.to_s.humanize
end
def channel_text(channel)
case channel.to_s
when "members"
"to your members in your Storefront"
when "storefront"
"online Storefront and installed widgets"
else
channel.to_s.humanize
end
end
def build_action_path(target, action)
action_path_name = action.new_record? ? "actions" : "actions"
"#{target.class.name.downcase}_#{action_path_name}_path"
end
def time_ago_sentence(t)
qualifier = t > Time.now ? "from now" : "ago"
"#{time_ago_in_words(t)} #{qualifier}"
end
#
# For use with the nav-pills to select an intem based on a current selection
# Will protect against nil by using try on the object
#
# returns 'active' if selected_object.id = menu_object.id
# 'unselected' otherwise
#
def get_selected_class(selected_object, menu_object)
selected_object.try(:id) == menu_object.id ? "active" : "unselected"
end
#For use with Bootstraps icon %i classes
def icon_link_to(text, href, icon, class_names, id, html_attributes={})
s = " #{text}"
s.html_safe
end
#
# just name the image, this method will prepend the path and append the .png
# icon_tag('111-logo')
#
def icon_tag(img, options={})
image_tag('glyphish/gray/' + img + '.png', options)
end
def time_zone_description(tz)
ActiveSupport::TimeZone.create(tz)
end
#This is for the widget generator, DO NOT use anywhere else
def fully_qualified_asset_path(asset)
"#{asset_path(asset, :digest => false)}"
end
def events_to_options(selected_event_id = nil)
@events = current_user.current_organization.events
@events_array = @events.map { |event| [event.name, event.id] }
@events_array.insert(0, ["", ""])
options_for_select(@events_array, selected_event_id)
end
def contextual_menu(&block)
menu = ContextualMenu.new(self)
block.call(menu)
menu.render_menu
end
def widget_script(event, organization)
return <<-EOF