aightbox-rails 0.1.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 293c0eabcda691b9ecf107083e9fcf46df090087
4
+ data.tar.gz: 00d3087134534f0ca0f3e419d1a2595c2a7e174f
5
+ SHA512:
6
+ metadata.gz: 9ca41d19ceaa7745a6c288c199b67f01563f2ab65a120d706b27e04b04d984b69217ffcdf45226fe9ef8349085a4ecde9a659f57d2aa4491b9dfde5e7ed3fb2e
7
+ data.tar.gz: 2e45fcf567971f11f527c9a376ff197db9dc8728c7e27a87bc44e9027663172f763effba41e82089d46d0830a2c0688a2ea446be34c909201c397925fc5fc9d2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in aight-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,8 @@
1
+ /*
2
+ ----------------------------------------------------------------------------
3
+ "THE BEER-WARE LICENSE" (Revision 42):
4
+ <axlwaii@gmail.com> wrote this file. As long as you retain this notice you
5
+ can do whatever you want with this stuff. If we meet some day, and you think
6
+ this stuff is worth it, you can buy me a beer in return.
7
+ ----------------------------------------------------------------------------
8
+ */
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # AIGHTbox::Rails
2
+
3
+ This is a gemified version of https://github.com/axlwaii/jquery.aightbox
4
+
5
+ ![alt tag](http://oi62.tinypic.com/2qtx16q.jpg)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'aightbox-rails', :git => 'git://github.com/axlwaii/aightbox-rails'
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ You need to edit your `app/assets/javascripts/application.js`:
18
+
19
+ ```javascript
20
+ //= require jquery
21
+ //= require aightbox
22
+ ```
23
+
24
+ And your `app/assets/stylesheets/application.css`:
25
+
26
+ ```css
27
+ /*
28
+ *= require aightbox
29
+ */
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ Basic html
35
+ ```html
36
+
37
+ <ul>
38
+ <li><a class="aight" href="big_picture_1.jpg"><img src="thumb_picture_1.jpg"/></a></li>
39
+ <li><a class="aight" href="big_picture_2.jpg"><img src="thumb_picture_1.jpg"/></a></li>
40
+ <li><a class="aight" href="big_picture_3.jpg"><img src="thumb_picture_1.jpg"/></a></li>
41
+ <li><a class="aight" href="big_picture_4.jpg"><img src="thumb_picture_1.jpg"/></a></li>
42
+ </ul>
43
+
44
+ ```
45
+
46
+ initialize with
47
+ ```javascript
48
+ $('.aight').aightbox();
49
+ ```
50
+
51
+ ## Further Documention
52
+ Go to https://github.com/axlwaii/jquery.aightbox to get more information
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork the jquery plugin ( https://github.com/axlwaii/jquery.aightbox )
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
61
+
62
+ Changes will go from there to the gem version as soon as possible.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Aightbox
2
+ module Rails
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "aightbox/rails/version"
2
+
3
+ module Aightbox
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,285 @@
1
+ (function($, window, document, undefined) {
2
+
3
+ 'use strict';
4
+
5
+ $.fn.aightbox = function(options) {
6
+
7
+ var init,
8
+ index,
9
+ setNextImage,
10
+ setNextGroupImage,
11
+ getGroupList,
12
+ firstSetup,
13
+ $imageLinks,
14
+ $imageDesc,
15
+ $backdrop,
16
+ $wrapper,
17
+ $container,
18
+ $currentImage,
19
+ bindEvents,
20
+ bindControls,
21
+ createImageContainer,
22
+ that,
23
+ config,
24
+ template,
25
+ singleImage = false;
26
+
27
+ that = this;
28
+
29
+ config = $.extend({
30
+
31
+ backdrop: 'aight-backdrop',
32
+ closeButton: 'aight-close',
33
+ carousel: false,
34
+ carouselGroup: true,
35
+ imageContainer: 'aight-container',
36
+ imageDescription: 'aight-description',
37
+ nextButton: 'aight-next',
38
+ nextCharacter: '>',
39
+ prevCharacter: '<',
40
+ prevButton: 'aight-prev',
41
+ wrapper: 'aight-wrapper'
42
+
43
+ }, options);
44
+
45
+
46
+ // @desc basic html structure of the lightbox
47
+ // id's are generated from the config data
48
+
49
+ template = '<div id="' + config.backdrop + '"></div>'+
50
+ '<div id="' + config.wrapper + '">'+
51
+ '<div id="' + config.imageContainer + '">' +
52
+ '<a id="' + config.nextButton + '" href="#">'+ config.nextCharacter +'</a>'+
53
+ '<a id="' + config.prevButton + '" href="#">' + config.prevCharacter +'</a>'+
54
+ '<a id="' + config.closeButton + '" href="#">x</a>'+
55
+ '<img src="" alt=""/>' +
56
+ '<p id="' + config.imageDescription + '"></p>'+
57
+ '</div>' +
58
+ '</div>';
59
+
60
+
61
+ // @desc finds the closest 'ul' node to the current image
62
+ // returns an array of all link elements inside this node
63
+ // returns an empty array if the current image is not in the list clostest to it
64
+
65
+ getGroupList = function() {
66
+ var list = $currentImage.closest('ul').find('a');
67
+
68
+ if(list.length > 1 && list.index($currentImage) >= 0) {
69
+ return list;
70
+ } else {
71
+ return [];
72
+ }
73
+
74
+ };
75
+
76
+ // @desc sets the next image
77
+ // @param dir - 'prev' dicreases the index anything else increases it
78
+
79
+ setNextImage = function(dir) {
80
+
81
+ if(dir === 'prev') {
82
+ index = index > 0 ? index - 1 : $imageLinks.length - 1;
83
+ } else {
84
+ index = index < $imageLinks.length-1 ? index + 1 : 0;
85
+ }
86
+
87
+ $currentImage = $($imageLinks[index]);
88
+
89
+ };
90
+
91
+ // @desc sets the next image of a group
92
+ // @param dir - 'prev' dicreases the index anything else increases it
93
+
94
+ setNextGroupImage = function(dir) {
95
+
96
+ var groupIndex,
97
+ groupList;
98
+
99
+ groupList = getGroupList();
100
+
101
+ if(groupList.length > 0) {
102
+
103
+ groupIndex = groupList.index($currentImage);
104
+
105
+ if(dir === 'prev') {
106
+ groupIndex = groupIndex > 0 ? groupIndex - 1 : groupList.length -1;
107
+ } else {
108
+ groupIndex = groupIndex < groupList.length - 1 ? groupIndex + 1 : 0;
109
+ }
110
+
111
+ $currentImage = $(groupList[groupIndex]);
112
+
113
+ }
114
+
115
+ return $currentImage;
116
+
117
+ };
118
+
119
+ // @desc sets click events for the lightbox
120
+ // get initiated after the first time a link is clicked
121
+
122
+ bindControls = function() {
123
+
124
+ if(!singleImage) {
125
+
126
+ $('#' + config.prevButton).unbind('click').click(function(e){
127
+ e.preventDefault();
128
+
129
+ if(config.carouselGroup){
130
+ setNextGroupImage('prev');
131
+ } else if (config.carousel) {
132
+ setNextImage('prev');
133
+ }
134
+
135
+ createImageContainer();
136
+ });
137
+
138
+ $('#' + config.nextButton).unbind('click').click(function(e){
139
+ e.preventDefault();
140
+
141
+ if(config.carouselGroup){
142
+ setNextGroupImage('next');
143
+ } else if (config.carousel) {
144
+ setNextImage('next');
145
+ }
146
+
147
+ createImageContainer();
148
+
149
+ });
150
+
151
+ }
152
+
153
+
154
+ $('#' + config.closeButton).on('click', function(e){
155
+
156
+ e.preventDefault();
157
+ $wrapper.fadeOut('slow');
158
+ $backdrop.hide();
159
+
160
+ });
161
+
162
+
163
+ $('#' + config.backdrop).unbind('click').click(function(e){
164
+ e.preventDefault();
165
+ $wrapper.fadeOut('slow');
166
+ $backdrop.hide();
167
+ });
168
+
169
+ };
170
+
171
+
172
+ firstSetup = function() {
173
+
174
+ $('body').append(template);
175
+
176
+ $backdrop = $('#' + config.backdrop);
177
+ $wrapper = $('#' + config.wrapper);
178
+ $container = $('#' + config.imageContainer);
179
+ $imageDesc = $('#' + config.imageDescription);
180
+
181
+ if($imageLinks.length === 1) {
182
+ $('#' + config.prevButton).hide();
183
+ $('#' + config.nextButton).hide();
184
+ singleImage = true;
185
+ }
186
+
187
+ };
188
+
189
+
190
+ bindEvents = function() {
191
+
192
+ $imageLinks.on('click', function(e){
193
+
194
+ e.preventDefault();
195
+
196
+ var list;
197
+
198
+ $currentImage = $(this);
199
+
200
+ list = getGroupList();
201
+
202
+ if(list.length > 1 ){
203
+ $('#' + config.prevButton).show();
204
+ $('#' + config.nextButton).show();
205
+ } else {
206
+ $('#' + config.prevButton).hide();
207
+ $('#' + config.nextButton).hide();
208
+ }
209
+
210
+ index = $imageLinks.index($currentImage);
211
+ createImageContainer();
212
+ });
213
+
214
+ };
215
+
216
+ createImageContainer = function() {
217
+
218
+ var $containerImage = $('#' + config.imageContainer + ' img'),
219
+ firstRun = false,
220
+ imgUrl = $currentImage.prop('href'),
221
+ imgDescription = $currentImage.find('img').prop('alt');
222
+
223
+ if($containerImage.length === 0){
224
+ firstSetup();
225
+ $('#' + config.imageContainer + ' img').prop('src', imgUrl);
226
+ $('#' + config.imageContainer + ' img').prop('alt', imgDescription);
227
+ $('#aight-description').text(imgDescription);
228
+ firstRun = true;
229
+ } else {
230
+ $containerImage.prop('src', imgUrl);
231
+ $containerImage.prop('alt', imgDescription);
232
+ $('#aight-description').text(imgDescription);
233
+ }
234
+
235
+ $containerImage = $('#' + config.imageContainer + ' img');
236
+ $container = $('#' + config.imageContainer);
237
+
238
+ if(firstRun){
239
+
240
+ bindControls();
241
+
242
+ if(getGroupList() <= 1){
243
+ $('#' + config.prevButton).hide();
244
+ $('#' + config.nextButton).hide();
245
+ }
246
+
247
+ }
248
+
249
+ $imageDesc.hide();
250
+
251
+ $containerImage.hide();
252
+ $wrapper.fadeIn('slow');
253
+ $container.append('<div class="aight-progress small"><div>Loading…</div></div>');
254
+
255
+ $containerImage.one('load',function(){
256
+
257
+ $('.aight-progress.small').remove();
258
+ $containerImage.show();
259
+
260
+ if(imgDescription !== ''){
261
+ $imageDesc.show();
262
+ }
263
+
264
+ $container.animate({
265
+ 'margin-left':-($containerImage.width()/2),
266
+ 'margin-top': -($containerImage.height()/2)
267
+ });
268
+
269
+ });
270
+
271
+ $backdrop.fadeIn(200);
272
+
273
+ };
274
+
275
+ init = function() {
276
+ $imageLinks = $(that.selector);
277
+ bindEvents();
278
+ };
279
+
280
+ init();
281
+ return that;
282
+
283
+ };
284
+
285
+ } (jQuery, window, document));
@@ -0,0 +1,160 @@
1
+ #aight-backdrop {
2
+ position: fixed;
3
+ height: 100%;
4
+ width: 100%;
5
+ top: 0;
6
+ left: 0;
7
+ z-index: 777;
8
+ display: none;
9
+ background: rgba(0, 0, 0, 0.4); }
10
+
11
+ #aight-wrapper {
12
+ position: relative;
13
+ top: 0;
14
+ left: 0;
15
+ display: none;
16
+ z-index: 999; }
17
+ #aight-wrapper * {
18
+ -webkit-backface-visibility: hidden; }
19
+
20
+ #aight-container {
21
+ background: #fff;
22
+ border: 2px solid #888;
23
+ padding: 15px;
24
+ display: block;
25
+ position: fixed;
26
+ top: 50%;
27
+ left: 50%;
28
+ -moz-box-shadow: 0 0 15px 0px #eee;
29
+ -webkit-box-shadow: 0 0 15px 0px #eee;
30
+ box-shadow: 0 0 15px 0px #eee; }
31
+ #aight-container img {
32
+ max-height: 100%;
33
+ max-width: 100%; }
34
+
35
+ #aight-description {
36
+ margin: 10px 0 0 0;
37
+ padding: 0; }
38
+
39
+ #aight-next, #aight-prev, #aight-close {
40
+ position: absolute;
41
+ font-family: 'Helvetica';
42
+ font-weight: bold;
43
+ color: #ddd;
44
+ text-decoration: none; }
45
+ #aight-next:hover, #aight-prev:hover, #aight-close:hover {
46
+ color: #fff; }
47
+
48
+ #aight-next, #aight-prev {
49
+ font-size: 35px;
50
+ margin-top: -25px; }
51
+
52
+ #aight-close {
53
+ font-size: 25px; }
54
+
55
+ #aight-next {
56
+ top: 50%;
57
+ right: 0;
58
+ margin-right: -35px; }
59
+
60
+ #aight-prev {
61
+ top: 50%;
62
+ left: 0;
63
+ margin-left: -35px; }
64
+
65
+ #aight-close {
66
+ top: 0;
67
+ right: 0;
68
+ margin-right: -25px;
69
+ margin-top: -25px; }
70
+
71
+ #aight-preload {
72
+ display: none; }
73
+
74
+ @-o-keyframes spin {
75
+ to {
76
+ transform: rotate(1turn);
77
+ -o-transform: rotate(1turn); } }
78
+
79
+ @-moz-keyframes spin {
80
+ to {
81
+ transform: rotate(1turn);
82
+ -moz-transform: rotate(1turn); } }
83
+
84
+ @-webkit-keyframes spin {
85
+ to {
86
+ transform: rotate(1turn);
87
+ -webkit-transform: rotate(1turn); } }
88
+
89
+ @keyframes spin {
90
+ to {
91
+ transform: rotate(1turn); } }
92
+
93
+ .aight-progress {
94
+ position: relative;
95
+ display: inline-block;
96
+ width: 5em;
97
+ height: 5em;
98
+ margin: 0 .5em;
99
+ font-size: 12px;
100
+ text-indent: 999em;
101
+ overflow: hidden;
102
+ animation: spin 1s infinite steps(8);
103
+ -webkit-animation: spin 1s infinite steps(8);
104
+ -moz-animation: spin 1s infinite steps(8);
105
+ -o-animation: spin 1s infinite steps(8); }
106
+
107
+ .small.aight-progress {
108
+ font-size: 6px; }
109
+
110
+ .large.aight-progress {
111
+ font-size: 24px; }
112
+
113
+ .aight-progress:before,
114
+ .aight-progress:after,
115
+ .aight-progress > div:before,
116
+ .aight-progress > div:after {
117
+ content: '';
118
+ position: absolute;
119
+ top: 0;
120
+ left: 2.25em;
121
+ /* (container width - part width)/2 */
122
+ width: .5em;
123
+ height: 1.5em;
124
+ border-radius: .2em;
125
+ background: #eee;
126
+ box-shadow: 0 3.5em #eee;
127
+ /* container height - part height */
128
+ transform-origin: 50% 2.5em;
129
+ /* container height / 2 */
130
+ -moz-transform-origin: 50% 2.5em;
131
+ /* container height / 2 */
132
+ -webkit-transform-origin: 50% 2.5em;
133
+ /* container height / 2 */
134
+ -o-transform-origin: 50% 2.5em;
135
+ /* container height / 2 */ }
136
+
137
+ .aight-progress:before {
138
+ background: #555; }
139
+
140
+ .aight-progress:after {
141
+ transform: rotate(-45deg);
142
+ -o-transform: rotate(-45deg);
143
+ -ms-transform: rotate(-45deg);
144
+ -moz-transform: rotate(-45deg);
145
+ -webkit-transform: rotate(-45deg);
146
+ background: #777; }
147
+
148
+ .aight-progress > div:before {
149
+ transform: rotate(-90deg);
150
+ -o-transform: rotate(-90deg);
151
+ -moz-transform: rotate(-90deg);
152
+ -webkit-transform: rotate(-90deg);
153
+ background: #999; }
154
+
155
+ .aight-progress > div:after {
156
+ transform: rotate(-135deg);
157
+ -o-transform: rotate(-135deg);
158
+ -moz-transform: rotate(-135deg);
159
+ -webkit-transform: rotate(-135deg);
160
+ background: #bbb; }
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aightbox-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Markus Waitl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-18 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: railties
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ description: Display single or group images.
84
+ email:
85
+ - axlwaii@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - LICENSE.txt
92
+ - README.md
93
+ - Rakefile
94
+ - lib/aightbox/rails.rb
95
+ - lib/aightbox/rails/version.rb
96
+ - vendor/assets/javascripts/aightbox.js
97
+ - vendor/assets/stylesheets/aightbox.css
98
+ homepage: ''
99
+ licenses:
100
+ - BEERWARE
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.2.1
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Another jQuery Image Gallery Plugin
122
+ test_files: []