<commit_before>import get_dialog_constructor from './widget_dialog.js';

export default class Widget {
	constructor(opts) {
		Object.assign(this, opts);
		this.make();
	}

	refresh() {
		this.set_title();
		this.set_actions();
		this.set_body();
		this.setup_events();
	}

	get_config() {
		return {
			name: this.name,
			label: this.label
		};
	}

	customize(options) {
		this.in_customize_mode = true;
		this.action_area.empty();

		options.allow_delete &&
			this.add_custom_button(
				'<i class="fa fa-trash" aria-hidden="true"></i>',
				() => this.delete(),
				"",
				`${__('Delete')}`
			);

		options.allow_sorting &&
			this.add_custom_button(
				'<i class="fa fa-arrows" aria-hidden="true"></i>',
				null,
				"drag-handle",
			);

		if (options.allow_hiding) {
			if (this.hidden) {
				this.widget.removeClass("hidden");
				this.body.css("opacity", 0.5);
				this.title_field.css("opacity", 0.5);
				this.footer.css("opacity", 0.5);
			}
			const classname = this.hidden ? 'fa fa-eye' : 'fa fa-eye-slash';
			const title = this.hidden ? `${__('Show')}` : `${__('Hide')}`;
			this.add_custom_button(
				`<i class="${classname}" aria-hidden="true"></i>`,
				() => this.hide_or_show(),
				"show-or-hide-button",
				title
			);

			this.show_or_hide_button = this.action_area.find(
				".show-or-hide-button"
			);
		}

		options.allow_edit &&
			this.add_custom_button(
				'<i class="fa fa-pencil" aria-hidden="true"></i>',
				() => this.edit()
			);

		if (options.allow_resize) {
			const title = this.width == 'Full'? `${__('Collapse')}` : `${__('Expand')}`;
			this.add_custom_button(
				'<i class="fa fa-expand" aria-hidden="true"></i>',
				() => this.toggle_width(),
				"resize-button",
				title
			);

			this.resize_button = this.action_area.find(
				".resize-button"
			);
		}
	}

	make() {
		this.make_widget();
		this.widget.appendTo(this.container);<commit_msg>feat: use frappe icons for widget actions<commit_after>import get_dialog_constructor from './widget_dialog.js';

export default class Widget {
	constructor(opts) {
		Object.assign(this, opts);
		this.make();
	}

	refresh() {
		this.set_title();
		this.set_actions();
		this.set_body();
		this.setup_events();
	}

	get_config() {
		return {
			name: this.name,
			label: this.label
		};
	}

	customize(options) {
		this.in_customize_mode = true;
		this.action_area.empty();

		options.allow_sorting &&
			this.add_custom_button(
				frappe.utils.icon('drag', 'xs'),
				null,
				"drag-handle",
			);

		options.allow_delete &&
			this.add_custom_button(
				frappe.utils.icon('delete', 'xs'),
				() => this.delete(),
				"",
				`${__('Delete')}`
			);

		if (options.allow_hiding) {
			if (this.hidden) {
				this.widget.removeClass("hidden");
				this.body.css("opacity", 0.5);
				this.title_field.css("opacity", 0.5);
				this.footer.css("opacity", 0.5);
			}
			const classname = this.hidden ? 'fa fa-eye' : 'fa fa-eye-slash';
			const title = this.hidden ? `${__('Show')}` : `${__('Hide')}`;
			this.add_custom_button(
				`<i class="${classname}" aria-hidden="true"></i>`,
				() => this.hide_or_show(),
				"show-or-hide-button",
				title
			);

			this.show_or_hide_button = this.action_area.find(
				".show-or-hide-button"
			);
		}

		options.allow_edit &&
			this.add_custom_button(
				frappe.utils.icon("edit", "xs"),
				() => this.edit()
			);

		if (options.allow_resize) {
			const title = this.width == 'Full'? `${__('Collapse')}` : `${__('Expand')}`;
			this.add_custom_button(
				'<i class="fa fa-expand" aria-hidden="true"></i>',
				() => this.toggle_width(),
				"resize-button",
				title
			);

			this.resize_button = this.action_area.find(
				".resize-button"
			);
		}
	}

	make() {
		this.make_widget();
		this.widget.appendTo(this.container);
{'fraction_non_alphanumeric': 0.19872982270441916, 'fraction_numerical': 0.0031754432389521038, 'mean_word_length': 3.228187919463087, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5555068', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1407, 'n_words': 209}