Skip to content
Snippets Groups Projects
button.js 1.19 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jake Read's avatar
    Jake Read committed
    /*
    
    
    Jake Read's avatar
    Jake Read committed
    contact
    
    Jake Read's avatar
    Jake Read committed
    
    */
    
    
    import { Hunkify, Input, Output, State } from '../hunks.js'
    
    Jake Read's avatar
    Jake Read committed
    
    function Button() {
        Hunkify(this, 'Button')
    
    
    Jake Read's avatar
    Jake Read committed
        let onclk = new Output('boolean', 'onclick', this)
    
    Jake Read's avatar
    Jake Read committed
        this.outputs.push(onclk)
    
    Jake Read's avatar
    Jake Read committed
        /* aspirationally
    
    Jake Read's avatar
    Jake Read committed
        this.outputs.mouseup
    
    Jake Read's avatar
    Jake Read committed
        */
    
    Jake Read's avatar
    Jake Read committed
        /*
    
    Jake Read's avatar
    Jake Read committed
        let strang = new State('string', 'strng', 'start value')
        let numbr = new State('number', 'nmbr', 101)
        let blen = new State('boolean', 'bln', false)
        this.states.push(strang, numbr, blen)
    
    Jake Read's avatar
    Jake Read committed
        */
    
    Jake Read's avatar
    Jake Read committed
    
    
        this.dom = {}
    
    
    Jake Read's avatar
    Jake Read committed
        this.init = () => {
    
    Jake Read's avatar
    Jake Read committed
            // manager calls this once
    
    Jake Read's avatar
    Jake Read committed
            this.log('HELLO BUTTON')
    
    Jake Read's avatar
    Jake Read committed
            this.dom = $('<div>').get(0)
    
    Jake Read's avatar
    Jake Read committed
        }
    
        this.onload = (dom) => {
          // function equivalent, our .dom element is loaded into ~ the d o m ~
          let contact = $('<div>').addClass('btn').append('! contact !').get(0)
          $(this.dom).append(contact)
          contact.addEventListener('click', (evt) => {
    
    Jake Read's avatar
    Jake Read committed
              //console.log('button hunk down')
    
              if(onclk.io()){
    
    Jake Read's avatar
    Jake Read committed
                console.warn("button attempts to push to occupied output")
              } else {
                onclk.put(true)
              }
    
    Jake Read's avatar
    Jake Read committed
          })
    
    Jake Read's avatar
    Jake Read committed
        }
    
        this.loop = () => {
    
    Jake Read's avatar
    Jake Read committed
        }
    }
    
    
    Jake Read's avatar
    Jake Read committed
    export default Button