Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 381
- Log:
Radiant is now packaged as a Gem - see Changeset #373, Changeset #374,
Changeset #375, Changeset #376, Changeset #377, Changeset #378,
Changeset #379 and Changeset #380. The application part of Radiant is
now mostly empty; it exists to provide a structure which hooks into the
gem and which provides a framework for extensions. Included in this big
changeset are all the deletions, additions and changes needed to go from
the old ROOL customised Radiant to a new ROOL customised Radiant, which
includes several custom extensions adapted from the old Radiant
modifications and requires Radiant 0.9.1 to be installed as a gem.
- Author:
- rool
- Date:
- Mon Mar 21 14:01:18 +0000 2011
- Size:
- 7386 Bytes
1 | /* |
2 | * popup.js |
3 | * |
4 | * dependencies: prototype.js, effects.js, lowpro.js |
5 | * |
6 | * -------------------------------------------------------------------------- |
7 | * |
8 | * Allows you to open up a URL inside of a Facebook-style window. To use |
9 | * simply assign the class "popup" to a link that contains an href to the |
10 | * HTML snippet that you would like to load up inside a window: |
11 | * |
12 | * <a class="popup" href="window.html">Window</a> |
13 | * |
14 | * You can also "popup" a specific div by referencing it by ID: |
15 | * |
16 | * <a class="popup" href="#my_div">Popup</a> |
17 | * <div id="my_div" style="display:none">Hello World!</div> |
18 | * |
19 | * You will need to install the following hook: |
20 | * |
21 | * Event.addBehavior({'a.popup': Popup.TriggerBehavior()}); |
22 | * |
23 | * -------------------------------------------------------------------------- |
24 | * |
25 | * Copyright (c) 2008, John W. Long |
26 | * Portions copyright (c) 2008, Five Points Solutions, Inc. |
27 | * |
28 | * Permission is hereby granted, free of charge, to any person obtaining a |
29 | * copy of this software and associated documentation files (the "Software"), |
30 | * to deal in the Software without restriction, including without limitation |
31 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
32 | * and/or sell copies of the Software, and to permit persons to whom the |
33 | * Software is furnished to do so, subject to the following conditions: |
34 | * |
35 | * The above copyright notice and this permission notice shall be included in |
36 | * all copies or substantial portions of the Software. |
37 | * |
38 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
39 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
40 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
41 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
42 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
43 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
44 | * DEALINGS IN THE SOFTWARE. |
45 | * |
46 | */ |
47 | |
48 | var Popup = { |
49 | BorderThickness: 8, |
50 | BorderImage: '/images/popup_border_background.png', |
51 | BorderTopLeftImage: '/images/popup_border_top_left.png', |
52 | BorderTopRightImage: '/images/popup_border_top_right.png', |
53 | BorderBottomLeftImage: '/images/popup_border_bottom_left.png', |
54 | BorderBottomRightImage: '/images/popup_border_bottom_right.png' |
55 | }; |
56 | |
57 | Popup.borderImages = function() { |
58 | return $A([ |
59 | Popup.BorderImage, |
60 | Popup.BorderTopLeftImage, |
61 | Popup.BorderTopRightImage, |
62 | Popup.BorderBottomLeftImage, |
63 | Popup.BorderBottomRightImage |
64 | ]); |
65 | } |
66 | |
67 | Popup.preloadImages = function() { |
68 | if (!Popup.imagesPreloaded) { |
69 | Popup.borderImages().each(function(src) { |
70 | var image = new Image(); |
71 | image.src = src; |
72 | }); |
73 | Popup.preloadedImages = true; |
74 | } |
75 | } |
76 | |
77 | Popup.TriggerBehavior = Behavior.create({ |
78 | initialize: function() { |
79 | var matches = this.element.href.match(/\#(.+)$/); |
80 | if (matches) { |
81 | this.window = new Popup.Window($(matches[1])); |
82 | } else { |
83 | this.window = new Popup.AjaxWindow(this.element.href); |
84 | } |
85 | }, |
86 | |
87 | onclick: function(event) { |
88 | this.popup(); |
89 | event.stop(); |
90 | }, |
91 | |
92 | popup: function() { |
93 | this.window.show(); |
94 | } |
95 | }); |
96 | |
97 | Popup.AbstractWindow = Class.create({ |
98 | initialize: function() { |
99 | Popup.preloadImages(); |
100 | this.buildWindow(); |
101 | }, |
102 | |
103 | buildWindow: function() { |
104 | this.element = $div({'class': 'popup_window', style: 'display: none; padding: 0 ' + Popup.BorderThickness + 'px; position: absolute'}); |
105 | |
106 | this.top = $div({style: 'background: url(' + Popup.BorderImage + '); height: ' + Popup.BorderThickness + 'px'}); |
107 | this.element.insert(this.top); |
108 | |
109 | var outer = $div({style: 'background: url(' + Popup.BorderImage + '); margin: 0px -' + Popup.BorderThickness + 'px; padding: 0px ' + Popup.BorderThickness + 'px; position: relative'}); |
110 | this.element.insert(outer); |
111 | |
112 | this.bottom = $div({style: 'background: url(' + Popup.BorderImage + '); height: ' + Popup.BorderThickness + 'px'}); |
113 | this.element.insert(this.bottom); |
114 | |
115 | var topLeft = $div({style: 'background: url(' + Popup.BorderTopLeftImage + '); height: ' + Popup.BorderThickness + 'px; width: ' + Popup.BorderThickness + 'px; position: absolute; left: 0; top: -' + Popup.BorderThickness + 'px'}); |
116 | outer.insert(topLeft); |
117 | |
118 | var topRight = $div({style: 'background: url(' + Popup.BorderTopRightImage + '); height: ' + Popup.BorderThickness + 'px; width: ' + Popup.BorderThickness + 'px; position: absolute; right: 0; top: -' + Popup.BorderThickness + 'px'}); |
119 | outer.insert(topRight); |
120 | |
121 | var bottomLeft = $div({style: 'background: url(' + Popup.BorderBottomLeftImage + '); height: ' + Popup.BorderThickness + 'px; width: ' + Popup.BorderThickness + 'px; position: absolute; left: 0; bottom: -' + Popup.BorderThickness + 'px'}); |
122 | outer.insert(bottomLeft); |
123 | |
124 | var bottomRight = $div({style: 'background: url(' + Popup.BorderBottomRightImage + '); height: ' + Popup.BorderThickness + 'px; width: ' + Popup.BorderThickness + 'px; position: absolute; right: 0; bottom: -' + Popup.BorderThickness + 'px'}); |
125 | outer.insert(bottomRight); |
126 | |
127 | this.content = $div({style: 'background-color: white'}); |
128 | outer.insert(this.content); |
129 | |
130 | var body = $$('body').first(); |
131 | body.insert(this.element); |
132 | }, |
133 | |
134 | show: function() { |
135 | this.beforeShow(); |
136 | this.element.show(); |
137 | this.afterShow(); |
138 | }, |
139 | |
140 | hide: function() { |
141 | this.element.hide(); |
142 | }, |
143 | |
144 | toggle: function() { |
145 | if (this.element.visible()) { |
146 | this.hide(); |
147 | } else { |
148 | this.show(); |
149 | } |
150 | }, |
151 | |
152 | focus: function() { |
153 | var form = this.element.down('form'); |
154 | if (form) { |
155 | var elements = form.getElements().reject(function(e) { return e.type == 'hidden' }); |
156 | var element = elements[0] || form.down('button'); |
157 | if (element) element.focus(); |
158 | } |
159 | }, |
160 | |
161 | beforeShow: function() { |
162 | if (Prototype.Browser.IE) { |
163 | // IE fixes |
164 | var width = this.element.getWidth() - (Popup.BorderThickness * 2); |
165 | this.top.setStyle("width:" + width + "px"); |
166 | this.bottom.setStyle("width:" + width + "px"); |
167 | } |
168 | this.centerWindowInView(); |
169 | }, |
170 | |
171 | afterShow: function() { |
172 | this.focus(); |
173 | }, |
174 | |
175 | centerWindowInView: function() { |
176 | var offsets = document.viewport.getScrollOffsets(); |
177 | this.element.setStyle({ |
178 | left: parseInt(offsets.left + (document.viewport.getWidth() - this.element.getWidth()) / 2) + 'px', |
179 | top: parseInt(offsets.top + (document.viewport.getHeight() - this.element.getHeight()) / 2.2) + 'px' |
180 | }); |
181 | } |
182 | }); |
183 | |
184 | Popup.Window = Class.create(Popup.AbstractWindow, { |
185 | initialize: function($super, element) { |
186 | $super(); |
187 | element.remove(); |
188 | this.content.update(element); |
189 | element.show(); |
190 | } |
191 | }); |
192 | |
193 | Popup.AjaxWindow = Class.create(Popup.AbstractWindow, { |
194 | initialize: function($super, url, options) { |
195 | $super(); |
196 | options = Object.extend({reload: true}, options); |
197 | this.url = url; |
198 | this.reload = options.reload; |
199 | }, |
200 | |
201 | show: function($super) { |
202 | if (!this.loaded || this.reload) { |
203 | new Ajax.Updater(this.content, this.url, {asynchronous: false, method: "get", evalScripts: true, onComplete: $super}); |
204 | this.loaded = true; |
205 | } else { |
206 | $super(); |
207 | } |
208 | } |
209 | }); |
210 | |
211 | // Element extensions |
212 | Element.addMethods({ |
213 | closePopup: function(element) { |
214 | $(element).up('div.popup_window').hide(); |
215 | } |
216 | }); |