ninjs 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/README.textile +86 -25
  2. data/lib/ninjs.rb +35 -0
  3. data/lib/ninjs/command.rb +146 -0
  4. data/lib/ninjs/configuration.rb +84 -0
  5. data/lib/ninjs/dependencies.rb +16 -0
  6. data/lib/ninjs/helpers.rb +16 -0
  7. data/lib/ninjs/manifest.rb +9 -0
  8. data/lib/ninjs/project.rb +253 -0
  9. data/ninjs.gemspec +115 -0
  10. data/repository/jquery/1.1.4.js +2508 -0
  11. data/repository/jquery/1.2.6.js +32 -0
  12. data/repository/jquery/1.3.2.js +19 -0
  13. data/repository/jquery/1.4.2.js +154 -0
  14. data/repository/jquery/1.4.3.js +166 -0
  15. data/repository/jquery/1.4.4.js +167 -0
  16. data/repository/jquery/fancybox/1.3.1.js +1079 -0
  17. data/repository/jquery/fancybox/assets/1.3.1/css/fancybox.css +363 -0
  18. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/blank.gif +0 -0
  19. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_close.png +0 -0
  20. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_loading.png +0 -0
  21. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_left.png +0 -0
  22. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_nav_right.png +0 -0
  23. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_e.png +0 -0
  24. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_n.png +0 -0
  25. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_ne.png +0 -0
  26. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_nw.png +0 -0
  27. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_s.png +0 -0
  28. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_se.png +0 -0
  29. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_sw.png +0 -0
  30. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_shadow_w.png +0 -0
  31. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_left.png +0 -0
  32. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_main.png +0 -0
  33. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_over.png +0 -0
  34. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancy_title_right.png +0 -0
  35. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-x.png +0 -0
  36. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox-y.png +0 -0
  37. data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/fancybox.png +0 -0
  38. data/repository/jquery/fancybox/latest.js +1 -0
  39. data/repository/jquery/latest.js +1 -0
  40. data/repository/jquery/mousewheel/3.0.2.js +11 -0
  41. data/repository/jquery/mousewheel/latest.js +1 -0
  42. data/repository/json2.js +482 -0
  43. data/repository/modernizr/1.5.js +28 -0
  44. data/repository/modernizr/latest.js +1 -0
  45. data/repository/ninjs/core/existence.js +41 -0
  46. data/repository/ninjs/core/extend.js +22 -0
  47. data/repository/ninjs/core/nin.js +138 -0
  48. data/repository/ninjs/tests/index.html +21 -0
  49. data/repository/ninjs/tests/ninjs.test.js +109 -0
  50. data/repository/ninjs/tests/ninjs.utilities.test.js +149 -0
  51. data/repository/ninjs/utilities/all.js +4 -0
  52. data/repository/ninjs/utilities/array.js +34 -0
  53. data/repository/ninjs/utilities/css.js +51 -0
  54. data/repository/ninjs/utilities/number.js +11 -0
  55. data/repository/ninjs/utilities/string.js +66 -0
  56. data/repository/nullconsole.js +7 -0
  57. data/repository/qunit/assets/css/qunit.css +196 -0
  58. data/repository/qunit/qunit.js +1374 -0
  59. data/repository/selectivizr/1.0.js +5 -0
  60. data/repository/selectivizr/latest.js +1 -0
  61. data/repository/syntaxhighlighter/default.js +10 -0
  62. data/repository/syntaxhighlighter/shAutoloader.js +17 -0
  63. data/repository/syntaxhighlighter/shBrushAS3.js +59 -0
  64. data/repository/syntaxhighlighter/shBrushAppleScript.js +75 -0
  65. data/repository/syntaxhighlighter/shBrushBash.js +59 -0
  66. data/repository/syntaxhighlighter/shBrushCSharp.js +65 -0
  67. data/repository/syntaxhighlighter/shBrushColdFusion.js +100 -0
  68. data/repository/syntaxhighlighter/shBrushCpp.js +97 -0
  69. data/repository/syntaxhighlighter/shBrushCss.js +91 -0
  70. data/repository/syntaxhighlighter/shBrushDelphi.js +55 -0
  71. data/repository/syntaxhighlighter/shBrushDiff.js +41 -0
  72. data/repository/syntaxhighlighter/shBrushErlang.js +52 -0
  73. data/repository/syntaxhighlighter/shBrushGroovy.js +67 -0
  74. data/repository/syntaxhighlighter/shBrushJScript.js +52 -0
  75. data/repository/syntaxhighlighter/shBrushJava.js +57 -0
  76. data/repository/syntaxhighlighter/shBrushJavaFX.js +58 -0
  77. data/repository/syntaxhighlighter/shBrushPerl.js +72 -0
  78. data/repository/syntaxhighlighter/shBrushPhp.js +88 -0
  79. data/repository/syntaxhighlighter/shBrushPlain.js +33 -0
  80. data/repository/syntaxhighlighter/shBrushPowerShell.js +74 -0
  81. data/repository/syntaxhighlighter/shBrushPython.js +64 -0
  82. data/repository/syntaxhighlighter/shBrushRuby.js +55 -0
  83. data/repository/syntaxhighlighter/shBrushSass.js +94 -0
  84. data/repository/syntaxhighlighter/shBrushScala.js +51 -0
  85. data/repository/syntaxhighlighter/shBrushSql.js +66 -0
  86. data/repository/syntaxhighlighter/shBrushVb.js +56 -0
  87. data/repository/syntaxhighlighter/shBrushXml.js +69 -0
  88. data/repository/syntaxhighlighter/shCore.js +17 -0
  89. data/repository/syntaxhighlighter/shLegacy.js +17 -0
  90. data/spec/spec_helper.rb +3 -0
  91. data/spec/test_spec.rb +5 -0
  92. metadata +100 -3
@@ -0,0 +1,1079 @@
1
+ //= provide "assets/1.3.1"
2
+
3
+ /*
4
+ * FancyBox - jQuery Plugin
5
+ * Simple and fancy lightbox alternative
6
+ *
7
+ * Examples and documentation at: http://fancybox.net
8
+ *
9
+ * Copyright (c) 2008 - 2010 Janis Skarnelis
10
+ *
11
+ * Version: 1.3.1 (05/03/2010)
12
+ * Requires: jQuery v1.3+
13
+ *
14
+ * Dual licensed under the MIT and GPL licenses:
15
+ * http://www.opensource.org/licenses/mit-license.php
16
+ * http://www.gnu.org/licenses/gpl.html
17
+ */
18
+
19
+ (function($) {
20
+
21
+ var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right,
22
+
23
+ selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
24
+
25
+ ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
26
+
27
+ loadingTimer, loadingFrame = 1,
28
+
29
+ start_pos, final_pos, busy = false, shadow = 20, fx = $.extend($('<div/>')[0], { prop: 0 }), titleh = 0,
30
+
31
+ isIE6 = !$.support.opacity && !window.XMLHttpRequest,
32
+
33
+ /*
34
+ * Private methods
35
+ */
36
+
37
+ fancybox_abort = function() {
38
+ loading.hide();
39
+
40
+ imgPreloader.onerror = imgPreloader.onload = null;
41
+
42
+ if (ajaxLoader) {
43
+ ajaxLoader.abort();
44
+ }
45
+
46
+ tmp.empty();
47
+ },
48
+
49
+ fancybox_error = function() {
50
+ $.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', {
51
+ 'scrolling' : 'no',
52
+ 'padding' : 20,
53
+ 'transitionIn' : 'none',
54
+ 'transitionOut' : 'none'
55
+ });
56
+ },
57
+
58
+ fancybox_get_viewport = function() {
59
+ return [ $(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop() ];
60
+ },
61
+
62
+ fancybox_get_zoom_to = function () {
63
+ var view = fancybox_get_viewport(),
64
+ to = {},
65
+
66
+ margin = currentOpts.margin,
67
+ resize = currentOpts.autoScale,
68
+
69
+ horizontal_space = (shadow + margin) * 2,
70
+ vertical_space = (shadow + margin) * 2,
71
+ double_padding = (currentOpts.padding * 2),
72
+
73
+ ratio;
74
+
75
+ if (currentOpts.width.toString().indexOf('%') > -1) {
76
+ to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2) ;
77
+ resize = false;
78
+
79
+ } else {
80
+ to.width = currentOpts.width + double_padding;
81
+ }
82
+
83
+ if (currentOpts.height.toString().indexOf('%') > -1) {
84
+ to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2);
85
+ resize = false;
86
+
87
+ } else {
88
+ to.height = currentOpts.height + double_padding;
89
+ }
90
+
91
+ if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) {
92
+ if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
93
+ horizontal_space += double_padding;
94
+ vertical_space += double_padding;
95
+
96
+ ratio = Math.min(Math.min( view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min( view[1] - vertical_space, currentOpts.height) / currentOpts.height);
97
+
98
+ to.width = Math.round(ratio * (to.width - double_padding)) + double_padding;
99
+ to.height = Math.round(ratio * (to.height - double_padding)) + double_padding;
100
+
101
+ } else {
102
+ to.width = Math.min(to.width, (view[0] - horizontal_space));
103
+ to.height = Math.min(to.height, (view[1] - vertical_space));
104
+ }
105
+ }
106
+
107
+ to.top = view[3] + ((view[1] - (to.height + (shadow * 2 ))) * 0.5);
108
+ to.left = view[2] + ((view[0] - (to.width + (shadow * 2 ))) * 0.5);
109
+
110
+ if (currentOpts.autoScale === false) {
111
+ to.top = Math.max(view[3] + margin, to.top);
112
+ to.left = Math.max(view[2] + margin, to.left);
113
+ }
114
+
115
+ return to;
116
+ },
117
+
118
+ fancybox_format_title = function(title) {
119
+ if (title && title.length) {
120
+ switch (currentOpts.titlePosition) {
121
+ case 'inside':
122
+ return title;
123
+ case 'over':
124
+ return '<span id="fancybox-title-over">' + title + '</span>';
125
+ default:
126
+ return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + title + '</span><span id="fancybox-title-right"></span></span>';
127
+ }
128
+ }
129
+
130
+ return false;
131
+ },
132
+
133
+ fancybox_process_title = function() {
134
+ var title = currentOpts.title,
135
+ width = final_pos.width - (currentOpts.padding * 2),
136
+ titlec = 'fancybox-title-' + currentOpts.titlePosition;
137
+
138
+ $('#fancybox-title').remove();
139
+
140
+ titleh = 0;
141
+
142
+ if (currentOpts.titleShow === false) {
143
+ return;
144
+ }
145
+
146
+ title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title);
147
+
148
+ if (!title || title === '') {
149
+ return;
150
+ }
151
+
152
+ $('<div id="fancybox-title" class="' + titlec + '" />').css({
153
+ 'width' : width,
154
+ 'paddingLeft' : currentOpts.padding,
155
+ 'paddingRight' : currentOpts.padding
156
+ }).html(title).appendTo('body');
157
+
158
+ switch (currentOpts.titlePosition) {
159
+ case 'inside':
160
+ titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding;
161
+ final_pos.height += titleh;
162
+ break;
163
+
164
+ case 'over':
165
+ $('#fancybox-title').css('bottom', currentOpts.padding);
166
+ break;
167
+
168
+ default:
169
+ $('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1);
170
+ break;
171
+ }
172
+
173
+ $('#fancybox-title').appendTo( outer ).hide();
174
+ },
175
+
176
+ fancybox_set_navigation = function() {
177
+ $(document).unbind('keydown.fb').bind('keydown.fb', function(e) {
178
+ if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
179
+ e.preventDefault();
180
+ $.fancybox.close();
181
+
182
+ } else if (e.keyCode == 37) {
183
+ e.preventDefault();
184
+ $.fancybox.prev();
185
+
186
+ } else if (e.keyCode == 39) {
187
+ e.preventDefault();
188
+ $.fancybox.next();
189
+ }
190
+ });
191
+
192
+ if ($.fn.mousewheel) {
193
+ wrap.unbind('mousewheel.fb');
194
+
195
+ if (currentArray.length > 1) {
196
+ wrap.bind('mousewheel.fb', function(e, delta) {
197
+ e.preventDefault();
198
+
199
+ if (busy || delta === 0) {
200
+ return;
201
+ }
202
+
203
+ if (delta > 0) {
204
+ $.fancybox.prev();
205
+ } else {
206
+ $.fancybox.next();
207
+ }
208
+ });
209
+ }
210
+ }
211
+
212
+ if (!currentOpts.showNavArrows) { return; }
213
+
214
+ if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
215
+ nav_left.show();
216
+ }
217
+
218
+ if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
219
+ nav_right.show();
220
+ }
221
+ },
222
+
223
+ fancybox_preload_images = function() {
224
+ var href,
225
+ objNext;
226
+
227
+ if ((currentArray.length -1) > currentIndex) {
228
+ href = currentArray[ currentIndex + 1 ].href;
229
+
230
+ if (typeof href !== 'undefined' && href.match(imgRegExp)) {
231
+ objNext = new Image();
232
+ objNext.src = href;
233
+ }
234
+ }
235
+
236
+ if (currentIndex > 0) {
237
+ href = currentArray[ currentIndex - 1 ].href;
238
+
239
+ if (typeof href !== 'undefined' && href.match(imgRegExp)) {
240
+ objNext = new Image();
241
+ objNext.src = href;
242
+ }
243
+ }
244
+ },
245
+
246
+ _finish = function () {
247
+ inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible')));
248
+
249
+ if (!$.support.opacity) {
250
+ inner.get(0).style.removeAttribute('filter');
251
+ wrap.get(0).style.removeAttribute('filter');
252
+ }
253
+
254
+ $('#fancybox-title').show();
255
+
256
+ if (currentOpts.hideOnContentClick) {
257
+ inner.one('click', $.fancybox.close);
258
+ }
259
+ if (currentOpts.hideOnOverlayClick) {
260
+ overlay.one('click', $.fancybox.close);
261
+ }
262
+
263
+ if (currentOpts.showCloseButton) {
264
+ close.show();
265
+ }
266
+
267
+ fancybox_set_navigation();
268
+
269
+ $(window).bind("resize.fb", $.fancybox.center);
270
+
271
+ if (currentOpts.centerOnScroll) {
272
+ $(window).bind("scroll.fb", $.fancybox.center);
273
+ } else {
274
+ $(window).unbind("scroll.fb");
275
+ }
276
+
277
+ if ($.isFunction(currentOpts.onComplete)) {
278
+ currentOpts.onComplete(currentArray, currentIndex, currentOpts);
279
+ }
280
+
281
+ busy = false;
282
+
283
+ fancybox_preload_images();
284
+ },
285
+
286
+ fancybox_draw = function(pos) {
287
+ var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos),
288
+ height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos),
289
+
290
+ top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos),
291
+ left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos);
292
+
293
+ wrap.css({
294
+ 'width' : width + 'px',
295
+ 'height' : height + 'px',
296
+ 'top' : top + 'px',
297
+ 'left' : left + 'px'
298
+ });
299
+
300
+ width = Math.max(width - currentOpts.padding * 2, 0);
301
+ height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0);
302
+
303
+ inner.css({
304
+ 'width' : width + 'px',
305
+ 'height' : height + 'px'
306
+ });
307
+
308
+ if (typeof final_pos.opacity !== 'undefined') {
309
+ wrap.css('opacity', (pos < 0.5 ? 0.5 : pos));
310
+ }
311
+ },
312
+
313
+ fancybox_get_obj_pos = function(obj) {
314
+ var pos = obj.offset();
315
+
316
+ pos.top += parseFloat( obj.css('paddingTop') ) || 0;
317
+ pos.left += parseFloat( obj.css('paddingLeft') ) || 0;
318
+
319
+ pos.top += parseFloat( obj.css('border-top-width') ) || 0;
320
+ pos.left += parseFloat( obj.css('border-left-width') ) || 0;
321
+
322
+ pos.width = obj.width();
323
+ pos.height = obj.height();
324
+
325
+ return pos;
326
+ },
327
+
328
+ fancybox_get_zoom_from = function() {
329
+ var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
330
+ from = {},
331
+ pos,
332
+ view;
333
+
334
+ if (orig && orig.length) {
335
+ pos = fancybox_get_obj_pos(orig);
336
+
337
+ from = {
338
+ width : (pos.width + (currentOpts.padding * 2)),
339
+ height : (pos.height + (currentOpts.padding * 2)),
340
+ top : (pos.top - currentOpts.padding - shadow),
341
+ left : (pos.left - currentOpts.padding - shadow)
342
+ };
343
+
344
+ } else {
345
+ view = fancybox_get_viewport();
346
+
347
+ from = {
348
+ width : 1,
349
+ height : 1,
350
+ top : view[3] + view[1] * 0.5,
351
+ left : view[2] + view[0] * 0.5
352
+ };
353
+ }
354
+
355
+ return from;
356
+ },
357
+
358
+ fancybox_show = function() {
359
+ loading.hide();
360
+
361
+ if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) {
362
+ if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
363
+ $.event.trigger('fancybox-cancel');
364
+
365
+ busy = false;
366
+ return;
367
+ }
368
+ }
369
+
370
+ currentArray = selectedArray;
371
+ currentIndex = selectedIndex;
372
+ currentOpts = selectedOpts;
373
+
374
+ inner.get(0).scrollTop = 0;
375
+ inner.get(0).scrollLeft = 0;
376
+
377
+ if (currentOpts.overlayShow) {
378
+ if (isIE6) {
379
+ $('select:not(#fancybox-tmp select)').filter(function() {
380
+ return this.style.visibility !== 'hidden';
381
+ }).css({'visibility':'hidden'}).one('fancybox-cleanup', function() {
382
+ this.style.visibility = 'inherit';
383
+ });
384
+ }
385
+
386
+ overlay.css({
387
+ 'background-color' : currentOpts.overlayColor,
388
+ 'opacity' : currentOpts.overlayOpacity
389
+ }).unbind().show();
390
+ }
391
+
392
+ final_pos = fancybox_get_zoom_to();
393
+
394
+ fancybox_process_title();
395
+
396
+ if (wrap.is(":visible")) {
397
+ $( close.add( nav_left ).add( nav_right ) ).hide();
398
+
399
+ var pos = wrap.position(),
400
+ equal;
401
+
402
+ start_pos = {
403
+ top : pos.top ,
404
+ left : pos.left,
405
+ width : wrap.width(),
406
+ height : wrap.height()
407
+ };
408
+
409
+ equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
410
+
411
+ inner.fadeOut(currentOpts.changeFade, function() {
412
+ var finish_resizing = function() {
413
+ inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish);
414
+ };
415
+
416
+ $.event.trigger('fancybox-change');
417
+
418
+ inner.empty().css('overflow', 'hidden');
419
+
420
+ if (equal) {
421
+ inner.css({
422
+ top : currentOpts.padding,
423
+ left : currentOpts.padding,
424
+ width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
425
+ height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
426
+ });
427
+
428
+ finish_resizing();
429
+
430
+ } else {
431
+ inner.css({
432
+ top : currentOpts.padding,
433
+ left : currentOpts.padding,
434
+ width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
435
+ height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
436
+ });
437
+
438
+ fx.prop = 0;
439
+
440
+ $(fx).animate({ prop: 1 }, {
441
+ duration : currentOpts.changeSpeed,
442
+ easing : currentOpts.easingChange,
443
+ step : fancybox_draw,
444
+ complete : finish_resizing
445
+ });
446
+ }
447
+ });
448
+
449
+ return;
450
+ }
451
+
452
+ wrap.css('opacity', 1);
453
+
454
+ if (currentOpts.transitionIn == 'elastic') {
455
+ start_pos = fancybox_get_zoom_from();
456
+
457
+ inner.css({
458
+ top : currentOpts.padding,
459
+ left : currentOpts.padding,
460
+ width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
461
+ height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
462
+ })
463
+ .html( tmp.contents() );
464
+
465
+ wrap.css(start_pos).show();
466
+
467
+ if (currentOpts.opacity) {
468
+ final_pos.opacity = 0;
469
+ }
470
+
471
+ fx.prop = 0;
472
+
473
+ $(fx).animate({ prop: 1 }, {
474
+ duration : currentOpts.speedIn,
475
+ easing : currentOpts.easingIn,
476
+ step : fancybox_draw,
477
+ complete : _finish
478
+ });
479
+
480
+ } else {
481
+ inner.css({
482
+ top : currentOpts.padding,
483
+ left : currentOpts.padding,
484
+ width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
485
+ height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
486
+ })
487
+ .html( tmp.contents() );
488
+
489
+ wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
490
+ }
491
+ },
492
+
493
+ fancybox_process_inline = function() {
494
+ tmp.width( selectedOpts.width );
495
+ tmp.height( selectedOpts.height );
496
+
497
+ if (selectedOpts.width == 'auto') {
498
+ selectedOpts.width = tmp.width();
499
+ }
500
+ if (selectedOpts.height == 'auto') {
501
+ selectedOpts.height = tmp.height();
502
+ }
503
+
504
+ fancybox_show();
505
+ },
506
+
507
+ fancybox_process_image = function() {
508
+ busy = true;
509
+
510
+ selectedOpts.width = imgPreloader.width;
511
+ selectedOpts.height = imgPreloader.height;
512
+
513
+ $("<img />").attr({
514
+ 'id' : 'fancybox-img',
515
+ 'src' : imgPreloader.src,
516
+ 'alt' : selectedOpts.title
517
+ }).appendTo( tmp );
518
+
519
+ fancybox_show();
520
+ },
521
+
522
+ fancybox_start = function() {
523
+ fancybox_abort();
524
+
525
+ var obj = selectedArray[ selectedIndex ],
526
+ href,
527
+ type,
528
+ title,
529
+ str,
530
+ emb,
531
+ selector,
532
+ data;
533
+
534
+ selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
535
+ title = obj.title || $(obj).title || selectedOpts.title || '';
536
+
537
+ if (obj.nodeName && !selectedOpts.orig) {
538
+ selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
539
+ }
540
+
541
+ if (title === '' && selectedOpts.orig) {
542
+ title = selectedOpts.orig.attr('alt');
543
+ }
544
+
545
+ if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) {
546
+ href = selectedOpts.href || null;
547
+ } else {
548
+ href = selectedOpts.href || obj.href || null;
549
+ }
550
+
551
+ if (selectedOpts.type) {
552
+ type = selectedOpts.type;
553
+
554
+ if (!href) {
555
+ href = selectedOpts.content;
556
+ }
557
+
558
+ } else if (selectedOpts.content) {
559
+ type = 'html';
560
+
561
+ } else if (href) {
562
+ if (href.match(imgRegExp)) {
563
+ type = 'image';
564
+
565
+ } else if (href.match(swfRegExp)) {
566
+ type = 'swf';
567
+
568
+ } else if ($(obj).hasClass("iframe")) {
569
+ type = 'iframe';
570
+
571
+ } else if (href.match(/#/)) {
572
+ obj = href.substr(href.indexOf("#"));
573
+
574
+ type = $(obj).length > 0 ? 'inline' : 'ajax';
575
+ } else {
576
+ type = 'ajax';
577
+ }
578
+ } else {
579
+ type = 'inline';
580
+ }
581
+
582
+ selectedOpts.type = type;
583
+ selectedOpts.href = href;
584
+ selectedOpts.title = title;
585
+
586
+ if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') {
587
+ selectedOpts.width = 'auto';
588
+ selectedOpts.height = 'auto';
589
+ }
590
+
591
+ if (selectedOpts.modal) {
592
+ selectedOpts.overlayShow = true;
593
+ selectedOpts.hideOnOverlayClick = false;
594
+ selectedOpts.hideOnContentClick = false;
595
+ selectedOpts.enableEscapeButton = false;
596
+ selectedOpts.showCloseButton = false;
597
+ }
598
+
599
+ if ($.isFunction(selectedOpts.onStart)) {
600
+ if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) {
601
+ busy = false;
602
+ return;
603
+ }
604
+ }
605
+
606
+ tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));
607
+
608
+ $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
609
+ $(this).replaceWith(inner.children());
610
+ });
611
+
612
+ switch (type) {
613
+ case 'html' :
614
+ tmp.html( selectedOpts.content );
615
+ fancybox_process_inline();
616
+ break;
617
+
618
+ case 'inline' :
619
+ $('<div class="fancybox-inline-tmp" />').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() {
620
+ $(this).replaceWith(inner.children());
621
+ }).bind('fancybox-cancel', function() {
622
+ $(this).replaceWith(tmp.children());
623
+ });
624
+
625
+ $(obj).appendTo(tmp);
626
+
627
+ fancybox_process_inline();
628
+ break;
629
+
630
+ case 'image':
631
+ busy = false;
632
+
633
+ $.fancybox.showActivity();
634
+
635
+ imgPreloader = new Image();
636
+
637
+ imgPreloader.onerror = function() {
638
+ fancybox_error();
639
+ };
640
+
641
+ imgPreloader.onload = function() {
642
+ imgPreloader.onerror = null;
643
+ imgPreloader.onload = null;
644
+ fancybox_process_image();
645
+ };
646
+
647
+ imgPreloader.src = href;
648
+
649
+ break;
650
+
651
+ case 'swf':
652
+ str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
653
+ emb = '';
654
+
655
+ $.each(selectedOpts.swf, function(name, val) {
656
+ str += '<param name="' + name + '" value="' + val + '"></param>';
657
+ emb += ' ' + name + '="' + val + '"';
658
+ });
659
+
660
+ str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
661
+
662
+ tmp.html(str);
663
+
664
+ fancybox_process_inline();
665
+ break;
666
+
667
+ case 'ajax':
668
+ selector = href.split('#', 2);
669
+ data = selectedOpts.ajax.data || {};
670
+
671
+ if (selector.length > 1) {
672
+ href = selector[0];
673
+
674
+ if (typeof data == "string") {
675
+ data += '&selector=' + selector[1];
676
+ } else {
677
+ data.selector = selector[1];
678
+ }
679
+ }
680
+
681
+ busy = false;
682
+ $.fancybox.showActivity();
683
+
684
+ ajaxLoader = $.ajax($.extend(selectedOpts.ajax, {
685
+ url : href,
686
+ data : data,
687
+ error : fancybox_error,
688
+ success : function(data, textStatus, XMLHttpRequest) {
689
+ if (ajaxLoader.status == 200) {
690
+ tmp.html( data );
691
+ fancybox_process_inline();
692
+ }
693
+ }
694
+ }));
695
+
696
+ break;
697
+
698
+ case 'iframe' :
699
+ $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp);
700
+ fancybox_show();
701
+ break;
702
+ }
703
+ },
704
+
705
+ fancybox_animate_loading = function() {
706
+ if (!loading.is(':visible')){
707
+ clearInterval(loadingTimer);
708
+ return;
709
+ }
710
+
711
+ $('div', loading).css('top', (loadingFrame * -40) + 'px');
712
+
713
+ loadingFrame = (loadingFrame + 1) % 12;
714
+ },
715
+
716
+ fancybox_init = function() {
717
+ if ($("#fancybox-wrap").length) {
718
+ return;
719
+ }
720
+
721
+ $('body').append(
722
+ tmp = $('<div id="fancybox-tmp"></div>'),
723
+ loading = $('<div id="fancybox-loading"><div></div></div>'),
724
+ overlay = $('<div id="fancybox-overlay"></div>'),
725
+ wrap = $('<div id="fancybox-wrap"></div>')
726
+ );
727
+
728
+ if (!$.support.opacity) {
729
+ wrap.addClass('fancybox-ie');
730
+ loading.addClass('fancybox-ie');
731
+ }
732
+
733
+ outer = $('<div id="fancybox-outer"></div>')
734
+ .append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>')
735
+ .appendTo( wrap );
736
+
737
+ outer.append(
738
+ inner = $('<div id="fancybox-inner"></div>'),
739
+ close = $('<a id="fancybox-close"></a>'),
740
+
741
+ nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
742
+ nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
743
+ );
744
+
745
+ close.click($.fancybox.close);
746
+ loading.click($.fancybox.cancel);
747
+
748
+ nav_left.click(function(e) {
749
+ e.preventDefault();
750
+ $.fancybox.prev();
751
+ });
752
+
753
+ nav_right.click(function(e) {
754
+ e.preventDefault();
755
+ $.fancybox.next();
756
+ });
757
+
758
+ if (isIE6) {
759
+ overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");
760
+ loading.get(0).style.setExpression('top', "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");
761
+
762
+ outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
763
+ }
764
+ };
765
+
766
+ /*
767
+ * Public methods
768
+ */
769
+
770
+ $.fn.fancybox = function(options) {
771
+ $(this)
772
+ .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
773
+ .unbind('click.fb').bind('click.fb', function(e) {
774
+ e.preventDefault();
775
+
776
+ if (busy) {
777
+ return;
778
+ }
779
+
780
+ busy = true;
781
+
782
+ $(this).blur();
783
+
784
+ selectedArray = [];
785
+ selectedIndex = 0;
786
+
787
+ var rel = $(this).attr('rel') || '';
788
+
789
+ if (!rel || rel == '' || rel === 'nofollow') {
790
+ selectedArray.push(this);
791
+
792
+ } else {
793
+ selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
794
+ selectedIndex = selectedArray.index( this );
795
+ }
796
+
797
+ fancybox_start();
798
+
799
+ return false;
800
+ });
801
+
802
+ return this;
803
+ };
804
+
805
+ $.fancybox = function(obj) {
806
+ if (busy) {
807
+ return;
808
+ }
809
+
810
+ busy = true;
811
+
812
+ var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
813
+
814
+ selectedArray = [];
815
+ selectedIndex = opts.index || 0;
816
+
817
+ if ($.isArray(obj)) {
818
+ for (var i = 0, j = obj.length; i < j; i++) {
819
+ if (typeof obj[i] == 'object') {
820
+ $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
821
+ } else {
822
+ obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
823
+ }
824
+ }
825
+
826
+ selectedArray = jQuery.merge(selectedArray, obj);
827
+
828
+ } else {
829
+ if (typeof obj == 'object') {
830
+ $(obj).data('fancybox', $.extend({}, opts, obj));
831
+ } else {
832
+ obj = $({}).data('fancybox', $.extend({content : obj}, opts));
833
+ }
834
+
835
+ selectedArray.push(obj);
836
+ }
837
+
838
+ if (selectedIndex > selectedArray.length || selectedIndex < 0) {
839
+ selectedIndex = 0;
840
+ }
841
+
842
+ fancybox_start();
843
+ };
844
+
845
+ $.fancybox.showActivity = function() {
846
+ clearInterval(loadingTimer);
847
+
848
+ loading.show();
849
+ loadingTimer = setInterval(fancybox_animate_loading, 66);
850
+ };
851
+
852
+ $.fancybox.hideActivity = function() {
853
+ loading.hide();
854
+ };
855
+
856
+ $.fancybox.next = function() {
857
+ return $.fancybox.pos( currentIndex + 1);
858
+ };
859
+
860
+ $.fancybox.prev = function() {
861
+ return $.fancybox.pos( currentIndex - 1);
862
+ };
863
+
864
+ $.fancybox.pos = function(pos) {
865
+ if (busy) {
866
+ return;
867
+ }
868
+
869
+ pos = parseInt(pos, 10);
870
+
871
+ if (pos > -1 && currentArray.length > pos) {
872
+ selectedIndex = pos;
873
+ fancybox_start();
874
+ }
875
+
876
+ if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) {
877
+ selectedIndex = currentArray.length - 1;
878
+ fancybox_start();
879
+ }
880
+
881
+ if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) {
882
+ selectedIndex = 0;
883
+ fancybox_start();
884
+ }
885
+
886
+ return;
887
+ };
888
+
889
+ $.fancybox.cancel = function() {
890
+ if (busy) {
891
+ return;
892
+ }
893
+
894
+ busy = true;
895
+
896
+ $.event.trigger('fancybox-cancel');
897
+
898
+ fancybox_abort();
899
+
900
+ if (selectedOpts && $.isFunction(selectedOpts.onCancel)) {
901
+ selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
902
+ }
903
+
904
+ busy = false;
905
+ };
906
+
907
+ // Note: within an iframe use - parent.$.fancybox.close();
908
+ $.fancybox.close = function() {
909
+ if (busy || wrap.is(':hidden')) {
910
+ return;
911
+ }
912
+
913
+ busy = true;
914
+
915
+ if (currentOpts && $.isFunction(currentOpts.onCleanup)) {
916
+ if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
917
+ busy = false;
918
+ return;
919
+ }
920
+ }
921
+
922
+ fancybox_abort();
923
+
924
+ $(close.add( nav_left ).add( nav_right )).hide();
925
+
926
+ $('#fancybox-title').remove();
927
+
928
+ wrap.add(inner).add(overlay).unbind();
929
+
930
+ $(window).unbind("resize.fb scroll.fb");
931
+ $(document).unbind('keydown.fb');
932
+
933
+ function _cleanup() {
934
+ overlay.fadeOut('fast');
935
+
936
+ wrap.hide();
937
+
938
+ $.event.trigger('fancybox-cleanup');
939
+
940
+ inner.empty();
941
+
942
+ if ($.isFunction(currentOpts.onClosed)) {
943
+ currentOpts.onClosed(currentArray, currentIndex, currentOpts);
944
+ }
945
+
946
+ currentArray = selectedOpts = [];
947
+ currentIndex = selectedIndex = 0;
948
+ currentOpts = selectedOpts = {};
949
+
950
+ busy = false;
951
+ }
952
+
953
+ inner.css('overflow', 'hidden');
954
+
955
+ if (currentOpts.transitionOut == 'elastic') {
956
+ start_pos = fancybox_get_zoom_from();
957
+
958
+ var pos = wrap.position();
959
+
960
+ final_pos = {
961
+ top : pos.top ,
962
+ left : pos.left,
963
+ width : wrap.width(),
964
+ height : wrap.height()
965
+ };
966
+
967
+ if (currentOpts.opacity) {
968
+ final_pos.opacity = 1;
969
+ }
970
+
971
+ fx.prop = 1;
972
+
973
+ $(fx).animate({ prop: 0 }, {
974
+ duration : currentOpts.speedOut,
975
+ easing : currentOpts.easingOut,
976
+ step : fancybox_draw,
977
+ complete : _cleanup
978
+ });
979
+
980
+ } else {
981
+ wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
982
+ }
983
+ };
984
+
985
+ $.fancybox.resize = function() {
986
+ var c, h;
987
+
988
+ if (busy || wrap.is(':hidden')) {
989
+ return;
990
+ }
991
+
992
+ busy = true;
993
+
994
+ c = inner.wrapInner("<div style='overflow:auto'></div>").children();
995
+ h = c.height();
996
+
997
+ wrap.css({height: h + (currentOpts.padding * 2) + titleh});
998
+ inner.css({height: h});
999
+
1000
+ c.replaceWith(c.children());
1001
+
1002
+ $.fancybox.center();
1003
+ };
1004
+
1005
+ $.fancybox.center = function() {
1006
+ busy = true;
1007
+
1008
+ var view = fancybox_get_viewport(),
1009
+ margin = currentOpts.margin,
1010
+ to = {};
1011
+
1012
+ to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2 ))) * 0.5);
1013
+ to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2 ))) * 0.5);
1014
+
1015
+ to.top = Math.max(view[3] + margin, to.top);
1016
+ to.left = Math.max(view[2] + margin, to.left);
1017
+
1018
+ wrap.css(to);
1019
+
1020
+ busy = false;
1021
+ };
1022
+
1023
+ $.fn.fancybox.defaults = {
1024
+ padding : 10,
1025
+ margin : 20,
1026
+ opacity : false,
1027
+ modal : false,
1028
+ cyclic : false,
1029
+ scrolling : 'auto', // 'auto', 'yes' or 'no'
1030
+
1031
+ width : 560,
1032
+ height : 340,
1033
+
1034
+ autoScale : true,
1035
+ autoDimensions : true,
1036
+ centerOnScroll : false,
1037
+
1038
+ ajax : {},
1039
+ swf : { wmode: 'transparent' },
1040
+
1041
+ hideOnOverlayClick : true,
1042
+ hideOnContentClick : false,
1043
+
1044
+ overlayShow : true,
1045
+ overlayOpacity : 0.3,
1046
+ overlayColor : '#666',
1047
+
1048
+ titleShow : true,
1049
+ titlePosition : 'outside', // 'outside', 'inside' or 'over'
1050
+ titleFormat : null,
1051
+
1052
+ transitionIn : 'fade', // 'elastic', 'fade' or 'none'
1053
+ transitionOut : 'fade', // 'elastic', 'fade' or 'none'
1054
+
1055
+ speedIn : 300,
1056
+ speedOut : 300,
1057
+
1058
+ changeSpeed : 300,
1059
+ changeFade : 'fast',
1060
+
1061
+ easingIn : 'swing',
1062
+ easingOut : 'swing',
1063
+
1064
+ showCloseButton : true,
1065
+ showNavArrows : true,
1066
+ enableEscapeButton : true,
1067
+
1068
+ onStart : null,
1069
+ onCancel : null,
1070
+ onComplete : null,
1071
+ onCleanup : null,
1072
+ onClosed : null
1073
+ };
1074
+
1075
+ $(document).ready(function() {
1076
+ fancybox_init();
1077
+ });
1078
+
1079
+ })(jQuery);