PageSourceSearch

https://www.cutpoint-inc.com/assets/plugins/master-slider/source/MasterSlider.js

js cutpoint-inc.com collected 2026-10-02 01:28:20 UTC 26,471 bytes, 856 lines download raw bytes

1/**
2 * Master Slider Main JavaScript File
3 */
4
5;(function($){
6
7	"use strict";
8
9	/* @ifdef PRO */
10	var LayerTypes = {
11		'image' 	: MSImageLayerElement,
12		'text'  	: MSLayerElement,
13		'video' 	: MSVideoLayerElement,
14		'hotspot'	: MSHotspotLayer,
15		'button'	: MSButtonLayer
16	};
17	/* @endif */
18
19	window.MasterSlider = function(){
20
21		// Default Options
22		this.options = {
23            forceInit           : true,       // Force calling init even an error occurs in jQuery's dom ready method.
24			autoplay 			: false,      // Enables the autoplay slideshow.
25			loop 				: false,	  // Enables the continuous sliding mode.
26			mouse				: true,		  // Whether the user can use mouse drag navigation.
27			swipe				: true,		  // Whether the drag/swipe navigation is enabled.
28			grabCursor			: true,		  // Whether the slider uses grab mouse cursor.
29			space  				: 0,		  // The spacing value between slides in pixels.
30			fillMode			: 'fill',  	  // Specifies the slide background scaling method. Its acceptable values are "fill", "fit", "stretch", "center" and "tile".
31			start				: 1,		  // The slider starting slide number.
32			view				: 'basic',	  // The slide changing transition.
33			width				: 300,		  // The base width of slides. It helps the slider to resize in correct ratio.
34			height				: 150,		  // The base height of slides, It helps the slider to resize in correct ratio.
35			inView				: 15, 		  // Specifies number of slides which will be added at a same time in DOM.
36            critMargin          : 1,          //
37			mobileBGVideo       : false,	  // Whether show background videos in mobile devices.
38			heightLimit			: true,		  // It force the slide to use max height value as its base specified height value.
39			smoothHeight		: true,		  // Whether the slider uses smooth animation while its height changes.
40			autoHeight			: false,      // Whether the slider adapts its height to each slide height or not. It overrides heightLimit option.
41			minHeight 			: -1,		  // @since 2.13.0, Specifies min height value for the slider, it prevents slider to shows too narrow in small screens.
42			fullwidth			: false,	  // It enables the slider to adapt width to its parent element. It's very useful for creating full-width sliders. In default it takes max width as its base width value.
43			fullheight			: false,	  // It enables the slider to adapt height to its parent element.
44			autofill			: false,	  // It enables the slider to adapt width and height to its parent element, It's very useful for creating fullscreen or fullwindow slider.
45			layersMode			: 'center',	  // It accepts two values "center" and "full". The "center" value indicates that the slider aligns layers to the center. This option is only effective in full width mode.
46			hideLayers			: false,	  // Whether the slider hides all layers before changing slide.
47			endPause			: false,	  // Whether the slider pauses slideshow when it stays at the last slide.
48			centerControls 		: true,		  // Whether the slider aligns UI controls to center. This option is only effective in full width mode.
49			overPause			: true,		  // Whether the slider pauses slideshow on hover.
50			shuffle				: false,	  // Enables the shuffle slide order.
51			speed				: 17, 		  // Specifies slide changing speed. It accepts float values between 0 and 100.
52			dir					: 'h',		  // Specifies slide changing direction. It accepts two values "h" (horizontal) and "v" (vertical).
53			preload				: 0,		  // Specifies number of slides which will be loaded by slider. 0 value means the slider loads slides in sequence.
54			wheel				: false,	  // Whether slider uses mouse wheel for navigation.
55			layout				: 'boxed',	  // It accepts 'fullwidth', 'fullscreen', 'fillwidth', 'autofill', 'partialview', 'boxed'. It overrides 'fullwidth' and 'autofill' (added in v1.5.6)
56			autofillTarget 		: null,		  // @since 2.13.0, Specifies the parent element of slider width jQuery selector, it used for sizing slider with autofill layout. Default value is the first parent element of slider.
57			fullscreenMargin	: 0,		  // Specifies margin amount to the bottom of slider, it's only effective on fullscreen slider.
58			instantStartLayers	: false, 	  // @since 1.5.0, Whether instantly shows slide layers.
59			parallaxMode 		: 'mouse',	  // @since 1.6.0, Specifies mode of parallax effect accepts: "mouse", "mouse:x-only", "mouse:y-only" and "swipe"
60			rtl 				: false,	  // @since 1.8.0, Whether Right-to-left direction slider.
61			deepLink			: null,       // @since 2.1.0, null value disables slider deep-linking any string values identifies the slider in page's url like /#msslider-1
62			deepLinkType 		: 'path', 	  // @since 2.1.0, type of hash value in page's url possible values, path and query (  #gallery/1 || #gallery=4 )
63			disablePlugins      : []		  // @since 2.9.6, list of disabled Master Slider plugin names for this instance.
64		};
65
66		this.slides = [];
67		this.activePlugins = [];
68		this.$element = null;
69
70		// used by new layout method. to force fullwidth or fullscreen
71		this.lastMargin = 0;
72
73		// Reserved side spaces of slider
74		this.leftSpace = 0;
75		this.topSpace = 0;
76		this.rightSpace = 0;
77		this.bottomSpace = 0;
78
79		// hold on stack
80		this._holdOn = 0;
81
82		var that = this;
83		this.resize_listener = function(){that._resize();};
84		$(window).bind('resize', this.resize_listener);
85
86	};
87
88	MasterSlider.author  		= 'Averta Ltd. (www.averta.net)';
89	MasterSlider.version 		= '/*@echo VERSION */';
90	MasterSlider.releaseDate 	= '/*@echo DATE */';
91
92	// Master Slider plugins.
93	MasterSlider._plugins = []
94	var MS = MasterSlider;
95	MS.registerPlugin = function ( plugin ) {
96		if ( MS._plugins.indexOf(plugin) === -1 ) {
97			MS._plugins.push(plugin);
98		}
99	};
100
101	var p = MasterSlider.prototype;
102
103	/*-------------- METHODS --------------*/
104
105	/**
106	 * create one slide object for each slide and add it to slide controller
107	 * @since 1.0
108	 * @private
109	 */
110	p.__setupSlides = function(){
111		var that = this,
112			new_slide,
113			ind = 0;
114
115		this.$element.children('.ms-slide').each(function(index) {
116
117			var $slide_ele = $(this);
118
119			new_slide 			= new MSSlide();
120			new_slide.$element 	= $slide_ele;
121			new_slide.slider 	= that;
122			new_slide.delay  	= $slide_ele.data('delay') 		!== undefined ? $slide_ele.data('delay') 		: 3;
123			new_slide.fillMode 	= $slide_ele.data('fill-mode')	!== undefined ? $slide_ele.data('fill-mode') 	: that.options.fillMode;
124			new_slide.index 	= ind++;
125            new_slide.id        = $slide_ele.data('id');
126
127			// Slide Background Image
128			var slide_img = $slide_ele.children('img:not(.ms-layer)');
129			if( slide_img.length > 0 ){
130				new_slide.setBG(slide_img[0]);
131			}
132
133			/* @ifdef PRO */
134			// Slide Video Background
135			var slide_video = $slide_ele.children('video');
136			if( slide_video.length > 0 ) new_slide.setBGVideo(slide_video);
137			/* @endif */
138
139			// controls
140			if(that.controls){
141				for(var i = 0 , l = that.controls.length; i<l ; ++i)
142					that.controls[i].slideAction(new_slide);
143			}
144
145			// Slide Link and Video
146			var slide_link = $slide_ele.children('a').each(function(index) {
147			  var $this = $(this);
148			  if(this.getAttribute('data-type') === 'video'){
149				new_slide.video = this.getAttribute('href');
150
151				new_slide.videoAutoPlay = $this.data('autoplay');
152
153				$this.remove();
154			  }else if(!$this.hasClass('ms-layer')) {
155				new_slide.link  = $(this);
156				//new_slide.link_targ = this.getAttribute('target');
157				//$this.remove();
158			  }
159			});//.remove();
160
161			/* @ifdef PRO */
162			// Slide Layers
163            that.__createSlideLayers(new_slide , $slide_ele.find('.ms-layer'));
164            /* @endif */
165
166            that.slides.push(new_slide);
167            that.slideController.view.addSlide(new_slide);
168
169        });
170    };
171
172    /**
173     * Setups the overlay layers to the slider
174     * @since 2.50
175     */
176    p._setupOverlayLayers = function() {
177        var self = this,
178            $ollayers = this.$element.children( '.ms-overlay-layers' ).eq(0);
179
180        if ( !$ollayers.length ) {
181            return;
182        }
183
184        var overlayLayers = new MSOverlayLayers( this );
185        overlayLayers.$element = $ollayers;
186        self.__createSlideLayers(overlayLayers , $ollayers.find('.ms-layer'));
187
188        this.view.$element.prepend( $ollayers );
189        this.overlayLayers = overlayLayers;
190        overlayLayers.create();
191    };
192
193	/* @ifdef PRO */
194	/**
195	 * Creates layers of specified layer
196	 * @param  {MSSlide} slide
197	 * @param  {Array} layers
198	 * @since 1.0
199	 * @private
200	 */
201	p.__createSlideLayers = function(slide , layers) {
202		if(layers.length == 0) return;
203		slide.setupLayerController();
204
205		layers.each(function(index , domEle){
206			var $layer_element = $(this),
207				$parent_ele;
208
209			if( domEle.nodeName === 'A' && $layer_element.find('>img').data('type') === 'image' ) {
210				$parent_ele = $(this);
211				$layer_element = $parent_ele.find('img');
212			}
213
214			var layer = new (LayerTypes[$layer_element.data('type') || 'text']) ();
215			layer.$element      = $layer_element;
216			layer.link          = $parent_ele;
217            layer.id            = layer.$element.data('id');
218            layer.waitForAction = layer.$element.data('wait');
219            layer.masked        = layer.$element.data('masked');
220            layer.maskWidth     = layer.$element.data('mask-width');
221            layer.maskHeight    = layer.$element.data('mask-height');
222
223            var eff_parameters = {},
224                end_eff_parameters = {};
225
226            if($layer_element.data('effect')    !== undefined)      eff_parameters.name             = $layer_element.data('effect');
227            if($layer_element.data('ease')      !== undefined)      eff_parameters.ease             = $layer_element.data('ease');
228            if($layer_element.data('duration')  !== undefined)      eff_parameters.duration         = $layer_element.data('duration');
229            if($layer_element.data('delay')     !== undefined)      eff_parameters.delay            = $layer_element.data('delay');
230
231            if($layer_element.data('hide-effect'))                  end_eff_parameters.name         = $layer_element.data('hide-effect');
232            if($layer_element.data('hide-ease'))                    end_eff_parameters.ease         = $layer_element.data('hide-ease');
233            if($layer_element.data('hide-duration') !== undefined)  end_eff_parameters.duration     = $layer_element.data('hide-duration');
234            if($layer_element.data('hide-time')     !== undefined)  end_eff_parameters.time         = $layer_element.data('hide-time');
235
236
237			layer.setStartAnim(eff_parameters);
238			layer.setEndAnim(end_eff_parameters);
239
240			slide.layerController.addLayer(layer);
241
242		});
243
244	};
245	/* @endif */
246
247	/**
248	 * remove slider initialize loading
249	 * @since 1.0
250	 * @private
251	 */
252	p._removeLoading = function(){
253		$(window).unbind('resize', this.resize_listener);
254		this.$element.removeClass('before-init')
255					.css('visibility', 'visible')
256					.css('height','')
257					.css('opacity' , 0);
258		CTween.fadeIn(this.$element);
259		this.$loading.remove();
260
261		if(this.slideController)
262			this.slideController.__resize();
263	};
264
265	/**
266	 * resize listener, it only used for aligning slider loading and after slider init it will be removed
267	 * @param  {Event} e
268	 * @since 1.0
269	 * @private
270	 */
271	p._resize = function(e){
272		if(this.$loading){
273			var h = this.$loading[0].clientWidth / this.aspect;
274			h = this.options.heightLimit ? Math.min(h , this.options.height) : h;
275
276			this.$loading.height(h);
277			this.$element.height(h);
278		}
279	};
280
281	/**
282	 * changes the order of slides element before setup slides
283	 * @since 1.0
284	 * @private
285	 */
286	p._shuffleSlides = function(){
287		var slides = this.$element.children('.ms-slide') , r;
288
289		for(var i = 0 , l = slides.length; i < l ; ++i){
290			r = Math.floor(Math.random() * (l - 1));
291			if(i != r){
292				this.$element[0].insertBefore(slides[i] , slides[r]);
293				slides = this.$element.children('.ms-slide');
294			}
295		}
296	};
297
298	/**
299	 * New method of setting up the layout of slider
300	 * @since 1.5.6
301	 */
302	p._setupSliderLayout = function(){
303
304		// create side spaces
305		this._updateSideMargins();
306		this.lastMargin = this.leftSpace;
307
308		var lo = this.options.layout;
309
310
311		if( lo !== 'boxed' && lo !== 'partialview' ){
312			this.options.fullwidth = true;  // enable slider fullscreen for fullwidth, fillwidth, autofill and fullscreen layouts.
313		}
314		/* @ifdef PRO */
315		if( lo === 'fullscreen' || lo === 'autofill' ){
316			this.options.fullheight = true;
317
318			if ( lo === 'autofill' ) {
319				this.$autofillTarget = $(this.options.autofillTarget);
320				if ( this.$autofillTarget.length === 0 ) {
321					this.$autofillTarget = this.$element.parent();
322				}
323			}
324
325		}
326
327		// partial view
328		if ( lo === 'partialview' ){
329			this.$element.addClass('ms-layout-partialview');
330		}
331		/* @endif */
332
333		if( lo === 'fullscreen' ||  lo === 'fullwidth' || lo === 'autofill' ){
334			$(window).bind('resize', {that:this}, this._updateLayout);
335			this._updateLayout();
336		}
337
338		// bind resize handler of slidecontroller __resize
339		$(window).bind('resize', this.slideController.resize_listener);
340	};
341
342	/**
343	 * updates layout of slider based on window size
344	 * @param  {Event} event
345	 * @since 1.5.6
346	 */
347	p._updateLayout = function(event){
348		var that = event? event.data.that : this,
349			lo = that.options.layout,
350			$element = that.$element,
351			$win = $(window);
352
353		/* @ifdef PRO */
354		// height
355		if( lo === 'fullscreen' ){
356			document.body.style.overflow = 'hidden';
357			$element.height( $win.height() - that.options.fullscreenMargin - that.topSpace - that.bottomSpace);
358			document.body.style.overflow = '';
359		} else if ( lo === 'autofill' ) {
360			$element.height(that.$autofillTarget.height() - that.options.fullscreenMargin - that.topSpace - that.bottomSpace)
361					.width(that.$autofillTarget.width() - that.leftSpace - that.rightSpace);
362			return;
363		}
364		/* @endif */
365
366		// width
367		$element.width($win.width() - that.leftSpace - that.rightSpace);
368		var margin = -$element.offset().left + that.leftSpace + that.lastMargin;
369		$element.css('margin-left', margin );
370		that.lastMargin = margin;
371//
372	};
373
374
375	/**
376	 * initialize the slider, called by document ready
377	 * <code>holdOn</code> property prevents auto initialize slider after document ready it used by plugins of slider like Flickr
378	 * @since 1.0
379	 * @protected
380	 */
381	p._init = function(){
382
383		if ( this._holdOn > 0 || !this._docReady ) {
384			return;
385		}
386
387		this.initialized = true;
388
389		if(this.options.preload !== 'all'){
390			this._removeLoading();
391		}
392		//else
393		//	this.$element.css('width' , this.$loading[0].clientWidth);
394
395		if(this.options.shuffle) 	this._shuffleSlides();
396
397		/* @ifdef PRO */
398		MSLayerEffects.setup();
399		/* @endif */
400
401		this.slideController.setupView();
402		this.view = this.slideController.view;
403
404		this.$controlsCont = $('<div></div>
404').addClass('ms-inner-controls-cont');//.appendTo(this.$element);
405		if(this.options.centerControls){
406			this.$controlsCont.css('max-width' , this.options.width + 'px');
407		}
408
409		this.$controlsCont.prepend(this.view.$element);
410
411		this.$msContainer = $('<div></div>').addClass('ms-container').prependTo(this.$element).append(this.$controlsCont);
412
413		if(this.controls){
414			for(var i = 0 , l = this.controls.length; i<l ; ++i){
415				this.controls[i].setup();
416			}
417		}
418		/*else{
419			this.$element.append(this.view.$element);
420		}*/
421
422		this._setupSliderLayout();
423		this.__setupSlides();
424		this.slideController.setup();
425        this._setupOverlayLayers();
426
427		if(this.controls){
428			for(i = 0 , l = this.controls.length; i<l ; ++i)
429				this.controls[i].create();
430		}
431
432		if(this.options.autoHeight){
433			this.slideController.view.$element.height(this.slideController.currentSlide.getHeight());
434		}
435
436		// add grab cursor
437		if(this.options.swipe && !window._touch && this.options.grabCursor && this.options.mouse){
438			var $view = this.view.$element;
439
440			$view.mousedown(function(){
441				$view.removeClass('ms-grab-cursor');
442				$view.addClass('ms-grabbing-cursor');
443
444				if ( $.browser.msie && window.ms_grabbing_curosr ) {
445					$view[0].style.cursor = 'url(' + window.ms_grabbing_curosr + '), move';
446				}
447
448			}).addClass('ms-grab-cursor');
449
450			$(document).mouseup(function(){
451				$view.removeClass('ms-grabbing-cursor');
452				$view.addClass('ms-grab-cursor');
453
454				if ( $.browser.msie && window.ms_grab_curosr ) {
455					$view[0].style.cursor = 'url(' + window.ms_grab_curosr + '), move';
456				}
457
458			});
459		}
460
461		this.slideController.__dispatchInit();
462	};
463
464	/**
465	 * changes the height of slider, it used in autoheight slider
466	 * @param {Number} value
467	 * @since 1.0
468	 * @public
469	 */
470	p.setHeight = function(value){
471		if(this.options.smoothHeight){
472			if(this.htween){
473				if(this.htween.reset)this.htween.reset();
474				else	 			 this.htween.stop(true);
475			}
476			this.htween = CTween.animate(this.slideController.view.$element , 500 , {height:value} , {ease:'easeOutQuart'});
477		}else
478			this.slideController.view.$element.height(value);
479	};
480
481	/**
482	 * reserves white space in sides of slider, it used by controls
483	 * @param  {String} side  left|right|top|bottom
484	 * @param  {Number} space
485	 * @returns {Number} start position in space.
486	 * @since 1.5.7
487	 * @public
488	 */
489	p.reserveSpace = function(side, space){
490		var sideSpace = side+'Space',
491			pos = this[sideSpace];
492
493		this[sideSpace] += space;
494
495		this._updateSideMargins();
496
497		return pos;
498	};
499
500	/**
501	 * returns the reserved space, it used by controls and called when aligned control hides
502	 * @param  {String} side
503	 * @param  {Number} space
504	 * @since 1.5.7
505	 * @public
506	 */
507	/*p.returnSpace = function(side, space){
508		var sideSpace = side+'Space';
509		this[sideSpace] = Math.max(0 , this[sideSpace] - space);
510
511		this.api.dispatchEvent(new MSSliderEvent(MSSliderEvent.RESERVED_SPACE_CHANGE));
512		this._updateSideMargins();
513	};*/
514
515	p._updateSideMargins = function(){
516		this.$element.css('margin', this.topSpace + 'px ' + this.rightSpace + 'px ' + this.bottomSpace + 'px ' + this.leftSpace + 'px');
517	}
518
519	p._realignControls = function(){
520		this.rightSpace = this.leftSpace = this.topSpace = this.bottomSpace = 0;
521		this._updateSideMargins();
522		this.api.dispatchEvent(new MSSliderEvent(MSSliderEvent.RESERVED_SPACE_CHANGE));
523	};
524
525	/*------------------------- Public Methods -----------------------*/
526
527	/**
528	 * Adds new control to the slider
529	 * @param  {String} control
530	 * @param  {Object} options [description]
531	 * @since 1.0
532	 * @public
533	 */
534	p.control = function(control , options){
535		if(!(control in MSSlideController.SliderControlList)) return;
536		if(!this.controls) this.controls = [];
537		var ins = new MSSlideController.SliderControlList[control](options);
538		ins.slider = this;
539		this.controls.push(ins);
540
541		return this;
542	};
543
544	/**
545	 * Hold on slider from initialization
546	 * @since 2.9.6
547	 * @public
548	 */
549	p.holdOn = function () {
550		this._holdOn ++;
551	};
552
553	/**
554	 * Let the slider to initialize
555	 * @since 2.9.6
556	 */
557	p.release = function () {
558		this._holdOn --;
559		this._init();
560	};
561
562	/**
563	 * setup slider
564	 * @param  {String|jQuery object} id
565	 * @param  {Object} options
566	 * @since 1.0
567	 * @public
568	 */
569	p.setup = function(target , options){
570		if(typeof target === 'string'){
571			this.$element = $('#' + target);
572		} else {
573			this.$element = target.eq(0);
574		}
575
576		//create a copy from slider markup, it will be used in destroy method.
577		this.setupMarkup = this.$element.html();
578
579		if( this.$element.length === 0 ){
580			//if(console) console.log('Master Slider Error: #'+id+' not found.');
581			return;
582		}
583
584		this.$element.addClass('master-slider').addClass('before-init');
585
586		// IE prefix class
587		// add browser prefix class name
588		if($.browser.msie){
589			this.$element.addClass('ms-ie')
590						 .addClass('ms-ie' + $.browser.version.slice(0 , $.browser.version.indexOf('.')));
591		} else if ( $.browser.webkit ) {
592			this.$element.addClass('ms-wk');
593		} else if ( $.browser.mozilla ) {
594			this.$element.addClass('ms-moz');
595		}
596
597
598		// Android prefix class
599		var ua = navigator.userAgent.toLowerCase();
600		var isAndroid = ua.indexOf("android") > -1;
601		if(isAndroid) {
602		  this.$element.addClass('ms-android');
603		}
604
605		var that = this;
606		$.extend(this.options, options);
607
608		this.aspect = this.options.width / this.options.height;
609
610		this.$loading = $('<div></div>').
611						addClass('ms-loading-container').
612						insertBefore(this.$element).
613						append($('<div></div>').addClass('ms-loading'));
614
615		this.$loading.parent().css('position' , 'relative');
616
617		// old methods
618		if(this.options.autofill){
619			this.options.fullwidth = true;
620			this.options.fullheight = true;
621		}
622
623		if(this.options.fullheight){
624			this.$element.addClass('ms-fullheight');
625		}
626
627		//this._setupSliderLayout();
628		this._resize();
629
630		// define slide controller and api
631		this.slideController = new MSSlideController(this);
632		this.api = this.slideController;
633
634		// setup plugins
635		for ( var i = 0, l = MS._plugins.length; i !== l; i++ ) {
636			var plugin = MS._plugins[i];
637
638			if ( this.options.disablePlugins.indexOf(plugin.name) === -1 ) {
639				this.activePlugins.push(new plugin(this));
640			}
641		}
642
643        if ( this.options.forceInit ) {
644            MasterSlider.addJQReadyErrorCheck( this );
645        }
646
647		$(document).ready(function(){
648            if ( !that.initialized ) {
649    			that._docReady = true;
650    			that._init();
651            }
652		});
653
654		return this;
655	};
656
657	/**
658	 * destroy the slider instance
659	 * @param  {Boolean} insertMarkup	 whether add slider markup after destroy.
660	 * @since 1.4
661	 * @public
662	 */
663	p.destroy = function(insertMarkup){
664
665		// destroy active plugins
666		for ( var i = 0, l = this.activePlugins.length; i !== l; i++ ) {
667			this.activePlugins[i].destroy();
668		}
669
670		if(this.controls){
671			for( i = 0, l = this.controls.length; i !== l; i++ )
672				this.controls[i].destroy();
673		}
674
675		if(this.slideController) this.slideController._destroy();
676
677		if(this.$loading) this.$loading.remove();
678
679		if ( insertMarkup ) {
680			this.$element.html(this.setupMarkup).css('visibility' , 'hidden');
681		} else {
682			this.$element.remove();
683		}
684
685		var lo = this.options.layout;
686		if( lo === 'fullscreen' ||  lo === 'fullwidth' ){
687			$(window).unbind('resize', this._updateLayout);
688		}
689
690		this.view = null;
691		this.slides = null;
692		this.options = null;
693		this.slideController = null;
694		this.api = null;
695		this.resize_listener = null;
696
697
698		this.activePlugins = null;
699	};
700
701})(jQuery);
702
703/**
704 * Master Slider jQuery Plugin
705 * @author Averta
706 */
707(function ( $, window, document, undefined ) {
708
709		var pluginName = "masterslider",
710			defaults = {
711				controls:{}
712			};
713
714		function MasterSliderPlugin ( element, options ) {
715			this.element = element;
716			this.$element = $(element);
717			this.settings = $.extend( {}, defaults, options );
718			this._defaults = defaults;
719			this._name = pluginName;
720			this.init();
721		}
722
723		$.extend(MasterSliderPlugin.prototype, {
724			init : function () {
725
726				var self = this;
727
728				// create new instance form Master Slider
729				this._slider = new MasterSlider();
730
731				// add controls
732				for ( var control in this.settings.controls ){
733					this._slider.control(control, this.settings.controls[control]);
734				}
735
736				this._slider.setup(this.$element, this.settings);
737
738				// override api eventdisaptcher method
739				var _superDispatch = this._slider.api.dispatchEvent;
740				this._slider.api.dispatchEvent = function(event){
741					self.$element.trigger(event.type);
742					_superDispatch.call(this, event);
743				};
744
745			},
746
747			api : function() {
748				return this._slider.api;
749			},
750
751			slider : function() {
752				return this._slider;
753			}
754
755		});
756
757		$.fn[pluginName] = function ( options ) {
758			var args = arguments,
759				plugin = 'plugin_' + pluginName;
760
761			// Is the first parameter an object (options), or was omitted,
762			// instantiate a new instance of the plugin.
763			if (options === undefined || typeof options === 'object') {
764				return this.each(function () {
765
766					// Only allow the plugin to be instantiated once,
767					// so we check that the element has no plugin instantiation yet
768					if (!$.data(this, plugin)) {
769						$.data(this, plugin, new MasterSliderPlugin( this, options ));
770					}
771				});
772
773			// If the first parameter is a string and it doesn't start
774			// with an underscore or "contains" the `init`-function,
775			// treat this as a call to a public method.
776			} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
777
778				// Cache the method call
779				// to make it possible
780				// to return a value
781				var returns;
782
783				this.each(function () {
784					var instance = $.data(this, plugin);
785
786					// Tests that there's already a plugin-instance
787					// and checks that the requested public method exists
788					if (instance instanceof MasterSliderPlugin && typeof instance[options] === 'function') {
789
790						// Call the method of our plugin instance,
791						// and pass it the supplied arguments.
792						returns = instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
793					}
794
795					// Map slider api functions to slider jq plugin
796					if ( instance instanceof MasterSliderPlugin && typeof instance._slider.api[options] === 'function' ) {
797						returns = instance._slider.api[options].apply( instance._slider.api, Array.prototype.slice.call( args, 1 ) );
798					}
799
800					// Allow instances to be destroyed via the 'destroy' method
801					if (options === 'destroy') {
802					  $.data(this, plugin, null);
803					}
804				});
805
806				// If the earlier cached method
807				// gives a value back return the value,
808				// otherwise return this to preserve chainability.
809				return returns !== undefined ? returns : this;
810			}
811		};
812
813})( jQuery, window, document );
814
815;(function ( $, window, document, undefined ) {
816    "use strict";
817
818    /* ------------------------------------------------------------------------------ */
819
820    var sliderInstances = [];
821    MasterSlider.addJQReadyErrorCheck = function ( slider ) {
822        sliderInstances.push( slider );
823    };
824
825    var _ready = $.fn.ready,
826        _onerror = window.onerror;
827
828    // override jQuery ready
829    $.fn.ready = function() {
830
831        // override window on load event
832        window.onerror = function() {
833
834            if ( sliderInstances.length !== 0 ) {
835                for ( var i = 0, l = sliderInstances.length; i !== l; i++ ) {
836                    var slider = sliderInstances[i];
837                    if ( !slider.initialized ) {
838                        slider._docReady = true;
839                        slider._init();
840                    }
841                }
842            }
843
844            if ( _onerror ) {
845                return _onerror.apply( this, arguments );
846            }
847
848            return false;
849        }
850
851        return _ready.apply( this, arguments );
852    };
853
854})(jQuery, window, document);
855
856

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.