readmorejs-rails 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6555f981bddb620917cb307c25421ac6cadb05f5
4
+ data.tar.gz: 344fd893c2489e576e50d2425956d1baa1188e2f
5
+ SHA512:
6
+ metadata.gz: 5c52d5f158adbad32feac8c70603971da7db46d03a32a5497bfb277f6024b36e137b66ce4dc87a3d89252d9590eb5878e92543ac65cb62b5b79022e43524373f
7
+ data.tar.gz: 467f93df36eca4ac9781d54d851ed1a8f01638e32b0f068b09fb4237d7381babf402c4290ced4654c5fe179aeb9f5ae560d8d075c6e1f51d1669f4b9f53049ca
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in readmorejs-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 seankay
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,37 @@
1
+ # Readmorejs::Rails
2
+
3
+ [Readmore.js](https://github.com/jedfoster/Readmore.js) for Rails
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
+ In your `application.css`, include the css file:
22
+
23
+ *= require readmorejs
24
+
25
+ In your `application.js`, include the js file:
26
+
27
+ //= require readmorejs
28
+
29
+ See [Readmore.js](https://github.com/jedfoster/Readmore.js) for more info.
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "lib"
7
+ t.libs << "test"
8
+ t.pattern = "test/**/*_test.rb"
9
+ t.verbose = false
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,5 @@
1
+ module Readmorejs
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "readmorejs/rails/version"
2
+
3
+ module Readmorejs
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,27 @@
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 = Readmorejs::Rails::VERSION
9
+ spec.authors = ["seankay"]
10
+ spec.email = ["f.sean.kay@gmail.com"]
11
+ spec.description = "Readmore.js for Rails"
12
+ spec.summary = "Gemified Readmore.js"
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_runtime_dependency "railties", ">= 3.2", "< 5.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "activesupport"
26
+ spec.add_development_dependency "tzinfo"
27
+ end
@@ -0,0 +1,2 @@
1
+ /log
2
+ /tmp
@@ -0,0 +1,3 @@
1
+ //
2
+ //= require mdmagick
3
+ //
@@ -0,0 +1 @@
1
+ @import mdmagick
@@ -0,0 +1 @@
1
+ @import "mdmagick";
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require mdmagick
3
+ */
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # require "rails/all"
4
+ require "sprockets/railtie"
5
+
6
+ Bundler.require(:default, :development)
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ config.encoding = "utf-8"
11
+ config.assets.enabled = true
12
+ config.assets.version = '1.0'
13
+
14
+ # replacement for environments/*.rb
15
+ config.active_support.deprecation = :stderr
16
+ config.eager_load = false
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
8
+ Dummy::Application.config.secret_key_base = 'deadbeef' if Dummy::Application.config.respond_to?(:secret_key_base)
@@ -0,0 +1,2 @@
1
+ Dummy::Application.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class ReadmorejsRailsTest < ActionDispatch::IntegrationTest
4
+ teardown { clean_sprockets_cache }
5
+
6
+ test "engine" do
7
+ assert_equal ::Rails::Engine, Readmorejs::Rails::Engine.superclass
8
+ end
9
+
10
+ test "javascripts are available" do
11
+ get "/assets/readmore.js"
12
+ assert_response :success
13
+ get "/assets/readmore.min.js"
14
+ assert_response :success
15
+ end
16
+
17
+ private
18
+
19
+ def clean_sprockets_cache
20
+ FileUtils.rm_rf File.expand_path("../dummy/tmp", __FILE__)
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
@@ -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,5 @@
1
+ (function(d){function g(c,a){this.element=c;this.options=d.extend({},h,a);d(this.element).data("max-height",this.options.maxHeight);delete this.options.maxHeight;if(this.options.embedCSS&&!k){var b=".readmore-js-toggle, .readmore-js-section { "+this.options.sectionCSS+" } .readmore-js-section { overflow: hidden; }",e=document.createElement("style");e.type="text/css";e.styleSheet?e.styleSheet.cssText=b:e.appendChild(document.createTextNode(b));document.getElementsByTagName("head")[0].appendChild(e);
2
+ k=!0}this._defaults=h;this._name=f;this.init()}var f="readmore",h={speed:100,maxHeight:200,moreLink:'<a href="#">Read More</a>',lessLink:'<a href="#">Close</a>',embedCSS:!0,sectionCSS:"display: block; width: 100%;",beforeToggle:function(){},afterToggle:function(){}},k=!1;g.prototype={init:function(){var c=this;d(this.element).each(function(){var a=d(this),b=a.css("max-height").replace(/[^-\d\.]/g,"")>a.data("max-height")?a.css("max-height").replace(/[^-\d\.]/g,""):a.data("max-height");a.addClass("readmore-js-section");
3
+ "none"!=a.css("max-height")&&a.css("max-height","none");a.data("boxHeight",a.outerHeight(!0));if(a.outerHeight(!0)<b)return!0;a.after(d(c.options.moreLink).on("click",function(b){c.toggleSlider(this,a,b)}).addClass("readmore-js-toggle"));a.data("sliderHeight",b);a.css({height:b})})},toggleSlider:function(c,a,b){b.preventDefault();var e=this,f=newLink="";b=!1;f=d(a).data("sliderHeight");d(a).height()==f?(f=d(a).data().boxHeight+"px",newLink="lessLink",b=!0):newLink="moreLink";e.options.beforeToggle(c,
4
+ a,b);d(a).animate({height:f},{duration:e.options.speed});d(c).replaceWith(d(e.options[newLink]).on("click",function(b){e.toggleSlider(this,a,b)}).addClass("readmore-js-toggle"));e.options.afterToggle(c,a,b)}};d.fn[f]=function(c){var a=arguments;if(void 0===c||"object"===typeof c)return this.each(function(){d.data(this,"plugin_"+f)||d.data(this,"plugin_"+f,new g(this,c))});if("string"===typeof c&&"_"!==c[0]&&"init"!==c)return this.each(function(){var b=d.data(this,"plugin_"+f);b instanceof g&&"function"===
5
+ typeof b[c]&&b[c].apply(b,Array.prototype.slice.call(a,1))})}})(jQuery);
metadata ADDED
@@ -0,0 +1,156 @@
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
+ - seankay
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: activesupport
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: tzinfo
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: Readmore.js for Rails
90
+ email:
91
+ - f.sean.kay@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - .gitignore
97
+ - Gemfile
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - lib/readmorejs/rails.rb
102
+ - lib/readmorejs/rails/version.rb
103
+ - readmorejs-rails.gemspec
104
+ - test/dummy/.gitignore
105
+ - test/dummy/app/assets/javascripts/application.js
106
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
107
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
108
+ - test/dummy/app/assets/stylesheets/sprockets-require.css
109
+ - test/dummy/config.ru
110
+ - test/dummy/config/application.rb
111
+ - test/dummy/config/boot.rb
112
+ - test/dummy/config/environment.rb
113
+ - test/dummy/config/initializers/secret_token.rb
114
+ - test/dummy/config/routes.rb
115
+ - test/readmorejs_rails_test.rb
116
+ - test/test_helper.rb
117
+ - vendor/assets/javascripts/readmore.js
118
+ - vendor/assets/javascripts/readmore.min.js
119
+ homepage: ''
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.0
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Gemified Readmore.js
143
+ test_files:
144
+ - test/dummy/.gitignore
145
+ - test/dummy/app/assets/javascripts/application.js
146
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
147
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
148
+ - test/dummy/app/assets/stylesheets/sprockets-require.css
149
+ - test/dummy/config.ru
150
+ - test/dummy/config/application.rb
151
+ - test/dummy/config/boot.rb
152
+ - test/dummy/config/environment.rb
153
+ - test/dummy/config/initializers/secret_token.rb
154
+ - test/dummy/config/routes.rb
155
+ - test/readmorejs_rails_test.rb
156
+ - test/test_helper.rb