Kaynağa Gözat

remove jq from reset of utils

Adam Shaw 8 yıl önce
ebeveyn
işleme
d7055d5844

+ 2 - 2
src/common/DragListener.ts

@@ -100,7 +100,7 @@ export default class DragListener {
       this.minDistance = firstDefined(extraOptions.distance, this.options.distance, 0)
       this.subjectEl = this.options.subjectEl
 
-      preventSelection($('body'))
+      preventSelection(document.body)
 
       this.isInteracting = true
       this.isTouch = getEvIsTouch(ev)
@@ -144,7 +144,7 @@ export default class DragListener {
       this.isInteracting = false
       this.handleInteractionEnd(ev, isCancelled)
 
-      allowSelection($('body'))
+      allowSelection(document.body)
     }
   }
 

+ 1 - 1
src/component/interactions/DateSelecting.ts

@@ -60,7 +60,7 @@ export default class DateSelecting extends Interaction {
       }
     })
 
-    preventSelection($(el))
+    preventSelection(el)
   }
 
 

+ 24 - 22
src/util.ts

@@ -1,6 +1,5 @@
-import * as $ from 'jquery'
 import * as moment from 'moment'
-import { applyStyle, computeHeightAndMargins } from './util/dom'
+import { applyStyle, computeHeightAndMargins, makeElement, removeElement } from './util/dom'
 
 
 /* FullCalendar-specific DOM Utilities
@@ -275,8 +274,8 @@ function getIsLeftRtlScrollbars() { // responsible for caching the computation
 }
 
 function computeIsLeftRtlScrollbars() { // creates an offscreen test element, then removes it
-  let el = $('<div><div></div></div>')
-    .css({
+  let outerEl = makeElement('div', {
+    style: {
       position: 'absolute',
       top: -1000,
       left: 0,
@@ -284,11 +283,14 @@ function computeIsLeftRtlScrollbars() { // creates an offscreen test element, th
       padding: 0,
       overflow: 'scroll',
       direction: 'rtl'
-    })
-    .appendTo('body')
-  let innerEl = el.children()
-  let res = innerEl.offset().left > el.offset().left // is the inner div shifted to accommodate a left scrollbar?
-  el.remove()
+    }
+  }, '<div></div>')
+
+  document.body.appendChild(outerEl)
+  let innerEl = outerEl.firstChild as HTMLElement
+  let res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left
+
+  removeElement(outerEl)
   return res
 }
 
@@ -298,13 +300,13 @@ function computeIsLeftRtlScrollbars() { // creates an offscreen test element, th
 
 
 // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
-export function isPrimaryMouseButton(ev) {
-  return ev.which === 1 && !ev.ctrlKey
+export function isPrimaryMouseButton(ev: MouseEvent) {
+  return ev.button === 0 && !ev.ctrlKey
 }
 
 
-export function getEvX(ev) {
-  let touches = ev.touches
+export function getEvX(ev: UIEvent) {
+  let touches = (ev as TouchEvent).touches
 
   // on mobile FF, pageX for touch events is present, but incorrect,
   // so, look at touch coordinates first.
@@ -312,12 +314,12 @@ export function getEvX(ev) {
     return touches[0].pageX
   }
 
-  return ev.pageX
+  return (ev as MouseEvent).pageX
 }
 
 
 export function getEvY(ev) {
-  let touches = ev.touches
+  let touches = (ev as TouchEvent).touches
 
   // on mobile FF, pageX for touch events is present, but incorrect,
   // so, look at touch coordinates first.
@@ -325,7 +327,7 @@ export function getEvY(ev) {
     return touches[0].pageY
   }
 
-  return ev.pageY
+  return (ev as MouseEvent).pageY
 }
 
 
@@ -334,15 +336,15 @@ export function getEvIsTouch(ev) {
 }
 
 
-export function preventSelection(el: JQuery) {
-  el.addClass('fc-unselectable')
-    .on('selectstart', preventDefault)
+export function preventSelection(el: HTMLElement) {
+  el.classList.add('fc-unselectable')
+  el.addEventListener('selectstart', preventDefault)
 }
 
 
-export function allowSelection(el: JQuery) {
-  el.removeClass('fc-unselectable')
-    .off('selectstart', preventDefault)
+export function allowSelection(el: HTMLElement) {
+  el.classList.remove('fc-unselectable')
+  el.removeEventListener('selectstart', preventDefault)
 }