PageSourceSearch

https://www.coloradoicsb.com/themes/common/javascripts/smb/jquery.set-spacing.js?v.284928

js coloradoicsb.com collected 2026-10-04 13:27:59 UTC 2,697 bytes, 85 lines download raw bytes

1// set spacing depending on width/height of specified element in options
2;(function($) {
3	// options
4	function setSpacing(options) {
5		this.options = $.extend({
6			takeSizeFrom: '.element',
7			takeSize: 'height', // width or height
8			spacingProp: 'padding-top', // 'left', 'right', 'top', 'bottom', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right'
9			flexible: true
10		}, options);
11		this.init();
12	}
13
14	// prototype
15	setSpacing.prototype = {
16		init: function() {
17			var self = this,
18				spacingVars = ['left', 'right', 'top', 'bottom', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right'],
19				spacingVarsValid;
20
21			// spacing properties validation
22			for (var i = 0; i < spacingVars.length; i++) {
23				if (spacingVars[i] === self.options.spacingProp) {
24					spacingVarsValid = true;
25				}
26			}
27
28			if (this.options.holder && typeof spacingVarsValid !== 'undefined') {
29				this.findElements();
30				this.setElemSpacing();
31				if(this.options.flexible) return self.attachEvents();
32			}
33		},
34		findElements: function() {
35			this.elements = {
36				holder: $(this.options.holder),
37				takeSizeFrom: $(this.options.takeSizeFrom)
38			};
39		},
40		attachEvents: function() {
41			this.bindHandlers(['onWindowResize']);
42			$(window).bind('resize orientationchange', this.onWindowResize);
43		},
44		onWindowResize: function() {
45			if (this.destroyed) return;
46			this.setElemSpacing();
47		},
48		bindHandlers: function(handlersList) {
49			var self = this;
50			$.each(handlersList, function(index, handler) {
51				var origHandler = self[handler];
52				self[handler] = function() {
53					return origHandler.apply(self, arguments);
54				};
55			});
56		},
57		setElemSpacing: function() {
58			if (this.options.takeSize === 'width') {
59				this.elements.holder.css(this.options.spacingProp, this.elements.takeSizeFrom.outerWidth());
60			} else if (this.options.takeSize === 'height') {
61				this.elements.holder.css(this.options.spacingProp, this.elements.takeSizeFrom.outerHeight());
62			}
63		},
64		destroy: function() {
65			var self = this;
66
67			// destroy handler
68			if(self.options.flexible) {
69				self.destroyed = true;
70				$(window).unbind('resize orientationchange', self.onWindowResize);
71			}
72			// remove assigned styles
73			self.elements.holder.css(this.options.spacingProp, '');
74			// remove data
75			self.elements.holder.removeData('setSpacing');
76		}
77	};
78
79	// jquery plugin
80	$.fn.setSpacing = function(opt) {
81		return this.each(function() {
82			$(this).data('setSpacing', new setSpacing($.extend(opt, { holder: this })));
83		});
84	};
85})(jQuery);

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.