<commit_before>// common file between desk and website

frappe.avatar = function (user, css_class, title, image_url=null, remove_avatar=false) {
	let user_info;
	if (user) {
		// desk
		user_info = frappe.user_info(user);
	} else {
		// website
		let full_name = title || frappe.get_cookie("full_name");
		user_info = {
			image: image_url === null ? frappe.get_cookie("user_image") : image_url,
			fullname: full_name,
			abbr: frappe.get_abbr(full_name),
			color: frappe.get_palette(full_name)
		};
	}

	if (!title) {
		title = user_info.fullname;
	}

	if (!css_class) {
		css_class = "avatar-small";
	}

	if (user_info.image || image_url) {
		image_url = image_url || user_info.image;

		const image = (window.cordova && image_url.indexOf('http') === -1) ? frappe.base_url + image_url : image_url;

		return `<span class="avatar ${css_class}" title="${title}">
				<span class="avatar-frame" style='background-image: url("${image}")'
					title="${title}"></span>
			</span>`;
	} else {
		var abbr = user_info.abbr;
		if (css_class === 'avatar-small' || css_class == 'avatar-xs') {
			abbr = abbr.substr(0, 1);
		}
		return `<span class="avatar ${css_class}" title="${title}">
			<div class="avatar-frame standard-image"
				style="background-color: var(${user_info.color[0]}); color: var(${user_info.color[1]})">
					${abbr}
			</div>
		</span>`;
	}
};

frappe.avatar_group = function(users, limit=4, options={}) {
	let icon_html = '';
	const display_users = users.slice(0, limit);
	const extra_users = users.slice(limit);

	let html = display_users.map(user => frappe.avatar(user, 'avatar-small ' + options.css_class)).join('');
	if (extra_users.length === 1) {
		html += frappe.avatar(extra_users[0], 'avatar-small ' + options.css_class);
	} else if (extra_users.length > 1) {
		html = `
			<span class="avatar avatar-small ${options.css_class}">
				<div class="avatar-frame standard-image avatar-extra-count"
					title="${extra_users.map(u => frappe.user_info(u).fullname).join(', ')}">
					+${extra_users.length}
				</div>
			</span>
			${html}
		`;
	}

	if (options.action_icon) {
		icon_html = `<span class="avatar avatar-small avatar avatar-small">
			<div class="avatar-frame avatar-action">
					${frappe.utils.icon(options.action_icon, 'md')}
			</div>
		</span>`;
	}

	const $avatar_group =
		$(`<div class="avatar-group ${options.align || 'right'} ${options.overlap != false ? 'overlap': ''}">
			${icon_html}
			${html}
		</div>`);

	$avatar_group.find('.avatar-action').on('click', options.action);
	return $avatar_group;
};

frappe.ui.scroll = function(element, animate, additional_offset) {
	var header_offset = $(".navbar").height() + $(".page-head").height();
	var top = $(element).offset().top - header_offset - cint(additional_offset);
	if (animate) {
		$("html, body").animate({ scrollTop: top });
	} else {
		$(window).scrollTop(top);
	}
};

frappe.palette = [
	['--orange-100', '--orange-600'],
	['--pink-50', '--pink-500'],
	['--blue-50', '--blue-500'],
	['--green-50', '--green-500'],
	['--dark-green-50', '--dark-green-500'],
	['--red-50', '--red-500'],<commit_msg>feat: use small icon in avatar group action<commit_after>// common file between desk and website

frappe.avatar = function (user, css_class, title, image_url=null, remove_avatar=false) {
	let user_info;
	if (user) {
		// desk
		user_info = frappe.user_info(user);
	} else {
		// website
		let full_name = title || frappe.get_cookie("full_name");
		user_info = {
			image: image_url === null ? frappe.get_cookie("user_image") : image_url,
			fullname: full_name,
			abbr: frappe.get_abbr(full_name),
			color: frappe.get_palette(full_name)
		};
	}

	if (!title) {
		title = user_info.fullname;
	}

	if (!css_class) {
		css_class = "avatar-small";
	}

	if (user_info.image || image_url) {
		image_url = image_url || user_info.image;

		const image = (window.cordova && image_url.indexOf('http') === -1) ? frappe.base_url + image_url : image_url;

		return `<span class="avatar ${css_class}" title="${title}">
				<span class="avatar-frame" style='background-image: url("${image}")'
					title="${title}"></span>
			</span>`;
	} else {
		var abbr = user_info.abbr;
		if (css_class === 'avatar-small' || css_class == 'avatar-xs') {
			abbr = abbr.substr(0, 1);
		}
		return `<span class="avatar ${css_class}" title="${title}">
			<div class="avatar-frame standard-image"
				style="background-color: var(${user_info.color[0]}); color: var(${user_info.color[1]})">
					${abbr}
			</div>
		</span>`;
	}
};

frappe.avatar_group = function(users, limit=4, options={}) {
	let icon_html = '';
	const display_users = users.slice(0, limit);
	const extra_users = users.slice(limit);

	let html = display_users.map(user => frappe.avatar(user, 'avatar-small ' + options.css_class)).join('');
	if (extra_users.length === 1) {
		html += frappe.avatar(extra_users[0], 'avatar-small ' + options.css_class);
	} else if (extra_users.length > 1) {
		html = `
			<span class="avatar avatar-small ${options.css_class}">
				<div class="avatar-frame standard-image avatar-extra-count"
					title="${extra_users.map(u => frappe.user_info(u).fullname).join(', ')}">
					+${extra_users.length}
				</div>
			</span>
			${html}
		`;
	}

	if (options.action_icon) {
		icon_html = `<span class="avatar avatar-small avatar avatar-small">
			<div class="avatar-frame avatar-action">
					${frappe.utils.icon(options.action_icon, 'sm')}
			</div>
		</span>`;
	}

	const $avatar_group =
		$(`<div class="avatar-group ${options.align || 'right'} ${options.overlap != false ? 'overlap': ''}">
			${icon_html}
			${html}
		</div>`);

	$avatar_group.find('.avatar-action').on('click', options.action);
	return $avatar_group;
};

frappe.ui.scroll = function(element, animate, additional_offset) {
	var header_offset = $(".navbar").height() + $(".page-head").height();
	var top = $(element).offset().top - header_offset - cint(additional_offset);
	if (animate) {
		$("html, body").animate({ scrollTop: top });
	} else {
		$(window).scrollTop(top);
	}
};

frappe.palette = [
	['--orange-100', '--orange-600'],
	['--pink-50', '--pink-500'],
	['--blue-50', '--blue-500'],
	['--green-50', '--green-500'],
	['--dark-green-50', '--dark-green-500'],
	['--red-50', '--red-500'],
{'fraction_non_alphanumeric': 0.207798459563543, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 4.034733441033926, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 45, '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': '4725545', 'n_tokens_mistral': 2586, 'n_tokens_neox': 2342, 'n_words': 424}