PageSourceSearch

https://djk-emmerting.de/wp-content/plugins/eventBookingPro/js/jquery.dropdown.js?ver=20170423

js djk-emmerting.de collected 2026-09-25 09:47:14 UTC 9,327 bytes, 267 lines download raw bytes

1/**
2 * jquery.dropdown.js v1.0.0
3 * http://www.codrops.com
4 *
5 * Licensed under the MIT license.
6 * http://www.opensource.org/licenses/mit-license.php
7 *
8 * Edited by Moe Haydar
9 */
10;(function($, window, undefined) {
11
12	'use strict';
13
14	$.DropDownEBP = function(options, element) {
15		this.$el = $(element);
16		this._init(options);
17	};
18
19	// the options
20	$.DropDownEBP.defaults = {
21		speed : 300,
22		easing : 'ease',
23		gutter : 0,
24		// initial stack effect
25		stack : true,
26		// delay between each option animation
27		delay : 0,
28		// random angle and positions for the options
29		random : false,
30		// rotated [right||left||false] : the options will be rotated to thr right side or left side.
31		// make sure to tune the transform origin in the stylesheet
32		rotated : false,
33		// effect to slide in the options. value is the margin to start with
34		slidingIn : false,
35		onOptionSelect : function(opt) { return false; }
36	};
37
38	$.DropDownEBP.prototype = {
39		_init : function(options) {
40			// options
41			this.options = $.extend(true, {}, $.DropDownEBP.defaults, options);
42			this._layout();
43			this._initEvents();
44		},
45
46		_layout : function () {
47			var self = this;
48			this.minZIndex = 1000;
49			var selected = this._transformSelect();
50			this.opts = this.listopts.children('li');
51			this.optsCount = this.opts.length;
52			this.size = { width : this.dd.width(), height : this.dd.height() };
53
54			var elName = this.$el.attr('name'), elId = this.$el.attr('id'),
55				inputName = elName !== undefined ? elName : elId !== undefined ? elId : 'cd-dropdown-' + (new Date()).getTime();
56
57			this.inputEl = $('<input type="hidden" name="' + inputName + '" data-cost="' + selected.cost + '" data-costs="' + selected.costs + '" data-breakdown="' + selected.breakdown + '" data-names="' + selected.names + '" value="' + selected.value + '"></input>').insertAfter(this.selectlabel);
58
59			this.selectlabel.css('z-index', this.minZIndex + this.optsCount);
60			this._positionOpts();
61			if (ModernizrC.csstransitions) {
62				setTimeout(function () {self.opts.css('transition', 'all ' + self.options.speed + 'ms ' + self.options.easing); }, 25);
63			}
64
65		},
66
67		_transformSelect : function () {
68			var optshtml = '', selectlabel = '', value = -1, selectedCost = 0, selectedBreakdown, selectedNames, selectedCosts;
69
70			this.$el.children('option').each(function () {
71
72				var $this = $(this),
73					val = isNaN($this.attr('value')) ? $this.attr('value') : Number($this.attr('value')) ,
74					cost = isNaN($this.attr('data-cost')) ? $this.attr('data-cost') : Number($this.attr('data-cost')),
75					breakdown = $this.attr('data-breakdown'),
76					names = $this.attr('data-names'),
77					costs = $this.attr('data-costs'),
78					allowed = isNaN($this.attr('data-allowed')) ? $this.attr('data-allowed') : Number($this.attr('data-allowed')) ,
79					classes = $this.attr('class'),
80					selected = $this.attr('selected'),
81					label = $this.text();
82
83				if (val !== -1) {
84					var li_html = '';
85					var class_html = (classes !== undefined) ? 'class="' + classes + '"' : '';
86
87					var datas = ''
88
89					if (allowed || allowed == 0) datas += 'data-allowed="' + allowed + '"';
90					if (cost || cost >= 0) datas += 'data-cost="' + cost + '"';
91					if ($this.attr('data-bookingStatus')) datas += 'data-bookingStatus="' + $this.attr('data-bookingStatus') + '"';
92					if ($this.attr('data-startsTxt')) datas += 'data-startsTxt="' + $this.attr('data-startsTxt') + '"';
93					if ($this.attr('data-endsTxt')) datas += 'data-endsTxt="' + $this.attr('data-endsTxt') + '"';
94					if ($this.attr('data-fee-type')) datas += 'data-fee-type="' + $this.attr('data-fee-type') + '"';
95					if ($this.attr('data-breakdown')) datas += 'data-breakdown="' + $this.attr('data-breakdown') + '"';
96					if ($this.attr('data-names')) datas += 'data-names="' + $this.attr('data-names') + '"';
97					if ($this.attr('data-costs')) datas += 'data-costs="' + $this.attr('data-costs') + '"';
98
99
100					li_html = '<li data-value="' + val + '" ' + datas + '><span ' + class_html + '>' + label + '</span></li>';
101
102					optshtml += li_html
103
104				}
105
106				if (selected) {
107					selectlabel = label;
108					value = val;
109					selectedCost = cost;
110					selectedBreakdown = breakdown;
111					selectedNames = names;
112					selectedCosts = costs;
113				}
114
115			});
116
117			this.listopts = $('<ul/>').append(optshtml);
118			this.selectlabel = $('<span/>').append(selectlabel);
119			this.dd = $('<div class="cd-dropdown"/>').append(this.selectlabel, this.listopts).insertAfter(this.$el);
120			this.$el.remove();
121
122			return {
123				value: value,
124				cost: selectedCost,
125				breakdown: selectedBreakdown,
126				names: selectedNames,
127				costs: selectedCosts
128			};
129		},
130
131		_positionOpts : function(anim) {
132			var self = this;
133
134			this.listopts.css('height', 'auto');
135			this.listopts.css('top', (self.size.height + self.options.gutter));
136
137			this.opts
138				.each(function(i) {
139					$(this).css({
140						zIndex : self.minZIndex + self.optsCount - 1 - i,
141						top : self.options.slidingIn ? (i) * (self.size.height + self.options.gutter) : 0,
142						left : 0,
143						marginLeft : self.options.slidingIn ? i % 2 === 0 ? self.options.slidingIn : - self.options.slidingIn : 0,
144						opacity : self.options.slidingIn ? 0 : 1,
145						transform : 'none'
146					});
147				});
148
149			if (!this.options.slidingIn) {
150				this.opts
151					.eq(this.optsCount - 1)
152					.css({ top : this.options.stack ? 9 : 0, left : this.options.stack ? 4 : 0, width : this.options.stack ? this.size.width - 8 : this.size.width, transform : 'none' })
153					.end()
154					.eq(this.optsCount - 2)
155					.css({ top : this.options.stack ? 6 : 0, left : this.options.stack ? 2 : 0, width : this.options.stack ? this.size.width - 4 : this.size.width, transform : 'none' })
156					.end()
157					.eq(this.optsCount - 3)
158					.css({ top : this.options.stack ? 3 : 0, left : 0, transform : 'none' });
159			}
160
161		},
162
163		_initEvents : function () {
164			var self = this;
165
166			this.selectlabel.on('mousedown.dropdown', function(event) {
167				self.opened ? self.close() : self.open();
168				return false;
169
170			});
171
172			this.opts.on('click.dropdown', function () {
173				if (self.opened) {
174					var opt = $(this);
175					self.inputEl.val(opt.data('value'));
176
177					var cost = isNaN(opt.attr('data-cost')) ? '' : Number(opt.attr('data-cost'));
178					self.inputEl.attr('data-cost', cost);
179
180					var dataFeeType = (opt.attr('data-fee-type')) ? opt.attr('data-fee-type') : '';
181					self.inputEl.attr('data-fee-type', dataFeeType);
182
183					var breakdown = (opt.attr('data-breakdown')) ? opt.attr('data-breakdown') : '';
184					self.inputEl.attr('data-breakdown', breakdown);
185
186					var names = (opt.attr('data-names')) ? opt.attr('data-names') : '';
187					self.inputEl.attr('data-names', names);
188
189					var costs = (opt.attr('data-costs')) ? opt.attr('data-costs') : '';
190					self.inputEl.attr('data-costs', costs);
191
192
193					self.selectlabel.html(opt.html());
194					self.close();
195					self.options.onOptionSelect(opt);
196				}
197			});
198
199		},
200
201		open : function () {
202			var self = this;
203			var h;
204			this.dd.toggleClass('cd-active');
205			var listHeight =(this.optsCount + 1) * (this.size.height + this.options.gutter);
206
207			this.listopts.css('height', listHeight);
208
209			if (this.listopts.height() > 450) {
210				this.listopts.css('height',"450");
211				this.listopts.css('overflow-y',"scroll");
212				this.listopts.css('overflow-x',"hidden");
213			}
214
215			this.opts.each(function(i) {
216			h = (self.size.height > 40)?self.size.height:40;
217				$(this).css({
218					opacity : 1,
219					top : self.options.rotated ? h + self.options.gutter : (i) * (h + self.options.gutter),
220					left : self.options.random ? Math.floor(Math.random() * 11 - 5) : 0,
221
222					marginLeft : 0,
223					transform : self.options.random ?
224						'rotate(' + Math.floor(Math.random() * 11 - 5) + 'deg)' :
225						self.options.rotated ?
226							self.options.rotated === 'right' ?
227								'rotate(-' + (i * 5) + 'deg)' :
228								'rotate(' + (i * 5) + 'deg)'
229							: 'none',
230					transitionDelay : self.options.delay && ModernizrC.csstransitions ? self.options.slidingIn ? (i * self.options.delay) + 'ms' : ((self.optsCount - 1 - i) * self.options.delay) + 'ms' : 0
231				});
232			});
233			this.opened = true;
234		},
235
236		close : function () {
237			var self = this;
238
239			this.dd.toggleClass('cd-active');
240			if (this.options.delay && ModernizrC.csstransitions) {
241				this.opts.each(function(i) {
242					$(this).css({ 'transition-delay' : self.options.slidingIn ? ((self.optsCount - 1 - i) * self.options.delay) + 'ms' : (i * self.options.delay) + 'ms' });
243				});
244			}
245			this._positionOpts(true);
246			this.opened = false;
247			this.listopts.css('overflow-y', 'default');
248			this.listopts.css('overflow-x', 'default');
249		}
250	}
251
252	$.fn.dropdownEBP = function(options) {
253		var instance = $.data(this, 'dropdownEBP');
254		if (typeof options === 'string') {
255			var args = Array.prototype.slice.call(arguments, 1);
256			this.each(function () {
257				instance[ options ].apply(instance, args);
258			});
259		} else {
260			this.each(function () {
261				instance ? instance._init() : instance = $.data(this, 'dropdownEBP', new $.DropDownEBP(options, this));
262			});
263		}
264		return instance;
265	};
266
267})(jQuery, window);

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.