sociality 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md~ ADDED
@@ -0,0 +1,31 @@
1
+ # Sociality
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sociality'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sociality
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/sociality/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,72 @@
1
+ window.Sociality =
2
+ openUrl : (url,popup) ->
3
+ if popup == "true"
4
+ window.open(url,'popup','height=500,width=500')
5
+ else
6
+ window.open(url)
7
+ false
8
+
9
+ share : (el) ->
10
+ site = $(el).data('site')
11
+ appkey = $(el).data('appkey') || ''
12
+ $parent = $(el).parent()
13
+ title = encodeURIComponent($(el).data(site + '-title') || $parent.data('title') || '')
14
+ img = encodeURIComponent($parent.data("img") || '')
15
+ url = encodeURIComponent($parent.data("url") || '')
16
+ via = encodeURIComponent($parent.data("via") || '')
17
+ desc = encodeURIComponent($parent.data("desc") || ' ')
18
+ popup = encodeURIComponent($parent.data("popup") || 'false')
19
+
20
+ if url.length == 0
21
+ url = encodeURIComponent(location.href)
22
+ switch site
23
+ when "email"
24
+ location.href = "mailto:?to=&subject=#{title}&body=#{url}"
25
+ when "twitter"
26
+ via_str = ''
27
+ via_str = "&via=#{via}" if via.length > 0
28
+ SocialShareButton.openUrl("https://twitter.com/intent/tweet?url=#{url}&text=#{title}#{via_str}",popup)
29
+ when "facebook"
30
+ SocialShareButton.openUrl("http://www.facebook.com/sharer.php?u=#{url}",popup)
31
+ when "google_plus"
32
+ SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}", popup)
33
+ when "google_bookmark"
34
+ SocialShareButton.openUrl("https://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{url}&title=#{title}", popup)
35
+ when "delicious"
36
+ SocialShareButton.openUrl("http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{img}", popup)
37
+ when "plurk"
38
+ SocialShareButton.openUrl("http://www.plurk.com/?status=#{title}: #{url}&qualifier=shares", popup)
39
+ when "pinterest"
40
+ SocialShareButton.openUrl("http://www.pinterest.com/pin/create/button/?url=#{url}&media=#{img}&description=#{title}", popup)
41
+ when "linkedin"
42
+ SocialShareButton.openUrl("https://www.linkedin.com/shareArticle?mini=true&url=#{url}&title=#{title}&summary=#{desc}&source=", popup)
43
+ when "tumblr"
44
+ get_tumblr_extra = (param) ->
45
+ cutom_data = $(el).attr("data-#{param}")
46
+ encodeURIComponent(cutom_data) if cutom_data
47
+
48
+ tumblr_params = ->
49
+ path = get_tumblr_extra('type') || 'link'
50
+
51
+ params = switch path
52
+ when 'text'
53
+ title = get_tumblr_extra('title') || title
54
+ "title=#{title}"
55
+ when 'photo'
56
+ title = get_tumblr_extra('caption') || title
57
+ source = get_tumblr_extra('source') || img
58
+ "caption=#{title}&source=#{source}"
59
+ when 'quote'
60
+ quote = get_tumblr_extra('quote') || title
61
+ source = get_tumblr_extra('source') || ''
62
+ "quote=#{quote}&source=#{source}"
63
+ else # actually, it's a link clause
64
+ title = get_tumblr_extra('title') || title
65
+ url = get_tumblr_extra('url') || url
66
+ "name=#{title}&url=#{url}"
67
+
68
+
69
+ "/#{path}?#{params}"
70
+
71
+ Sociality.openUrl("http://www.tumblr.com/share#{tumblr_params()}", popup)
72
+ false