');
37 | var e = $('.farbtastic', container);
38 | fb.wheel = $('.wheel', container).get(0);
39 | // Dimensions
40 | fb.radius = 84;
41 | fb.square = 100;
42 | fb.width = 194;
43 |
44 | // Fix background PNGs in IE6
45 | if (navigator.appVersion.match(/MSIE [0-6]\./)) {
46 | $('*', e).each(function () {
47 | if (this.currentStyle.backgroundImage != 'none') {
48 | var image = this.currentStyle.backgroundImage;
49 | image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
50 | $(this).css({
51 | 'backgroundImage': 'none',
52 | 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
53 | });
54 | }
55 | });
56 | }
57 |
58 | /**
59 | * Link to the given element(s) or callback.
60 | */
61 | fb.linkTo = function (callback) {
62 | // Unbind previous nodes
63 | if (typeof fb.callback == 'object') {
64 | $(fb.callback).unbind('keyup', fb.updateValue);
65 | }
66 |
67 | // Reset color
68 | fb.color = null;
69 |
70 | // Bind callback or elements
71 | if (typeof callback == 'function') {
72 | fb.callback = callback;
73 | }
74 | else if (typeof callback == 'object' || typeof callback == 'string') {
75 | fb.callback = $(callback);
76 | fb.callback.bind('keyup', fb.updateValue);
77 | if (fb.callback.get(0).value) {
78 | fb.setColor(fb.callback.get(0).value);
79 | }
80 | }
81 | return this;
82 | }
83 | fb.updateValue = function (event) {
84 | if (this.value && this.value != fb.color) {
85 | fb.setColor(this.value);
86 | }
87 | }
88 |
89 | /**
90 | * Change color with HTML syntax #123456
91 | */
92 | fb.setColor = function (color) {
93 | var unpack = fb.unpack(color);
94 | if (fb.color != color && unpack) {
95 | fb.color = color;
96 | fb.rgb = unpack;
97 | fb.hsl = fb.RGBToHSL(fb.rgb);
98 | fb.updateDisplay();
99 | }
100 | return this;
101 | }
102 |
103 | /**
104 | * Change color with HSL triplet [0..1, 0..1, 0..1]
105 | */
106 | fb.setHSL = function (hsl) {
107 | fb.hsl = hsl;
108 | fb.rgb = fb.HSLToRGB(hsl);
109 | fb.color = fb.pack(fb.rgb);
110 | fb.updateDisplay();
111 | return this;
112 | }
113 |
114 | /////////////////////////////////////////////////////
115 |
116 | /**
117 | * Retrieve the coordinates of the given event relative to the center
118 | * of the widget.
119 | */
120 | fb.widgetCoords = function (event) {
121 | var x, y;
122 | var el = event.target || event.srcElement;
123 | var reference = fb.wheel;
124 |
125 | if (typeof event.offsetX != 'undefined') {
126 | // Use offset coordinates and find common offsetParent
127 | var pos = { x: event.offsetX, y: event.offsetY };
128 |
129 | // Send the coordinates upwards through the offsetParent chain.
130 | var e = el;
131 | while (e) {
132 | e.mouseX = pos.x;
133 | e.mouseY = pos.y;
134 | pos.x += e.offsetLeft;
135 | pos.y += e.offsetTop;
136 | e = e.offsetParent;
137 | }
138 |
139 | // Look for the coordinates starting from the wheel widget.
140 | var e = reference;
141 | var offset = { x: 0, y: 0 }
142 | while (e) {
143 | if (typeof e.mouseX != 'undefined') {
144 | x = e.mouseX - offset.x;
145 | y = e.mouseY - offset.y;
146 | break;
147 | }
148 | offset.x += e.offsetLeft;
149 | offset.y += e.offsetTop;
150 | e = e.offsetParent;
151 | }
152 |
153 | // Reset stored coordinates
154 | e = el;
155 | while (e) {
156 | e.mouseX = undefined;
157 | e.mouseY = undefined;
158 | e = e.offsetParent;
159 | }
160 | }
161 | else {
162 | // Use absolute coordinates
163 | var pos = fb.absolutePosition(reference);
164 | x = (event.pageX || 0*(event.clientX + $('html').get(0).scrollLeft)) - pos.x;
165 | y = (event.pageY || 0*(event.clientY + $('html').get(0).scrollTop)) - pos.y;
166 | }
167 | // Subtract distance to middle
168 | return { x: x - fb.width / 2, y: y - fb.width / 2 };
169 | }
170 |
171 | /**
172 | * Mousedown handler
173 | */
174 | fb.mousedown = function (event) {
175 | // Capture mouse
176 | if (!document.dragging) {
177 | $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
178 | document.dragging = true;
179 | }
180 |
181 | // Check which area is being dragged
182 | var pos = fb.widgetCoords(event);
183 | fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
184 |
185 | // Process
186 | fb.mousemove(event);
187 | return false;
188 | }
189 |
190 | /**
191 | * Mousemove handler
192 | */
193 | fb.mousemove = function (event) {
194 | // Get coordinates relative to color picker center
195 | var pos = fb.widgetCoords(event);
196 |
197 | // Set new HSL parameters
198 | if (fb.circleDrag) {
199 | var hue = Math.atan2(pos.x, -pos.y) / 6.28;
200 | if (hue < 0) hue += 1;
201 | fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
202 | }
203 | else {
204 | var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
205 | var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
206 | fb.setHSL([fb.hsl[0], sat, lum]);
207 | }
208 | return false;
209 | }
210 |
211 | /**
212 | * Mouseup handler
213 | */
214 | fb.mouseup = function () {
215 | // Uncapture mouse
216 | $(document).unbind('mousemove', fb.mousemove);
217 | $(document).unbind('mouseup', fb.mouseup);
218 | document.dragging = false;
219 | }
220 |
221 | /**
222 | * Update the markers and styles
223 | */
224 | fb.updateDisplay = function () {
225 | // Markers
226 | var angle = fb.hsl[0] * 6.28;
227 | $('.h-marker', e).css({
228 | left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
229 | top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
230 | });
231 |
232 | $('.sl-marker', e).css({
233 | left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
234 | top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
235 | });
236 |
237 | // Saturation/Luminance gradient
238 | $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
239 |
240 | // Linked elements or callback
241 | if (typeof fb.callback == 'object') {
242 | // Set background/foreground color
243 | $(fb.callback).css({
244 | backgroundColor: fb.color,
245 | color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
246 | });
247 |
248 | // Change linked value
249 | $(fb.callback).each(function() {
250 | if (this.value && this.value != fb.color) {
251 | this.value = fb.color;
252 | }
253 | });
254 | }
255 | else if (typeof fb.callback == 'function') {
256 | fb.callback.call(fb, fb.color);
257 | }
258 | }
259 |
260 | /**
261 | * Get absolute position of element
262 | */
263 | fb.absolutePosition = function (el) {
264 | var r = { x: el.offsetLeft, y: el.offsetTop };
265 | // Resolve relative to offsetParent
266 | if (el.offsetParent) {
267 | var tmp = fb.absolutePosition(el.offsetParent);
268 | r.x += tmp.x;
269 | r.y += tmp.y;
270 | }
271 | return r;
272 | };
273 |
274 | /* Various color utility functions */
275 | fb.pack = function (rgb) {
276 | var r = Math.round(rgb[0] * 255);
277 | var g = Math.round(rgb[1] * 255);
278 | var b = Math.round(rgb[2] * 255);
279 | return '#' + (r < 16 ? '0' : '') + r.toString(16) +
280 | (g < 16 ? '0' : '') + g.toString(16) +
281 | (b < 16 ? '0' : '') + b.toString(16);
282 | }
283 |
284 | fb.unpack = function (color) {
285 | if (color.length == 7) {
286 | return [parseInt('0x' + color.substring(1, 3)) / 255,
287 | parseInt('0x' + color.substring(3, 5)) / 255,
288 | parseInt('0x' + color.substring(5, 7)) / 255];
289 | }
290 | else if (color.length == 4) {
291 | return [parseInt('0x' + color.substring(1, 2)) / 15,
292 | parseInt('0x' + color.substring(2, 3)) / 15,
293 | parseInt('0x' + color.substring(3, 4)) / 15];
294 | }
295 | }
296 |
297 | fb.HSLToRGB = function (hsl) {
298 | var m1, m2, r, g, b;
299 | var h = hsl[0], s = hsl[1], l = hsl[2];
300 | m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
301 | m1 = l * 2 - m2;
302 | return [this.hueToRGB(m1, m2, h+0.33333),
303 | this.hueToRGB(m1, m2, h),
304 | this.hueToRGB(m1, m2, h-0.33333)];
305 | }
306 |
307 | fb.hueToRGB = function (m1, m2, h) {
308 | h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
309 | if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
310 | if (h * 2 < 1) return m2;
311 | if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
312 | return m1;
313 | }
314 |
315 | fb.RGBToHSL = function (rgb) {
316 | var min, max, delta, h, s, l;
317 | var r = rgb[0], g = rgb[1], b = rgb[2];
318 | min = Math.min(r, Math.min(g, b));
319 | max = Math.max(r, Math.max(g, b));
320 | delta = max - min;
321 | l = (min + max) / 2;
322 | s = 0;
323 | if (l > 0 && l < 1) {
324 | s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
325 | }
326 | h = 0;
327 | if (delta > 0) {
328 | if (max == r && max != g) h += (g - b) / delta;
329 | if (max == g && max != b) h += (2 + (b - r) / delta);
330 | if (max == b && max != r) h += (4 + (r - g) / delta);
331 | h /= 6;
332 | }
333 | return [h, s, l];
334 | }
335 |
336 | // Install mousedown handler (the others are set on the document on-demand)
337 | $('*', e).mousedown(fb.mousedown);
338 |
339 | // Init color
340 | fb.setColor('#000000');
341 |
342 | // Set linked elements/callback
343 | if (callback) {
344 | fb.linkTo(callback);
345 | }
346 | }
347 | })(jQuery);
--------------------------------------------------------------------------------
/js/jquery.blockUI.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * jQuery blockUI plugin
3 | * Version 2.38 (29-MAR-2011)
4 | * @requires jQuery v1.2.3 or later
5 | *
6 | * Examples at: http://malsup.com/jquery/block/
7 | * Copyright (c) 2007-2010 M. Alsup
8 | * Dual licensed under the MIT and GPL licenses:
9 | * http://www.opensource.org/licenses/mit-license.php
10 | * http://www.gnu.org/licenses/gpl.html
11 | *
12 | * Thanks to Amir-Hossein Sobhi for some excellent contributions!
13 | */
14 |
15 | ;(function($) {
16 |
17 | if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
18 | alert('blockUI requires jQuery v1.2.3 or later! You are using v' + $.fn.jquery);
19 | return;
20 | }
21 |
22 | $.fn._fadeIn = $.fn.fadeIn;
23 |
24 | var noOp = function() {};
25 |
26 | // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
27 | // retarded userAgent strings on Vista)
28 | var mode = document.documentMode || 0;
29 | var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
30 | var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
31 |
32 | // global $ methods for blocking/unblocking the entire page
33 | $.blockUI = function(opts) { install(window, opts); };
34 | $.unblockUI = function(opts) { remove(window, opts); };
35 |
36 | // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
37 | $.growlUI = function(title, message, timeout, onClose) {
38 | var $m = $('');
39 | if (title) $m.append('
'+title+'
');
40 | if (message) $m.append('
'+message+'
');
41 | if (timeout == undefined) timeout = 3000;
42 | $.blockUI({
43 | message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
44 | timeout: timeout, showOverlay: false,
45 | onUnblock: onClose,
46 | css: $.blockUI.defaults.growlCSS
47 | });
48 | };
49 |
50 | // plugin method for blocking element content
51 | $.fn.block = function(opts) {
52 | return this.unblock({ fadeOut: 0 }).each(function() {
53 | if ($.css(this,'position') == 'static')
54 | this.style.position = 'relative';
55 | if ($.browser.msie)
56 | this.style.zoom = 1; // force 'hasLayout'
57 | install(this, opts);
58 | });
59 | };
60 |
61 | // plugin method for unblocking element content
62 | $.fn.unblock = function(opts) {
63 | return this.each(function() {
64 | remove(this, opts);
65 | });
66 | };
67 |
68 | $.blockUI.version = 2.38; // 2nd generation blocking at no extra cost!
69 |
70 | // override these in your code to change the default behavior and style
71 | $.blockUI.defaults = {
72 | // message displayed when blocking (use null for no message)
73 | message: '
Please wait...
',
74 |
75 | title: null, // title string; only used when theme == true
76 | draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
77 |
78 | theme: false, // set to true to use with jQuery UI themes
79 |
80 | // styles for the message when blocking; if you wish to disable
81 | // these and use an external stylesheet then do this in your code:
82 | // $.blockUI.defaults.css = {};
83 | css: {
84 | padding: 0,
85 | margin: 0,
86 | width: '30%',
87 | top: '40%',
88 | left: '35%',
89 | textAlign: 'center',
90 | color: '#000',
91 | border: '3px solid #aaa',
92 | backgroundColor:'#fff',
93 | cursor: 'wait'
94 | },
95 |
96 | // minimal style set used when themes are used
97 | themedCSS: {
98 | width: '30%',
99 | top: '40%',
100 | left: '35%'
101 | },
102 |
103 | // styles for the overlay
104 | overlayCSS: {
105 | backgroundColor: '#000',
106 | opacity: 0.6,
107 | cursor: 'wait'
108 | },
109 |
110 | // styles applied when using $.growlUI
111 | growlCSS: {
112 | width: '350px',
113 | top: '10px',
114 | left: '',
115 | right: '10px',
116 | border: 'none',
117 | padding: '5px',
118 | opacity: 0.6,
119 | cursor: 'default',
120 | color: '#fff',
121 | backgroundColor: '#000',
122 | '-webkit-border-radius': '10px',
123 | '-moz-border-radius': '10px',
124 | 'border-radius': '10px'
125 | },
126 |
127 | // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
128 | // (hat tip to Jorge H. N. de Vasconcelos)
129 | iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
130 |
131 | // force usage of iframe in non-IE browsers (handy for blocking applets)
132 | forceIframe: false,
133 |
134 | // z-index for the blocking overlay
135 | baseZ: 1000,
136 |
137 | // set these to true to have the message automatically centered
138 | centerX: true, // <-- only effects element blocking (page block controlled via css above)
139 | centerY: true,
140 |
141 | // allow body element to be stetched in ie6; this makes blocking look better
142 | // on "short" pages. disable if you wish to prevent changes to the body height
143 | allowBodyStretch: true,
144 |
145 | // enable if you want key and mouse events to be disabled for content that is blocked
146 | bindEvents: true,
147 |
148 | // be default blockUI will supress tab navigation from leaving blocking content
149 | // (if bindEvents is true)
150 | constrainTabKey: true,
151 |
152 | // fadeIn time in millis; set to 0 to disable fadeIn on block
153 | fadeIn: 200,
154 |
155 | // fadeOut time in millis; set to 0 to disable fadeOut on unblock
156 | fadeOut: 400,
157 |
158 | // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
159 | timeout: 0,
160 |
161 | // disable if you don't want to show the overlay
162 | showOverlay: true,
163 |
164 | // if true, focus will be placed in the first available input field when
165 | // page blocking
166 | focusInput: true,
167 |
168 | // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
169 | applyPlatformOpacityRules: true,
170 |
171 | // callback method invoked when fadeIn has completed and blocking message is visible
172 | onBlock: null,
173 |
174 | // callback method invoked when unblocking has completed; the callback is
175 | // passed the element that has been unblocked (which is the window object for page
176 | // blocks) and the options that were passed to the unblock call:
177 | // onUnblock(element, options)
178 | onUnblock: null,
179 |
180 | // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
181 | quirksmodeOffsetHack: 4,
182 |
183 | // class name of the message block
184 | blockMsgClass: 'blockMsg'
185 | };
186 |
187 | // private data and functions follow...
188 |
189 | var pageBlock = null;
190 | var pageBlockEls = [];
191 |
192 | function install(el, opts) {
193 | var full = (el == window);
194 | var msg = opts && opts.message !== undefined ? opts.message : undefined;
195 | opts = $.extend({}, $.blockUI.defaults, opts || {});
196 | opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
197 | var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
198 | var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
199 | msg = msg === undefined ? opts.message : msg;
200 |
201 | // remove the current block (if there is one)
202 | if (full && pageBlock)
203 | remove(window, {fadeOut:0});
204 |
205 | // if an existing element is being used as the blocking content then we capture
206 | // its current place in the DOM (and current display style) so we can restore
207 | // it when we unblock
208 | if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
209 | var node = msg.jquery ? msg[0] : msg;
210 | var data = {};
211 | $(el).data('blockUI.history', data);
212 | data.el = node;
213 | data.parent = node.parentNode;
214 | data.display = node.style.display;
215 | data.position = node.style.position;
216 | if (data.parent)
217 | data.parent.removeChild(node);
218 | }
219 |
220 | var z = opts.baseZ;
221 |
222 | // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
223 | // layer1 is the iframe layer which is used to supress bleed through of underlying content
224 | // layer2 is the overlay layer which has opacity and a wait cursor (by default)
225 | // layer3 is the message content that is displayed while blocking
226 |
227 | var lyr1 = ($.browser.msie || opts.forceIframe)
228 | ? $('')
229 | : $('');
230 |
231 | var lyr2 = opts.theme
232 | ? $('')
233 | : $('');
234 |
235 | var lyr3, s;
236 | if (opts.theme && full) {
237 | s = '
' +
238 | '
'+(opts.title || ' ')+'
' +
239 | '' +
240 | '
';
241 | }
242 | else if (opts.theme) {
243 | s = '
' +
244 | '
'+(opts.title || ' ')+'
' +
245 | '' +
246 | '
';
247 | }
248 | else if (full) {
249 | s = '';
250 | }
251 | else {
252 | s = '';
253 | }
254 | lyr3 = $(s);
255 |
256 | // if we have a message, style it
257 | if (msg) {
258 | if (opts.theme) {
259 | lyr3.css(themedCSS);
260 | lyr3.addClass('ui-widget-content');
261 | }
262 | else
263 | lyr3.css(css);
264 | }
265 |
266 | // style the overlay
267 | if (!opts.theme && (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform))))
268 | lyr2.css(opts.overlayCSS);
269 | lyr2.css('position', full ? 'fixed' : 'absolute');
270 |
271 | // make iframe layer transparent in IE
272 | if ($.browser.msie || opts.forceIframe)
273 | lyr1.css('opacity',0.0);
274 |
275 | //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
276 | var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
277 | $.each(layers, function() {
278 | this.appendTo($par);
279 | });
280 |
281 | if (opts.theme && opts.draggable && $.fn.draggable) {
282 | lyr3.draggable({
283 | handle: '.ui-dialog-titlebar',
284 | cancel: 'li'
285 | });
286 | }
287 |
288 | // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
289 | var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
290 | if (ie6 || expr) {
291 | // give body 100% height
292 | if (full && opts.allowBodyStretch && $.boxModel)
293 | $('html,body').css('height','100%');
294 |
295 | // fix ie6 issue when blocked element has a border width
296 | if ((ie6 || !$.boxModel) && !full) {
297 | var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
298 | var fixT = t ? '(0 - '+t+')' : 0;
299 | var fixL = l ? '(0 - '+l+')' : 0;
300 | }
301 |
302 | // simulate fixed position
303 | $.each([lyr1,lyr2,lyr3], function(i,o) {
304 | var s = o[0].style;
305 | s.position = 'absolute';
306 | if (i < 2) {
307 | full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
308 | : s.setExpression('height','this.parentNode.offsetHeight + "px"');
309 | full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
310 | : s.setExpression('width','this.parentNode.offsetWidth + "px"');
311 | if (fixL) s.setExpression('left', fixL);
312 | if (fixT) s.setExpression('top', fixT);
313 | }
314 | else if (opts.centerY) {
315 | if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
316 | s.marginTop = 0;
317 | }
318 | else if (!opts.centerY && full) {
319 | var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
320 | var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
321 | s.setExpression('top',expression);
322 | }
323 | });
324 | }
325 |
326 | // show the message
327 | if (msg) {
328 | if (opts.theme)
329 | lyr3.find('.ui-widget-content').append(msg);
330 | else
331 | lyr3.append(msg);
332 | if (msg.jquery || msg.nodeType)
333 | $(msg).show();
334 | }
335 |
336 | if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
337 | lyr1.show(); // opacity is zero
338 | if (opts.fadeIn) {
339 | var cb = opts.onBlock ? opts.onBlock : noOp;
340 | var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
341 | var cb2 = msg ? cb : noOp;
342 | if (opts.showOverlay)
343 | lyr2._fadeIn(opts.fadeIn, cb1);
344 | if (msg)
345 | lyr3._fadeIn(opts.fadeIn, cb2);
346 | }
347 | else {
348 | if (opts.showOverlay)
349 | lyr2.show();
350 | if (msg)
351 | lyr3.show();
352 | if (opts.onBlock)
353 | opts.onBlock();
354 | }
355 |
356 | // bind key and mouse events
357 | bind(1, el, opts);
358 |
359 | if (full) {
360 | pageBlock = lyr3[0];
361 | pageBlockEls = $(':input:enabled:visible',pageBlock);
362 | if (opts.focusInput)
363 | setTimeout(focus, 20);
364 | }
365 | else
366 | center(lyr3[0], opts.centerX, opts.centerY);
367 |
368 | if (opts.timeout) {
369 | // auto-unblock
370 | var to = setTimeout(function() {
371 | full ? $.unblockUI(opts) : $(el).unblock(opts);
372 | }, opts.timeout);
373 | $(el).data('blockUI.timeout', to);
374 | }
375 | };
376 |
377 | // remove the block
378 | function remove(el, opts) {
379 | var full = (el == window);
380 | var $el = $(el);
381 | var data = $el.data('blockUI.history');
382 | var to = $el.data('blockUI.timeout');
383 | if (to) {
384 | clearTimeout(to);
385 | $el.removeData('blockUI.timeout');
386 | }
387 | opts = $.extend({}, $.blockUI.defaults, opts || {});
388 | bind(0, el, opts); // unbind events
389 |
390 | var els;
391 | if (full) // crazy selector to handle odd field errors in ie6/7
392 | els = $('body').children().filter('.blockUI').add('body > .blockUI');
393 | else
394 | els = $('.blockUI', el);
395 |
396 | if (full)
397 | pageBlock = pageBlockEls = null;
398 |
399 | if (opts.fadeOut) {
400 | els.fadeOut(opts.fadeOut);
401 | setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
402 | }
403 | else
404 | reset(els, data, opts, el);
405 | };
406 |
407 | // move blocking element back into the DOM where it started
408 | function reset(els,data,opts,el) {
409 | els.each(function(i,o) {
410 | // remove via DOM calls so we don't lose event handlers
411 | if (this.parentNode)
412 | this.parentNode.removeChild(this);
413 | });
414 |
415 | if (data && data.el) {
416 | data.el.style.display = data.display;
417 | data.el.style.position = data.position;
418 | if (data.parent)
419 | data.parent.appendChild(data.el);
420 | $(el).removeData('blockUI.history');
421 | }
422 |
423 | if (typeof opts.onUnblock == 'function')
424 | opts.onUnblock(el,opts);
425 | };
426 |
427 | // bind/unbind the handler
428 | function bind(b, el, opts) {
429 | var full = el == window, $el = $(el);
430 |
431 | // don't bother unbinding if there is nothing to unbind
432 | if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
433 | return;
434 | if (!full)
435 | $el.data('blockUI.isBlocked', b);
436 |
437 | // don't bind events when overlay is not in use or if bindEvents is false
438 | if (!opts.bindEvents || (b && !opts.showOverlay))
439 | return;
440 |
441 | // bind anchors and inputs for mouse and key events
442 | var events = 'mousedown mouseup keydown keypress';
443 | b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);
444 |
445 | // former impl...
446 | // var $e = $('a,:input');
447 | // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
448 | };
449 |
450 | // event handler to suppress keyboard/mouse events when blocking
451 | function handler(e) {
452 | // allow tab navigation (conditionally)
453 | if (e.keyCode && e.keyCode == 9) {
454 | if (pageBlock && e.data.constrainTabKey) {
455 | var els = pageBlockEls;
456 | var fwd = !e.shiftKey && e.target === els[els.length-1];
457 | var back = e.shiftKey && e.target === els[0];
458 | if (fwd || back) {
459 | setTimeout(function(){focus(back)},10);
460 | return false;
461 | }
462 | }
463 | }
464 | var opts = e.data;
465 | // allow events within the message content
466 | if ($(e.target).parents('div.' + opts.blockMsgClass).length > 0)
467 | return true;
468 |
469 | // allow events for content that is not being blocked
470 | return $(e.target).parents().children().filter('div.blockUI').length == 0;
471 | };
472 |
473 | function focus(back) {
474 | if (!pageBlockEls)
475 | return;
476 | var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
477 | if (e)
478 | e.focus();
479 | };
480 |
481 | function center(el, x, y) {
482 | var p = el.parentNode, s = el.style;
483 | var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
484 | var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
485 | if (x) s.left = l > 0 ? (l+'px') : '0';
486 | if (y) s.top = t > 0 ? (t+'px') : '0';
487 | };
488 |
489 | function sz(el, p) {
490 | return parseInt($.css(el,p))||0;
491 | };
492 |
493 | })(jQuery);
494 |
--------------------------------------------------------------------------------
/js/chat.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Chat plugin javascript
3 | *
4 | * @todo Make this more OO when we have time
5 | *
6 | * @author S H Mohanjith
7 | * @since 1.0.1
8 | */
9 |
10 | var chat_localized;
11 |
12 | if (chat_localized) {
13 | var instanse = false;
14 | var logging_out = false;
15 | var mes;
16 | var file;
17 | var postid;
18 | var currentContent = [];
19 | var lastCheck = [];
20 | var last_mid = [];
21 | var chat_refresh_timer = [];
22 | var mids = [];
23 | var chat;
24 | var pingSound;
25 | var lastUpdate = [];
26 |
27 | var name = chat_localized["name"];
28 | var vip = chat_localized["vip"];
29 | var sounds = chat_localized["sounds"];
30 | var post_id = chat_localized["post_id"];
31 |
32 | function Chat() {
33 | this.update = updateChat;
34 | this.send = sendChat;
35 | this.setup = setupChat;
36 | this.clear = clearChat;
37 | this.archive = archiveChat;
38 | }
39 |
40 | function updateChat(sounds) {
41 | if (!instanse) {
42 | jQuery('.chat-post-id').each(function () {
43 | var instanse = true;
44 | var pid = jQuery(this).val();
45 | if (!lastCheck[pid]) {
46 | lastCheck[pid] = 0;
47 | last_mid[pid] = 0;
48 | lastUpdate[pid] = new Date().getTime();
49 | }
50 | if (!(pid == 1 && jQuery('#chat-block-site').hasClass('closed'))) {
51 | jQuery.ajax({
52 | type: "POST",
53 | url: chat_localized["url"],
54 | data: {
55 | 'function': 'update',
56 | 'cid': pid,
57 | 'file': file,
58 | 'action': 'chatProcess',
59 | 'avatar': chat_localized["avatar_" + pid],
60 | 'emoticons': chat_localized["avatar_" + pid],
61 | 'date_color': chat_localized["date_color_" + pid],
62 | 'name_color': chat_localized["name_color_" + pid],
63 | 'moderator_name_color': chat_localized["moderator_name_color_" + pid],
64 | 'text_color': chat_localized["text_color_" + pid],
65 | 'date_show': chat_localized["date_show_" + pid],
66 | 'time_show': chat_localized["time_show_" + pid],
67 | 'since': lastCheck[pid],
68 | 'since_id': last_mid[pid],
69 | 'moderator_roles': chat_localized["moderator_roles_" + pid]
70 | },
71 | dataType: "json",
72 | success: function (data) {
73 | if (data && data.text) {
74 | var updateContent = '';
75 | for (i in data.text) {
76 | updateContent = updateContent + "