Initial commit: Klammertext source distribution
Curated source subset assembled by klammertext-dev's doc/make_dist.sh: the Klammermachine (mac), the Standard Klammer Set (sks), the commands (com), editor plugins and install guides (doc), a test subset (tst), and lib/bin placeholders. Builds with 'make -C com'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
51
sks/image/js/image.js
Normal file
51
sks/image/js/image.js
Normal file
@@ -0,0 +1,51 @@
|
||||
function resize_images() {
|
||||
//console.log("resize_images");
|
||||
K.getv("#text img[data-scale-x]").forEach(
|
||||
function (img) {
|
||||
let text_area = K.get("#text"); //img.parentNode.parentNode;
|
||||
let scale_x = parseFloat(K.attr(img, "data-scale-x"));
|
||||
let style = window.getComputedStyle(text_area); //text_area.currentStyle;
|
||||
let parent_width = text_area.clientWidth
|
||||
- parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
||||
let container = img.parentNode.parentNode;
|
||||
if (container.classList.contains("image_grid_row")) {
|
||||
if (!container.style) {
|
||||
container.style = {};
|
||||
}
|
||||
container.style.width = parent_width + "px";
|
||||
} else if (container.parentNode.classList.contains("image_grid_row")) {
|
||||
container = container.parentNode;
|
||||
if (!container.style) {
|
||||
container.style = {};
|
||||
}
|
||||
container.style.width = parent_width + "px";
|
||||
}
|
||||
let image_width = scale_x * parent_width;
|
||||
if (!img.style) {
|
||||
img.style = {};
|
||||
}
|
||||
img.style.width = image_width + "px";
|
||||
let caption = img.parentNode.getElementsByClassName("caption")[0];
|
||||
if (typeof caption !== 'undefined') {
|
||||
if (typeof caption.style == 'undefined') {
|
||||
caption.style = {};
|
||||
}
|
||||
caption.style.width = image_width + "px";
|
||||
}
|
||||
});
|
||||
|
||||
K.getv(".caption_right, .caption_left").forEach(
|
||||
function (img) {
|
||||
K.width(img, img.parentNode.clientWidth);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
window.addEventListener("load", function (event) {
|
||||
window.addEventListener(
|
||||
"resize",
|
||||
function (event) {
|
||||
resize_images();
|
||||
});
|
||||
resize_images();
|
||||
});
|
||||
Reference in New Issue
Block a user