see_more 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/assets/javascripts/see_more.js +86 -0
- data/lib/see_more/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODlhMzM0YWU2OGQxZmE2MjRkZjEzOTA3NmJkZWNlY2NjYTJiOTdkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzJiNzJmZWIxNTQyYWZlODNmNzVjN2Q2ZDhlODIwZDE5Y2U4YjQ5MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWM4OTNhNTZkNDU3ZWRiMWJiMjU4MWQzZjE0ZWYyYjZkZmY2OTVhZmVhZGMx
|
10
|
+
MDc4ZDQ0ZTJmYzMxMTNjOWU4YmQzYTFkN2U2MmQzYTdhNGYxZTdmY2U2YTRk
|
11
|
+
MDUwOGNkYjc4ZmY3OThiN2EyYmM1NTliZDk0YWE3MmM4YmM0NmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWRiOTVmZjg1NzE2YzAyZjFmY2M4MGY5NGE3YmE0NDc2N2ZiZjk1Y2Y4ZDBl
|
14
|
+
N2QzMzc4NThiZjFkMGFmNzA2ZjY4NzQzYmNiNGE5MGY4NTAzZmExNmUyOGIy
|
15
|
+
YjNjOTcwNWE2MzgzNzlhNDkwMDhkNTE1OTE0ZjE1YTJhYmViMTk=
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/*
|
2
|
+
SeeMore (for jQuery)
|
3
|
+
version: 0.1.0 (16/03/2014)
|
4
|
+
@requires jQuery
|
5
|
+
|
6
|
+
By Senthil Kumar Muthamzihan
|
7
|
+
Examples at http://beckproducts.com
|
8
|
+
|
9
|
+
Licensed under the MIT:
|
10
|
+
http://www.opensource.org/licenses/mit-license.php
|
11
|
+
|
12
|
+
*/
|
13
|
+
|
14
|
+
|
15
|
+
// this function delegates 2 methods on 2 events, 1. on click of see_more_link and 2. on click of see_less_link
|
16
|
+
(function($) {
|
17
|
+
window.SeeMoreEvents = function() {
|
18
|
+
this.showMore = $.proxy(this.showMore, this);
|
19
|
+
this.showLess = $.proxy(this.showLess, this);
|
20
|
+
};
|
21
|
+
|
22
|
+
SeeMoreEvents.prototype = {
|
23
|
+
// runs when see more is clicked
|
24
|
+
showMore: function(e) {
|
25
|
+
var link = e.currentTarget;
|
26
|
+
startSwitch(link,"more");
|
27
|
+
return false;
|
28
|
+
},
|
29
|
+
// runs when see less is clicked
|
30
|
+
showLess: function(e) {
|
31
|
+
var link = e.currentTarget;
|
32
|
+
startSwitch(link,"less");
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
window.seeMoreEvents = new SeeMoreEvents();
|
38
|
+
$(document)
|
39
|
+
.delegate('a.see_more_link','click',seeMoreEvents.showMore)
|
40
|
+
.delegate('a.see_less_link','click',seeMoreEvents.showLess);
|
41
|
+
})(jQuery);
|
42
|
+
|
43
|
+
// Start the process of switching
|
44
|
+
function startSwitch(lk,t){
|
45
|
+
var fromDb = $(lk).data('from-db');
|
46
|
+
// check if fetch from db or just hdie/unhide
|
47
|
+
if (fromDb){
|
48
|
+
var url = $(lk).data('route');
|
49
|
+
// actual fetch from db
|
50
|
+
var precontent = $.getJSON( url, function( data ) {
|
51
|
+
var field = $(lk).data('field');
|
52
|
+
var precontent = data[field];
|
53
|
+
prepareContent(t,lk,precontent);
|
54
|
+
});
|
55
|
+
}else{
|
56
|
+
var precontent = $(lk).data('content');
|
57
|
+
prepareContent(t,lk,precontent);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
// prepares content based on more/less
|
62
|
+
function prepareContent(t,lk,pc){
|
63
|
+
if (t == "more"){ switchMoreLess(lk,"more",pc);}
|
64
|
+
else if (t == "less"){
|
65
|
+
var cSize = $(lk).data('content-size');
|
66
|
+
// substring limit set as 20 if not passed by user, else users limit
|
67
|
+
var c = pc.substring(0, parseInt(cSize));
|
68
|
+
switchMoreLess(lk,"less",c);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
//this function does the actual switch from less content to more content and changes the link text from more to less and vice versa
|
73
|
+
function switchMoreLess(lk,t,ctnt){
|
74
|
+
t = t || "more";
|
75
|
+
if (t == "more"){var opp = "less"}
|
76
|
+
else if (t == "less"){var opp = "more"}
|
77
|
+
// changing content
|
78
|
+
$(lk).closest('.see_more_span').find('.see_more_content').text(ctnt + "...");
|
79
|
+
// changing link text
|
80
|
+
$(lk).closest('.see_' + t + '_link').text('see ' + opp);
|
81
|
+
// toggling class
|
82
|
+
$(lk).removeClass('see_' + t + '_link');
|
83
|
+
$(lk).addClass('see_' + opp + '_link');
|
84
|
+
}
|
85
|
+
|
86
|
+
|
data/lib/see_more/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: see_more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- beck03076
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- LICENSE.txt
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
|
+
- lib/assets/javascripts/see_more.js
|
53
54
|
- lib/see_more.rb
|
54
55
|
- lib/see_more/helper.rb
|
55
56
|
- lib/see_more/railtie.rb
|