diff options
Diffstat (limited to '')
-rw-r--r-- | static/components.ts (renamed from static/elements.ts) | 0 | ||||
-rw-r--r-- | static/components/date-time-input.ts | 2 | ||||
-rw-r--r-- | static/components/input-list.ts | 2 | ||||
-rw-r--r-- | static/components/popup-element.ts | 7 | ||||
-rw-r--r-- | static/components/slider.ts | 18 | ||||
-rw-r--r-- | static/components/vevent-block.ts | 2 | ||||
-rw-r--r-- | static/components/vevent-edit.ts | 8 | ||||
-rw-r--r-- | static/components/vevent.ts | 4 |
8 files changed, 20 insertions, 23 deletions
diff --git a/static/elements.ts b/static/components.ts index e5fabba6..e5fabba6 100644 --- a/static/elements.ts +++ b/static/components.ts diff --git a/static/components/date-time-input.ts b/static/components/date-time-input.ts index 005e4190..20e9a505 100644 --- a/static/components/date-time-input.ts +++ b/static/components/date-time-input.ts @@ -68,7 +68,6 @@ class DateTimeInput extends /* HTMLInputElement */ HTMLElement { set value(date: Date) { let [d, t] = date.format("~L~Y-~m-~dT~H:~M").split('T'); - // console.log(d, t); this.date.value = d; this.time.value = t; @@ -98,7 +97,6 @@ class DateTimeInput extends /* HTMLInputElement */ HTMLElement { } set stringValue(new_value: Date | string) { - // console.log('Setting date'); let date, time, dateonly = false; if (new_value instanceof Date) { date = new_value.format("~L~Y-~m-~d"); diff --git a/static/components/input-list.ts b/static/components/input-list.ts index 34696e3e..0afd4999 100644 --- a/static/components/input-list.ts +++ b/static/components/input-list.ts @@ -1,7 +1,5 @@ export { InputList } -/* This file replaces input_list.js */ - /* TODO allow each item to be a larger unit, possibly containing multiple input fields. diff --git a/static/components/popup-element.ts b/static/components/popup-element.ts index 3300f885..458f543c 100644 --- a/static/components/popup-element.ts +++ b/static/components/popup-element.ts @@ -71,10 +71,12 @@ class PopupElement extends ComponentVEvent { return ['visible']; } - attributeChangedCallback(name: string, oldValue?: string, newValue?: string) { + attributeChangedCallback(name: string, _?: string, newValue?: string) { switch (name) { case 'visible': - this.onVisibilityChange() + if (newValue !== null) + /* Only run resize code when showing the popup */ + this.onVisibilityChange() break; } } @@ -92,6 +94,7 @@ class PopupElement extends ComponentVEvent { } private onVisibilityChange() { + console.log('here'); /* TODO better way to find root */ let root; diff --git a/static/components/slider.ts b/static/components/slider.ts index a48d5a40..48abc91b 100644 --- a/static/components/slider.ts +++ b/static/components/slider.ts @@ -24,14 +24,14 @@ class SliderInput extends HTMLElement { constructor(min?: number, max?: number, step?: number, value?: number) { super(); - this.min = min || parseFloat(this.getAttribute('min') || ""+dflt['min']); - this.max = max || parseFloat(this.getAttribute('max') || ""+dflt['max']); - this.step = step || parseFloat(this.getAttribute('step') || ""+dflt['step']); + this.min = min || parseFloat(this.getAttribute('min') || "" + dflt['min']); + this.max = max || parseFloat(this.getAttribute('max') || "" + dflt['max']); + this.step = step || parseFloat(this.getAttribute('step') || "" + dflt['step']); // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value const defaultValue = (this.max < this.min) - ? this.min - : this.min + (this.max - this.min)/2; + ? this.min + : this.min + (this.max - this.min) / 2; this.slider = makeElement('input', { type: 'range', @@ -48,8 +48,8 @@ class SliderInput extends HTMLElement { value: this.value, }) as HTMLInputElement - this.slider.addEventListener('input', (e) => this.propagate(e)); - this.textIn.addEventListener('input', (e) => this.propagate(e)); + this.slider.addEventListener('input', e => this.propagate(e)); + this.textIn.addEventListener('input', e => this.propagate(e)); /* MUST be after sub components are bound */ this.value = "" + (value || this.getAttribute('value') || defaultValue); @@ -64,7 +64,7 @@ class SliderInput extends HTMLElement { return ['min', 'max', 'step'] } - attributeChangedCallback(name: Attribute, _: string|null, to: string|null): void { + attributeChangedCallback(name: Attribute, _?: string, to?: string): void { if (to) { this.slider.setAttribute(name, to); this.textIn.setAttribute(name, to); @@ -72,7 +72,7 @@ class SliderInput extends HTMLElement { this.slider.removeAttribute(name); this.textIn.removeAttribute(name); } - this[name] = parseFloat(to || ""+dflt[name]) + this[name] = parseFloat(to || "" + dflt[name]) } propagate(e: Event) { diff --git a/static/components/vevent-block.ts b/static/components/vevent-block.ts index 8cf61d30..9bbb8e7e 100644 --- a/static/components/vevent-block.ts +++ b/static/components/vevent-block.ts @@ -91,7 +91,7 @@ class ComponentBlock extends ComponentVEvent { if (data.getProperty('rrule') !== undefined) { let rep = this.getElementsByClassName('repeating') - if (rep && rep.length !== 0) { + if (rep.length !== 0) { (rep[0] as HTMLElement).innerText = '↺' } } diff --git a/static/components/vevent-edit.ts b/static/components/vevent-edit.ts index bf72678c..686ad5e8 100644 --- a/static/components/vevent-edit.ts +++ b/static/components/vevent-edit.ts @@ -49,7 +49,7 @@ class ComponentEdit extends ComponentVEvent { // return; /* Handle calendar dropdown */ - for (let el of this.getElementsByClassName('calendar-selection')) { + for (let el of this.querySelectorAll('select.calendar-selection')) { for (let opt of el.getElementsByTagName('option')) { opt.selected = false; } @@ -57,7 +57,7 @@ class ComponentEdit extends ComponentVEvent { (el as HTMLSelectElement).value = data.calendar; } - el.addEventListener('change', (e) => { + el.addEventListener('change', e => { let v = (e.target as HTMLSelectElement).selectedOptions[0].value let obj = vcal_objects.get(this.uid)! obj.calendar = v; @@ -69,9 +69,8 @@ class ComponentEdit extends ComponentVEvent { // for (let el of this.getElementsByClassName("interactive")) { for (let el of this.querySelectorAll("[data-property]")) { // console.log(el); - el.addEventListener('input', (e) => { + el.addEventListener('input', () => { let obj = vcal_objects.get(this.uid) - // console.log(el, e); if (obj === undefined) { throw 'No object with uid ' + this.uid } @@ -83,7 +82,6 @@ class ComponentEdit extends ComponentVEvent { console.log(el, 'not an HTMLInputElement'); return; } - // console.log(`obj[${el.dataset.property!}] = `, el.value); obj.setProperty( el.dataset.property!, el.value) diff --git a/static/components/vevent.ts b/static/components/vevent.ts index 5852a2ff..7487cbb6 100644 --- a/static/components/vevent.ts +++ b/static/components/vevent.ts @@ -10,12 +10,12 @@ Lacks an accompaning tag, and shouldn't be directly instanciated. */ abstract class ComponentVEvent extends HTMLElement { - template: HTMLTemplateElement | null + template?: HTMLTemplateElement uid: string constructor(uid?: string) { super(); - this.template = document.getElementById(this.tagName.toLowerCase()) as HTMLTemplateElement | null + this.template = document.getElementById(this.tagName.toLowerCase()) as HTMLTemplateElement | undefined let real_uid; |