readmorejs_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/readmore.js +142 -0
- data/lib/readmorejs_rails.rb +8 -0
- data/lib/readmorejs_rails/version.rb +3 -0
- data/readmorejs_rails.gemspec +25 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NjkwYjQ1MzM1NDgyMmYyZTk0NGFiZjYzZTIzYTkzZjIyMmQwZDY3Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWJiMjUxMTVjNTZlYjVhZTcwYjMyODRlNjI2M2RjNTIwMzhmOGI1ZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmViMjY2MjRhZTMwMjZlNzIwNzY5OWJjNDA3MjViNjQ5ZTVjMWViYWQzOTMw
|
10
|
+
YzkyNDYwZTQ3MWExZjczNmEwZTMxNTZiYWYzZWNkYjMwMmU4OWVkMjhhYzY4
|
11
|
+
YTA5ZmU3OWE1NTQ1OTk5Nzk4YTY4OGY4NTg3YjAzZmIxZWM0NmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjAxMWE3OTI3ZjM4ZWRkNTE4MGJmMDQ2M2RmMzQ5MGE1ZjY5NmFlYjRhY2Q1
|
14
|
+
M2RmMGUxZjg2Y2FlZTYwOTNmYmRkOWI5M2I3ODdlYjQ0NWZjYmUyMGM5NmE2
|
15
|
+
NDE2ODM2MjRiN2RlOWFhZTU2OTdiMDVjOGU0YjM5YmIyODc3YWU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Guy Israeli
|
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
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Readmore.jsRails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'readmorejs_rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install readmorejs_rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
add to javascript manifest file with
|
22
|
+
|
23
|
+
//= require readmore.js
|
24
|
+
|
25
|
+
|
26
|
+
see latest info here https://github.com/jedfoster/Readmore.js
|
27
|
+
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,142 @@
|
|
1
|
+
/*!
|
2
|
+
* Readmore.js jQuery plugin
|
3
|
+
* Author: @jed_foster
|
4
|
+
* Project home: jedfoster.github.io/Readmore.js
|
5
|
+
* Licensed under the MIT license
|
6
|
+
*/
|
7
|
+
|
8
|
+
;(function($) {
|
9
|
+
|
10
|
+
var readmore = 'readmore',
|
11
|
+
defaults = {
|
12
|
+
speed: 100,
|
13
|
+
maxHeight: 200,
|
14
|
+
moreLink: '<a href="#">Read More</a>',
|
15
|
+
lessLink: '<a href="#">Close</a>',
|
16
|
+
embedCSS: true,
|
17
|
+
sectionCSS: 'display: block; width: 100%;',
|
18
|
+
startOpen: false,
|
19
|
+
|
20
|
+
// callbacks
|
21
|
+
beforeToggle: function(){},
|
22
|
+
afterToggle: function(){}
|
23
|
+
},
|
24
|
+
cssEmbedded = false;
|
25
|
+
|
26
|
+
function Readmore( element, options ) {
|
27
|
+
this.element = element;
|
28
|
+
|
29
|
+
this.options = $.extend( {}, defaults, options);
|
30
|
+
|
31
|
+
$(this.element).data('max-height', this.options.maxHeight);
|
32
|
+
|
33
|
+
delete(this.options.maxHeight);
|
34
|
+
|
35
|
+
if(this.options.embedCSS && ! cssEmbedded) {
|
36
|
+
var styles = '.readmore-js-toggle, .readmore-js-section { ' + this.options.sectionCSS + ' } .readmore-js-section { overflow: hidden; }';
|
37
|
+
|
38
|
+
(function(d,u) {
|
39
|
+
var css=d.createElement('style');
|
40
|
+
css.type = 'text/css';
|
41
|
+
if(css.styleSheet) {
|
42
|
+
css.styleSheet.cssText = u;
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
css.appendChild(d.createTextNode(u));
|
46
|
+
}
|
47
|
+
d.getElementsByTagName("head")[0].appendChild(css);
|
48
|
+
}(document, styles));
|
49
|
+
|
50
|
+
cssEmbedded = true;
|
51
|
+
}
|
52
|
+
|
53
|
+
this._defaults = defaults;
|
54
|
+
this._name = readmore;
|
55
|
+
|
56
|
+
this.init();
|
57
|
+
}
|
58
|
+
|
59
|
+
Readmore.prototype = {
|
60
|
+
|
61
|
+
init: function() {
|
62
|
+
var $this = this;
|
63
|
+
|
64
|
+
$(this.element).each(function() {
|
65
|
+
var current = $(this),
|
66
|
+
maxHeight = (current.css('max-height').replace(/[^-\d\.]/g, '') > current.data('max-height')) ? current.css('max-height').replace(/[^-\d\.]/g, '') : current.data('max-height');
|
67
|
+
|
68
|
+
current.addClass('readmore-js-section');
|
69
|
+
|
70
|
+
if(current.css('max-height') != "none") {
|
71
|
+
current.css("max-height", "none");
|
72
|
+
}
|
73
|
+
|
74
|
+
current.data("boxHeight", current.outerHeight(true));
|
75
|
+
|
76
|
+
if(current.outerHeight(true) < maxHeight) {
|
77
|
+
// The block is shorter than the limit, so there's no need to truncate it.
|
78
|
+
return true;
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
current.data('sliderHeight', maxHeight);
|
82
|
+
|
83
|
+
var useLink = $this.options.startOpen ? $this.options.lessLink : $this.options.moreLink;
|
84
|
+
current.after($(useLink).on('click', function(event) { $this.toggleSlider(this, current, event) }).addClass('readmore-js-toggle'));
|
85
|
+
|
86
|
+
if(!$this.options.startOpen) {
|
87
|
+
current.css({height: maxHeight});
|
88
|
+
}
|
89
|
+
}
|
90
|
+
});
|
91
|
+
},
|
92
|
+
|
93
|
+
toggleSlider: function(trigger, element, event)
|
94
|
+
{
|
95
|
+
event.preventDefault();
|
96
|
+
|
97
|
+
var $this = this,
|
98
|
+
newHeight = newLink = '',
|
99
|
+
more = false,
|
100
|
+
sliderHeight = $(element).data('sliderHeight');
|
101
|
+
|
102
|
+
if ($(element).height() == sliderHeight) {
|
103
|
+
newHeight = $(element).data().boxHeight + "px";
|
104
|
+
newLink = 'lessLink';
|
105
|
+
more = true;
|
106
|
+
}
|
107
|
+
|
108
|
+
else {
|
109
|
+
newHeight = sliderHeight;
|
110
|
+
newLink = 'moreLink';
|
111
|
+
}
|
112
|
+
|
113
|
+
// Fire beforeToggle callback
|
114
|
+
$this.options.beforeToggle(trigger, element, more);
|
115
|
+
|
116
|
+
$(element).animate({"height": newHeight}, {duration: $this.options.speed });
|
117
|
+
|
118
|
+
$(trigger).replaceWith($($this.options[newLink]).on('click', function(event) { $this.toggleSlider(this, element, event) }).addClass('readmore-js-toggle'));
|
119
|
+
|
120
|
+
// Fire afterToggle callback
|
121
|
+
$this.options.afterToggle(trigger, element, more);
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
$.fn[readmore] = function( options ) {
|
126
|
+
var args = arguments;
|
127
|
+
if (options === undefined || typeof options === 'object') {
|
128
|
+
return this.each(function () {
|
129
|
+
if (!$.data(this, 'plugin_' + readmore)) {
|
130
|
+
$.data(this, 'plugin_' + readmore, new Readmore( this, options ));
|
131
|
+
}
|
132
|
+
});
|
133
|
+
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
134
|
+
return this.each(function () {
|
135
|
+
var instance = $.data(this, 'plugin_' + readmore);
|
136
|
+
if (instance instanceof Readmore && typeof instance[options] === 'function') {
|
137
|
+
instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
|
138
|
+
}
|
139
|
+
});
|
140
|
+
}
|
141
|
+
}
|
142
|
+
})(jQuery);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'readmorejs_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "readmorejs_rails"
|
8
|
+
spec.version = ReadmorejsRails::VERSION
|
9
|
+
spec.authors = ["Guy Israeli"]
|
10
|
+
spec.email = ["guy.israeli@gmail.com"]
|
11
|
+
spec.description = %q{Readmore.js for Rails 3.1+}
|
12
|
+
spec.summary = %q{See more! Read more! now for the asset pipeline}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "railties", ">=3.1"
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: readmorejs_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guy Israeli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
description: Readmore.js for Rails 3.1+
|
56
|
+
email:
|
57
|
+
- guy.israeli@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- app/assets/javascripts/readmore.js
|
68
|
+
- lib/readmorejs_rails.rb
|
69
|
+
- lib/readmorejs_rails/version.rb
|
70
|
+
- readmorejs_rails.gemspec
|
71
|
+
homepage: ''
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.1.3
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: See more! Read more! now for the asset pipeline
|
95
|
+
test_files: []
|