like_dislike 0.0.1 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d24ef95b3816c2470f322b307a60f1291c071ec7
4
- data.tar.gz: 772e7674e977618c90160869f344c43263d9623e
3
+ metadata.gz: 77129d38d442f4373796eec12051c33166b494cb
4
+ data.tar.gz: 283f109bbc3347662fc42f7eb6b303cb84315026
5
5
  SHA512:
6
- metadata.gz: 36218adc00243a9255fdffff993e3dbb993c8f5fe3bf75046d0636217a65c042a64e395ba3f439ee50919ea25eb55eb9a598498d95ee51cf311226441c094a7f
7
- data.tar.gz: d3d65f82beddcad5d6001b8ceead3ea9b2a8e94c8b47d10bf76c12743edf5a0249119eede79984aa182242aa5af52efa845ce0c98688e25f1aa301aa6699fa2b
6
+ metadata.gz: 6d2487667e314ae533387d31547564ac5725f3fe21c1e7f25a66125e7b886d79469ea0f72d950bd8bb81b7118e7ee1387de6b847b0c6544512bbbe0f1589d846
7
+ data.tar.gz: 1d6031d3466ceb157b1fca00f1f61179ac83192cf2709103b19b88f58146e0d51303b260e247eff51a75832a7efd83ad30fcaa7f743a17de55a6f0b98c3ee6b4
@@ -0,0 +1,32 @@
1
+ $(document).ready(function() {
2
+ $(".voting_wrapper .voting_btn").click(function (e) {
3
+ var clicked_button = $(this).children().attr('class');
4
+ var unique_id = $(this).parent().attr("id");
5
+ if(clicked_button==='down_button')
6
+ {
7
+ post_data = {'id':unique_id, 'vote':'down'};
8
+ $.post('vote_items', post_data, function(data) {
9
+ getData = data.toString().split(",")
10
+ $('#'+unique_id+' .up_votes').text(getData[0]);
11
+ $('#'+unique_id+' .down_votes').text(getData[1]);
12
+ }).fail(function(err) {
13
+ if (err.statusText == "Unauthorized"){
14
+ alert("Please login to UnLike")
15
+ }
16
+ });
17
+ }
18
+ else if(clicked_button==='up_button')
19
+ {
20
+ post_data = {'id':unique_id, 'vote':'up'};
21
+ $.post('vote_items', post_data, function(data) {
22
+ getData = data.toString().split(",")
23
+ $('#'+unique_id+' .up_votes').text(getData[0]);
24
+ $('#'+unique_id+' .down_votes').text(getData[1]);
25
+ }).fail(function(err) {
26
+ if (err.statusText == "Unauthorized"){
27
+ alert("Please login to Like")
28
+ }
29
+ });
30
+ }
31
+ });
32
+ });
@@ -0,0 +1,7 @@
1
+ .voting_wrapper {display:inline-block;margin-left: 20px;}
2
+ .voting_wrapper .down_button {background: url("<%= asset_path "thumbs.png"%>") no-repeat;float: left;height: 14px;width: 16px;cursor:pointer;margin-top: 3px;}
3
+ .voting_wrapper .down_button:hover {background: url("<%= asset_path "thumbs.png"%>") no-repeat 0px -16px;}
4
+ .voting_wrapper .up_button {background: url("<%= asset_path "thumbs.png"%>") no-repeat -16px 0px;float: left;height: 14px;width: 16px;cursor:pointer;}
5
+ .voting_wrapper .up_button:hover{background: url("<%= asset_path "thumbs.png"%>") no-repeat -16px -16px;;}
6
+ .voting_btn{float:left;margin-right:5px;}
7
+ .voting_btn span{font-size: 11px;float: left;margin-left: 3px;}
@@ -0,0 +1,9 @@
1
+ require "rubygems"
2
+ require 'acts_as_votable'
3
+
4
+ module LikeDislike
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module LikeDislike
2
+ module Helper
3
+ def like_unlike_button(votable_object)
4
+ html = []
5
+ html << "<div class='voting_wrapper' id=#{votable_object.id}>
6
+ <div class='voting_wrapper' id=#{votable_object.id}>
7
+ <div class='voting_btn'>
8
+ <div class='up_button'></div>
9
+ <span class='up_votes'>#{votable_object.get_upvotes.size}</span>
10
+ </div>
11
+ <div class='voting_btn'>
12
+ <div class='down_button'></div>
13
+ <span class='down_votes'>#{votable_object.get_downvotes.size}</span>
14
+ </div>
15
+ </div>"
16
+ raw html.join("\n")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ # coding: utf-8
2
+ module LikeDislike
3
+ module Rails
4
+ class Railtie < ::Rails::Railtie
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module LikeDislike
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0"
3
3
  end
data/lib/like_dislike.rb CHANGED
@@ -1,4 +1,15 @@
1
1
  require "like_dislike/version"
2
+ require "like_dislike/helper"
3
+ require "acts_as_votable"
2
4
 
3
5
  module LikeDislike
6
+ module Rails
7
+ if ::Rails.version < "3.1"
8
+ require "like_dislike/railtie"
9
+ else
10
+ require "like_dislike/engine"
11
+ end
12
+ end
4
13
  end
14
+
15
+ ActionView::Base.send :include, LikeDislike::Helper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: like_dislike
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - kishore-mohan
@@ -31,14 +31,13 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
35
- - Gemfile
36
- - LICENSE.txt
37
- - README.md
38
- - Rakefile
34
+ - app/assets/javascripts/like_dislike.js
35
+ - app/assets/stylesheets/like_dislike.css.erb
39
36
  - lib/like_dislike.rb
37
+ - lib/like_dislike/engine.rb
38
+ - lib/like_dislike/helper.rb
39
+ - lib/like_dislike/railtie.rb
40
40
  - lib/like_dislike/version.rb
41
- - like_dislike.gemspec
42
41
  homepage: https://github.com/kishore-mohan/like_dislike
43
42
  licenses:
44
43
  - MIT
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in like_dislike.gemspec
4
- gemspec
5
-
6
- gem 'acts_as_votable'
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 kishore-mohan
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,29 +0,0 @@
1
- # LikeDislike
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'like_dislike'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install like_dislike
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it ( https://github.com/[my-github-username]/like_dislike/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create a new Pull Request
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
data/like_dislike.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'like_dislike/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "like_dislike"
8
- spec.version = LikeDislike::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ["kishore-mohan"]
11
- spec.email = ["kishorevlrtn@gmail.com"]
12
- spec.summary = "Like Dislike by user and Vote and Unvote by user "
13
- spec.description = "Like Dislike/Unlike by user by any object resource, dependency of act_as_votable"
14
- spec.homepage = "https://github.com/kishore-mohan/like_dislike"
15
- spec.licenses = ["MIT"]
16
-
17
- spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_dependency("acts_as_votable")
23
- end