-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Shipping methods in load:shipping event
- Loading branch information
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export default class ShippingMethod extends HTMLDivElement{ | ||
constructor(element){ | ||
if(!(element instanceof HTMLDivElement) | ||
|| !element.classList.contains('radio-wrapper')){ | ||
throw TypeError('Not a radio-wrapper'); | ||
} | ||
Object.setPrototypeOf(element, ShippingMethod.prototype); | ||
return element; | ||
} | ||
|
||
addDescription(text){ | ||
let span = this.querySelector('.radio__label__primary'); | ||
let desc = document.createElement('span'); | ||
desc.classList.add('small-text'); | ||
desc.innerHTML = text; | ||
|
||
span.appendChild(document.createElement('br')); | ||
span.appendChild(desc); | ||
} | ||
|
||
get checked(){ | ||
let input = this.querySelector('input'); | ||
if(!input) return false; | ||
return input.checked; | ||
} | ||
|
||
set checked(boolean){ | ||
let input = this.querySelector('input'); | ||
if(!input || !(typeof boolean == 'boolean')) return; | ||
return input.checked = boolean; | ||
} | ||
} |