cm-chessboard 7.6.4 → 7.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "7.6.4",
3
+ "version": "7.6.5",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -23,6 +23,7 @@ export class PromotionDialog extends Extension {
23
23
  this.registerExtensionPoint(EXTENSION_POINT.redrawBoard, this.extensionPointRedrawBoard.bind(this))
24
24
  this.registerExtensionPoint(EXTENSION_POINT.animation, this.extensionPointAnimation.bind(this))
25
25
  chessboard.showPromotionDialog = this.showPromotionDialog.bind(this)
26
+ chessboard.isPromotionDialogShown = this.isPromotionDialogShown.bind(this)
26
27
  this.promotionDialogGroup = Svg.addElement(chessboard.view.interactiveTopLayer, "g", {class: "promotion-dialog-group"})
27
28
  this.state = {
28
29
  displayState: DISPLAY_STATE.hidden,
@@ -42,6 +43,11 @@ export class PromotionDialog extends Extension {
42
43
  this.setDisplayState(DISPLAY_STATE.displayRequested)
43
44
  }
44
45
 
46
+ isPromotionDialogShown() {
47
+ return this.state.displayState === DISPLAY_STATE.shown ||
48
+ this.state.displayState === DISPLAY_STATE.displayRequested
49
+ }
50
+
45
51
  // private
46
52
  extensionPointRedrawBoard() {
47
53
  this.redrawDialog()
@@ -55,7 +61,6 @@ export class PromotionDialog extends Extension {
55
61
  }
56
62
  }
57
63
 
58
-
59
64
  drawPieceButton(piece, point) {
60
65
  const squareWidth = this.chessboard.view.squareWidth
61
66
  const squareHeight = this.chessboard.view.squareHeight
@@ -134,7 +139,7 @@ export class PromotionDialog extends Extension {
134
139
  }
135
140
 
136
141
  promotionDialogOnClickPiece(event) {
137
- if(event.button !== 2) {
142
+ if (event.button !== 2) {
138
143
  if (event.target.dataset.piece) {
139
144
  this.state.callback({square: this.state.dialogParams.square, piece: event.target.dataset.piece})
140
145
  this.setDisplayState(DISPLAY_STATE.hidden)
@@ -145,7 +150,7 @@ export class PromotionDialog extends Extension {
145
150
  }
146
151
 
147
152
  promotionDialogOnCancel(event) {
148
- if(this.state.displayState === DISPLAY_STATE.shown) {
153
+ if (this.state.displayState === DISPLAY_STATE.shown) {
149
154
  event.preventDefault()
150
155
  this.setDisplayState(DISPLAY_STATE.hidden)
151
156
  this.state.callback(null)
@@ -160,14 +165,14 @@ export class PromotionDialog extends Extension {
160
165
 
161
166
  setDisplayState(displayState) {
162
167
  this.state.displayState = displayState
163
- if(displayState === DISPLAY_STATE.shown) {
168
+ if (displayState === DISPLAY_STATE.shown) {
164
169
  this.clickDelegate = Utils.delegate(this.chessboard.view.svg,
165
170
  "mousedown",
166
171
  "*",
167
172
  this.promotionDialogOnClickPiece.bind(this))
168
173
  this.contextMenuListener = this.contextMenu.bind(this)
169
174
  this.chessboard.view.svg.addEventListener("contextmenu", this.contextMenuListener)
170
- } else if(displayState === DISPLAY_STATE.hidden) {
175
+ } else if (displayState === DISPLAY_STATE.hidden) {
171
176
  this.clickDelegate.remove()
172
177
  this.chessboard.view.svg.removeEventListener("contextmenu", this.contextMenuListener)
173
178
  }