css-lightbox 0.2.0 → 0.3.beta.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.
@@ -1,20 +1,25 @@
1
1
  Compass CSS Lightbox
2
2
  ====================
3
3
 
4
- CSS-only lightboxes that work in Everything But IE. Degrades gracefully, with
5
- no effect on IE at all, so you can set fallback styles there and/or bootstrap it
6
- with Javascript.
4
+ These lightboxes work in all modern browsers with pure CSS. Additional support
5
+ for Internet Explorer and older browsers is made possible with a small amount
6
+ of JavaScript.
7
+
7
8
 
8
9
  Installation
9
10
  ============
10
11
 
11
12
  From the command line:
12
13
 
13
- sudo gem install css-lightbox
14
+ (sudo) gem install css-lightbox
14
15
 
15
- Add to a project (rails: compass.config, other: config.rb):
16
+ Add to a project:
16
17
 
18
+ // rails: compass.config, other: config.rb
17
19
  require 'css-lightbox'
20
+
21
+ // command line
22
+ compass install css-lightbox
18
23
 
19
24
  Or create a new project:
20
25
 
@@ -24,58 +29,163 @@ Or create a new project:
24
29
  Lightboxes
25
30
  ==========
26
31
 
27
- Your HTML:
28
-
29
- <div id="content">
30
- <!-- all your normal page content, with links to lightboxes: -->
31
- <a href="#about-us">a link to the about-us lightbox</a>
32
- </div>
32
+ The basic CSS-Lightbox works with a combination of internal links, z-index,
33
+ positioning and the css3 `:target` selector. Javascript bootstrapping simply
34
+ interupts the link action, and applys active or inactive classes to the
35
+ boxes.
36
+
37
+ Each lightbox contains three important elements:
33
38
 
34
- <div id="lightboxes">
39
+ - Container
40
+ - Box
41
+ - Link to close the box (href="#")
42
+
43
+ The container gives you extra positioning options, and acts as an optional
44
+ modal overlay for the page. You can write the HTML to your liking, but here is
45
+ one example:
46
+
47
+ <aside id="about-us" class="container">
48
+ <div class="box">
35
49
 
36
- <!-- start lightbox -->
37
- <aside id="about-us">
38
- <div>
39
- <!-- Your Lightbox Content -->
40
- <a href="#" title="close the about lightbox">close</a>
41
- </div>
42
- </aside>
43
- <!-- end lightbox... repeat as needed... -->
50
+ <!-- Your Lightbox Content -->
44
51
 
45
- </div>
52
+ <a href="#" title="close the 'about' lightbox">close</a> <!-- Link to close -->
53
+ </div>
54
+ </aside>
55
+
56
+ To open your lightbox, all you need is a link from somewhere else on the page
57
+ that points at your lightbox:
46
58
 
47
- The important part is that you have:
59
+ <a href="#about-us">a link to the about-us lightbox</a>
48
60
 
49
- * elements with an ID linked from the content (the `aside` above)
50
- * an inner element in each that will act as the box itself (the `div` above)
51
- * a link to `#` from each box, to close it
61
+ For a quick, pre-styled lightbox simply apply the `lightbox-with-default-styles`
62
+ mixin to your lightbox containers.
52
63
 
53
- Your Scss:
64
+ .container {
65
+ @include lightbox-with-default-styles;
66
+ }
67
+
68
+ `lightbox-with-default-styles` takes three optional arguments, each with
69
+ defaults that you can override globaly for your project.
70
+
71
+ * The first argument is a (relative) selector for the box, and defaults
72
+ to `"> div"`.
73
+ * The second is a fade-speed using CSS transitions. This defaults to `false`
74
+ for no fade.
75
+ * The third defines the JS fallback "active" selector that you are using.
76
+ It defaults to `.active`.
77
+
78
+ Use them like so:
79
+
80
+ .container {
81
+ @include lightbox-with-default-styles('> div', '300ms', '.visible');
82
+ }
83
+
84
+
85
+ Javascript Bootstrapping
86
+ ========================
87
+
88
+ For Javascript bootstrapping in IE (using jQuery), simply link the included
89
+ lightbox.js and make any needed changes to the HTML-related variables that it
90
+ uses:
91
+
92
+ // "lightboxes" should point to the lightbox containers on your page
93
+ var lightboxes = $('#lightboxes aside');
94
+
95
+ // "closeLinks" should point at the links used to close boxes
96
+ var closeLinks = $('#lightboxes a[title*="close"]');
54
97
 
55
- // override these if you want
56
- //
57
- // // set to "true" for CSS3 transform fade-in/out
58
- // // - bug in Chrome allows you to see fade-out on-load
59
- // !lightbox-fade ||= "false"
60
- //
61
- // // set to your box element
62
- // // or false to set the box styles on your own (see below)
63
- // !lightbox-box ||= "> div"
64
-
65
- // import lightboxes
66
- @import "css-lightbox";
67
-
68
- // make it happen (assuming lightbox.html markup)
69
- #lightboxes aside {
70
- @include css-lightbox;
71
-
72
- // add styles for IE
73
- // properties: values
74
-
75
- // override box styles
76
- // &:not(:target), &:target
77
- // > div
78
- // properties: values
98
+ // "showClass" is the class to use for active lightboxes
99
+ // "hideClass" is used for inactive lightboxes
100
+ var showClass = 'active'
101
+ var hideClass = 'hidden'
102
+
103
+ The function is called simply, and the variables can be overridden on each call
104
+ as needed:
79
105
 
106
+ $(document).ready(function(){
107
+ lightboxBootstrap(lightboxes, closeLinks, showClass, hideClass);
108
+ });
109
+
110
+
111
+ Advanced Lightboxes
112
+ ===================
113
+
114
+ But why would you use my styles when you can create your own? For simple
115
+ lightboxes without any styling at all, you can use the simple `lightbox` mixin:
116
+
117
+ .container {
118
+ @include lightbox;
80
119
  }
81
-
120
+
121
+ I'll warn you, it's ugly until you add some style, but adding style isn't hard.
122
+ By default `absolute` positioning is used on the containers to place them in
123
+ the top left. You can override that by changing the positioning of your
124
+ container as you like. You'll find that each solution has advantages and
125
+ disadvantages.
126
+
127
+
128
+ Available Defaults and Mixins
129
+ =============================
130
+
131
+ Defaults:
132
+
133
+ // Set this to a selector for the inner box.
134
+ $lightbox-box-to-style: "> div";
135
+
136
+ // Set the default fade time, or leave false for no fade
137
+ $lightbox-fade: false;
138
+
139
+ // Set the active selector to be used by the JS fallback
140
+ $lightbox-active: ".active";
141
+
142
+ Mixins:
143
+
144
+ * What makes a lightbox inactive
145
+
146
+ lightbox-hidden();
147
+
148
+ * What makes a lightbox active
149
+
150
+ lightbox-active();
151
+
152
+ * Initiallizes lightbox styles, and hides them to be revealed later
153
+
154
+ lightbox-hide();
155
+
156
+ * Shows a lightbox when it should be active
157
+
158
+ lightbox-show(
159
+ $active: $lightbox-active );
160
+
161
+ * Set up your lightboxes by applying to each container
162
+
163
+ lightbox(
164
+ $active: $lightbox-active );
165
+
166
+ * Set a lightbox to fade
167
+
168
+ lightbox-fade(
169
+ $fade-speed: $lightbox-fade or 500ms );
170
+
171
+ * Apply default styles to the lightbox container
172
+
173
+ lightbox-default-container-styles(
174
+ $fade-speed: $lightbox-fade );
175
+
176
+ * Apply default styles to the box
177
+
178
+ lightbox-default-box-styles();
179
+
180
+ * Apply default styles to the container and box in one fell swoop
181
+
182
+ lightbox-default-styles(
183
+ $style : $lightbox-box-to-style,
184
+ $fade-speed : $lightbox-fade );
185
+
186
+ * Create and style a lightbox all at once
187
+
188
+ lightbox-with-default-styles(
189
+ $style : $lightbox-box-to-style,
190
+ $fade-speed : $lightbox-fade,
191
+ $active : $lightbox-active );
@@ -1,27 +1,22 @@
1
- // CSS-only Lightboxes
2
- // Plugin by Eric Meyer - http://www.oddbird.net/
3
- // Based on the work of Jenna Smith - http://growldesign.co.uk/
1
+ // CSS-Lightboxes ------------------------------------------------------------
2
+ // Plugin by Eric Meyer - http://eric.oddbird.net/
4
3
 
5
- // CSS-only lightboxes that work in Everything But IE. Degrades gracefully, with
6
- // no effect on IE at all, so you can set fallback styles there or bootstrap it
7
- // with Javascript. Probably both.
4
+ // These lightboxes work in all modern standards-complient browsers with
5
+ // pure CSS. Additional support for Internet Explorer and older browsers
6
+ // is made possible with a small amount of JavaScript.
8
7
 
9
- // Set this to "true" to turn on CSS transitions
10
- // - causes Chrome to show fade-out on-load
11
- $lightbox-fade: false !default;
12
8
 
13
- // override to set your own box styles as follows:
14
- // FOR EXAMPLE:
15
- //
16
- // #lightboxes aside
17
- // +css-lightbox
18
- //
19
- // &:not(:target), &:target
20
- // > div
21
- // /* styles for your box element
9
+ // Defaults ------------------------------------------------------------------
22
10
 
23
- //
24
- $lightbox-box: "> div" !default;
11
+ // Every lightbox includes an outer container and an inner box
12
+ // Set this to a selector for that box.
13
+ $lightbox-box-to-style : "> div" !default;
25
14
 
26
- // import lightboxes
15
+ // Set the default fade time, or leave false for no fade
16
+ $lightbox-fade : false !default;
17
+
18
+ // Set the active selector to be used by the JS fallback
19
+ $lightbox-active : ".active" !default;
20
+
21
+ // Import --------------------------------------------------------------------
27
22
  @import "css-lightbox/lightbox";
@@ -1,36 +1,106 @@
1
- // apply this to the container elements of each lightbox
2
- @mixin css-lightbox($fade: $lightbox-fade, $style: $lightbox-box) {
3
- &:not(:target), &:target {
4
- @include reset-box-model;
5
- @include reset-font;
6
- display: block;
7
- z-index: -1;
8
- position: fixed;
9
- top: 0;
10
- left: 0;
11
- width: 100%;
12
- @include transparent;
13
- @if $fade {
14
- @include transition(unquote("opacity, z-index"));
15
- }
16
- @if $style {
17
- #{$style} {
18
- margin: 3em auto;
19
- padding: 1.5em;
20
- width: 32em;
21
- border: 1em solid;
22
- background: white;
23
- text-align: left;
24
- @include box-shadow(rgba(0, 0, 0, 0.9), 0, 0, 1em);
25
- }
26
- }
27
- }
28
-
1
+ //** CSS-Lightboxes **//
2
+
3
+ // Lightbox Basics -----------------------------------------------------------
4
+
5
+ // Sets a lightbox as hidden
6
+ @mixin lightbox-hidden {
7
+ @include reset-box-model;
8
+ @include transparent;
9
+ position: absolute;
10
+ top: 0;
11
+ right: 0;
12
+ bottom: 0;
13
+ left: 0;
14
+ display: block;
15
+ z-index: -1;
16
+ }
17
+
18
+ // Sets a lightbox as active
19
+ @mixin lightbox-active {
20
+ @include opaque;
21
+ z-index: 999;
22
+ }
23
+
24
+ // Initiallizes lightbox styles, and hides them to be revealed later
25
+ @mixin lightbox-hide {
26
+ @include lightbox-hidden;
27
+ }
28
+
29
+ // Shows a lightbox when it should be active
30
+ @mixin lightbox-show(
31
+ $active: $lightbox-active
32
+ ) {
29
33
  &:target {
30
- z-index: 999;
31
- @include opaque;
32
- @if $fade {
33
- @include transition(unquote("opacity, z-index"));
34
+ @include lightbox-active;
35
+ }
36
+ @if $active {
37
+ &#{$active} {
38
+ @include lightbox-active;
34
39
  }
35
40
  }
36
41
  }
42
+
43
+ // Set up your lightboxes by applying to each container
44
+ @mixin lightbox(
45
+ $active: $lightbox-active
46
+ ) {
47
+ @include lightbox-hide;
48
+ @include lightbox-show($active);
49
+ }
50
+
51
+ // Default Lightboxing ------------------------------------------------------
52
+
53
+ // Set a lightbox to fade
54
+ @mixin lightbox-fade(
55
+ $fade-speed: $lightbox-fade
56
+ ) {
57
+ @if not $fade-speed {
58
+ $fade-speed: 500ms;
59
+ }
60
+ @include transition(unquote("opacity, z-index"), $fade-speed);
61
+ }
62
+
63
+ // Styles the lightbox container
64
+ @mixin lightbox-default-container-styles(
65
+ $fade-speed: $lightbox-fade
66
+ ) {
67
+ background: rgba(#000,.125);
68
+ @if $fade-speed {
69
+ @include lightbox-fade($fade-speed);
70
+ }
71
+ }
72
+
73
+ // Styles the lightbox box
74
+ @mixin lightbox-default-box-styles {
75
+ @include box-shadow(rgba(0, 0, 0, 0.9), 0, 0, 1em);
76
+ position: relative;
77
+ margin: 3em auto;
78
+ padding: 1.5em;
79
+ width: 32em;
80
+ border: 1em solid;
81
+ background: white;
82
+ text-align: left;
83
+ }
84
+
85
+ // Style the container and box in one fell swoop
86
+ @mixin lightbox-default-styles(
87
+ $style : $lightbox-box-to-style,
88
+ $fade-speed : $lightbox-fade
89
+ ) {
90
+ @include lightbox-default-container-styles($fade-speed);
91
+ @if $style {
92
+ #{$style} {
93
+ @include lightbox-default-box-styles;
94
+ }
95
+ }
96
+ }
97
+
98
+ // Create and style a lightbox all at once
99
+ @mixin lightbox-with-default-styles(
100
+ $style : $lightbox-box-to-style,
101
+ $fade-speed : $lightbox-fade,
102
+ $active : $lightbox-active
103
+ ) {
104
+ @include lightbox($active);
105
+ @include lightbox-default-styles($style,$fade-speed);
106
+ }
@@ -1,31 +1,12 @@
1
- // CSS LIGHTBOXES
2
- // CSS-only lightboxes that work in Everything But IE. Degrades gracefully, with
3
- // no effect on IE at all, so you can set fallback styles there or bootstrap it
4
- // with Javascript. Probably both.
1
+ //** CSS-Lightboxes **//
5
2
 
6
- // override these if you want
7
- //
8
- // // set to "true" for CSS3 transform fade-in/out
9
- // // - bug in Chrome allows you to see fade-out on-load
10
- // !lightbox-fade ||= "false"
11
- //
12
- // // set to your box element
13
- // // or false to set the box styles on your own (see below)
14
- // !lightbox-box ||= "> div"
3
+ // Import ------------------------------------------------------------------
15
4
 
16
- // import lightboxes
17
5
  @import "css-lightbox";
18
6
 
19
- // make it happen (assuming lightbox.html markup)
7
+ /* Lightboxes --------------------------------------------------------------*/
8
+
9
+ // Based on the lightbox.html template provided:
20
10
  #lightboxes aside {
21
- @include css-lightbox;
22
-
23
- // add styles for IE
24
- // properties: values
25
-
26
- // override box styles
27
- // &:not(:target), &:target
28
- // > div
29
- // properties: values
30
-
31
- }
11
+ @include lightbox-with-default-style("> div", "300ms");
12
+ }
@@ -5,14 +5,23 @@
5
5
 
6
6
  <div id="lightboxes">
7
7
 
8
- <!-- start lightbox -->
9
- <!-- You need this structure, but can use whatever tags/classes/IDs you like-->
10
- <aside id="about-us">
11
- <div>
8
+ <!-- start lightbox
9
+ You need this structure for each lightbox:
10
+
11
+ * Container
12
+ * Lightbox
13
+ * Link to close the lightbox
14
+
15
+ But you can use whatever tags/classes/IDs you like
16
+ -->
17
+
18
+ <aside id="about-us"><!-- Container -->
19
+ <div><!-- Lightbox -->
12
20
  <!-- Your Lightbox Content -->
13
- <a href="#" title="close the about lightbox">close</a>
21
+ <a href="#" title="close the 'about' lightbox">close</a><!-- Link to close -->
14
22
  </div>
15
23
  </aside>
16
- <!-- end lightbox... repeat as needed... -->
24
+
25
+ <!-- repeat as needed -->
17
26
 
18
27
  </div>
@@ -0,0 +1,45 @@
1
+ //** CSS-Lightboxes **//
2
+
3
+ // Settings ------------------------------------------------------------------
4
+ // Edit these settings to match your lightbox HTML code. These will act as
5
+ // defaults, which you can override per application as needed:
6
+
7
+ var lightboxes = $('#lightboxes aside');
8
+ var closeLinks = $('#lightboxes a[title*="close"]');
9
+ var showClass = 'active'
10
+ var hideClass = 'hidden'
11
+
12
+ // Function ------------------------------------------------------------------
13
+ // Call this function to implement lightbox bootstrapping
14
+ // on any given lightboxes:
15
+
16
+ function lightboxBootstrap(boxes, close, sClass, hClass) {
17
+
18
+ $(boxes).not('.' + sClass).addClass(hClass);
19
+
20
+ function lightboxClose(lightbox) {
21
+ $(lightbox).removeClass(sClass).addClass(hClass);
22
+ }
23
+
24
+ function lightboxOpen(lightbox) {
25
+ $(boxes).removeClass(sClass).addClass(hClass);
26
+ $(lightbox).removeClass(hClass).addClass(sClass);
27
+ }
28
+
29
+ boxes.each(function() {
30
+ $('a[href="#' + $(this).attr('id') + '"]').click(function() {
31
+ lightboxOpen($(this).attr('href'));
32
+ return false;
33
+ });
34
+ });
35
+
36
+ closeLinks.click(function() {
37
+ lightboxClose($(this).parents(boxes));
38
+ return false;
39
+ });
40
+ }
41
+
42
+ // Application ---------------------------------------------------------------
43
+ $(document).ready(function(){
44
+ lightboxBootstrap(lightboxes, closeLinks, showClass, hideClass);
45
+ });
@@ -1,16 +1,19 @@
1
1
  # Make sure you list all the project template files here in the manifest.
2
2
  stylesheet '_lightbox.scss', :media => 'screen, projection'
3
3
  html 'lightbox.html'
4
+ javascript 'lightbox.js'
4
5
 
5
- description "css-only lightboxes"
6
+ description "css-only lightboxes with optional javascript bootstrapping."
6
7
 
7
8
  help %Q{
8
- Installs some html and a stylesheet that you can use directly
9
- or refer to as an example.
9
+ Installs some html, a stylesheet partial, and javascript bootstrapping that
10
+ you can use directly or refer to as an example.
10
11
  }
11
12
 
12
13
  welcome_message %Q{
13
- Please refer to the lightbox.html file to see how the markup should be structured.
14
- And to the lightbox stylesheet partial to see how to use the library and apply it to your markup.
14
+ Please refer to the lightbox.html file to see how the markup should be
15
+ structured, the lightbox stylesheet partial to see how to use the library and
16
+ apply it to your markup, and the lightbox.js script to see how
17
+ bootstrapping works.
15
18
  }
16
19
 
metadata CHANGED
@@ -1,12 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css-lightbox
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 62196299
5
+ prerelease: 4
5
6
  segments:
6
7
  - 0
7
- - 2
8
+ - 3
9
+ - beta
8
10
  - 0
9
- version: 0.2.0
11
+ version: 0.3.beta.0
10
12
  platform: ruby
11
13
  authors:
12
14
  - Eric Meyer
@@ -14,22 +16,24 @@ autorequire:
14
16
  bindir: bin
15
17
  cert_chain: []
16
18
 
17
- date: 2010-04-20 00:00:00 -06:00
19
+ date: 2011-03-18 00:00:00 -06:00
18
20
  default_executable:
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: compass
22
24
  prerelease: false
23
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
30
+ hash: 62196237
27
31
  segments:
28
32
  - 0
29
- - 10
30
- - 0
31
- - rc3
32
- version: 0.10.0.rc3
33
+ - 11
34
+ - beta
35
+ - 3
36
+ version: 0.11.beta.3
33
37
  type: :runtime
34
38
  version_requirements: *id001
35
39
  description: a css-only lightbox implementation for compass
@@ -42,11 +46,11 @@ extra_rdoc_files: []
42
46
 
43
47
  files:
44
48
  - README.mkdn
45
- - lib/css-lightbox.rb
46
49
  - stylesheets/_css-lightbox.scss
47
50
  - stylesheets/css-lightbox/_lightbox.scss
48
51
  - templates/project/_lightbox.scss
49
52
  - templates/project/lightbox.html
53
+ - templates/project/lightbox.js
50
54
  - templates/project/manifest.rb
51
55
  has_rdoc: true
52
56
  homepage: http://www.oddbird.net/
@@ -58,23 +62,29 @@ rdoc_options: []
58
62
  require_paths:
59
63
  - lib
60
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
61
66
  requirements:
62
67
  - - ">="
63
68
  - !ruby/object:Gem::Version
69
+ hash: 3
64
70
  segments:
65
71
  - 0
66
72
  version: "0"
67
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
68
75
  requirements:
69
- - - ">="
76
+ - - ">"
70
77
  - !ruby/object:Gem::Version
78
+ hash: 25
71
79
  segments:
72
- - 0
73
- version: "0"
80
+ - 1
81
+ - 3
82
+ - 1
83
+ version: 1.3.1
74
84
  requirements: []
75
85
 
76
86
  rubyforge_project:
77
- rubygems_version: 1.3.6
87
+ rubygems_version: 1.5.2
78
88
  signing_key:
79
89
  specification_version: 3
80
90
  summary: a css-only lightbox implementation for compass
@@ -1 +0,0 @@
1
- Compass::Frameworks.register("css-lightbox", :path => "#{File.dirname(__FILE__)}/..")