dadablog 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/.gitignore +6 -0
  2. data/COPYING +18 -0
  3. data/Gemfile +2 -0
  4. data/README.md +20 -0
  5. data/Rakefile +1 -0
  6. data/bin/dadablog +4 -0
  7. data/dadablog.gemspec +31 -0
  8. data/lib/dadablog/blog.rb +79 -0
  9. data/lib/dadablog/cli.rb +11 -0
  10. data/lib/dadablog/generators/create/.gitignore +11 -0
  11. data/lib/dadablog/generators/create/Gemfile +1 -0
  12. data/lib/dadablog/generators/create/config.ru +15 -0
  13. data/lib/dadablog/generators/create/hello-world.md +4 -0
  14. data/lib/dadablog/generators/create/public/css/blog.css +104 -0
  15. data/lib/dadablog/generators/create/public/img/house.png +0 -0
  16. data/lib/dadablog/generators/create/public/js/blog.js +3 -0
  17. data/lib/dadablog/generators/create/public/js/fancyBox/CHANGELOG.md +34 -0
  18. data/lib/dadablog/generators/create/public/js/fancyBox/README.md +133 -0
  19. data/lib/dadablog/generators/create/public/js/fancyBox/demo/1_b.jpg +0 -0
  20. data/lib/dadablog/generators/create/public/js/fancyBox/demo/1_s.jpg +0 -0
  21. data/lib/dadablog/generators/create/public/js/fancyBox/demo/2_b.jpg +0 -0
  22. data/lib/dadablog/generators/create/public/js/fancyBox/demo/2_s.jpg +0 -0
  23. data/lib/dadablog/generators/create/public/js/fancyBox/demo/3_b.jpg +0 -0
  24. data/lib/dadablog/generators/create/public/js/fancyBox/demo/3_s.jpg +0 -0
  25. data/lib/dadablog/generators/create/public/js/fancyBox/demo/4_b.jpg +0 -0
  26. data/lib/dadablog/generators/create/public/js/fancyBox/demo/4_s.jpg +0 -0
  27. data/lib/dadablog/generators/create/public/js/fancyBox/demo/5_b.jpg +0 -0
  28. data/lib/dadablog/generators/create/public/js/fancyBox/demo/5_s.jpg +0 -0
  29. data/lib/dadablog/generators/create/public/js/fancyBox/demo/ajax.txt +15 -0
  30. data/lib/dadablog/generators/create/public/js/fancyBox/demo/index.html +227 -0
  31. data/lib/dadablog/generators/create/public/js/fancyBox/lib/jquery-1.7.1.min.js +4 -0
  32. data/lib/dadablog/generators/create/public/js/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js +13 -0
  33. data/lib/dadablog/generators/create/public/js/fancyBox/source/blank.gif +0 -0
  34. data/lib/dadablog/generators/create/public/js/fancyBox/source/fancybox_loading.gif +0 -0
  35. data/lib/dadablog/generators/create/public/js/fancyBox/source/fancybox_sprite.png +0 -0
  36. data/lib/dadablog/generators/create/public/js/fancyBox/source/helpers/fancybox_buttons.png +0 -0
  37. data/lib/dadablog/generators/create/public/js/fancyBox/source/helpers/jquery.fancybox-buttons.css +85 -0
  38. data/lib/dadablog/generators/create/public/js/fancyBox/source/helpers/jquery.fancybox-buttons.js +115 -0
  39. data/lib/dadablog/generators/create/public/js/fancyBox/source/helpers/jquery.fancybox-thumbs.css +54 -0
  40. data/lib/dadablog/generators/create/public/js/fancyBox/source/helpers/jquery.fancybox-thumbs.js +151 -0
  41. data/lib/dadablog/generators/create/public/js/fancyBox/source/jquery.fancybox.css +224 -0
  42. data/lib/dadablog/generators/create/public/js/fancyBox/source/jquery.fancybox.js +1310 -0
  43. data/lib/dadablog/generators/create/public/js/fancyBox/source/jquery.fancybox.pack.js +32 -0
  44. data/lib/dadablog/generators/create/public/js/jquery-1.7.1.min.js +4 -0
  45. data/lib/dadablog/generators/create/public/js/jquery.timeago.js +146 -0
  46. data/lib/dadablog/generators/create/public/js/post.js +3 -0
  47. data/lib/dadablog/generators/create/server.sh +35 -0
  48. data/lib/dadablog/generators/create/views/index.erb +3 -0
  49. data/lib/dadablog/generators/create/views/layout.erb +23 -0
  50. data/lib/dadablog/generators/create/views/post.erb +34 -0
  51. data/lib/dadablog/generators/create/views/summary.erb +13 -0
  52. data/lib/dadablog/generators/create.rb +43 -0
  53. data/lib/dadablog/github_hook.rb +36 -0
  54. data/lib/dadablog/version.rb +3 -0
  55. data/lib/dadablog.rb +5 -0
  56. metadata +168 -0
@@ -0,0 +1,1310 @@
1
+ /*!
2
+ * fancyBox - jQuery Plugin
3
+ * version: 2.0.4 (12/12/2011)
4
+ * @requires jQuery v1.6 or later
5
+ *
6
+ * Examples at http://fancyapps.com/fancybox/
7
+ * License: www.fancyapps.com/fancybox/#license
8
+ *
9
+ * Copyright 2011 Janis Skarnelis - janis@fancyapps.com
10
+ *
11
+ */
12
+ (function (window, document, $) {
13
+ var W = $(window),
14
+ D = $(document),
15
+ F = $.fancybox = function () {
16
+ F.open.apply( this, arguments );
17
+ },
18
+ didResize = false,
19
+ resizeTimer = null;
20
+
21
+ $.extend(F, {
22
+ // The current version of fancyBox
23
+ version: '2.0.4',
24
+
25
+ defaults: {
26
+ padding: 15,
27
+ margin: 20,
28
+
29
+ width: 800,
30
+ height: 600,
31
+ minWidth: 200,
32
+ minHeight: 200,
33
+ maxWidth: 9999,
34
+ maxHeight: 9999,
35
+
36
+ autoSize: true,
37
+ fitToView: true,
38
+ aspectRatio: false,
39
+ topRatio: 0.5,
40
+
41
+ fixed: !$.browser.msie || $.browser.version > 6 || !document.documentElement.hasOwnProperty('ontouchstart'),
42
+ scrolling: 'auto', // 'auto', 'yes' or 'no'
43
+ wrapCSS: 'fancybox-default',
44
+
45
+ arrows: true,
46
+ closeBtn: true,
47
+ closeClick: false,
48
+ nextClick : false,
49
+ mouseWheel: true,
50
+ autoPlay: false,
51
+ playSpeed: 3000,
52
+
53
+ modal: false,
54
+ loop: true,
55
+ ajax: {},
56
+ keys: {
57
+ next: [13, 32, 34, 39, 40], // enter, space, page down, right arrow, down arrow
58
+ prev: [8, 33, 37, 38], // backspace, page up, left arrow, up arrow
59
+ close: [27] // escape key
60
+ },
61
+
62
+ // Override some properties
63
+ index: 0,
64
+ type: null,
65
+ href: null,
66
+ content: null,
67
+ title: null,
68
+
69
+ // HTML templates
70
+ tpl: {
71
+ wrap: '<div class="fancybox-wrap"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div>',
72
+ image: '<img class="fancybox-image" src="{href}" alt="" />',
73
+ iframe: '<iframe class="fancybox-iframe" name="fancybox-frame{rnd}" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="{scrolling}" src="{href}"></iframe>',
74
+ swf: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{href}" /><embed src="{href}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%" wmode="transparent"></embed></object>',
75
+ error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
76
+ closeBtn: '<div title="Close" class="fancybox-item fancybox-close"></div>',
77
+ next: '<a title="Next" class="fancybox-item fancybox-next"><span></span></a>',
78
+ prev: '<a title="Previous" class="fancybox-item fancybox-prev"><span></span></a>'
79
+ },
80
+
81
+ // Properties for each animation type
82
+ // Opening fancyBox
83
+ openEffect: 'fade', // 'elastic', 'fade' or 'none'
84
+ openSpeed: 250,
85
+ openEasing: 'swing',
86
+ openOpacity: true,
87
+ openMethod: 'zoomIn',
88
+
89
+ // Closing fancyBox
90
+ closeEffect: 'fade', // 'elastic', 'fade' or 'none'
91
+ closeSpeed: 250,
92
+ closeEasing: 'swing',
93
+ closeOpacity: true,
94
+ closeMethod: 'zoomOut',
95
+
96
+ // Changing next gallery item
97
+ nextEffect: 'elastic', // 'elastic', 'fade' or 'none'
98
+ nextSpeed: 300,
99
+ nextEasing: 'swing',
100
+ nextMethod: 'changeIn',
101
+
102
+ // Changing previous gallery item
103
+ prevEffect: 'elastic', // 'elastic', 'fade' or 'none'
104
+ prevSpeed: 300,
105
+ prevEasing: 'swing',
106
+ prevMethod: 'changeOut',
107
+
108
+ // Enabled helpers
109
+ helpers: {
110
+ overlay: {
111
+ speedIn: 0,
112
+ speedOut: 300,
113
+ opacity: 0.8,
114
+ css: {
115
+ cursor: 'pointer'
116
+ },
117
+ closeClick: true
118
+ },
119
+ title: {
120
+ type: 'float' // 'float', 'inside', 'outside' or 'over'
121
+ }
122
+ },
123
+
124
+ // Callbacks
125
+ onCancel: $.noop, // If canceling
126
+ beforeLoad: $.noop, // Before loading
127
+ afterLoad: $.noop, // After loading
128
+ beforeShow: $.noop, // Before changing in current item
129
+ afterShow: $.noop, // After opening
130
+ beforeClose: $.noop, // Before closing
131
+ afterClose: $.noop // After closing
132
+ },
133
+
134
+ //Current state
135
+ group: {}, // Selected group
136
+ opts: {}, // Group options
137
+ coming: null, // Element being loaded
138
+ current: null, // Currently loaded element
139
+ isOpen: false, // Is currently open
140
+ isOpened: false, // Have been fully opened at least once
141
+ wrap: null,
142
+ outer: null,
143
+ inner: null,
144
+
145
+ player: {
146
+ timer: null,
147
+ isActive: false
148
+ },
149
+
150
+ // Loaders
151
+ ajaxLoad: null,
152
+ imgPreload: null,
153
+
154
+ // Some collections
155
+ transitions: {},
156
+ helpers: {},
157
+
158
+ /*
159
+ * Static methods
160
+ */
161
+
162
+ open: function (group, opts) {
163
+ // Normalize group
164
+ if (!$.isArray(group)) {
165
+ group = [group];
166
+ }
167
+
168
+ if (!group.length) {
169
+ return;
170
+ }
171
+
172
+ //Kill existing instances
173
+ F.close(true);
174
+
175
+ //Extend the defaults
176
+ F.opts = $.extend(true, {}, F.defaults, opts);
177
+ F.group = group;
178
+
179
+ F._start(F.opts.index || 0);
180
+ },
181
+
182
+ cancel: function () {
183
+ if (F.coming && false === F.trigger('onCancel')) {
184
+ return;
185
+ }
186
+
187
+ F.coming = null;
188
+
189
+ F.hideLoading();
190
+
191
+ if (F.ajaxLoad) {
192
+ F.ajaxLoad.abort();
193
+ }
194
+
195
+ F.ajaxLoad = null;
196
+
197
+ if (F.imgPreload) {
198
+ F.imgPreload.onload = F.imgPreload.onabort = F.imgPreload.onerror = null;
199
+ }
200
+ },
201
+
202
+ close: function (a) {
203
+ F.cancel();
204
+
205
+ if (!F.current || false === F.trigger('beforeClose')) {
206
+ return;
207
+ }
208
+
209
+ F.unbindEvents();
210
+
211
+ //If forced or is still opening then remove immediately
212
+ if (!F.isOpen || (a && a[0] === true)) {
213
+ $(".fancybox-wrap").stop().trigger('onReset').remove();
214
+
215
+ F._afterZoomOut();
216
+
217
+ } else {
218
+ F.isOpen = F.isOpened = false;
219
+
220
+ $(".fancybox-item").remove();
221
+
222
+ F.wrap.stop(true).removeClass('fancybox-opened');
223
+ F.inner.css('overflow', 'hidden');
224
+
225
+ F.transitions[F.current.closeMethod]();
226
+ }
227
+ },
228
+
229
+ // Start/stop slideshow
230
+ play: function (a) {
231
+ var clear = function () {
232
+ clearTimeout(F.player.timer);
233
+ },
234
+ set = function () {
235
+ clear();
236
+
237
+ if (F.current && F.player.isActive) {
238
+ F.player.timer = setTimeout(F.next, F.current.playSpeed);
239
+ }
240
+ },
241
+ stop = function () {
242
+ clear();
243
+
244
+ $('body').unbind('.player');
245
+
246
+ F.player.isActive = false;
247
+
248
+ F.trigger('onPlayEnd');
249
+ },
250
+ start = function () {
251
+ if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
252
+ F.player.isActive = true;
253
+
254
+ $('body').bind({
255
+ 'afterShow.player onUpdate.player': set,
256
+ 'onCancel.player beforeClose.player': stop,
257
+ 'beforeLoad.player': clear
258
+ });
259
+
260
+ set();
261
+
262
+ F.trigger('onPlayStart');
263
+ }
264
+ };
265
+
266
+ if (F.player.isActive || (a && a[0] === false)) {
267
+ stop();
268
+ } else {
269
+ start();
270
+ }
271
+ },
272
+
273
+ next: function () {
274
+ if (F.current) {
275
+ F.jumpto(F.current.index + 1);
276
+ }
277
+ },
278
+
279
+ prev: function () {
280
+ if (F.current) {
281
+ F.jumpto(F.current.index - 1);
282
+ }
283
+ },
284
+
285
+ jumpto: function (index) {
286
+ if (!F.current) {
287
+ return;
288
+ }
289
+
290
+ index = parseInt(index, 10);
291
+
292
+ if (F.group.length > 1 && F.current.loop) {
293
+ if (index >= F.group.length) {
294
+ index = 0;
295
+
296
+ } else if (index < 0) {
297
+ index = F.group.length - 1;
298
+ }
299
+ }
300
+
301
+ if (typeof F.group[index] !== 'undefined') {
302
+ F.cancel();
303
+
304
+ F._start(index);
305
+ }
306
+ },
307
+
308
+ reposition: function (a) {
309
+ if (F.isOpen) {
310
+ F.wrap.css(F._getPosition(a));
311
+ }
312
+ },
313
+
314
+ update: function () {
315
+ if (F.isOpen) {
316
+ // It's a very bad idea to attach handlers to the window scroll event, run this code after a delay
317
+ if (!didResize) {
318
+ resizeTimer = setInterval(function () {
319
+ if (didResize) {
320
+ didResize = false;
321
+
322
+ clearTimeout(resizeTimer);
323
+
324
+ if (F.current) {
325
+ if (F.current.autoSize) {
326
+ F.inner.height('auto');
327
+ F.current.height = F.inner.height();
328
+ }
329
+
330
+ F._setDimension();
331
+
332
+ if (F.current.canGrow) {
333
+ F.inner.height('auto');
334
+ }
335
+
336
+ F.reposition();
337
+
338
+ F.trigger('onUpdate');
339
+ }
340
+ }
341
+ }, 100);
342
+ }
343
+
344
+ didResize = true;
345
+ }
346
+ },
347
+
348
+ toggle: function () {
349
+ if (F.isOpen) {
350
+ F.current.fitToView = !F.current.fitToView;
351
+
352
+ F.update();
353
+ }
354
+ },
355
+
356
+ hideLoading: function () {
357
+ $("#fancybox-loading").remove();
358
+ },
359
+
360
+ showLoading: function () {
361
+ F.hideLoading();
362
+
363
+ $('<div id="fancybox-loading"></div>').click(F.cancel).appendTo('body');
364
+ },
365
+
366
+ getViewport: function () {
367
+ return {
368
+ x: W.scrollLeft(),
369
+ y: W.scrollTop(),
370
+ w: W.width(),
371
+ h: W.height()
372
+ };
373
+ },
374
+
375
+ // Unbind the keyboard / clicking actions
376
+ unbindEvents: function () {
377
+ if (F.wrap) {
378
+ F.wrap.unbind('.fb');
379
+ }
380
+
381
+ D.unbind('.fb');
382
+ W.unbind('.fb');
383
+ },
384
+
385
+ bindEvents: function () {
386
+ var current = F.current,
387
+ keys = current.keys;
388
+
389
+ if (!current) {
390
+ return;
391
+ }
392
+
393
+ W.bind('resize.fb, orientationchange.fb', F.update);
394
+
395
+ if (keys) {
396
+ D.bind('keydown.fb', function (e) {
397
+ var code;
398
+
399
+ // Ignore key combinations and key events within form elements
400
+ if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && $.inArray(e.target.tagName.toLowerCase(), ['input', 'textarea', 'select', 'button']) < 0) {
401
+ code = e.keyCode;
402
+
403
+ if ($.inArray(code, keys.close) > -1) {
404
+ F.close();
405
+ e.preventDefault();
406
+
407
+ } else if ($.inArray(code, keys.next) > -1) {
408
+ F.next();
409
+ e.preventDefault();
410
+
411
+ } else if ($.inArray(code, keys.prev) > -1) {
412
+ F.prev();
413
+ e.preventDefault();
414
+ }
415
+ }
416
+ });
417
+ }
418
+
419
+ if ($.fn.mousewheel && current.mouseWheel && F.group.length > 1) {
420
+ F.wrap.bind('mousewheel.fb', function (e, delta) {
421
+ var target = $(e.target).get(0);
422
+
423
+ if (target.clientHeight === 0 || target.scrollHeight === target.clientHeight) {
424
+ e.preventDefault();
425
+
426
+ F[delta > 0 ? 'prev' : 'next']();
427
+ }
428
+ });
429
+ }
430
+ },
431
+
432
+ trigger: function (event) {
433
+ var ret, obj = F[ $.inArray(event, ['onCancel', 'beforeLoad', 'afterLoad']) > -1 ? 'coming' : 'current' ];
434
+
435
+ if (!obj) {
436
+ return;
437
+ }
438
+
439
+ if ($.isFunction( obj[event] )) {
440
+ ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
441
+ }
442
+
443
+ if (ret === false) {
444
+ return false;
445
+ }
446
+
447
+ if (obj.helpers) {
448
+ $.each(obj.helpers, function (helper, opts) {
449
+ if (opts && typeof F.helpers[helper] !== 'undefined' && $.isFunction(F.helpers[helper][event])) {
450
+ F.helpers[helper][event](opts, obj);
451
+ }
452
+ });
453
+ }
454
+
455
+ $.event.trigger(event + '.fb');
456
+ },
457
+
458
+ isImage: function (str) {
459
+ return str && str.match(/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i);
460
+ },
461
+
462
+ isSWF: function (str) {
463
+ return str && str.match(/\.(swf)(.*)?$/i);
464
+ },
465
+
466
+ _start: function (index) {
467
+ var coming = {},
468
+ element = F.group[index] || null,
469
+ isDom,
470
+ href,
471
+ type,
472
+ rez;
473
+
474
+ if (typeof element === 'object' && (element.nodeType || element instanceof $)) {
475
+ isDom = true;
476
+
477
+ if ($.metadata) {
478
+ coming = $(element).metadata();
479
+ }
480
+ }
481
+
482
+ coming = $.extend(true, {}, F.opts, {index : index, element : element}, ($.isPlainObject(element) ? element : coming));
483
+
484
+ // Re-check overridable options
485
+ $.each(['href', 'title', 'content', 'type'], function(i,v) {
486
+ coming[v] = F.opts[ v ] || (isDom && $(element).attr( v )) || coming[ v ] || null;
487
+ });
488
+
489
+ // Convert margin property to array - top, right, bottom, left
490
+ if (typeof coming.margin === 'number') {
491
+ coming.margin = [coming.margin, coming.margin, coming.margin, coming.margin];
492
+ }
493
+
494
+ // 'modal' propery is just a shortcut
495
+ if (coming.modal) {
496
+ $.extend(true, coming, {
497
+ closeBtn : false,
498
+ closeClick: false,
499
+ nextClick : false,
500
+ arrows : false,
501
+ mouseWheel : false,
502
+ keys : null,
503
+ helpers: {
504
+ overlay : {
505
+ css: {
506
+ cursor : 'auto'
507
+ },
508
+ closeClick : false
509
+ }
510
+ }
511
+ });
512
+ }
513
+
514
+ //Give a chance for callback or helpers to update coming item (type, title, etc)
515
+ F.coming = coming;
516
+
517
+ if (false === F.trigger('beforeLoad')) {
518
+ F.coming = null;
519
+ return;
520
+ }
521
+
522
+ type = coming.type;
523
+ href = coming.href;
524
+
525
+ ///Check if content type is set, if not, try to get
526
+ if (!type) {
527
+ if (isDom) {
528
+ rez = $(element).data('fancybox-type');
529
+
530
+ if (!rez && element.className) {
531
+ rez = element.className.match(/fancybox\.(\w+)/);
532
+ type = rez ? rez[1] : null;
533
+ }
534
+ }
535
+
536
+ if (!type && href) {
537
+ if (F.isImage(href)) {
538
+ type = 'image';
539
+
540
+ } else if (F.isSWF(href)) {
541
+ type = 'swf';
542
+
543
+ } else if (href.match(/^#/)) {
544
+ type = 'inline';
545
+ }
546
+ }
547
+
548
+ // ...if not - display element itself
549
+ if (!type) {
550
+ type = isDom ? 'inline' : 'html';
551
+ }
552
+
553
+ coming.type = type;
554
+ }
555
+
556
+ // Check before try to load; 'inline' and 'html' types need content, others - href
557
+ if (type === 'inline' || type === 'html') {
558
+ coming.content = coming.content || (type === 'inline' && href ? $(href) : element);
559
+
560
+ if (!coming.content.length) {
561
+ type = null;
562
+ }
563
+
564
+ } else {
565
+ coming.href = href || element;
566
+
567
+ if (!coming.href) {
568
+ type = null;
569
+ }
570
+ }
571
+
572
+ /*
573
+ Add reference to the group, so it`s possible to access from callbacks, example:
574
+
575
+ afterLoad : function() {
576
+ this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
577
+ }
578
+
579
+ */
580
+
581
+ coming.group = F.group;
582
+
583
+ if (type === 'image') {
584
+ F._loadImage();
585
+
586
+ } else if (type === 'ajax') {
587
+ F._loadAjax();
588
+
589
+ } else if (type) {
590
+ F._afterLoad();
591
+
592
+ } else {
593
+ F._error( 'type' );
594
+ }
595
+ },
596
+
597
+ _error: function ( type ) {
598
+ $.extend(F.coming, {
599
+ type : 'html',
600
+ autoSize : true,
601
+ minHeight : '0',
602
+ hasError : type,
603
+ content : F.coming.tpl.error
604
+ });
605
+
606
+ F._afterLoad();
607
+ },
608
+
609
+ _loadImage: function () {
610
+ // Reset preload image so it is later possible to check "complete" property
611
+ F.imgPreload = new Image();
612
+
613
+ F.imgPreload.onload = function () {
614
+ this.onload = this.onerror = null;
615
+
616
+ F.coming.width = this.width;
617
+ F.coming.height = this.height;
618
+
619
+ F._afterLoad();
620
+ };
621
+
622
+ F.imgPreload.onerror = function () {
623
+ this.onload = this.onerror = null;
624
+
625
+ F._error( 'image' );
626
+ };
627
+
628
+ F.imgPreload.src = F.coming.href;
629
+
630
+ if (!F.imgPreload.complete) {
631
+ F.showLoading();
632
+ }
633
+ },
634
+
635
+ _loadAjax: function () {
636
+ F.showLoading();
637
+
638
+ F.ajaxLoad = $.ajax($.extend({}, F.coming.ajax, {
639
+ url: F.coming.href,
640
+ error: function (jqXHR, textStatus) {
641
+ if (textStatus !== 'abort') {
642
+ F._error( 'ajax', jqXHR );
643
+
644
+ } else {
645
+ F.hideLoading();
646
+ }
647
+ },
648
+ success: function (data, textStatus) {
649
+ if (textStatus === 'success') {
650
+ F.coming.content = data;
651
+
652
+ F._afterLoad();
653
+ }
654
+ }
655
+ }));
656
+ },
657
+
658
+ _preload : function() {
659
+ var group = F.group,
660
+ index = F.current.index,
661
+ load = function(href) {
662
+ if (href && F.isImage(href)) {
663
+ new Image().src = href;
664
+ }
665
+ };
666
+
667
+ if (group.length > 1) {
668
+ load( $( group[ index + 1 ] || group[ 0 ] ).attr('href') );
669
+ load( $( group[ index - 1 ] || group[ group.length - 1 ] ).attr('href') );
670
+ }
671
+ },
672
+
673
+ _afterLoad: function () {
674
+ F.hideLoading();
675
+
676
+ if (!F.coming || false === F.trigger('afterLoad', F.current)) {
677
+ F.coming = false;
678
+
679
+ return;
680
+ }
681
+
682
+ if (F.isOpened) {
683
+ $(".fancybox-item").remove();
684
+
685
+ F.wrap.stop(true).removeClass('fancybox-opened');
686
+ F.inner.css('overflow', 'hidden');
687
+
688
+ F.transitions[F.current.prevMethod]();
689
+
690
+ } else {
691
+ $(".fancybox-wrap").stop().trigger('onReset').remove();
692
+
693
+ F.trigger('afterClose');
694
+ }
695
+
696
+ F.unbindEvents();
697
+
698
+ F.isOpen = false;
699
+ F.current = F.coming;
700
+ F.coming = false;
701
+
702
+ //Build the neccessary markup
703
+ F.wrap = $(F.current.tpl.wrap).addClass('fancybox-tmp ' + F.current.wrapCSS).appendTo('body');
704
+ F.outer = $('.fancybox-outer', F.wrap).css('padding', F.current.padding + 'px');
705
+ F.inner = $('.fancybox-inner', F.wrap);
706
+
707
+ F._setContent();
708
+
709
+ //Give a chance for helpers or callbacks to update elements
710
+ F.trigger('beforeShow');
711
+
712
+ //Set initial dimensions and hide
713
+ F._setDimension();
714
+
715
+ F.wrap.hide().removeClass('fancybox-tmp');
716
+
717
+ F.bindEvents();
718
+ F._preload();
719
+
720
+ F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
721
+ },
722
+
723
+ _setContent: function () {
724
+ var content, loadingBay, current = F.current,
725
+ type = current.type;
726
+
727
+ switch (type) {
728
+ case 'inline':
729
+ case 'ajax':
730
+ case 'html':
731
+ content = current.content;
732
+
733
+ if (type === 'inline' && content instanceof $) {
734
+ content = content.show().detach();
735
+
736
+ if (content.parent().hasClass('fancybox-inner')) {
737
+ content.parents('.fancybox-wrap').trigger('onReset').remove();
738
+ }
739
+
740
+ $(F.wrap).bind('onReset', function () {
741
+ content.appendTo('body').hide();
742
+ });
743
+ }
744
+
745
+ if (current.autoSize) {
746
+ loadingBay = $('<div class="fancybox-tmp"></div>').appendTo($("body")).append(content);
747
+
748
+ current.width = loadingBay.outerWidth();
749
+ current.height = loadingBay.outerHeight(true);
750
+
751
+ content = loadingBay.contents().detach();
752
+
753
+ loadingBay.remove();
754
+ }
755
+
756
+ break;
757
+
758
+ case 'image':
759
+ content = current.tpl.image.replace('{href}', current.href);
760
+
761
+ current.aspectRatio = true;
762
+ break;
763
+
764
+ case 'swf':
765
+ content = current.tpl.swf.replace(/\{width\}/g, current.width).replace(/\{height\}/g, current.height).replace(/\{href\}/g, current.href);
766
+ break;
767
+
768
+ case 'iframe':
769
+ content = current.tpl.iframe.replace('{href}', current.href).replace('{scrolling}', current.scrolling).replace('{rnd}', new Date().getTime());
770
+ break;
771
+ }
772
+
773
+ if ($.inArray(type, ['image', 'swf', 'iframe']) > -1) {
774
+ current.autoSize = false;
775
+ current.scrolling = false;
776
+ }
777
+
778
+ F.inner.append(content);
779
+ },
780
+
781
+ _setDimension: function () {
782
+ var wrap = F.wrap,
783
+ outer = F.outer,
784
+ inner = F.inner,
785
+ current = F.current,
786
+ viewport = F.getViewport(),
787
+ margin = current.margin,
788
+ padding2 = current.padding * 2,
789
+ width = current.width + padding2,
790
+ height = current.height + padding2,
791
+ ratio = current.width / current.height,
792
+
793
+ maxWidth = current.maxWidth,
794
+ maxHeight = current.maxHeight,
795
+ minWidth = current.minWidth,
796
+ minHeight = current.minHeight,
797
+ height_,
798
+ space;
799
+
800
+ viewport.w -= (margin[1] + margin[3]);
801
+ viewport.h -= (margin[0] + margin[2]);
802
+
803
+ if (width.toString().indexOf('%') > -1) {
804
+ width = ((viewport.w * parseFloat(width)) / 100);
805
+ }
806
+
807
+ if (height.toString().indexOf('%') > -1) {
808
+ height = ((viewport.h * parseFloat(height)) / 100);
809
+ }
810
+
811
+ if (current.fitToView) {
812
+ maxWidth = Math.min(viewport.w, maxWidth);
813
+ maxHeight = Math.min(viewport.h, maxHeight);
814
+ }
815
+
816
+ minWidth = Math.min(width, minWidth);
817
+ minHeight = Math.min(width, minHeight);
818
+
819
+ maxWidth = Math.max(minWidth, maxWidth);
820
+ maxHeight = Math.max(minHeight, maxHeight);
821
+
822
+ if (current.aspectRatio) {
823
+ if (width > maxWidth) {
824
+ width = maxWidth;
825
+ height = ((width - padding2) / ratio) + padding2;
826
+ }
827
+
828
+ if (height > maxHeight) {
829
+ height = maxHeight;
830
+ width = ((height - padding2) * ratio) + padding2;
831
+ }
832
+
833
+ if (width < minWidth) {
834
+ width = minWidth;
835
+ height = ((width - padding2) / ratio) + padding2;
836
+ }
837
+
838
+ if (height < minHeight) {
839
+ height = minHeight;
840
+ width = ((height - padding2) * ratio) + padding2;
841
+ }
842
+
843
+ } else {
844
+ width = Math.max(minWidth, Math.min(width, maxWidth));
845
+ height = Math.max(minHeight, Math.min(height, maxHeight));
846
+ }
847
+
848
+ width = Math.round(width);
849
+ height = Math.round(height);
850
+
851
+ //Reset dimensions
852
+ $(wrap.add(outer).add(inner)).width('auto').height('auto');
853
+
854
+ inner.width(width - padding2).height(height - padding2);
855
+ wrap.width(width);
856
+
857
+ height_ = wrap.height(); // Real wrap height
858
+
859
+ //Fit wrapper inside
860
+ if (width > maxWidth || height_ > maxHeight) {
861
+ while ((width > maxWidth || height_ > maxHeight) && width > minWidth && height_ > minHeight) {
862
+ height = height - 10;
863
+
864
+ if (current.aspectRatio) {
865
+ width = Math.round(((height - padding2) * ratio) + padding2);
866
+
867
+ if (width < minWidth) {
868
+ width = minWidth;
869
+ height = ((width - padding2) / ratio) + padding2;
870
+ }
871
+
872
+ } else {
873
+ width = width - 10;
874
+ }
875
+
876
+ inner.width(width - padding2).height(height - padding2);
877
+ wrap.width(width);
878
+
879
+ height_ = wrap.height();
880
+ }
881
+ }
882
+
883
+ current.dim = {
884
+ width: width,
885
+ height: height_
886
+ };
887
+
888
+ current.canGrow = current.autoSize && height > minHeight && height < maxHeight;
889
+ current.canShrink = false;
890
+ current.canExpand = false;
891
+
892
+ if ((width - padding2) < current.width || (height - padding2) < current.height) {
893
+ current.canExpand = true;
894
+
895
+ } else if ((width > viewport.w || height_ > viewport.h) && width > minWidth && height > minHeight) {
896
+ current.canShrink = true;
897
+ }
898
+
899
+ space = height_ - padding2;
900
+
901
+ F.innerSpace = space - inner.height();
902
+ F.outerSpace = space - outer.height();
903
+ },
904
+
905
+ _getPosition: function (a) {
906
+ var current = F.current,
907
+ viewport = F.getViewport(),
908
+ margin = current.margin,
909
+ width = F.wrap.width() + margin[1] + margin[3],
910
+ height = F.wrap.height() + margin[0] + margin[2],
911
+ rez = {
912
+ position: 'absolute',
913
+ top: margin[0] + viewport.y,
914
+ left: margin[3] + viewport.x
915
+ };
916
+
917
+ if (current.fixed && (!a || a[0] === false) && height <= viewport.h && width <= viewport.w) {
918
+ rez = {
919
+ position: 'fixed',
920
+ top: margin[0],
921
+ left: margin[3]
922
+ };
923
+ }
924
+
925
+ rez.top = Math.ceil(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))) + 'px';
926
+ rez.left = Math.ceil(Math.max(rez.left, rez.left + ((viewport.w - width) * 0.5))) + 'px';
927
+
928
+ return rez;
929
+ },
930
+
931
+ _afterZoomIn: function () {
932
+ var current = F.current;
933
+
934
+ F.isOpen = F.isOpened = true;
935
+
936
+ F.wrap.addClass('fancybox-opened').css('overflow', 'visible');
937
+
938
+ F.update();
939
+
940
+ F.inner.css('overflow', current.scrolling === 'auto' ? 'auto' : (current.scrolling === 'yes' ? 'scroll' : 'hidden'));
941
+
942
+ //Assign a click event
943
+ if (current.closeClick || current.nextClick) {
944
+ F.inner.css('cursor', 'pointer').bind('click.fb', current.nextClick ? F.next : F.close);
945
+ }
946
+
947
+ //Create a close button
948
+ if (current.closeBtn) {
949
+ $(current.tpl.closeBtn).appendTo(F.wrap).bind('click.fb', F.close);
950
+ }
951
+
952
+ //Create navigation arrows
953
+ if (current.arrows && F.group.length > 1) {
954
+ if (current.loop || current.index > 0) {
955
+ $(current.tpl.prev).appendTo(F.wrap).bind('click.fb', F.prev);
956
+ }
957
+
958
+ if (current.loop || current.index < F.group.length - 1) {
959
+ $(current.tpl.next).appendTo(F.wrap).bind('click.fb', F.next);
960
+ }
961
+ }
962
+
963
+ F.trigger('afterShow');
964
+
965
+ if (F.opts.autoPlay && !F.player.isActive) {
966
+ F.opts.autoPlay = false;
967
+
968
+ F.play();
969
+ }
970
+ },
971
+
972
+ _afterZoomOut: function () {
973
+ F.trigger('afterClose');
974
+
975
+ F.wrap.trigger('onReset').remove();
976
+
977
+ $.extend(F, {
978
+ group: {},
979
+ opts: {},
980
+ current: null,
981
+ isOpened: false,
982
+ isOpen: false,
983
+ wrap: null,
984
+ outer: null,
985
+ inner: null
986
+ });
987
+ }
988
+ });
989
+
990
+ /*
991
+ * Default transitions
992
+ */
993
+
994
+ F.transitions = {
995
+ getOrigPosition: function () {
996
+ var element = F.current.element,
997
+ pos = {},
998
+ width = 50,
999
+ height = 50,
1000
+ image, viewport;
1001
+
1002
+ if (element && element.nodeName && $(element).is(':visible')) {
1003
+ image = $(element).find('img:first');
1004
+
1005
+ if (image.length) {
1006
+ pos = image.offset();
1007
+ width = image.outerWidth();
1008
+ height = image.outerHeight();
1009
+
1010
+ } else {
1011
+ pos = $(element).offset();
1012
+ }
1013
+
1014
+ } else {
1015
+ viewport = F.getViewport();
1016
+ pos.top = viewport.y + (viewport.h - height) * 0.5;
1017
+ pos.left = viewport.x + (viewport.w - width) * 0.5;
1018
+ }
1019
+
1020
+ pos = {
1021
+ top: Math.ceil(pos.top) + 'px',
1022
+ left: Math.ceil(pos.left) + 'px',
1023
+ width: Math.ceil(width) + 'px',
1024
+ height: Math.ceil(height) + 'px'
1025
+ };
1026
+
1027
+ return pos;
1028
+ },
1029
+
1030
+ step: function (now, fx) {
1031
+ var ratio, innerValue, outerValue;
1032
+
1033
+ if (fx.prop === 'width' || fx.prop === 'height') {
1034
+ innerValue = outerValue = Math.ceil(now - (F.current.padding * 2));
1035
+
1036
+ if (fx.prop === 'height') {
1037
+ ratio = (now - fx.start) / (fx.end - fx.start);
1038
+
1039
+ if (fx.start > fx.end) {
1040
+ ratio = 1 - ratio;
1041
+ }
1042
+
1043
+ innerValue -= F.innerSpace * ratio;
1044
+ outerValue -= F.outerSpace * ratio;
1045
+ }
1046
+
1047
+ F.inner[fx.prop](innerValue);
1048
+ F.outer[fx.prop](outerValue);
1049
+ }
1050
+ },
1051
+
1052
+ zoomIn: function () {
1053
+ var wrap = F.wrap,
1054
+ current = F.current,
1055
+ startPos,
1056
+ endPos,
1057
+ dim = current.dim;
1058
+
1059
+ if (current.openEffect === 'elastic') {
1060
+ endPos = $.extend({}, dim, F._getPosition(true));
1061
+
1062
+ //Remove "position" property
1063
+ delete endPos.position;
1064
+
1065
+ startPos = this.getOrigPosition();
1066
+
1067
+ if (current.openOpacity) {
1068
+ startPos.opacity = 0;
1069
+ endPos.opacity = 1;
1070
+ }
1071
+
1072
+ wrap.css(startPos).show().animate(endPos, {
1073
+ duration: current.openSpeed,
1074
+ easing: current.openEasing,
1075
+ step: this.step,
1076
+ complete: F._afterZoomIn
1077
+ });
1078
+
1079
+ } else {
1080
+ wrap.css($.extend({}, dim, F._getPosition()));
1081
+
1082
+ if (current.openEffect === 'fade') {
1083
+ wrap.fadeIn(current.openSpeed, F._afterZoomIn);
1084
+
1085
+ } else {
1086
+ wrap.show();
1087
+ F._afterZoomIn();
1088
+ }
1089
+ }
1090
+ },
1091
+
1092
+ zoomOut: function () {
1093
+ var wrap = F.wrap,
1094
+ current = F.current,
1095
+ endPos;
1096
+
1097
+ if (current.closeEffect === 'elastic') {
1098
+ if (wrap.css('position') === 'fixed') {
1099
+ wrap.css(F._getPosition(true));
1100
+ }
1101
+
1102
+ endPos = this.getOrigPosition();
1103
+
1104
+ if (current.closeOpacity) {
1105
+ endPos.opacity = 0;
1106
+ }
1107
+
1108
+ wrap.animate(endPos, {
1109
+ duration: current.closeSpeed,
1110
+ easing: current.closeEasing,
1111
+ step: this.step,
1112
+ complete: F._afterZoomOut
1113
+ });
1114
+
1115
+ } else {
1116
+ wrap.fadeOut(current.closeEffect === 'fade' ? current.closeSpeed : 0, F._afterZoomOut);
1117
+ }
1118
+ },
1119
+
1120
+ changeIn: function () {
1121
+ var wrap = F.wrap,
1122
+ current = F.current,
1123
+ startPos;
1124
+
1125
+ if (current.nextEffect === 'elastic') {
1126
+ startPos = F._getPosition(true);
1127
+ startPos.opacity = 0;
1128
+ startPos.top = (parseInt(startPos.top, 10) - 200) + 'px';
1129
+
1130
+ wrap.css(startPos).show().animate({
1131
+ opacity: 1,
1132
+ top: '+=200px'
1133
+ }, {
1134
+ duration: current.nextSpeed,
1135
+ complete: F._afterZoomIn
1136
+ });
1137
+
1138
+ } else {
1139
+ wrap.css(F._getPosition());
1140
+
1141
+ if (current.nextEffect === 'fade') {
1142
+ wrap.hide().fadeIn(current.nextSpeed, F._afterZoomIn);
1143
+
1144
+ } else {
1145
+ wrap.show();
1146
+ F._afterZoomIn();
1147
+ }
1148
+ }
1149
+ },
1150
+
1151
+ changeOut: function () {
1152
+ var wrap = F.wrap,
1153
+ current = F.current,
1154
+ cleanUp = function () {
1155
+ $(this).trigger('onReset').remove();
1156
+ };
1157
+
1158
+ wrap.removeClass('fancybox-opened');
1159
+
1160
+ if (current.prevEffect === 'elastic') {
1161
+ wrap.animate({
1162
+ 'opacity': 0,
1163
+ top: '+=200px'
1164
+ }, {
1165
+ duration: current.prevSpeed,
1166
+ complete: cleanUp
1167
+ });
1168
+
1169
+ } else {
1170
+ wrap.fadeOut(current.prevEffect === 'fade' ? current.prevSpeed : 0, cleanUp);
1171
+ }
1172
+ }
1173
+ };
1174
+
1175
+ /*
1176
+ * Overlay helper
1177
+ */
1178
+
1179
+ F.helpers.overlay = {
1180
+ overlay: null,
1181
+
1182
+ update: function () {
1183
+ var width, scrollWidth, offsetWidth;
1184
+
1185
+ //Reset width/height so it will not mess
1186
+ this.overlay.width(0).height(0);
1187
+
1188
+ if ($.browser.msie) {
1189
+ scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
1190
+ offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1191
+
1192
+ width = scrollWidth < offsetWidth ? W.width() : scrollWidth;
1193
+
1194
+ } else {
1195
+ width = D.width();
1196
+ }
1197
+
1198
+ this.overlay.width(width).height(D.height());
1199
+ },
1200
+
1201
+ beforeShow: function (opts) {
1202
+ if (this.overlay) {
1203
+ return;
1204
+ }
1205
+
1206
+ this.overlay = $('<div id="fancybox-overlay"></div>').css(opts.css || {
1207
+ background: 'black'
1208
+ }).appendTo('body');
1209
+
1210
+ this.update();
1211
+
1212
+ if (opts.closeClick) {
1213
+ this.overlay.bind('click.fb', F.close);
1214
+ }
1215
+
1216
+ W.bind("resize.fb", $.proxy(this.update, this));
1217
+
1218
+ this.overlay.fadeTo(opts.speedIn || "fast", opts.opacity || 1);
1219
+ },
1220
+
1221
+ onUpdate: function () {
1222
+ //Update as content may change document dimensions
1223
+ this.update();
1224
+ },
1225
+
1226
+ afterClose: function (opts) {
1227
+ if (this.overlay) {
1228
+ this.overlay.fadeOut(opts.speedOut || "fast", function () {
1229
+ $(this).remove();
1230
+ });
1231
+ }
1232
+
1233
+ this.overlay = null;
1234
+ }
1235
+ };
1236
+
1237
+ /*
1238
+ * Title helper
1239
+ */
1240
+
1241
+ F.helpers.title = {
1242
+ beforeShow: function (opts) {
1243
+ var title, text = F.current.title;
1244
+
1245
+ if (text) {
1246
+ title = $('<div class="fancybox-title fancybox-title-' + opts.type + '-wrap">' + text + '</div>').appendTo('body');
1247
+
1248
+ if (opts.type === 'float') {
1249
+ //This helps for some browsers
1250
+ title.width(title.width());
1251
+
1252
+ title.wrapInner('<span class="child"></span>');
1253
+
1254
+ //Increase bottom margin so this title will also fit into viewport
1255
+ F.current.margin[2] += Math.abs(parseInt(title.css('margin-bottom'), 10));
1256
+ }
1257
+
1258
+ title.appendTo(opts.type === 'over' ? F.inner : (opts.type === 'outside' ? F.wrap : F.outer));
1259
+ }
1260
+ }
1261
+ };
1262
+
1263
+ // jQuery plugin initialization
1264
+ $.fn.fancybox = function (options) {
1265
+ var opts = options || {},
1266
+ selector = this.selector || '';
1267
+
1268
+ function run(e) {
1269
+ var group = [], relType, relVal, rel = this.rel;
1270
+
1271
+ if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
1272
+ e.preventDefault();
1273
+
1274
+ relVal = $(this).data('fancybox-group');
1275
+
1276
+ // Check if element has 'data-fancybox-group' attribute, if not - use 'rel'
1277
+ if (typeof relVal !== 'undefined') {
1278
+ relType = relVal ? 'data-fancybox-group' : false;
1279
+
1280
+ } else if (rel && rel !== '' && rel !== 'nofollow') {
1281
+ relVal = rel;
1282
+ relType = 'rel';
1283
+ }
1284
+
1285
+ if (relType) {
1286
+ group = selector.length ? $(selector).filter('[' + relType + '="' + relVal + '"]') : $('[' + relType + '="' + relVal + '"]');
1287
+ }
1288
+
1289
+ if (group.length) {
1290
+ opts.index = group.index(this);
1291
+
1292
+ F.open(group.get(), opts);
1293
+
1294
+ } else {
1295
+ F.open(this, opts);
1296
+ }
1297
+ }
1298
+ }
1299
+
1300
+ if (selector) {
1301
+ D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);
1302
+
1303
+ } else {
1304
+ $(this).unbind('click.fb-start').bind('click.fb-start', run);
1305
+ }
1306
+
1307
+ return this;
1308
+ };
1309
+
1310
+ }(window, document, jQuery));