PageSourceSearch

https://www.hfsp.org/modules/custom/md_slider/assets/js/frontend/md-slider.js?tm4mzs

js hfsp.org collected 2026-10-01 09:12:50 UTC 92,516 bytes, 2,091 lines download raw bytes

1
2(function ($) {
3    var transitionEffects = [
4            "slit-horizontal-left-top",
5            "slit-horizontal-top-right",
6            "slit-horizontal-bottom-up",
7            "slit-vertical-down",
8            "slit-vertical-up",
9            "strip-up-right",
10            "strip-up-left",
11            "strip-down-right",
12            "strip-down-left",
13            "strip-left-up",
14            "strip-left-down",
15            "strip-right-up",
16            "strip-right-down",
17            "strip-right-left-up",
18            "strip-right-left-down",
19            "strip-up-down-right",
20            "strip-up-down-left",
21            "left-curtain",
22            "right-curtain",
23            "top-curtain",
24            "bottom-curtain",
25            "slide-in-right",
26            "slide-in-left",
27            "slide-in-up",
28            "slide-in-down",
29            "fade"
30        ],
31        effectsIn = [
32            "bounceIn",
33            "bounceInDown",
34            "bounceInUp",
35            "bounceInLeft",
36            "bounceInRight",
37            "fadeIn",
38            "fadeInUp",
39            "fadeInDown",
40            "fadeInLeft",
41            "fadeInRight",
42            "fadeInUpBig",
43            "fadeInDownBig",
44            "fadeInLeftBig",
45            "fadeInRightBig",
46            "flipInX",
47            "flipInY",
48            "foolishIn",
49            "lightSpeedIn",
50            "puffIn",
51            "rollIn",
52            "rotateIn",
53            "rotateInDownLeft",
54            "rotateInDownRight",
55            "rotateInUpLeft",
56            "rotateInUpRight",
57            "twisterInDown",
58            "twisterInUp",
59            "swap",
60            "swashIn",
61            "tinRightIn",
62            "tinLeftIn",
63            "tinUpIn",
64            "tinDownIn",
65            "vanishIn"
66        ],
67        effectsOut = [
68            "bombRightOut",
69            "bombLeftOut",
70            "bounceOut",
71            "bounceOutDown",
72            "bounceOutUp",
73            "bounceOutLeft",
74            "bounceOutRight",
75            "fadeOut",
76            "fadeOutUp",
77            "fadeOutDown",
78            "fadeOutLeft",
79            "fadeOutRight",
80            "fadeOutUpBig",
81            "fadeOutDownBig",
82            "fadeOutLeftBig",
83            "fadeOutRightBig",
84            "flipOutX",
85            "flipOutY",
86            "foolishOut",
87            "hinge",
88            "holeOut",
89            "lightSpeedOut",
90            "puffOut",
91            "rollOut",
92            "rotateOut",
93            "rotateOutDownLeft",
94            "rotateOutDownRight",
95            "rotateOutUpLeft",
96            "rotateOutUpRight",
97            "rotateDown",
98            "rotateUp",
99            "rotateLeft",
100            "rotateRight",
101            "swashOut",
102            "tinRightOut",
103            "tinLeftOut",
104            "tinUpOut",
105            "tinDownOut",
106            "vanishOut"
107        ];
108    var MDSlider = function ($element, options) {
109        var default_options = {
110            autoPlay: true,
111            loop: true,
112            width: 960,
113            height: 420,
114            responsive: true,
115            fullWidth: true,
116            pauseOnHover: true,
117            enableLoadingBar: true,
118            loadingBarPosition: 1,
119            enableNextPrevButton: true,
120            hoverNextPrevButton: true,
121            enableKeyNavigation: true,
122            enableBullet: false,
123            bulletPosition: 2,
124            hoverBullet: 0,
125            enableThumbnail: true,
126            thumbnailPosition: 3,
127            thumbnailWidth: 80,
128            thumbnailHeight: 50,
129            enableBorderStyle: false,
130            borderStyle: 1, // from 1-9
131            enableDropShadow: false,
132            dropShadowStyle: 1, // from 1 - 5
133            enableDrag: true, // Allow mouse drag to change slide
134            defaultTransitions: "fade", // Default transition effect when slide transition effect not choose
135            defaultTransitionSpeed: 1000, // Default time to play transition slide effect. Calculate by milliseconds
136            defaultSlideTime: 6000, // Default time for slides (millisecond)
137            stripCols: 20,
138            stripRows: 10,
139            touchSensitive: 50,
140            onInit: function () {
141            },	// this callback is invoked when init slide show
142            onEndTransition: function () {
143            },	// this callback is invoked when the transition effect ends
144            onStartTransition: function () {
145            },	// this callback is invoked when the transition effect starts
146            lightBoxVideoWidth: 640,
147            lightBoxVideoHeight: 350,
148            lightBoxOverlay: 0.8,
149            onVideoClick: function () {
150            }
151        }
152
153        this.slider = $element;
154        this.options = $.extend(default_options, options);
155        this.slideTime = this.options.defaultSlideTime;
156        this.slides = [];
157        this.playTime = 0;
158        this.timeUnit = 40;
159        this.itemsTimer = [];
160        this.active = -1;
161        this.prev = -1;
162        this.numberSlides = 0;
163        this.hasTouch = ("ontouchstart" in window || "createTouch" in document);
164        this.width = 0;
165        this.height = 0;
166        this.lock = false;
167        this.pause = false;
168        this.supportCss3 = (window.Modernizr.csstransitions && window.Modernizr.csstransforms3d);
169        this.tooltipDistance = 50;
170
171        this.init();
172    }
173    MDSlider.prototype = {
174        constructor: MDSlider,
175        init: function () {
176            var self = this,
177                inActiveTime = false;
178
179            // Add class loading-image to start initialize for slide show
180            this.slider.addClass("loading-image");
181
182            // Create wrap element for slide show
183            this.slider.wrap('<div class="md-slider-wrap"><div class="md-slide-wrap"></div></div>');
184            this.wrap = this.slider.parent().parent();
185            this.wrap.addClass(this.slider.attr("id") + "-wrap");
186
187            // Init slide show classes configure
188            if (this.options.responsive)
189                this.wrap.addClass("md-slider-responsive");
190            if (this.options.fullWidth)
191                this.wrap.addClass("md-slider-full-width");
192
193            if (this.options.responsive && !this.options.fullWidth)
194                this.wrap.css("max-width", this.options.width + "px");
195
196            if (this.options.enableBullet && this.options.bulletPosition)
197                this.wrap.addClass("md-slider-bullet-" + this.options.bulletPosition);
198            if (!this.options.enableBullet && this.options.enableThumbnail && this.options.thumbnailPosition);
199            this.wrap.addClass("md-slider-thumb-" + this.options.thumbnailPosition);
200
201            // Initialize width and height of slide
202            this.width = (this.options.responsive) ? this.slider.width() : this.options.width;
203            this.height = this.options.height;
204
205            // Initialize slides
206            this.numberSlides = $(".md-slide-item", this.slider).length;
207            $(".md-slide-item", this.slider).each(function (index) {
208                self.slides[index] = $(this);
209
210                // Initialize for items in slide
211                $(".md-object", $(this)).each(function () {
212                    var top = $(this).data("y") ? $(this).data("y") : 0,
213                        left = $(this).data("x") ? $(this).data("x") : 0,
214                        width = $(this).data("width") ? $(this).data("width") : 0,
215                        height = $(this).data("height") ? $(this).data("height") : 0;
216                    width = 100 * width/self.options.width;
217                    height = 100 * height / self.options.height;
218
219                    top = 100 * top/self.options.height;
220                    left = 100 * left / self.options.width;
221
222                    if (width > 0)
223                        $(this).width(width + "%");
224                    if (height > 0)
225                        $(this).height(height + "%");
226
227                    $(this).css({top: top + "%", left: left + "%"});
228                    $(this).hide();
229                });
230                if (index > 0)
231                    $(this).hide();
232            });
233
234            // Load slide show elements
235            this.initControl();
236            this.initDrag();
237            this.initVideo();
238            this.initHotSpot();
239
240            // Load images to play slide
241            this.loadImages();
242            this.removeLoader();
243            //
244
245            // Invoke custom init callback
246            this.options.onInit.call(self.slider);
247
248            // process when un-active tab
249            $(window).blur(function () {
250                inActiveTime = (new Date()).getTime();
251            });
252            $(window).focus(function () {
253                if (inActiveTime) {
254                    var duration = (new Date()).getTime() - inActiveTime;
255
256                    if (duration > self.slideTime - self.playTime)
257                        self.playTime = self.slideTime - 200;
258                    else
259                        self.playTime += duration;
260                    inActiveTime = false;
261                }
262            });
263
264            $(window).resize(function () {
265                self.resize();
266            }).trigger("resize");
267        },
268        initControl: function () {
269            var self = this;
270
271            // Initialize loading bar
272            if (this.options.enableLoadingBar) {
273                var loadingContainer = $('<div class="loading-bar-hoz loading-bar-' + this.options.loadingBarPosition + '"><div class="br-timer-glow" style="left: -100px;"></div><div class="br-timer-bar" style="width:0px"></div></div>');
274                this.wrap.append(loadingContainer);
275            }
276
277            // Initialize pause on hover
278            if (this.options.pauseOnHover) {
279                $(".md-slide-wrap", this.wrap).mouseenter(function () {
280                    self.pauseSlide();
281                });
282                $(".md-slide-wrap", this.wrap).mouseleave(function () {
283                    self.unPauseSlide();
284                });
285            }
286
287            // Initialize border
288            if (this.options.enableBorderStyle && this.options.borderStyle) {
289                var borderDivs = '<div class="border-top border-style-' + this.options.borderStyle + '"></div><div class="border-bottom border-style-' + this.options.borderStyle + '"></div>';
290
291                if (!this.options.fullWidth) {
292                    borderDivs += '<div class="border-left border-style-' + this.options.borderStyle + '"><div class="edge-top"></div><div class="edge-bottom"></div></div>';
293                    borderDivs += '<div class="border-right border-style-' + this.options.borderStyle + '"><div class="edge-top"></div><div class="edge-bottom"></div></div>';
294                }
295                this.wrap.append(borderDivs);
296            }
297
298            // Initialize for shadow
299            if (this.options.enableDropShadow && this.options.dropShadowStyle) {
300                var shadowDiv = '<div class="md-shadow md-shadow-style-' + this.options.dropShadowStyle + '"></div>';
301                this.wrap.append(shadowDiv);
302            }
303
304            // Initialize bullets
305            if (this.options.enableBullet && this.options.bulletPosition) {
306                var $bullets = $('<div class="md-bullets"></div>');
307                $(".md-slide-wrap", this.wrap).append($bullets);
308
309                for (var i = 0; i < this.numberSlides; i++) {
310                    $bullets.append('<div class="md-bullet"  rel="' + i + '"><a></a></div>');
311                }
312
313                if (this.options.hoverBullet) {
314                    $bullets.css("opacity", 0);
315                    $(".md-slide-wrap", this.wrap).hover(
316                        function () {
317                            $bullets.stop().animate({opacity: 1.0}, "fast");
318                        },
319                        function () {
320                            $bullets.stop().animate({opacity: 0}, "fast");
321                        }
322                    );
323                }
324
325                // Show thumbnail is set => Hover bullet would be show thumbnail
326                if (this.options.enableThumbnail) {
327                    var thumbW = parseInt(this.slider.data("thumb-width")),
328                        thumbH = parseInt(this.slider.data("thumb-height"));
329
330                    for (var i = 0; i < this.numberSlides; i++) {
331                        var thumbSrc = this.slides[i].data("thumb"),
332                            thumbType = this.slides[i].data("thumb-type"),
333                            thumbAlt = this.slides[i].data("thumb-alt");
334                        if (thumbSrc) {
335                            var thumb;
336                            if (thumbType == "image")
337                                thumb = $('<img />').attr("src", thumbSrc).attr("alt", this.slides[i].data("thumb-alt")).css({
338                                    top: -(9 + thumbH) + "px",
339                                    left: -(thumbW / 2 - 2) + "px",
340                                    opacity: 0
341                                })
342                            else
343                                thumb = $("<span></span>").attr("style", thumbSrc).css({
344                                    top: -(9 + thumbH) + "px",
345                                    left: -(thumbW / 2 - 2) + "px",
346                                    opacity: 0
347                                });
348                            $("div.md-bullet:eq(" + i + ")", $bullets).append(thumb).append('<div class="md-thumb-arrow" style="opacity: 0"></div>');
349                        }
350                    }
351                    $("div.md-bullet", $bullets).hover(
352                        function () {
353                            $(this).addClass("md-hover");
354                            $("img, span", this).show().animate({'opacity': 1}, 200);
355                            $('.md-thumb-arrow', this).show().animate({'opacity': 1}, 200);
356                        },
357                        function () {
358                            $(this).removeClass('md_hover');
359                            $('img, span', this).animate({'opacity': 0}, 200, function () {
360                                $(this).hide();
361                            });
362                            $('.md-thumb-arrow', this).animate({'opacity': 0}, 200, function () {
363                                $(this).hide();
364                            });
365                        }
366                    );
367                }
368                $("div.md-bullet", this.wrap).click(function () {
369                    if ($(this).hasClass("md-current"))
370                        return false;
371
372                    self.slide($(this).attr("rel"));
373                });
374            }
375            else if (this.options.enableThumbnail && this.options.thumbnailPosition) {
376                var $thumbnailContainer = $('<div class="md-thumb"><div class="md-thumb-container"><div class="md-thumb-items"></div></div></div>'),
377                    $thumbnails = $(".md-thumb-items", $thumbnailContainer);
378
379                for (var i = 0; i < this.numberSlides; i++) {
380                    var thumbSrc = this.slides[i].data("thumb");
381                    if (thumbSrc) {
382                        var link = $('<a class="md-thumb-item" />').attr("rel", i).append($('<img />').attr("src", thumbSrc));
383                        $thumbnails.append(link);
384                    }
385                }
386                this.wrap.append($thumbnailContainer);
387
388                $("a", $thumbnails).click(function () {
389                    if ($(this).hasClass("md-current"))
390                        return false;
391
392                    self.slide($(this).attr("rel"));
393                });
394            }
395
396            // initialize next previous button
397            if (this.options.enableNextPrevButton) {
398                $(".md-slide-wrap", self.wrap).append('<div class="md-arrow"><div class="md-arrow-left"><span></span></div><div class="md-arrow-right"><span></span></div></div>');
399                $(".md-arrow-right", self.wrap).bind("click", function () {
400                    self.nextSlide();
401                });
402                $(".md-arrow-left", self.wrap).bind("click", function () {
403                    self.prevSlide();
404                });
405
406                if (this.options.hoverNextPrevButton) {
407                    $(".md-arrow", self.wrap).css("opacity", 0);
408                    $(".md-slide-wrap", self.wrap).hover(
409                        function () {
410                            $(".md-arrow", self.wrap).stop().animate({opacity: 1}, "fast");
411                        },
412                        function () {
413                            $(".md-arrow", self.wrap).stop().animate({opacity: 0}, "fast");
414                        }
415                    );
416                }
417            }
418
419            // Next, Prev slides with key navigation
420            if (this.options.enableKeyNavigation) {
421                $(window).keydown(function (event) {
422                    var key = event.keyCode || event.which;
423
424                    if (key == 37 || key == 38)
425                        self.nextSlide();
426                    else if (key == 39 || key == 40)
427                        self.prevSlide();
428                });
429            }
430        },
431        initDrag: function () {
432            var self = this,
433                touchStart = false,
434                isScrolling = false,
435                mouseLeft = 0;
436
437            if (this.hasTouch) {
438                this.slider.bind("touchstart", function (event) {
439                    if (touchStart) return false;
440                    event = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0];
441                    touchStart = true;
442                    isScrolling = undefined;
443                    self.slider.mouseY = event.pageY;
444                    self.slider.mouseX = event.pageX;
445                });
446                this.slider.bind("touchmove", function (event) {
447                    event = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0];
448                    if (touchStart) {
449                        var pageX = (event.pageX || event.clientX),
450                            pageY = (event.pageY || event.clientY);
451
452                        if (typeof isScrolling == 'undefined')
453                            isScrolling = !!( isScrolling || Math.abs(pageY - self.slider.mouseY) > Math.abs(pageX - self.slider.mouseX));
454
455                        if (isScrolling)
456                            touchStart = false;
457                        else
458                            mouseLeft = pageX - self.slider.mouseX;
459                    }
460                    return;
461                });
462                this.slider.bind("touchend", function (event) {
463                    if (touchStart) {
464                        touchStart = false;
465
466                        if (mouseLeft > self.options.touchSensitive) {
467                            self.nextSlide();
468                            mouseLeft = 0;
469                        }
470                        else if (mouseLeft < -self.options.touchSensitive) {
471                            self.nextSlide();
472                            mouseLeft = 0;
473                            return false;
474                        }
475                    }
476                });
477            }
478            else {
479                $(".md-slide-wrap", this.wrap).hover(
480                    function () {
481                        if ($(".md-arrow", self.wrap))
482                            $(".md-arrow", self.wrap).stop(true, true).animate({opacity: 1}, 200);
483                    },
484                    function () {
485                        if ($(".md-arrow", self.wrap))
486                            $(".md-arrow", self.wrap).stop(true, true).animate({opacity: 0}, 200);
487                    }
488                ).trigger("hover");
489            }
490
491            if (this.options.enableDrag) {
492                this.slider.mousedown(function (event) {
493                    if (!touchStart) {
494                        touchStart = true;
495                        isScrolling = undefined;
496                        self.slider.mouseY = event.pageY;
497                        self.slider.mouseX = event.pageX;
498                    }
499                    ;
500                    return false;
501                });
502
503                this.slider.mousemove(function (event) {
504                    if (touchStart) {
505                        var pageX = (event.pageX || event.clientX);
506                        var pageY = (event.pageY || event.clientY);
507
508                        if (typeof isScrolling == 'undefined')
509                            isScrolling = !!( isScrolling || Math.abs(pageY - self.slider.mouseY) > Math.abs(pageX - self.slider.mouseX))
510
511                        if (isScrolling)
512                            touchStart = false;
513                        else
514                            mouseLeft = pageX - self.slider.mouseX;
515                    }
516                });
517
518                this.slider.mouseup(function (event) {
519                    if (touchStart) {
520                        touchStart = false;
521
522                        if (mouseLeft > self.options.touchSensitive)
523                            self.prevSlide();
524                        else if (mouseLeft < -self.options.touchSensitive)
525                            self.nextSlide();
526
527                        mouseLeft = 0;
528                        return false;
529                    }
530                });
531                this.slider.mouseleave(function (event) {
532                    self.slider.mouseup();
533                });
534            }
535            ;
536        },
537        initVideo: function () {
538            var self = this;
539
540            $(".md-video", this.slider).each(function () {
541                var $video = $(this),
542                    display = $(this).parent().data("display"),
543                    videoSrc = $video.attr("href")+'?autoplay=1';
544
545                switch (display) {
546                    case "lightbox":
547                        var videoBoxOptions = {
548                            videoWidth: self.options.lightBoxVideoWidth,
549                            videoHeight: self.options.lightBoxVideoHeight,
550                            overlay: self.options.lightBoxOverlay,
551                            onClick: self.options.onVideoClick
552                        }
553                        $(this).mdVideoBox(self, videoBoxOptions);
554                        break;
555
556                    case "full":
557                        var $videoContainer = $('<div class="md-video-control md-loading" style="display: none"></div>');
558
559                        // Add video container
560                        self.wrap.append($videoContainer);
561                        $videoContainer.hover(
562                            function () {
563                                self.pauseSlide();
564                            },
565                            function () {
566                            }
567                        );
568
569                        // Process when click to video
570                        $video.click(function () {
571                            var $closeBtn = $('<a href="#" class="md-close-video" title="close"></a>'),
572                                $videoFrame = $('<iframe frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
573
574                            // Process for close video button click
575                            $closeBtn.click(function () {
576                                $videoContainer.html("").hide();
577                                self.unPauseSlide();
578                                return false;
579                            });
580
581                            // Load video content
582                            $videoFrame.attr("src", videoSrc).css({
583                                width: "100%",
584                                height: "100%"
585                            });
586                            $videoContainer.append($videoFrame).append($closeBtn).show();
587
588                            return false;
589                        });
590                        break;
591
592                    default :
593                        $video.click(function () {
594                            var $videoContainer = $video.parent(),
595                                $videoFrame = $('<iframe frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>');
596
597                            $videoContainer.addClass("md-loading");
598                            $video.hide();
599                            $videoFrame.attr("src", videoSrc);
600                            $videoFrame.css({
601                                width: $videoContainer.width(),
602                                height: $videoContainer.height()
603                            });
604
605                            $videoContainer.append($videoFrame);
606                            return false;
607                        });
608                        break;
609                }
610            });
611        },
612        initHotSpot: function () {
613            var self = this;
614
615            $(".md-object .md-hotspot", this.slider).hover(
616                function () {
617
618                    var $tooltip = $(".md-hotspot-tooltip", $(this).parent()).clone(),
619                        position;
620
621                    self.wrap.append($tooltip);
622                    position = self.getTooltipPosition($(this), $tooltip);
623                    if (position != false) {
624                        self.wrap.append($tooltip);
625                        $tooltip.addClass("active");
626                        $tooltip.addClass(position.class);
627                        $tooltip.offset({
628                            left: position.left,
629                            top: position.top
630                        }).animate({opacity: 1}, "fast");
631                    }
632                },
633                function () {
634                    $(".md-hotspot-tooltip.active", self.wrap).remove();
635                }
636            ).click(function () {
637                    return false;
638                }
639            );
640
641            $(".md-object .transBg-diamond", this.slider).hover(
642                function () {
643                    $(this).addClass("animation");
644                    $(".darkBg-diamond", $(this)).addClass("animation");
645                    $(".hoverBg-diamond", $(this)).addClass("animation");
646                    $(".content-diamond", $(this)).addClass("animation");
647                    $(".transBg-diamond .diamon-title", $(this)).addClass("animation");
648                    $(".border", $(this).parent()).addClass("animation");
649                },
650                function () {
651                    $(this).removeClass("animation");
652                    $(".darkBg-diamond", $(this)).removeClass("animation");
653                    $(".hoverBg-diamond", $(this)).removeClass("animation");
654                    $(".transBg-diamond .diamon-title", $(this)).removeClass("animation");
655                    $(".content-diamond", $(this)).removeClass("animation");
656                    $(".border", $(this).parent()).removeClass("animation");
657                }
658            );
659        },
660        getTooltipPosition: function ($hotSpot, $tooltip) {
661            var $itemObj = $hotSpot.parent(),
662                direction = $itemObj.data("tooltip-direction") ? $itemObj.data("tooltip-direction") : "left",
663                responsive = $itemObj.data("tooltip-responsive") ? $itemObj.data("tooltip-responsive") : 0,
664                position = $hotSpot.offset(),
665                pointWidth = $hotSpot.width(),
666                pointHeight = $hotSpot.height(),
667                width = $tooltip.width(),
668                height = $tooltip.height(),
669                top = 0,
670                left = 0,
671                directionClass = "md-hotspot-tooltip-" + direction;
672
673            if (width > $(window).width())
674                return false;
675
676            if (direction == "auto")
677                return this.autoTooltipPosition($hotSpot, $tooltip);
678            else {
679                switch (direction) {
680                    case "left":
681                        top = position.top - (height - pointHeight) / 2;
682                        left = position.left - width - 10;
683                        $tooltip.offset({
684                            left: left - this.tooltipDistance,
685                            top: top
686                        });
687                        break;
688
689                    case "top":
690                        top = position.top - height - 10;
691                        left = position.left - (width - pointWidth) / 2;
692                        $tooltip.offset({
693                            left: left,
694                            top: top - this.tooltipDistance
695                        });
696                        break;
697
698                    case "right":
699                        top = position.top - (height - pointHeight) / 2;
700                        left = position.left + pointWidth + 10;
701                        $tooltip.offset({
702                            left: left + this.tooltipDistance,
703                            top: top
704                        });
705                        break;
706
707                    case "bottom":
708                        top = position.top + pointHeight + 10;
709                        left = position.left - (width - pointWidth) / 2;
710                        $tooltip.offset({
711                            left: left,
712                            top: top + this.tooltipDistance
713                        });
714                        break;
715                }
716
717                if ((left < 0 || top < 0 || left + width > $(window).width() || top + height > $(window).height()) && responsive)
718                    return this.autoTooltipPosition($hotSpot, $tooltip);
719
720                return {left: left, top: top, class: directionClass};
721            }
722        },
723        autoTooltipPosition: function ($hotSpot, $tooltip) {
724            var $itemObj = $hotSpot.parent(),
725                direction = $itemObj.data("tooltip-direction") ? $itemObj.data("tooltip-direction") : "left",
726                responsive = $itemObj.data("tooltip-responsive") ? $itemObj.data("tooltip-responsive") : 0,
727                position = $hotSpot.offset(),
728                pointWidth = $hotSpot.width(),
729                pointHeight = $hotSpot.height(),
730                width = $tooltip.width(),
731                height = $tooltip.height(),
732                top = position.top - (height - pointHeight) / 2,
733                left = position.left - width - 10,
734                directionClass = "md-hotspot-tooltip-left";
735
736            if (top < 0) {
737                top = position.top + pointHeight + 10;
738                if (top + height > $(window).height())
739                    return false;
740
741                left = position.left - (width - pointWidth) / 2;
742                if (left < 0) {
743                    left = 0;
744                    $(".md-hotspot-tooltip-arrow", $tooltip).css({
745                        top: "-10px",
746                        bottom: "auto",
747                        left: position.left + pointWidth / 2,
748                        right: "auto"
749                    });
750                }
751                else if (left + width > $(window).width()) {
752                    left += ($(window).width() - (left + width));
753                    $(".md-hotspot-tooltip-arrow", $tooltip).css({
754                        top: "-10px",
755                        bottom: "auto",
756                        left: position.left + pointWidth / 2 - left,
757                        right: "auto"
758                    });
759                }
760                directionClass = "md-hotspot-tooltip-bottom";
761                $tooltip.offset({top: top + this.tooltipDistance, left: left});
762            }
763            else {
764                if (left < 0) {
765                    directionClass = "md-hotspot-tooltip-top";
766                    left = position.left - (width - pointWidth) / 2;
767                    top = position.top - height - 10;
768
769                    if (top < 0) {
770                        directionClass = "md-hotspot-tooltip-right";
771                        top = position.top - (height - pointHeight) / 2;
772                        left = position.left + pointWidth + 10;
773
774                        if (left + width > $(window).width()) {
775                            directionClass = "md-hotspot-tooltip-bottom";
776                            top = position.top + pointHeight + 10;
777                            left = position.left + (width - pointWidth) / 2;
778
779                            if (top + height > $(window).height())
780                                return false;
781
782                            if (left < 0) {
783                                left = 0;
784                                $(".md-hotspot-tooltip-arrow", $tooltip).css({
785                                    top: "-10px",
786                                    bottom: "auto",
787                                    left: position.left + pointWidth / 2
788                                });
789                            }
790                            else if (left + width > $(window).width()) {
791                                left += ($(window).width() - (left + width));
792                                $(".md-hotspot-tooltip-arrow", $tooltip).css({
793                                    top: "-10px",
794                                    bottom: "auto",
795                                    left: position.left + pointWidth / 2 - left,
796                                    right: "auto"
797                                });
798                            }
799                            $tooltip.offset({
800                                top: top + this.tooltipDistance,
801                                left: left
802                            });
803                        }
804                        else
805                            $tooltip.offset({
806                                top: top,
807                                left: left + this.tooltipDistance
808                            });
809                    }
810                    else {
811                        if (left < 0) {
812                            left = 0;
813                            $(".md-hotspot-tooltip-arrow", $tooltip).css({
814                                top: "auto",
815                                bottom: "-10px",
816                                left: position.left + pointWidth / 2
817                            });
818                        }
819                        else if (left + width > $(window).width()) {
820                            left += ($(window).width() - (left + width));
821                            $(".md-hotspot-tooltip-arrow", $tooltip).css({
822                                top: "auto",
823                                bottom: "-10px",
824                                left: position.left + pointWidth / 2 - left
825                            });
826                        }
827
828                        $tooltip.offset({
829                            top: top - this.tooltipDistance,
830                            left: left
831                        });
832                    }
833                }
834                else
835                    $tooltip.offset({
836                        top: top,
837                        left: left - this.tooltipDistance
838                    });
839            }
840
841            return {left: left, top: top, class: directionClass}
842        },
843        timer: function () {
844            if (this.lock)
845                return;
846
847            if (!this.pause) {
848                this.playTime += this.timeUnit;
849                if (this.playTime > this.slideTime) {
850                    if (this.options.autoPlay)
851                        this.nextSlide();
852                }
853                else {
854                    if (this.options.enableLoadingBar) {
855                        var width = this.playTime * this.width / this.slideTime;
856                        $(".br-timer-bar", this.wrap).width(width);
857                        $(".br-timer-glow", this.wrap).css({left: width - 100 + "px"});
858                    }
859                }
860            }
861        },
862        play: function () {
863            var self = this;
864
865            this.slider.removeClass("loading-image")
866            this.slide(0);
867            setInterval(function () {
868                self.timer();
869            }, this.timeUnit);
870        },
871        slide: function (index) {
872            index = parseInt(index);
873            if (this.lock)
874                return;
875
876            this.lock = true;
877            this.playTime = 0;
878            this.slideTime = this.slides[index].data("timeout") ? this.slides[index].data("timeout") : this.options.defaultSlideTime;
879            if (this.options.enableLoadingBar) {
880                $(".br-timer-bar", this.wrap).width(0);
881                $(".br-timer-glow", this.wrap).css({left: "-100px"});
882            }
883            this.prev = this.active;
884            this.active = index;
885            // Clear effect classes in slide items
886            $(".md-object", this.slides[this.active]).each(function () {
887                $(this).removeClass(effectsIn.join(" "));
888                $(this).removeClass(effectsOut.join(" "));
889                $(this).hide();
890            });
891
892            // Invoke custom onTransitionBegin
893            this.options.onStartTransition.call(this.slider);
894
895            if (this.slides[this.prev]) {
896                $("div.md-bullet:eq(" + this.prev + ")", this.wrap).removeClass("md-current");
897                $("a:eq(" + this.prev + ")", this.wrap).removeClass("md-current");
898
899                // Clear items timer
900                this.clearItemsTimer();
901
902                // Reset video item with inline display style
903                $(".md-video", this.slides[this.prev]).each(function () {
904                    var $itemObject = $(this).parent();
905                    if (!$itemObject.data("display") || $itemObject.data("display") == "inline")
906                        $("iframe", $itemObject).remove();
907
908                    $(this).show();
909                });
910
911                // Get slide transition effect
912                var fx = this.slides[this.active].data("transition") ? this.slides[this.active].data("transition") : this.options.defaultTransitions;
913                fx = fx.trim();
914
915                if (fx.toLowerCase() == "random") {
916                    fx = transitionEffects[Math.floor(Math.random() * transitionEffects.length)];
917                    if (fx == undefined)
918                        fx = "fade";
919                    fx = $.trim(fx.toLowerCase());
920                }
921                else if (fx.indexOf(",") != -1) {
922                    var transitions = fx.split(",");
923                    fx = transitions[Math.floor(Math.random() * transitions.length)];
924                    if (fx == undefined)
925                        fx = "fade";
926                    fx = $.trim(fx.toLowerCase());
927                }
928
929                if (!this.supportCss3 && fx.indexOf("slit-") != -1)
930                    fx = "fade";
931
932                // Play transition effect
933                this.playTransition(fx);
934                this.setCurrent();
935            }
936            else {
937                this.slides[this.active].css({top: 0, left: 0}).show();
938                this.playSlideItems();
939                this.setCurrent();
940            }
941        },
942        nextSlide: function () {
943            if (this.lock)
944                return;
945
946            var index = this.active + 1;
947            if (index < this.numberSlides)
948                this.slide(index)
949            else if (this.options.loop)
950                this.slide(0);
951        },
952        prevSlide: function () {
953            if (this.lock)
954                return;
955
956            if (this.active - 1 >= 0)
957                this.slide(this.active - 1);
958            else if (this.options.loop)
959                this.slide(this.numberSlides - 1);
960        },
961        pauseSlide: function () {
962            this.pause = true;
963            if (!this.lock)
964                this.clearItemsTimer();
965        },
966        unPauseSlide: function () {
967            this.pause = false;
968            if (!this.lock)
969                this.playSlideItems();
970        },
971        clearItemsTimer: function () {
972            $.each(this.itemsTimer, function (index, timer) {
973                clearTimeout(timer);
974            });
975
976            this.itemsTimer = [];
977        },
978        playSlideItems: function () {
979            var self = this,
980                activeSlide = this.slides[this.active];
981            $(".md-object", activeSlide).each(function () {
982                var $caption = $(this),
983                    inFx = $caption.data("easein") ? $caption.data("easein") : "",
984                    outFx = $caption.data("easeout") ? $caption.data("easeout") : "",
985                    start = $caption.data("start") ? $caption.data("start") : 0,
986                    stop = $caption.data("stop") ? $caption.data("stop") : 0;
987
988                // Get effect in and out
989                if (inFx.toLowerCase() == "random")
990                    inFx = effectsIn[Math.floor(Math.random() * effectsIn.length)];
991                if (outFx.toLowerCase() == "random")
992                    outFx = effectsOut[Math.floor(Math.random() * effectsOut.length)];
993
994                // Process start for slide item
995                if (stop - self.playTime >= 0) {
996                    if (start - self.playTime >= 0) {
997                        // Remove class effect out and hide caption
998                        $caption.removeClass(effectsOut.join(" "));
999                        $caption.removeClass(effectsIn.join(" "));
1000                        $caption.hide();
1001
1002                        var timer = setTimeout(
1003                            function () {
1004                                if (inFx == "" || !self.supportCss3 || (inFx == "shuffleLetter" && !jQuery().shuffleLetters))
1005                                    $caption.show();
1006                                else {
1007                                    if (inFx !== "shuffleLetter") {
1008                                        var fxDuration = $caption.data("duration-in");
1009                                        if (fxDuration != undefined && fxDuration > 0) {
1010                                            $caption.css({
1011                                                "animation-duration": fxDuration + "ms",
1012                                                "-webkit-animation-duration": fxDuration + "ms",
1013                                                "-moz-animation-duration": fxDuration + "ms",
1014                                                "-ms-animation-duration": fxDuration + "ms"
1015                                            });
1016                                        }
1017                                        $caption.show().addClass(inFx);
1018                                    }
1019                                    else {
1020                                        var shuffleLetterOpt = {fps: 25};
1021                                        if (fxDuration && fxDuration > 0) {
1022                                            shuffleLetterOpt.fps = 25/(fxDuration/1000)
1023                                        }
1024                                        $caption.show().shuffleLetters(shuffleLetterOpt);
1025                                    }
1026                                }
1027                            },
1028                            start - self.playTime
1029                        );
1030
1031                        self.itemsTimer.push(timer);
1032                    }
1033                    else
1034                        $caption.show();
1035
1036                    // Process for stop slide item
1037                    if (stop - self.playTime >= 0) {
1038                        var timer = setTimeout(
1039                            function () {
1040                                if (outFx == "" || !self.supportCss3)
1041                                    $caption.fadeOut();
1042                                else {
1043                                    var fxDuration = $caption.data("duration-out");
1044                                    if (fxDuration != undefined && fxDuration > 0) {
1045                                        $caption.css({
1046                                            "animation-duration": fxDuration + "ms",
1047                                            "-webkit-animation-duration": fxDuration + "ms",
1048                                            "-moz-animation-duration": fxDuration + "ms",
1049                                            "-ms-animation-duration": fxDuration + "ms"
1050                                        });
1051                                    }
1052                                    $caption.addClass(outFx);
1053                                }
1054
1055                                $caption.removeClass(inFx);
1056                            },
1057                            stop - self.playTime
1058                        );
1059
1060                        self.itemsTimer.push(timer);
1061                    }
1062                }
1063                else
1064                    $caption.hide();
1065            });
1066            this.lock = false;
1067
1068            if (this.options.pauseOnHover && this.pause)
1069                $(".md-slide-wrap", this.wrap).trigger("mouseenter");
1070        },
1071        loadImages: function () {
1072            var self = this,
1073                count = $(".md-slide-item .md-main-img img", this.slider).length;
1074            if(count){
1075                $(".md-slide-item .md-main-img img", this.slider).each(function () {
1076                    $(this).on('load', function () {
1077                        var $image = $(this);
1078                        if (!$image.data("defW")) {
1079                            var imgSize = self.getImageSize($image.attr("src"));
1080
1081                            self.changeBackgroundPosition($image, imgSize.width, imgSize.height);
1082                            $image.data({
1083                                defW: imgSize.width,
1084                                defH: imgSize.height
1085                            });
1086                        }
1087
1088                    count--;
1089                        if (count == 0)
1090                            self.play();
1091                    });
1092
1093                    if (this.complete)
1094                        $(this).trigger('load');
1095                });
1096            }else{
1097                self.play();
1098            }
1099        },
1100        changeBackgroundPosition: function ($background, width, height) {
1101            var panelWidth = $(".md-slide-item:visible", this.slider).width(),
1102                panelHeight = $(".md-slide-item:visible", this.slider).height();
1103
1104            if (height > 0 && panelHeight > 0) {
1105                if (((width / height) > (panelWidth / panelHeight))) {
1106                    var left = panelWidth - (panelHeight / height) * width;
1107                    $background.css({
1108                        width: "auto",
1109                        height: panelHeight + "px"
1110                    });
1111                    if (left < 0)
1112                        $background.css({left: (left / 2) + "px", top: 0});
1113                    else
1114                        $background.css({left: 0, top: 0});
1115                }
1116                else {
1117                    var top = panelHeight - (panelWidth / width) * height;
1118                    $background.css({width: panelWidth + "px", height: "auto"});
1119                    if (top < 0)
1120                        $background.css({top: (top / 2) + "px", left: 0});
1121                    else
1122                        $background.css({left: 0, top: 0});
1123                }
1124            }
1125        },
1126        getImageSize: function (src) {
1127            var image = new Image();
1128
1129            image.src = src;
1130            return {width: image.width, height: image.height}
1131        },
1132        resize: function () {
1133            this.width = this.options.responsive ? this.wrap.width() : this.options.width;
1134            if (this.options.responsive && (this.width < this.options.width)) {
1135                this.height = Math.round(this.options.height * this.width / this.options.width);
1136            }
1137            else
1138                this.height = this.options.height;
1139
1140            this.wrap.height(this.height);
1141            $(".md-slide-item", this.slider).height(this.height);
1142
1143            if (this.options.fullWidth) {
1144                var bulletSpace = 20;
1145
1146                if ((this.wrap.width() - this.options.width) / 2 > 20)
1147                    bulletSpace = (this.wrap.width() - this.options.width) / 2;
1148
1149                $(".md-bullets", this.wrap).css({
1150                    left: bulletSpace,
1151                    right: bulletSpace
1152                });
1153                $(".md-thumb", this.wrap).css({
1154                    left: bulletSpace,
1155                    right: bulletSpace
1156                });
1157                $(".md-objects", this.slider).width(this.options.width);
1158            }
1159
1160            if (this.options.responsive && this.wrap.width() < this.options.width)
1161                $(".md-objects", this.slider).width(this.width);
1162
1163            this.resizeBackgroundImages();
1164            this.resizeThumbnail();
1165            this.resizeFont();
1166            this.resizePadding();
1167            this.setThumbnailPosition();
1168        },
1169        resizeBackgroundImages: function () {
1170            var self = this;
1171
1172            $(".md-slide-item", this.slider).each(function () {
1173                var $background = $(".md-main-img img", this);
1174                if($background.length){
1175                    if ($background.data("defW") && $background.data("defH")) {
1176                        self.changeBackgroundPosition($background, $background.data("defW"), $background.data("defH"));
1177                    }
1178                }else{
1179                    $(".md-main-img", $(this)).width($(".md-slide-item:visible", self.slider).width()).height($(".md-slide-item:visible", self.slider).height())
1180                }
1181            });
1182        },
1183        resizeThumbnail: function () {
1184            var self = this;
1185
1186            if (this.options.enableThumbnail && !this.options.enableBullet) {
1187                var $thumbnailItems = $(".md-thumb-items", this.wrap),
1188                    thumbnailsWidth = $("a", $thumbnailItems).width() * this.numberSlides,
1189                    $thumbnailContainer = $(".md-thumb", this.wrap);
1190
1191                $thumbnailItems.unbind("touchstart").unbind("touchmove").unbind("touchend").css("left", 0);
1192                $(".md-thumb-next", $thumbnailContainer).remove();
1193                $(".md-thumb-prev", $thumbnailContainer).remove();
1194
1195                if (thumbnailsWidth > $(".md-thumb-container", $thumbnailContainer).width()) {
1196                    var thumbWidthInvisible = $(".md-thumb-container", this.wrap).width() - thumbnailsWidth;
1197
1198                    $thumbnailItems.width(thumbnailsWidth);
1199
1200                    // Add scroll thumbnail button
1201                    $thumbnailContainer.append('<div class="md-thumb-prev"></div><div class="md-thumb-next"></div>');
1202                    $(".md-thumb-prev", $thumbnailContainer).click(function () {
1203                        self.scrollThumbnail("right");
1204                    });
1205                    $(".md-thumb-next", $thumbnailContainer).click(function () {
1206                        self.scrollThumbnail("left");
1207                    });
1208                    this.enableThumbnailArrow(thumbWidthInvisible);
1209
1210                    if (this.hasTouch) {
1211                        var thumbTouch = false,
1212                            thumbLeft = 0;
1213
1214                        $(".md-thumb-items", this.wrap).bind("touchstart", function (event) {
1215                            event = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0];
1216                            thumbTouch = true;
1217                            this.mouseX = event.pageX;
1218                            thumbLeft = $thumbnailItems.position().left;
1219                            return false;
1220                        });
1221                        $thumbnailItems.bind("touchmove", function (event) {
1222                            event.preventDefault();
1223                            event = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0];
1224                            if (thumbTouch)
1225                                $thumbnailItems.css("left", thumbLeft + event.pageX - this.mouseX);
1226
1227                            return false;
1228                        });
1229                        $thumbnailItems.bind("touchend", function (event) {
1230                            event.preventDefault();
1231                            event = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0];
1232                            thumbTouch = false;
1233                            if (Math.abs(event.pageX - this.mouseX) < self.options.touchSensitive) {
1234                                var item = $(event.target).closest("a.md-thumb-item");
1235
1236                                if (item.length)
1237                                    self.slide(item.attr("rel"));
1238
1239                                $thumbnailItems.stop(true, true).animate({left: thumbLeft}, 400);
1240                                return false;
1241                            }
1242
1243                            if ($thumbnailItems.position().left < thumbWidthInvisible)
1244                                $thumbnailItems.stop(true, true).animate({left: thumbWidthInvisible}, 400, function () {
1245                                    self.enableThumbnailArrow(thumbWidthInvisible);
1246                                });
1247                            else if ($thumbnailItems.position().left > 0)
1248                                $thumbnailItems.stop(true, true).animate({left: 0}, 400, function () {
1249                                    self.enableThumbnailArrow(thumbWidthInvisible);
1250                                });
1251
1252                            thumbLeft = 0;
1253                            return false;
1254                        });
1255                    }
1256                }
1257            }
1258        },
1259        scrollThumbnail: function (direction) {
1260            var self = this,
1261                $thumbnailItems = $(".md-thumb-items", this.wrap),
1262                thumbnailsWidth = $("a", $thumbnailItems).width() * this.numberSlides;
1263
1264            if (this.options.enableThumbnail && !this.options.enableBullet) {
1265                var thumbWidthInvisible = $(".md-thumb-container", this.wrap).width() - thumbnailsWidth;
1266
1267                switch (direction) {
1268                    case "left":
1269                        var thumbLeft = $thumbnailItems.position().left;
1270
1271                        if (thumbLeft > thumbWidthInvisible) {
1272                            var containerWidth = $(".md-thumb-container", self.wrap).width();
1273                            if ((thumbLeft - containerWidth) > thumbWidthInvisible)
1274                                $thumbnailItems.stop(true, true).animate({left: thumbLeft - containerWidth}, 400, function () {
1275                                    self.enableThumbnailArrow(thumbWidthInvisible);
1276                                });
1277                            else
1278                                $thumbnailItems.stop(true, true).animate({left: thumbWidthInvisible}, 400, function () {
1279                                    self.enableThumbnailArrow(thumbWidthInvisible)
1280                                });
1281                        }
1282                        break;
1283
1284                    case "right":
1285                        var thumbLeft = $thumbnailItems.position().left;
1286                        if (thumbLeft < 0) {
1287                            var containerWidth = $(".md-thumb-container", self.wrap).width();
1288                            if (thumbLeft + containerWidth < 0)
1289                                $thumbnailItems.stop(true, true).animate({left: thumbLeft + containerWidth}, 400, function () {
1290                                    self.enableThumbnailArrow(thumbWidthInvisible);
1291                                });
1292                            else
1293                                $thumbnailItems.stop(true, true).animate({left: 0}, 400, function () {
1294                                    self.enableThumbnailArrow(thumbWidthInvisible);
1295                                });
1296                        }
1297                        break;
1298
1299                    default :
1300                        var thumbCurrent = $("a", $thumbnailItems).index($("a.md-current", $thumbnailItems));
1301                        if (thumbCurrent >= 0) {
1302                            var thumbLeft = $thumbnailItems.position().left;
1303                            var currentLeft = thumbCurrent * $("a", $thumbnailItems).width();
1304                            if (currentLeft + thumbLeft < 0)
1305                                $thumbnailItems.stop(true, true).animate({left: -currentLeft}, 400, function () {
1306                                    self.enableThumbnailArrow(thumbWidthInvisible);
1307                                });
1308                            else {
1309                                var currentRight = currentLeft + $("a", $thumbnailItems).width(),
1310                                    containerWidth = $(".md-thumb-container", self.wrap).width();
1311
1312                                if (currentRight + thumbLeft > containerWidth)
1313                                    $thumbnailItems.stop(true, true).animate({left: containerWidth - currentRight}, 400, function () {
1314                                        self.enableThumbnailArrow(thumbWidthInvisible);
1315                                    });
1316                            }
1317                        }
1318                        break;
1319                }
1320            }
1321        },
1322        enableThumbnailArrow: function (minThumbsLeft) {
1323            var thumbLeft = $(".md-thumb-items", this.wrap).position().left;
1324
1325            if (thumbLeft > minThumbsLeft)
1326                $(".md-thumb-next", this.wrap).show();
1327            else
1328                $(".md-thumb-next", this.wrap).hide();
1329
1330            if (thumbLeft < 0)
1331                $(".md-thumb-prev", this.wrap).show();
1332            else
1333                $(".md-thumb-prev", this.wrap).hide();
1334        },
1335        setThumbnailPosition: function () {
1336            if (this.options.enableThumbnail && !this.options.enableBullet) {
1337                var thumbHeight = this.slider.data("thumb-height");
1338
1339                if (this.options.thumbnailPosition == 1) {
1340                    var thumbBottom = thumbHeight / 2;
1341                    $(".md-thumb", this.wrap).css({
1342                        height: thumbHeight + 20,
1343                        bottom: -thumbBottom - 10
1344                    });
1345                    this.wrap.css({"margin-bottom": thumbBottom + 10})
1346                }
1347                else {
1348                    $(".md-thumb", this.wrap).css({
1349                        height: thumbHeight + 20,
1350                        bottom: -(thumbHeight + 20)
1351                    });
1352                    this.wrap.css({"margin-bottom": thumbHeight + 50})
1353                }
1354            }
1355        },
1356        resizeFont: function () {
1357            var fontDiff = 1;
1358
1359            if (this.wrap.width() < this.options.width)
1360                $(".md-objects", this.slider).css({"font-size": 100 * this.wrap.width() / this.options.width - fontDiff + "%"});
1361            else
1362                $(".md-objects", this.slider).css({"font-size": 100 - fontDiff + "%"});
1363        },
1364        resizePadding: function () {
1365            var self = this;
1366
1367            if (this.wrap.width() < this.options.width && this.options.responsive) {
1368                $(".md-objects > div", this.slider).each(function () {
1369                    var objectRatio = self.wrap.width() / self.options.width,
1370                        $_object = $(this),
1371                        objectPadding = {};
1372
1373                    if ($_object.data("paddingtop")) objectPadding["padding-top"] = $_object.data("paddingtop") * objectRatio;
1374                    if ($_object.data("paddingright")) objectPadding["padding-right"] = $_object.data("paddingright") * objectRatio;
1375                    if ($_object.data("paddingbottom")) objectPadding["padding-bottom"] = $_object.data("paddingbottom") * objectRatio;
1376                    if ($_object.data("paddingleft")) objectPadding["padding-left"] = $_object.data("paddingleft") * objectRatio;
1377                    if ($_object.find("a").length)
1378                        $_object.find("a").css(objectPadding);
1379                    else
1380                        $_object.css(objectPadding);
1381                });
1382            }
1383            else {
1384                $(".md-objects > div", this.slider).each(function () {
1385                    var $_object = $(this),
1386                        objectPadding = {};
1387
1388                    if ($_object.data("paddingtop")) objectPadding["padding-top"] = $_object.data("paddingtop");
1389                    if ($_object.data("paddingright")) objectPadding["padding-right"] = $_object.data("paddingright");
1390                    if ($_object.data("paddingbottom")) objectPadding["padding-bottom"] = $_object.data("paddingbottom");
1391                    if ($_object.data("paddingleft")) objectPadding["padding-left"] = $_object.data("paddingleft");
1392                    if ($_object.find("a").length)
1393                        $_object.find("a").css(objectPadding);
1394                    else
1395                        $_object.css(objectPadding);
1396                });
1397            }
1398        },
1399        playTransition: function (fx) {
1400            var self = this,
1401                transitionSpeed = this.options.transitionsSpeed ? this.options.transitionsSpeed : this.options.defaultTransitionSpeed;
1402            switch (fx) {
1403                case "slit-horizontal-left-top":
1404                case "slit-horizontal-top-right":
1405                case "slit-horizontal-bottom-up":
1406                case "slit-vertical-down":
1407                case "slit-vertical-up":
1408                    this.addSlit(fx);
1409                    $(".md-object", this.slides[this.active]).hide();
1410                    this.slides[this.prev].hide();
1411                    this.slides[this.active].show();
1412                    var slice1 = $(".md-slider-slit", this.slider).first(),
1413                        slice2 = $(".md-slider-slit", this.slider).last(),
1414                        transitionProp = {
1415                            "transition": "all " + transitionSpeed + "ms ease-in-out",
1416                            "-webkit-transition": "all " + transitionSpeed + "ms ease-in-out",
1417                            "-moz-transition": "all " + transitionSpeed + "ms ease-in-out",
1418                            "-ms-transition": "all " + transitionSpeed + "ms ease-in-out"
1419                        };
1420
1421                    $(".md-slider-slit", this.slider).css(transitionProp);
1422                    setTimeout(function () {
1423                        slice1.addClass("md-transition-elements-1");
1424                        slice2.addClass("md-transition-elements-2");
1425                    }, 50);
1426                    setTimeout(function () {
1427                        self.transitionEnd();
1428                    }, transitionSpeed);
1429                    break;
1430                case "strip-up-right":
1431                case "strip-up-left":
1432                    this.addTiles(this.options.stripCols, 1, this.active);
1433                    var strips = $(".md-slider-title", this.slider),
1434                        timeStep = transitionSpeed / this.options.stripCols / 2,
1435                        speed = transitionSpeed / 2;
1436                    if (fx == "strip-up-right")
1437                        strips = $(".md-slider-title", this.slider).reverse();
1438                    strips.css({height: "1px", bottom: 0, top: "auto"});
1439                    strips.each(function (i) {
1440                        var strip = $(this);
1441
1442                        setTimeout(
1443                            function () {
1444                                strip.animate({
1445                                    height: "100%",
1446                                    opacity: "1.0"
1447                                }, speed, "easeInOutQuart", function () {
1448                                    if (i == self.options.stripCols - 1)
1449                                        self.transitionEnd();
1450                                });
1451                            },
1452                            i * timeStep
1453                        );
1454                    });
1455                    break;
1456                case "strip-down-right":
1457                case "strip-down-left":
1458                    this.addTiles(this.options.stripCols, 1, this.active);
1459                    var $strips = $(".md-slider-title", this.slider),
1460                        timeStep = transitionSpeed / this.options.stripCols / 2,
1461                        speed = transitionSpeed / 2;
1462
1463                    if (fx == "strip-down-right")
1464                        $strips = $(".md-slider-title", this.slider).reverse();
1465                    $strips.css({height: "1px", top: 0, bottom: "auto"});
1466                    $strips.each(function (i) {
1467                        var $strip = $(this);
1468                        setTimeout(
1469                            function () {
1470                                $strip.animate({
1471                                    height: "100%",
1472                                    opacity: "1.0"
1473                                }, speed, "easeInOutQuart", function () {
1474                                    if (i == self.options.stripCols - 1)
1475                                        self.transitionEnd();
1476                                });
1477                            },
1478                            i * timeStep
1479                        );
1480                    });
1481                    break;
1482                case "strip-left-up":
1483                case "strip-left-down":
1484                    this.addTiles(1, this.options.stripRows, this.active);
1485                    var $strips = $(".md-slider-title", this.slider),
1486                        timeStep = transitionSpeed / this.options.stripRows / 2,
1487                        speed = transitionSpeed / 2;
1488
1489                    if (fx == "strip-left-up")
1490                        $strips = $(".md-slider-title", this.slider).reverse();
1491                    $strips.css({width: "1px", left: 0, right: "auto"});
1492                    $strips.each(function (i) {
1493                        var $strip = $(this);
1494                        setTimeout(
1495                            function () {
1496                                $strip.animate({
1497                                    width: "100%",
1498                                    opacity: "1.0"
1499                                }, speed, "easeInOutQuart", function () {
1500                                    if (i == self.options.stripRows - 1)
1501                                        self.transitionEnd();
1502                                });
1503                            },
1504                            i * timeStep
1505                        );
1506                    });
1507                    break;
1508                case "strip-right-up":
1509                case "strip-right-down":
1510                    this.addTiles(1, this.options.stripRows, this.active);
1511                    var $strips = $(".md-slider-title", this.slider),
1512                        timeStep = transitionSpeed / this.options.stripRows / 2,
1513                        speed = transitionSpeed / 2;
1514                    if (fx == "strip-left-right-up")
1515                        $strips = $(".md-slider-title", self).reverse();
1516                    $strips.css({width: "1px", left: "auto", right: "1px"});
1517                    $strips.each(function (i) {
1518                        var $strip = $(this);
1519                        setTimeout(
1520                            function () {
1521                                $strip.animate({
1522                                    width: "100%",
1523                                    opacity: "1.0"
1524                                }, speed, "easeInOutQuart", function () {
1525                                    if (i == self.options.stripRows - 1)
1526                                        self.transitionEnd();
1527                                });
1528                            },
1529                            i * timeStep
1530                        );
1531                    });
1532                    break;
1533                case "strip-right-left-up":
1534                case "strip-right-left-down":
1535                    this.addTiles(1, this.options.stripRows, this.prev);
1536                    this.slides[this.prev].hide();
1537                    this.slides[this.active].show();
1538
1539                    var $strips = $(".md-slider-title", this.slider),
1540                        timeStep = transitionSpeed / this.options.stripRows,
1541                        speed = transitionSpeed / 2;
1542
1543                    if (fx == "strip-right-left-up")
1544                        $strips = $(".md-slider-title", this.slider).reverse();
1545                    $strips.filter(":odd").css({
1546                        width: "100%",
1547                        right: 0,
1548                        left: "auto",
1549                        opacity: 1
1550                    }).end().filter(":even").css({
1551                        width: "100%",
1552                        right: "auto",
1553                        left: "0px",
1554                        opacity: 1
1555                    });
1556                    $strips.each(function (i) {
1557                        var $strip = $(this),
1558                            css = (i % 2 == 0) ? {
1559                                left: "-50%",
1560                                opacity: 0
1561                            } : {right: "-50%", opacity: 0};
1562
1563                        setTimeout(
1564                            function () {
1565                                $strip.animate(css, speed, "easeOutQuint", function () {
1566                                    if (i == self.options.stripRows - 1) {
1567                                        self.transitionEnd();
1568                                    }
1569                                });
1570                            },
1571                            i * timeStep
1572                        );
1573                    });
1574                    break;
1575                case "strip-up-down-right":
1576                case "strip-up-down-left":
1577                    this.addTiles(this.options.stripCols, 1, this.prev);
1578                    this.slides[this.prev].hide();
1579                    this.slides[this.active].show();
1580
1581                    var $strips = $(".md-slider-title", this.slider),
1582                        timeStep = transitionSpeed / this.options.stripCols / 2,
1583                        speed = transitionSpeed / 2;
1584
1585                    if (fx == "strip-up-down-right")
1586                        $strips = $(".md-slider-title", this.slider).reverse();
1587
1588                    $strips.filter(":odd").css({
1589                        height: "100%",
1590                        bottom: 0,
1591                        top: "auto",
1592                        opacity: 1
1593                    }).end().filter(":even").css({
1594                        height: "100%",
1595                        bottom: "auto",
1596                        top: 0,
1597                        opacity: 1
1598                    });
1599                    $strips.each(function (i) {
1600                        var $strip = $(this),
1601                            css = (i % 2 == 0) ? {
1602                                top: "-50%",
1603                                opacity: 0
1604                            }
1604 : {bottom: "-50%", opacity: 0};
1605
1606                        setTimeout(
1607                            function () {
1608                                $strip.animate(css, speed, "easeOutQuint", function () {
1609                                    if (i == self.options.stripCols - 1)
1610                                        self.transitionEnd();
1611                                });
1612                            },
1613                            i * timeStep
1614                        );
1615                    });
1616                    break;
1617                case "left-curtain":
1618                    this.addTiles(this.options.stripCols, 1, this.active);
1619                    var $strips = $(".md-slider-title", this.slider),
1620                        stripItemWidth = this.getWidthStripItem(),
1621                        _self = this,
1622                        timeStep = transitionSpeed / this.options.stripCols / 2;
1623
1624                    $strips.each(function (i) {
1625                        var $strip = $(this);
1626                        var width = (i == _self.options.stripCols - 1) ? stripItemWidth.last : stripItemWidth.normal,
1627                            left = (i == _self.options.stripCols - 1) ? (_self.width - stripItemWidth.last) : (width * i);
1628                        $strip.css({left: left, width: 0, opacity: 0});
1629                        setTimeout(
1630                            function () {
1631                                $strip.animate({
1632                                    width: width,
1633                                    opacity: 1
1634                                }, transitionSpeed / 2, function () {
1635                                    if (i == self.options.stripCols - 1)
1636                                        self.transitionEnd();
1637                                });
1638                            },
1639                            timeStep * i
1640                        );
1641                    });
1642                    break;
1643                case "right-curtain":
1644                    this.addTiles(this.options.stripCols, 1, this.active);
1645
1646                    var $strips = $(".md-slider-title", this.slider).reverse(),
1647                        stripItemWidth = this.getWidthStripItem(),
1648                        _self = this,
1649                        timeStep = transitionSpeed / this.options.stripCols / 2;
1650                    //right-curtain neu de item cuoi cung co width la last thi js transition se chuyen cai last nay thanh first va gay loi
1651                    //vay nen ta lam nguoc lai, cho item first chua width last
1652                    $strips.each(function (i) {
1653                        var $strip = $(this);
1654                        var width = (i == 0) ? stripItemWidth.last : stripItemWidth.normal,
1655                            right = i ? ((width * (i -1)) + stripItemWidth.last) : 0;
1656                        $strip.css({
1657                            right: right,
1658                            left: "auto",
1659                            width: 0,
1660                            opacity: 0
1661                        });
1662                        setTimeout(
1663                            function () {
1664                                $strip.animate({
1665                                    width: width,
1666                                    opacity: 1
1667                                }, transitionSpeed / 2, function () {
1668                                    if (i == self.options.stripCols - 1)
1669                                        self.transitionEnd();
1670                                });
1671                            },
1672                            timeStep * i
1673                        );
1674                    });
1675                    break;
1676                case "top-curtain":
1677                    this.addTiles(1, this.options.stripRows, this.active);
1678
1679                    var $strips = $(".md-slider-title", this.slider),
1680                        stripItemHeight = this.getHeightStripItem(),
1681                        _self = this,
1682                        timeStep = transitionSpeed / this.options.stripRows / 2;
1683
1684                    $strips.each(function (i) {
1685                        var $strip = $(this);
1686                        var height = (i == _self.options.stripRows - 1) ? stripItemHeight.last : stripItemHeight.normal,
1687                            top = (i == _self.options.stripRows - 1) ? (_self.height - stripItemHeight.last) : (height * i);
1688                        $strip.css({top: top, height: 0, opacity: 0});
1689                        setTimeout(
1690                            function () {
1691                                $strip.animate({
1692                                    height: height,
1693                                    opacity: 1
1694                                }, transitionSpeed / 2, function () {
1695                                    if (i == self.options.stripRows - 1)
1696                                        self.transitionEnd();
1697                                });
1698                            },
1699                            timeStep * i
1700                        );
1701                    });
1702                    break;
1703                case "bottom-curtain":
1704                    this.addTiles(1, this.options.stripRows, this.active);
1705                    var $strips = $(".md-slider-title", this.slider).reverse(),
1706                        stripItemHeight = this.getHeightStripItem(),
1707                        _self = this,
1708                        timeStep = transitionSpeed / this.options.stripRows / 2;
1709                    //bottom-curtain neu de item cuoi cung co height la last thi js transition se chuyen cai last nay thanh first va gay loi
1710                    //vay nen ta lam nguoc lai, cho item first chua height last
1711                    $strips.each(function (i) {
1712                        var $strip = $(this);
1713                        var height = (i == 0) ? stripItemHeight.last : stripItemHeight.normal,
1714                            bottom = i ? ((height * (i -1)) + stripItemHeight.last) : 0;
1715                        $strip.css({bottom: bottom, height: 0, opacity: 0});
1716                        setTimeout(
1717                            function () {
1718                                $strip.animate({
1719                                    height: height,
1720                                    opacity: 1
1721                                }, transitionSpeed / 2, function () {
1722                                    if (i == self.options.stripRows - 1)
1723                                        self.transitionEnd();
1724                                });
1725                            },
1726                            timeStep * i
1727                        );
1728                    });
1729                    break;
1730                case "slide-in-right":
1731                    this.addStrips2();
1732
1733                    var $strips = $(".md-slider-strip", this.slider);
1734
1735                    $strips.each(function (i) {
1736                        var left = i * self.width,
1737                            $strip = $(this);
1738
1739                        $strip.css({left: left}).animate({left: left - self.width}, transitionSpeed, function () {
1740                            self.transitionEnd();
1741                        });
1742                    });
1743                    break;
1744                case "slide-in-left":
1745                    this.addStrips2();
1746                    var $strips = $(".md-slider-strip", this.slider);
1747
1748                    $strips.each(function (i) {
1749                        var left = -i * self.width,
1750                            $strip = $(this);
1751
1752                        $strip.css({left: left}).animate({left: self.width + left}, transitionSpeed * 2, function () {
1753                            self.transitionEnd();
1754                        });
1755                    });
1756                    break;
1757                case "slide-in-up":
1758                    this.addStrips2();
1759                    var $strips = $(".md-slider-strip", this.slider);
1760
1761                    $strips.each(function (i) {
1762                        var top = i * self.height,
1763                            $strip = $(this);
1764
1765                        $strip.css({top: top}).animate({top: top - self.height}, transitionSpeed, function () {
1766                            self.transitionEnd();
1767                        });
1768                    });
1769                    break;
1770                case "slide-in-down":
1771                    this.addStrips2();
1772                    var $strips = $(".md-slider-strip", this.slider);
1773
1774                    $strips.each(function (i) {
1775                        var top = -i * self.height,
1776                            $strip = $(this);
1777
1778                        $strip.css({top: top}).animate({top: self.height + top}, transitionSpeed, function () {
1779                            self.transitionEnd();
1780                        });
1781                    });
1782                    break;
1783                case "fade":
1784                default:
1785                    this.addStrips(false, {strips: 1});
1786
1787                    var $strip = $(".md-slider-strip:first", this.slider);
1788
1789                    $strip.css({height: "100%", width: self.width});
1790                    if (fx == "slide-in-right")
1791                        $strip.css({
1792                            height: "100%",
1793                            width: self.width + "px",
1794                            left: self.width + "px",
1795                            right: "auto"
1796                        });
1797                    else if (fx == "slide-in-left")
1798                        $strip.css({
1799                            left: "-" + self.width + "px"
1800                        });
1801
1802                    $strip.animate({
1803                        left: 0,
1804                        opacity: 1
1805                    }, transitionSpeed, function () {
1806                        self.transitionEnd();
1807                    });
1808                    break;
1809            }
1810        },
1811        getWidthStripItem: function(){
1812            var width = this.width / this.options.stripCols,
1813                result = {};
1814            result.normal = Math.round(width);
1815            result.last = this.width - (result.normal * (this.options.stripCols - 1));
1816            return result;
1817        },
1818        getHeightStripItem: function(){
1819            var height = this.height / this.options.stripRows,
1820                result = {};
1821            result.normal = Math.round(height);
1822            result.last = this.height - (result.normal * (this.options.stripRows - 1));
1823            return result;
1824        },
1825        addSlit: function (fx) {
1826            var $slitContainer = $('<div class="md-strips-container ' + fx + '"></div>'),
1827                $image = $(".md-main-img img", this.slides[this.prev]).length ? $(".md-main-img img", this.slides[this.prev]) : $(".md-main-img ", this.slides[this.prev]),
1828                $div1 = $('<div class="md-slider-slit"/>').append($image.clone()),
1829                position = $image.position(),
1830                $div2 = $('<div class="md-slider-slit"/>').append($image.clone().css("top", position.top - (this.height / 2) + "px"));
1831            if (fx == "slit-vertical-down" || fx == "slit-vertical-up")
1832                $div2 = $('<div class="md-slider-slit"/>').append($image.clone().css("left", position.left - (this.width / 2) + "px"));
1833
1834            $slitContainer.append($div1).append($div2);
1835            this.slider.append($slitContainer);
1836        },
1837        addStrips: function (vertical, opts) {
1838            var $strip,
1839                opts = (opts) ? opts : this.options,
1840                stripsContainer = $('<div class="md-strips-container"></div>'),
1841                stripWidth = Math.round(this.width / opts.strips),
1842                stripHeight = Math.round(this.height / opts.strips),
1843                $image = $(".md-main-img img", this.slides[this.active]);
1844
1845            for (var i = 0; i < opts.strips; i++) {
1846                var top = ((vertical) ? (stripHeight * i) + "px" : 0),
1847                    left = ((vertical) ? 0 : (stripWidth * i) + "px"),
1848                    width,
1849                    height;
1850
1851                if (i == opts.strips - 1) {
1852                    width = ((vertical) ? 0 : (this.width - (stripWidth * i)) + "px");
1853                    height = ((vertical) ? (this.height - (stripHeight * i)) + "px" : 0);
1854                }
1855                else {
1856                    width = ((vertical) ? 0 : stripWidth + "px");
1857                    height = ((vertical) ? stripHeight + "px" : 0);
1858                }
1859
1860                $strip = $('<div class="md-slider-strip"></div>').css({
1861                    width: width,
1862                    height: height,
1863                    top: top,
1864                    left: left,
1865                    opacity: 0
1866                });
1867                $strip.append($image.clone().css({
1868                    marginLeft: vertical ? 0 : -(i * stripWidth) + "px",
1869                    marginTop: vertical ? -(i * stripHeight) + "px" : 0
1870                }));
1871                stripsContainer.append($strip);
1872            }
1873            this.slider.append(stripsContainer);
1874        },
1875        addStrips2: function () {
1876            var $strip,
1877                images = [this.slides[this.prev].children(), $(".md-main-img img", this.slides[this.active])];
1878            var stripsContainer = $('<div class="md-strips-container"></div>');
1879            for (var i = 0; i < 2; i++) {
1880                var cloneHtml = images[i].clone();
1881                if(i == 0){
1882                    $('.md-object', cloneHtml).removeClass(effectsIn.join(" "));
1883                }
1884                $strip = $('<div class="md-slider-strip"></div>').css({
1885                    width: this.width,
1886                    height: this.height
1887                }).append(cloneHtml);
1888                stripsContainer.append($strip);
1889            }
1890            this.slider.append(stripsContainer);
1891        },
1892        addTiles: function (x, y, index) {
1893            var $title,
1894                $stripsContainer = $('<div class="md-strips-container"></div>'),
1895                titleWidth = this.width / x,
1896                titleHeight = this.height / y,
1897                $image = $(".md-main-img img", this.slides[index]),
1898                specialHeight = 0,
1899                specialWidth = 0;
1900
1901            if ($image.length == 0)
1902                $image = $(".md-main-img", this.slides[index]);
1903
1904            // fix make round width height
1905            if(x > 1){
1906                var titleWidthRound = Math.round(titleWidth);
1907                specialWidth = titleWidthRound - titleWidth;
1908                titleWidth = titleWidthRound;
1909            }else if(y > 1){
1910                var titleHeightRound = Math.round(titleHeight);
1911                specialHeight = titleHeightRound - titleHeight;
1912                titleHeight = titleHeightRound;
1913            }
1914
1915            for (var i = 0; i < y; i++) {
1916                for (var j = 0; j < x; j++) {
1917                    var top = (titleHeight * i) + 'px',
1918                        left = (titleWidth * j) + 'px';
1919
1920                    // fix increase / decrease with/height in last col / last row
1921                    if(x > 1 && specialWidth && j === (x-1)){
1922                        var titleWidthNew = titleWidth - x * specialWidth;
1923                        left = (x-1)*titleWidth + 'px';
1924                        titleWidth = titleWidthNew;
1925                    }
1926                    else if(y > 1 && specialHeight && i == (y-1)){
1927                        var titleHeightNew = titleHeight - y * specialHeight;
1928                        top = (y-1)*titleHeight + 'px';
1929                        titleHeight = titleHeightNew;
1930                    }
1931
1932                    $title = $('<div class="md-slider-title"/>').css({
1933                        width: titleWidth,
1934                        height: titleHeight,
1935                        top: top,
1936                        left: left
1937                    });
1938                    $title.append($image.clone().css({
1939                        marginLeft: "-" + left,
1940                        marginTop: "-" + top
1941                    }));
1942
1943                    $stripsContainer.append($title);
1944                }
1945            }
1946            this.slider.append($stripsContainer);
1947        },
1948        transitionEnd: function () {
1949            this.options.onEndTransition.call(this.slider);
1950            $(".md-strips-container", this.slider).remove();
1951            if (this.numberSlides != 1)
1952                this.slides[this.prev].hide();
1953            this.slides[this.active].show();
1954            this.playSlideItems();
1955        },
1956        setCurrent: function () {
1957            if (this.options.enableBullet)
1958                $("div.md-bullet:eq(" + this.active + ")", this.wrap).addClass("md-current");
1959            if (this.enableThumbnail && !this.options.enableBullet)
1960                $("a:eq(" + this.active + ")", this.wrap).addClass("md-current");
1961            this.scrollThumbnail("");
1962        },
1963        removeLoader: function() {
1964            $('.wrap-loader-slider').addClass('fadeOut');
1965            $('.md-slide-items').css('min-height','');
1966        }
1967    }
1968    $.fn.mdSlider = function (options) {
1969        return new MDSlider($(this), options);
1970    }
1971    $.fn.reverse = [].reverse;
1972})(jQuery);
1973
1974(function($) {
1975    var MDVideoBox = function($element, slider, options) {
1976        var default_options = {
1977            videoWidth: 640,
1978            videoHeight: 350,
1979            overlay: 0.8,
1980            onClick: function(){}
1981        };
1982
1983        this.video = $element;
1984        this.slider = slider;
1985        this.options = $.extend(default_options, options);
1986        this.height = this.options.videoHeight;
1987        this.width = this.options.videoWidth;
1988
1989        this.init();
1990    }
1991
1992    MDVideoBox.prototype = {
1993        constructor: MDVideoBox,
1994        init: function() {
1995            var self = this;
1996
1997            if($("#md-overlay").length == 0) {
1998                $("body").append('<div id="md-overlay" class="md-overlay" style="display: none"></div>');
1999                $("body").append('<div id="md-video-container" class="md-video-container" style="display: none"><div id="md-video-embed"></div><div class="md-description clearfix"><div class="md-caption"></div><a id="md-close-btn" class="md-close-btn" href="#"></a></div></div>');
2000            }
2001
2002            this.video.click(function() {
2003                self.open();
2004                return false;
2005            });
2006
2007            $("#md-overlay").click(function() {
2008                self.close();
2009            });
2010
2011            $("#md-video-container #md-close-btn").click(function() {
2012                self.close();
2013            });
2014
2015            $(window).resize(function() {
2016                self.resize();
2017            });
2018            $(window).keydown(function(event) {
2019                var key = event.keyCode || event.which;
2020
2021                if (key == 27)
2022                    self.close();
2023            });
2024        },
2025        open: function() {
2026            var self = this,
2027                $videoContainer = $("#md-video-container");
2028
2029            // Pause slide
2030            $videoContainer.hover(
2031                function() {
2032                    self.slider.pauseSlide();
2033                },
2034                function() {}
2035            );
2036            $("#md-video-embed", $videoContainer).hover(
2037                function() {
2038                    self.slider.pauseSlide();
2039                },
2040                function() {}
2041            );
2042
2043            // Invoke custom on click video element callback
2044            this.options.onClick.call(this.video);
2045
2046            // Implements set size for video box elements
2047            var docWidth = $(window).width(),
2048                docHeight = $(window).height();
2049
2050            if (docWidth < this.options.videoWidth) {
2051                this.width = docWidth;
2052                this.height = this.options.videoHeight * docWidth / this.options.videoWidth;
2053
2054                if (docHeight < this.height) {
2055                    this.width = docHeight*this.options.videoWidth/this.options.videoHeight;
2056                    this.height = docHeight;
2057                }
2058            }
2059            $("#md-video-embed", $videoContainer).css({width: this.width + "px", height: this.height + "px"}).addClass("md-loading");
2060            $(window).trigger("resize");
2061
2062            $videoContainer.show();
2063            $(".md-caption", $videoContainer).html(this.video.attr("title"));
2064            $("#md-overlay").show().fadeTo("fast", this.options.opacity);
2065            $("#md-video-embed", $videoContainer).fadeIn("slow", function() {
2066                var $videoFrame = $('<iframe frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'),
2067                    videoSrc = self.video.attr("href") + '?autoplay=1';
2068
2069                $videoFrame.attr("src", videoSrc);
2070                $videoFrame.css({width: self.width, height: self.height});
2071                $("#md-video-embed", $videoContainer).append($videoFrame);
2072            });
2073        },
2074        close: function() {
2075            $("#md-overlay").fadeOut("fast");
2076            $("#md-video-embed").html("");
2077            $("#md-video-container").hide();
2078            return false;
2079        },
2080        resize: function() {
2081            var docWidth = $(window).width(),
2082                docHeight = $(window).height();
2083
2084            $("#md-video-container").css({left: (docWidth - this.width)/2 + "px", top: (docHeight - this.height)/2 + "px"});
2085            $("#md-overlay").css({width: docWidth, height: docHeight});
2086        }
2087    }
2088    $.fn.mdVideoBox = function(slider, options) {
2089        return new MDVideoBox($(this), slider, options);
2090    }
2091})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.