OLD | NEW |
1 /* | 1 /* |
2 Created By: Chris Campbell | 2 Created By: Chris Campbell |
3 Modified By: Noah Winecoff (http://www.findmotive.com) | 3 Modified By: Noah Winecoff (http://www.findmotive.com) |
4 Website: http://particletree.com | 4 Website: http://particletree.com |
5 Date: 2/1/2006 | 5 Date: 2/1/2006 |
6 | 6 |
7 Inspired by the lightbox implementation found at http://www.huddletogether.com/p
rojects/lightbox/ | 7 Inspired by the lightbox implementation found at http://www.huddletogether.com/p
rojects/lightbox/ |
8 */ | 8 */ |
9 | 9 |
10 /*-------------------------------GLOBAL VARIABLES-------------------------------
-----*/ | 10 /*-------------------------------GLOBAL VARIABLES-------------------------------
-----*/ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 lightbox.prototype = { | 61 lightbox.prototype = { |
62 | 62 |
63 yPos : 0, | 63 yPos : 0, |
64 xPos : 0, | 64 xPos : 0, |
65 | 65 |
66 initialize: function(ctrl) { | 66 initialize: function(ctrl) { |
67 this.content = ctrl.href; | 67 this.content = ctrl.href; |
68 Event.observe(ctrl, 'click', this.activate.bindAsEventListener(t
his), false); | 68 Event.observe(ctrl, 'click', this.activate.bindAsEventListener(t
his), false); |
69 ctrl.onclick = function(){return false;}; | 69 ctrl.onclick = function(){return false;}; |
70 }, | 70 }, |
71 » | 71 |
72 // Turn everything on - mainly the IE fixes | 72 // Turn everything on - mainly the IE fixes |
73 activate: function(){ | 73 activate: function(){ |
74 if (browser == 'Internet Explorer'){ | 74 if (browser == 'Internet Explorer'){ |
75 this.getScroll(); | 75 this.getScroll(); |
76 this.prepareIE('100%', 'hidden'); | 76 this.prepareIE('100%', 'hidden'); |
77 this.setScroll(0,0); | 77 this.setScroll(0,0); |
78 this.hideSelects('hidden'); | 78 this.hideSelects('hidden'); |
79 } | 79 } |
80 this.displayLightbox("block"); | 80 this.displayLightbox("block"); |
81 }, | 81 }, |
82 » | 82 |
83 // Ie requires height to 100% and overflow hidden or else you can scroll
down past the lightbox | 83 // Ie requires height to 100% and overflow hidden or else you can scroll
down past the lightbox |
84 prepareIE: function(height, overflow){ | 84 prepareIE: function(height, overflow){ |
85 bod = document.getElementsByTagName('body')[0]; | 85 bod = document.getElementsByTagName('body')[0]; |
86 bod.style.height = height; | 86 bod.style.height = height; |
87 bod.style.overflow = overflow; | 87 bod.style.overflow = overflow; |
88 | 88 |
89 htm = document.getElementsByTagName('html')[0]; | 89 htm = document.getElementsByTagName('html')[0]; |
90 htm.style.height = height; | 90 htm.style.height = height; |
91 » » htm.style.overflow = overflow; | 91 » » htm.style.overflow = overflow; |
92 }, | 92 }, |
93 » | 93 |
94 // In IE, select elements hover on top of the lightbox | 94 // In IE, select elements hover on top of the lightbox |
95 hideSelects: function(visibility){ | 95 hideSelects: function(visibility){ |
96 selects = document.getElementsByTagName('select'); | 96 selects = document.getElementsByTagName('select'); |
97 for(i = 0; i < selects.length; i++) { | 97 for(i = 0; i < selects.length; i++) { |
98 selects[i].style.visibility = visibility; | 98 selects[i].style.visibility = visibility; |
99 } | 99 } |
100 }, | 100 }, |
101 » | 101 |
102 // Taken from lightbox implementation found at http://www.huddletogether
.com/projects/lightbox/ | 102 // Taken from lightbox implementation found at http://www.huddletogether
.com/projects/lightbox/ |
103 getScroll: function(){ | 103 getScroll: function(){ |
104 if (self.pageYOffset) { | 104 if (self.pageYOffset) { |
105 this.yPos = self.pageYOffset; | 105 this.yPos = self.pageYOffset; |
106 } else if (document.documentElement && document.documentElement.
scrollTop){ | 106 } else if (document.documentElement && document.documentElement.
scrollTop){ |
107 » » » this.yPos = document.documentElement.scrollTop; | 107 » » » this.yPos = document.documentElement.scrollTop; |
108 } else if (document.body) { | 108 } else if (document.body) { |
109 this.yPos = document.body.scrollTop; | 109 this.yPos = document.body.scrollTop; |
110 } | 110 } |
111 }, | 111 }, |
112 » | 112 |
113 setScroll: function(x, y){ | 113 setScroll: function(x, y){ |
114 » » window.scrollTo(x, y); | 114 » » window.scrollTo(x, y); |
115 }, | 115 }, |
116 » | 116 |
117 displayLightbox: function(display){ | 117 displayLightbox: function(display){ |
118 $('overlay').style.display = display; | 118 $('overlay').style.display = display; |
119 $('lightbox').style.display = display; | 119 $('lightbox').style.display = display; |
120 if(display != 'none') this.loadInfo(); | 120 if(display != 'none') this.loadInfo(); |
121 }, | 121 }, |
122 » | 122 |
123 // Write an iFrame instead of using an AJAX call to pull the content | 123 // Write an iFrame instead of using an AJAX call to pull the content |
124 loadInfo: function() { | 124 loadInfo: function() { |
125 info = "<div id='lbContent'><center><a href='#' class='lbAction'
rel='deactivate'>close (x)</a></center><iframe frameborder=\"0\" width=\"100%\"
height=\"100%\" src=\"" + this.content + "\"</iframe></div>"; | 125 info = "<div id='lbContent'><center><a href='#' class='lbAction'
rel='deactivate'>close (x)</a></center><iframe frameborder=\"0\" width=\"100%\"
height=\"100%\" src=\"" + this.content + "\"</iframe></div>"; |
126 new Insertion.Before($('lbLoadMessage'), info) | 126 new Insertion.Before($('lbLoadMessage'), info) |
127 » » $('lightbox').className = "done";» | 127 » » $('lightbox').className = "done"; |
128 » » this.actions();»» » | 128 » » this.actions(); |
129 » » | 129 |
130 }, | 130 }, |
131 » | 131 |
132 // Search through new links within the lightbox, and attach click event | 132 // Search through new links within the lightbox, and attach click event |
133 actions: function(){ | 133 actions: function(){ |
134 lbActions = document.getElementsByClassName('lbAction'); | 134 lbActions = document.getElementsByClassName('lbAction'); |
135 | 135 |
136 for(i = 0; i < lbActions.length; i++) { | 136 for(i = 0; i < lbActions.length; i++) { |
137 Event.observe(lbActions[i], 'click', this[lbActions[i].r
el].bindAsEventListener(this), false); | 137 Event.observe(lbActions[i], 'click', this[lbActions[i].r
el].bindAsEventListener(this), false); |
138 lbActions[i].onclick = function(){return false;}; | 138 lbActions[i].onclick = function(){return false;}; |
139 } | 139 } |
140 | 140 |
141 }, | 141 }, |
142 » | 142 |
143 // Example of creating your own functionality once lightbox is initiated | 143 // Example of creating your own functionality once lightbox is initiated |
144 insert: function(e){ | 144 insert: function(e){ |
145 link = Event.element(e).parentNode; | 145 link = Event.element(e).parentNode; |
146 Element.remove($('lbContent')); | 146 Element.remove($('lbContent')); |
147 » | 147 |
148 var myAjax = new Ajax.Request( | 148 var myAjax = new Ajax.Request( |
149 link.href, | 149 link.href, |
150 {method: 'post', parameters: "", onComplete: this.proc
essInfo.bindAsEventListener(this)} | 150 {method: 'post', parameters: "", onComplete: this.proc
essInfo.bindAsEventListener(this)} |
151 ); | 151 ); |
152 » | 152 |
153 }, | 153 }, |
154 » | 154 |
155 // Example of creating your own functionality once lightbox is initiated | 155 // Example of creating your own functionality once lightbox is initiated |
156 deactivate: function(){ | 156 deactivate: function(){ |
157 Element.remove($('lbContent')); | 157 Element.remove($('lbContent')); |
158 » » | 158 |
159 if (browser == "Internet Explorer"){ | 159 if (browser == "Internet Explorer"){ |
160 this.setScroll(0,this.yPos); | 160 this.setScroll(0,this.yPos); |
161 this.prepareIE("auto", "auto"); | 161 this.prepareIE("auto", "auto"); |
162 this.hideSelects("visible"); | 162 this.hideSelects("visible"); |
163 } | 163 } |
164 » » | 164 |
165 this.displayLightbox("none"); | 165 this.displayLightbox("none"); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 /*------------------------------------------------------------------------------
-----------------*/ | 169 /*------------------------------------------------------------------------------
-----------------*/ |
170 | 170 |
171 // Onload, make all links that need to trigger a lightbox active | 171 // Onload, make all links that need to trigger a lightbox active |
172 function initialize(){ | 172 function initialize(){ |
173 addLightboxMarkup(); | 173 addLightboxMarkup(); |
174 lbox = document.getElementsByClassName('lbOn'); | 174 lbox = document.getElementsByClassName('lbOn'); |
(...skipping 14 matching lines...) Expand all Loading... |
189 // lb.className = 'loading'; | 189 // lb.className = 'loading'; |
190 lb.innerHTML = '<div id="lbLoadMessage">' + | 190 lb.innerHTML = '<div id="lbLoadMessage">' + |
191 'loading' + | 191 'loading' + |
192 '</div>'; | 192 '</div>'; |
193 lbcontainer = document.createElement('div'); | 193 lbcontainer = document.createElement('div'); |
194 lbcontainer.id = 'lightbox'; | 194 lbcontainer.id = 'lightbox'; |
195 lb.className = 'loading'; | 195 lb.className = 'loading'; |
196 lbcontainer.appendChild(lb); | 196 lbcontainer.appendChild(lb); |
197 bod.appendChild(overlay); | 197 bod.appendChild(overlay); |
198 bod.appendChild(lbcontainer); | 198 bod.appendChild(lbcontainer); |
199 } | 199 } |
OLD | NEW |