PageSourceSearch

https://azaleasuites.co.id/assets/site/js/owl.navigation.js

js azaleasuites.co.id collected 2026-09-25 06:32:12 UTC 11,178 bytes, 406 lines download raw bytes

vendor: 11,178 bytes, lines 1-406
1/**
2 * Navigation Plugin
3 * @version 2.3.4
4 * @author Artus Kolanowski
5 * @author David Deutsch
6 * @license The MIT License (MIT)
7 */
8;(function($, window, document, undefined) {
9	'use strict';
10
11	/**
12	 * Creates the navigation plugin.
13	 * @class The Navigation Plugin
14	 * @param {Owl} carousel - The Owl Carousel.
15	 */
16	var Navigation = function(carousel) {
17		/**
18		 * Reference to the core.
19		 * @protected
20		 * @type {Owl}
21		 */
22		this._core = carousel;
23
24		/**
25		 * Indicates whether the plugin is initialized or not.
26		 * @protected
27		 * @type {Boolean}
28		 */
29		this._initialized = false;
30
31		/**
32		 * The current paging indexes.
33		 * @protected
34		 * @type {Array}
35		 */
36		this._pages = [];
37
38		/**
39		 * All DOM elements of the user interface.
40		 * @protected
41		 * @type {Object}
42		 */
43		this._controls = {};
44
45		/**
46		 * Markup for an indicator.
47		 * @protected
48		 * @type {Array.<String>}
49		 */
50		this._templates = [];
51
52		/**
53		 * The carousel element.
54		 * @type {jQuery}
55		 */
56		this.$element = this._core.$element;
57
58		/**
59		 * Overridden methods of the carousel.
60		 * @protected
61		 * @type {Object}
62		 */
63		this._overrides = {
64			next: this._core.next,
65			prev: this._core.prev,
66			to: this._core.to
67		};
68
69		/**
70		 * All event handlers.
71		 * @protected
72		 * @type {Object}
73		 */
74		this._handlers = {
75			'prepared.owl.carousel': $.proxy(function(e) {
76				if (e.namespace && this._core.settings.dotsData) {
77					this._templates.push('<div class="' + this._core.settings.dotClass + '">' +
78						$(e.content).find('[data-dot]').addBack('[data-dot]').attr('data-dot') + '</div>');
79				}
80			}, this),
81			'added.owl.carousel': $.proxy(function(e) {
82				if (e.namespace && this._core.settings.dotsData) {
83					this._templates.splice(e.position, 0, this._templates.pop());
84				}
85			}, this),
86			'remove.owl.carousel': $.proxy(function(e) {
87				if (e.namespace && this._core.settings.dotsData) {
88					this._templates.splice(e.position, 1);
89				}
90			}, this),
91			'changed.owl.carousel': $.proxy(function(e) {
92				if (e.namespace && e.property.name == 'position') {
93					this.draw();
94				}
95			}, this),
96			'initialized.owl.carousel': $.proxy(function(e) {
97				if (e.namespace && !this._initialized) {
98					this._core.trigger('initialize', null, 'navigation');
99					this.initialize();
100					this.update();
101					this.draw();
102					this._initialized = true;
103					this._core.trigger('initialized', null, 'navigation');
104				}
105			}, this),
106			'refreshed.owl.carousel': $.proxy(function(e) {
107				if (e.namespace && this._initialized) {
108					this._core.trigger('refresh', null, 'navigation');
109					this.update();
110					this.draw();
111					this._core.trigger('refreshed', null, 'navigation');
112				}
113			}, this)
114		};
115
116		// set default options
117		this._core.options = $.extend({}, Navigation.Defaults, this._core.options);
118
119		// register event handlers
120		this.$element.on(this._handlers);
121	};
122
123	/**
124	 * Default options.
125	 * @public
126	 * @todo Rename `slideBy` to `navBy`
127	 */
128	Navigation.Defaults = {
129		nav: false,
130		navText: [
131			'<span aria-label="' + 'Previous' + '">&#x2039;</span>',
132			'<span aria-label="' + 'Next' + '">&#x203a;</span>'
133		],
134		navSpeed: false,
135		navElement: 'button type="button" role="presentation"',
136		navContainer: false,
137		navContainerClass: 'owl-nav',
138		navClass: [
139			'owl-prev',
140			'owl-next'
141		],
142		slideBy: 1,
143		dotClass: 'owl-dot',
144		dotsClass: 'owl-dots',
145		dots: true,
146		dotsEach: false,
147		dotsData: false,
148		dotsSpeed: false,
149		dotsContainer: false
150	};
151
152	/**
153	 * Initializes the layout of the plugin and extends the carousel.
154	 * @protected
155	 */
156	Navigation.prototype.initialize = function() {
157		var override,
158			settings = this._core.settings;
159
160		// create DOM structure for relative navigation
161		this._controls.$relative = (settings.navContainer ? $(settings.navContainer)
162			: $('<div>').addClass(settings.navContainerClass).appendTo(this.$element)).addClass('disabled');
163
164		this._controls.$previous = $('<' + settings.navElement + '>')
165			.addClass(settings.navClass[0])
166			.html(settings.navText[0])
167			.prependTo(this._controls.$relative)
168			.on('click', $.proxy(function(e) {
169				this.prev(settings.navSpeed);
170			}, this));
171		this._controls.$next = $('<' + settings.navElement + '>')
172			.addClass(settings.navClass[1])
173			.html(settings.navText[1])
174			.appendTo(this._controls.$relative)
175			.on('click', $.proxy(function(e) {
176				this.next(settings.navSpeed);
177			}, this));
178
179		// create DOM structure for absolute navigation
180		if (!settings.dotsData) {
181			this._templates = [ $('<button role="button">')
182				.addClass(settings.dotClass)
183				.append($('<span>'))
184				.prop('outerHTML') ];
185		}
186
187		this._controls.$absolute = (settings.dotsContainer ? $(settings.dotsContainer)
188			: $('<div>').addClass(settings.dotsClass).appendTo(this.$element)).addClass('disabled');
189
190		this._controls.$absolute.on('click', 'button', $.proxy(function(e) {
191			var index = $(e.target).parent().is(this._controls.$absolute)
192				? $(e.target).index() : $(e.target).parent().index();
193
194			e.preventDefault();
195
196			this.to(index, settings.dotsSpeed);
197		}, this));
198
199		/*$el.on('focusin', function() {
200			$(document).off(".carousel");
201
202			$(document).on('keydown.carousel', function(e) {
203				if(e.keyCode == 37) {
204					$el.trigger('prev.owl')
205				}
206				if(e.keyCode == 39) {
207					$el.trigger('next.owl')
208				}
209			});
210		});*/
211
212		// override public methods of the carousel
213		for (override in this._overrides) {
214			this._core[override] = $.proxy(this[override], this);
215		}
216	};
217
218	/**
219	 * Destroys the plugin.
220	 * @protected
221	 */
222	Navigation.prototype.destroy = function() {
223		var handler, control, property, override, settings;
224		settings = this._core.settings;
225
226		for (handler in this._handlers) {
227			this.$element.off(handler, this._handlers[handler]);
228		}
229		for (control in this._controls) {
230			if (control === '$relative' && settings.navContainer) {
231				this._controls[control].html('');
232			} else {
233				this._controls[control].remove();
234			}
235		}
236		for (override in this.overides) {
237			this._core[override] = this._overrides[override];
238		}
239		for (property in Object.getOwnPropertyNames(this)) {
240			typeof this[property] != 'function' && (this[property] = null);
241		}
242	};
243
244	/**
245	 * Updates the internal state.
246	 * @protected
247	 */
248	Navigation.prototype.update = function() {
249		var i, j, k,
250			lower = this._core.clones().length / 2,
251			upper = lower + this._core.items().length,
252			maximum = this._core.maximum(true),
253			settings = this._core.settings,
254			size = settings.center || settings.autoWidth || settings.dotsData
255				? 1 : settings.dotsEach || settings.items;
256
257		if (settings.slideBy !== 'page') {
258			settings.slideBy = Math.min(settings.slideBy, settings.items);
259		}
260
261		if (settings.dots || settings.slideBy == 'page') {
262			this._pages = [];
263
264			for (i = lower, j = 0, k = 0; i < upper; i++) {
265				if (j >= size || j === 0) {
266					this._pages.push({
267						start: Math.min(maximum, i - lower),
268						end: i - lower + size - 1
269					});
270					if (Math.min(maximum, i - lower) === maximum) {
271						break;
272					}
273					j = 0, ++k;
274				}
275				j += this._core.mergers(this._core.relative(i));
276			}
277		}
278	};
279
280	/**
281	 * Draws the user interface.
282	 * @todo The option `dotsData` wont work.
283	 * @protected
284	 */
285	Navigation.prototype.draw = function() {
286		var difference,
287			settings = this._core.settings,
288			disabled = this._core.items().length <= settings.items,
289			index = this._core.relative(this._core.current()),
290			loop = settings.loop || settings.rewind;
291
292		this._controls.$relative.toggleClass('disabled', !settings.nav || disabled);
293
294		if (settings.nav) {
295			this._controls.$previous.toggleClass('disabled', !loop && index <= this._core.minimum(true));
296			this._controls.$next.toggleClass('disabled', !loop && index >= this._core.maximum(true));
297		}
298
299		this._controls.$absolute.toggleClass('disabled', !settings.dots || disabled);
300
301		if (settings.dots) {
302			difference = this._pages.length - this._controls.$absolute.children().length;
303
304			if (settings.dotsData && difference !== 0) {
305				this._controls.$absolute.html(this._templates.join(''));
306			} else if (difference > 0) {
307				this._controls.$absolute.append(new Array(difference + 1).join(this._templates[0]));
308			} else if (difference < 0) {
309				this._controls.$absolute.children().slice(difference).remove();
310			}
311
312			this._controls.$absolute.find('.active').removeClass('active');
313			this._controls.$absolute.children().eq($.inArray(this.current(), this._pages)).addClass('active');
314		}
315	};
316
317	/**
318	 * Extends event data.
319	 * @protected
320	 * @param {Event} event - The event object which gets thrown.
321	 */
322	Navigation.prototype.onTrigger = function(event) {
323		var settings = this._core.settings;
324
325		event.page = {
326			index: $.inArray(this.current(), this._pages),
327			count: this._pages.length,
328			size: settings && (settings.center || settings.autoWidth || settings.dotsData
329				? 1 : settings.dotsEach || settings.items)
330		};
331	};
332
333	/**
334	 * Gets the current page position of the carousel.
335	 * @protected
336	 * @returns {Number}
337	 */
338	Navigation.prototype.current = function() {
339		var current = this._core.relative(this._core.current());
340		return $.grep(this._pages, $.proxy(function(page, index) {
341			return page.start <= current && page.end >= current;
342		}, this)).pop();
343	};
344
345	/**
346	 * Gets the current succesor/predecessor position.
347	 * @protected
348	 * @returns {Number}
349	 */
350	Navigation.prototype.getPosition = function(successor) {
351		var position, length,
352			settings = this._core.settings;
353
354		if (settings.slideBy == 'page') {
355			position = $.inArray(this.current(), this._pages);
356			length = this._pages.length;
357			successor ? ++position : --position;
358			position = this._pages[((position % length) + length) % length].start;
359		} else {
360			position = this._core.relative(this._core.current());
361			length = this._core.items().length;
362			successor ? position += settings.slideBy : position -= settings.slideBy;
363		}
364
365		return position;
366	};
367
368	/**
369	 * Slides to the next item or page.
370	 * @public
371	 * @param {Number} [speed=false] - The time in milliseconds for the transition.
372	 */
373	Navigation.prototype.next = function(speed) {
374		$.proxy(this._overrides.to, this._core)(this.getPosition(true), speed);
375	};
376
377	/**
378	 * Slides to the previous item or page.
379	 * @public
380	 * @param {Number} [speed=false] - The time in milliseconds for the transition.
381	 */
382	Navigation.prototype.prev = function(speed) {
383		$.proxy(this._overrides.to, this._core)(this.getPosition(false), speed);
384	};
385
386	/**
387	 * Slides to the specified item or page.
388	 * @public
389	 * @param {Number} position - The position of the item or page.
390	 * @param {Number} [speed] - The time in milliseconds for the transition.
391	 * @param {Boolean} [standard=false] - Whether to use the standard behaviour or not.
392	 */
393	Navigation.prototype.to = function(position, speed, standard) {
394		var length;
395
396		if (!standard && this._pages.length) {
397			length = this._pages.length;
398			$.proxy(this._overrides.to, this._core)(this._pages[((position % length) + length) % length].start, speed);
399		} else {
400			$.proxy(this._overrides.to, this._core)(position, speed);
401		}
402	};
403
404	$.fn.owlCarousel.Constructor.Plugins.Navigation = Navigation;
405
406})(window.Zepto || window.jQuery, window, document);

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.