PageSourceSearch

https://www.minhajbooks.com/js/jquerypp.custom.js

js minhajbooks.com collected 2026-09-24 10:08:31 UTC 8,237 bytes, 301 lines download raw bytes

1(function() {
2
3	var event = jQuery.event,
4
5		//helper that finds handlers by type and calls back a function, this is basically handle
6		// events - the events object
7		// types - an array of event types to look for
8		// callback(type, handlerFunc, selector) - a callback
9		// selector - an optional selector to filter with, if there, matches by selector
10		//     if null, matches anything, otherwise, matches with no selector
11		findHelper = function( events, types, callback, selector ) {
12			var t, type, typeHandlers, all, h, handle, 
13				namespaces, namespace,
14				match;
15			for ( t = 0; t < types.length; t++ ) {
16				type = types[t];
17				all = type.indexOf(".") < 0;
18				if (!all ) {
19					namespaces = type.split(".");
20					type = namespaces.shift();
21					namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
22				}
23				typeHandlers = (events[type] || []).slice(0);
24
25				for ( h = 0; h < typeHandlers.length; h++ ) {
26					handle = typeHandlers[h];
27					
28					match = (all || namespace.test(handle.namespace));
29					
30					if(match){
31						if(selector){
32							if (handle.selector === selector  ) {
33								callback(type, handle.origHandler || handle.handler);
34							}
35						} else if (selector === null){
36							callback(type, handle.origHandler || handle.handler, handle.selector);
37						}
38						else if (!handle.selector ) {
39							callback(type, handle.origHandler || handle.handler);
40							
41						} 
42					}
43					
44					
45				}
46			}
47		};
48
49	/**
50	 * Finds event handlers of a given type on an element.
51	 * @param {HTMLElement} el
52	 * @param {Array} types an array of event names
53	 * @param {String} [selector] optional selector
54	 * @return {Array} an array of event handlers
55	 */
56	event.find = function( el, types, selector ) {
57		var events = ( $._data(el) || {} ).events,
58			handlers = [],
59			t, liver, live;
60
61		if (!events ) {
62			return handlers;
63		}
64		findHelper(events, types, function( type, handler ) {
65			handlers.push(handler);
66		}, selector);
67		return handlers;
68	};
69	/**
70	 * Finds all events.  Group by selector.
71	 * @param {HTMLElement} el the element
72	 * @param {Array} types event types
73	 */
74	event.findBySelector = function( el, types ) {
75		var events = $._data(el).events,
76			selectors = {},
77			//adds a handler for a given selector and event
78			add = function( selector, event, handler ) {
79				var select = selectors[selector] || (selectors[selector] = {}),
80					events = select[event] || (select[event] = []);
81				events.push(handler);
82			};
83
84		if (!events ) {
85			return selectors;
86		}
87		//first check live:
88		/*$.each(events.live || [], function( i, live ) {
89			if ( $.inArray(live.origType, types) !== -1 ) {
90				add(live.selector, live.origType, live.origHandler || live.handler);
91			}
92		});*/
93		//then check straight binds
94		findHelper(events, types, function( type, handler, selector ) {
95			add(selector || "", type, handler);
96		}, null);
97
98		return selectors;
99	};
100	event.supportTouch = "ontouchend" in document;
101	
102	$.fn.respondsTo = function( events ) {
103		if (!this.length ) {
104			return false;
105		} else {
106			//add default ?
107			return event.find(this[0], $.isArray(events) ? events : [events]).length > 0;
108		}
109	};
110	$.fn.triggerHandled = function( event, data ) {
111		event = (typeof event == "string" ? $.Event(event) : event);
112		this.trigger(event, data);
113		return event.handled;
114	};
115	/**
116	 * Only attaches one event handler for all types ...
117	 * @param {Array} types llist of types that will delegate here
118	 * @param {Object} startingEvent the first event to start listening to
119	 * @param {Object} onFirst a function to call 
120	 */
121	event.setupHelper = function( types, startingEvent, onFirst ) {
122		if (!onFirst ) {
123			onFirst = startingEvent;
124			startingEvent = null;
125		}
126		var add = function( handleObj ) {
127
128			var bySelector, selector = handleObj.selector || "";
129			if ( selector ) {
130				bySelector = event.find(this, types, selector);
131				if (!bySelector.length ) {
132					$(this).delegate(selector, startingEvent, onFirst);
133				}
134			}
135			else {
136				//var bySelector = event.find(this, types, selector);
137				if (!event.find(this, types, selector).length ) {
138					event.add(this, startingEvent, onFirst, {
139						selector: selector,
140						delegate: this
141					});
142				}
143
144			}
145
146		},
147			remove = function( handleObj ) {
148				var bySelector, selector = handleObj.selector || "";
149				if ( selector ) {
150					bySelector = event.find(this, types, selector);
151					if (!bySelector.length ) {
152						$(this).undelegate(selector, startingEvent, onFirst);
153					}
154				}
155				else {
156					if (!event.find(this, types, selector).length ) {
157						event.remove(this, startingEvent, onFirst, {
158							selector: selector,
159							delegate: this
160						});
161					}
162				}
163			};
164		$.each(types, function() {
165			event.special[this] = {
166				add: add,
167				remove: remove,
168				setup: function() {},
169				teardown: function() {}
170			};
171		});
172	};
173})(jQuery);
174(function($){
175var isPhantom = /Phantom/.test(navigator.userAgent),
176	supportTouch = !isPhantom && "ontouchend" in document,
177	scrollEvent = "touchmove scroll",
178	// Use touch events or map it to mouse events
179	touchStartEvent = supportTouch ? "touchstart" : "mousedown",
180	touchStopEvent = supportTouch ? "touchend" : "mouseup",
181	touchMoveEvent = supportTouch ? "touchmove" : "mousemove",
182	data = function(event){
183		var d = event.originalEvent.touches ?
184			event.originalEvent.touches[ 0 ] :
185			event;
186		return {
187			time: (new Date).getTime(),
188			coords: [ d.pageX, d.pageY ],
189			origin: $( event.target )
190		};
191	};
192
193/**
194 * @add jQuery.event.swipe
195 */
196var swipe = $.event.swipe = {
197	/**
198	 * @attribute delay
199	 * Delay is the upper limit of time the swipe motion can take in milliseconds.  This defaults to 500.
200	 * 
201	 * A user must perform the swipe motion in this much time.
202	 */
203	delay : 500,
204	/**
205	 * @attribute max
206	 * The maximum distance the pointer must travel in pixels.  The default is 75 pixels.
207	 */
208	max : 75,
209	/**
210	 * @attribute min
211	 * The minimum distance the pointer must travel in pixels.  The default is 30 pixels.
212	 */
213	min : 30
214};
215
216$.event.setupHelper( [
217
218/**
219 * @hide
220 * @attribute swipe
221 */
222"swipe",
223/**
224 * @hide
225 * @attribute swipeleft
226 */
227'swipeleft',
228/**
229 * @hide
230 * @attribute swiperight
231 */
232'swiperight',
233/**
234 * @hide
235 * @attribute swipeup
236 */
237'swipeup',
238/**
239 * @hide
240 * @attribute swipedown
241 */
242'swipedown'], touchStartEvent, function(ev){
243	var
244		// update with data when the event was started
245		start = data(ev),
246		stop,
247		delegate = ev.delegateTarget || ev.currentTarget,
248		selector = ev.handleObj.selector,
249		entered = this;
250	
251	function moveHandler(event){
252		if ( !start ) {
253			return;
254		}
255		// update stop with the data from the current event
256		stop = data(event);
257
258		// prevent scrolling
259		if ( Math.abs( start.coords[0] - stop.coords[0] ) > 10 ) {
260			event.preventDefault();
261		}
262	};
263
264	// Attach to the touch move events
265	$(document.documentElement).bind(touchMoveEvent, moveHandler)
266		.one(touchStopEvent, function(event){
267			$(this).unbind( touchMoveEvent, moveHandler);
268			// if start and stop contain data figure out if we have a swipe event
269			if ( start && stop ) {
270				// calculate the distance between start and stop data
271				var deltaX = Math.abs(start.coords[0] - stop.coords[0]),
272					deltaY = Math.abs(start.coords[1] - stop.coords[1]),
273					distance = Math.sqrt(deltaX*deltaX+deltaY*deltaY);
274
275				// check if the delay and distance are matched
276				if ( stop.time - start.time < swipe.delay && distance >= swipe.min ) {
277					var events = ['swipe'];
278					// check if we moved horizontally
279					if( deltaX >= swipe.min && deltaY < swipe.min) {
280						// based on the x coordinate check if we moved left or right
281						events.push( start.coords[0] > stop.coords[0] ? "swipeleft" : "swiperight" );
282					} else
283					// check if we moved vertically
284					if(deltaY >= swipe.min && deltaX < swipe.min){
285						// based on the y coordinate check if we moved up or down
286						events.push( start.coords[1] < stop.coords[1] ? "swipedown" : "swipeup" );
287					}
288
289					// trigger swipe events on this guy
290					$.each($.event.find(delegate, events, selector), function(){
291						this.call(entered, ev, {start : start, end: stop})
292					})
293				
294				}
295			}
296			// reset start and stop
297			start = stop = undefined;
298		})
299});
300
301})(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.