jquery-modal-rails-assets 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +24 -0
- data/app/assets/images/jquery-modal/close.png +0 -0
- data/app/assets/images/jquery-modal/spinner.gif +0 -0
- data/app/assets/javascripts/jquery.modal.js +226 -0
- data/app/assets/stylesheets/jquery.modal.css.scss +44 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/jquery-modal-rails-assets.gemspec +23 -0
- data/lib/jquery-modal-rails-assets.rb +6 -0
- data/lib/jquery-modal-rails-assets/version.rb +3 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21a99e6244070fa8b838df1e49fdec1e4ee5208d
|
4
|
+
data.tar.gz: 410e2bd8860e5a6896253180a839f0556701f356
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5dfd078594beb6552b5fef0024ea8a4191a3bff8691886f1cfb00d0151ab85f12d86a17fd424f42f6426870e76c6abae8fe674fa419496bc70f2b4e471c92b67
|
7
|
+
data.tar.gz: 9fec89d9549712a7facd1d7a20b5121f8a08abf695520bc92f5aefafb710bb58acd0ec611f4978fef0f632f2243fb944e61b0e303daa44ef211c65d32bd1c90b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# jQuery Modal for Rails
|
2
|
+
|
3
|
+
This gem vendors the jQuery Modal assets for Rails 3.1 and greater.
|
4
|
+
The files will be added to the asset pipeline and available for you to use.
|
5
|
+
|
6
|
+
For info on how to use jQuery Modal or get the unmodified asset files visit:
|
7
|
+
|
8
|
+
[jQuery modal](https://github.com/kylefox/jquery-modal)
|
9
|
+
|
10
|
+
## Using the gem
|
11
|
+
|
12
|
+
In your Gemfile add:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'jquery-modal-rails-assets'
|
16
|
+
```
|
17
|
+
|
18
|
+
You can then include it in your app by adding the following to your javascript application file:
|
19
|
+
|
20
|
+
```javascript
|
21
|
+
//= require jquery.modal
|
22
|
+
```
|
23
|
+
|
24
|
+
And to the css application file:
|
25
|
+
|
26
|
+
```css
|
27
|
+
*= require jquery.modal
|
28
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
desc "Update asset files for Rails"
|
4
|
+
task :update_assets do
|
5
|
+
|
6
|
+
Dir.glob(File.join('app/assets/stylesheets', '*.css')).each do |css_file_name|
|
7
|
+
# rename css file
|
8
|
+
css_file_name_out = css_file_name + '.scss'
|
9
|
+
File.rename(css_file_name, css_file_name_out)
|
10
|
+
# update image reference
|
11
|
+
file_content = ''
|
12
|
+
File.open(css_file_name_out, "r:UTF-8") do |file|
|
13
|
+
file_content = file.read
|
14
|
+
end
|
15
|
+
file_content.gsub! /url\(([A-Za-z0-9_-]*\.)(png|gif)\)/ do
|
16
|
+
"image-url(\"jquery-modal/#{$1}#{$2}\")"
|
17
|
+
end
|
18
|
+
File.open(css_file_name_out, 'w') do |file|
|
19
|
+
file << file_content
|
20
|
+
end
|
21
|
+
puts "Renamed and updated #{css_file_name_out}"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/*
|
2
|
+
A simple jQuery modal (http://github.com/kylefox/jquery-modal)
|
3
|
+
Version 0.5.5
|
4
|
+
*/
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
var current = null;
|
8
|
+
|
9
|
+
$.modal = function(el, options) {
|
10
|
+
$.modal.close(); // Close any open modals.
|
11
|
+
var remove, target;
|
12
|
+
this.$body = $('body');
|
13
|
+
this.options = $.extend({}, $.modal.defaults, options);
|
14
|
+
this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10));
|
15
|
+
if (el.is('a')) {
|
16
|
+
target = el.attr('href');
|
17
|
+
//Select element by id from href
|
18
|
+
if (/^#/.test(target)) {
|
19
|
+
this.$elm = $(target);
|
20
|
+
if (this.$elm.length !== 1) return null;
|
21
|
+
this.open();
|
22
|
+
//AJAX
|
23
|
+
} else {
|
24
|
+
this.$elm = $('<div>');
|
25
|
+
this.$body.append(this.$elm);
|
26
|
+
remove = function(event, modal) { modal.elm.remove(); };
|
27
|
+
this.showSpinner();
|
28
|
+
el.trigger($.modal.AJAX_SEND);
|
29
|
+
$.get(target).done(function(html) {
|
30
|
+
if (!current) return;
|
31
|
+
el.trigger($.modal.AJAX_SUCCESS);
|
32
|
+
current.$elm.empty().append(html).on($.modal.CLOSE, remove);
|
33
|
+
current.hideSpinner();
|
34
|
+
current.open();
|
35
|
+
el.trigger($.modal.AJAX_COMPLETE);
|
36
|
+
}).fail(function() {
|
37
|
+
el.trigger($.modal.AJAX_FAIL);
|
38
|
+
current.hideSpinner();
|
39
|
+
el.trigger($.modal.AJAX_COMPLETE);
|
40
|
+
});
|
41
|
+
}
|
42
|
+
} else {
|
43
|
+
this.$elm = el;
|
44
|
+
this.$body.append(this.$elm);
|
45
|
+
this.open();
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
$.modal.prototype = {
|
50
|
+
constructor: $.modal,
|
51
|
+
|
52
|
+
open: function() {
|
53
|
+
var m = this;
|
54
|
+
if(this.options.doFade) {
|
55
|
+
this.block();
|
56
|
+
setTimeout(function() {
|
57
|
+
m.show();
|
58
|
+
}, this.options.fadeDuration * this.options.fadeDelay);
|
59
|
+
} else {
|
60
|
+
this.block();
|
61
|
+
this.show();
|
62
|
+
}
|
63
|
+
if (this.options.escapeClose) {
|
64
|
+
$(document).on('keydown.modal', function(event) {
|
65
|
+
if (event.which == 27) $.modal.close();
|
66
|
+
});
|
67
|
+
}
|
68
|
+
if (this.options.clickClose) this.blocker.click($.modal.close);
|
69
|
+
},
|
70
|
+
|
71
|
+
close: function() {
|
72
|
+
this.unblock();
|
73
|
+
this.hide();
|
74
|
+
$(document).off('keydown.modal');
|
75
|
+
},
|
76
|
+
|
77
|
+
block: function() {
|
78
|
+
var initialOpacity = this.options.doFade ? 0 : this.options.opacity;
|
79
|
+
this.$elm.trigger($.modal.BEFORE_BLOCK, [this._ctx()]);
|
80
|
+
this.blocker = $('<div class="jquery-modal blocker"></div>').css({
|
81
|
+
top: 0, right: 0, bottom: 0, left: 0,
|
82
|
+
width: "100%", height: "100%",
|
83
|
+
position: "fixed",
|
84
|
+
zIndex: this.options.zIndex,
|
85
|
+
background: this.options.overlay,
|
86
|
+
opacity: initialOpacity
|
87
|
+
});
|
88
|
+
this.$body.append(this.blocker);
|
89
|
+
if(this.options.doFade) {
|
90
|
+
this.blocker.animate({opacity: this.options.opacity}, this.options.fadeDuration);
|
91
|
+
}
|
92
|
+
this.$elm.trigger($.modal.BLOCK, [this._ctx()]);
|
93
|
+
},
|
94
|
+
|
95
|
+
unblock: function() {
|
96
|
+
if(this.options.doFade) {
|
97
|
+
this.blocker.fadeOut(this.options.fadeDuration, function() {
|
98
|
+
$(this).remove();
|
99
|
+
});
|
100
|
+
} else {
|
101
|
+
this.blocker.remove();
|
102
|
+
}
|
103
|
+
},
|
104
|
+
|
105
|
+
show: function() {
|
106
|
+
this.$elm.trigger($.modal.BEFORE_OPEN, [this._ctx()]);
|
107
|
+
if (this.options.showClose) {
|
108
|
+
this.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>');
|
109
|
+
this.$elm.append(this.closeButton);
|
110
|
+
}
|
111
|
+
this.$elm.addClass(this.options.modalClass + ' current');
|
112
|
+
this.center();
|
113
|
+
if(this.options.doFade) {
|
114
|
+
this.$elm.fadeIn(this.options.fadeDuration);
|
115
|
+
} else {
|
116
|
+
this.$elm.show();
|
117
|
+
}
|
118
|
+
this.$elm.trigger($.modal.OPEN, [this._ctx()]);
|
119
|
+
},
|
120
|
+
|
121
|
+
hide: function() {
|
122
|
+
this.$elm.trigger($.modal.BEFORE_CLOSE, [this._ctx()]);
|
123
|
+
if (this.closeButton) this.closeButton.remove();
|
124
|
+
this.$elm.removeClass('current');
|
125
|
+
|
126
|
+
if(this.options.doFade) {
|
127
|
+
this.$elm.fadeOut(this.options.fadeDuration);
|
128
|
+
} else {
|
129
|
+
this.$elm.hide();
|
130
|
+
}
|
131
|
+
this.$elm.trigger($.modal.CLOSE, [this._ctx()]);
|
132
|
+
},
|
133
|
+
|
134
|
+
showSpinner: function() {
|
135
|
+
if (!this.options.showSpinner) return;
|
136
|
+
this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>')
|
137
|
+
.append(this.options.spinnerHtml);
|
138
|
+
this.$body.append(this.spinner);
|
139
|
+
this.spinner.show();
|
140
|
+
},
|
141
|
+
|
142
|
+
hideSpinner: function() {
|
143
|
+
if (this.spinner) this.spinner.remove();
|
144
|
+
},
|
145
|
+
|
146
|
+
center: function() {
|
147
|
+
this.$elm.css({
|
148
|
+
position: 'fixed',
|
149
|
+
top: "50%",
|
150
|
+
left: "50%",
|
151
|
+
marginTop: - (this.$elm.outerHeight() / 2),
|
152
|
+
marginLeft: - (this.$elm.outerWidth() / 2),
|
153
|
+
zIndex: this.options.zIndex + 1
|
154
|
+
});
|
155
|
+
},
|
156
|
+
|
157
|
+
//Return context for custom events
|
158
|
+
_ctx: function() {
|
159
|
+
return { elm: this.$elm, blocker: this.blocker, options: this.options };
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
//resize is alias for center for now
|
164
|
+
$.modal.prototype.resize = $.modal.prototype.center;
|
165
|
+
|
166
|
+
$.modal.close = function(event) {
|
167
|
+
if (!current) return;
|
168
|
+
if (event) event.preventDefault();
|
169
|
+
current.close();
|
170
|
+
var that = current.$elm;
|
171
|
+
current = null;
|
172
|
+
return that;
|
173
|
+
};
|
174
|
+
|
175
|
+
$.modal.resize = function() {
|
176
|
+
if (!current) return;
|
177
|
+
current.resize();
|
178
|
+
};
|
179
|
+
|
180
|
+
// Returns if there currently is an active modal
|
181
|
+
$.modal.isActive = function () {
|
182
|
+
return current ? true : false;
|
183
|
+
}
|
184
|
+
|
185
|
+
$.modal.defaults = {
|
186
|
+
overlay: "#000",
|
187
|
+
opacity: 0.75,
|
188
|
+
zIndex: 1,
|
189
|
+
escapeClose: true,
|
190
|
+
clickClose: true,
|
191
|
+
closeText: 'Close',
|
192
|
+
closeClass: '',
|
193
|
+
modalClass: "modal",
|
194
|
+
spinnerHtml: null,
|
195
|
+
showSpinner: true,
|
196
|
+
showClose: true,
|
197
|
+
fadeDuration: null, // Number of milliseconds the fade animation takes.
|
198
|
+
fadeDelay: 1.0 // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.)
|
199
|
+
};
|
200
|
+
|
201
|
+
// Event constants
|
202
|
+
$.modal.BEFORE_BLOCK = 'modal:before-block';
|
203
|
+
$.modal.BLOCK = 'modal:block';
|
204
|
+
$.modal.BEFORE_OPEN = 'modal:before-open';
|
205
|
+
$.modal.OPEN = 'modal:open';
|
206
|
+
$.modal.BEFORE_CLOSE = 'modal:before-close';
|
207
|
+
$.modal.CLOSE = 'modal:close';
|
208
|
+
$.modal.AJAX_SEND = 'modal:ajax:send';
|
209
|
+
$.modal.AJAX_SUCCESS = 'modal:ajax:success';
|
210
|
+
$.modal.AJAX_FAIL = 'modal:ajax:fail';
|
211
|
+
$.modal.AJAX_COMPLETE = 'modal:ajax:complete';
|
212
|
+
|
213
|
+
$.fn.modal = function(options){
|
214
|
+
if (this.length === 1) {
|
215
|
+
current = new $.modal(this, options);
|
216
|
+
}
|
217
|
+
return this;
|
218
|
+
};
|
219
|
+
|
220
|
+
// Automatically bind links with rel="modal:close" to, well, close the modal.
|
221
|
+
$(document).on('click.modal', 'a[rel="modal:close"]', $.modal.close);
|
222
|
+
$(document).on('click.modal', 'a[rel="modal:open"]', function(event) {
|
223
|
+
event.preventDefault();
|
224
|
+
$(this).modal();
|
225
|
+
});
|
226
|
+
})(jQuery);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
.modal {
|
2
|
+
display: none;
|
3
|
+
width: 400px;
|
4
|
+
background: #fff;
|
5
|
+
padding: 15px 30px;
|
6
|
+
-webkit-border-radius: 8px;
|
7
|
+
-moz-border-radius: 8px;
|
8
|
+
-o-border-radius: 8px;
|
9
|
+
-ms-border-radius: 8px;
|
10
|
+
border-radius: 8px;
|
11
|
+
-webkit-box-shadow: 0 0 10px #000;
|
12
|
+
-moz-box-shadow: 0 0 10px #000;
|
13
|
+
-o-box-shadow: 0 0 10px #000;
|
14
|
+
-ms-box-shadow: 0 0 10px #000;
|
15
|
+
box-shadow: 0 0 10px #000;
|
16
|
+
}
|
17
|
+
|
18
|
+
.modal a.close-modal {
|
19
|
+
position: absolute;
|
20
|
+
top: -12.5px;
|
21
|
+
right: -12.5px;
|
22
|
+
display: block;
|
23
|
+
width: 30px;
|
24
|
+
height: 30px;
|
25
|
+
text-indent: -9999px;
|
26
|
+
background: image-url("jquery-modal/close.png") no-repeat 0 0;
|
27
|
+
}
|
28
|
+
|
29
|
+
.modal-spinner {
|
30
|
+
display: none;
|
31
|
+
width: 64px;
|
32
|
+
height: 64px;
|
33
|
+
position: fixed;
|
34
|
+
top: 50%;
|
35
|
+
left: 50%;
|
36
|
+
margin-right: -32px;
|
37
|
+
margin-top: -32px;
|
38
|
+
background: image-url("jquery-modal/spinner.gif") #111 no-repeat center center;
|
39
|
+
-webkit-border-radius: 8px;
|
40
|
+
-moz-border-radius: 8px;
|
41
|
+
-o-border-radius: 8px;
|
42
|
+
-ms-border-radius: 8px;
|
43
|
+
border-radius: 8px;
|
44
|
+
}
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jquery/modal/rails/assets"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jquery-modal-rails-assets/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jquery-modal-rails-assets"
|
8
|
+
spec.version = JqueryModalRailsAssets::VERSION
|
9
|
+
spec.authors = ["RogerE"]
|
10
|
+
spec.email = ["roger@webfokus.no"]
|
11
|
+
|
12
|
+
spec.summary = "Use jQuery Modal with Rails Asset Pipeline"
|
13
|
+
spec.description = "Provides the jQuery Modal assets for your Rails application."
|
14
|
+
spec.homepage = "https://github.com/RogerE/jquery-modal-rails-assets"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-modal-rails-assets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- RogerE
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-10 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Provides the jQuery Modal assets for your Rails application.
|
42
|
+
email:
|
43
|
+
- roger@webfokus.no
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- app/assets/images/jquery-modal/close.png
|
53
|
+
- app/assets/images/jquery-modal/spinner.gif
|
54
|
+
- app/assets/javascripts/jquery.modal.js
|
55
|
+
- app/assets/stylesheets/jquery.modal.css.scss
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- jquery-modal-rails-assets.gemspec
|
59
|
+
- lib/jquery-modal-rails-assets.rb
|
60
|
+
- lib/jquery-modal-rails-assets/version.rb
|
61
|
+
homepage: https://github.com/RogerE/jquery-modal-rails-assets
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.8
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Use jQuery Modal with Rails Asset Pipeline
|
84
|
+
test_files: []
|