Revision c2a0470d
Mise à jour de mootools dans VigiBoard (ajout Chain.Wait & Log dans mootools-more).
Correction de l'effet de "flash" dans le template et mise à jour des styles CSS en conséquence.
git-svn-id: https://vigilo-dev.si.c-s.fr/svn@1568 b22e2e97-25c9-44ff-b637-2e5ceca36478
vigiboard/public/js/mootools-more.js | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
|
25 | 25 |
MooTools.More = { |
26 |
'version': '1.2.4.2dev',
|
|
27 |
'build': '%build%'
|
|
26 |
'version': '1.2.4.2', |
|
27 |
'build': 'bd5a93c0913cce25917c48cbdacde568e15e02ef'
|
|
28 | 28 |
}; |
29 | 29 |
|
30 | 30 |
/* |
... | ... | |
133 | 133 |
/* |
134 | 134 |
--- |
135 | 135 |
|
136 |
script: Log.js |
|
137 |
|
|
138 |
description: Provides basic logging functionality for plugins to implement. |
|
139 |
|
|
140 |
license: MIT-style license |
|
141 |
|
|
142 |
authors: |
|
143 |
- Guillermo Rauch |
|
144 |
- Thomas Aylott |
|
145 |
- Scott Kyle |
|
146 |
|
|
147 |
requires: |
|
148 |
- core:1.2.4/Class |
|
149 |
- /MooTools.More |
|
150 |
|
|
151 |
provides: [Log] |
|
152 |
|
|
153 |
... |
|
154 |
*/ |
|
155 |
|
|
156 |
(function(){ |
|
157 |
|
|
158 |
var global = this; |
|
159 |
|
|
160 |
var log = function(){ |
|
161 |
if (global.console && console.log){ |
|
162 |
try { |
|
163 |
console.log.apply(console, arguments); |
|
164 |
} catch(e) { |
|
165 |
console.log(Array.slice(arguments)); |
|
166 |
} |
|
167 |
} else { |
|
168 |
Log.logged.push(arguments); |
|
169 |
} |
|
170 |
return this; |
|
171 |
}; |
|
172 |
|
|
173 |
var disabled = function(){ |
|
174 |
this.logged.push(arguments); |
|
175 |
return this; |
|
176 |
}; |
|
177 |
|
|
178 |
this.Log = new Class({ |
|
179 |
|
|
180 |
logged: [], |
|
181 |
|
|
182 |
log: disabled, |
|
183 |
|
|
184 |
resetLog: function(){ |
|
185 |
this.logged.empty(); |
|
186 |
return this; |
|
187 |
}, |
|
188 |
|
|
189 |
enableLog: function(){ |
|
190 |
this.log = log; |
|
191 |
this.logged.each(function(args){ |
|
192 |
this.log.apply(this, args); |
|
193 |
}, this); |
|
194 |
return this.resetLog(); |
|
195 |
}, |
|
196 |
|
|
197 |
disableLog: function(){ |
|
198 |
this.log = disabled; |
|
199 |
return this; |
|
200 |
} |
|
201 |
|
|
202 |
}); |
|
203 |
|
|
204 |
Log.extend(new Log).enableLog(); |
|
205 |
|
|
206 |
// legacy |
|
207 |
Log.logger = function(){ |
|
208 |
return this.log.apply(this, arguments); |
|
209 |
}; |
|
210 |
|
|
211 |
})(); |
|
212 |
|
|
213 |
/* |
|
214 |
--- |
|
215 |
|
|
136 | 216 |
script: Class.Refactor.js |
137 | 217 |
|
138 | 218 |
description: Extends a class onto itself with new property, preserving any items attached to the class's namespace. |
... | ... | |
244 | 324 |
/* |
245 | 325 |
--- |
246 | 326 |
|
327 |
script: Chain.Wait.js |
|
328 |
|
|
329 |
description: value, Adds a method to inject pauses between chained events. |
|
330 |
|
|
331 |
license: MIT-style license. |
|
332 |
|
|
333 |
authors: |
|
334 |
- Aaron Newton |
|
335 |
|
|
336 |
requires: |
|
337 |
- core:1.2.4/Chain |
|
338 |
- core:1.2.4/Element |
|
339 |
- core:1.2.4/Fx |
|
340 |
- /MooTools.More |
|
341 |
|
|
342 |
provides: [Chain.Wait] |
|
343 |
|
|
344 |
... |
|
345 |
*/ |
|
346 |
|
|
347 |
(function(){ |
|
348 |
|
|
349 |
var wait = { |
|
350 |
wait: function(duration){ |
|
351 |
return this.chain(function(){ |
|
352 |
this.callChain.delay($pick(duration, 500), this); |
|
353 |
}.bind(this)); |
|
354 |
} |
|
355 |
}; |
|
356 |
|
|
357 |
Chain.implement(wait); |
|
358 |
|
|
359 |
if (window.Fx){ |
|
360 |
Fx.implement(wait); |
|
361 |
['Css', 'Tween', 'Elements'].each(function(cls){ |
|
362 |
if (Fx[cls]) Fx[cls].implement(wait); |
|
363 |
}); |
|
364 |
} |
|
365 |
|
|
366 |
Element.implement({ |
|
367 |
chains: function(effects){ |
|
368 |
$splat($pick(effects, ['tween', 'morph', 'reveal'])).each(function(effect){ |
|
369 |
effect = this.get(effect); |
|
370 |
if (!effect) return; |
|
371 |
effect.setOptions({ |
|
372 |
link:'chain' |
|
373 |
}); |
|
374 |
}, this); |
|
375 |
return this; |
|
376 |
}, |
|
377 |
pauseFx: function(duration, effect){ |
|
378 |
this.chains(effect).get($pick(effect, 'tween')).wait(duration); |
|
379 |
return this; |
|
380 |
} |
|
381 |
}); |
|
382 |
|
|
383 |
})(); |
|
384 |
|
|
385 |
/* |
|
386 |
--- |
|
387 |
|
|
247 | 388 |
script: Date.js |
248 | 389 |
|
249 | 390 |
description: Extends the Date native object to include methods useful in managing dates. |
... | ... | |
705 | 846 |
'%x( %X)?', // "12/31", "12.31.99", "12-31-1999", "12/31/2008 11:59 PM" |
706 | 847 |
'%d%o( %b( %Y)?)?( %X)?', // "31st", "31st December", "31 Dec 1999", "31 Dec 1999 11:59pm" |
707 | 848 |
'%b( %d%o)?( %Y)?( %X)?', // Same as above with month and day switched |
708 |
'%Y %b( %d%o( %X)?)?' // Same as above with year coming first |
|
849 |
'%Y %b( %d%o( %X)?)?', // Same as above with year coming first |
|
850 |
'%o %b %d %X %T %Y' // "Thu Oct 22 08:11:23 +0000 2009" |
|
709 | 851 |
); |
710 | 852 |
|
711 | 853 |
MooTools.lang.addEvent('langChange', function(language){ |
... | ... | |
1059 | 1201 |
/* |
1060 | 1202 |
--- |
1061 | 1203 |
|
1204 |
script: Element.Shortcuts.js |
|
1205 |
|
|
1206 |
description: Extends the Element native object to include some shortcut methods. |
|
1207 |
|
|
1208 |
license: MIT-style license |
|
1209 |
|
|
1210 |
authors: |
|
1211 |
- Aaron Newton |
|
1212 |
|
|
1213 |
requires: |
|
1214 |
- core:1.2.4/Element.Style |
|
1215 |
- /MooTools.More |
|
1216 |
|
|
1217 |
provides: [Element.Shortcuts] |
|
1218 |
|
|
1219 |
... |
|
1220 |
*/ |
|
1221 |
|
|
1222 |
Element.implement({ |
|
1223 |
|
|
1224 |
isDisplayed: function(){ |
|
1225 |
return this.getStyle('display') != 'none'; |
|
1226 |
}, |
|
1227 |
|
|
1228 |
isVisible: function(){ |
|
1229 |
var w = this.offsetWidth, |
|
1230 |
h = this.offsetHeight; |
|
1231 |
return (w == 0 && h == 0) ? false : (w > 0 && h > 0) ? true : this.isDisplayed(); |
|
1232 |
}, |
|
1233 |
|
|
1234 |
toggle: function(){ |
|
1235 |
return this[this.isDisplayed() ? 'hide' : 'show'](); |
|
1236 |
}, |
|
1237 |
|
|
1238 |
hide: function(){ |
|
1239 |
var d; |
|
1240 |
try { |
|
1241 |
// IE fails here if the element is not in the dom |
|
1242 |
if ((d = this.getStyle('display')) == 'none') d = null; |
|
1243 |
} catch(e){} |
|
1244 |
|
|
1245 |
return this.store('originalDisplay', d || 'block').setStyle('display', 'none'); |
|
1246 |
}, |
|
1247 |
|
|
1248 |
show: function(display){ |
|
1249 |
return this.setStyle('display', display || this.retrieve('originalDisplay') || 'block'); |
|
1250 |
}, |
|
1251 |
|
|
1252 |
swapClass: function(remove, add){ |
|
1253 |
return this.removeClass(remove).addClass(add); |
|
1254 |
} |
|
1255 |
|
|
1256 |
}); |
|
1257 |
|
|
1258 |
|
|
1259 |
/* |
|
1260 |
--- |
|
1261 |
|
|
1062 | 1262 |
script: Fx.Elements.js |
1063 | 1263 |
|
1064 | 1264 |
description: Effect to change any number of CSS properties of any number of Elements. |
... | ... | |
1224 | 1424 |
display: function(index, useFx){ |
1225 | 1425 |
if (!this.check(index, useFx)) return this; |
1226 | 1426 |
useFx = $pick(useFx, true); |
1227 |
if (this.options.returnHeightToAuto) {
|
|
1427 |
if (this.options.returnHeightToAuto){ |
|
1228 | 1428 |
var prev = this.elements[this.previous]; |
1229 |
if (prev) {
|
|
1230 |
for (var fx in this.effects) {
|
|
1429 |
if (prev && !this.selfHidden){
|
|
1430 |
for (var fx in this.effects){ |
|
1231 | 1431 |
prev.setStyle(fx, prev[this.effects[fx]]); |
1232 | 1432 |
} |
1233 | 1433 |
} |
... | ... | |
1238 | 1438 |
var obj = {}; |
1239 | 1439 |
this.elements.each(function(el, i){ |
1240 | 1440 |
obj[i] = {}; |
1241 |
var hide = (i != index) || |
|
1242 |
(this.options.alwaysHide && ((el.offsetHeight > 0 && this.options.height) || |
|
1243 |
el.offsetWidth > 0 && this.options.width)); |
|
1441 |
var hide; |
|
1442 |
if (i != index){ |
|
1443 |
hide = true; |
|
1444 |
} else if (this.options.alwaysHide && ((el.offsetHeight > 0 && this.options.height) || el.offsetWidth > 0 && this.options.width)){ |
|
1445 |
hide = true; |
|
1446 |
this.selfHidden = true; |
|
1447 |
} |
|
1244 | 1448 |
this.fireEvent(hide ? 'background' : 'active', [this.togglers[i], el]); |
1245 | 1449 |
for (var fx in this.effects) obj[i][fx] = hide ? 0 : el[this.effects[fx]]; |
1246 | 1450 |
}, this); |
1247 | 1451 |
this.internalChain.chain(function(){ |
1248 |
if (this.options.returnHeightToAuto) {
|
|
1452 |
if (this.options.returnHeightToAuto && !this.selfHidden){
|
|
1249 | 1453 |
var el = this.elements[index]; |
1250 |
el.setStyle('height', 'auto'); |
|
1454 |
if (el) el.setStyle('height', 'auto');
|
|
1251 | 1455 |
}; |
1252 | 1456 |
}.bind(this)); |
1253 | 1457 |
return useFx ? this.start(obj) : this.set(obj); |
... | ... | |
1299 | 1503 |
handle: false, |
1300 | 1504 |
invert: false, |
1301 | 1505 |
preventDefault: false, |
1506 |
stopPropagation: false, |
|
1302 | 1507 |
modifiers: {x: 'left', y: 'top'} |
1303 | 1508 |
}, |
1304 | 1509 |
|
... | ... | |
1338 | 1543 |
start: function(event){ |
1339 | 1544 |
if (event.rightClick) return; |
1340 | 1545 |
if (this.options.preventDefault) event.preventDefault(); |
1546 |
if (this.options.stopPropagation) event.stopPropagation(); |
|
1341 | 1547 |
this.mouse.start = event.page; |
1342 | 1548 |
this.fireEvent('beforeStart', this.element); |
1343 | 1549 |
var limit = this.options.limit; |
... | ... | |
1992 | 2198 |
/* |
1993 | 2199 |
--- |
1994 | 2200 |
|
1995 |
script: IframeShim.js |
|
1996 |
|
|
1997 |
description: Defines IframeShim, a class for obscuring select lists and flash objects in IE. |
|
1998 |
|
|
1999 |
license: MIT-style license |
|
2000 |
|
|
2001 |
authors: |
|
2002 |
- Aaron Newton |
|
2003 |
|
|
2004 |
requires: |
|
2005 |
- core:1.2.4/Element.Event |
|
2006 |
- core:1.2.4/Element.Style |
|
2007 |
- core:1.2.4/Options Events |
|
2008 |
- /Element.Position |
|
2009 |
- /Class.Occlude |
|
2010 |
|
|
2011 |
provides: [IframeShim] |
|
2012 |
|
|
2013 |
... |
|
2014 |
*/ |
|
2015 |
|
|
2016 |
var IframeShim = new Class({ |
|
2017 |
|
|
2018 |
Implements: [Options, Events, Class.Occlude], |
|
2019 |
|
|
2020 |
options: { |
|
2021 |
className: 'iframeShim', |
|
2022 |
src: 'javascript:false;document.write("");', |
|
2023 |
display: false, |
|
2024 |
zIndex: null, |
|
2025 |
margin: 0, |
|
2026 |
offset: {x: 0, y: 0}, |
|
2027 |
browsers: (Browser.Engine.trident4 || (Browser.Engine.gecko && !Browser.Engine.gecko19 && Browser.Platform.mac)) |
|
2028 |
}, |
|
2029 |
|
|
2030 |
property: 'IframeShim', |
|
2031 |
|
|
2032 |
initialize: function(element, options){ |
|
2033 |
this.element = document.id(element); |
|
2034 |
if (this.occlude()) return this.occluded; |
|
2035 |
this.setOptions(options); |
|
2036 |
this.makeShim(); |
|
2037 |
return this; |
|
2038 |
}, |
|
2039 |
|
|
2040 |
makeShim: function(){ |
|
2041 |
if(this.options.browsers){ |
|
2042 |
var zIndex = this.element.getStyle('zIndex').toInt(); |
|
2043 |
|
|
2044 |
if (!zIndex){ |
|
2045 |
zIndex = 1; |
|
2046 |
var pos = this.element.getStyle('position'); |
|
2047 |
if (pos == 'static' || !pos) this.element.setStyle('position', 'relative'); |
|
2048 |
this.element.setStyle('zIndex', zIndex); |
|
2049 |
} |
|
2050 |
zIndex = ($chk(this.options.zIndex) && zIndex > this.options.zIndex) ? this.options.zIndex : zIndex - 1; |
|
2051 |
if (zIndex < 0) zIndex = 1; |
|
2052 |
this.shim = new Element('iframe', { |
|
2053 |
src: this.options.src, |
|
2054 |
scrolling: 'no', |
|
2055 |
frameborder: 0, |
|
2056 |
styles: { |
|
2057 |
zIndex: zIndex, |
|
2058 |
position: 'absolute', |
|
2059 |
border: 'none', |
|
2060 |
filter: 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)' |
|
2061 |
}, |
|
2062 |
'class': this.options.className |
|
2063 |
}).store('IframeShim', this); |
|
2064 |
var inject = (function(){ |
|
2065 |
this.shim.inject(this.element, 'after'); |
|
2066 |
this[this.options.display ? 'show' : 'hide'](); |
|
2067 |
this.fireEvent('inject'); |
|
2068 |
}).bind(this); |
|
2069 |
if (IframeShim.ready) window.addEvent('load', inject); |
|
2070 |
else inject(); |
|
2071 |
} else { |
|
2072 |
this.position = this.hide = this.show = this.dispose = $lambda(this); |
|
2073 |
} |
|
2074 |
}, |
|
2075 |
|
|
2076 |
position: function(){ |
|
2077 |
if (!IframeShim.ready || !this.shim) return this; |
|
2078 |
var size = this.element.measure(function(){ |
|
2079 |
return this.getSize(); |
|
2080 |
}); |
|
2081 |
if (this.options.margin != undefined){ |
|
2082 |
size.x = size.x - (this.options.margin * 2); |
|
2083 |
size.y = size.y - (this.options.margin * 2); |
|
2084 |
this.options.offset.x += this.options.margin; |
|
2085 |
this.options.offset.y += this.options.margin; |
|
2086 |
} |
|
2087 |
this.shim.set({width: size.x, height: size.y}).position({ |
|
2088 |
relativeTo: this.element, |
|
2089 |
offset: this.options.offset |
|
2090 |
}); |
|
2091 |
return this; |
|
2092 |
}, |
|
2093 |
|
|
2094 |
hide: function(){ |
|
2095 |
if (this.shim) this.shim.setStyle('display', 'none'); |
|
2096 |
return this; |
|
2097 |
}, |
|
2098 |
|
|
2099 |
show: function(){ |
|
2100 |
if (this.shim) this.shim.setStyle('display', 'block'); |
|
2101 |
return this.position(); |
|
2102 |
}, |
|
2103 |
|
|
2104 |
dispose: function(){ |
|
2105 |
if (this.shim) this.shim.dispose(); |
|
2106 |
return this; |
|
2107 |
}, |
|
2108 |
|
|
2109 |
destroy: function(){ |
|
2110 |
if (this.shim) this.shim.destroy(); |
|
2111 |
return this; |
|
2112 |
} |
|
2113 |
|
|
2114 |
}); |
|
2115 |
|
|
2116 |
window.addEvent('load', function(){ |
|
2117 |
IframeShim.ready = true; |
|
2118 |
}); |
|
2119 |
|
|
2120 |
/* |
|
2121 |
--- |
|
2122 |
|
|
2123 |
script: Mask.js |
|
2124 |
|
|
2125 |
description: Creates a mask element to cover another. |
|
2126 |
|
|
2127 |
license: MIT-style license |
|
2128 |
|
|
2129 |
authors: |
|
2130 |
- Aaron Newton |
|
2131 |
|
|
2132 |
requires: |
|
2133 |
- core:1.2.4/Options |
|
2134 |
- core:1.2.4/Events |
|
2135 |
- core:1.2.4/Element.Event |
|
2136 |
- /Class.Binds |
|
2137 |
- /Element.Position |
|
2138 |
- /IframeShim |
|
2139 |
|
|
2140 |
provides: [Mask] |
|
2141 |
|
|
2142 |
... |
|
2143 |
*/ |
|
2144 |
|
|
2145 |
var Mask = new Class({ |
|
2146 |
|
|
2147 |
Implements: [Options, Events], |
|
2148 |
|
|
2149 |
Binds: ['resize'], |
|
2150 |
|
|
2151 |
options: { |
|
2152 |
// onShow: $empty, |
|
2153 |
// onHide: $empty, |
|
2154 |
// onDestroy: $empty, |
|
2155 |
// onClick: $empty, |
|
2156 |
//inject: { |
|
2157 |
// where: 'after', |
|
2158 |
// target: null, |
|
2159 |
//}, |
|
2160 |
// hideOnClick: false, |
|
2161 |
// id: null, |
|
2162 |
// destroyOnHide: false, |
|
2163 |
style: {}, |
|
2164 |
'class': 'mask', |
|
2165 |
maskMargins: false, |
|
2166 |
useIframeShim: true |
|
2167 |
}, |
|
2168 |
|
|
2169 |
initialize: function(target, options){ |
|
2170 |
this.target = document.id(target) || document.body; |
|
2171 |
this.target.store('mask', this); |
|
2172 |
this.setOptions(options); |
|
2173 |
this.render(); |
|
2174 |
this.inject(); |
|
2175 |
}, |
|
2176 |
|
|
2177 |
render: function() { |
|
2178 |
this.element = new Element('div', { |
|
2179 |
'class': this.options['class'], |
|
2180 |
id: this.options.id || 'mask-' + $time(), |
|
2181 |
styles: $merge(this.options.style, { |
|
2182 |
display: 'none' |
|
2183 |
}), |
|
2184 |
events: { |
|
2185 |
click: function(){ |
|
2186 |
this.fireEvent('click'); |
|
2187 |
if (this.options.hideOnClick) this.hide(); |
|
2188 |
}.bind(this) |
|
2189 |
} |
|
2190 |
}); |
|
2191 |
this.hidden = true; |
|
2192 |
}, |
|
2193 |
|
|
2194 |
toElement: function(){ |
|
2195 |
return this.element; |
|
2196 |
}, |
|
2197 |
|
|
2198 |
inject: function(target, where){ |
|
2199 |
where = where || this.options.inject ? this.options.inject.where : '' || this.target == document.body ? 'inside' : 'after'; |
|
2200 |
target = target || this.options.inject ? this.options.inject.target : '' || this.target; |
|
2201 |
this.element.inject(target, where); |
|
2202 |
if (this.options.useIframeShim) { |
|
2203 |
this.shim = new IframeShim(this.element); |
|
2204 |
this.addEvents({ |
|
2205 |
show: this.shim.show.bind(this.shim), |
|
2206 |
hide: this.shim.hide.bind(this.shim), |
|
2207 |
destroy: this.shim.destroy.bind(this.shim) |
|
2208 |
}); |
|
2209 |
} |
|
2210 |
}, |
|
2211 |
|
|
2212 |
position: function(){ |
|
2213 |
this.resize(this.options.width, this.options.height); |
|
2214 |
this.element.position({ |
|
2215 |
relativeTo: this.target, |
|
2216 |
position: 'topLeft', |
|
2217 |
ignoreMargins: !this.options.maskMargins, |
|
2218 |
ignoreScroll: this.target == document.body |
|
2219 |
}); |
|
2220 |
return this; |
|
2221 |
}, |
|
2222 |
|
|
2223 |
resize: function(x, y){ |
|
2224 |
var opt = { |
|
2225 |
styles: ['padding', 'border'] |
|
2226 |
}; |
|
2227 |
if (this.options.maskMargins) opt.styles.push('margin'); |
|
2228 |
var dim = this.target.getComputedSize(opt); |
|
2229 |
if (this.target == document.body) { |
|
2230 |
var win = window.getSize(); |
|
2231 |
if (dim.totalHeight < win.y) dim.totalHeight = win.y; |
|
2232 |
if (dim.totalWidth < win.x) dim.totalWidth = win.x; |
|
2233 |
} |
|
2234 |
this.element.setStyles({ |
|
2235 |
width: $pick(x, dim.totalWidth, dim.x), |
|
2236 |
height: $pick(y, dim.totalHeight, dim.y) |
|
2237 |
}); |
|
2238 |
return this; |
|
2239 |
}, |
|
2240 |
|
|
2241 |
show: function(){ |
|
2242 |
if (!this.hidden) return this; |
|
2243 |
this.target.addEvent('resize', this.resize); |
|
2244 |
if (this.target != document.body) document.id(document.body).addEvent('resize', this.resize); |
|
2245 |
this.position(); |
|
2246 |
this.showMask.apply(this, arguments); |
|
2247 |
return this; |
|
2248 |
}, |
|
2249 |
|
|
2250 |
showMask: function(){ |
|
2251 |
this.element.setStyle('display', 'block'); |
|
2252 |
this.hidden = false; |
|
2253 |
this.fireEvent('show'); |
|
2254 |
}, |
|
2255 |
|
|
2256 |
hide: function(){ |
|
2257 |
if (this.hidden) return this; |
|
2258 |
this.target.removeEvent('resize', this.resize); |
|
2259 |
this.hideMask.apply(this, arguments); |
|
2260 |
if (this.options.destroyOnHide) return this.destroy(); |
|
2261 |
return this; |
|
2262 |
}, |
|
2263 |
|
|
2264 |
hideMask: function(){ |
|
2265 |
this.element.setStyle('display', 'none'); |
|
2266 |
this.hidden = true; |
|
2267 |
this.fireEvent('hide'); |
|
2268 |
}, |
|
2269 |
|
|
2270 |
toggle: function(){ |
|
2271 |
this[this.hidden ? 'show' : 'hide'](); |
|
2272 |
}, |
|
2273 |
|
|
2274 |
destroy: function(){ |
|
2275 |
this.hide(); |
|
2276 |
this.element.destroy(); |
|
2277 |
this.fireEvent('destroy'); |
|
2278 |
this.target.eliminate('mask'); |
|
2279 |
} |
|
2280 |
|
|
2281 |
}); |
|
2282 |
|
|
2283 |
Element.Properties.mask = { |
|
2284 |
|
|
2285 |
set: function(options){ |
|
2286 |
var mask = this.retrieve('mask'); |
|
2287 |
return this.eliminate('mask').store('mask:options', options); |
|
2288 |
}, |
|
2289 |
|
|
2290 |
get: function(options){ |
|
2291 |
if (options || !this.retrieve('mask')){ |
|
2292 |
if (this.retrieve('mask')) this.retrieve('mask').destroy(); |
|
2293 |
if (options || !this.retrieve('mask:options')) this.set('mask', options); |
|
2294 |
this.store('mask', new Mask(this, this.retrieve('mask:options'))); |
|
2295 |
} |
|
2296 |
return this.retrieve('mask'); |
|
2297 |
} |
|
2298 |
|
|
2299 |
}; |
|
2300 |
|
|
2301 |
Element.implement({ |
|
2302 |
|
|
2303 |
mask: function(options){ |
|
2304 |
this.get('mask', options).show(); |
|
2305 |
return this; |
|
2306 |
}, |
|
2307 |
|
|
2308 |
unmask: function(){ |
|
2309 |
this.get('mask').hide(); |
|
2310 |
return this; |
|
2311 |
} |
|
2312 |
|
|
2313 |
}); |
|
2314 |
|
|
2315 |
/* |
|
2316 |
--- |
|
2317 |
|
|
2318 | 2201 |
script: Tips.js |
2319 | 2202 |
|
2320 | 2203 |
description: Class for creating nice tips that follow the mouse cursor when hovering an element. |
... | ... | |
2385 | 2268 |
return this.tip = new Element('div', { |
2386 | 2269 |
'class': this.options.className, |
2387 | 2270 |
styles: { |
2388 |
display: 'none', |
|
2389 | 2271 |
position: 'absolute', |
2390 | 2272 |
top: 0, |
2391 | 2273 |
left: 0 |
... | ... | |
2456 | 2338 |
this.fireForParent(event, element); |
2457 | 2339 |
}, |
2458 | 2340 |
|
2459 |
fireForParent: function(event, element) { |
|
2460 |
parentNode = element.getParent(); |
|
2461 |
if (parentNode == document.body) return; |
|
2462 |
if (parentNode.retrieve('tip:enter')) parentNode.fireEvent('mouseenter', event); |
|
2463 |
else return this.fireForParent(parentNode, event); |
|
2341 |
fireForParent: function(event, element){ |
|
2342 |
if (!element) return; |
|
2343 |
parentNode = element.getParent(); |
|
2344 |
if (parentNode == document.body) return; |
|
2345 |
if (parentNode.retrieve('tip:enter')) parentNode.fireEvent('mouseenter', event); |
|
2346 |
else this.fireForParent(parentNode, event); |
|
2464 | 2347 |
}, |
2465 | 2348 |
|
2466 | 2349 |
elementMove: function(event, element){ |
... | ... | |
2487 | 2370 |
}, |
2488 | 2371 |
|
2489 | 2372 |
show: function(element){ |
2490 |
this.fireEvent('show', [element]); |
|
2373 |
this.fireEvent('show', [this.tip, element]);
|
|
2491 | 2374 |
}, |
2492 | 2375 |
|
2493 | 2376 |
hide: function(element){ |
2494 |
this.fireEvent('hide', [element]); |
|
2377 |
this.fireEvent('hide', [this.tip, element]);
|
|
2495 | 2378 |
} |
2496 | 2379 |
|
2497 | 2380 |
}); |
... | ... | |
2501 | 2384 |
/* |
2502 | 2385 |
--- |
2503 | 2386 |
|
2504 |
script: Spinner.js |
|
2505 |
|
|
2506 |
description: Adds a semi-transparent overlay over a dom element with a spinnin ajax icon. |
|
2507 |
|
|
2508 |
license: MIT-style license |
|
2509 |
|
|
2510 |
authors: |
|
2511 |
- Aaron Newton |
|
2512 |
|
|
2513 |
requires: |
|
2514 |
- core:1.2.4/Fx.Tween |
|
2515 |
- /Class.refactor |
|
2516 |
- /Mask |
|
2517 |
|
|
2518 |
provides: [Spinner] |
|
2519 |
|
|
2520 |
... |
|
2521 |
*/ |
|
2522 |
|
|
2523 |
var Spinner = new Class({ |
|
2524 |
|
|
2525 |
Extends: Mask, |
|
2526 |
|
|
2527 |
options: { |
|
2528 |
/*message: false,*/ |
|
2529 |
'class':'spinner', |
|
2530 |
containerPosition: {}, |
|
2531 |
content: { |
|
2532 |
'class':'spinner-content' |
|
2533 |
}, |
|
2534 |
messageContainer: { |
|
2535 |
'class':'spinner-msg' |
|
2536 |
}, |
|
2537 |
img: { |
|
2538 |
'class':'spinner-img' |
|
2539 |
}, |
|
2540 |
fxOptions: { |
|
2541 |
link: 'chain' |
|
2542 |
} |
|
2543 |
}, |
|
2544 |
|
|
2545 |
initialize: function(){ |
|
2546 |
this.parent.apply(this, arguments); |
|
2547 |
this.target.store('spinner', this); |
|
2548 |
|
|
2549 |
//add this to events for when noFx is true; parent methods handle hide/show |
|
2550 |
var deactivate = function(){ this.active = false; }.bind(this); |
|
2551 |
this.addEvents({ |
|
2552 |
hide: deactivate, |
|
2553 |
show: deactivate |
|
2554 |
}); |
|
2555 |
}, |
|
2556 |
|
|
2557 |
render: function(){ |
|
2558 |
this.parent(); |
|
2559 |
this.element.set('id', this.options.id || 'spinner-'+$time()); |
|
2560 |
this.content = document.id(this.options.content) || new Element('div', this.options.content); |
|
2561 |
this.content.inject(this.element); |
|
2562 |
if (this.options.message) { |
|
2563 |
this.msg = document.id(this.options.message) || new Element('p', this.options.messageContainer).appendText(this.options.message); |
|
2564 |
this.msg.inject(this.content); |
|
2565 |
} |
|
2566 |
if (this.options.img) { |
|
2567 |
this.img = document.id(this.options.img) || new Element('div', this.options.img); |
|
2568 |
this.img.inject(this.content); |
|
2569 |
} |
|
2570 |
this.element.set('tween', this.options.fxOptions); |
|
2571 |
}, |
|
2572 |
|
|
2573 |
show: function(noFx){ |
|
2574 |
if (this.active) return this.chain(this.show.bind(this)); |
|
2575 |
if (!this.hidden) { |
|
2576 |
this.callChain.delay(20, this); |
|
2577 |
return this; |
|
2578 |
} |
|
2579 |
this.active = true; |
|
2580 |
return this.parent(noFx); |
|
2581 |
}, |
|
2582 |
|
|
2583 |
showMask: function(noFx){ |
|
2584 |
var pos = function(){ |
|
2585 |
this.content.position($merge({ |
|
2586 |
relativeTo: this.element |
|
2587 |
}, this.options.containerPosition)); |
|
2588 |
}.bind(this); |
|
2589 |
if (noFx) { |
|
2590 |
this.parent(); |
|
2591 |
pos(); |
|
2592 |
} else { |
|
2593 |
this.element.setStyles({ |
|
2594 |
display: 'block', |
|
2595 |
opacity: 0 |
|
2596 |
}).tween('opacity', this.options.style.opacity || 0.9); |
|
2597 |
pos(); |
|
2598 |
this.hidden = false; |
|
2599 |
this.fireEvent('show'); |
|
2600 |
this.callChain(); |
|
2601 |
} |
|
2602 |
}, |
|
2603 |
|
|
2604 |
hide: function(noFx){ |
|
2605 |
if (this.active) return this.chain(this.hide.bind(this)); |
|
2606 |
if (this.hidden) { |
|
2607 |
this.callChain.delay(20, this); |
|
2608 |
return this; |
|
2609 |
} |
|
2610 |
this.active = true; |
|
2611 |
return this.parent(); |
|
2612 |
}, |
|
2613 |
|
|
2614 |
hideMask: function(noFx){ |
|
2615 |
if (noFx) return this.parent(); |
|
2616 |
this.element.tween('opacity', 0).get('tween').chain(function(){ |
|
2617 |
this.element.setStyle('display', 'none'); |
|
2618 |
this.hidden = true; |
|
2619 |
this.fireEvent('hide'); |
|
2620 |
this.callChain(); |
|
2621 |
}.bind(this)); |
|
2622 |
}, |
|
2623 |
|
|
2624 |
destroy: function(){ |
|
2625 |
this.content.destroy(); |
|
2626 |
this.parent(); |
|
2627 |
this.target.eliminate('spinner'); |
|
2628 |
} |
|
2629 |
|
|
2630 |
}); |
|
2631 |
|
|
2632 |
Spinner.implement(new Chain); |
|
2633 |
|
|
2634 |
if (window.Request) { |
|
2635 |
Request = Class.refactor(Request, { |
|
2636 |
options: { |
|
2637 |
useSpinner: false, |
|
2638 |
spinnerOptions: {}, |
|
2639 |
spinnerTarget: false |
|
2640 |
}, |
|
2641 |
initialize: function(options){ |
|
2642 |
this._send = this.send; |
|
2643 |
this.send = function(options){ |
|
2644 |
if (this.spinner) this.spinner.chain(this._send.bind(this, options)).show(); |
|
2645 |
else this._send(options); |
|
2646 |
return this; |
|
2647 |
}; |
|
2648 |
this.previous(options); |
|
2649 |
var update = document.id(this.options.spinnerTarget) || document.id(this.options.update); |
|
2650 |
if (this.options.useSpinner && update) { |
|
2651 |
this.spinner = update.get('spinner', this.options.spinnerOptions); |
|
2652 |
['onComplete', 'onException', 'onCancel'].each(function(event){ |
|
2653 |
this.addEvent(event, this.spinner.hide.bind(this.spinner)); |
|
2654 |
}, this); |
|
2655 |
} |
|
2656 |
} |
|
2657 |
}); |
|
2658 |
} |
|
2659 |
|
|
2660 |
Element.Properties.spinner = { |
|
2661 |
|
|
2662 |
set: function(options){ |
|
2663 |
var spinner = this.retrieve('spinner'); |
|
2664 |
return this.eliminate('spinner').store('spinner:options', options); |
|
2665 |
}, |
|
2666 |
|
|
2667 |
get: function(options){ |
|
2668 |
if (options || !this.retrieve('spinner')){ |
|
2669 |
if (this.retrieve('spinner')) this.retrieve('spinner').destroy(); |
|
2670 |
if (options || !this.retrieve('spinner:options')) this.set('spinner', options); |
|
2671 |
new Spinner(this, this.retrieve('spinner:options')); |
|
2672 |
} |
|
2673 |
return this.retrieve('spinner'); |
|
2674 |
} |
|
2675 |
|
|
2676 |
}; |
|
2677 |
|
|
2678 |
Element.implement({ |
|
2679 |
|
|
2680 |
spin: function(options){ |
|
2681 |
this.get('spinner', options).show(); |
|
2682 |
return this; |
|
2683 |
}, |
|
2684 |
|
|
2685 |
unspin: function(){ |
|
2686 |
var opt = Array.link(arguments, {options: Object.type, callback: Function.type}); |
|
2687 |
this.get('spinner', opt.options).hide(opt.callback); |
|
2688 |
return this; |
|
2689 |
} |
|
2690 |
|
|
2691 |
}); |
|
2692 |
|
|
2693 |
/* |
|
2694 |
--- |
|
2695 |
|
|
2696 | 2387 |
script: Date.English.US.js |
2697 | 2388 |
|
2698 | 2389 |
description: Date messages for US English. |
Also available in: Unified diff