PageSourceSearch

https://bahai-news.info/javascripts/DV/lib/drag_reporter.js

js bahai-news.info collected 2026-10-02 14:21:37 UTC 2,646 bytes, 80 lines download raw bytes

1DV.DragReporter = function(viewer, toWatch, dispatcher, argHash) {
2  this.viewer         = viewer;
3  this.dragClassName  = 'DV-dragging';
4  this.sensitivityY   = 1.0;
5  this.sensitivityX   = 1.0;
6  this.oldPageY       = 0;
7
8  _.extend(this, argHash);
9
10  this.dispatcher             = dispatcher;
11  this.toWatch                = this.viewer.$(toWatch);
12  this.boundReporter          = _.bind(this.mouseMoveReporter,this);
13  this.boundMouseUpReporter   = _.bind(this.mouseUpReporter,this);
14  this.boundMouseDownReporter = _.bind(this.mouseDownReporter,this);
15
16  this.setBinding();
17};
18
19DV.DragReporter.prototype.shouldIgnore = function(e) {
20  if (!this.ignoreSelector) return false;
21  var el = this.viewer.$(e.target);
22  return el.parents().is(this.ignoreSelector) || el.is(this.ignoreSelector);
23};
24
25DV.DragReporter.prototype.mouseUpReporter     = function(e){
26  if (this.shouldIgnore(e)) return true;
27  e.preventDefault();
28  clearInterval(this.updateTimer);
29  this.stop();
30};
31
32DV.DragReporter.prototype.oldPositionUpdater   = function(){
33  this.oldPageY = this.pageY;
34};
35
36DV.DragReporter.prototype.stop         = function(){
37  this.toWatch.removeClass(this.dragClassName);
38  this.toWatch.unbind('mousemove');
39};
40
41DV.DragReporter.prototype.setBinding         = function(){
42  this.toWatch.mouseup(this.boundMouseUpReporter);
43  this.toWatch.mousedown(this.boundMouseDownReporter);
44};
45
46DV.DragReporter.prototype.unBind           = function(){
47  this.toWatch.unbind('mouseup',this.boundMouseUpReporter);
48  this.toWatch.unbind('mousedown',this.boundMouseDownReporter);
49};
50
51DV.DragReporter.prototype.destroy           = function(){
52  this.unBind();
53  this.toWatch = null;
54};
55
56DV.DragReporter.prototype.mouseDownReporter   = function(e){
57   if (this.shouldIgnore(e)) return true;
58  e.preventDefault();
59  this.pageY    = e.pageY;
60  this.pageX    = e.pageX;
61  this.oldPageY = e.pageY;
62
63  this.updateTimer = setInterval(_.bind(this.oldPositionUpdater,this),1200);
64
65  this.toWatch.addClass(this.dragClassName);
66  this.toWatch.mousemove(this.boundReporter);
67};
68
69DV.DragReporter.prototype.mouseMoveReporter     = function(e){
70  if (this.shouldIgnore(e)) return true;
71  e.preventDefault();
72  var deltaX      = Math.round(this.sensitivityX * (this.pageX - e.pageX));
73  var deltaY      = Math.round(this.sensitivityY * (this.pageY - e.pageY));
74  var directionX  = (deltaX > 0) ? 'right' : 'left';
75  var directionY  = (deltaY > 0) ? 'down' : 'up';
76  this.pageY      = e.pageY;
77  this.pageX      = e.pageX;
78  if (deltaY === 0 && deltaX === 0) return;
79  this.dispatcher({ event: e, deltaX: deltaX, deltaY: deltaY, directionX: directionX, directionY: directionY });
80};

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.