lazybox 0.1.8 → 0.2.0

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.
data/README.md CHANGED
@@ -65,7 +65,7 @@ end
65
65
  `new.js.haml`
66
66
 
67
67
  ```haml
68
- $.lazybox("#{escape_javascript(render :partial => 'form')}");
68
+ $.lazybox("#{j(render :partial => 'form')}");
69
69
  ```
70
70
 
71
71
  `create.js.haml`
@@ -93,9 +93,14 @@ for options use global lazybox settings:
93
93
  ```javascript
94
94
  $.lazybox.settings = {cancelClass: "button gray", submitClass: 'button gray', overlay: false}
95
95
  ```
96
-
97
96
  ![LazyBox](http://i.imgur.com/2gW9R.png)
98
97
 
98
+ or instance settings
99
+
100
+ ```javascript
101
+ $.lazybox("<div>It works!</div>",{onTop: true, opacity: 0.7, modal: false})
102
+ ```
103
+
99
104
  ###Images
100
105
 
101
106
  ```haml
@@ -160,6 +165,7 @@ Options
160
165
  closeImg: true|false //default false. Use image for close link
161
166
  onTop: true|false //default false. Show lazybox on top instead of on center. It will use slide animation instead of fade.
162
167
  opacity: 0.6 //default 0.3. Set opacity for lazybox overlay
168
+ speed: 400 //default 300. Set animation speed
163
169
  klass: 'class' // Set class for lazybox. <div id='lazybox' class='class'>...</div>
164
170
  //confirmation options
165
171
  cancelText: //default 'Cancel'. Cancel button text
@@ -1,3 +1,3 @@
1
1
  module Lazybox
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,19 +1,21 @@
1
1
  (function($){
2
- var defaults = {overlay: true, esc: true, close: true, niceClose: true, modal: true, opacity: 0.3, onTop: false, cancelText: 'Cancel', cancelClass: 'button', submitText: 'Ok', submitClass: 'button'}, effect, y
2
+ var defaults = {overlay: true, esc: true, close: true, niceClose: true, modal: true, opacity: 0.3, onTop: false, cancelText: 'Cancel', cancelClass: 'button', submitText: 'Ok', submitClass: 'button', speed: 300}, effect, y
3
3
  $.lazybox = function(html, options){ $.lazybox.show(html, options) }
4
4
  $.extend($.lazybox, {
5
5
  settings: $.extend({}, defaults),
6
6
  show: function(content, options){
7
- var onTop = init(options).onTop
7
+ var options = init(options)
8
8
  $('#lazybox_body').html(content)
9
- $.lazybox.center(onTop);
10
- (onTop) ? effect = 'slideDown' : effect = 'fadeIn'
11
- $('#lazybox')[effect](300)
9
+ $.lazybox.center(options.onTop);
10
+ (options.onTop) ? effect = 'slideDown' : effect = 'fadeIn'
11
+ $('#lazybox')[effect](options.speed)
12
+ return options
12
13
  },
13
- close: function(){
14
+ close: function(speed){
15
+ speed = speed || defaults.speed;
14
16
  ($('#lazybox').position().top == 0) ? effect = 'slideUp' : effect = 'fadeOut'
15
- $('#lazybox')[effect](300)
16
- $('#lazybox_overlay').fadeOut(500)
17
+ $('#lazybox')[effect](speed)
18
+ $('#lazybox_overlay').fadeOut(speed+200)
17
19
  },
18
20
  center: function(onTop){
19
21
  (onTop) ? y = 0 : y = (($(window).height()-$('#lazybox').outerHeight())/2)+$(window).scrollTop()
@@ -36,12 +38,12 @@
36
38
  if (href.match(imagesRegexp)){
37
39
  var img = new Image(), nextLink
38
40
  img.onload = function(element){
39
- $.lazybox.show(img, options);
41
+ options = $.lazybox.show(img, options);
40
42
  (a.is(':last-child')) ? nextLink = a.siblings('a[rel*=lazybox]:first') : nextLink = a.next('a[rel*=lazybox]:first')
41
- if (!nextLink.length == 0) $('#lazybox img').bind('click', function(){ $('#lazybox').fadeOut(function(){ nextLink.click() }) })
43
+ if (!nextLink.length == 0) $('#lazybox img').bind('click', function(){ $('#lazybox').fadeOut(options.speed, function(){ nextLink.click() }) })
42
44
  }
43
45
  $(img).attr({'class': 'lazy_img', src: href})
44
- } else $.ajax({url: href, success: function(data){ $.lazybox.show(data, options) }, error: function(){ $.lazybox.close() }})
46
+ } else $.ajax({url: href, success: function(data){ $.lazybox.show(data, options) }, error: function(){ $.lazybox.close(300) }})
45
47
  });
46
48
  }
47
49
 
@@ -49,7 +51,7 @@
49
51
  var options = $.extend($.extend({}, defaults), $.lazybox.settings, options)
50
52
  if (options.overlay) {
51
53
  $('body:not(:has(#lazybox_overlay))').append("<div id='lazybox_overlay'></div>")
52
- $('#lazybox_overlay').css({filter: 'alpha(opacity='+options.opacity*100+')', opacity: options.opacity}).fadeIn(500)
54
+ $('#lazybox_overlay').css({filter: 'alpha(opacity='+options.opacity*100+')', opacity: options.opacity}).fadeIn(options.speed+200)
53
55
  }
54
56
  $('body:not(:has(#lazybox))').append("<div id='lazybox'><div id='lazybox_body'></div></div>");
55
57
  (options.klass) ? $('#lazybox').attr('class', options.klass) : $('#lazybox').removeClass()
@@ -58,9 +60,9 @@
58
60
  (options.closeImg) ? $('#lazybox_close').attr('class', 'img').text('') : $('#lazybox_close').removeClass().text('×')
59
61
  if (!$.browser.msie && options.niceClose && !options.closeImg && !options.onTop) $('#lazybox_close').attr('class', 'nice')
60
62
  } else $('#lazybox_close').remove();
61
- (!options.modal && options.overlay) ? $('#lazybox_overlay').bind('click', function(){ $.lazybox.close() }) : $('#lazybox_overlay').unbind()
62
- $(document).keyup(function(e) { if (e.keyCode == 27 && options.esc) $.lazybox.close() })
63
- $('#lazybox_close, #lazybox_body .lazy_buttons a').live('click', function(e){ $.lazybox.close(); e.preventDefault() })
63
+ (!options.modal && options.overlay) ? $('#lazybox_overlay').bind('click', function(){ $.lazybox.close(options.speed) }) : $('#lazybox_overlay').unbind()
64
+ $(document).keyup(function(e) { if (e.keyCode == 27 && options.esc) $.lazybox.close(options.speed) })
65
+ $('#lazybox_close, #lazybox_body .lazy_buttons a').live('click', function(e){ $.lazybox.close(options.speed); e.preventDefault() })
64
66
  return options
65
67
  }
66
68
 
@@ -6,7 +6,7 @@
6
6
  position: fixed;
7
7
  right: 0px;
8
8
  top: 0px;
9
- z-index: 100;
9
+ z-index: 1000;
10
10
  }
11
11
 
12
12
  #lazybox {
@@ -19,7 +19,7 @@
19
19
  padding: 20px;
20
20
  position: absolute;
21
21
  top: 49%;
22
- z-index: 101;
22
+ z-index: 1001;
23
23
  -moz-box-shadow: 0 1px 5px #333;
24
24
  -webkit-box-shadow: 0 1px 5px #333;
25
25
  }
@@ -52,7 +52,7 @@ a#lazybox_close.nice {
52
52
  }
53
53
 
54
54
  a#lazybox_close:hover { color: black; }
55
- a#lazybox_close.nice:hover { background: white; border-color: black; color: black; }
55
+ a#lazybox_close.nice:hover { background: white; border-color: black; }
56
56
  img.lazy_img { cursor: pointer; }
57
57
  #lazybox .lazy_buttons { margin-top: 15px; text-align: right; }
58
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: 11
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
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-04-04 00:00:00 Z
18
+ date: 2012-04-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails