diff options
Diffstat (limited to 'docroot/custom_content/2col.js')
-rwxr-xr-x | docroot/custom_content/2col.js | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/docroot/custom_content/2col.js b/docroot/custom_content/2col.js new file mode 100755 index 0000000..3a91e4d --- /dev/null +++ b/docroot/custom_content/2col.js | |||
@@ -0,0 +1,170 @@ | |||
1 | /* | ||
2 | * Material Experience - 2 Column Custom Content Script | ||
3 | * | ||
4 | * EYEMG - Interactive Media Group | ||
5 | * Created by Mike Crute (mcrute@eyemg.com) | ||
6 | * Updated by Mike Crute (mcrute@eyemg.com) on 10/21/07 | ||
7 | */ | ||
8 | |||
9 | // Tracks the last ID requested | ||
10 | var lastID = null; | ||
11 | |||
12 | // Track the currently open nav item | ||
13 | var curr = null; | ||
14 | |||
15 | document.write('<script type="text/javascript" src="http://materialexperience.santoprene.com/lib/scriptaculous/scriptaculous.js"></script>'); | ||
16 | |||
17 | function doLoad() | ||
18 | { | ||
19 | // Hide everything first | ||
20 | $$('ul#navigation li ul').each(function(item) | ||
21 | { | ||
22 | item.setStyle({ display: 'none' }); | ||
23 | }); | ||
24 | |||
25 | // Then attach the onclick events | ||
26 | $$('ul#navigation li').each(function(item) | ||
27 | { | ||
28 | Event.observe(item, 'click', function(event) | ||
29 | { | ||
30 | // Hide the currently opened item if it is clicked again | ||
31 | // per BS. | ||
32 | if (curr && item == curr) | ||
33 | { | ||
34 | curr.down('ul').hide(); | ||
35 | item.setStyle({ borderLeft: '0px' }); | ||
36 | curr = null; | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | curr = item; | ||
41 | |||
42 | // Hide everything | ||
43 | $$('ul#navigation li ul').each(function(item) | ||
44 | { | ||
45 | item.setStyle({ display: 'none' }); | ||
46 | }); | ||
47 | |||
48 | // Clear out the borders | ||
49 | $$('ul#navigation li').each(function(item) | ||
50 | { | ||
51 | item.setStyle({ borderLeft: '' }); | ||
52 | }); | ||
53 | |||
54 | // Figure out what color we SHOULD be, this will change | ||
55 | // depending on the card color we are on so just rely | ||
56 | // on the designer to communicate through the CSS, | ||
57 | // probably not wise relying on a designer for code | ||
58 | // but alas... | ||
59 | var color = $$('ul#navigation li a')[0].getStyle('background-color'); | ||
60 | |||
61 | // Catch and execute or just leave it lie | ||
62 | try | ||
63 | { | ||
64 | if (item.down('ul').style.display != 'none') | ||
65 | { | ||
66 | item.down('ul').hide(); | ||
67 | Event.stop(event); | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | item.down('ul').show(); | ||
72 | item.setStyle({ borderLeft: '3px solid ' + color }); | ||
73 | Event.stop(event); | ||
74 | } | ||
75 | catch (e) | ||
76 | { | ||
77 | // Just let the link do its thing | ||
78 | } | ||
79 | }); | ||
80 | }); | ||
81 | } | ||
82 | |||
83 | function locateContent(contID) | ||
84 | { | ||
85 | // Hide the last ID from a global variable because going over each | ||
86 | // item and hiding it could take a prohibitively long time on a big | ||
87 | // page and we will most definitely be dealing with big pages here. | ||
88 | if (lastID) | ||
89 | { | ||
90 | $(lastID).className = ""; | ||
91 | } | ||
92 | |||
93 | // Track the requested content ID | ||
94 | lastID = contID; | ||
95 | |||
96 | // The scroll top but subtract the height of the item itself or we | ||
97 | // always scroll to the bottom of items. | ||
98 | $('test').scrollTop = $(contID).offsetTop - $(contID).getHeight(); | ||
99 | $(contID).className = "selected"; | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * Create custom scroll bars for an HTML element. | ||
104 | */ | ||
105 | function scrollify(div) | ||
106 | { | ||
107 | // Inherit the color from a link | ||
108 | var color = $$('ul#navigation li a')[0].getStyle('background-color'); | ||
109 | |||
110 | // Create the scroll container and draggable widget | ||
111 | document.body.appendChild( | ||
112 | this.scrollCont = Builder.node('div', | ||
113 | { | ||
114 | style: 'border-left: 1px solid ' + color + ';' + | ||
115 | 'width: 1px; position: absolute; ' + | ||
116 | 'height:' + div.offsetHeight + 'px; ' + | ||
117 | 'top: 10px;' + 'left: ' + (div.offsetLeft + div.offsetWidth + 12) + 'px;' | ||
118 | }, | ||
119 | |||
120 | this.scrollBar = Builder.node('img', | ||
121 | { | ||
122 | src: 'http://materialexperience.santoprene.com/images/pill.gif', | ||
123 | style: 'display: block; margin-left: -3px; cursor: move; ' + | ||
124 | 'background: ' + color + '; padding: 0px;' | ||
125 | }) | ||
126 | )); | ||
127 | |||
128 | // Create the scroller | ||
129 | this.scroller = new Control.Slider(this.scrollBar, this.scrollCont, | ||
130 | { | ||
131 | axis: 'vertical', | ||
132 | range: $R(0, div.scrollHeight), | ||
133 | |||
134 | onSlide: function(value) | ||
135 | { | ||
136 | div.scrollTop = Math.floor(value); | ||
137 | }.bind(this) | ||
138 | }); | ||
139 | |||
140 | new PeriodicalExecuter(function() | ||
141 | { | ||
142 | // Update the scroller range when the contents change | ||
143 | this.scroller.range = $R(0, div.scrollHeight); | ||
144 | |||
145 | // Move the scroller when the scrolled element changes | ||
146 | // (e.g. linking down into the page). | ||
147 | if (this.scroller.value != div.scrollTop) | ||
148 | { | ||
149 | this.scroller.setValue(div.scrollTop); | ||
150 | } | ||
151 | }.bind(this), 1); | ||
152 | } | ||
153 | |||
154 | /* | ||
155 | * Attach scrollbars to the narrow column and the wide column if they exist. | ||
156 | */ | ||
157 | Event.observe(window, 'load', function() | ||
158 | { | ||
159 | if ($$('.narrowCol')[0]) | ||
160 | { | ||
161 | new scrollify($$('.narrowCol')[0]); | ||
162 | } | ||
163 | |||
164 | if ($$('.wideCol')[0]) | ||
165 | { | ||
166 | new scrollify($$('.wideCol')[0]); | ||
167 | } | ||
168 | }); | ||
169 | |||
170 | Event.observe(window, 'load', doLoad); \ No newline at end of file | ||