-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gsuiChannel/s: use of gsui0ne + prefix $
- Loading branch information
Showing
5 changed files
with
768 additions
and
774 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,110 @@ | ||
"use strict"; | ||
|
||
class gsuiChannel extends HTMLElement { | ||
#dispatch = GSUdispatchEvent.bind( null, this, "gsuiChannel" ); | ||
#children = GSUgetTemplate( "gsui-channel" ); | ||
#elements = GSUfindElements( this.#children, { | ||
toggle: "gsui-toggle", | ||
nameWrap: ".gsuiChannel-nameWrap", | ||
name: ".gsuiChannel-name", | ||
analyser: "gsui-analyser", | ||
effects: ".gsuiChannel-effects", | ||
pan: ".gsuiChannel-pan gsui-slider", | ||
gain: ".gsuiChannel-gain gsui-slider", | ||
connecta: ".gsuiChannel-connectA", | ||
connectb: ".gsuiChannel-connectB", | ||
} ); | ||
analyser = this.#elements.analyser; | ||
|
||
constructor() { | ||
super(); | ||
Object.seal( this ); | ||
|
||
this.#elements.nameWrap.onclick = | ||
this.#elements.analyser.onclick = () => { | ||
this.#dispatch( "selectChannel" ); | ||
}; | ||
this.#elements.effects.onclick = e => { | ||
if ( e.target.dataset.id ) { | ||
this.#dispatch( "selectChannel" ); | ||
this.#dispatch( "selectEffect", e.target.dataset.id ); | ||
} | ||
}; | ||
GSUlistenEvents( this, { | ||
gsuiToggle: { | ||
toggle: d => { | ||
GSUsetAttribute( this, "muted", !d.args[ 0 ] ); | ||
this.#dispatch( "toggle", d.args[ 0 ] ); | ||
}, | ||
toggleSolo: () => { | ||
GSUsetAttribute( this, "muted", false ); | ||
this.#dispatch( "toggleSolo" ); | ||
}, | ||
}, | ||
gsuiSlider: { | ||
inputStart: GSUnoop, | ||
inputEnd: GSUnoop, | ||
input: ( d, sli ) => { | ||
this.#dispatch( "liveChange", sli.dataset.prop, d.args[ 0 ] ); | ||
}, | ||
change: ( d, sli ) => { | ||
this.#dispatch( "change", sli.dataset.prop, d.args[ 0 ] ); | ||
}, | ||
}, | ||
} ); | ||
} | ||
|
||
// ......................................................................... | ||
connectedCallback() { | ||
if ( !this.firstChild ) { | ||
this.append( ...this.#children ); | ||
this.#children = null; | ||
GSUsetAttribute( this, "draggable", "true" ); | ||
GSUrecallAttributes( this, { | ||
name: "chan", | ||
pan: 0, | ||
gain: 1, | ||
connecta: "down", | ||
} ); | ||
} | ||
} | ||
static get observedAttributes() { | ||
return [ "name", "muted", "pan", "gain", "connecta", "connectb" ]; | ||
} | ||
attributeChangedCallback( prop, prev, val ) { | ||
if ( !this.#children && prev !== val ) { | ||
switch ( prop ) { | ||
case "name": | ||
this.#elements.name.textContent = val; | ||
break; | ||
case "muted": | ||
GSUsetAttribute( this.#elements.toggle, "off", val !== null ); | ||
break; | ||
case "pan": | ||
case "gain": | ||
this.#elements[ prop ].setValue( val ); | ||
break; | ||
case "connecta": | ||
case "connectb": | ||
this.#elements[ prop ].dataset.icon = val ? `caret-${ val }` : ""; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
// ......................................................................... | ||
$addEffect( id, obj ) { | ||
this.#elements.effects.append( GSUgetTemplate( "gsui-channel-effect", id, obj.type ) ); | ||
} | ||
$removeEffect( id ) { | ||
this.#getEffect( id ).remove(); | ||
} | ||
$updateEffect( id, obj ) { | ||
if ( "order" in obj ) { | ||
this.#getEffect( id ).style.order = obj.order; | ||
} | ||
if ( "toggle" in obj ) { | ||
this.#getEffect( id ).classList.toggle( "gsuiChannel-effect-enable", obj.toggle ); | ||
} | ||
} | ||
#getEffect( id ) { | ||
return this.#elements.effects.querySelector( `[data-id="${ id }"]` ); | ||
} | ||
} | ||
|
||
Object.freeze( gsuiChannel ); | ||
customElements.define( "gsui-channel", gsuiChannel ); | ||
"use strict"; | ||
|
||
class gsuiChannel extends gsui0ne { | ||
$analyser = null; | ||
|
||
constructor() { | ||
super( { | ||
$cmpName: "gsuiChannel", | ||
$tagName: "gsui-channel", | ||
$elements: { | ||
toggle: "gsui-toggle", | ||
nameWrap: ".gsuiChannel-nameWrap", | ||
name: ".gsuiChannel-name", | ||
analyser: "gsui-analyser", | ||
effects: ".gsuiChannel-effects", | ||
pan: ".gsuiChannel-pan gsui-slider", | ||
gain: ".gsuiChannel-gain gsui-slider", | ||
connecta: ".gsuiChannel-connectA", | ||
connectb: ".gsuiChannel-connectB", | ||
}, | ||
$attributes: { | ||
draggable: "true", | ||
name: "chan", | ||
pan: 0, | ||
gain: 1, | ||
connecta: "down", | ||
}, | ||
} ); | ||
Object.seal( this ); | ||
|
||
this.$analyser = this.$elements.analyser; | ||
this.$analyser.onclick = | ||
this.$elements.nameWrap.onclick = () => { | ||
this.$dispatch( "selectChannel" ); | ||
}; | ||
this.$elements.effects.onclick = e => { | ||
if ( e.target.dataset.id ) { | ||
this.$dispatch( "selectChannel" ); | ||
this.$dispatch( "selectEffect", e.target.dataset.id ); | ||
} | ||
}; | ||
GSUlistenEvents( this, { | ||
gsuiToggle: { | ||
toggle: d => { | ||
GSUsetAttribute( this, "muted", !d.args[ 0 ] ); | ||
this.$dispatch( "toggle", d.args[ 0 ] ); | ||
}, | ||
toggleSolo: () => { | ||
GSUsetAttribute( this, "muted", false ); | ||
this.$dispatch( "toggleSolo" ); | ||
}, | ||
}, | ||
gsuiSlider: { | ||
inputStart: GSUnoop, | ||
inputEnd: GSUnoop, | ||
input: ( d, sli ) => { | ||
this.$dispatch( "liveChange", sli.dataset.prop, d.args[ 0 ] ); | ||
}, | ||
change: ( d, sli ) => { | ||
this.$dispatch( "change", sli.dataset.prop, d.args[ 0 ] ); | ||
}, | ||
}, | ||
} ); | ||
} | ||
|
||
// ......................................................................... | ||
static get observedAttributes() { | ||
return [ "name", "muted", "pan", "gain", "connecta", "connectb" ]; | ||
} | ||
$attributeChanged( prop, val ) { | ||
switch ( prop ) { | ||
case "name": | ||
this.$elements.name.textContent = val; | ||
break; | ||
case "muted": | ||
GSUsetAttribute( this.$elements.toggle, "off", val !== null ); | ||
break; | ||
case "pan": | ||
case "gain": | ||
this.$elements[ prop ].setValue( val ); | ||
break; | ||
case "connecta": | ||
case "connectb": | ||
this.$elements[ prop ].dataset.icon = val ? `caret-${ val }` : ""; | ||
break; | ||
} | ||
} | ||
|
||
// ......................................................................... | ||
$addEffect( id, obj ) { | ||
this.$elements.effects.append( GSUgetTemplate( "gsui-channel-effect", id, obj.type ) ); | ||
} | ||
$removeEffect( id ) { | ||
this.#getEffect( id ).remove(); | ||
} | ||
$updateEffect( id, obj ) { | ||
if ( "order" in obj ) { | ||
this.#getEffect( id ).style.order = obj.order; | ||
} | ||
if ( "toggle" in obj ) { | ||
this.#getEffect( id ).classList.toggle( "gsuiChannel-effect-enable", obj.toggle ); | ||
} | ||
} | ||
#getEffect( id ) { | ||
return this.$elements.effects.querySelector( `[data-id="${ id }"]` ); | ||
} | ||
} | ||
|
||
Object.freeze( gsuiChannel ); | ||
customElements.define( "gsui-channel", gsuiChannel ); |
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 |
---|---|---|
@@ -1,62 +1,63 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1"/> | ||
<link rel="shortcut icon" href="/assets/favicon.png"/> | ||
<link rel="stylesheet" href="/assets/fonts/fonts.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsui.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/test-assets/test.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiIcon/gsuiIcon.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiToggle/gsuiToggle.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiSlider/gsuiSlider.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiSpectrum/gsuiSpectrum.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiChannel/gsuiChannel.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<style> | ||
body { | ||
--test-content-w: 120px; | ||
--test-content-h: 320px; | ||
--test-content-resize: vertical; | ||
} | ||
#testWrap { | ||
display: flex; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<!-- ....................................................................... --> | ||
<div id="TEST"> | ||
<gsui-channel></gsui-channel> | ||
</div> | ||
|
||
<!-- ....................................................................... --> | ||
<script src="/gs-ui-components/gs-utils/gs-utils.js"></script> | ||
<script src="/gs-ui-components/gs-utils/gs-utils-dom.js"></script> | ||
<script src="/gs-ui-components/test-assets/test.js"></script> | ||
<script src="/gs-ui-components/gsuiToggle/gsuiToggle.js"></script> | ||
<script src="/gs-ui-components/gsuiAnalyser/gsuiAnalyser.js"></script> | ||
<script src="/gs-ui-components/gsuiSpectrum/gsuiSpectrum.js"></script> | ||
<script src="/gs-ui-components/gsuiSlider/gsuiSlider.html.js"></script> | ||
<script src="/gs-ui-components/gsuiSlider/gsuiSlider.js"></script> | ||
|
||
<!-- ....................................................................... --> | ||
<script src="/gs-ui-components/gsuiChannel/gsuiChannel.html.js"></script> | ||
<script src="/gs-ui-components/gsuiChannel/gsuiChannel.js"></script> | ||
|
||
<!-- ....................................................................... --> | ||
<script> | ||
const chan = document.querySelector( "gsui-channel" ); | ||
|
||
GSUsetAttribute( chan, "name", "chan" ); | ||
</script> | ||
</body> | ||
</html> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1"/> | ||
<link rel="shortcut icon" href="/assets/favicon.png"/> | ||
<link rel="stylesheet" href="/assets/fonts/fonts.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsui.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/test-assets/test.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiIcon/gsuiIcon.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiToggle/gsuiToggle.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiSlider/gsuiSlider.css"/> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiSpectrum/gsuiSpectrum.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<link rel="stylesheet" href="/gs-ui-components/gsuiChannel/gsuiChannel.css"/> | ||
|
||
<!-- ....................................................................... --> | ||
<style> | ||
body { | ||
--test-content-w: 120px; | ||
--test-content-h: 320px; | ||
--test-content-resize: vertical; | ||
} | ||
#testWrap { | ||
display: flex; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<!-- ....................................................................... --> | ||
<div id="TEST"> | ||
<gsui-channel></gsui-channel> | ||
</div> | ||
|
||
<!-- ....................................................................... --> | ||
<script src="/gs-ui-components/gs-utils/gs-utils.js"></script> | ||
<script src="/gs-ui-components/gs-utils/gs-utils-dom.js"></script> | ||
<script src="/gs-ui-components/test-assets/test.js"></script> | ||
<script src="/gs-ui-components/gsui0ne/gsui0ne.js"></script> | ||
<script src="/gs-ui-components/gsuiToggle/gsuiToggle.js"></script> | ||
<script src="/gs-ui-components/gsuiAnalyser/gsuiAnalyser.js"></script> | ||
<script src="/gs-ui-components/gsuiSpectrum/gsuiSpectrum.js"></script> | ||
<script src="/gs-ui-components/gsuiSlider/gsuiSlider.html.js"></script> | ||
<script src="/gs-ui-components/gsuiSlider/gsuiSlider.js"></script> | ||
|
||
<!-- ....................................................................... --> | ||
<script src="/gs-ui-components/gsuiChannel/gsuiChannel.html.js"></script> | ||
<script src="/gs-ui-components/gsuiChannel/gsuiChannel.js"></script> | ||
|
||
<!-- ....................................................................... --> | ||
<script> | ||
const chan = document.querySelector( "gsui-channel" ); | ||
|
||
GSUsetAttribute( chan, "name", "chan" ); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.