social_stream 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Gemfile +9 -0
- data/base/app/assets/images/frontpage/right_conference.png +0 -0
- data/base/app/assets/images/loader.gif +0 -0
- data/base/app/assets/javascripts/jquery.ad-gallery.js +850 -0
- data/base/app/assets/javascripts/jquery.ad-gallery.pack.js +10 -0
- data/base/app/assets/stylesheets/_colors.scss +6 -3
- data/base/app/assets/stylesheets/ad_next.png +0 -0
- data/base/app/assets/stylesheets/ad_prev.png +0 -0
- data/base/app/assets/stylesheets/ad_scroll_back.png +0 -0
- data/base/app/assets/stylesheets/ad_scroll_forward.png +0 -0
- data/base/app/assets/stylesheets/contacts.css.scss +1 -0
- data/base/app/assets/stylesheets/frontpage.css.scss +10 -3
- data/base/app/assets/stylesheets/header.css.scss +5 -5
- data/base/app/assets/stylesheets/{home.css → home.css.scss} +12 -11
- data/base/app/assets/stylesheets/jquery.ad-gallery.css +171 -0
- data/base/app/assets/stylesheets/loader.gif +0 -0
- data/base/app/assets/stylesheets/{location.css → location.css.scss} +3 -1
- data/base/app/assets/stylesheets/menu.css.scss +19 -0
- data/base/app/assets/stylesheets/{messages.css → messages.css.scss} +17 -15
- data/base/app/assets/stylesheets/opa75.png +0 -0
- data/base/app/assets/stylesheets/{relation_customs.css → relation_customs.css.scss} +9 -27
- data/base/app/assets/stylesheets/{search.css → search.css.scss} +26 -23
- data/base/app/assets/stylesheets/{ties.css → ties.css.scss} +4 -2
- data/base/app/controllers/search_controller.rb +1 -1
- data/base/app/helpers/search_helper.rb +25 -5
- data/base/app/helpers/toolbar_helper.rb +1 -1
- data/base/app/models/post.rb +4 -4
- data/base/app/views/frontpage/_caracteristics.html.erb +7 -7
- data/base/app/views/frontpage/_header.html.erb +2 -4
- data/base/app/views/frontpage/_social_networks.html.erb +5 -0
- data/base/app/views/frontpage/index.html.erb +0 -3
- data/base/app/views/groups/_group_focus_search.html.erb +2 -0
- data/base/app/views/groups/_group_global_search.html.erb +2 -0
- data/base/app/views/groups/_show.html.erb +33 -0
- data/base/app/views/groups/_show_frontpage.html.erb +11 -0
- data/base/app/views/groups/show.html.erb +5 -32
- data/base/app/views/layouts/application.html.erb +2 -2
- data/base/app/views/posts/_post_focus_search.html.erb +3 -0
- data/base/app/views/posts/_post_global_search.html.erb +16 -0
- data/base/app/views/posts/_post_with_details.html.erb +3 -0
- data/base/app/views/search/_extended_search.html.erb +7 -2
- data/base/app/views/search/_header_search.html.erb +1 -1
- data/base/app/views/users/_show.html.erb +33 -0
- data/base/app/views/users/_show_frontpage.html.erb +11 -0
- data/base/app/views/users/_user_focus_search.html.erb +2 -0
- data/base/app/views/users/_user_global_search.html.erb +2 -0
- data/base/app/views/users/show.html.erb +5 -32
- data/base/config/locales/en.yml +5 -3
- data/base/config/locales/es.yml +2 -2
- data/base/lib/social_stream-base.rb +2 -2
- data/base/lib/social_stream/base/version.rb +1 -1
- data/documents/app/views/audios/_audio_focus_search.html.erb +3 -0
- data/documents/app/views/audios/_audio_global_search.html.erb +3 -0
- data/documents/app/views/documents/_document_focus_search.html.erb +2 -0
- data/documents/app/views/documents/_document_global_search.html.erb +2 -0
- data/documents/app/views/pictures/_picture_focus_search.html.erb +2 -0
- data/documents/app/views/pictures/_picture_global_search.html.erb +2 -0
- data/documents/app/views/videos/_video_focus_search.html.erb +2 -0
- data/documents/app/views/videos/_video_global_search.html.erb +2 -0
- data/documents/lib/social_stream-documents.rb +5 -0
- data/documents/lib/social_stream/documents/version.rb +1 -1
- data/documents/social_stream-documents.gemspec +1 -1
- data/events/app/assets/images/frontpage/thumbs/tvideo_1_happy.jpg +0 -0
- data/events/app/assets/images/frontpage/thumbs/tvideo_2_kostas.jpg +0 -0
- data/events/app/assets/images/frontpage/thumbs/tvideo_3_colin.jpg +0 -0
- data/events/app/assets/images/frontpage/thumbs/tvideo_4_romilla.jpg +0 -0
- data/events/app/assets/images/frontpage/video_1_happy.jpg +0 -0
- data/events/app/assets/images/frontpage/video_2_kostas.jpg +0 -0
- data/events/app/assets/images/frontpage/video_3_colin.jpg +0 -0
- data/events/app/assets/images/frontpage/video_4_romilla.jpg +0 -0
- data/events/app/assets/javascripts/jquery.ad-gallery.js +850 -0
- data/events/app/assets/javascripts/jquery.ad-gallery.pack.js +10 -0
- data/events/app/assets/stylesheets/ad_next.png +0 -0
- data/events/app/assets/stylesheets/ad_prev.png +0 -0
- data/events/app/assets/stylesheets/ad_scroll_back.png +0 -0
- data/events/app/assets/stylesheets/ad_scroll_forward.png +0 -0
- data/events/app/assets/stylesheets/jquery.ad-gallery.css +171 -0
- data/events/app/assets/stylesheets/loader.gif +0 -0
- data/events/app/views/events/_event_focus_search.html.erb +2 -0
- data/events/app/views/events/_event_global_search.html.erb +2 -0
- data/events/app/views/frontpage/_caracteristics.html.erb +73 -0
- data/events/app/views/frontpage/index.html.erb +72 -0
- data/events/config/locales/en.yml +14 -0
- data/events/config/locales/es.yml +103 -0
- data/events/lib/social_stream-events.rb +3 -0
- data/events/lib/social_stream/events/version.rb +1 -1
- data/events/social_stream-events.gemspec +1 -1
- data/lib/social_stream/version.rb +1 -1
- data/social_stream.gemspec +3 -3
- data/spec/dummy/config/database.yml +8 -5
- data/spec/spec_helper.rb +4 -0
- data/spec/support/components.rb +1 -1
- metadata +71 -21
- data/base/app/assets/stylesheets/menu.css +0 -26
- data/base/spec/support/thinking-sphinx.rb +0 -10
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
Binary file
|
Binary file
|
@@ -0,0 +1,850 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2010 Anders Ekdahl (http://coffeescripter.com/)
|
3
|
+
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
4
|
+
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
5
|
+
*
|
6
|
+
* Version: 1.2.4
|
7
|
+
*
|
8
|
+
* Demo and documentation: http://coffeescripter.com/code/ad-gallery/
|
9
|
+
*/
|
10
|
+
(function($) {
|
11
|
+
$.fn.adGallery = function(options) {
|
12
|
+
var defaults = { loader_image: 'loader.gif',
|
13
|
+
start_at_index: 0,
|
14
|
+
description_wrapper: false,
|
15
|
+
thumb_opacity: 0.7,
|
16
|
+
animate_first_image: false,
|
17
|
+
animation_speed: 400,
|
18
|
+
width: false,
|
19
|
+
height: false,
|
20
|
+
display_next_and_prev: true,
|
21
|
+
display_back_and_forward: true,
|
22
|
+
scroll_jump: 0, // If 0, it jumps the width of the container
|
23
|
+
slideshow: {
|
24
|
+
enable: true,
|
25
|
+
autostart: false,
|
26
|
+
speed: 5000,
|
27
|
+
start_label: 'Start',
|
28
|
+
stop_label: 'Stop',
|
29
|
+
stop_on_scroll: true,
|
30
|
+
countdown_prefix: '(',
|
31
|
+
countdown_sufix: ')',
|
32
|
+
onStart: false,
|
33
|
+
onStop: false
|
34
|
+
},
|
35
|
+
effect: 'slide-hori', // or 'slide-vert', 'fade', or 'resize', 'none'
|
36
|
+
enable_keyboard_move: true,
|
37
|
+
cycle: true,
|
38
|
+
callbacks: {
|
39
|
+
init: false,
|
40
|
+
afterImageVisible: false,
|
41
|
+
beforeImageVisible: false
|
42
|
+
}
|
43
|
+
};
|
44
|
+
var settings = $.extend(false, defaults, options);
|
45
|
+
if(options && options.slideshow) {
|
46
|
+
settings.slideshow = $.extend(false, defaults.slideshow, options.slideshow);
|
47
|
+
};
|
48
|
+
if(!settings.slideshow.enable) {
|
49
|
+
settings.slideshow.autostart = false;
|
50
|
+
};
|
51
|
+
var galleries = [];
|
52
|
+
$(this).each(function() {
|
53
|
+
var gallery = new AdGallery(this, settings);
|
54
|
+
galleries[galleries.length] = gallery;
|
55
|
+
});
|
56
|
+
// Sorry, breaking the jQuery chain because the gallery instances
|
57
|
+
// are returned so you can fiddle with them
|
58
|
+
return galleries;
|
59
|
+
};
|
60
|
+
|
61
|
+
function VerticalSlideAnimation(img_container, direction, desc) {
|
62
|
+
var current_top = parseInt(img_container.css('top'), 10);
|
63
|
+
if(direction == 'left') {
|
64
|
+
var old_image_top = '-'+ this.image_wrapper_height +'px';
|
65
|
+
img_container.css('top', this.image_wrapper_height +'px');
|
66
|
+
} else {
|
67
|
+
var old_image_top = this.image_wrapper_height +'px';
|
68
|
+
img_container.css('top', '-'+ this.image_wrapper_height +'px');
|
69
|
+
};
|
70
|
+
if(desc) {
|
71
|
+
desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
|
72
|
+
desc.animate({bottom: 0}, this.settings.animation_speed * 2);
|
73
|
+
};
|
74
|
+
if(this.current_description) {
|
75
|
+
this.current_description.animate({bottom: '-'+ this.current_description[0].offsetHeight +'px'}, this.settings.animation_speed * 2);
|
76
|
+
};
|
77
|
+
return {old_image: {top: old_image_top},
|
78
|
+
new_image: {top: current_top}};
|
79
|
+
};
|
80
|
+
|
81
|
+
function HorizontalSlideAnimation(img_container, direction, desc) {
|
82
|
+
var current_left = parseInt(img_container.css('left'), 10);
|
83
|
+
if(direction == 'left') {
|
84
|
+
var old_image_left = '-'+ this.image_wrapper_width +'px';
|
85
|
+
img_container.css('left',this.image_wrapper_width +'px');
|
86
|
+
} else {
|
87
|
+
var old_image_left = this.image_wrapper_width +'px';
|
88
|
+
img_container.css('left','-'+ this.image_wrapper_width +'px');
|
89
|
+
};
|
90
|
+
if(desc) {
|
91
|
+
desc.css('bottom', '-'+ desc[0].offsetHeight +'px');
|
92
|
+
desc.animate({bottom: 0}, this.settings.animation_speed * 2);
|
93
|
+
};
|
94
|
+
if(this.current_description) {
|
95
|
+
this.current_description.animate({bottom: '-'+ this.current_description[0].offsetHeight +'px'}, this.settings.animation_speed * 2);
|
96
|
+
};
|
97
|
+
return {old_image: {left: old_image_left},
|
98
|
+
new_image: {left: current_left}};
|
99
|
+
};
|
100
|
+
|
101
|
+
function ResizeAnimation(img_container, direction, desc) {
|
102
|
+
var image_width = img_container.width();
|
103
|
+
var image_height = img_container.height();
|
104
|
+
var current_left = parseInt(img_container.css('left'), 10);
|
105
|
+
var current_top = parseInt(img_container.css('top'), 10);
|
106
|
+
img_container.css({width: 0, height: 0, top: this.image_wrapper_height / 2, left: this.image_wrapper_width / 2});
|
107
|
+
return {old_image: {width: 0,
|
108
|
+
height: 0,
|
109
|
+
top: this.image_wrapper_height / 2,
|
110
|
+
left: this.image_wrapper_width / 2},
|
111
|
+
new_image: {width: image_width,
|
112
|
+
height: image_height,
|
113
|
+
top: current_top,
|
114
|
+
left: current_left}};
|
115
|
+
};
|
116
|
+
|
117
|
+
function FadeAnimation(img_container, direction, desc) {
|
118
|
+
img_container.css('opacity', 0);
|
119
|
+
return {old_image: {opacity: 0},
|
120
|
+
new_image: {opacity: 1}};
|
121
|
+
};
|
122
|
+
|
123
|
+
// Sort of a hack, will clean this up... eventually
|
124
|
+
function NoneAnimation(img_container, direction, desc) {
|
125
|
+
img_container.css('opacity', 0);
|
126
|
+
return {old_image: {opacity: 0},
|
127
|
+
new_image: {opacity: 1},
|
128
|
+
speed: 0};
|
129
|
+
};
|
130
|
+
|
131
|
+
function AdGallery(wrapper, settings) {
|
132
|
+
this.init(wrapper, settings);
|
133
|
+
};
|
134
|
+
AdGallery.prototype = {
|
135
|
+
// Elements
|
136
|
+
wrapper: false,
|
137
|
+
image_wrapper: false,
|
138
|
+
gallery_info: false,
|
139
|
+
nav: false,
|
140
|
+
loader: false,
|
141
|
+
preloads: false,
|
142
|
+
thumbs_wrapper: false,
|
143
|
+
scroll_back: false,
|
144
|
+
scroll_forward: false,
|
145
|
+
next_link: false,
|
146
|
+
prev_link: false,
|
147
|
+
|
148
|
+
slideshow: false,
|
149
|
+
image_wrapper_width: 0,
|
150
|
+
image_wrapper_height: 0,
|
151
|
+
current_index: 0,
|
152
|
+
current_image: false,
|
153
|
+
current_description: false,
|
154
|
+
nav_display_width: 0,
|
155
|
+
settings: false,
|
156
|
+
images: false,
|
157
|
+
in_transition: false,
|
158
|
+
animations: false,
|
159
|
+
init: function(wrapper, settings) {
|
160
|
+
var context = this;
|
161
|
+
this.wrapper = $(wrapper);
|
162
|
+
this.settings = settings;
|
163
|
+
this.setupElements();
|
164
|
+
this.setupAnimations();
|
165
|
+
if(this.settings.width) {
|
166
|
+
this.image_wrapper_width = this.settings.width;
|
167
|
+
this.image_wrapper.width(this.settings.width);
|
168
|
+
this.wrapper.width(this.settings.width);
|
169
|
+
} else {
|
170
|
+
this.image_wrapper_width = this.image_wrapper.width();
|
171
|
+
};
|
172
|
+
if(this.settings.height) {
|
173
|
+
this.image_wrapper_height = this.settings.height;
|
174
|
+
this.image_wrapper.height(this.settings.height);
|
175
|
+
} else {
|
176
|
+
this.image_wrapper_height = this.image_wrapper.height();
|
177
|
+
};
|
178
|
+
this.nav_display_width = this.nav.width();
|
179
|
+
this.current_index = 0;
|
180
|
+
this.current_image = false;
|
181
|
+
this.current_description = false;
|
182
|
+
this.in_transition = false;
|
183
|
+
this.findImages();
|
184
|
+
if(this.settings.display_next_and_prev) {
|
185
|
+
this.initNextAndPrev();
|
186
|
+
};
|
187
|
+
// The slideshow needs a callback to trigger the next image to be shown
|
188
|
+
// but we don't want to give it access to the whole gallery instance
|
189
|
+
var nextimage_callback = function(callback) {
|
190
|
+
return context.nextImage(callback);
|
191
|
+
};
|
192
|
+
this.slideshow = new AdGallerySlideshow(nextimage_callback, this.settings.slideshow);
|
193
|
+
this.controls.append(this.slideshow.create());
|
194
|
+
if(this.settings.slideshow.enable) {
|
195
|
+
this.slideshow.enable();
|
196
|
+
} else {
|
197
|
+
this.slideshow.disable();
|
198
|
+
};
|
199
|
+
if(this.settings.display_back_and_forward) {
|
200
|
+
this.initBackAndForward();
|
201
|
+
};
|
202
|
+
if(this.settings.enable_keyboard_move) {
|
203
|
+
this.initKeyEvents();
|
204
|
+
};
|
205
|
+
var start_at = parseInt(this.settings.start_at_index, 10);
|
206
|
+
if(window.location.hash && window.location.hash.indexOf('#ad-image') === 0) {
|
207
|
+
start_at = window.location.hash.replace(/[^0-9]+/g, '');
|
208
|
+
// Check if it's a number
|
209
|
+
if((start_at * 1) != start_at) {
|
210
|
+
start_at = this.settings.start_at_index;
|
211
|
+
};
|
212
|
+
};
|
213
|
+
|
214
|
+
this.loading(true);
|
215
|
+
this.showImage(start_at,
|
216
|
+
function() {
|
217
|
+
// We don't want to start the slideshow before the image has been
|
218
|
+
// displayed
|
219
|
+
if(context.settings.slideshow.autostart) {
|
220
|
+
context.preloadImage(start_at + 1);
|
221
|
+
context.slideshow.start();
|
222
|
+
};
|
223
|
+
}
|
224
|
+
);
|
225
|
+
this.fireCallback(this.settings.callbacks.init);
|
226
|
+
},
|
227
|
+
setupAnimations: function() {
|
228
|
+
this.animations = {
|
229
|
+
'slide-vert': VerticalSlideAnimation,
|
230
|
+
'slide-hori': HorizontalSlideAnimation,
|
231
|
+
'resize': ResizeAnimation,
|
232
|
+
'fade': FadeAnimation,
|
233
|
+
'none': NoneAnimation
|
234
|
+
};
|
235
|
+
},
|
236
|
+
setupElements: function() {
|
237
|
+
this.controls = this.wrapper.find('.ad-controls');
|
238
|
+
this.gallery_info = $('<p class="ad-info"></p>');
|
239
|
+
this.controls.append(this.gallery_info);
|
240
|
+
this.image_wrapper = this.wrapper.find('.ad-image-wrapper');
|
241
|
+
this.image_wrapper.empty();
|
242
|
+
this.nav = this.wrapper.find('.ad-nav');
|
243
|
+
this.thumbs_wrapper = this.nav.find('.ad-thumbs');
|
244
|
+
this.preloads = $('<div class="ad-preloads"></div>');
|
245
|
+
this.loader = $('<img class="ad-loader" src="'+ this.settings.loader_image +'">');
|
246
|
+
this.image_wrapper.append(this.loader);
|
247
|
+
this.loader.hide();
|
248
|
+
$(document.body).append(this.preloads);
|
249
|
+
},
|
250
|
+
loading: function(bool) {
|
251
|
+
if(bool) {
|
252
|
+
this.loader.show();
|
253
|
+
} else {
|
254
|
+
this.loader.hide();
|
255
|
+
};
|
256
|
+
},
|
257
|
+
addAnimation: function(name, fn) {
|
258
|
+
if($.isFunction(fn)) {
|
259
|
+
this.animations[name] = fn;
|
260
|
+
};
|
261
|
+
},
|
262
|
+
findImages: function() {
|
263
|
+
var context = this;
|
264
|
+
this.images = [];
|
265
|
+
var thumb_wrapper_width = 0;
|
266
|
+
var thumbs_loaded = 0;
|
267
|
+
var thumbs = this.thumbs_wrapper.find('a');
|
268
|
+
var thumb_count = thumbs.length;
|
269
|
+
if(this.settings.thumb_opacity < 1) {
|
270
|
+
thumbs.find('img').css('opacity', this.settings.thumb_opacity);
|
271
|
+
};
|
272
|
+
thumbs.each(
|
273
|
+
function(i) {
|
274
|
+
var link = $(this);
|
275
|
+
var image_src = link.attr('href');
|
276
|
+
var thumb = link.find('img');
|
277
|
+
// Check if the thumb has already loaded
|
278
|
+
if(!context.isImageLoaded(thumb[0])) {
|
279
|
+
thumb.load(
|
280
|
+
function() {
|
281
|
+
thumb_wrapper_width += this.parentNode.parentNode.offsetWidth;
|
282
|
+
thumbs_loaded++;
|
283
|
+
}
|
284
|
+
);
|
285
|
+
} else{
|
286
|
+
thumb_wrapper_width += thumb[0].parentNode.parentNode.offsetWidth;
|
287
|
+
thumbs_loaded++;
|
288
|
+
};
|
289
|
+
link.addClass('ad-thumb'+ i);
|
290
|
+
link.click(
|
291
|
+
function() {
|
292
|
+
context.showImage(i);
|
293
|
+
context.slideshow.stop();
|
294
|
+
return false;
|
295
|
+
}
|
296
|
+
).hover(
|
297
|
+
function() {
|
298
|
+
if(!$(this).is('.ad-active') && context.settings.thumb_opacity < 1) {
|
299
|
+
$(this).find('img').fadeTo(300, 1);
|
300
|
+
};
|
301
|
+
context.preloadImage(i);
|
302
|
+
},
|
303
|
+
function() {
|
304
|
+
if(!$(this).is('.ad-active') && context.settings.thumb_opacity < 1) {
|
305
|
+
$(this).find('img').fadeTo(300, context.settings.thumb_opacity);
|
306
|
+
};
|
307
|
+
}
|
308
|
+
);
|
309
|
+
var link = false;
|
310
|
+
if(thumb.data('ad-link')) {
|
311
|
+
link = thumb.data('ad-link');
|
312
|
+
} else if(thumb.attr('longdesc') && thumb.attr('longdesc').length) {
|
313
|
+
link = thumb.attr('longdesc');
|
314
|
+
};
|
315
|
+
var desc = false;
|
316
|
+
if(thumb.data('ad-desc')) {
|
317
|
+
desc = thumb.data('ad-desc');
|
318
|
+
} else if(thumb.attr('alt') && thumb.attr('alt').length) {
|
319
|
+
desc = thumb.attr('alt');
|
320
|
+
};
|
321
|
+
var title = false;
|
322
|
+
if(thumb.data('ad-title')) {
|
323
|
+
title = thumb.data('ad-title');
|
324
|
+
} else if(thumb.attr('title') && thumb.attr('title').length) {
|
325
|
+
title = thumb.attr('title');
|
326
|
+
};
|
327
|
+
context.images[i] = { thumb: thumb.attr('src'), image: image_src, error: false,
|
328
|
+
preloaded: false, desc: desc, title: title, size: false,
|
329
|
+
link: link };
|
330
|
+
}
|
331
|
+
);
|
332
|
+
// Wait until all thumbs are loaded, and then set the width of the ul
|
333
|
+
var inter = setInterval(
|
334
|
+
function() {
|
335
|
+
if(thumb_count == thumbs_loaded) {
|
336
|
+
thumb_wrapper_width -= 100;
|
337
|
+
var list = context.nav.find('.ad-thumb-list');
|
338
|
+
list.css('width', thumb_wrapper_width +'px');
|
339
|
+
var i = 1;
|
340
|
+
var last_height = list.height();
|
341
|
+
while(i < 201) {
|
342
|
+
list.css('width', (thumb_wrapper_width + i) +'px');
|
343
|
+
if(last_height != list.height()) {
|
344
|
+
break;
|
345
|
+
}
|
346
|
+
last_height = list.height();
|
347
|
+
i++;
|
348
|
+
}
|
349
|
+
clearInterval(inter);
|
350
|
+
};
|
351
|
+
},
|
352
|
+
100
|
353
|
+
);
|
354
|
+
},
|
355
|
+
initKeyEvents: function() {
|
356
|
+
var context = this;
|
357
|
+
$(document).keydown(
|
358
|
+
function(e) {
|
359
|
+
if(e.keyCode == 39) {
|
360
|
+
// right arrow
|
361
|
+
context.nextImage();
|
362
|
+
context.slideshow.stop();
|
363
|
+
} else if(e.keyCode == 37) {
|
364
|
+
// left arrow
|
365
|
+
context.prevImage();
|
366
|
+
context.slideshow.stop();
|
367
|
+
};
|
368
|
+
}
|
369
|
+
);
|
370
|
+
},
|
371
|
+
initNextAndPrev: function() {
|
372
|
+
this.next_link = $('<div class="ad-next"><div class="ad-next-image"></div></div>');
|
373
|
+
this.prev_link = $('<div class="ad-prev"><div class="ad-prev-image"></div></div>');
|
374
|
+
this.image_wrapper.append(this.next_link);
|
375
|
+
this.image_wrapper.append(this.prev_link);
|
376
|
+
var context = this;
|
377
|
+
this.prev_link.add(this.next_link).mouseover(
|
378
|
+
function(e) {
|
379
|
+
// IE 6 hides the wrapper div, so we have to set it's width
|
380
|
+
$(this).css('height', context.image_wrapper_height);
|
381
|
+
$(this).find('div').show();
|
382
|
+
}
|
383
|
+
).mouseout(
|
384
|
+
function(e) {
|
385
|
+
$(this).find('div').hide();
|
386
|
+
}
|
387
|
+
).click(
|
388
|
+
function() {
|
389
|
+
if($(this).is('.ad-next')) {
|
390
|
+
context.nextImage();
|
391
|
+
context.slideshow.stop();
|
392
|
+
} else {
|
393
|
+
context.prevImage();
|
394
|
+
context.slideshow.stop();
|
395
|
+
};
|
396
|
+
}
|
397
|
+
).find('div').css('opacity', 0.7);
|
398
|
+
},
|
399
|
+
initBackAndForward: function() {
|
400
|
+
var context = this;
|
401
|
+
this.scroll_forward = $('<div class="ad-forward"></div>');
|
402
|
+
this.scroll_back = $('<div class="ad-back"></div>');
|
403
|
+
this.nav.append(this.scroll_forward);
|
404
|
+
this.nav.prepend(this.scroll_back);
|
405
|
+
var has_scrolled = 0;
|
406
|
+
var thumbs_scroll_interval = false;
|
407
|
+
$(this.scroll_back).add(this.scroll_forward).click(
|
408
|
+
function() {
|
409
|
+
// We don't want to jump the whole width, since an image
|
410
|
+
// might be cut at the edge
|
411
|
+
var width = context.nav_display_width - 50;
|
412
|
+
if(context.settings.scroll_jump > 0) {
|
413
|
+
var width = context.settings.scroll_jump;
|
414
|
+
};
|
415
|
+
if($(this).is('.ad-forward')) {
|
416
|
+
var left = context.thumbs_wrapper.scrollLeft() + width;
|
417
|
+
} else {
|
418
|
+
var left = context.thumbs_wrapper.scrollLeft() - width;
|
419
|
+
};
|
420
|
+
if(context.settings.slideshow.stop_on_scroll) {
|
421
|
+
context.slideshow.stop();
|
422
|
+
};
|
423
|
+
context.thumbs_wrapper.animate({scrollLeft: left +'px'});
|
424
|
+
return false;
|
425
|
+
}
|
426
|
+
).css('opacity', 0.6).hover(
|
427
|
+
function() {
|
428
|
+
var direction = 'left';
|
429
|
+
if($(this).is('.ad-forward')) {
|
430
|
+
direction = 'right';
|
431
|
+
};
|
432
|
+
thumbs_scroll_interval = setInterval(
|
433
|
+
function() {
|
434
|
+
has_scrolled++;
|
435
|
+
// Don't want to stop the slideshow just because we scrolled a pixel or two
|
436
|
+
if(has_scrolled > 30 && context.settings.slideshow.stop_on_scroll) {
|
437
|
+
context.slideshow.stop();
|
438
|
+
};
|
439
|
+
var left = context.thumbs_wrapper.scrollLeft() + 1;
|
440
|
+
if(direction == 'left') {
|
441
|
+
left = context.thumbs_wrapper.scrollLeft() - 1;
|
442
|
+
};
|
443
|
+
context.thumbs_wrapper.scrollLeft(left);
|
444
|
+
},
|
445
|
+
10
|
446
|
+
);
|
447
|
+
$(this).css('opacity', 1);
|
448
|
+
},
|
449
|
+
function() {
|
450
|
+
has_scrolled = 0;
|
451
|
+
clearInterval(thumbs_scroll_interval);
|
452
|
+
$(this).css('opacity', 0.6);
|
453
|
+
}
|
454
|
+
);
|
455
|
+
},
|
456
|
+
_afterShow: function() {
|
457
|
+
this.gallery_info.html((this.current_index + 1) +' / '+ this.images.length);
|
458
|
+
if(!this.settings.cycle) {
|
459
|
+
// Needed for IE
|
460
|
+
this.prev_link.show().css('height', this.image_wrapper_height);
|
461
|
+
this.next_link.show().css('height', this.image_wrapper_height);
|
462
|
+
if(this.current_index == (this.images.length - 1)) {
|
463
|
+
this.next_link.hide();
|
464
|
+
};
|
465
|
+
if(this.current_index == 0) {
|
466
|
+
this.prev_link.hide();
|
467
|
+
};
|
468
|
+
};
|
469
|
+
this.fireCallback(this.settings.callbacks.afterImageVisible);
|
470
|
+
},
|
471
|
+
/**
|
472
|
+
* Checks if the image is small enough to fit inside the container
|
473
|
+
* If it's not, shrink it proportionally
|
474
|
+
*/
|
475
|
+
_getContainedImageSize: function(image_width, image_height) {
|
476
|
+
if(image_height > this.image_wrapper_height) {
|
477
|
+
var ratio = image_width / image_height;
|
478
|
+
image_height = this.image_wrapper_height;
|
479
|
+
image_width = this.image_wrapper_height * ratio;
|
480
|
+
};
|
481
|
+
if(image_width > this.image_wrapper_width) {
|
482
|
+
var ratio = image_height / image_width;
|
483
|
+
image_width = this.image_wrapper_width;
|
484
|
+
image_height = this.image_wrapper_width * ratio;
|
485
|
+
};
|
486
|
+
return {width: image_width, height: image_height};
|
487
|
+
},
|
488
|
+
/**
|
489
|
+
* If the image dimensions are smaller than the wrapper, we position
|
490
|
+
* it in the middle anyway
|
491
|
+
*/
|
492
|
+
_centerImage: function(img_container, image_width, image_height) {
|
493
|
+
img_container.css('top', '0px');
|
494
|
+
if(image_height < this.image_wrapper_height) {
|
495
|
+
var dif = this.image_wrapper_height - image_height;
|
496
|
+
img_container.css('top', (dif / 2) +'px');
|
497
|
+
};
|
498
|
+
img_container.css('left', '0px');
|
499
|
+
if(image_width < this.image_wrapper_width) {
|
500
|
+
var dif = this.image_wrapper_width - image_width;
|
501
|
+
img_container.css('left', (dif / 2) +'px');
|
502
|
+
};
|
503
|
+
},
|
504
|
+
_getDescription: function(image) {
|
505
|
+
var desc = false;
|
506
|
+
if(image.desc.length || image.title.length) {
|
507
|
+
var title = '';
|
508
|
+
if(image.title.length) {
|
509
|
+
title = '<strong class="ad-description-title">'+ image.title +'</strong>';
|
510
|
+
};
|
511
|
+
var desc = '';
|
512
|
+
if(image.desc.length) {
|
513
|
+
desc = '<span>'+ image.desc +'</span>';
|
514
|
+
};
|
515
|
+
desc = $('<p class="ad-image-description">'+ title + desc +'</p>');
|
516
|
+
};
|
517
|
+
return desc;
|
518
|
+
},
|
519
|
+
/**
|
520
|
+
* @param function callback Gets fired when the image has loaded, is displaying
|
521
|
+
* and it's animation has finished
|
522
|
+
*/
|
523
|
+
showImage: function(index, callback) {
|
524
|
+
if(this.images[index] && !this.in_transition) {
|
525
|
+
var context = this;
|
526
|
+
var image = this.images[index];
|
527
|
+
this.in_transition = true;
|
528
|
+
if(!image.preloaded) {
|
529
|
+
this.loading(true);
|
530
|
+
this.preloadImage(index, function() {
|
531
|
+
context.loading(false);
|
532
|
+
context._showWhenLoaded(index, callback);
|
533
|
+
});
|
534
|
+
} else {
|
535
|
+
this._showWhenLoaded(index, callback);
|
536
|
+
};
|
537
|
+
};
|
538
|
+
},
|
539
|
+
/**
|
540
|
+
* @param function callback Gets fired when the image has loaded, is displaying
|
541
|
+
* and it's animation has finished
|
542
|
+
*/
|
543
|
+
_showWhenLoaded: function(index, callback) {
|
544
|
+
if(this.images[index]) {
|
545
|
+
var context = this;
|
546
|
+
var image = this.images[index];
|
547
|
+
var img_container = $(document.createElement('div')).addClass('ad-image');
|
548
|
+
var img = $(new Image()).attr('src', image.image);
|
549
|
+
if(image.link) {
|
550
|
+
var link = $('<a href="'+ image.link +'" target="_blank"></a>');
|
551
|
+
link.append(img);
|
552
|
+
img_container.append(link);
|
553
|
+
} else {
|
554
|
+
img_container.append(img);
|
555
|
+
}
|
556
|
+
this.image_wrapper.prepend(img_container);
|
557
|
+
var size = this._getContainedImageSize(image.size.width, image.size.height);
|
558
|
+
img.attr('width', size.width);
|
559
|
+
img.attr('height', size.height);
|
560
|
+
img_container.css({width: size.width +'px', height: size.height +'px'});
|
561
|
+
this._centerImage(img_container, size.width, size.height);
|
562
|
+
var desc = this._getDescription(image, img_container);
|
563
|
+
if(desc) {
|
564
|
+
if(!this.settings.description_wrapper) {
|
565
|
+
img_container.append(desc);
|
566
|
+
var width = size.width - parseInt(desc.css('padding-left'), 10) - parseInt(desc.css('padding-right'), 10);
|
567
|
+
desc.css('width', width +'px');
|
568
|
+
} else {
|
569
|
+
this.settings.description_wrapper.append(desc);
|
570
|
+
}
|
571
|
+
};
|
572
|
+
this.highLightThumb(this.nav.find('.ad-thumb'+ index));
|
573
|
+
|
574
|
+
var direction = 'right';
|
575
|
+
if(this.current_index < index) {
|
576
|
+
direction = 'left';
|
577
|
+
};
|
578
|
+
this.fireCallback(this.settings.callbacks.beforeImageVisible);
|
579
|
+
if(this.current_image || this.settings.animate_first_image) {
|
580
|
+
var animation_speed = this.settings.animation_speed;
|
581
|
+
var easing = 'swing';
|
582
|
+
var animation = this.animations[this.settings.effect].call(this, img_container, direction, desc);
|
583
|
+
if(typeof animation.speed != 'undefined') {
|
584
|
+
animation_speed = animation.speed;
|
585
|
+
};
|
586
|
+
if(typeof animation.easing != 'undefined') {
|
587
|
+
easing = animation.easing;
|
588
|
+
};
|
589
|
+
if(this.current_image) {
|
590
|
+
var old_image = this.current_image;
|
591
|
+
var old_description = this.current_description;
|
592
|
+
old_image.animate(animation.old_image, animation_speed, easing,
|
593
|
+
function() {
|
594
|
+
old_image.remove();
|
595
|
+
if(old_description) old_description.remove();
|
596
|
+
}
|
597
|
+
);
|
598
|
+
};
|
599
|
+
img_container.animate(animation.new_image, animation_speed, easing,
|
600
|
+
function() {
|
601
|
+
context.current_index = index;
|
602
|
+
context.current_image = img_container;
|
603
|
+
context.current_description = desc;
|
604
|
+
context.in_transition = false;
|
605
|
+
context._afterShow();
|
606
|
+
context.fireCallback(callback);
|
607
|
+
}
|
608
|
+
);
|
609
|
+
} else {
|
610
|
+
this.current_index = index;
|
611
|
+
this.current_image = img_container;
|
612
|
+
context.current_description = desc;
|
613
|
+
this.in_transition = false;
|
614
|
+
context._afterShow();
|
615
|
+
this.fireCallback(callback);
|
616
|
+
};
|
617
|
+
};
|
618
|
+
},
|
619
|
+
nextIndex: function() {
|
620
|
+
if(this.current_index == (this.images.length - 1)) {
|
621
|
+
if(!this.settings.cycle) {
|
622
|
+
return false;
|
623
|
+
};
|
624
|
+
var next = 0;
|
625
|
+
} else {
|
626
|
+
var next = this.current_index + 1;
|
627
|
+
};
|
628
|
+
return next;
|
629
|
+
},
|
630
|
+
nextImage: function(callback) {
|
631
|
+
var next = this.nextIndex();
|
632
|
+
if(next === false) return false;
|
633
|
+
this.preloadImage(next + 1);
|
634
|
+
this.showImage(next, callback);
|
635
|
+
return true;
|
636
|
+
},
|
637
|
+
prevIndex: function() {
|
638
|
+
if(this.current_index == 0) {
|
639
|
+
if(!this.settings.cycle) {
|
640
|
+
return false;
|
641
|
+
};
|
642
|
+
var prev = this.images.length - 1;
|
643
|
+
} else {
|
644
|
+
var prev = this.current_index - 1;
|
645
|
+
};
|
646
|
+
return prev;
|
647
|
+
},
|
648
|
+
prevImage: function(callback) {
|
649
|
+
var prev = this.prevIndex();
|
650
|
+
if(prev === false) return false;
|
651
|
+
this.preloadImage(prev - 1);
|
652
|
+
this.showImage(prev, callback);
|
653
|
+
return true;
|
654
|
+
},
|
655
|
+
preloadAll: function() {
|
656
|
+
var context = this;
|
657
|
+
var i = 0;
|
658
|
+
function preloadNext() {
|
659
|
+
if(i < context.images.length) {
|
660
|
+
i++;
|
661
|
+
context.preloadImage(i, preloadNext);
|
662
|
+
};
|
663
|
+
};
|
664
|
+
context.preloadImage(i, preloadNext);
|
665
|
+
},
|
666
|
+
preloadImage: function(index, callback) {
|
667
|
+
if(this.images[index]) {
|
668
|
+
var image = this.images[index];
|
669
|
+
if(!this.images[index].preloaded) {
|
670
|
+
var img = $(new Image());
|
671
|
+
img.attr('src', image.image);
|
672
|
+
if(!this.isImageLoaded(img[0])) {
|
673
|
+
this.preloads.append(img);
|
674
|
+
var context = this;
|
675
|
+
img.load(
|
676
|
+
function() {
|
677
|
+
image.preloaded = true;
|
678
|
+
image.size = { width: this.width, height: this.height };
|
679
|
+
context.fireCallback(callback);
|
680
|
+
}
|
681
|
+
).error(
|
682
|
+
function() {
|
683
|
+
image.error = true;
|
684
|
+
image.preloaded = false;
|
685
|
+
image.size = false;
|
686
|
+
}
|
687
|
+
);
|
688
|
+
} else {
|
689
|
+
image.preloaded = true;
|
690
|
+
image.size = { width: img[0].width, height: img[0].height };
|
691
|
+
this.fireCallback(callback);
|
692
|
+
};
|
693
|
+
} else {
|
694
|
+
this.fireCallback(callback);
|
695
|
+
};
|
696
|
+
};
|
697
|
+
},
|
698
|
+
isImageLoaded: function(img) {
|
699
|
+
if(typeof img.complete != 'undefined' && !img.complete) {
|
700
|
+
return false;
|
701
|
+
};
|
702
|
+
if(typeof img.naturalWidth != 'undefined' && img.naturalWidth == 0) {
|
703
|
+
return false;
|
704
|
+
};
|
705
|
+
return true;
|
706
|
+
},
|
707
|
+
highLightThumb: function(thumb) {
|
708
|
+
this.thumbs_wrapper.find('.ad-active').removeClass('ad-active');
|
709
|
+
thumb.addClass('ad-active');
|
710
|
+
if(this.settings.thumb_opacity < 1) {
|
711
|
+
this.thumbs_wrapper.find('a:not(.ad-active) img').fadeTo(300, this.settings.thumb_opacity);
|
712
|
+
thumb.find('img').fadeTo(300, 1);
|
713
|
+
};
|
714
|
+
var left = thumb[0].parentNode.offsetLeft;
|
715
|
+
left -= (this.nav_display_width / 2) - (thumb[0].offsetWidth / 2);
|
716
|
+
this.thumbs_wrapper.animate({scrollLeft: left +'px'});
|
717
|
+
},
|
718
|
+
fireCallback: function(fn) {
|
719
|
+
if($.isFunction(fn)) {
|
720
|
+
fn.call(this);
|
721
|
+
};
|
722
|
+
}
|
723
|
+
};
|
724
|
+
|
725
|
+
function AdGallerySlideshow(nextimage_callback, settings) {
|
726
|
+
this.init(nextimage_callback, settings);
|
727
|
+
};
|
728
|
+
AdGallerySlideshow.prototype = {
|
729
|
+
start_link: false,
|
730
|
+
stop_link: false,
|
731
|
+
countdown: false,
|
732
|
+
controls: false,
|
733
|
+
|
734
|
+
settings: false,
|
735
|
+
nextimage_callback: false,
|
736
|
+
enabled: false,
|
737
|
+
running: false,
|
738
|
+
countdown_interval: false,
|
739
|
+
init: function(nextimage_callback, settings) {
|
740
|
+
var context = this;
|
741
|
+
this.nextimage_callback = nextimage_callback;
|
742
|
+
this.settings = settings;
|
743
|
+
},
|
744
|
+
create: function() {
|
745
|
+
this.start_link = $('<span class="ad-slideshow-start">'+ this.settings.start_label +'</span>');
|
746
|
+
this.stop_link = $('<span class="ad-slideshow-stop">'+ this.settings.stop_label +'</span>');
|
747
|
+
this.countdown = $('<span class="ad-slideshow-countdown"></span>');
|
748
|
+
this.controls = $('<div class="ad-slideshow-controls"></div>');
|
749
|
+
this.controls.append(this.start_link).append(this.stop_link).append(this.countdown);
|
750
|
+
this.countdown.hide();
|
751
|
+
|
752
|
+
var context = this;
|
753
|
+
this.start_link.click(
|
754
|
+
function() {
|
755
|
+
context.start();
|
756
|
+
}
|
757
|
+
);
|
758
|
+
this.stop_link.click(
|
759
|
+
function() {
|
760
|
+
context.stop();
|
761
|
+
}
|
762
|
+
);
|
763
|
+
$(document).keydown(
|
764
|
+
function(e) {
|
765
|
+
if(e.keyCode == 83) {
|
766
|
+
// 's'
|
767
|
+
if(context.running) {
|
768
|
+
context.stop();
|
769
|
+
} else {
|
770
|
+
context.start();
|
771
|
+
};
|
772
|
+
};
|
773
|
+
}
|
774
|
+
);
|
775
|
+
return this.controls;
|
776
|
+
},
|
777
|
+
disable: function() {
|
778
|
+
this.enabled = false;
|
779
|
+
this.stop();
|
780
|
+
this.controls.hide();
|
781
|
+
},
|
782
|
+
enable: function() {
|
783
|
+
this.enabled = true;
|
784
|
+
this.controls.show();
|
785
|
+
},
|
786
|
+
toggle: function() {
|
787
|
+
if(this.enabled) {
|
788
|
+
this.disable();
|
789
|
+
} else {
|
790
|
+
this.enable();
|
791
|
+
};
|
792
|
+
},
|
793
|
+
start: function() {
|
794
|
+
if(this.running || !this.enabled) return false;
|
795
|
+
var context = this;
|
796
|
+
this.running = true;
|
797
|
+
this.controls.addClass('ad-slideshow-running');
|
798
|
+
this._next();
|
799
|
+
this.fireCallback(this.settings.onStart);
|
800
|
+
return true;
|
801
|
+
},
|
802
|
+
stop: function() {
|
803
|
+
if(!this.running) return false;
|
804
|
+
this.running = false;
|
805
|
+
this.countdown.hide();
|
806
|
+
this.controls.removeClass('ad-slideshow-running');
|
807
|
+
clearInterval(this.countdown_interval);
|
808
|
+
this.fireCallback(this.settings.onStop);
|
809
|
+
return true;
|
810
|
+
},
|
811
|
+
_next: function() {
|
812
|
+
var context = this;
|
813
|
+
var pre = this.settings.countdown_prefix;
|
814
|
+
var su = this.settings.countdown_sufix;
|
815
|
+
clearInterval(context.countdown_interval);
|
816
|
+
this.countdown.show().html(pre + (this.settings.speed / 1000) + su);
|
817
|
+
var slide_timer = 0;
|
818
|
+
this.countdown_interval = setInterval(
|
819
|
+
function() {
|
820
|
+
slide_timer += 1000;
|
821
|
+
if(slide_timer >= context.settings.speed) {
|
822
|
+
var whenNextIsShown = function() {
|
823
|
+
// A check so the user hasn't stoped the slideshow during the
|
824
|
+
// animation
|
825
|
+
if(context.running) {
|
826
|
+
context._next();
|
827
|
+
};
|
828
|
+
slide_timer = 0;
|
829
|
+
};
|
830
|
+
if(!context.nextimage_callback(whenNextIsShown)) {
|
831
|
+
context.stop();
|
832
|
+
};
|
833
|
+
slide_timer = 0;
|
834
|
+
};
|
835
|
+
var sec = parseInt(context.countdown.text().replace(/[^0-9]/g, ''), 10);
|
836
|
+
sec--;
|
837
|
+
if(sec > 0) {
|
838
|
+
context.countdown.html(pre + sec + su);
|
839
|
+
};
|
840
|
+
},
|
841
|
+
1000
|
842
|
+
);
|
843
|
+
},
|
844
|
+
fireCallback: function(fn) {
|
845
|
+
if($.isFunction(fn)) {
|
846
|
+
fn.call(this);
|
847
|
+
};
|
848
|
+
}
|
849
|
+
};
|
850
|
+
})(jQuery);
|