PageSourceSearch

https://sandrabradley.com/.cm4all/stcfb/.cm4all/designs/static/sys…/js/cm_template-focus-point.js

js sandrabradley.com collected 2026-10-08 08:39:33 UTC 2,956 bytes, 98 lines download raw bytes

1/**
2 * @brief focus point backward compatibility
3 *
4 * This class/object ensures backward compatibility with auto covering of keyvisuals and logos until Sites 3.1.
5 *
6 * private
7 */
8__cm_template_focus_point_backward_compatibility = {
9
10	/* private */
11	_isAbsoluteKVPosition: function(x, y) {
12		var isRelative = function(val) {
13			return val.match(/%$/) || val == "auto";
14		};
15		return !isRelative(x) && !isRelative(y);
16	},
17
18	/* private */
19	_hasSizeConfig: function(size) {
20		return size && size != "auto" && size != "auto auto";
21	},
22
23	/* private */
24	_applyDeprecatedKVClass(elem) {
25		var style = window.getComputedStyle(elem);
26		if (style && (!this._hasSizeConfig(style.backgroundSize) || this._isAbsoluteKVPosition(style.backgroundPositionX, style.backgroundPositionY))) {
27			elem.classList.add('cm-templates-kv-deprecated-px');
28		}
29	},
30
31	/* private */
32	_applyDeprecatedLogoClass(elem) {
33		var style = window.getComputedStyle(elem);
34		if (style && (this._isAbsoluteKVPosition(style.backgroundPositionX, style.backgroundPositionY))) {
35			elem.classList.add('cm-templates-logo-deprecated-px');
36		}
37	},
38
39	/**
40	 * @brief backward compatibility for px values in logo/kv
41	 */
42	ensure_focus_point_backward_compatibility: function() {
43		var kvDiv = document.querySelector(".cm-kv-0");
44		var slideDivs = kvDiv.querySelectorAll(".cm-slides-addon");
45		if (slideDivs.length > 0) {
46			/* slide show */
47			for (var i = 0; i < slideDivs.length; i++) {
48				this._applyDeprecatedKVClass(slideDivs[i]);
49			}
50		} else {
51			/* kv */
52			this._applyDeprecatedKVClass(kvDiv);
53		}
54		var logoDiv = document.querySelector(".cm-logo");
55		if (logoDiv) {
56			this._applyDeprecatedLogoClass(logoDiv);
57		}
58	}
59};
60
61/*
62 * @see https://www.sitepoint.com/jquery-document-ready-plain-javascript/
63 */
64(function() {
65
66	/**
67	 * @brief DOM ready handler
68	 *
69	 * This handler is called when the DOM has fully been loaded.
70	 * Functions that do template initializations can be added here.
71	 */
72	var __cm_template_init = function() {
73		/* add function invocations here */
74		__cm_template_focus_point_backward_compatibility.ensure_focus_point_backward_compatibility();
75	};
76
77	/* The callback will not be executed if the event has already been fired. So we make sure the callback is always run. */
78	if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) {
79		__cm_template_init();
80		return;
81	}
82
83	/* register callback */
84	if (document.addEventListener) {
85		document.addEventListener('DOMContentLoaded', __cm_template_init, false);
86	} else if (document.attachEvent) {
87		/* older IE versions */
88		document.attachEvent("onreadystatechange", function() {
89			// check if the DOM is fully loaded
90			if (document.readyState === "complete") {
91				// remove the listener, to make sure it isn't fired in future
92				document.detachEvent("onreadystatechange", arguments.callee);
93				// call the actual handler
94				__cm_template_init();
95			}
96		});
97	}
98})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.