Commit 4648199ea878a0fdb79046a74a770524f7e6b04a
1 parent
01ac8954
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
site_tour: parse profile fields in tooltip description
Showing
7 changed files
with
46 additions
and
3 deletions
Show diff stats
plugins/site_tour/lib/site_tour_plugin/site_tour_helper.rb
0 → 100644
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +module SiteTourPlugin::SiteTourHelper | ||
2 | + | ||
3 | + def parse_tour_description(description) | ||
4 | + p = profile rescue nil | ||
5 | + if !p.nil? && description.present? | ||
6 | + description.gsub('{profile.identifier}', p.identifier). | ||
7 | + gsub('{profile.name}', p.name). | ||
8 | + gsub('{profile.url}', url_for(p.url)) | ||
9 | + else | ||
10 | + description | ||
11 | + end | ||
12 | + end | ||
13 | + | ||
14 | +end |
plugins/site_tour/lib/site_tour_plugin/tour_block.rb
@@ -8,7 +8,7 @@ class SiteTourPlugin::TourBlock < Block | @@ -8,7 +8,7 @@ class SiteTourPlugin::TourBlock < Block | ||
8 | 8 | ||
9 | before_save do |block| | 9 | before_save do |block| |
10 | block.actions.reject! {|i| i[:group_name].blank? && i[:selector].blank? && i[:description].blank?} | 10 | block.actions.reject! {|i| i[:group_name].blank? && i[:selector].blank? && i[:description].blank?} |
11 | - block.group_triggers.reject! {|i| i[:group_name].blank? && i[:selector].blank? && i[:event].blank?} | 11 | + block.group_triggers.reject! {|i| i[:group_name].blank? && i[:selector].blank?} |
12 | end | 12 | end |
13 | 13 | ||
14 | def self.description | 14 | def self.description |
plugins/site_tour/public/edit_tour_block.css
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +require File.dirname(__FILE__) + '/../test_helper' | ||
2 | + | ||
3 | +class SiteTourHelperTest < ActionView::TestCase | ||
4 | + | ||
5 | + include SiteTourPlugin::SiteTourHelper | ||
6 | + | ||
7 | + should 'parse tooltip description' do | ||
8 | + assert_equal 'test', parse_tour_description("test") | ||
9 | + end | ||
10 | + | ||
11 | + should 'replace profile attributes in tooltip description' do | ||
12 | + profile = fast_create(Profile) | ||
13 | + expects(:profile).returns(profile).at_least_once | ||
14 | + assert_equal "name #{profile.name}, identifier #{profile.identifier}, url #{url_for profile.url}", parse_tour_description("name {profile.name}, identifier {profile.identifier}, url {profile.url}") | ||
15 | + end | ||
16 | + | ||
17 | +end |
plugins/site_tour/views/box_organizer/site_tour_plugin/_tour_block.html.erb
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | <div id='edit-tour-block'> | 6 | <div id='edit-tour-block'> |
7 | <div id="tooltip-actions" class="list-items"> | 7 | <div id="tooltip-actions" class="list-items"> |
8 | <h3><%= _('Tooltip Actions') %></h3> | 8 | <h3><%= _('Tooltip Actions') %></h3> |
9 | + <div class="special-attributes"><%= _('Special fields for description: {profile.name}, {profile.identifier}, {profile.url}.') %></div> | ||
9 | <ul class='list-header'> | 10 | <ul class='list-header'> |
10 | <li class='list-name'><%= _('Group Name') %></li> | 11 | <li class='list-name'><%= _('Group Name') %></li> |
11 | <li class='list-selector'><%= _('Selector') %></li> | 12 | <li class='list-selector'><%= _('Selector') %></li> |
plugins/site_tour/views/box_organizer/site_tour_plugin/_tour_block_group_item.html.erb
@@ -7,7 +7,9 @@ | @@ -7,7 +7,9 @@ | ||
7 | <%= text_field_tag 'block[group_triggers][][selector]', group[:selector], :class => 'selector' %> | 7 | <%= text_field_tag 'block[group_triggers][][selector]', group[:selector], :class => 'selector' %> |
8 | </li> | 8 | </li> |
9 | <li> | 9 | <li> |
10 | - <%= text_field_tag 'block[group_triggers][][event]', group[:event], :class => 'description' %> | 10 | + <%= select_tag 'block[group_triggers][][event]', |
11 | + options_for_select(['mouseenter', 'mouseleave', 'mouseover', 'mouseout', 'click', 'change', 'select', 'keydown', 'keyup', 'keypress', 'focus', 'blur', 'submit', 'drag', 'drop'], group[:event]), | ||
12 | + :class => 'description' %> | ||
11 | </li> | 13 | </li> |
12 | <li> | 14 | <li> |
13 | <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-tour-block-item") %> | 15 | <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-tour-block-item") %> |
plugins/site_tour/views/tour_actions.html.erb
1 | +<% extend SiteTourPlugin::SiteTourHelper %> | ||
1 | <% js_file = defined?(:js_file) ? js_file : nil %> | 2 | <% js_file = defined?(:js_file) ? js_file : nil %> |
2 | <%= javascript_include_tag(js_file) if js_file.present? %> | 3 | <%= javascript_include_tag(js_file) if js_file.present? %> |
3 | 4 | ||
@@ -6,7 +7,7 @@ | @@ -6,7 +7,7 @@ | ||
6 | jQuery( document ).ready(function( $ ) { | 7 | jQuery( document ).ready(function( $ ) { |
7 | <% actions.group_by {|h| h[:group_name]}.each do |group, group_actions| %> | 8 | <% actions.group_by {|h| h[:group_name]}.each do |group, group_actions| %> |
8 | <% group_actions.each_with_index do |action, index| %> | 9 | <% group_actions.each_with_index do |action, index| %> |
9 | - <%= "siteTourPlugin.add('#{j action[:group_name]}', '#{j action[:selector]}', '#{j action[:description]}', #{index + 1});" %> | 10 | + <%= "siteTourPlugin.add('#{j action[:group_name]}', '#{j action[:selector]}', '#{j parse_tour_description(action[:description])}', #{index + 1});" %> |
10 | <% end %> | 11 | <% end %> |
11 | <% end %> | 12 | <% end %> |
12 | 13 |