facebox-rails5 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b313a71b583c2f95378a5db6a1b6fe0b0886013
4
+ data.tar.gz: 13c4937baec53c95186e284c1f44d7ed5527044b
5
+ SHA512:
6
+ metadata.gz: 660af00086fecc5b6fa26e23615992500baf3a5828769eb115bbcd1fb3950b93f35c29ccfdf7187293160ddba433408b2be4c2d2b7a23be1d7b3ccf62a373202
7
+ data.tar.gz: 544c6ffebc33c1b3e095221a14ef3136491e0b2cf761e32b4809f514f9f87c4b0150817eff015b06e1e94a5dd8df08abb4657062640367829ebfa3b8ee084aa6
@@ -0,0 +1,25 @@
1
+ # facebox-rails
2
+
3
+ A gemified Facebox for Rails.
4
+
5
+ # Rails 3.1
6
+
7
+ Add it to your Gemfile:
8
+
9
+ gem 'facebox-rails'
10
+
11
+ Include in your `app/assets/stylesheets/application.css`:
12
+
13
+ /*
14
+ * ...
15
+ *= require jquery.facebox
16
+ * ...
17
+ */
18
+
19
+ And in `app/assets/javascripts/application.js`:
20
+
21
+ //= require jquery.facebox
22
+
23
+ If you are using [turbolinks](https://github.com/rails/turbolinks), facebox will still think the necessary DOM objects are present after turbolink load. Avoid this by resetting the `inited` setting.
24
+
25
+ $(document).on 'page:change', -> $.facebox.settings.inited = false
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.verbose = false
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,330 @@
1
+ /*
2
+ * Facebox (for jQuery)
3
+ * version: 1.3
4
+ * @requires jQuery v1.2 or later
5
+ * @homepage https://github.com/defunkt/facebox
6
+ *
7
+ * Licensed under the MIT:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * Copyright Forever Chris Wanstrath, Kyle Neath
11
+ *
12
+ * Usage:
13
+ *
14
+ * jQuery(document).ready(function() {
15
+ * jQuery('a[rel*=facebox]').facebox()
16
+ * })
17
+ *
18
+ * <a href="#terms" rel="facebox">Terms</a>
19
+ * Loads the #terms div in the box
20
+ *
21
+ * <a href="terms.html" rel="facebox">Terms</a>
22
+ * Loads the terms.html page in the box
23
+ *
24
+ * <a href="terms.png" rel="facebox">Terms</a>
25
+ * Loads the terms.png image in the box
26
+ *
27
+ *
28
+ * You can also use it programmatically:
29
+ *
30
+ * jQuery.facebox('some html')
31
+ * jQuery.facebox('some html', 'my-groovy-style')
32
+ *
33
+ * The above will open a facebox with "some html" as the content.
34
+ *
35
+ * jQuery.facebox(function($) {
36
+ * $.get('blah.html', function(data) { $.facebox(data) })
37
+ * })
38
+ *
39
+ * The above will show a loading screen before the passed function is called,
40
+ * allowing for a better ajaxy experience.
41
+ *
42
+ * The facebox function can also display an ajax page, an image, or the contents of a div:
43
+ *
44
+ * jQuery.facebox({ ajax: 'remote.html' })
45
+ * jQuery.facebox({ ajax: 'remote.html' }, 'my-groovy-style')
46
+ * jQuery.facebox({ image: 'stairs.jpg' })
47
+ * jQuery.facebox({ image: 'stairs.jpg' }, 'my-groovy-style')
48
+ * jQuery.facebox({ div: '#box' })
49
+ * jQuery.facebox({ div: '#box' }, 'my-groovy-style')
50
+ *
51
+ * Want to close the facebox? Trigger the 'close.facebox' document event:
52
+ *
53
+ * jQuery(document).trigger('close.facebox')
54
+ *
55
+ * Facebox also has a bunch of other hooks:
56
+ *
57
+ * loading.facebox
58
+ * beforeReveal.facebox
59
+ * reveal.facebox (aliased as 'afterReveal.facebox')
60
+ * init.facebox
61
+ * afterClose.facebox
62
+ *
63
+ * Simply bind a function to any of these hooks:
64
+ *
65
+ * $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... })
66
+ *
67
+ */
68
+
69
+ (function($) {
70
+ $.facebox = function(data, klass) {
71
+ $.facebox.loading()
72
+
73
+ if (data.ajax) fillFaceboxFromAjax(data.ajax, klass)
74
+ else if (data.image) fillFaceboxFromImage(data.image, klass)
75
+ else if (data.div) fillFaceboxFromHref(data.div, klass)
76
+ else if ($.isFunction(data)) data.call($)
77
+ else $.facebox.reveal(data, klass)
78
+ }
79
+
80
+ /*
81
+ * Public, $.facebox methods
82
+ */
83
+
84
+ $.extend($.facebox, {
85
+ settings: {
86
+ opacity : 0.2,
87
+ overlay : true,
88
+ loadingImage : '/assets/facebox/loading.gif',
89
+ closeImage : '/assets/facebox/closelabel.png',
90
+ imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ],
91
+ faceboxHtml : '\
92
+ <div id="facebox" style="display:none;"> \
93
+ <div class="popup"> \
94
+ <div class="content"> \
95
+ </div> \
96
+ <a href="#" class="close"></a> \
97
+ </div> \
98
+ </div>'
99
+ },
100
+
101
+ loading: function(event) {
102
+ init()
103
+ if ($('#facebox .loading').length == 1) return true
104
+ showOverlay()
105
+
106
+ $('#facebox .content').empty().
107
+ append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
108
+ // shepherd
109
+ $('#facebox').show().css(position(event));
110
+ // $('#facebox').show().css({
111
+ // top: getPageScroll()[1] + (getPageHeight() / 10),
112
+ // left: $(window).width() / 2 - ($('#facebox .popup').outerWidth() / 2)
113
+ // })
114
+
115
+ $(document).bind('keydown.facebox', function(e) {
116
+ if (e.keyCode == 27) $.facebox.close()
117
+ return true
118
+ })
119
+ $(document).trigger('loading.facebox')
120
+ },
121
+
122
+ reveal: function(data, klass) {
123
+ $(document).trigger('beforeReveal.facebox')
124
+ if (klass) $('#facebox .content').addClass(klass)
125
+ $('#facebox .content').empty().append(data)
126
+ $('#facebox .popup').children().fadeIn('normal')
127
+ $('#facebox').css('left', $(window).width() / 2 - ($('#facebox .popup').outerWidth() / 2))
128
+ $(document).trigger('reveal.facebox').trigger('afterReveal.facebox')
129
+ },
130
+
131
+ close: function() {
132
+ $(document).trigger('close.facebox')
133
+ return false
134
+ }
135
+ })
136
+
137
+ /*
138
+ * Public, $.fn methods
139
+ */
140
+
141
+ $.fn.facebox = function(settings) {
142
+ if ($(this).length == 0) return
143
+
144
+ init(settings)
145
+
146
+ function clickHandler(event) {
147
+ // shepherd
148
+ $.facebox.loading(event, true)
149
+ // $.facebox.loading(true)
150
+
151
+ // support for rel="facebox.inline_popup" syntax, to add a class
152
+ // also supports deprecated "facebox[.inline_popup]" syntax
153
+ var klass = this.rel.match(/facebox\[?\.(\w+)\]?/)
154
+ if (klass) klass = klass[1]
155
+
156
+ fillFaceboxFromHref(this.href, klass)
157
+ return false
158
+ }
159
+
160
+ return this.bind('click.facebox', clickHandler)
161
+ }
162
+
163
+ /*
164
+ * Private methods
165
+ */
166
+
167
+ // called one time to setup facebox on this page
168
+ function init(settings) {
169
+ $.facebox.settings.inited = $('#facebox').length > 0;
170
+
171
+ if ($.facebox.settings.inited) return true
172
+ else $.facebox.settings.inited = true
173
+
174
+ $(document).trigger('init.facebox')
175
+ makeCompatible()
176
+
177
+ var imageTypes = $.facebox.settings.imageTypes.join('|')
178
+ $.facebox.settings.imageTypesRegexp = new RegExp('\\.(' + imageTypes + ')(\\?.*)?$', 'i')
179
+
180
+ if (settings) $.extend($.facebox.settings, settings)
181
+ $('body').append($.facebox.settings.faceboxHtml)
182
+
183
+ var preload = [ new Image(), new Image() ]
184
+ preload[0].src = $.facebox.settings.closeImage
185
+ preload[1].src = $.facebox.settings.loadingImage
186
+
187
+ $('#facebox').find('.b:first, .bl').each(function() {
188
+ preload.push(new Image())
189
+ preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1')
190
+ })
191
+
192
+ $('#facebox .close')
193
+ .click($.facebox.close)
194
+ .append('<img src="'
195
+ + $.facebox.settings.closeImage
196
+ + '" class="close_image" title="close">')
197
+ }
198
+
199
+ // getPageScroll() by quirksmode.com
200
+ function getPageScroll() {
201
+ var xScroll, yScroll;
202
+ if (self.pageYOffset) {
203
+ yScroll = self.pageYOffset;
204
+ xScroll = self.pageXOffset;
205
+ } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
206
+ yScroll = document.documentElement.scrollTop;
207
+ xScroll = document.documentElement.scrollLeft;
208
+ } else if (document.body) {// all other Explorers
209
+ yScroll = document.body.scrollTop;
210
+ xScroll = document.body.scrollLeft;
211
+ }
212
+ return new Array(xScroll,yScroll)
213
+ }
214
+
215
+ // Adapted from getPageSize() by quirksmode.com
216
+ function getPageHeight() {
217
+ var windowHeight
218
+ if (self.innerHeight) { // all except Explorer
219
+ windowHeight = self.innerHeight;
220
+ } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
221
+ windowHeight = document.documentElement.clientHeight;
222
+ } else if (document.body) { // other Explorers
223
+ windowHeight = document.body.clientHeight;
224
+ }
225
+ return windowHeight
226
+ }
227
+
228
+ // Backwards compatibility
229
+ function makeCompatible() {
230
+ var $s = $.facebox.settings
231
+
232
+ $s.loadingImage = $s.loading_image || $s.loadingImage
233
+ $s.closeImage = $s.close_image || $s.closeImage
234
+ $s.imageTypes = $s.image_types || $s.imageTypes
235
+ $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml
236
+ }
237
+
238
+ // Figures out what you want to display and displays it
239
+ // formats are:
240
+ // div: #id
241
+ // image: blah.extension
242
+ // ajax: anything else
243
+ function fillFaceboxFromHref(href, klass) {
244
+ // div
245
+ if (href.match(/#/)) {
246
+ var url = window.location.href.split('#')[0]
247
+ var target = href.replace(url,'')
248
+ if (target == '#') return
249
+ $.facebox.reveal($(target).html(), klass)
250
+
251
+ // image
252
+ } else if (href.match($.facebox.settings.imageTypesRegexp)) {
253
+ fillFaceboxFromImage(href, klass)
254
+ // ajax
255
+ } else {
256
+ fillFaceboxFromAjax(href, klass)
257
+ }
258
+ }
259
+
260
+ function fillFaceboxFromImage(href, klass) {
261
+ var image = new Image()
262
+ image.onload = function() {
263
+ $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
264
+ }
265
+ image.src = href
266
+ }
267
+
268
+ function fillFaceboxFromAjax(href, klass) {
269
+ $.get(href, function(data) { $.facebox.reveal(data, klass) })
270
+ }
271
+
272
+ function skipOverlay() {
273
+ return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null
274
+ }
275
+
276
+ function showOverlay() {
277
+ if (skipOverlay()) return
278
+
279
+ if ($('#facebox_overlay').length == 0)
280
+ $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>')
281
+
282
+ $('#facebox_overlay').hide().addClass("facebox_overlayBG")
283
+ .css('opacity', $.facebox.settings.opacity)
284
+ .click(function() { $(document).trigger('close.facebox') })
285
+ .fadeIn(200)
286
+ return false
287
+ }
288
+
289
+ function hideOverlay() {
290
+ if (skipOverlay()) return
291
+
292
+ $('#facebox_overlay').fadeOut(200, function(){
293
+ $("#facebox_overlay").removeClass("facebox_overlayBG")
294
+ $("#facebox_overlay").addClass("facebox_hide")
295
+ $("#facebox_overlay").remove()
296
+ })
297
+
298
+ return false
299
+ }
300
+ // shepherd
301
+ function position(event){
302
+ var options = {};
303
+ var ref = $(event.target).attr('ref');
304
+ options.left = $(window).width() / 2 - ($('#facebox .popup').outerWidth() / 2);
305
+ if(ref=='eventY'){
306
+ options.top = event.pageY;
307
+ }else if(ref=='top'){
308
+ options.top = 0;
309
+ $('#facebox').css('max-height', '100%');
310
+ }else{
311
+ options.top = getPageScroll()[1] + (getPageHeight() / 10);
312
+ }
313
+ return options;
314
+ }
315
+
316
+ /*
317
+ * Bindings
318
+ */
319
+
320
+ $(document).bind('close.facebox', function() {
321
+ $(document).unbind('keydown.facebox')
322
+ $('#facebox').fadeOut(function() {
323
+ $('#facebox .content').removeClass().addClass('content')
324
+ $('#facebox .loading').remove()
325
+ $(document).trigger('afterClose.facebox')
326
+ })
327
+ hideOverlay()
328
+ })
329
+
330
+ })(jQuery);
@@ -0,0 +1,82 @@
1
+ #facebox {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: 100;
6
+ text-align: left;
7
+ }
8
+
9
+
10
+ #facebox .popup{
11
+ position:relative;
12
+ border:3px solid rgba(0,0,0,0);
13
+ -webkit-border-radius:5px;
14
+ -moz-border-radius:5px;
15
+ border-radius:5px;
16
+ -webkit-box-shadow:0 0 18px rgba(0,0,0,0.4);
17
+ -moz-box-shadow:0 0 18px rgba(0,0,0,0.4);
18
+ box-shadow:0 0 18px rgba(0,0,0,0.4);
19
+ }
20
+
21
+ #facebox .content {
22
+ display:table;
23
+ width: 370px;
24
+ padding: 10px;
25
+ background: #fff;
26
+ -webkit-border-radius:4px;
27
+ -moz-border-radius:4px;
28
+ border-radius:4px;
29
+ }
30
+
31
+ #facebox .content > p:first-child{
32
+ margin-top:0;
33
+ }
34
+ #facebox .content > p:last-child{
35
+ margin-bottom:0;
36
+ }
37
+
38
+ #facebox .close{
39
+ line-height: 12px;
40
+ position: absolute;
41
+ top: 0px;
42
+ right: 0px;
43
+ padding: 2px;
44
+ background: transparent;
45
+ }
46
+
47
+ #facebox .close img{
48
+ opacity:0.5;
49
+ }
50
+ #facebox .close:hover img{
51
+ opacity:1.0;
52
+ }
53
+
54
+ #facebox .loading {
55
+ text-align: center;
56
+ }
57
+
58
+ #facebox .image {
59
+ text-align: center;
60
+ }
61
+
62
+ #facebox img {
63
+ border: 0;
64
+ margin: 0;
65
+ }
66
+
67
+ #facebox_overlay {
68
+ position: fixed;
69
+ top: 0px;
70
+ left: 0px;
71
+ height:100%;
72
+ width:100%;
73
+ }
74
+
75
+ .facebox_hide {
76
+ z-index:-100;
77
+ }
78
+
79
+ .facebox_overlayBG {
80
+ background-color: #000;
81
+ z-index: 99;
82
+ }
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ $:.unshift File.expand_path('../lib', __FILE__)
4
+ require 'facebox-rails/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "facebox-rails5"
8
+ s.version = Facebox::Rails::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["xinlangzi"]
11
+ s.email = "jordan@51shepherd.com"
12
+ s.homepage = "https://github.com/pracstrat/facebox-rails"
13
+ s.summary = "Use Facebox with Rails 3+"
14
+ s.description = "This gem provides Facebox for your Rails 3+ application."
15
+ s.require_paths = ['lib']
16
+
17
+ s.required_ruby_version = ">= 1.9.3"
18
+ s.required_rubygems_version = ">= 1.3.6"
19
+
20
+ s.add_dependency "railties", ">= 4.2.0"
21
+ s.add_dependency "thor", ">= 0.14", "< 2.0"
22
+
23
+ s.add_dependency "rails-dom-testing", ">= 1", "< 3"
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- test/*`.split("\n")
27
+ end
@@ -0,0 +1,2 @@
1
+ require 'facebox-rails/engine'
2
+ require 'facebox-rails/version'
@@ -0,0 +1,6 @@
1
+ module Facebox
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Facebox
2
+ module Rails
3
+ VERSION = "1.3.1"
4
+ FACEBOX_VERSION = "30d3f057c466c5a56e36fbdd0a40523a1c38617a"
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: facebox-rails5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.1
5
+ platform: ruby
6
+ authors:
7
+ - xinlangzi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-07 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: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0.14'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rails-dom-testing
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '1'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '3'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '1'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '3'
67
+ description: This gem provides Facebox for your Rails 3+ application.
68
+ email: jordan@51shepherd.com
69
+ executables: []
70
+ extensions: []
71
+ extra_rdoc_files: []
72
+ files:
73
+ - README.md
74
+ - Rakefile
75
+ - app/assets/images/facebox/closelabel.png
76
+ - app/assets/images/facebox/loading.gif
77
+ - app/assets/javascripts/jquery.facebox.js
78
+ - app/assets/stylesheets/jquery.facebox.css
79
+ - facebox-rails.gemspec
80
+ - lib/facebox-rails.rb
81
+ - lib/facebox-rails/engine.rb
82
+ - lib/facebox-rails/version.rb
83
+ homepage: https://github.com/pracstrat/facebox-rails
84
+ licenses: []
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.9.3
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 1.3.6
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.6.6
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Use Facebox with Rails 3+
106
+ test_files: []