Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating sexy_bookmarks for rails 3.1
- Loading branch information
Showing
3 changed files
with
40 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,57 @@ | ||
module SexyBookmarksMacrosHelper | ||
|
||
def available_social_networks | ||
if @available_socials.nil? | ||
socials = File.new( File.join(File.dirname(__FILE__), 'fixtures', 'socials.yml') ) | ||
@available_socials = YAML::load socials | ||
socials.close | ||
end | ||
|
||
@available_socials | ||
end | ||
|
||
def show_sexy_bookmarks( content, socials = nil, per_row = 8 ) | ||
socials = available_social_networks.keys if socials.nil? | ||
|
||
list_items = socials.collect do |social| | ||
|
||
list_items = socials.collect do |social| | ||
link_url = available_social_networks[social.to_s]['url'].to_s.gsub( /SHORT_TITLE|TITLE/, content[:title].to_s ) | ||
link_url = link_url.gsub( /FETCH_URL|PERMALINK/, content[:permalink].to_s ) | ||
link_url = link_url.gsub( /POST_SUMMARY|SEXY_TEASER/, content[:post_summary].to_s ).gsub(/SITE_NAME/, content[:site_name].to_s ) | ||
link_url = link_url.gsub( /TWITT_CAT/, content[:twitt_cat].to_s ).gsub( /DEFAULT_TAGS/, content[:default_tags].to_s ) | ||
link_url = link_url.gsub( /YAHOOTEASER/, content[:yahooteaser].to_s ).gsub( /YAHOOCATEGORY/, content[:yahoocategory].to_s ) | ||
link_url = link_url.gsub( /YAHOOMEDIATYPE/, content[:yahoomediatype].to_s ) | ||
|
||
link_options = { | ||
:href => link_url, | ||
:rel => :nofollow, | ||
debugger if social == :twitter | ||
link_options = { | ||
:href => link_url, | ||
:rel => :nofollow, | ||
:title => available_social_networks[social.to_s]['message'], | ||
:class => :external | ||
} | ||
} | ||
link = content_tag( 'a', available_social_networks[social.to_s]['message'], link_options ) | ||
content_tag( 'li', link, :class => 'shr-' + social.to_s ) | ||
end | ||
unordered_list = content_tag( 'ul', list_items, :class => 'socials' ) | ||
content_tag( 'div', unordered_list, { :class => 'shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr', :id => 'sexybookmarks' } ) + reveal_social_list(socials.count, per_row) | ||
end.join('') | ||
|
||
unordered_list = content_tag( 'ul', list_items.html_safe, :class => 'socials' ) | ||
content_tag( 'div', unordered_list.html_safe, { :class => 'shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr', :id => 'sexybookmarks' } ) + reveal_social_list(socials.count, per_row) | ||
end | ||
|
||
def include_sexy_bookmarks_if_needed | ||
stylesheet_link_tag "sexybookmarks/style.css" if @uses_sexy_bookmarks | ||
end | ||
def reveal_social_list(total, per_row) | ||
|
||
def reveal_social_list(total, per_row) | ||
rows = ( total / Float(per_row ) % 2 == 0 ) ? total / per_row : ( total / per_row ) + 1 | ||
javascript = %{ | ||
$(document).ready(function() { | ||
$(".socials").hover(function(){ | ||
$("#sexybookmarks").delay(500).animate({ height: "#{rows*32}px" }, 750); | ||
$(".socials").hover(function(){ | ||
$("#sexybookmarks").delay(500).animate({ height: "#{rows*32}px" }, 750); | ||
}, | ||
function(){ | ||
$("#sexybookmarks").animate({ height: "32px"}, 750); | ||
function(){ | ||
$("#sexybookmarks").animate({ height: "32px"}, 750); | ||
}); | ||
}); | ||
} | ||
content_tag('script', javascript, :type => 'text/javascript') | ||
|
||
content_tag('script', javascript.html_safe, :type => 'text/javascript') | ||
end | ||
end | ||
end |