social_stream 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/base/app/assets/javascripts/contacts.js +0 -6
  2. data/base/app/assets/javascripts/relation_customs.js +28 -81
  3. data/base/app/assets/javascripts/settings.js +12 -33
  4. data/base/app/assets/stylesheets/base.css.scss +2 -1
  5. data/base/app/assets/stylesheets/relation_customs.css.scss +8 -2
  6. data/base/app/controllers/contacts_controller.rb +7 -3
  7. data/base/app/controllers/messages_controller.rb +1 -1
  8. data/base/app/controllers/search_controller.rb +22 -6
  9. data/base/app/controllers/settings_controller.rb +1 -1
  10. data/base/app/models/contact.rb +7 -1
  11. data/base/app/models/relation.rb +14 -1
  12. data/base/app/views/activities/_new.html.erb +3 -2
  13. data/base/app/views/contacts/_link.html.erb +1 -1
  14. data/base/app/views/contacts/index.html.erb +1 -1
  15. data/base/app/views/conversations/_conversation.html.erb +3 -3
  16. data/base/app/views/conversations/_conversation_full.html.erb +3 -3
  17. data/base/app/views/devise/registrations/_delete_account.html.erb +20 -0
  18. data/base/app/views/devise/registrations/_edit_user.html.erb +87 -0
  19. data/base/app/views/devise/registrations/edit.html.erb +16 -93
  20. data/base/app/views/layouts/_header_dropdown_menu.html.erb +0 -3
  21. data/base/app/views/messages/_form.html.erb +1 -1
  22. data/base/app/views/permissions/_index.html.erb +2 -2
  23. data/base/app/views/permissions/index.js.erb +7 -2
  24. data/base/app/views/relation/customs/_list.html.erb +12 -5
  25. data/base/app/views/relation/customs/create.js.erb +4 -2
  26. data/base/app/views/relation/customs/index.html.erb +0 -5
  27. data/base/app/views/search/_form.html.erb +1 -1
  28. data/base/app/views/settings/_api_key.html.erb +3 -3
  29. data/base/app/views/settings/_index.html.erb +6 -1
  30. data/base/app/views/settings/_notifications.html.erb +3 -3
  31. data/base/app/views/settings/index.html.erb +4 -1
  32. data/base/config/locales/en.yml +31 -12
  33. data/base/config/locales/es.yml +33 -10
  34. data/base/config/routes.rb +10 -11
  35. data/base/lib/mailboxer/notification_decoder.rb +13 -4
  36. data/base/lib/social_stream/base/version.rb +1 -1
  37. data/documents/app/assets/javascripts/social_stream-documents.js +1 -1
  38. data/documents/app/views/pictures/_picture.html.erb +3 -1
  39. data/documents/lib/social_stream/documents/version.rb +1 -1
  40. data/documents/social_stream-documents.gemspec +1 -1
  41. data/documents/vendor/assets/javascripts/jquery.lightbox-with-resize-plugin.js +533 -0
  42. data/events/vendor/assets/stylesheets/jquery.ad-gallery.css +1 -1
  43. data/lib/social_stream/version.rb +1 -1
  44. data/presence/app/assets/stylesheets/chat.css +9 -1
  45. data/presence/app/controllers/xmpp_controller.rb +19 -10
  46. data/presence/app/helpers/xmpp_helper.rb +10 -23
  47. data/presence/app/views/xmpp/_chat.html.erb +9 -7
  48. data/presence/app/views/xmpp/_chat_off.html.erb +1 -1
  49. data/presence/lib/social_stream-presence.rb +12 -0
  50. data/presence/lib/social_stream/presence/config.rb +0 -4
  51. data/presence/lib/social_stream/presence/engine.rb +27 -14
  52. data/presence/lib/social_stream/presence/models/buddy_manager.rb +20 -12
  53. data/social_stream.gemspec +2 -2
  54. metadata +13 -14
  55. data/base/app/assets/images/title_background.png +0 -0
  56. data/base/vendor/assets/javascripts/ui.checkbox.js +0 -309
  57. data/documents/vendor/assets/javascripts/jquery.lightbox.min.js +0 -42
  58. data/presence/app/assets/images/arrow.png +0 -0
@@ -19,6 +19,8 @@ es:
19
19
  attributes:
20
20
  contact:
21
21
  relation_ids: "El tipo de contacto"
22
+ relation/custom:
23
+ name: "Nombre"
22
24
  user:
23
25
  email: "Correo"
24
26
  name: "Nombre"
@@ -43,9 +45,14 @@ es:
43
45
  one: "Actividad"
44
46
  other: "Actividades"
45
47
  privacy:
46
- contacts:
47
- user: "Contactos de %{receiver}"
48
- group: "Integrantes de %{receiver}"
48
+ myself:
49
+ contacts:
50
+ group: "Todos los integrantes"
51
+ user: "Tus contacts"
52
+ outside:
53
+ contacts:
54
+ group: "Integrantes de %{receiver}"
55
+ user: "Contactos de %{receiver}"
49
56
  sending: "Enviando"
50
57
  title: "Actividades"
51
58
  to_comment: "Comentar"
@@ -195,7 +202,7 @@ es:
195
202
  submit:
196
203
  relation_custom:
197
204
  create: "Guardar"
198
- update: "Actualizar"
205
+ update: "Guardar"
199
206
  home: "Inicio"
200
207
  inbox:
201
208
  one: "Entrada"
@@ -219,15 +226,21 @@ es:
219
226
  base: "Estás aquí"
220
227
  separator: " > "
221
228
  mailboxer:
229
+ delete: "Borrar"
230
+ delete_confirm: "¿Quieres enviar '%{object}' a la papelera?"
222
231
  form:
223
232
  body: "Mensaje"
224
233
  recipients: "Para"
225
234
  subject: "Asunto"
235
+ mark_as_read: "Marcar como leido"
226
236
  message_mailer:
227
237
  subject_new: "%{subject}"
228
238
  subject_reply: "%{subject}"
229
239
  notification_mailer:
230
- subject: "%{subject}"
240
+ subject: "%{subject}"
241
+ reply: "Contestar"
242
+ send: "Enviar mensaje"
243
+ sent: "Tu mensaje fue enviado"
231
244
  menu:
232
245
  options: "Opciones"
233
246
  information: "Información"
@@ -371,11 +384,6 @@ es:
371
384
  write: "Escribe tu búsqueda..."
372
385
  wrong: "Parece que hay un problema con el motor de búsqueda"
373
386
  settings:
374
- error: "Hubo errores al guardar los cambios"
375
- for: "Ajustes para"
376
- main: "Ajustes principales"
377
- one: "Ajustes"
378
- success: "Ajustes guardados con éxito"
379
387
  api_key:
380
388
  briefing: "Gestiona tu clave API"
381
389
  confirm: "¿Estás seguro?"
@@ -383,6 +391,17 @@ es:
383
391
  explanation: "Ésta es tu clave API"
384
392
  name: "Clave API"
385
393
  regenerate: "Regenerar clave API"
394
+ cancel_account:
395
+ briefing: "Te permite cancelar tu cuenta"
396
+ email_change:
397
+ briefing: "Cambia tu email"
398
+ error: "Hubo errores al guardar los cambios"
399
+ for: "Ajustes para"
400
+ main: "Ajustes"
401
+ manage:
402
+ name: "Administrar contactos"
403
+ briefing: "Ajustes de contactos"
404
+ explanation: "Cambiar los permisos de contactos"
386
405
  notifications:
387
406
  briefing: "Ajustes sobre notificaciones y alertas por correo"
388
407
  name: "Notificaciones"
@@ -390,6 +409,10 @@ es:
390
409
  name: "Mandarme un correo cuando me llega una notificación"
391
410
  always: "Siempre"
392
411
  never: "Nunca"
412
+ one: "Ajustes"
413
+ password_change:
414
+ briefing: "Cambia tu contraseña"
415
+ success: "Ajustes guardados con éxito"
393
416
  share: "Compartir"
394
417
  sign_in: "Entrar"
395
418
  sign_out: "Salir"
@@ -14,17 +14,6 @@ Rails.application.routes.draw do
14
14
  match 'home' => 'home#index', :as => :home
15
15
  match 'home' => 'home#index', :as => :user_root # devise after_sign_in_path_for
16
16
 
17
- ##API###
18
- match 'api/keygen' => 'api#create_key', :as => :api_keygen
19
- match 'api/user/:id' => 'api#users'
20
- match 'api/me' => 'api#users'
21
- match 'api/me/home/' => 'api#activity_atom_feed', :format => 'atom', :as => :api_my_home
22
- match 'api/me/contacts' => 'contacts#index', :format => 'json'
23
- match 'api/subjects/:s/contacts' => 'contacts#index', :format => 'json'
24
- match 'api/user/:id/public' => 'api#activity_atom_feed', :format => 'atom'
25
- match 'api/user/:id/public' => 'api#activity_atom_feed', :format => 'atom'
26
- ##/API##
27
-
28
17
  # Webfinger
29
18
  match '.well-known/host-meta',:to => 'frontpage#host_meta'
30
19
 
@@ -87,4 +76,14 @@ Rails.application.routes.draw do
87
76
  (SocialStream.objects - [ :actor ]).each do |object|
88
77
  resources object.to_s.pluralize
89
78
  end
79
+
80
+ ##API###
81
+ match 'api/keygen' => 'api#create_key', :as => :api_keygen
82
+ match 'api/user/:id' => 'api#users', :as => :api_user
83
+ match 'api/me' => 'api#users', :as => :api_me
84
+ match 'api/me/home/' => 'api#activity_atom_feed', :format => 'atom', :as => :api_my_home
85
+ match 'api/me/contacts' => 'contacts#index', :format => 'json', :as => :api_contacts
86
+ match 'api/subjects/:s/contacts' => 'contacts#index', :format => 'json', :as => :api_subject_contacts
87
+ match 'api/user/:id/public' => 'api#activity_atom_feed', :format => 'atom', :as => :api_user_activities
88
+ ##/API##
90
89
  end
@@ -20,7 +20,7 @@ module Mailboxer
20
20
  :receiver => truncate_name(activity.receiver.name)))
21
21
  notification_text = notification_text.gsub(/\%\{who\}/,truncate_name(activity.receiver.name))
22
22
  end
23
-
23
+
24
24
  if activity.direct_object.present?
25
25
  object = activity.direct_object
26
26
  object = object.subject if object.is_a? Actor
@@ -28,10 +28,19 @@ module Mailboxer
28
28
  url_for(:controller=> object.class.to_s.underscore.pluralize, :action=> :show,
29
29
  :id=> object.id, :only_path => false)))
30
30
  notification_text=notification_text.gsub(/\%\{object.name\}/,object.class.to_s.underscore)
31
- notification_text=notification_text.gsub(/\%\{object.text\}/,link_to(object.text.truncate(100, :separator =>' '),
31
+
32
+
33
+
34
+ if object.respond_to? :text
35
+ notification_text=notification_text.gsub(/\%\{object.text\}/,link_to(object.text.truncate(100, :separator =>' '),
32
36
  url_for(:controller=> object.class.to_s.underscore.pluralize, :action=> :show,
33
- :id=> object.id, :only_path => false))) if object.respond_to? :text
34
-
37
+ :id=> object.id, :only_path => false)))
38
+ elsif SocialStream.objects.include? :document and object.is_a? Document
39
+ notification_text=notification_text.gsub(/\%\{object.text\}/,link_to(object.file_file_name.truncate(100, :separator =>' '),
40
+ url_for(:controller=> object.class.to_s.underscore.pluralize, :action=> :show,
41
+ :id=> object.id, :only_path => false)))
42
+
43
+ end
35
44
  #notification_text=notification_text.gsub(/\%\{object.image\}/,thumb_for(object)) if SocialStream.activity_forms.include? :document and object.is_a? Document
36
45
 
37
46
  else
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.9.19".freeze
3
+ VERSION = "0.9.20".freeze
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  //= require jquery.jplayer
2
2
  //= require_tree .
3
- //= require jquery.lightbox.min
3
+ //= require jquery.lightbox-with-resize-plugin
@@ -30,10 +30,12 @@
30
30
  <%= javascript_tag do %>
31
31
  $(document).ready(function() {
32
32
  $('.picture_thumbnail_show a').lightBox({
33
+ maxHeight: 920,
34
+ maxWidth: 920,
33
35
  imageLoading: 'assets/lightbox-ico-loading.gif',
34
36
  imageBtnClose: 'assets/lightbox-btn-close.gif',
35
37
  imageBtnPrev: 'assets/lightbox-btn-prev.gif',
36
38
  imageBtnNext: 'assets/lightbox-btn-next.gif',
37
- imageBlank: 'assets/lightbox-blank.gif'});
39
+ imageBlank: 'assets/lightbox-blank.gif'});
38
40
  })
39
41
  <% end %>
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.3.1".freeze
3
+ VERSION = "0.3.2".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.9.16')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.20')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','2.3.11')
18
18
  s.add_runtime_dependency('delayed_paperclip','>= 0.7.2')
@@ -0,0 +1,533 @@
1
+ /**
2
+ * jQuery lightBox plugin
3
+ * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
4
+ * and adapted to me for use like a plugin from jQuery.
5
+ * @name jquery-lightbox-0.5.js
6
+ * @author Leandro Vieira Pinho - http://leandrovieira.com
7
+ * @version 0.5
8
+ * @date April 11, 2008
9
+ * @category jQuery plugin
10
+ * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
11
+ * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
12
+ * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
13
+ */
14
+
15
+ // Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
16
+ (function($) {
17
+ /**
18
+ * $ is an alias to jQuery object
19
+ *
20
+ */
21
+ $.fn.lightBox = function(settings) {
22
+ // Settings to configure the jQuery lightBox plugin how you like
23
+ settings = jQuery.extend({
24
+ maxWidth : null,
25
+ maxHeight : null,
26
+ // Configuration related to overlay
27
+ overlayBgColor : '#000', // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
28
+ overlayOpacity : 0.8, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
29
+ // Configuration related to navigation
30
+ fixedNavigation : false, // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
31
+ // Configuration related to images
32
+ imageLoading : 'images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
33
+ imageBtnPrev : 'images/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
34
+ imageBtnNext : 'images/lightbox-btn-next.gif', // (string) Path and the name of the next button image
35
+ imageBtnClose : 'images/lightbox-btn-close.gif', // (string) Path and the name of the close btn
36
+ imageBlank : 'images/lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel)
37
+ // Configuration related to container image box
38
+ containerBorderSize : 10, // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
39
+ containerResizeSpeed : 400, // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
40
+ // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
41
+ txtImage : 'Image', // (string) Specify text "Image"
42
+ txtOf : 'of', // (string) Specify text "of"
43
+ // Configuration related to keyboard navigation
44
+ keyToClose : 'c', // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
45
+ keyToPrev : 'p', // (string) (p = previous) Letter to show the previous image
46
+ keyToNext : 'n', // (string) (n = next) Letter to show the next image.
47
+ // Don�t alter these variables in any way
48
+ imageArray : [],
49
+ activeImage : 0
50
+ }, settings);
51
+ // Caching the jQuery object with all elements matched
52
+ var jQueryMatchedObj = this;
53
+ // This, in this context, refer to jQuery object
54
+ /**
55
+ * Initializing the plugin calling the start function
56
+ *
57
+ * @return boolean false
58
+ */
59
+ function _initialize() {
60
+ _start(this, jQueryMatchedObj);
61
+ // This, in this context, refer to object (link) which the user have clicked
62
+ return false;
63
+ // Avoid the browser following the link
64
+ }
65
+
66
+ /**
67
+ * Start the jQuery lightBox plugin
68
+ *
69
+ * @param object objClicked The object (link) whick the user have clicked
70
+ * @param object jQueryMatchedObj The jQuery object with all elements matched
71
+ */
72
+ function _start(objClicked, jQueryMatchedObj) {
73
+ // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
74
+ $('embed, object, select').css({
75
+ 'visibility' : 'hidden'
76
+ });
77
+ // Call the function to create the markup structure; style some elements; assign events in some elements.
78
+ _set_interface();
79
+ // Unset total images in imageArray
80
+ settings.imageArray.length = 0;
81
+ // Unset image active information
82
+ settings.activeImage = 0;
83
+ // We have an image set? Or just an image? Let�s see it.
84
+ if(jQueryMatchedObj.length == 1) {
85
+ settings.imageArray.push(new Array(objClicked.getAttribute('href'), objClicked.getAttribute('title')));
86
+ } else {
87
+ // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
88
+ for(var i = 0; i < jQueryMatchedObj.length; i++) {
89
+ settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'), jQueryMatchedObj[i].getAttribute('title')));
90
+ }
91
+ }
92
+ while(settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href')) {
93
+ settings.activeImage++;
94
+ }
95
+ // Call the function that prepares image exibition
96
+ _set_image_to_view();
97
+ }
98
+
99
+ /**
100
+ * Create the jQuery lightBox plugin interface
101
+ *
102
+ * The HTML markup will be like that:
103
+ <div id="jquery-overlay"></div>
104
+ <div id="jquery-lightbox">
105
+ <div id="lightbox-container-image-box">
106
+ <div id="lightbox-container-image">
107
+ <img src="../fotos/XX.jpg" id="lightbox-image">
108
+ <div id="lightbox-nav">
109
+ <a href="#" id="lightbox-nav-btnPrev"></a>
110
+ <a href="#" id="lightbox-nav-btnNext"></a>
111
+ </div>
112
+ <div id="lightbox-loading">
113
+ <a href="#" id="lightbox-loading-link">
114
+ <img src="../images/lightbox-ico-loading.gif">
115
+ </a>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ <div id="lightbox-container-image-data-box">
120
+ <div id="lightbox-container-image-data">
121
+ <div id="lightbox-image-details">
122
+ <span id="lightbox-image-details-caption"></span>
123
+ <span id="lightbox-image-details-currentNumber"></span>
124
+ </div>
125
+ <div id="lightbox-secNav">
126
+ <a href="#" id="lightbox-secNav-btnClose">
127
+ <img src="../images/lightbox-btn-close.gif">
128
+ </a>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ *
134
+ */
135
+ function _set_interface() {
136
+ // Apply the HTML markup into body tag
137
+ $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
138
+ // Get page sizes
139
+ var arrPageSizes = ___getPageSize();
140
+ // Style overlay and show it
141
+ $('#jquery-overlay').css({
142
+ backgroundColor : settings.overlayBgColor,
143
+ opacity : settings.overlayOpacity,
144
+ width : arrPageSizes[0],
145
+ height : arrPageSizes[1]
146
+ }).fadeIn();
147
+ // Get page scroll
148
+ var arrPageScroll = ___getPageScroll();
149
+ // Calculate top and left offset for the jquery-lightbox div object and show it
150
+ $('#jquery-lightbox').css({
151
+ top : arrPageScroll[1] + (arrPageSizes[3] / 10),
152
+ left : arrPageScroll[0]
153
+ }).show();
154
+ // Assigning click events in elements to close overlay
155
+ $('#jquery-overlay,#jquery-lightbox').click(function() {
156
+ _finish();
157
+ });
158
+ // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
159
+ $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
160
+ _finish();
161
+ return false;
162
+ });
163
+ // If window was resized, calculate the new overlay dimensions
164
+ $(window).resize(function() {
165
+ // Get page sizes
166
+ var arrPageSizes = ___getPageSize();
167
+ // Style overlay and show it
168
+ $('#jquery-overlay').css({
169
+ width : arrPageSizes[0],
170
+ height : arrPageSizes[1]
171
+ });
172
+ // Get page scroll
173
+ var arrPageScroll = ___getPageScroll();
174
+ // Calculate top and left offset for the jquery-lightbox div object and show it
175
+ $('#jquery-lightbox').css({
176
+ top : arrPageScroll[1] + (arrPageSizes[3] / 10),
177
+ left : arrPageScroll[0]
178
+ });
179
+ });
180
+ }
181
+
182
+ /**
183
+ * Prepares image exibition; doing a image�s preloader to calculate it�s size
184
+ *
185
+ */
186
+ function _set_image_to_view() {// show the loading
187
+ // Show the loading
188
+ $('#lightbox-loading').show();
189
+ if(settings.fixedNavigation) {
190
+ $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
191
+ } else {
192
+ // Hide some elements
193
+ $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
194
+ }
195
+ // Image preload process
196
+ var objImagePreloader = new Image();
197
+ objImagePreloader.onload = function() {
198
+ $('#lightbox-image').attr('src', settings.imageArray[settings.activeImage][0]);
199
+ // Perfomance an effect in the image container resizing it
200
+ _resize_container_image_box(objImagePreloader.width, objImagePreloader.height);
201
+ // clear onLoad, IE behaves irratically with animated gifs otherwise
202
+ objImagePreloader.onload = function() {
203
+ };
204
+ };
205
+ objImagePreloader.src = settings.imageArray[settings.activeImage][0];
206
+ };
207
+
208
+ /**
209
+ * Perfomance an effect in the image container resizing it
210
+ *
211
+ * @param integer intImageWidth The image�s width that will be showed
212
+ * @param integer intImageHeight The image�s height that will be showed
213
+ */
214
+ function _resize_container_image_box(intImageWidth, intImageHeight) {
215
+ //rescale if necessary
216
+ if((settings.maxWidth != null && settings.maxHeight != null) && (intImageWidth > settings.maxWidth || intImageHeight > settings.maxHeight)) {
217
+ var isWider = intImageWidth > intImageHeight;
218
+ //is the image wide or tall?
219
+ var scale = isWider ? settings.maxWidth / intImageWidth : settings.maxHeight / intImageHeight;
220
+ intImageWidth = intImageWidth * scale;
221
+ intImageHeight = intImageHeight * scale;
222
+ }
223
+
224
+ $('#lightbox-image').height(intImageHeight);
225
+ $('#lightbox-image').width(intImageWidth);
226
+ // Get current width and height
227
+ var intCurrentWidth = $('#lightbox-container-image-box').width();
228
+ var intCurrentHeight = $('#lightbox-container-image-box').height();
229
+ // Get the width and height of the selected image plus the padding
230
+ var intWidth = (intImageWidth + (settings.containerBorderSize * 2));
231
+ // Plus the image�s width and the left and right padding value
232
+ var intHeight = (intImageHeight + (settings.containerBorderSize * 2));
233
+ // Plus the image�s height and the left and right padding value
234
+ // Diferences
235
+ var intDiffW = intCurrentWidth - intWidth;
236
+ var intDiffH = intCurrentHeight - intHeight;
237
+ // Perfomance the effect
238
+ $('#lightbox-container-image-box').animate({
239
+ width : intWidth,
240
+ height : intHeight
241
+ }, settings.containerResizeSpeed, function() { _show_image();
242
+ });
243
+ if((intDiffW == 0 ) && (intDiffH == 0 )) {
244
+ if($.browser.msie) {
245
+ ___pause(250);
246
+ } else {
247
+ ___pause(100);
248
+ }
249
+ }
250
+ $('#lightbox-container-image-data-box').css({
251
+ width : intImageWidth
252
+ });
253
+ $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({
254
+ height : intImageHeight + (settings.containerBorderSize * 2)
255
+ });
256
+ };
257
+
258
+ /**
259
+ * Show the prepared image
260
+ *
261
+ */
262
+ function _show_image() {
263
+ $('#lightbox-loading').hide();
264
+ $('#lightbox-image').fadeIn(function() {
265
+ _show_image_data();
266
+ _set_navigation();
267
+ });
268
+ _preload_neighbor_images();
269
+ };
270
+
271
+ /**
272
+ * Show the image information
273
+ *
274
+ */
275
+ function _show_image_data() {
276
+ $('#lightbox-container-image-data-box').slideDown('fast');
277
+ $('#lightbox-image-details-caption').hide();
278
+ if(settings.imageArray[settings.activeImage][1]) {
279
+ $('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
280
+ }
281
+ // If we have a image set, display 'Image X of X'
282
+ if(settings.imageArray.length > 1) {
283
+ $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + (settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Display the button navigations
289
+ *
290
+ */
291
+ function _set_navigation() {
292
+ $('#lightbox-nav').show();
293
+
294
+ // Instead to define this configuration in CSS file, we define here. And it�s need to IE. Just.
295
+ $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({
296
+ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat'
297
+ });
298
+
299
+ // Show the prev button, if not the first image in set
300
+ if(settings.activeImage != 0) {
301
+ if(settings.fixedNavigation) {
302
+ $('#lightbox-nav-btnPrev').css({
303
+ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat'
304
+ }).unbind().bind('click', function() {
305
+ settings.activeImage = settings.activeImage - 1;
306
+ _set_image_to_view();
307
+ return false;
308
+ });
309
+ } else {
310
+ // Show the images button for Next buttons
311
+ $('#lightbox-nav-btnPrev').unbind().hover(function() {
312
+ $(this).css({
313
+ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat'
314
+ });
315
+ }, function() {
316
+ $(this).css({
317
+ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat'
318
+ });
319
+ }).show().bind('click', function() {
320
+ settings.activeImage = settings.activeImage - 1;
321
+ _set_image_to_view();
322
+ return false;
323
+ });
324
+ }
325
+ }
326
+
327
+ // Show the next button, if not the last image in set
328
+ if(settings.activeImage != (settings.imageArray.length - 1 )) {
329
+ if(settings.fixedNavigation) {
330
+ $('#lightbox-nav-btnNext').css({
331
+ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat'
332
+ }).unbind().bind('click', function() {
333
+ settings.activeImage = settings.activeImage + 1;
334
+ _set_image_to_view();
335
+ return false;
336
+ });
337
+ } else {
338
+ // Show the images button for Next buttons
339
+ $('#lightbox-nav-btnNext').unbind().hover(function() {
340
+ $(this).css({
341
+ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat'
342
+ });
343
+ }, function() {
344
+ $(this).css({
345
+ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat'
346
+ });
347
+ }).show().bind('click', function() {
348
+ settings.activeImage = settings.activeImage + 1;
349
+ _set_image_to_view();
350
+ return false;
351
+ });
352
+ }
353
+ }
354
+ // Enable keyboard navigation
355
+ _enable_keyboard_navigation();
356
+ }
357
+
358
+ /**
359
+ * Enable a support to keyboard navigation
360
+ *
361
+ */
362
+ function _enable_keyboard_navigation() {
363
+ $(document).keydown(function(objEvent) {
364
+ _keyboard_action(objEvent);
365
+ });
366
+ }
367
+
368
+ /**
369
+ * Disable the support to keyboard navigation
370
+ *
371
+ */
372
+ function _disable_keyboard_navigation() {
373
+ $(document).unbind();
374
+ }
375
+
376
+ /**
377
+ * Perform the keyboard actions
378
+ *
379
+ */
380
+ function _keyboard_action(objEvent) {
381
+ // To ie
382
+ if(objEvent == null) {
383
+ keycode = event.keyCode;
384
+ escapeKey = 27;
385
+ // To Mozilla
386
+ } else {
387
+ keycode = objEvent.keyCode;
388
+ escapeKey = objEvent.DOM_VK_ESCAPE;
389
+ }
390
+ // Get the key in lower case form
391
+ key = String.fromCharCode(keycode).toLowerCase();
392
+ // Verify the keys to close the ligthBox
393
+ if((key == settings.keyToClose ) || (key == 'x' ) || (keycode == escapeKey )) {
394
+ _finish();
395
+ }
396
+ // Verify the key to show the previous image
397
+ if((key == settings.keyToPrev ) || (keycode == 37 )) {
398
+ // If we�re not showing the first image, call the previous
399
+ if(settings.activeImage != 0) {
400
+ settings.activeImage = settings.activeImage - 1;
401
+ _set_image_to_view();
402
+ _disable_keyboard_navigation();
403
+ }
404
+ }
405
+ // Verify the key to show the next image
406
+ if((key == settings.keyToNext ) || (keycode == 39 )) {
407
+ // If we�re not showing the last image, call the next
408
+ if(settings.activeImage != (settings.imageArray.length - 1 )) {
409
+ settings.activeImage = settings.activeImage + 1;
410
+ _set_image_to_view();
411
+ _disable_keyboard_navigation();
412
+ }
413
+ }
414
+ }
415
+
416
+ /**
417
+ * Preload prev and next images being showed
418
+ *
419
+ */
420
+ function _preload_neighbor_images() {
421
+ if((settings.imageArray.length - 1) > settings.activeImage) {
422
+ objNext = new Image();
423
+ objNext.src = settings.imageArray[settings.activeImage + 1][0];
424
+ }
425
+ if(settings.activeImage > 0) {
426
+ objPrev = new Image();
427
+ objPrev.src = settings.imageArray[settings.activeImage -1][0];
428
+ }
429
+ }
430
+
431
+ /**
432
+ * Remove jQuery lightBox plugin HTML markup
433
+ *
434
+ */
435
+ function _finish() {
436
+ $('#jquery-lightbox').remove();
437
+ $('#jquery-overlay').fadeOut(function() {
438
+ $('#jquery-overlay').remove();
439
+ });
440
+ // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
441
+ $('embed, object, select').css({
442
+ 'visibility' : 'visible'
443
+ });
444
+ }
445
+
446
+ /**
447
+ / THIRD FUNCTION
448
+ * getPageSize() by quirksmode.com
449
+ *
450
+ * @return Array Return an array with page width, height and window width, height
451
+ */
452
+ function ___getPageSize() {
453
+ var xScroll, yScroll;
454
+ if(window.innerHeight && window.scrollMaxY) {
455
+ xScroll = window.innerWidth + window.scrollMaxX;
456
+ yScroll = window.innerHeight + window.scrollMaxY;
457
+ } else if(document.body.scrollHeight > document.body.offsetHeight) {// all but Explorer Mac
458
+ xScroll = document.body.scrollWidth;
459
+ yScroll = document.body.scrollHeight;
460
+ } else {// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
461
+ xScroll = document.body.offsetWidth;
462
+ yScroll = document.body.offsetHeight;
463
+ }
464
+ var windowWidth, windowHeight;
465
+ if(self.innerHeight) {// all except Explorer
466
+ if(document.documentElement.clientWidth) {
467
+ windowWidth = document.documentElement.clientWidth;
468
+ } else {
469
+ windowWidth = self.innerWidth;
470
+ }
471
+ windowHeight = self.innerHeight;
472
+ } else if(document.documentElement && document.documentElement.clientHeight) {// Explorer 6 Strict Mode
473
+ windowWidth = document.documentElement.clientWidth;
474
+ windowHeight = document.documentElement.clientHeight;
475
+ } else if(document.body) {// other Explorers
476
+ windowWidth = document.body.clientWidth;
477
+ windowHeight = document.body.clientHeight;
478
+ }
479
+ // for small pages with total height less then height of the viewport
480
+ if(yScroll < windowHeight) {
481
+ pageHeight = windowHeight;
482
+ } else {
483
+ pageHeight = yScroll;
484
+ }
485
+ // for small pages with total width less then width of the viewport
486
+ if(xScroll < windowWidth) {
487
+ pageWidth = xScroll;
488
+ } else {
489
+ pageWidth = windowWidth;
490
+ }
491
+ arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
492
+ return arrayPageSize;
493
+ };
494
+
495
+ /**
496
+ / THIRD FUNCTION
497
+ * getPageScroll() by quirksmode.com
498
+ *
499
+ * @return Array Return an array with x,y page scroll values.
500
+ */
501
+ function ___getPageScroll() {
502
+ var xScroll, yScroll;
503
+ if(self.pageYOffset) {
504
+ yScroll = self.pageYOffset;
505
+ xScroll = self.pageXOffset;
506
+ } else if(document.documentElement && document.documentElement.scrollTop) {// Explorer 6 Strict
507
+ yScroll = document.documentElement.scrollTop;
508
+ xScroll = document.documentElement.scrollLeft;
509
+ } else if(document.body) {// all other Explorers
510
+ yScroll = document.body.scrollTop;
511
+ xScroll = document.body.scrollLeft;
512
+ }
513
+ arrayPageScroll = new Array(xScroll, yScroll);
514
+ return arrayPageScroll;
515
+ };
516
+
517
+ /**
518
+ * Stop the code execution from a escified time in milisecond
519
+ *
520
+ */
521
+ function ___pause(ms) {
522
+ var date = new Date();
523
+ curDate = null;
524
+ do {
525
+ var curDate = new Date();
526
+ } while ( curDate - date < ms);
527
+ };
528
+
529
+ // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
530
+ return this.unbind('click').click(_initialize);
531
+ };
532
+ })(jQuery);
533
+ // Call and execute the function immediately passing the jQuery object