Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 390
- Log:
Initial import of Canvass, a donations-based poll application.
- Author:
- rool
- Date:
- Mon Mar 21 14:58:04 +0000 2011
- Size:
- 6473 Bytes
- Properties:
- Property svn:executable is set to *
1 | /* |
2 | Created By: Chris Campbell |
3 | Website: http://particletree.com |
4 | Date: 2/1/2006 |
5 | |
6 | Adapted By: Simon de Haan |
7 | Website: http://blog.eight.nl |
8 | Date: 21/2/2006 |
9 | |
10 | Custom Modifications By: Andrew Hodgkinson |
11 | Website: http://pond.org.uk |
12 | Date: 2009, 2010 - modified sections marked by "(ADH)" in comments |
13 | |
14 | Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/ |
15 | And the lightbox gone wild by ParticleTree at http://particletree.com/features/lightbox-gone-wild/ |
16 | |
17 | */ |
18 | |
19 | /*-------------------------------GLOBAL VARIABLES------------------------------------*/ |
20 | |
21 | var detect = navigator.userAgent.toLowerCase(); |
22 | var OS,browser,version,total,thestring; |
23 | |
24 | /*-----------------------------------------------------------------------------------------------*/ |
25 | |
26 | //Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/ |
27 | |
28 | function getBrowserInfo() { |
29 | if (checkIt('konqueror')) { |
30 | browser = "Konqueror"; |
31 | OS = "Linux"; |
32 | } |
33 | else if (checkIt('safari')) browser = "Safari" |
34 | else if (checkIt('omniweb')) browser = "OmniWeb" |
35 | else if (checkIt('opera')) browser = "Opera" |
36 | else if (checkIt('webtv')) browser = "WebTV"; |
37 | else if (checkIt('icab')) browser = "iCab" |
38 | else if (checkIt('msie')) browser = "Internet Explorer" |
39 | else if (!checkIt('compatible')) { |
40 | browser = "Netscape Navigator" |
41 | version = detect.charAt(8); |
42 | } |
43 | else browser = "An unknown browser"; |
44 | |
45 | if (!version) version = detect.charAt(place + thestring.length); |
46 | |
47 | if (!OS) { |
48 | if (checkIt('linux')) OS = "Linux"; |
49 | else if (checkIt('x11')) OS = "Unix"; |
50 | else if (checkIt('mac')) OS = "Mac" |
51 | else if (checkIt('win')) OS = "Windows" |
52 | else OS = "an unknown operating system"; |
53 | } |
54 | } |
55 | |
56 | function checkIt(string) { |
57 | place = detect.indexOf(string) + 1; |
58 | thestring = string; |
59 | return place; |
60 | } |
61 | |
62 | /*-----------------------------------------------------------------------------------------------*/ |
63 | |
64 | Event.observe(window, 'load', initialize, false); |
65 | Event.observe(window, 'load', getBrowserInfo, false); |
66 | Event.observe(window, 'unload', Event.unloadCache, false); |
67 | |
68 | var lightbox = Class.create(); |
69 | |
70 | lightbox.prototype = { |
71 | |
72 | yPos : 0, |
73 | xPos : 0, |
74 | |
75 | initialize: function(ctrl) { |
76 | this.content = ctrl.rel; |
77 | Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false); |
78 | ctrl.onclick = function(){return false;}; |
79 | /* 2009-11-16 (ADH): Added line below */ |
80 | this.keyHandler = this.deactivateKey.bindAsEventListener(this); |
81 | }, |
82 | |
83 | // Turn everything on - mainly the IE fixes |
84 | activate: function(){ |
85 | if (browser == 'Internet Explorer'){ |
86 | this.getScroll(); |
87 | this.prepareIE('100%', 'hidden'); |
88 | this.setScroll(0,0); |
89 | this.hideSelects('hidden'); |
90 | } |
91 | this.displayLightbox("block"); |
92 | }, |
93 | |
94 | // Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox |
95 | prepareIE: function(height, overflow){ |
96 | bod = document.getElementsByTagName('body')[0]; |
97 | bod.style.height = height; |
98 | bod.style.overflow = overflow; |
99 | |
100 | htm = document.getElementsByTagName('html')[0]; |
101 | htm.style.height = height; |
102 | htm.style.overflow = overflow; |
103 | }, |
104 | |
105 | // In IE, select elements hover on top of the lightbox |
106 | hideSelects: function(visibility){ |
107 | selects = document.getElementsByTagName('select'); |
108 | for(i = 0; i < selects.length; i++) { |
109 | selects[i].style.visibility = visibility; |
110 | } |
111 | }, |
112 | |
113 | // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/ |
114 | getScroll: function(){ |
115 | if (self.pageYOffset) { |
116 | this.yPos = self.pageYOffset; |
117 | } else if (document.documentElement && document.documentElement.scrollTop){ |
118 | this.yPos = document.documentElement.scrollTop; |
119 | } else if (document.body) { |
120 | this.yPos = document.body.scrollTop; |
121 | } |
122 | }, |
123 | |
124 | setScroll: function(x, y){ |
125 | window.scrollTo(x, y); |
126 | }, |
127 | |
128 | displayLightbox: function(display){ |
129 | $('overlay').style.display = display; |
130 | $(this.content).style.display = display; |
131 | |
132 | /* 2009-11-16 (ADH): Changed conditional from |
133 | * "if(display != 'none') this.actions();" into the |
134 | * if...else code shown. |
135 | */ |
136 | |
137 | if(display != 'none'){ |
138 | this.actions(); |
139 | Event.observe(window, 'keydown', this.keyHandler); |
140 | }else{ |
141 | Event.stopObserving(window, 'keydown', this.keyHandler); |
142 | } |
143 | }, |
144 | |
145 | // Search through new links within the lightbox, and attach click event |
146 | actions: function(){ |
147 | lbActions = document.getElementsByClassName('lbAction'); |
148 | |
149 | for(i = 0; i < lbActions.length; i++) { |
150 | Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this), false); |
151 | lbActions[i].onclick = function(){return false;}; |
152 | } |
153 | |
154 | }, |
155 | |
156 | /* 2009-11-16 (ADH): Added function below */ |
157 | deactivateKey: function(event){ |
158 | if (event.keyCode == 27){ |
159 | this.deactivate(); |
160 | Event.stop(event); |
161 | } |
162 | }, |
163 | |
164 | // Example of creating your own functionality once lightbox is initiated |
165 | deactivate: function(){ |
166 | if (browser == "Internet Explorer"){ |
167 | this.setScroll(0,this.yPos); |
168 | this.prepareIE("auto", "auto"); |
169 | this.hideSelects("visible"); |
170 | } |
171 | |
172 | this.displayLightbox("none"); |
173 | } |
174 | } |
175 | |
176 | /*-----------------------------------------------------------------------------------------------*/ |
177 | |
178 | // Onload, make all links that need to trigger a lightbox active |
179 | // |
180 | // 2010-04-26 (ADH): Made self-contained to avoid potential namespace clashes |
181 | // and extracted the sacn-document-and-build-objects code to |
182 | // a new namespaced method so that it can be called from |
183 | // external scripts. This is necessary for cases where AJAX |
184 | // updates to a document cause Leightbox enabled links to be |
185 | // replaced. |
186 | // |
187 | function initialize(){ |
188 | // Add in markup necessary to make this work. Basically two divs: |
189 | // Overlay holds the shadow |
190 | // Lightbox is the centered square that the content is put into. |
191 | |
192 | bod = document.getElementsByTagName('body')[0]; |
193 | |
194 | overlay = document.createElement('div'); |
195 | overlay.id = 'overlay'; |
196 | |
197 | bod.appendChild(overlay); |
198 | |
199 | // Now activate Leightbox links. |
200 | |
201 | leightboxScanDocument(); |
202 | } |
203 | |
204 | // 2010-04-26 (ADH): Added (see 'initialize' above). |
205 | // |
206 | function leightboxScanDocument(){ |
207 | lbox = document.getElementsByClassName('lbOn'); |
208 | for(i = 0; i < lbox.length; i++) { |
209 | valid = new lightbox(lbox[i]); |
210 | } |
211 | } |