2021-07-21 14:13:56 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="typescript">
|
|
|
|
import * as tr from "lib/i18n";
|
|
|
|
|
|
|
|
import ButtonGroup from "components/ButtonGroup.svelte";
|
|
|
|
import ButtonGroupItem from "components/ButtonGroupItem.svelte";
|
|
|
|
import IconButton from "components/IconButton.svelte";
|
|
|
|
|
|
|
|
import { createEventDispatcher } from "svelte";
|
|
|
|
import { sizeActual, sizeMinimized } from "./icons";
|
|
|
|
|
|
|
|
export let image: HTMLImageElement;
|
|
|
|
export let imageRule: CSSStyleRule;
|
2021-07-21 15:52:48 +02:00
|
|
|
export let selector: string;
|
|
|
|
export let active: boolean;
|
2021-07-21 16:48:02 +02:00
|
|
|
export let isRtl: boolean;
|
2021-07-21 14:13:56 +02:00
|
|
|
|
|
|
|
$: icon = active ? sizeActual : sizeMinimized;
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
2021-07-21 15:52:48 +02:00
|
|
|
export function toggleActualSize() {
|
2021-07-21 14:13:56 +02:00
|
|
|
if (!image.hasAttribute("src")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active) {
|
|
|
|
imageRule.selectorText = imageRule.selectorText.replace(selector, "");
|
|
|
|
active = false;
|
|
|
|
} else {
|
|
|
|
imageRule.selectorText += selector;
|
|
|
|
active = true;
|
|
|
|
}
|
|
|
|
|
2021-07-21 15:52:48 +02:00
|
|
|
dispatch("update", active);
|
2021-07-21 14:13:56 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<ButtonGroup size={1.6}>
|
|
|
|
<ButtonGroupItem>
|
|
|
|
<IconButton
|
|
|
|
{active}
|
2021-07-21 16:48:02 +02:00
|
|
|
flipX={isRtl}
|
2021-07-21 14:13:56 +02:00
|
|
|
tooltip={tr.editingActualSize()}
|
|
|
|
on:click={toggleActualSize}>{@html icon}</IconButton
|
|
|
|
>
|
|
|
|
</ButtonGroupItem>
|
|
|
|
</ButtonGroup>
|