127.0.0.1:8000 budget / master src / js / ui / list_row.js
master

Tree @master (Download .tar.gz)

list_row.js @masterraw · history · blame

require('../../scss/list.scss');
const $ = require('jquery');

module.exports = {
    create: function(list_name, contents, on_click) {
        const $list_entry = $('<div>', {
            class: "list-entry",
        }).on('click', on_click);
        if (contents.icon) {
            $list_entry.append($('<img>', {
                src: `/images/${contents.icon}-icon.png`,
                class: 'icon'
            }));
        }
        if (contents.title) {
            $list_entry.append($('<span>', {
                text: contents.title,
                class: 'list-entry-title'
            }));
        }
        if (contents.text) {
            $list_entry.append($('<span>', {
                text: contents.text,
                class: 'list-entry-text'
            }));
        }
        $(`#${list_name}-list`).append($list_entry);
        return $list_entry;
    }
}