PageSourceSearch

https://www.climanoticias.com/style/js/jquery.gestures.js?2084745

js climanoticias.com collected 2026-10-07 22:55:07 UTC 7,362 bytes, 281 lines download raw bytes

1(function($)
2{
3	// This script was written by Steve Fenton
4	// http://www.stevefenton.co.uk/Content/Jquery-Gestures/
5	// Feel free to use this jQuery Plugin
6	// Version: 1.0.1
7	
8	var gesturesX = 0;
9	var gesturesY = 0;
10	
11	$(document).mousemove( function (e) {
12		gesturesX = parseInt(e.pageX, 10);
13		gesturesY = parseInt(e.pageY, 10);
14	});
15	
16	$.fn.gestures = function (settings) {
17	
18		var config = {
19			classModifier: "gestures",
20			tolerance: 25,
21			startEvent: "mousedown",
22			endEvent: "mouseup",
23			advancedShapes: false,
24			shapeSpeed: 200,
25			showTrail: false,
26			trailSpeed: 50,
27			eventLimit: 5000,
28			eventHandler: function (eventName, compassPoint) {
29				// Local variable eventName, uses eight point compass directions for the drag direction
30				// Also, eventStartX, eventStaryY, eventEndX, eventEndY are all available with the details!
31				$("#gestureoutput").attr("tabindex", "0").html("Event name '" + eventName + "'. Started at (" + eventStartX + ", " + eventStartY + ") Ended at (" + eventEndX + ", " + eventEndY + ")")[0].focus();
32				if (eventName != "falsealarm") {
33					$This.html(eventName); 
34				}
35			},
36			eventHandlerAdvanced: function (directions) {
37				// Local variable directions, returns a list of direction objects to be used to form a "shape"
38				var output = GetCombinedName(directions, false, false);
39
40				$("#gestureoutput").attr("tabindex", "0").html(output)[0].focus();
41			}
42		};
43		
44		if (settings) {
45			$.extend(config, settings);
46		}
47		
48		$This = null;
49		$Body = null;
50		var eventStartX = 0;
51		var eventStartY = 0;
52		var eventEndX = 0;
53		var eventEndY = 0;
54		var previousX = 0; // Advanced Tracking
55		var previousY = 0; // Advanced Tracking
56		var underEvent = false;
57		
58		var trailTimer = null;
59		var shapeTimer = null;
60		var eventTimer = null;
61		
62		// Determines the compass direction from a gesture
63		function GetEvent(sx, sy, ex, ey) {
64		
65			var eventName = "none";
66		
67			var horizontalMovement = ex - sx;
68			var verticalMovement = sy - ey;
69		
70			// Discard horizontal movements below the tolerance threshold
71			if (horizontalMovement < config.tolerance && horizontalMovement > (config.tolerance * -1)) {
72				horizontalMovement = 0;
73			}
74
75			// Discard vertical movements below the tolerance threshold
76			if (verticalMovement < config.tolerance && verticalMovement > (config.tolerance * -1)) {
77				verticalMovement = 0;
78			}
79			
80			// For a diagonal move, horizontal should be within 50% of vertical otherwise we assume not diagonal
81			if (horizontalMovement != 0 && verticalMovement != 0) {
82				var h = horizontalMovement;
83				var v = verticalMovement;
84				// Use positive numbers for calculations
85				if (h < 0) {
86					h = h * -1;
87				}
88				if (v < 0) {
89					v = v * -1;
90				}
91				// Check "diagonality" - if it isn't diagonal enough, make it flat
92				if (h > v) {
93					if (v < (h * 0.5)) {
94						verticalMovement = 0;
95					}
96				} else {
97					if (h < (v * 0.5)) {
98						horizontalMovement = 0;
99					}
100				}
101			}
102			
103			// Adjustments are all made... lets get the event...
104			if (horizontalMovement != 0 && verticalMovement != 0) {
105				eventName = "diagonal - direction to follow";
106				if (horizontalMovement > 0) {
107					if (verticalMovement > 0) {
108						eventName = "NE";
109					} else {
110						eventName = "SE";
111					}
112				} else {
113					if (verticalMovement > 0) {
114						eventName = "NW";
115					} else {
116						eventName = "SW";
117					}
118				}
119			} else if (horizontalMovement != 0) {
120				if (horizontalMovement > 0) {
121					eventName = "E";
122				} else {
123					eventName = "W";
124				}
125			} else if (verticalMovement != 0) {
126				if (verticalMovement > 0) {
127					eventName = "N";
128				} else {
129					eventName = "S";
130				}
131			} else {
132				eventName = "falsealarm";
133			}
134		
135			return eventName;
136		}
137		
138		function GetCombinedName(directions, dropDiagonals, dropNonDiagonals) {
139			var output = "";
140			for (var i = 0; i < directions.length; i++) {
141				var show = true;
142				
143				if (dropDiagonals) {
144					if (directions[i].d.length == 2) {
145						show = false;
146					}
147				}
148				
149				if (dropNonDiagonals) {
150					if (directions[i].d.length == 1) {
151						show = false;
152					}
153				}
154			
155				if (show) {
156					output += directions[i].d + " ";
157				}
158			}
159			return $.trim(output);
160		}
161		
162		// Displays a trail for the mouse movement
163		function TrackTrail() {
164			if (underEvent) {
165				$Body.append("<div class=\"" + config.classModifier + "motion\" style=\"position: absolute; top: " + gesturesY + "px; left :" + gesturesX + "px;\">.</div>");
166				trailTimer = window.setTimeout(TrackTrail, config.trailSpeed);
167			}
168		}
169		
170		// Clears any trail
171		function ClearTrail() {
172			$("." + config.classModifier + "motion").fadeOut(1000, function () { $(this).remove(); });
173		}
174		
175		var directionArray;
176		
177		function TrackDirections() {
178			if (underEvent) {
179			
180				var xLength = gesturesX - previousX;
181				var yLength = gesturesY - previousY;
182				
183				if (xLength < 0) {
184					xLength = xLength * -1;
185				}
186				
187				if (yLength < 0) {
188					yLength = yLength * -1;
189				}
190	
191				// If the lengths are over the ignorable tolerance
192				if (xLength > config.tolerance || yLength > config.tolerance) {
193	
194					var direction = GetEvent(previousX, previousY, gesturesX, gesturesY);
195					if (direction != "falsealarm") {
196						previousX = gesturesX;
197						previousY = gesturesY;
198						if (directionArray.length == 0) {
199							directionArray[directionArray.length] = { d: direction, lx: xLength, ly: yLength };
200							config.eventHandler(direction);
201						} else{
202							if (direction != directionArray[directionArray.length - 1].d) {
203								directionArray[directionArray.length] = { d: direction, lx: xLength, ly: yLength };
204								config.eventHandler(direction);
205							} else {
206								directionArray[directionArray.length - 1].lx += xLength;
207								directionArray[directionArray.length - 1].ly += yLength;
208							}
209						}
210					}
211				}
212				
213				shapeTimer = window.setTimeout(TrackDirections, config.shapeSpeed);
214			}
215		}
216		
217		// Starts tracking
218		function StartTracking() {
219			if (!underEvent) {
220				underEvent = true;
221				eventStartX = gesturesX;
222				eventStartY = gesturesY;
223				// In case the mouse up event is lost, this will force the stop event
224				eventTimer = window.setTimeout(EndTracking, config.eventLimit);
225				// Track Advanced Shapes
226				if (config.advancedShapes) {
227					previousX = gesturesX;
228					previousY = gesturesY;
229					directionArray = new Array();
230					TrackDirections();
231				}
232				// Track Mouse Trail
233				if (config.showTrail) {
234					TrackTrail();
235				}
236			}
237		}
238		
239		// Ends tracking
240		function EndTracking() {
241			window.clearTimeout(eventTimer);
242			if (underEvent) {
243				underEvent = false;
244				eventEndX = gesturesX;
245				eventEndY = gesturesY;
246				// Track Advanced Shapes
247				if (config.advancedShapes) {
248					if (directionArray.length > 0) {
249						config.eventHandlerAdvanced(directionArray);
250					}
251				} else {
252					// Simple Event
253					config.eventHandler(GetEvent(eventStartX, eventStartY, eventEndX, eventEndY));
254				}
255				// Track Mouse Trail
256				if (config.showTrail) {
257					ClearTrail();
258				}
259			}
260		}
261		
262		
263		
264		return this.each( function () {
265			$This = $(this);
266			$Body = $("body").eq(0);
267
268			$This.bind(config.startEvent, function () {
269				StartTracking();
270				return false;
271			});
272			
273			$Body.bind(config.endEvent, function () {
274				EndTracking();
275				return false;
276			});
277		});
278		
279		return this;
280	};
281})(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.