build() {
        // attach the click to show picker
        this.targetElement.addEventListener('click', this.show.bind(this));

        // create picker wrapper div
        this.wrapper = document.createElement('div');
        this.wrapper.classList.add('nj-picker');
        this.wrapper.setAttribute('id', this.config.id);

        // init the overlay
        this.overlay = new Background();
        if (this.config.clickOutsideToClose) { // check if clickOutsideToClose is true
            this.overlay.addEventListener('click', this.hide.bind(this));
        }
        // append the overlay to the picker wrapper
        this.wrapper.append(this.overlay);

        // create the container
        this.container = document.createElement('div');
        this.container.classList.add('nj-picker-container');

        // create header
        if (this.config.headerText || this.config.texts.header) {
            this.header = new Header(this.config);
            this.container.append(this.header.element);
        }

        this.buildItems();
        this.buildButtons(); // configure picker buttons

        // attach the picker container to the wrapper
        this.wrapper.append(this.container);
        // attach the picker wrapper to the dom
        document.body.append(this.wrapper);
        setTimeout(() => {
            this.emitter.emit('ready', {}); // emit the plugin ready event
        });

        this.emitter.on('selection', () => {
            if (this.pickerVisible && this.config.autoSave && this.allowAutoSave) {
                let val = this.getValue();
                if (val.hours && val.minutes && val.ampm)
                    this.onSave();
            }
        });
    }
// set the options for building the plugin
set the options for building the plugin
set the options for building the plugin
build() {
        this.targetElement.addEventListener('click', this.show.bind(this));
        this.wrapper = document.createElement('div');
        this.wrapper.classList.add('nj-picker');
        this.wrapper.setAttribute('id', this.config.id);
        this.overlay = new Background();
        if (this.config.clickOutsideToClose) { 
            this.overlay.addEventListener('click', this.hide.bind(this));
        }
        this.wrapper.append(this.overlay);
        this.container = document.createElement('div');
        this.container.classList.add('nj-picker-container');
        if (this.config.headerText || this.config.texts.header) {
            this.header = new Header(this.config);
            this.container.append(this.header.element);
        }
        this.buildItems();
        this.buildButtons(); 
        this.wrapper.append(this.container);
        document.body.append(this.wrapper);
        setTimeout(() => {
            this.emitter.emit('ready', {}); 
        });
        this.emitter.on('selection', () => {
            if (this.pickerVisible && this.config.autoSave && this.allowAutoSave) {
                let val = this.getValue();
                if (val.hours && val.minutes && val.ampm)
                    this.onSave();
            }
        });
    }
build ( ) { this . targetElement . addEventListener ( 'click' , this . show . bind ( this ) ) ; this . wrapper = document . createElement ( 'div' ) ; this . wrapper . classList . add ( 'nj-picker' ) ; this . wrapper . setAttribute ( 'id' , this . config . id ) ; this . overlay = new Background ( ) ; if ( this . config . clickOutsideToClose ) { this . overlay . addEventListener ( 'click' , this . hide . bind ( this ) ) ; } this . wrapper . append ( this . overlay ) ; this . container = document . createElement ( 'div' ) ; this . container . classList . add ( 'nj-picker-container' ) ; if ( this . config . headerText || this . config . texts . header ) { this . header = new Header ( this . config ) ; this . container . append ( this . header . element ) ; } this . buildItems ( ) ; this . buildButtons ( ) ; this . wrapper . append ( this . container ) ; document . body . append ( this . wrapper ) ; setTimeout ( ( ) => { this . emitter . emit ( 'ready' , { } ) ; } ) ; this . emitter . on ( 'selection' , ( ) => { if ( this . pickerVisible && this . config . autoSave && this . allowAutoSave ) { let val = this . getValue ( ) ; if ( val . hours && val . minutes && val . ampm ) this . onSave ( ) ; } } ) ; }
set the options for building the plugin
set the options for building the plugin
// attach the click to show picker // create picker wrapper div // init the overlay // check if clickOutsideToClose is true // append the overlay to the picker wrapper // create the container // create header // configure picker buttons // attach the picker container to the wrapper // attach the picker wrapper to the dom // emit the plugin ready event