ay-menu-button
Advanced tools
Comparing version 1.0.2 to 1.0.3
/*! Copyright 2016 Ayogo Health Inc. */ | ||
export declare class MenuButtonBehaviour { | ||
private el; | ||
private menu; | ||
private clickHandler; | ||
@@ -6,0 +5,0 @@ private keyHandler; |
@@ -6,15 +6,6 @@ /*! Copyright 2016 Ayogo Health Inc. */ | ||
this.el = btn; | ||
let menuID = this.el.getAttribute('menu'); | ||
if (!menuID) { | ||
return; | ||
} | ||
let menu = btn.ownerDocument.getElementById(menuID); | ||
if (!menu) { | ||
return; | ||
} | ||
this.menu = menu; | ||
this.el.setAttribute('aria-haspopup', 'true'); | ||
this.el.setAttribute('aria-expanded', 'false'); | ||
this.clickHandler = () => { | ||
MenuManager.toggleMenu(this.el, this.menu); | ||
MenuManager.toggleMenu(this.el); | ||
}; | ||
@@ -40,3 +31,2 @@ this.keyHandler = (e) => { | ||
this.resizeHandler = null; | ||
this.menu = null; | ||
this.el = null; | ||
@@ -50,3 +40,3 @@ } | ||
if (!MenuManager.open) { | ||
MenuManager.openMenu(this.el, this.menu, true); | ||
MenuManager.openMenu(this.el, true); | ||
} | ||
@@ -53,0 +43,0 @@ else { |
@@ -10,5 +10,5 @@ /*! Copyright 2016 Ayogo Health Inc. */ | ||
static readonly open: boolean; | ||
static openMenu(btn: HTMLButtonElement, mnu: HTMLMenuElement, focus?: boolean): void; | ||
static openMenu(btn: HTMLButtonElement, focus?: boolean): void; | ||
static closeMenu(): void; | ||
static toggleMenu(btn: HTMLButtonElement, mnu: HTMLMenuElement): void; | ||
static toggleMenu(btn: HTMLButtonElement): void; | ||
static focusMenu(): void; | ||
@@ -15,0 +15,0 @@ private static clickMenuItem(); |
@@ -6,6 +6,14 @@ /*! Copyright 2016 Ayogo Health Inc. */ | ||
} | ||
static openMenu(btn, mnu, focus = false) { | ||
static openMenu(btn, focus = false) { | ||
if (this.transitionEndHandler !== null) { | ||
this.transitionEndHandler(); | ||
} | ||
let mnuID = btn.getAttribute('menu'); | ||
if (!mnuID) { | ||
return; | ||
} | ||
let mnu = btn.ownerDocument.getElementById(mnuID); | ||
if (!mnu) { | ||
return; | ||
} | ||
this.curButton = btn; | ||
@@ -67,3 +75,3 @@ this.curMenu = mnu; | ||
} | ||
static toggleMenu(btn, mnu) { | ||
static toggleMenu(btn) { | ||
let openMnu = this.curMenu; | ||
@@ -73,4 +81,4 @@ if (this.isOpen && btn === this.curButton) { | ||
} | ||
if (openMnu !== mnu) { | ||
this.openMenu(btn, mnu); | ||
if (!openMnu || openMnu.getAttribute('id') !== btn.getAttribute('menu')) { | ||
this.openMenu(btn); | ||
} | ||
@@ -77,0 +85,0 @@ } |
@@ -18,3 +18,3 @@ /*! Copyright 2017 Ayogo Health Inc. */ | ||
}); | ||
MenuManager.openMenu = function (btn, mnu, focus) { | ||
MenuManager.openMenu = function (btn, focus) { | ||
if (focus === void 0) { focus = false; } | ||
@@ -24,2 +24,10 @@ if (this.transitionEndHandler !== null) { | ||
} | ||
var mnuID = btn.getAttribute('menu'); | ||
if (!mnuID) { | ||
return; | ||
} | ||
var mnu = btn.ownerDocument.getElementById(mnuID); | ||
if (!mnu) { | ||
return; | ||
} | ||
this.curButton = btn; | ||
@@ -82,3 +90,3 @@ this.curMenu = mnu; | ||
}; | ||
MenuManager.toggleMenu = function (btn, mnu) { | ||
MenuManager.toggleMenu = function (btn) { | ||
var openMnu = this.curMenu; | ||
@@ -88,4 +96,4 @@ if (this.isOpen && btn === this.curButton) { | ||
} | ||
if (openMnu !== mnu) { | ||
this.openMenu(btn, mnu); | ||
if (!openMnu || openMnu.getAttribute('id') !== btn.getAttribute('menu')) { | ||
this.openMenu(btn); | ||
} | ||
@@ -288,15 +296,6 @@ }; | ||
this.el = btn; | ||
var menuID = this.el.getAttribute('menu'); | ||
if (!menuID) { | ||
return; | ||
} | ||
var menu = btn.ownerDocument.getElementById(menuID); | ||
if (!menu) { | ||
return; | ||
} | ||
this.menu = menu; | ||
this.el.setAttribute('aria-haspopup', 'true'); | ||
this.el.setAttribute('aria-expanded', 'false'); | ||
this.clickHandler = function () { | ||
MenuManager.toggleMenu(_this.el, _this.menu); | ||
MenuManager.toggleMenu(_this.el); | ||
}; | ||
@@ -322,3 +321,2 @@ this.keyHandler = function (e) { | ||
this.resizeHandler = null; | ||
this.menu = null; | ||
this.el = null; | ||
@@ -332,3 +330,3 @@ }; | ||
if (!MenuManager.open) { | ||
MenuManager.openMenu(this.el, this.menu, true); | ||
MenuManager.openMenu(this.el, true); | ||
} | ||
@@ -335,0 +333,0 @@ else { |
@@ -18,3 +18,3 @@ /*! Copyright 2017 Ayogo Health Inc. */ | ||
}); | ||
MenuManager.openMenu = function (btn, mnu, focus) { | ||
MenuManager.openMenu = function (btn, focus) { | ||
if (focus === void 0) { focus = false; } | ||
@@ -24,2 +24,10 @@ if (this.transitionEndHandler !== null) { | ||
} | ||
var mnuID = btn.getAttribute('menu'); | ||
if (!mnuID) { | ||
return; | ||
} | ||
var mnu = btn.ownerDocument.getElementById(mnuID); | ||
if (!mnu) { | ||
return; | ||
} | ||
this.curButton = btn; | ||
@@ -82,3 +90,3 @@ this.curMenu = mnu; | ||
}; | ||
MenuManager.toggleMenu = function (btn, mnu) { | ||
MenuManager.toggleMenu = function (btn) { | ||
var openMnu = this.curMenu; | ||
@@ -88,4 +96,4 @@ if (this.isOpen && btn === this.curButton) { | ||
} | ||
if (openMnu !== mnu) { | ||
this.openMenu(btn, mnu); | ||
if (!openMnu || openMnu.getAttribute('id') !== btn.getAttribute('menu')) { | ||
this.openMenu(btn); | ||
} | ||
@@ -288,15 +296,6 @@ }; | ||
this.el = btn; | ||
var menuID = this.el.getAttribute('menu'); | ||
if (!menuID) { | ||
return; | ||
} | ||
var menu = btn.ownerDocument.getElementById(menuID); | ||
if (!menu) { | ||
return; | ||
} | ||
this.menu = menu; | ||
this.el.setAttribute('aria-haspopup', 'true'); | ||
this.el.setAttribute('aria-expanded', 'false'); | ||
this.clickHandler = function () { | ||
MenuManager.toggleMenu(_this.el, _this.menu); | ||
MenuManager.toggleMenu(_this.el); | ||
}; | ||
@@ -322,3 +321,2 @@ this.keyHandler = function (e) { | ||
this.resizeHandler = null; | ||
this.menu = null; | ||
this.el = null; | ||
@@ -332,3 +330,3 @@ }; | ||
if (!MenuManager.open) { | ||
MenuManager.openMenu(this.el, this.menu, true); | ||
MenuManager.openMenu(this.el, true); | ||
} | ||
@@ -335,0 +333,0 @@ else { |
{ | ||
"name": "ay-menu-button", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"copyright": "Copyright 2016 Ayogo Health Inc.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,3 +7,2 @@ /*! Copyright 2016 Ayogo Health Inc. */ | ||
private el: null | HTMLButtonElement; | ||
private menu : null | HTMLMenuElement; | ||
@@ -17,14 +16,2 @@ private clickHandler : null | (() => void); | ||
let menuID = this.el.getAttribute('menu'); | ||
if (!menuID) { | ||
return; | ||
} | ||
let menu = btn.ownerDocument.getElementById(menuID) as HTMLMenuElement; | ||
if (!menu) { | ||
return; | ||
} | ||
this.menu = menu; | ||
this.el.setAttribute('aria-haspopup', 'true'); | ||
@@ -34,3 +21,3 @@ this.el.setAttribute('aria-expanded', 'false'); | ||
this.clickHandler = () => { | ||
MenuManager.toggleMenu(this.el!, this.menu!); | ||
MenuManager.toggleMenu(this.el!); | ||
}; | ||
@@ -63,3 +50,2 @@ | ||
this.resizeHandler = null; | ||
this.menu = null; | ||
this.el = null; | ||
@@ -78,3 +64,3 @@ } | ||
if (!MenuManager.open) { | ||
MenuManager.openMenu(this.el!, this.menu!, true); | ||
MenuManager.openMenu(this.el!, true); | ||
} else { | ||
@@ -81,0 +67,0 @@ MenuManager.focusMenu(); |
@@ -16,3 +16,3 @@ /*! Copyright 2016 Ayogo Health Inc. */ | ||
static openMenu(btn : HTMLButtonElement, mnu : HTMLMenuElement, focus : boolean = false) { | ||
static openMenu(btn : HTMLButtonElement, focus : boolean = false) { | ||
if (this.transitionEndHandler !== null) { | ||
@@ -22,4 +22,14 @@ this.transitionEndHandler(); | ||
let mnuID = btn.getAttribute('menu'); | ||
if (!mnuID) { | ||
return; | ||
} | ||
let mnu = btn.ownerDocument.getElementById(mnuID); | ||
if (!mnu) { | ||
return; | ||
} | ||
this.curButton = btn; | ||
this.curMenu = mnu; | ||
this.curMenu = mnu as HTMLMenuElement; | ||
this.isOpen = true; | ||
@@ -98,3 +108,3 @@ | ||
static toggleMenu(btn : HTMLButtonElement, mnu : HTMLMenuElement) { | ||
static toggleMenu(btn : HTMLButtonElement) { | ||
let openMnu = this.curMenu; | ||
@@ -106,4 +116,4 @@ | ||
if (openMnu !== mnu) { | ||
this.openMenu(btn, mnu); | ||
if (!openMnu || openMnu.getAttribute('id') !== btn.getAttribute('menu')) { | ||
this.openMenu(btn); | ||
} | ||
@@ -110,0 +120,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135550
1699