PageSourceSearch

https://admeyersuniforms.com/skin/frontend/base/default/tm/attributepages/js/attributepages.js

js admeyersuniforms.com collected 2026-10-10 00:27:09 UTC 4,475 bytes, 133 lines download raw bytes

1var AttributePages = {};
2AttributePages.Slider = Class.create();
3AttributePages.Slider.prototype = {
4    initialize: function(container, controlLeft, controlRight){
5        this.animating    = false;
6        this.container    = $(container);
7        this.content      = $(container).down();
8        this.items        = this.content.childElements();
9        this.controlLeft  = $(controlLeft);
10        this.controlRight = $(controlRight);
11        // fix for slider inside tabs or navigation dropdown
12        var interval = setInterval(function() {
13            if (!this.container.getWidth()) {
14                return;
15            }
16            clearInterval(interval);
17            this.initSize();
18            this.initControls();
19        }.bind(this), 1000);
20    },
21
22    initSize: function() {
23        var width = 0,
24            self = this,
25            containerWidth = this.container.getWidth();
26        this.items.each(function(li) {
27            if (li.getWidth() > containerWidth) {
28                li.setStyle({
29                    width: containerWidth
30                        - parseFloat(li.getStyle('padding-left'))
31                        - parseFloat(li.getStyle('padding-right'))
32                        + 'px'
33                });
34                if (!self.shift) {
35                    self.shift = containerWidth
36                        + parseFloat(li.getStyle('margin-left'))
37                        + parseFloat(li.getStyle('margin-right'));
38                }
39            } else {
40                if (!self.shift) {
41                    self.shift = Math.floor(containerWidth / li.getWidth()) * li.getWidth();
42                }
43            }
44            width += li.getWidth()
45                + parseFloat(li.getStyle('margin-left'))
46                + parseFloat(li.getStyle('margin-right'));
47        });
48        this.content.setStyle({
49            width: width + 'px'
50        });
51    },
52
53    initControls: function(){
54        this.controlLeft.href = this.controlRight.href = 'javascript:void(0)';
55        Event.observe(this.controlLeft,  'click', this.shiftLeft.bind(this));
56        Event.observe(this.controlRight, 'click', this.shiftRight.bind(this));
57
58        var lastItem = this.content.childElements().last();
59        if ((lastItem.positionedOffset()[0] + lastItem.getWidth()) <= this.container.getWidth()) {
60            this.updateControls(0, 0);
61        } else {
62            this.updateControls(1, 0);
63        }
64    },
65
66    shiftRight: function(){
67        if (this.animating) {
68            return;
69        }
70
71        var left = isNaN(parseInt(this.content.style.left)) ? 0 : parseInt(this.content.style.left);
72        if ((left + this.shift) < 0) {
73            var shift = this.shift;
74            this.updateControls(1, 1);
75        } else {
76            var shift = Math.abs(left);
77            this.updateControls(1, 0);
78        }
79        this.moveTo(shift);
80    },
81
82    shiftLeft: function(){
83        if (this.animating) {
84            return;
85        }
86
87        var left          = isNaN(parseInt(this.content.style.left)) ? 0 : parseInt(this.content.style.left),
88            lastItemLeft  = this.content.childElements().last().positionedOffset()[0],
89            lastItemWidth = this.content.childElements().last().getWidth(),
90            contentWidth  = lastItemLeft + lastItemWidth;
91
92        if (contentWidth <= this.container.getWidth()) {
93            this.updateControls(0, 0);
94            return false;
95        }
96
97        if ((contentWidth + left - this.shift) > this.container.getWidth()) {
98            var shift = this.shift;
99            this.updateControls(1, 1);
100        } else {
101            var shift = contentWidth + left - this.container.getWidth();
102            this.updateControls(0, 1);
103        }
104        this.moveTo(-shift);
105    },
106
107    moveTo: function(shift){
108        var self = this;
109        this.animating = true;
110        new Effect.Move(this.content, {
111            x          : shift,
112            duration   : 0.3,
113            delay      : 0,
114            afterFinish: function(){
115                self.animating = false;
116            }
117        });
118    },
119
120    updateControls: function(left, right){
121        if (!left) {
122            this.controlLeft.addClassName('disabled');
123        } else {
124            this.controlLeft.removeClassName('disabled');
125        }
126
127        if (!right) {
128            this.controlRight.addClassName('disabled');
129        } else {
130            this.controlRight.removeClassName('disabled');
131        }
132    }
133};

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.