lazybox 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +62 -33
- data/lib/lazybox/version.rb +1 -1
- data/vendor/assets/javascripts/lazybox.js +8 -10
- data/vendor/assets/stylesheets/lazybox.css +2 -4
- metadata +4 -4
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
LazyBox
|
2
2
|
=======
|
3
3
|
|
4
|
+
[Live Demo](http://lazybox.herokuapp.com/)
|
5
|
+
|
6
|
+
[Demo Source](https://github.com/alex-galushka/lazybox_demo)
|
7
|
+
|
4
8
|
Lazybox is a jQuery-based, lightbox that can display entire remote pages, images and confirmation dialogs.
|
5
9
|
Replace standard rails confirmations with lazybox just added several rows to your project. Use lazybox with rails assets pipeline.
|
6
10
|
|
@@ -9,12 +13,12 @@ This is high perfomance modal dialogs. All unpacked files take only 5 kb.
|
|
9
13
|
This is simplest solution for popup windows and custom confirmation dialogs.
|
10
14
|
|
11
15
|
Installing
|
12
|
-
|
16
|
+
----------
|
13
17
|
|
14
18
|
Add it to your Gemfile:
|
15
19
|
|
16
20
|
```ruby
|
17
|
-
|
21
|
+
gem 'lazybox'
|
18
22
|
```
|
19
23
|
|
20
24
|
Then run `bundle install` to update your application's bundle.
|
@@ -22,17 +26,17 @@ Then run `bundle install` to update your application's bundle.
|
|
22
26
|
Include in your `application.css`:
|
23
27
|
|
24
28
|
```css
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
/*
|
30
|
+
* ...
|
31
|
+
*= require lazybox
|
32
|
+
* ...
|
33
|
+
*/
|
30
34
|
```
|
31
35
|
|
32
36
|
And in `application.js`:
|
33
37
|
|
34
38
|
```javascript
|
35
|
-
|
39
|
+
//= require lazybox
|
36
40
|
```
|
37
41
|
|
38
42
|
Usage
|
@@ -41,34 +45,34 @@ Usage
|
|
41
45
|
###Remote pages
|
42
46
|
Usual remote link:
|
43
47
|
|
44
|
-
```
|
45
|
-
|
48
|
+
```haml
|
49
|
+
- link_to 'Lazybox', new_model_path, :remote => true
|
46
50
|
```
|
47
51
|
|
48
52
|
In your controller:
|
49
53
|
|
50
54
|
```ruby
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
def new
|
56
|
+
@model = Model.new
|
57
|
+
end
|
58
|
+
|
59
|
+
def create
|
60
|
+
@model = Model.new(params[:model])
|
61
|
+
render :action => :new unless @model.save
|
62
|
+
end
|
59
63
|
```
|
60
64
|
|
61
65
|
`new.js.haml`
|
62
66
|
|
63
|
-
```
|
64
|
-
|
67
|
+
```haml
|
68
|
+
$.lazybox("#{escape_javascript(render :partial => 'form')}");
|
65
69
|
```
|
66
70
|
|
67
71
|
`create.js.haml`
|
68
72
|
|
69
|
-
```
|
70
|
-
|
71
|
-
|
73
|
+
```haml
|
74
|
+
$.lazybox.close()
|
75
|
+
window.location.reload()
|
72
76
|
```
|
73
77
|
![LazyBox](http://i.imgur.com/FEYpJ.png)
|
74
78
|
|
@@ -79,7 +83,7 @@ You can replace standard rails confirmations with lazybox
|
|
79
83
|
And in `application.js`:
|
80
84
|
|
81
85
|
```javascript
|
82
|
-
|
86
|
+
$.rails.allowAction = $.lazybox.confirm;
|
83
87
|
```
|
84
88
|
|
85
89
|
![LazyBox](http://i.imgur.com/1OQdU.png)
|
@@ -87,7 +91,7 @@ And in `application.js`:
|
|
87
91
|
for options use global lazybox settings:
|
88
92
|
|
89
93
|
```javascript
|
90
|
-
|
94
|
+
$.lazybox.settings = {cancelClass: "button gray", submitClass: 'button gray', overlay: false}
|
91
95
|
```
|
92
96
|
|
93
97
|
![LazyBox](http://i.imgur.com/2gW9R.png)
|
@@ -95,7 +99,7 @@ for options use global lazybox settings:
|
|
95
99
|
###Images
|
96
100
|
|
97
101
|
```haml
|
98
|
-
|
102
|
+
- link_to 'Image', image.url, :rel => :lazybox
|
99
103
|
```
|
100
104
|
Include in your `app/assets/javascripts/application.js`:
|
101
105
|
|
@@ -112,10 +116,37 @@ $(document).ready(function() {
|
|
112
116
|
If there are more than one link to image you can click on image in the lazybox to show the next one
|
113
117
|
|
114
118
|
```haml
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
+
= link_to image.url, :rel => :lazybox do
|
120
|
+
= image_tag image.url, :height => 100
|
121
|
+
= link_to image2.url, :rel => :lazybox do
|
122
|
+
= image_tag image2.url, :height => 100
|
123
|
+
```
|
124
|
+
|
125
|
+
Custom close image
|
126
|
+
------------------
|
127
|
+
|
128
|
+
Set 'closeImg' option to true.
|
129
|
+
|
130
|
+
`application.js`:
|
131
|
+
|
132
|
+
```javascript
|
133
|
+
$(document).ready(function() {
|
134
|
+
$('.images a').lazybox({closeImg: true});
|
135
|
+
});
|
136
|
+
```
|
137
|
+
|
138
|
+
Style your close:
|
139
|
+
|
140
|
+
`application.css`
|
141
|
+
|
142
|
+
```css
|
143
|
+
#lazybox_close.img {
|
144
|
+
background: url('close.png') no-repeat;
|
145
|
+
width: 32px;
|
146
|
+
height: 32px;
|
147
|
+
top: -17px;
|
148
|
+
right: -17px;
|
149
|
+
}
|
119
150
|
```
|
120
151
|
|
121
152
|
Options
|
@@ -125,6 +156,7 @@ Options
|
|
125
156
|
esc: true|false //default true. Close lazybox on esc press
|
126
157
|
close: true|false //default true. Show close lazybox button
|
127
158
|
niceClose: true|false //default true. Show nice close button like in fancybox(IE always shows simple close button)
|
159
|
+
closeImg: true|false //default false. Use image for close link
|
128
160
|
modal: true|false //default true. Close lazybox on overlay click
|
129
161
|
opacity: 0.6 //default 0.3. Set opacity for lazybox overlay
|
130
162
|
klass: 'class' // Set class for lazybox. <div id='lazybox' class='class'>...</div>
|
@@ -140,9 +172,6 @@ Events
|
|
140
172
|
$.lazybox.show()
|
141
173
|
$.lazybox.close()
|
142
174
|
$.lazybox.center()
|
143
|
-
$(document).trigger('close.lazybox') //Will be deprecated in next version. Use $.lazybox.close()
|
144
|
-
$(document).trigger('center.lazybox') //Will be deprecated in next version. Use $.lazybox.center()
|
145
|
-
|
146
175
|
|
147
176
|
Browser Compatibility
|
148
177
|
---------------------
|
data/lib/lazybox/version.rb
CHANGED
@@ -28,9 +28,8 @@
|
|
28
28
|
}
|
29
29
|
});
|
30
30
|
$.fn.lazybox = function(options){
|
31
|
-
var imagesRegexp = new RegExp('\\.(png|jpg|jpeg|gif)(\\?.*)?$', 'i')
|
32
31
|
this.live('click', function(e){
|
33
|
-
var a = $(this), href = a.attr('href')
|
32
|
+
var a = $(this), href = a.attr('href'), imagesRegexp = new RegExp('\\.(png|jpg|jpeg|gif)(\\?.*)?$', 'i')
|
34
33
|
e.preventDefault()
|
35
34
|
if (href.match(imagesRegexp)){
|
36
35
|
var img = new Image()
|
@@ -50,17 +49,16 @@
|
|
50
49
|
$('body:not(:has(#lazybox_overlay))').append("<div id='lazybox_overlay'></div>")
|
51
50
|
$('#lazybox_overlay').css({filter: 'alpha(opacity='+options.opacity*100+')', opacity: options.opacity}).fadeIn(500)
|
52
51
|
}
|
53
|
-
$('body:not(:has(#lazybox))').append("<div id='lazybox'><div id='lazybox_body'></div></div>")
|
54
|
-
|
52
|
+
$('body:not(:has(#lazybox))').append("<div id='lazybox'><div id='lazybox_body'></div></div>");
|
53
|
+
(options.klass) ? $('#lazybox').attr('class', options.klass) : $('#lazybox').removeClass()
|
55
54
|
if (options.close) {
|
56
|
-
$('#lazybox:not(:has(#lazybox_close))').prepend($("<a id='lazybox_close' title='close'
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
$('#lazybox:not(:has(#lazybox_close))').prepend($("<a id='lazybox_close' title='close'></a>"));
|
56
|
+
(options.closeImg) ? $('#lazybox_close').attr('class', 'img').text('') : $('#lazybox_close').removeClass().text('×')
|
57
|
+
if (!$.browser.msie && options.niceClose && !options.closeImg) $('#lazybox_close').attr('class', 'nice')
|
58
|
+
} else $('#lazybox_close').remove();
|
59
|
+
(!options.modal && options.overlay) ? $('#lazybox_overlay').bind('click', function(){ $.lazybox.close() }) : $('#lazybox_overlay').unbind()
|
60
60
|
$(document).keyup(function(e) { if (e.keyCode == 27 && options.esc) $.lazybox.close() })
|
61
61
|
$('#lazybox_close, #lazybox_body .lazy_buttons a').live('click', function(e){ $.lazybox.close(); e.preventDefault() })
|
62
62
|
}
|
63
63
|
|
64
|
-
$(document).bind('close.lazybox', function(){ $.lazybox.close(); console.warn('will be deprecated') })
|
65
|
-
$(document).bind('center.lazybox', function(){ $.lazybox.center(); console.warn('will be deprecated') })
|
66
64
|
})(jQuery);
|
@@ -38,8 +38,6 @@ a#lazybox_close {
|
|
38
38
|
width: 25px;
|
39
39
|
}
|
40
40
|
|
41
|
-
a#lazybox_close:hover { color: black; }
|
42
|
-
|
43
41
|
a#lazybox_close.nice {
|
44
42
|
background: black;
|
45
43
|
border: 2px solid white;
|
@@ -52,9 +50,9 @@ a#lazybox_close.nice {
|
|
52
50
|
-moz-box-shadow: 0 1px 5px #333;
|
53
51
|
-webkit-box-shadow: 0 1px 5px #333;
|
54
52
|
}
|
55
|
-
a#lazybox_close.nice:hover { background: white; border-color: black; color: black; }
|
56
53
|
|
54
|
+
a#lazybox_close:hover { color: black; }
|
55
|
+
a#lazybox_close.nice:hover { background: white; border-color: black; color: black; }
|
57
56
|
img.lazy_img { cursor: pointer; }
|
58
|
-
|
59
57
|
#lazybox .lazy_buttons { margin-top: 15px; text-align: right; }
|
60
58
|
#lazybox.confirm { max-width: 300px; }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazybox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Galushka
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-31 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|