update facebook setting

This commit is contained in:
spen 2014-03-13 15:25:26 +08:00
parent 09c5a92ba6
commit af1676c69f
10 changed files with 132 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

View File

@ -0,0 +1,33 @@
window.SocialShareButton =
openUrl : (url) ->
window.open(url)
false
share : (el) ->
site = $(el).data('site')
title = encodeURIComponent($(el).parent().data('title'))
img = encodeURIComponent($(el).parent().data("img"))
fb_url = encodeURIComponent($(el).parent().data("fb_url"))
url = encodeURIComponent(location.href)
switch site
when "weibo"
SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8")
when "twitter"
SocialShareButton.openUrl("https://twitter.com/home?status=#{title}: #{url}")
when "douban"
SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}")
when "facebook"
SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}")
when "qq"
SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}")
when "tqq"
SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}")
when "baidu"
SocialShareButton.openUrl("http://apps.hi.baidu.com/share/?url=#{url}&title=#{title}&content=")
when "kaixin001"
SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}")
when "renren"
SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&title=#{title}&description=")
when "google_plus"
SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}&t=#{title}")
false

View File

@ -0,0 +1,90 @@
.social-share-button-baidu {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") 0px 0px no-repeat;
}
.social-share-button-delicious {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -16px 0px no-repeat;
}
.social-share-button-douban {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") 0px -16px no-repeat;
}
.social-share-button-email {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -16px -16px no-repeat;
}
.social-share-button-facebook {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -32px 0px no-repeat;
}
.social-share-button-flickr {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -32px -16px no-repeat;
}
.social-share-button-google {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") 0px -32px no-repeat;
}
.social-share-button-google_plus {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -16px -32px no-repeat;
}
.social-share-button-kaixin001 {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -32px -32px no-repeat;
}
.social-share-button-qq {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -48px 0px no-repeat;
}
.social-share-button-renren {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -48px -16px no-repeat;
}
.social-share-button-tqq {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -48px -32px no-repeat;
}
.social-share-button-twitter {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") 0px -48px no-repeat;
}
.social-share-button-weibo {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -16px -48px no-repeat;
}
.social-share-button-rss {
display:inline-block;
width:16px;
height:16px;
background:url("/assets/social-share-button.png") -32px -48px no-repeat;
}

View File

@ -107,6 +107,11 @@ class Admin::PagePartsController < OrbitBackendController
# params[:page_part][:category] ||= params[:page][:category] # params[:page_part][:category] ||= params[:page][:category]
if @part.update_attributes(params[:page_part]) if @part.update_attributes(params[:page_part])
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
@part['category'] = params[:page_part]['category'] == nil ? [] : params[:page_part]['category']
@part['tag'] = params[:page_part]['tag'] == nil ? [] : params[:page_part]['tag']
@part.save
flash.now[:notice] = t('update.success.content') flash.now[:notice] = t('update.success.content')
respond_to do |format| respond_to do |format|
format.js format.js

View File

@ -31,7 +31,6 @@ class Admin::PagesController < Admin::ItemsController
params[:page][:tag] = [] params[:page][:tag] = []
end end
end end
params[:page][:facebook_enabled] = params[:page][:facebook_enabled] ? true : false
@item = Page.find(params[:id]) @item = Page.find(params[:id])
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank? if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
@ -72,7 +71,6 @@ class Admin::PagesController < Admin::ItemsController
if params[:val].eql?("default_widget") if params[:val].eql?("default_widget")
@checked_style = @item.frontend_style.present? ? @item.frontend_style : nil if @item && @item.app_frontend_url.eql?("default_widget") @checked_style = @item.frontend_style.present? ? @item.frontend_style : nil if @item && @item.app_frontend_url.eql?("default_widget")
@enabled_styles = @module_app.get_default_widget["enabled_styles"] @enabled_styles = @module_app.get_default_widget["enabled_styles"]
@facebook_enabled = @module_app.get_default_widget["facebook_enabled"]
@widget_fields = @module_app.widget_fields.collect do |widget_field| @widget_fields = @module_app.widget_fields.collect do |widget_field|
label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}") label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}")
[label, widget_field[0], class: widget_field[2]] [label, widget_field[0], class: widget_field[2]]

View File

@ -43,7 +43,7 @@ class DefaultWidgetController< OrbitWidgetController
if !params[:id].blank? and !params["clicked_field_name"].blank? if !params[:id].blank? and !params["clicked_field_name"].blank?
clicked_field_name = params["clicked_field_name"].to_sym clicked_field_name = params["clicked_field_name"].to_sym
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}, facebook_share: #{@page_part.facebook_enabled}})") redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})")
elsif !params[:id].blank? and params["preview"] elsif !params[:id].blank? and params["preview"]
clicked_field_name = :title clicked_field_name = :title
@preview_pages = @page_part.module_app.widget_fields_link_method.find_all{|t| t[1].has_key?(:preview)}.collect{|t| t[0]} @preview_pages = @page_part.module_app.widget_fields_link_method.find_all{|t| t[1].has_key?(:preview)}.collect{|t| t[0]}

View File

@ -195,6 +195,7 @@ module ApplicationHelper
stylesheets << "<link href='#{page.design.css_reset.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_reset stylesheets << "<link href='#{page.design.css_reset.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_reset
# stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n" # stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n"
# stylesheets << "<link href='#{asset_path 'default_widget.css'}' rel='stylesheet' type='text/css' />\n" # stylesheets << "<link href='#{asset_path 'default_widget.css'}' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/social-share-button.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.css_default.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_default stylesheets << "<link href='#{page.design.css_default.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_default
theme = page.design.themes.detect{ |d| d.id == page.theme_id } theme = page.design.themes.detect{ |d| d.id == page.theme_id }
stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme
@ -205,6 +206,7 @@ module ApplicationHelper
javascripts = '' javascripts = ''
# javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n" # javascripts << "<script type='text/javascript' src='/assets/lib/jquery.preload-min.js'></script>\n"
# javascripts << "<script type='text/javascript' src='/assets/jquery.cycle.all.latest.js'></script>\n" # javascripts << "<script type='text/javascript' src='/assets/jquery.cycle.all.latest.js'></script>\n"
javascripts << "<script type='text/javascript' src='/assets/lib/social-share-button.js'></script>\n"
page.design.javascripts.each do |js| page.design.javascripts.each do |js|
javascripts << "<script type='text/javascript' src='#{js.file.url}'></script>" javascripts << "<script type='text/javascript' src='#{js.file.url}'></script>"
end end

View File

@ -21,7 +21,6 @@ class Page < Item
field :frontend_sat_to_link , :type => Array,:default => [] field :frontend_sat_to_link , :type => Array,:default => []
field :frontend_data_count field :frontend_data_count
field :facebook_enabled, :type => Boolean, :default => false
belongs_to :theme belongs_to :theme
belongs_to :design belongs_to :design

View File

@ -43,15 +43,6 @@
</li> </li>
<% end %> <% end %>
</ul> </ul>
<div id="facebook-enabled" class="checkbox-groups">
<label>Share setting</label>
<p>
<label class="radio inline">
<%= check_box_tag 'page[facebook_enabled]', true, @item && @item.facebook_enabled || false %>
Enable facebook sharing
</label>
</p>
</div>
<label><%= t("default_widget.fields_") %></label> <label><%= t("default_widget.fields_") %></label>
<table> <table>
<thead> <thead>

View File

@ -103,7 +103,6 @@ module OrbitApp
@query = nil @query = nil
@widget_title_enabled = false @widget_title_enabled = false
@column_title_enabled = true @column_title_enabled = true
@facebook_enabled = false
@image = nil @image = nil
@more_link = {} @more_link = {}
@fields = [] @fields = []
@ -125,7 +124,7 @@ module OrbitApp
end end
def to_module_app_format def to_module_app_format
{"query"=>@query,"image"=>@image,"more_link"=>@more_link,"enabled_styles"=>@enabled_styles,"widget_title_enabled"=>@widget_title_enabled, "column_title_enabled"=>@column_title_enabled, "facebook_enabled"=>@facebook_enabled} rescue nil {"query"=>@query,"image"=>@image,"more_link"=>@more_link,"enabled_styles"=>@enabled_styles,"widget_title_enabled"=>@widget_title_enabled, "column_title_enabled"=>@column_title_enabled} rescue nil
end end
def link_field(field_name,setting) def link_field(field_name,setting)
@ -152,10 +151,6 @@ module OrbitApp
@widget_title_enabled = var @widget_title_enabled = var
end end
def facebook_enabled(var)
@facebook_enabled = var
end
def column_title_enabled(var) def column_title_enabled(var)
@column_title_enabled = var @column_title_enabled = var
end end