adhearsion 0.7.6 → 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.version +1 -1
  2. data/CHANGELOG +43 -25
  3. data/Rakefile +0 -5
  4. data/TODO +51 -2
  5. data/ahn +2 -1
  6. data/apps/default/Rakefile +16 -7
  7. data/apps/default/config/adhearsion.yml +22 -1
  8. data/apps/default/config/helpers/manager_proxy.yml +1 -0
  9. data/apps/default/config/helpers/micromenus/images/arrow-off.gif +0 -0
  10. data/apps/default/config/helpers/micromenus/images/arrow-on.gif +0 -0
  11. data/apps/default/config/helpers/micromenus/images/error.gif +0 -0
  12. data/apps/default/config/helpers/micromenus/images/folder-off.gif +0 -0
  13. data/apps/default/config/helpers/micromenus/images/folder-on.gif +0 -0
  14. data/apps/default/config/helpers/micromenus/images/folder.png +0 -0
  15. data/apps/default/config/helpers/micromenus/images/ggbridge.jpg +0 -0
  16. data/apps/default/config/helpers/micromenus/images/green.png +0 -0
  17. data/apps/default/config/helpers/micromenus/images/microbrowser.bg.gif +0 -0
  18. data/apps/default/config/helpers/micromenus/images/red.png +0 -0
  19. data/apps/default/config/helpers/micromenus/images/url-off.gif +0 -0
  20. data/apps/default/config/helpers/micromenus/images/url-on.gif +0 -0
  21. data/apps/default/config/helpers/micromenus/images/yellow.png +0 -0
  22. data/apps/default/config/helpers/micromenus/javascripts/animation.js +1341 -0
  23. data/apps/default/config/helpers/micromenus/javascripts/carousel.js +1238 -0
  24. data/apps/default/config/helpers/micromenus/javascripts/columnav.js +306 -0
  25. data/apps/default/config/helpers/micromenus/javascripts/connection.js +965 -0
  26. data/apps/default/config/helpers/micromenus/javascripts/container.js +4727 -0
  27. data/apps/default/config/helpers/micromenus/javascripts/container_core.js +2915 -0
  28. data/apps/default/config/helpers/micromenus/javascripts/dom.js +892 -0
  29. data/apps/default/config/helpers/micromenus/javascripts/dragdrop.js +2921 -907
  30. data/apps/default/config/helpers/micromenus/javascripts/event.js +1771 -0
  31. data/apps/default/config/helpers/micromenus/javascripts/yahoo.js +433 -0
  32. data/apps/default/config/helpers/micromenus/stylesheets/carousel.css +78 -0
  33. data/apps/default/config/helpers/micromenus/stylesheets/columnav.css +135 -0
  34. data/apps/default/config/helpers/micromenus/stylesheets/microbrowsers.css +42 -0
  35. data/apps/default/config/helpers/multi_messenger.yml +5 -1
  36. data/apps/default/config/migration.rb +10 -0
  37. data/apps/default/extensions.rb +1 -1
  38. data/apps/default/helpers/factorial.alien.c +3 -3
  39. data/apps/default/helpers/lookup.rb +2 -1
  40. data/apps/default/helpers/manager_proxy.rb +67 -15
  41. data/apps/default/helpers/micromenus.rb +173 -31
  42. data/apps/default/helpers/multi_messenger.rb +20 -3
  43. data/lib/adhearsion.rb +218 -88
  44. data/lib/constants.rb +1 -0
  45. data/lib/core_extensions.rb +15 -9
  46. data/lib/phone_number.rb +85 -0
  47. data/lib/rami.rb +3 -2
  48. data/lib/servlet_container.rb +47 -24
  49. data/lib/sexy_migrations.rb +70 -0
  50. data/test/asterisk_module_test.rb +9 -9
  51. data/test/specs/numerical_string_spec.rb +53 -0
  52. metadata +31 -11
  53. data/apps/default/config/helpers/micromenus/javascripts/builder.js +0 -131
  54. data/apps/default/config/helpers/micromenus/javascripts/controls.js +0 -834
  55. data/apps/default/config/helpers/micromenus/javascripts/effects.js +0 -956
  56. data/apps/default/config/helpers/micromenus/javascripts/prototype.js +0 -2319
  57. data/apps/default/config/helpers/micromenus/javascripts/scriptaculous.js +0 -51
  58. data/apps/default/config/helpers/micromenus/javascripts/slider.js +0 -278
  59. data/apps/default/config/helpers/micromenus/javascripts/unittest.js +0 -557
  60. data/apps/default/config/helpers/micromenus/stylesheets/firefox.css +0 -10
  61. data/apps/default/config/helpers/micromenus/stylesheets/firefox.xul.css +0 -44
@@ -0,0 +1,4727 @@
1
+ /*
2
+ Copyright (c) 2007, Yahoo! Inc. All rights reserved.
3
+ Code licensed under the BSD License:
4
+ http://developer.yahoo.net/yui/license.txt
5
+ version: 2.2.0
6
+ */
7
+ /**
8
+ * Config is a utility used within an Object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
9
+ * @namespace YAHOO.util
10
+ * @class Config
11
+ * @constructor
12
+ * @param {Object} owner The owner Object to which this Config Object belongs
13
+ */
14
+ YAHOO.util.Config = function(owner) {
15
+ if (owner) {
16
+ this.init(owner);
17
+ }
18
+ };
19
+
20
+ YAHOO.util.Config.prototype = {
21
+
22
+ /**
23
+ * Object reference to the owner of this Config Object
24
+ * @property owner
25
+ * @type Object
26
+ */
27
+ owner : null,
28
+
29
+ /**
30
+ * Boolean flag that specifies whether a queue is currently being executed
31
+ * @property queueInProgress
32
+ * @type Boolean
33
+ */
34
+ queueInProgress : false,
35
+
36
+
37
+ /**
38
+ * Validates that the value passed in is a Boolean.
39
+ * @method checkBoolean
40
+ * @param {Object} val The value to validate
41
+ * @return {Boolean} true, if the value is valid
42
+ */
43
+ checkBoolean: function(val) {
44
+ if (typeof val == 'boolean') {
45
+ return true;
46
+ } else {
47
+ return false;
48
+ }
49
+ },
50
+
51
+ /**
52
+ * Validates that the value passed in is a number.
53
+ * @method checkNumber
54
+ * @param {Object} val The value to validate
55
+ * @return {Boolean} true, if the value is valid
56
+ */
57
+ checkNumber: function(val) {
58
+ if (isNaN(val)) {
59
+ return false;
60
+ } else {
61
+ return true;
62
+ }
63
+ }
64
+ };
65
+
66
+
67
+ /**
68
+ * Initializes the configuration Object and all of its local members.
69
+ * @method init
70
+ * @param {Object} owner The owner Object to which this Config Object belongs
71
+ */
72
+ YAHOO.util.Config.prototype.init = function(owner) {
73
+
74
+ this.owner = owner;
75
+
76
+ /**
77
+ * Object reference to the owner of this Config Object
78
+ * @event configChangedEvent
79
+ */
80
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
81
+ this.queueInProgress = false;
82
+
83
+ /* Private Members */
84
+
85
+ /**
86
+ * Maintains the local collection of configuration property objects and their specified values
87
+ * @property config
88
+ * @private
89
+ * @type Object
90
+ */
91
+ var config = {};
92
+
93
+ /**
94
+ * Maintains the local collection of configuration property objects as they were initially applied.
95
+ * This object is used when resetting a property.
96
+ * @property initialConfig
97
+ * @private
98
+ * @type Object
99
+ */
100
+ var initialConfig = {};
101
+
102
+ /**
103
+ * Maintains the local, normalized CustomEvent queue
104
+ * @property eventQueue
105
+ * @private
106
+ * @type Object
107
+ */
108
+ var eventQueue = [];
109
+
110
+ /**
111
+ * Fires a configuration property event using the specified value.
112
+ * @method fireEvent
113
+ * @private
114
+ * @param {String} key The configuration property's name
115
+ * @param {value} Object The value of the correct type for the property
116
+ */
117
+ var fireEvent = function( key, value ) {
118
+ key = key.toLowerCase();
119
+
120
+ var property = config[key];
121
+
122
+ if (typeof property != 'undefined' && property.event) {
123
+ property.event.fire(value);
124
+ }
125
+ };
126
+ /* End Private Members */
127
+
128
+ /**
129
+ * Adds a property to the Config Object's private config hash.
130
+ * @method addProperty
131
+ * @param {String} key The configuration property's name
132
+ * @param {Object} propertyObject The Object containing all of this property's arguments
133
+ */
134
+ this.addProperty = function( key, propertyObject ) {
135
+ key = key.toLowerCase();
136
+
137
+ config[key] = propertyObject;
138
+
139
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
140
+ propertyObject.key = key;
141
+
142
+ if (propertyObject.handler) {
143
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
144
+ }
145
+
146
+ this.setProperty(key, propertyObject.value, true);
147
+
148
+ if (! propertyObject.suppressEvent) {
149
+ this.queueProperty(key, propertyObject.value);
150
+ }
151
+ };
152
+
153
+ /**
154
+ * Returns a key-value configuration map of the values currently set in the Config Object.
155
+ * @method getConfig
156
+ * @return {Object} The current config, represented in a key-value map
157
+ */
158
+ this.getConfig = function() {
159
+ var cfg = {};
160
+
161
+ for (var prop in config) {
162
+ var property = config[prop];
163
+ if (typeof property != 'undefined' && property.event) {
164
+ cfg[prop] = property.value;
165
+ }
166
+ }
167
+
168
+ return cfg;
169
+ };
170
+
171
+ /**
172
+ * Returns the value of specified property.
173
+ * @method getProperty
174
+ * @param {String} key The name of the property
175
+ * @return {Object} The value of the specified property
176
+ */
177
+ this.getProperty = function(key) {
178
+ key = key.toLowerCase();
179
+
180
+ var property = config[key];
181
+ if (typeof property != 'undefined' && property.event) {
182
+ return property.value;
183
+ } else {
184
+ return undefined;
185
+ }
186
+ };
187
+
188
+ /**
189
+ * Resets the specified property's value to its initial value.
190
+ * @method resetProperty
191
+ * @param {String} key The name of the property
192
+ * @return {Boolean} True is the property was reset, false if not
193
+ */
194
+ this.resetProperty = function(key) {
195
+ key = key.toLowerCase();
196
+
197
+ var property = config[key];
198
+ if (typeof property != 'undefined' && property.event) {
199
+ if (initialConfig[key] && initialConfig[key] != 'undefined') {
200
+ this.setProperty(key, initialConfig[key]);
201
+ }
202
+ return true;
203
+ } else {
204
+ return false;
205
+ }
206
+ };
207
+
208
+ /**
209
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
210
+ * @method setProperty
211
+ * @param {String} key The name of the property
212
+ * @param {String} value The value to set the property to
213
+ * @param {Boolean} silent Whether the value should be set silently, without firing the property event.
214
+ * @return {Boolean} True, if the set was successful, false if it failed.
215
+ */
216
+ this.setProperty = function(key, value, silent) {
217
+ key = key.toLowerCase();
218
+
219
+ if (this.queueInProgress && ! silent) {
220
+ this.queueProperty(key,value); // Currently running through a queue...
221
+ return true;
222
+ } else {
223
+ var property = config[key];
224
+ if (typeof property != 'undefined' && property.event) {
225
+ if (property.validator && ! property.validator(value)) { // validator
226
+ return false;
227
+ } else {
228
+ property.value = value;
229
+ if (! silent) {
230
+ fireEvent(key, value);
231
+ this.configChangedEvent.fire([key, value]);
232
+ }
233
+ return true;
234
+ }
235
+ } else {
236
+ return false;
237
+ }
238
+ }
239
+ };
240
+
241
+ /**
242
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
243
+ * moved from its current position to the end of the queue.
244
+ * @method queueProperty
245
+ * @param {String} key The name of the property
246
+ * @param {String} value The value to set the property to
247
+ * @return {Boolean} true, if the set was successful, false if it failed.
248
+ */
249
+ this.queueProperty = function(key, value) {
250
+ key = key.toLowerCase();
251
+
252
+ var property = config[key];
253
+
254
+ if (typeof property != 'undefined' && property.event) {
255
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
256
+ return false;
257
+ } else {
258
+
259
+ if (typeof value != 'undefined') {
260
+ property.value = value;
261
+ } else {
262
+ value = property.value;
263
+ }
264
+
265
+ var foundDuplicate = false;
266
+
267
+ for (var i=0;i<eventQueue.length;i++) {
268
+ var queueItem = eventQueue[i];
269
+
270
+ if (queueItem) {
271
+ var queueItemKey = queueItem[0];
272
+ var queueItemValue = queueItem[1];
273
+
274
+ if (queueItemKey.toLowerCase() == key) {
275
+ // found a dupe... push to end of queue, null current item, and break
276
+ eventQueue[i] = null;
277
+ eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
278
+ foundDuplicate = true;
279
+ break;
280
+ }
281
+ }
282
+ }
283
+
284
+ if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
285
+ eventQueue.push([key, value]);
286
+ }
287
+ }
288
+
289
+ if (property.supercedes) {
290
+ for (var s=0;s<property.supercedes.length;s++) {
291
+ var supercedesCheck = property.supercedes[s];
292
+
293
+ for (var q=0;q<eventQueue.length;q++) {
294
+ var queueItemCheck = eventQueue[q];
295
+
296
+ if (queueItemCheck) {
297
+ var queueItemCheckKey = queueItemCheck[0];
298
+ var queueItemCheckValue = queueItemCheck[1];
299
+
300
+ if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
301
+ eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
302
+ eventQueue[q] = null;
303
+ break;
304
+ }
305
+ }
306
+ }
307
+ }
308
+ }
309
+
310
+ return true;
311
+ } else {
312
+ return false;
313
+ }
314
+ };
315
+
316
+ /**
317
+ * Fires the event for a property using the property's current value.
318
+ * @method refireEvent
319
+ * @param {String} key The name of the property
320
+ */
321
+ this.refireEvent = function(key) {
322
+ key = key.toLowerCase();
323
+
324
+ var property = config[key];
325
+ if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
326
+ if (this.queueInProgress) {
327
+ this.queueProperty(key);
328
+ } else {
329
+ fireEvent(key, property.value);
330
+ }
331
+ }
332
+ };
333
+
334
+ /**
335
+ * Applies a key-value Object literal to the configuration, replacing any existing values, and queueing the property events.
336
+ * Although the values will be set, fireQueue() must be called for their associated events to execute.
337
+ * @method applyConfig
338
+ * @param {Object} userConfig The configuration Object literal
339
+ * @param {Boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
340
+ */
341
+ this.applyConfig = function(userConfig, init) {
342
+ if (init) {
343
+ initialConfig = userConfig;
344
+ }
345
+ for (var prop in userConfig) {
346
+ this.queueProperty(prop, userConfig[prop]);
347
+ }
348
+ };
349
+
350
+ /**
351
+ * Refires the events for all configuration properties using their current values.
352
+ * @method refresh
353
+ */
354
+ this.refresh = function() {
355
+ for (var prop in config) {
356
+ this.refireEvent(prop);
357
+ }
358
+ };
359
+
360
+ /**
361
+ * Fires the normalized list of queued property change events
362
+ * @method fireQueue
363
+ */
364
+ this.fireQueue = function() {
365
+ this.queueInProgress = true;
366
+ for (var i=0;i<eventQueue.length;i++) {
367
+ var queueItem = eventQueue[i];
368
+ if (queueItem) {
369
+ var key = queueItem[0];
370
+ var value = queueItem[1];
371
+
372
+ var property = config[key];
373
+ property.value = value;
374
+
375
+ fireEvent(key,value);
376
+ }
377
+ }
378
+
379
+ this.queueInProgress = false;
380
+ eventQueue = [];
381
+ };
382
+
383
+ /**
384
+ * Subscribes an external handler to the change event for any given property.
385
+ * @method subscribeToConfigEvent
386
+ * @param {String} key The property name
387
+ * @param {Function} handler The handler function to use subscribe to the property's event
388
+ * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation)
389
+ * @param {Boolean} override Optional. If true, will override "this" within the handler to map to the scope Object passed into the method.
390
+ * @return {Boolean} True, if the subscription was successful, otherwise false.
391
+ */
392
+ this.subscribeToConfigEvent = function(key, handler, obj, override) {
393
+ key = key.toLowerCase();
394
+
395
+ var property = config[key];
396
+ if (typeof property != 'undefined' && property.event) {
397
+ if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
398
+ property.event.subscribe(handler, obj, override);
399
+ }
400
+ return true;
401
+ } else {
402
+ return false;
403
+ }
404
+ };
405
+
406
+ /**
407
+ * Unsubscribes an external handler from the change event for any given property.
408
+ * @method unsubscribeFromConfigEvent
409
+ * @param {String} key The property name
410
+ * @param {Function} handler The handler function to use subscribe to the property's event
411
+ * @param {Object} obj The Object to use for scoping the event handler (see CustomEvent documentation)
412
+ * @return {Boolean} True, if the unsubscription was successful, otherwise false.
413
+ */
414
+ this.unsubscribeFromConfigEvent = function(key, handler, obj) {
415
+ key = key.toLowerCase();
416
+
417
+ var property = config[key];
418
+ if (typeof property != 'undefined' && property.event) {
419
+ return property.event.unsubscribe(handler, obj);
420
+ } else {
421
+ return false;
422
+ }
423
+ };
424
+
425
+ /**
426
+ * Returns a string representation of the Config object
427
+ * @method toString
428
+ * @return {String} The Config object in string format.
429
+ */
430
+ this.toString = function() {
431
+ var output = "Config";
432
+ if (this.owner) {
433
+ output += " [" + this.owner.toString() + "]";
434
+ }
435
+ return output;
436
+ };
437
+
438
+ /**
439
+ * Returns a string representation of the Config object's current CustomEvent queue
440
+ * @method outputEventQueue
441
+ * @return {String} The string list of CustomEvents currently queued for execution
442
+ */
443
+ this.outputEventQueue = function() {
444
+ var output = "";
445
+ for (var q=0;q<eventQueue.length;q++) {
446
+ var queueItem = eventQueue[q];
447
+ if (queueItem) {
448
+ output += queueItem[0] + "=" + queueItem[1] + ", ";
449
+ }
450
+ }
451
+ return output;
452
+ };
453
+ };
454
+
455
+ /**
456
+ * Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent
457
+ * @method YAHOO.util.Config.alreadySubscribed
458
+ * @static
459
+ * @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions
460
+ * @param {Function} fn The function to look for in the subscribers list
461
+ * @param {Object} obj The execution scope Object for the subscription
462
+ * @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in
463
+ */
464
+ YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
465
+ for (var e=0;e<evt.subscribers.length;e++) {
466
+ var subsc = evt.subscribers[e];
467
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
468
+ return true;
469
+ }
470
+ }
471
+ return false;
472
+ };
473
+
474
+ /**
475
+ * The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog.
476
+ * @module container
477
+ * @title Container
478
+ * @requires yahoo,dom,event,dragdrop,animation
479
+ */
480
+
481
+ /**
482
+ * Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
483
+ * @namespace YAHOO.widget
484
+ * @class Module
485
+ * @constructor
486
+ * @param {String} el The element ID representing the Module <em>OR</em>
487
+ * @param {HTMLElement} el The element representing the Module
488
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
489
+ */
490
+ YAHOO.widget.Module = function(el, userConfig) {
491
+ if (el) {
492
+ this.init(el, userConfig);
493
+ } else {
494
+ }
495
+ };
496
+
497
+ /**
498
+ * Constant representing the prefix path to use for non-secure images
499
+ * @property YAHOO.widget.Module.IMG_ROOT
500
+ * @static
501
+ * @final
502
+ * @type String
503
+ */
504
+ YAHOO.widget.Module.IMG_ROOT = null;
505
+
506
+ /**
507
+ * Constant representing the prefix path to use for securely served images
508
+ * @property YAHOO.widget.Module.IMG_ROOT_SSL
509
+ * @static
510
+ * @final
511
+ * @type String
512
+ */
513
+ YAHOO.widget.Module.IMG_ROOT_SSL = null;
514
+
515
+ /**
516
+ * Constant for the default CSS class name that represents a Module
517
+ * @property YAHOO.widget.Module.CSS_MODULE
518
+ * @static
519
+ * @final
520
+ * @type String
521
+ */
522
+ YAHOO.widget.Module.CSS_MODULE = "module";
523
+
524
+ /**
525
+ * Constant representing the module header
526
+ * @property YAHOO.widget.Module.CSS_HEADER
527
+ * @static
528
+ * @final
529
+ * @type String
530
+ */
531
+ YAHOO.widget.Module.CSS_HEADER = "hd";
532
+
533
+ /**
534
+ * Constant representing the module body
535
+ * @property YAHOO.widget.Module.CSS_BODY
536
+ * @static
537
+ * @final
538
+ * @type String
539
+ */
540
+ YAHOO.widget.Module.CSS_BODY = "bd";
541
+
542
+ /**
543
+ * Constant representing the module footer
544
+ * @property YAHOO.widget.Module.CSS_FOOTER
545
+ * @static
546
+ * @final
547
+ * @type String
548
+ */
549
+ YAHOO.widget.Module.CSS_FOOTER = "ft";
550
+
551
+ /**
552
+ * Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
553
+ * @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL
554
+ * @static
555
+ * @final
556
+ * @type String
557
+ */
558
+ YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";
559
+
560
+ /**
561
+ * Singleton CustomEvent fired when the font size is changed in the browser.
562
+ * Opera's "zoom" functionality currently does not support text size detection.
563
+ * @event YAHOO.widget.Module.textResizeEvent
564
+ */
565
+ YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");
566
+
567
+ YAHOO.widget.Module.prototype = {
568
+ /**
569
+ * The class's constructor function
570
+ * @property contructor
571
+ * @type Function
572
+ */
573
+ constructor : YAHOO.widget.Module,
574
+
575
+ /**
576
+ * The main module element that contains the header, body, and footer
577
+ * @property element
578
+ * @type HTMLElement
579
+ */
580
+ element : null,
581
+
582
+ /**
583
+ * The header element, denoted with CSS class "hd"
584
+ * @property header
585
+ * @type HTMLElement
586
+ */
587
+ header : null,
588
+
589
+ /**
590
+ * The body element, denoted with CSS class "bd"
591
+ * @property body
592
+ * @type HTMLElement
593
+ */
594
+ body : null,
595
+
596
+ /**
597
+ * The footer element, denoted with CSS class "ft"
598
+ * @property footer
599
+ * @type HTMLElement
600
+ */
601
+ footer : null,
602
+
603
+ /**
604
+ * The id of the element
605
+ * @property id
606
+ * @type String
607
+ */
608
+ id : null,
609
+
610
+ /**
611
+ * The String representing the image root
612
+ * @property imageRoot
613
+ * @type String
614
+ */
615
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
616
+
617
+ /**
618
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
619
+ * @method initEvents
620
+ */
621
+ initEvents : function() {
622
+
623
+ /**
624
+ * CustomEvent fired prior to class initalization.
625
+ * @event beforeInitEvent
626
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
627
+ */
628
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
629
+
630
+ /**
631
+ * CustomEvent fired after class initalization.
632
+ * @event initEvent
633
+ * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
634
+ */
635
+ this.initEvent = new YAHOO.util.CustomEvent("init");
636
+
637
+ /**
638
+ * CustomEvent fired when the Module is appended to the DOM
639
+ * @event appendEvent
640
+ */
641
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
642
+
643
+ /**
644
+ * CustomEvent fired before the Module is rendered
645
+ * @event beforeRenderEvent
646
+ */
647
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
648
+
649
+ /**
650
+ * CustomEvent fired after the Module is rendered
651
+ * @event renderEvent
652
+ */
653
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
654
+
655
+ /**
656
+ * CustomEvent fired when the header content of the Module is modified
657
+ * @event changeHeaderEvent
658
+ * @param {String/HTMLElement} content String/element representing the new header content
659
+ */
660
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
661
+
662
+ /**
663
+ * CustomEvent fired when the body content of the Module is modified
664
+ * @event changeBodyEvent
665
+ * @param {String/HTMLElement} content String/element representing the new body content
666
+ */
667
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
668
+
669
+ /**
670
+ * CustomEvent fired when the footer content of the Module is modified
671
+ * @event changeFooterEvent
672
+ * @param {String/HTMLElement} content String/element representing the new footer content
673
+ */
674
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
675
+
676
+ /**
677
+ * CustomEvent fired when the content of the Module is modified
678
+ * @event changeContentEvent
679
+ */
680
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
681
+
682
+ /**
683
+ * CustomEvent fired when the Module is destroyed
684
+ * @event destroyEvent
685
+ */
686
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
687
+
688
+ /**
689
+ * CustomEvent fired before the Module is shown
690
+ * @event beforeShowEvent
691
+ */
692
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
693
+
694
+ /**
695
+ * CustomEvent fired after the Module is shown
696
+ * @event showEvent
697
+ */
698
+ this.showEvent = new YAHOO.util.CustomEvent("show");
699
+
700
+ /**
701
+ * CustomEvent fired before the Module is hidden
702
+ * @event beforeHideEvent
703
+ */
704
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
705
+
706
+ /**
707
+ * CustomEvent fired after the Module is hidden
708
+ * @event hideEvent
709
+ */
710
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
711
+ },
712
+
713
+ /**
714
+ * String representing the current user-agent platform
715
+ * @property platform
716
+ * @type String
717
+ */
718
+ platform : function() {
719
+ var ua = navigator.userAgent.toLowerCase();
720
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
721
+ return "windows";
722
+ } else if (ua.indexOf("macintosh") != -1) {
723
+ return "mac";
724
+ } else {
725
+ return false;
726
+ }
727
+ }(),
728
+
729
+ /**
730
+ * String representing the current user-agent browser
731
+ * @property browser
732
+ * @type String
733
+ */
734
+ browser : function() {
735
+ var ua = navigator.userAgent.toLowerCase();
736
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
737
+ return 'opera';
738
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
739
+ return 'ie7';
740
+ } else if (ua.indexOf('msie') !=-1) { // IE
741
+ return 'ie';
742
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
743
+ return 'safari';
744
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
745
+ return 'gecko';
746
+ } else {
747
+ return false;
748
+ }
749
+ }(),
750
+
751
+ /**
752
+ * Boolean representing whether or not the current browsing context is secure (https)
753
+ * @property isSecure
754
+ * @type Boolean
755
+ */
756
+ isSecure : function() {
757
+ if (window.location.href.toLowerCase().indexOf("https") === 0) {
758
+ return true;
759
+ } else {
760
+ return false;
761
+ }
762
+ }(),
763
+
764
+ /**
765
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
766
+ */
767
+ initDefaultConfig : function() {
768
+ // Add properties //
769
+
770
+ /**
771
+ * Specifies whether the Module is visible on the page.
772
+ * @config visible
773
+ * @type Boolean
774
+ * @default true
775
+ */
776
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
777
+
778
+ /**
779
+ * Object or array of objects representing the ContainerEffect classes that are active for animating the container.
780
+ * @config effect
781
+ * @type Object
782
+ * @default null
783
+ */
784
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
785
+
786
+ /**
787
+ * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document
788
+ * @config monitorresize
789
+ * @type Boolean
790
+ * @default true
791
+ */
792
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
793
+ },
794
+
795
+ /**
796
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
797
+ * @method init
798
+ * @param {String} el The element ID representing the Module <em>OR</em>
799
+ * @param {HTMLElement} el The element representing the Module
800
+ * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.
801
+ */
802
+ init : function(el, userConfig) {
803
+
804
+ this.initEvents();
805
+
806
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
807
+
808
+ /**
809
+ * The Module's Config object used for monitoring configuration properties.
810
+ * @property cfg
811
+ * @type YAHOO.util.Config
812
+ */
813
+ this.cfg = new YAHOO.util.Config(this);
814
+
815
+ if (this.isSecure) {
816
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
817
+ }
818
+
819
+ if (typeof el == "string") {
820
+ var elId = el;
821
+
822
+ el = document.getElementById(el);
823
+ if (! el) {
824
+ el = document.createElement("div");
825
+ el.id = elId;
826
+ }
827
+ }
828
+
829
+ this.element = el;
830
+
831
+ if (el.id) {
832
+ this.id = el.id;
833
+ }
834
+
835
+ var childNodes = this.element.childNodes;
836
+
837
+ if (childNodes) {
838
+ for (var i=0;i<childNodes.length;i++) {
839
+ var child = childNodes[i];
840
+ switch (child.className) {
841
+ case YAHOO.widget.Module.CSS_HEADER:
842
+ this.header = child;
843
+ break;
844
+ case YAHOO.widget.Module.CSS_BODY:
845
+ this.body = child;
846
+ break;
847
+ case YAHOO.widget.Module.CSS_FOOTER:
848
+ this.footer = child;
849
+ break;
850
+ }
851
+ }
852
+ }
853
+
854
+ this.initDefaultConfig();
855
+
856
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE);
857
+
858
+ if (userConfig) {
859
+ this.cfg.applyConfig(userConfig, true);
860
+ }
861
+
862
+ // Subscribe to the fireQueue() method of Config so that any queued configuration changes are
863
+ // excecuted upon render of the Module
864
+ if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) {
865
+ this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true);
866
+ }
867
+
868
+ this.initEvent.fire(YAHOO.widget.Module);
869
+ },
870
+
871
+ /**
872
+ * Initialized an empty IFRAME that is placed out of the visible area that can be used to detect text resize.
873
+ * @method initResizeMonitor
874
+ */
875
+ initResizeMonitor : function() {
876
+
877
+ if(this.browser != "opera") {
878
+
879
+ var resizeMonitor = document.getElementById("_yuiResizeMonitor");
880
+
881
+ if (! resizeMonitor) {
882
+
883
+ resizeMonitor = document.createElement("iframe");
884
+
885
+ var bIE = (this.browser.indexOf("ie") === 0);
886
+
887
+ if(this.isSecure && YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL && bIE) {
888
+ resizeMonitor.src = YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL;
889
+ }
890
+
891
+ resizeMonitor.id = "_yuiResizeMonitor";
892
+ resizeMonitor.style.visibility = "hidden";
893
+
894
+ document.body.appendChild(resizeMonitor);
895
+
896
+ resizeMonitor.style.width = "10em";
897
+ resizeMonitor.style.height = "10em";
898
+ resizeMonitor.style.position = "absolute";
899
+
900
+ var nLeft = -1 * resizeMonitor.offsetWidth;
901
+ var nTop = -1 * resizeMonitor.offsetHeight;
902
+
903
+ resizeMonitor.style.top = nTop + "px";
904
+ resizeMonitor.style.left = nLeft + "px";
905
+ resizeMonitor.style.borderStyle = "none";
906
+ resizeMonitor.style.borderWidth = "0";
907
+ YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0");
908
+
909
+ resizeMonitor.style.visibility = "visible";
910
+
911
+ if(!bIE) {
912
+
913
+ var doc = resizeMonitor.contentWindow.document;
914
+
915
+ doc.open();
916
+ doc.close();
917
+
918
+ }
919
+ }
920
+
921
+ var fireTextResize = function() {
922
+ YAHOO.widget.Module.textResizeEvent.fire();
923
+ };
924
+
925
+ if(resizeMonitor && resizeMonitor.contentWindow) {
926
+ this.resizeMonitor = resizeMonitor;
927
+
928
+ YAHOO.widget.Module.textResizeEvent.subscribe(this.onDomResize, this, true);
929
+
930
+ if (! YAHOO.widget.Module.textResizeInitialized) {
931
+ if (! YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", fireTextResize)) {
932
+ // This will fail in IE if document.domain has changed, so we must change the listener to
933
+ // use the resizeMonitor element instead
934
+ YAHOO.util.Event.addListener(this.resizeMonitor, "resize", fireTextResize);
935
+ }
936
+ YAHOO.widget.Module.textResizeInitialized = true;
937
+ }
938
+ }
939
+
940
+ }
941
+
942
+ },
943
+
944
+ /**
945
+ * Event handler fired when the resize monitor element is resized.
946
+ * @method onDomResize
947
+ * @param {DOMEvent} e The DOM resize event
948
+ * @param {Object} obj The scope object passed to the handler
949
+ */
950
+ onDomResize : function(e, obj) {
951
+
952
+ var nLeft = -1 * this.resizeMonitor.offsetWidth,
953
+ nTop = -1 * this.resizeMonitor.offsetHeight;
954
+
955
+ this.resizeMonitor.style.top = nTop + "px";
956
+ this.resizeMonitor.style.left = nLeft + "px";
957
+
958
+ },
959
+
960
+ /**
961
+ * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
962
+ * @method setHeader
963
+ * @param {String} headerContent The HTML used to set the header <em>OR</em>
964
+ * @param {HTMLElement} headerContent The HTMLElement to append to the header
965
+ */
966
+ setHeader : function(headerContent) {
967
+ if (! this.header) {
968
+ this.header = document.createElement("div");
969
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
970
+ }
971
+
972
+ if (typeof headerContent == "string") {
973
+ this.header.innerHTML = headerContent;
974
+ } else {
975
+ this.header.innerHTML = "";
976
+ this.header.appendChild(headerContent);
977
+ }
978
+
979
+ this.changeHeaderEvent.fire(headerContent);
980
+ this.changeContentEvent.fire();
981
+ },
982
+
983
+ /**
984
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
985
+ * @method appendToHeader
986
+ * @param {HTMLElement} element The element to append to the header
987
+ */
988
+ appendToHeader : function(element) {
989
+ if (! this.header) {
990
+ this.header = document.createElement("div");
991
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
992
+ }
993
+
994
+ this.header.appendChild(element);
995
+ this.changeHeaderEvent.fire(element);
996
+ this.changeContentEvent.fire();
997
+ },
998
+
999
+ /**
1000
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
1001
+ * @method setBody
1002
+ * @param {String} bodyContent The HTML used to set the body <em>OR</em>
1003
+ * @param {HTMLElement} bodyContent The HTMLElement to append to the body
1004
+ */
1005
+ setBody : function(bodyContent) {
1006
+ if (! this.body) {
1007
+ this.body = document.createElement("div");
1008
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
1009
+ }
1010
+
1011
+ if (typeof bodyContent == "string")
1012
+ {
1013
+ this.body.innerHTML = bodyContent;
1014
+ } else {
1015
+ this.body.innerHTML = "";
1016
+ this.body.appendChild(bodyContent);
1017
+ }
1018
+
1019
+ this.changeBodyEvent.fire(bodyContent);
1020
+ this.changeContentEvent.fire();
1021
+ },
1022
+
1023
+ /**
1024
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
1025
+ * @method appendToBody
1026
+ * @param {HTMLElement} element The element to append to the body
1027
+ */
1028
+ appendToBody : function(element) {
1029
+ if (! this.body) {
1030
+ this.body = document.createElement("div");
1031
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
1032
+ }
1033
+
1034
+ this.body.appendChild(element);
1035
+ this.changeBodyEvent.fire(element);
1036
+ this.changeContentEvent.fire();
1037
+ },
1038
+
1039
+ /**
1040
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
1041
+ * @method setFooter
1042
+ * @param {String} footerContent The HTML used to set the footer <em>OR</em>
1043
+ * @param {HTMLElement} footerContent The HTMLElement to append to the footer
1044
+ */
1045
+ setFooter : function(footerContent) {
1046
+ if (! this.footer) {
1047
+ this.footer = document.createElement("div");
1048
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
1049
+ }
1050
+
1051
+ if (typeof footerContent == "string") {
1052
+ this.footer.innerHTML = footerContent;
1053
+ } else {
1054
+ this.footer.innerHTML = "";
1055
+ this.footer.appendChild(footerContent);
1056
+ }
1057
+
1058
+ this.changeFooterEvent.fire(footerContent);
1059
+ this.changeContentEvent.fire();
1060
+ },
1061
+
1062
+ /**
1063
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
1064
+ * @method appendToFooter
1065
+ * @param {HTMLElement} element The element to append to the footer
1066
+ */
1067
+ appendToFooter : function(element) {
1068
+ if (! this.footer) {
1069
+ this.footer = document.createElement("div");
1070
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
1071
+ }
1072
+
1073
+ this.footer.appendChild(element);
1074
+ this.changeFooterEvent.fire(element);
1075
+ this.changeContentEvent.fire();
1076
+ },
1077
+
1078
+ /**
1079
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
1080
+ * @method render
1081
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
1082
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
1083
+ * @param {HTMLElement} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
1084
+ * @return {Boolean} Success or failure of the render
1085
+ */
1086
+ render : function(appendToNode, moduleElement) {
1087
+ this.beforeRenderEvent.fire();
1088
+
1089
+ if (! moduleElement) {
1090
+ moduleElement = this.element;
1091
+ }
1092
+
1093
+ var me = this;
1094
+ var appendTo = function(element) {
1095
+ if (typeof element == "string") {
1096
+ element = document.getElementById(element);
1097
+ }
1098
+
1099
+ if (element) {
1100
+ element.appendChild(me.element);
1101
+ me.appendEvent.fire();
1102
+ }
1103
+ };
1104
+
1105
+ if (appendToNode) {
1106
+ appendTo(appendToNode);
1107
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
1108
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
1109
+ return false;
1110
+ }
1111
+ }
1112
+
1113
+ // Need to get everything into the DOM if it isn't already
1114
+
1115
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
1116
+ // There is a header, but it's not in the DOM yet... need to add it
1117
+ var firstChild = moduleElement.firstChild;
1118
+ if (firstChild) { // Insert before first child if exists
1119
+ moduleElement.insertBefore(this.header, firstChild);
1120
+ } else { // Append to empty body because there are no children
1121
+ moduleElement.appendChild(this.header);
1122
+ }
1123
+ }
1124
+
1125
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
1126
+ // There is a body, but it's not in the DOM yet... need to add it
1127
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
1128
+ moduleElement.insertBefore(this.body, this.footer);
1129
+ } else { // Append to element because there is no footer
1130
+ moduleElement.appendChild(this.body);
1131
+ }
1132
+ }
1133
+
1134
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
1135
+ // There is a footer, but it's not in the DOM yet... need to add it
1136
+ moduleElement.appendChild(this.footer);
1137
+ }
1138
+
1139
+ this.renderEvent.fire();
1140
+ return true;
1141
+ },
1142
+
1143
+ /**
1144
+ * Removes the Module element from the DOM and sets all child elements to null.
1145
+ * @method destroy
1146
+ */
1147
+ destroy : function() {
1148
+ var parent;
1149
+
1150
+ if (this.element) {
1151
+ YAHOO.util.Event.purgeElement(this.element, true);
1152
+ parent = this.element.parentNode;
1153
+ }
1154
+ if (parent) {
1155
+ parent.removeChild(this.element);
1156
+ }
1157
+
1158
+ this.element = null;
1159
+ this.header = null;
1160
+ this.body = null;
1161
+ this.footer = null;
1162
+
1163
+ for (var e in this) {
1164
+ if (e instanceof YAHOO.util.CustomEvent) {
1165
+ e.unsubscribeAll();
1166
+ }
1167
+ }
1168
+
1169
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this);
1170
+
1171
+ this.destroyEvent.fire();
1172
+ },
1173
+
1174
+ /**
1175
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
1176
+ * @method show
1177
+ */
1178
+ show : function() {
1179
+ this.cfg.setProperty("visible", true);
1180
+ },
1181
+
1182
+ /**
1183
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
1184
+ * @method hide
1185
+ */
1186
+ hide : function() {
1187
+ this.cfg.setProperty("visible", false);
1188
+ },
1189
+
1190
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
1191
+
1192
+ /**
1193
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
1194
+ * This method is responsible for firing showEvent and hideEvent.
1195
+ * @param {String} type The CustomEvent type (usually the property name)
1196
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1197
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1198
+ * @method configVisible
1199
+ */
1200
+ configVisible : function(type, args, obj) {
1201
+ var visible = args[0];
1202
+ if (visible) {
1203
+ this.beforeShowEvent.fire();
1204
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
1205
+ this.showEvent.fire();
1206
+ } else {
1207
+ this.beforeHideEvent.fire();
1208
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
1209
+ this.hideEvent.fire();
1210
+ }
1211
+ },
1212
+
1213
+ /**
1214
+ * Default event handler for the "monitorresize" configuration property
1215
+ * @param {String} type The CustomEvent type (usually the property name)
1216
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1217
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1218
+ * @method configMonitorResize
1219
+ */
1220
+ configMonitorResize : function(type, args, obj) {
1221
+ var monitor = args[0];
1222
+ if (monitor) {
1223
+ this.initResizeMonitor();
1224
+ } else {
1225
+ YAHOO.widget.Module.textResizeEvent.unsubscribe(this.onDomResize, this, true);
1226
+ this.resizeMonitor = null;
1227
+ }
1228
+ }
1229
+ };
1230
+
1231
+ /**
1232
+ * Returns a String representation of the Object.
1233
+ * @method toString
1234
+ * @return {String} The string representation of the Module
1235
+ */
1236
+ YAHOO.widget.Module.prototype.toString = function() {
1237
+ return "Module " + this.id;
1238
+ };
1239
+
1240
+ /**
1241
+ * Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
1242
+ * @namespace YAHOO.widget
1243
+ * @class Overlay
1244
+ * @extends YAHOO.widget.Module
1245
+ * @param {String} el The element ID representing the Overlay <em>OR</em>
1246
+ * @param {HTMLElement} el The element representing the Overlay
1247
+ * @param {Object} userConfig The configuration object literal containing 10/23/2006the configuration that should be set for this Overlay. See configuration documentation for more details.
1248
+ * @constructor
1249
+ */
1250
+ YAHOO.widget.Overlay = function(el, userConfig) {
1251
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
1252
+ };
1253
+
1254
+ YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
1255
+
1256
+ /**
1257
+ * The URL that will be placed in the iframe
1258
+ * @property YAHOO.widget.Overlay.IFRAME_SRC
1259
+ * @static
1260
+ * @final
1261
+ * @type String
1262
+ */
1263
+ YAHOO.widget.Overlay.IFRAME_SRC = "javascript:false;";
1264
+
1265
+ /**
1266
+ * Constant representing the top left corner of an element, used for configuring the context element alignment
1267
+ * @property YAHOO.widget.Overlay.TOP_LEFT
1268
+ * @static
1269
+ * @final
1270
+ * @type String
1271
+ */
1272
+ YAHOO.widget.Overlay.TOP_LEFT = "tl";
1273
+
1274
+ /**
1275
+ * Constant representing the top right corner of an element, used for configuring the context element alignment
1276
+ * @property YAHOO.widget.Overlay.TOP_RIGHT
1277
+ * @static
1278
+ * @final
1279
+ * @type String
1280
+ */
1281
+ YAHOO.widget.Overlay.TOP_RIGHT = "tr";
1282
+
1283
+ /**
1284
+ * Constant representing the top bottom left corner of an element, used for configuring the context element alignment
1285
+ * @property YAHOO.widget.Overlay.BOTTOM_LEFT
1286
+ * @static
1287
+ * @final
1288
+ * @type String
1289
+ */
1290
+ YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
1291
+
1292
+ /**
1293
+ * Constant representing the bottom right corner of an element, used for configuring the context element alignment
1294
+ * @property YAHOO.widget.Overlay.BOTTOM_RIGHT
1295
+ * @static
1296
+ * @final
1297
+ * @type String
1298
+ */
1299
+ YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
1300
+
1301
+ /**
1302
+ * Constant representing the default CSS class used for an Overlay
1303
+ * @property YAHOO.widget.Overlay.CSS_OVERLAY
1304
+ * @static
1305
+ * @final
1306
+ * @type String
1307
+ */
1308
+ YAHOO.widget.Overlay.CSS_OVERLAY = "yui-overlay";
1309
+
1310
+ /**
1311
+ * The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
1312
+ * @method init
1313
+ * @param {String} el The element ID representing the Overlay <em>OR</em>
1314
+ * @param {HTMLElement} el The element representing the Overlay
1315
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
1316
+ */
1317
+ YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
1318
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
1319
+
1320
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
1321
+
1322
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
1323
+
1324
+ if (userConfig) {
1325
+ this.cfg.applyConfig(userConfig, true);
1326
+ }
1327
+
1328
+ if (this.platform == "mac" && this.browser == "gecko") {
1329
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
1330
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
1331
+ }
1332
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
1333
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
1334
+ }
1335
+ }
1336
+
1337
+ this.initEvent.fire(YAHOO.widget.Overlay);
1338
+
1339
+ };
1340
+
1341
+ /**
1342
+ * Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
1343
+ * @method initEvents
1344
+ */
1345
+ YAHOO.widget.Overlay.prototype.initEvents = function() {
1346
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
1347
+
1348
+ /**
1349
+ * CustomEvent fired before the Overlay is moved.
1350
+ * @event beforeMoveEvent
1351
+ * @param {Number} x x coordinate
1352
+ * @param {Number} y y coordinate
1353
+ */
1354
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
1355
+
1356
+ /**
1357
+ * CustomEvent fired after the Overlay is moved.
1358
+ * @event moveEvent
1359
+ * @param {Number} x x coordinate
1360
+ * @param {Number} y y coordinate
1361
+ */
1362
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
1363
+ };
1364
+
1365
+ /**
1366
+ * Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
1367
+ * @method initDefaultConfig
1368
+ */
1369
+ YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
1370
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
1371
+
1372
+ // Add overlay config properties //
1373
+
1374
+ /**
1375
+ * The absolute x-coordinate position of the Overlay
1376
+ * @config x
1377
+ * @type Number
1378
+ * @default null
1379
+ */
1380
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
1381
+
1382
+ /**
1383
+ * The absolute y-coordinate position of the Overlay
1384
+ * @config y
1385
+ * @type Number
1386
+ * @default null
1387
+ */
1388
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
1389
+
1390
+ /**
1391
+ * An array with the absolute x and y positions of the Overlay
1392
+ * @config xy
1393
+ * @type Number[]
1394
+ * @default null
1395
+ */
1396
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
1397
+
1398
+ /**
1399
+ * The array of context arguments for context-sensitive positioning. The format is: [id or element, element corner, context corner]. For example, setting this property to ["img1", "tl", "bl"] would align the Overlay's top left corner to the context element's bottom left corner.
1400
+ * @config context
1401
+ * @type Array
1402
+ * @default null
1403
+ */
1404
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
1405
+
1406
+ /**
1407
+ * True if the Overlay should be anchored to the center of the viewport.
1408
+ * @config fixedcenter
1409
+ * @type Boolean
1410
+ * @default false
1411
+ */
1412
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
1413
+
1414
+ /**
1415
+ * CSS width of the Overlay.
1416
+ * @config width
1417
+ * @type String
1418
+ * @default null
1419
+ */
1420
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
1421
+
1422
+ /**
1423
+ * CSS height of the Overlay.
1424
+ * @config height
1425
+ * @type String
1426
+ * @default null
1427
+ */
1428
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
1429
+
1430
+ /**
1431
+ * CSS z-index of the Overlay.
1432
+ * @config zIndex
1433
+ * @type Number
1434
+ * @default null
1435
+ */
1436
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
1437
+
1438
+ /**
1439
+ * True if the Overlay should be prevented from being positioned out of the viewport.
1440
+ * @config constraintoviewport
1441
+ * @type Boolean
1442
+ * @default false
1443
+ */
1444
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
1445
+
1446
+ /**
1447
+ * True if the Overlay should have an IFRAME shim (for correcting the select z-index bug in IE6 and below).
1448
+ * @config iframe
1449
+ * @type Boolean
1450
+ * @default true for IE6 and below, false for all others
1451
+ */
1452
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
1453
+ };
1454
+
1455
+ /**
1456
+ * Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
1457
+ * @method moveTo
1458
+ * @param {Number} x The Overlay's new x position
1459
+ * @param {Number} y The Overlay's new y position
1460
+ */
1461
+ YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
1462
+ this.cfg.setProperty("xy",[x,y]);
1463
+ };
1464
+
1465
+ /**
1466
+ * Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
1467
+ * scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
1468
+ * @method hideMacGeckoScrollbars
1469
+ */
1470
+ YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
1471
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
1472
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
1473
+ };
1474
+
1475
+ /**
1476
+ * Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
1477
+ * scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
1478
+ * @method showMacGeckoScrollbars
1479
+ */
1480
+ YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
1481
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
1482
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
1483
+ };
1484
+
1485
+ // BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
1486
+
1487
+ /**
1488
+ * The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
1489
+ * @method configVisible
1490
+ * @param {String} type The CustomEvent type (usually the property name)
1491
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1492
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1493
+ */
1494
+ YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
1495
+ var visible = args[0];
1496
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
1497
+
1498
+ if (currentVis == "inherit") {
1499
+ var e = this.element.parentNode;
1500
+ while (e.nodeType != 9 && e.nodeType != 11) {
1501
+ currentVis = YAHOO.util.Dom.getStyle(e, "visibility");
1502
+ if (currentVis != "inherit") { break; }
1503
+ e = e.parentNode;
1504
+ }
1505
+ if (currentVis == "inherit") {
1506
+ currentVis = "visible";
1507
+ }
1508
+ }
1509
+
1510
+ var effect = this.cfg.getProperty("effect");
1511
+
1512
+ var effectInstances = [];
1513
+ if (effect) {
1514
+ if (effect instanceof Array) {
1515
+ for (var i=0;i<effect.length;i++) {
1516
+ var eff = effect[i];
1517
+ effectInstances[effectInstances.length] = eff.effect(this, eff.duration);
1518
+ }
1519
+ } else {
1520
+ effectInstances[effectInstances.length] = effect.effect(this, effect.duration);
1521
+ }
1522
+ }
1523
+
1524
+ var isMacGecko = (this.platform == "mac" && this.browser == "gecko");
1525
+
1526
+ if (visible) { // Show
1527
+ if (isMacGecko) {
1528
+ this.showMacGeckoScrollbars();
1529
+ }
1530
+
1531
+ if (effect) { // Animate in
1532
+ if (visible) { // Animate in if not showing
1533
+ if (currentVis != "visible" || currentVis === "") {
1534
+ this.beforeShowEvent.fire();
1535
+ for (var j=0;j<effectInstances.length;j++) {
1536
+ var ei = effectInstances[j];
1537
+ if (j === 0 && ! YAHOO.util.Config.alreadySubscribed(ei.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) {
1538
+ ei.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete
1539
+ }
1540
+ ei.animateIn();
1541
+ }
1542
+ }
1543
+ }
1544
+ } else { // Show
1545
+ if (currentVis != "visible" || currentVis === "") {
1546
+ this.beforeShowEvent.fire();
1547
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "visible");
1548
+ this.cfg.refireEvent("iframe");
1549
+ this.showEvent.fire();
1550
+ }
1551
+ }
1552
+
1553
+ } else { // Hide
1554
+ if (isMacGecko) {
1555
+ this.hideMacGeckoScrollbars();
1556
+ }
1557
+
1558
+ if (effect) { // Animate out if showing
1559
+ if (currentVis == "visible") {
1560
+ this.beforeHideEvent.fire();
1561
+ for (var k=0;k<effectInstances.length;k++) {
1562
+ var h = effectInstances[k];
1563
+ if (k === 0 && ! YAHOO.util.Config.alreadySubscribed(h.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) {
1564
+ h.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete
1565
+ }
1566
+ h.animateOut();
1567
+ }
1568
+ } else if (currentVis === "") {
1569
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
1570
+ }
1571
+ } else { // Simple hide
1572
+ if (currentVis == "visible" || currentVis === "") {
1573
+ this.beforeHideEvent.fire();
1574
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
1575
+ this.cfg.refireEvent("iframe");
1576
+ this.hideEvent.fire();
1577
+ }
1578
+ }
1579
+ }
1580
+ };
1581
+
1582
+ /**
1583
+ * Center event handler used for centering on scroll/resize, but only if the Overlay is visible
1584
+ * @method doCenterOnDOMEvent
1585
+ */
1586
+ YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() {
1587
+ if (this.cfg.getProperty("visible")) {
1588
+ this.center();
1589
+ }
1590
+ };
1591
+
1592
+ /**
1593
+ * The default event handler fired when the "fixedcenter" property is changed.
1594
+ * @method configFixedCenter
1595
+ * @param {String} type The CustomEvent type (usually the property name)
1596
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1597
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1598
+ */
1599
+ YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) {
1600
+ var val = args[0];
1601
+
1602
+ if (val) {
1603
+ this.center();
1604
+
1605
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) {
1606
+ this.beforeShowEvent.subscribe(this.center, this, true);
1607
+ }
1608
+
1609
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) {
1610
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true);
1611
+ }
1612
+
1613
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) {
1614
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true);
1615
+ }
1616
+ } else {
1617
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
1618
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
1619
+ }
1620
+ };
1621
+
1622
+ /**
1623
+ * The default event handler fired when the "height" property is changed.
1624
+ * @method configHeight
1625
+ * @param {String} type The CustomEvent type (usually the property name)
1626
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1627
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1628
+ */
1629
+ YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) {
1630
+ var height = args[0];
1631
+ var el = this.element;
1632
+ YAHOO.util.Dom.setStyle(el, "height", height);
1633
+ this.cfg.refireEvent("iframe");
1634
+ };
1635
+
1636
+ /**
1637
+ * The default event handler fired when the "width" property is changed.
1638
+ * @method configWidth
1639
+ * @param {String} type The CustomEvent type (usually the property name)
1640
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1641
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1642
+ */
1643
+ YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) {
1644
+ var width = args[0];
1645
+ var el = this.element;
1646
+ YAHOO.util.Dom.setStyle(el, "width", width);
1647
+ this.cfg.refireEvent("iframe");
1648
+ };
1649
+
1650
+ /**
1651
+ * The default event handler fired when the "zIndex" property is changed.
1652
+ * @method configzIndex
1653
+ * @param {String} type The CustomEvent type (usually the property name)
1654
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1655
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1656
+ */
1657
+ YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) {
1658
+ var zIndex = args[0];
1659
+
1660
+ var el = this.element;
1661
+
1662
+ if (! zIndex) {
1663
+ zIndex = YAHOO.util.Dom.getStyle(el, "zIndex");
1664
+ if (! zIndex || isNaN(zIndex)) {
1665
+ zIndex = 0;
1666
+ }
1667
+ }
1668
+
1669
+ if (this.iframe) {
1670
+ if (zIndex <= 0) {
1671
+ zIndex = 1;
1672
+ }
1673
+ YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1));
1674
+ }
1675
+
1676
+ YAHOO.util.Dom.setStyle(el, "zIndex", zIndex);
1677
+ this.cfg.setProperty("zIndex", zIndex, true);
1678
+ };
1679
+
1680
+ /**
1681
+ * The default event handler fired when the "xy" property is changed.
1682
+ * @method configXY
1683
+ * @param {String} type The CustomEvent type (usually the property name)
1684
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1685
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1686
+ */
1687
+ YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) {
1688
+ var pos = args[0];
1689
+ var x = pos[0];
1690
+ var y = pos[1];
1691
+
1692
+ this.cfg.setProperty("x", x);
1693
+ this.cfg.setProperty("y", y);
1694
+
1695
+ this.beforeMoveEvent.fire([x,y]);
1696
+
1697
+ x = this.cfg.getProperty("x");
1698
+ y = this.cfg.getProperty("y");
1699
+
1700
+
1701
+ this.cfg.refireEvent("iframe");
1702
+ this.moveEvent.fire([x,y]);
1703
+ };
1704
+
1705
+ /**
1706
+ * The default event handler fired when the "x" property is changed.
1707
+ * @method configX
1708
+ * @param {String} type The CustomEvent type (usually the property name)
1709
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1710
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1711
+ */
1712
+ YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) {
1713
+ var x = args[0];
1714
+ var y = this.cfg.getProperty("y");
1715
+
1716
+ this.cfg.setProperty("x", x, true);
1717
+ this.cfg.setProperty("y", y, true);
1718
+
1719
+ this.beforeMoveEvent.fire([x,y]);
1720
+
1721
+ x = this.cfg.getProperty("x");
1722
+ y = this.cfg.getProperty("y");
1723
+
1724
+ YAHOO.util.Dom.setX(this.element, x, true);
1725
+
1726
+ this.cfg.setProperty("xy", [x, y], true);
1727
+
1728
+ this.cfg.refireEvent("iframe");
1729
+ this.moveEvent.fire([x, y]);
1730
+ };
1731
+
1732
+ /**
1733
+ * The default event handler fired when the "y" property is changed.
1734
+ * @method configY
1735
+ * @param {String} type The CustomEvent type (usually the property name)
1736
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1737
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1738
+ */
1739
+ YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) {
1740
+ var x = this.cfg.getProperty("x");
1741
+ var y = args[0];
1742
+
1743
+ this.cfg.setProperty("x", x, true);
1744
+ this.cfg.setProperty("y", y, true);
1745
+
1746
+ this.beforeMoveEvent.fire([x,y]);
1747
+
1748
+ x = this.cfg.getProperty("x");
1749
+ y = this.cfg.getProperty("y");
1750
+
1751
+ YAHOO.util.Dom.setY(this.element, y, true);
1752
+
1753
+ this.cfg.setProperty("xy", [x, y], true);
1754
+
1755
+ this.cfg.refireEvent("iframe");
1756
+ this.moveEvent.fire([x, y]);
1757
+ };
1758
+
1759
+ /**
1760
+ * Shows the iframe shim, if it has been enabled
1761
+ * @method showIframe
1762
+ */
1763
+ YAHOO.widget.Overlay.prototype.showIframe = function() {
1764
+ if (this.iframe) {
1765
+ this.iframe.style.display = "block";
1766
+ }
1767
+ };
1768
+
1769
+ /**
1770
+ * Hides the iframe shim, if it has been enabled
1771
+ * @method hideIframe
1772
+ */
1773
+ YAHOO.widget.Overlay.prototype.hideIframe = function() {
1774
+ if (this.iframe) {
1775
+ this.iframe.style.display = "none";
1776
+ }
1777
+ };
1778
+
1779
+ /**
1780
+ * The default event handler fired when the "iframe" property is changed.
1781
+ * @method configIframe
1782
+ * @param {String} type The CustomEvent type (usually the property name)
1783
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1784
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1785
+ */
1786
+ YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) {
1787
+
1788
+ var val = args[0];
1789
+
1790
+ if (val) { // IFRAME shim is enabled
1791
+
1792
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, this.showIframe, this)) {
1793
+ this.showEvent.subscribe(this.showIframe, this, true);
1794
+ }
1795
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, this.hideIframe, this)) {
1796
+ this.hideEvent.subscribe(this.hideIframe, this, true);
1797
+ }
1798
+
1799
+ var x = this.cfg.getProperty("x");
1800
+ var y = this.cfg.getProperty("y");
1801
+
1802
+ if (! x || ! y) {
1803
+ this.syncPosition();
1804
+ x = this.cfg.getProperty("x");
1805
+ y = this.cfg.getProperty("y");
1806
+ }
1807
+
1808
+
1809
+ if (! isNaN(x) && ! isNaN(y)) {
1810
+ if (! this.iframe) {
1811
+ this.iframe = document.createElement("iframe");
1812
+ if (this.isSecure) {
1813
+ this.iframe.src = YAHOO.widget.Overlay.IFRAME_SRC;
1814
+ }
1815
+
1816
+ var parent = this.element.parentNode;
1817
+ if (parent) {
1818
+ parent.appendChild(this.iframe);
1819
+ } else {
1820
+ document.body.appendChild(this.iframe);
1821
+ }
1822
+
1823
+ YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute");
1824
+ YAHOO.util.Dom.setStyle(this.iframe, "border", "none");
1825
+ YAHOO.util.Dom.setStyle(this.iframe, "margin", "0");
1826
+ YAHOO.util.Dom.setStyle(this.iframe, "padding", "0");
1827
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
1828
+ if (this.cfg.getProperty("visible")) {
1829
+ this.showIframe();
1830
+ } else {
1831
+ this.hideIframe();
1832
+ }
1833
+ }
1834
+
1835
+ var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display");
1836
+
1837
+ if (iframeDisplay == "none") {
1838
+ this.iframe.style.display = "block";
1839
+ }
1840
+
1841
+ YAHOO.util.Dom.setXY(this.iframe, [x,y]);
1842
+
1843
+ var width = this.element.clientWidth;
1844
+ var height = this.element.clientHeight;
1845
+
1846
+ YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px");
1847
+ YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px");
1848
+
1849
+ if (iframeDisplay == "none") {
1850
+ this.iframe.style.display = "none";
1851
+ }
1852
+ }
1853
+ } else {
1854
+ if (this.iframe) {
1855
+ this.iframe.style.display = "none";
1856
+ }
1857
+ this.showEvent.unsubscribe(this.showIframe, this);
1858
+ this.hideEvent.unsubscribe(this.hideIframe, this);
1859
+ }
1860
+ };
1861
+
1862
+
1863
+ /**
1864
+ * The default event handler fired when the "constraintoviewport" property is changed.
1865
+ * @method configConstrainToViewport
1866
+ * @param {String} type The CustomEvent type (usually the property name)
1867
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1868
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1869
+ */
1870
+ YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) {
1871
+ var val = args[0];
1872
+ if (val) {
1873
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) {
1874
+ this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true);
1875
+ }
1876
+ } else {
1877
+ this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this);
1878
+ }
1879
+ };
1880
+
1881
+ /**
1882
+ * The default event handler fired when the "context" property is changed.
1883
+ * @method configContext
1884
+ * @param {String} type The CustomEvent type (usually the property name)
1885
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1886
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1887
+ */
1888
+ YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) {
1889
+ var contextArgs = args[0];
1890
+
1891
+ if (contextArgs) {
1892
+ var contextEl = contextArgs[0];
1893
+ var elementMagnetCorner = contextArgs[1];
1894
+ var contextMagnetCorner = contextArgs[2];
1895
+
1896
+ if (contextEl) {
1897
+ if (typeof contextEl == "string") {
1898
+ this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true);
1899
+ }
1900
+
1901
+ if (elementMagnetCorner && contextMagnetCorner) {
1902
+ this.align(elementMagnetCorner, contextMagnetCorner);
1903
+ }
1904
+ }
1905
+ }
1906
+ };
1907
+
1908
+
1909
+ // END BUILT-IN PROPERTY EVENT HANDLERS //
1910
+
1911
+ /**
1912
+ * Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT.
1913
+ * @method align
1914
+ * @param {String} elementAlign The String representing the corner of the Overlay that should be aligned to the context element
1915
+ * @param {String} contextAlign The corner of the context element that the elementAlign corner should stick to.
1916
+ */
1917
+ YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) {
1918
+ var contextArgs = this.cfg.getProperty("context");
1919
+ if (contextArgs) {
1920
+ var context = contextArgs[0];
1921
+
1922
+ var element = this.element;
1923
+ var me = this;
1924
+
1925
+ if (! elementAlign) {
1926
+ elementAlign = contextArgs[1];
1927
+ }
1928
+
1929
+ if (! contextAlign) {
1930
+ contextAlign = contextArgs[2];
1931
+ }
1932
+
1933
+ if (element && context) {
1934
+ var contextRegion = YAHOO.util.Dom.getRegion(context);
1935
+
1936
+ var doAlign = function(v,h) {
1937
+ switch (elementAlign) {
1938
+ case YAHOO.widget.Overlay.TOP_LEFT:
1939
+ me.moveTo(h,v);
1940
+ break;
1941
+ case YAHOO.widget.Overlay.TOP_RIGHT:
1942
+ me.moveTo(h-element.offsetWidth,v);
1943
+ break;
1944
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
1945
+ me.moveTo(h,v-element.offsetHeight);
1946
+ break;
1947
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
1948
+ me.moveTo(h-element.offsetWidth,v-element.offsetHeight);
1949
+ break;
1950
+ }
1951
+ };
1952
+
1953
+ switch (contextAlign) {
1954
+ case YAHOO.widget.Overlay.TOP_LEFT:
1955
+ doAlign(contextRegion.top, contextRegion.left);
1956
+ break;
1957
+ case YAHOO.widget.Overlay.TOP_RIGHT:
1958
+ doAlign(contextRegion.top, contextRegion.right);
1959
+ break;
1960
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
1961
+ doAlign(contextRegion.bottom, contextRegion.left);
1962
+ break;
1963
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
1964
+ doAlign(contextRegion.bottom, contextRegion.right);
1965
+ break;
1966
+ }
1967
+ }
1968
+ }
1969
+ };
1970
+
1971
+ /**
1972
+ * The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true.
1973
+ * @method enforceConstraints
1974
+ * @param {String} type The CustomEvent type (usually the property name)
1975
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
1976
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
1977
+ */
1978
+ YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) {
1979
+ var pos = args[0];
1980
+
1981
+ var x = pos[0];
1982
+ var y = pos[1];
1983
+
1984
+ var offsetHeight = this.element.offsetHeight;
1985
+ var offsetWidth = this.element.offsetWidth;
1986
+
1987
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
1988
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
1989
+
1990
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
1991
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
1992
+
1993
+ var topConstraint = scrollY + 10;
1994
+ var leftConstraint = scrollX + 10;
1995
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
1996
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
1997
+
1998
+ if (x < leftConstraint) {
1999
+ x = leftConstraint;
2000
+ } else if (x > rightConstraint) {
2001
+ x = rightConstraint;
2002
+ }
2003
+
2004
+ if (y < topConstraint) {
2005
+ y = topConstraint;
2006
+ } else if (y > bottomConstraint) {
2007
+ y = bottomConstraint;
2008
+ }
2009
+
2010
+ this.cfg.setProperty("x", x, true);
2011
+ this.cfg.setProperty("y", y, true);
2012
+ this.cfg.setProperty("xy", [x,y], true);
2013
+ };
2014
+
2015
+ /**
2016
+ * Centers the container in the viewport.
2017
+ * @method center
2018
+ */
2019
+ YAHOO.widget.Overlay.prototype.center = function() {
2020
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
2021
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
2022
+
2023
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
2024
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
2025
+
2026
+ var elementWidth = this.element.offsetWidth;
2027
+ var elementHeight = this.element.offsetHeight;
2028
+
2029
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
2030
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
2031
+
2032
+ this.cfg.setProperty("xy", [parseInt(x, 10), parseInt(y, 10)]);
2033
+
2034
+ this.cfg.refireEvent("iframe");
2035
+ };
2036
+
2037
+ /**
2038
+ * Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
2039
+ * @method syncPosition
2040
+ */
2041
+ YAHOO.widget.Overlay.prototype.syncPosition = function() {
2042
+ var pos = YAHOO.util.Dom.getXY(this.element);
2043
+ this.cfg.setProperty("x", pos[0], true);
2044
+ this.cfg.setProperty("y", pos[1], true);
2045
+ this.cfg.setProperty("xy", pos, true);
2046
+ };
2047
+
2048
+ /**
2049
+ * Event handler fired when the resize monitor element is resized.
2050
+ * @method onDomResize
2051
+ * @param {DOMEvent} e The resize DOM event
2052
+ * @param {Object} obj The scope object
2053
+ */
2054
+ YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
2055
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
2056
+ var me = this;
2057
+ setTimeout(function() {
2058
+ me.syncPosition();
2059
+ me.cfg.refireEvent("iframe");
2060
+ me.cfg.refireEvent("context");
2061
+ }, 0);
2062
+ };
2063
+
2064
+ /**
2065
+ * Removes the Overlay element from the DOM and sets all child elements to null.
2066
+ * @method destroy
2067
+ */
2068
+ YAHOO.widget.Overlay.prototype.destroy = function() {
2069
+ if (this.iframe) {
2070
+ this.iframe.parentNode.removeChild(this.iframe);
2071
+ }
2072
+
2073
+ this.iframe = null;
2074
+
2075
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
2076
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
2077
+
2078
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
2079
+ };
2080
+
2081
+ /**
2082
+ * Returns a String representation of the object.
2083
+ * @method toString
2084
+ * @return {String} The string representation of the Overlay.
2085
+ */
2086
+ YAHOO.widget.Overlay.prototype.toString = function() {
2087
+ return "Overlay " + this.id;
2088
+ };
2089
+
2090
+ /**
2091
+ * A singleton CustomEvent used for reacting to the DOM event for window scroll
2092
+ * @event YAHOO.widget.Overlay.windowScrollEvent
2093
+ */
2094
+ YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
2095
+
2096
+ /**
2097
+ * A singleton CustomEvent used for reacting to the DOM event for window resize
2098
+ * @event YAHOO.widget.Overlay.windowResizeEvent
2099
+ */
2100
+ YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
2101
+
2102
+ /**
2103
+ * The DOM event handler used to fire the CustomEvent for window scroll
2104
+ * @method YAHOO.widget.Overlay.windowScrollHandler
2105
+ * @static
2106
+ * @param {DOMEvent} e The DOM scroll event
2107
+ */
2108
+ YAHOO.widget.Overlay.windowScrollHandler = function(e) {
2109
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
2110
+ if (! window.scrollEnd) {
2111
+ window.scrollEnd = -1;
2112
+ }
2113
+ clearTimeout(window.scrollEnd);
2114
+ window.scrollEnd = setTimeout(function() { YAHOO.widget.Overlay.windowScrollEvent.fire(); }, 1);
2115
+ } else {
2116
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
2117
+ }
2118
+ };
2119
+
2120
+ /**
2121
+ * The DOM event handler used to fire the CustomEvent for window resize
2122
+ * @method YAHOO.widget.Overlay.windowResizeHandler
2123
+ * @static
2124
+ * @param {DOMEvent} e The DOM resize event
2125
+ */
2126
+ YAHOO.widget.Overlay.windowResizeHandler = function(e) {
2127
+ if (YAHOO.widget.Module.prototype.browser == "ie" || YAHOO.widget.Module.prototype.browser == "ie7") {
2128
+ if (! window.resizeEnd) {
2129
+ window.resizeEnd = -1;
2130
+ }
2131
+ clearTimeout(window.resizeEnd);
2132
+ window.resizeEnd = setTimeout(function() { YAHOO.widget.Overlay.windowResizeEvent.fire(); }, 100);
2133
+ } else {
2134
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
2135
+ }
2136
+ };
2137
+
2138
+ /**
2139
+ * A boolean that indicated whether the window resize and scroll events have already been subscribed to.
2140
+ * @property YAHOO.widget.Overlay._initialized
2141
+ * @private
2142
+ * @type Boolean
2143
+ */
2144
+ YAHOO.widget.Overlay._initialized = null;
2145
+
2146
+ if (YAHOO.widget.Overlay._initialized === null) {
2147
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
2148
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
2149
+
2150
+ YAHOO.widget.Overlay._initialized = true;
2151
+ }
2152
+
2153
+ /**
2154
+ * OverlayManager is used for maintaining the focus status of multiple Overlays.* @namespace YAHOO.widget
2155
+ * @namespace YAHOO.widget
2156
+ * @class OverlayManager
2157
+ * @constructor
2158
+ * @param {Array} overlays Optional. A collection of Overlays to register with the manager.
2159
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
2160
+ */
2161
+ YAHOO.widget.OverlayManager = function(userConfig) {
2162
+ this.init(userConfig);
2163
+ };
2164
+
2165
+ /**
2166
+ * The CSS class representing a focused Overlay
2167
+ * @property YAHOO.widget.OverlayManager.CSS_FOCUSED
2168
+ * @static
2169
+ * @final
2170
+ * @type String
2171
+ */
2172
+ YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
2173
+
2174
+ YAHOO.widget.OverlayManager.prototype = {
2175
+ /**
2176
+ * The class's constructor function
2177
+ * @property contructor
2178
+ * @type Function
2179
+ */
2180
+ constructor : YAHOO.widget.OverlayManager,
2181
+
2182
+ /**
2183
+ * The array of Overlays that are currently registered
2184
+ * @property overlays
2185
+ * @type YAHOO.widget.Overlay[]
2186
+ */
2187
+ overlays : null,
2188
+
2189
+ /**
2190
+ * Initializes the default configuration of the OverlayManager
2191
+ * @method initDefaultConfig
2192
+ */
2193
+ initDefaultConfig : function() {
2194
+ /**
2195
+ * The collection of registered Overlays in use by the OverlayManager
2196
+ * @config overlays
2197
+ * @type YAHOO.widget.Overlay[]
2198
+ * @default null
2199
+ */
2200
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
2201
+
2202
+ /**
2203
+ * The default DOM event that should be used to focus an Overlay
2204
+ * @config focusevent
2205
+ * @type String
2206
+ * @default "mousedown"
2207
+ */
2208
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
2209
+ },
2210
+
2211
+ /**
2212
+ * Initializes the OverlayManager
2213
+ * @method init
2214
+ * @param {YAHOO.widget.Overlay[]} overlays Optional. A collection of Overlays to register with the manager.
2215
+ * @param {Object} userConfig The object literal representing the user configuration of the OverlayManager
2216
+ */
2217
+ init : function(userConfig) {
2218
+ /**
2219
+ * The OverlayManager's Config object used for monitoring configuration properties.
2220
+ * @property cfg
2221
+ * @type YAHOO.util.Config
2222
+ */
2223
+ this.cfg = new YAHOO.util.Config(this);
2224
+
2225
+ this.initDefaultConfig();
2226
+
2227
+ if (userConfig) {
2228
+ this.cfg.applyConfig(userConfig, true);
2229
+ }
2230
+ this.cfg.fireQueue();
2231
+
2232
+ /**
2233
+ * The currently activated Overlay
2234
+ * @property activeOverlay
2235
+ * @private
2236
+ * @type YAHOO.widget.Overlay
2237
+ */
2238
+ var activeOverlay = null;
2239
+
2240
+ /**
2241
+ * Returns the currently focused Overlay
2242
+ * @method getActive
2243
+ * @return {YAHOO.widget.Overlay} The currently focused Overlay
2244
+ */
2245
+ this.getActive = function() {
2246
+ return activeOverlay;
2247
+ };
2248
+
2249
+ /**
2250
+ * Focuses the specified Overlay
2251
+ * @method focus
2252
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to focus
2253
+ * @param {String} overlay The id of the Overlay to focus
2254
+ */
2255
+ this.focus = function(overlay) {
2256
+ var o = this.find(overlay);
2257
+ if (o) {
2258
+ this.blurAll();
2259
+ activeOverlay = o;
2260
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
2261
+ this.overlays.sort(this.compareZIndexDesc);
2262
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
2263
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
2264
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex, 10) + 2));
2265
+ }
2266
+ this.overlays.sort(this.compareZIndexDesc);
2267
+ }
2268
+ };
2269
+
2270
+ /**
2271
+ * Removes the specified Overlay from the manager
2272
+ * @method remove
2273
+ * @param {YAHOO.widget.Overlay} overlay The Overlay to remove
2274
+ * @param {String} overlay The id of the Overlay to remove
2275
+ */
2276
+ this.remove = function(overlay) {
2277
+ var o = this.find(overlay);
2278
+ if (o) {
2279
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
2280
+ o.cfg.setProperty("zIndex", -1000, true);
2281
+ this.overlays.sort(this.compareZIndexDesc);
2282
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
2283
+ o.cfg.setProperty("zIndex", originalZ, true);
2284
+
2285
+ o.cfg.setProperty("manager", null);
2286
+ o.focusEvent = null;
2287
+ o.blurEvent = null;
2288
+ o.focus = null;
2289
+ o.blur = null;
2290
+ }
2291
+ };
2292
+
2293
+ /**
2294
+ * Removes focus from all registered Overlays in the manager
2295
+ * @method blurAll
2296
+ */
2297
+ this.blurAll = function() {
2298
+ activeOverlay = null;
2299
+ for (var o=0;o<this.overlays.length;o++) {
2300
+ YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
2301
+ }
2302
+ };
2303
+
2304
+ var overlays = this.cfg.getProperty("overlays");
2305
+
2306
+ if (! this.overlays) {
2307
+ this.overlays = [];
2308
+ }
2309
+
2310
+ if (overlays) {
2311
+ this.register(overlays);
2312
+ this.overlays.sort(this.compareZIndexDesc);
2313
+ }
2314
+ },
2315
+
2316
+ /**
2317
+ * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.
2318
+ * @method register
2319
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to register with the manager.
2320
+ * @param {YAHOO.widget.Overlay[]} overlay An array of Overlays to register with the manager.
2321
+ * @return {Boolean} True if any Overlays are registered.
2322
+ */
2323
+ register : function(overlay) {
2324
+ if (overlay instanceof YAHOO.widget.Overlay) {
2325
+ overlay.cfg.addProperty("manager", { value:this } );
2326
+
2327
+ overlay.focusEvent = new YAHOO.util.CustomEvent("focus");
2328
+ overlay.blurEvent = new YAHOO.util.CustomEvent("blur");
2329
+
2330
+ var mgr=this;
2331
+
2332
+ overlay.focus = function() {
2333
+ mgr.focus(this);
2334
+ this.focusEvent.fire();
2335
+ };
2336
+
2337
+ overlay.blur = function() {
2338
+ mgr.blurAll();
2339
+ this.blurEvent.fire();
2340
+ };
2341
+
2342
+ var focusOnDomEvent = function(e,obj) {
2343
+ overlay.focus();
2344
+ };
2345
+
2346
+ var focusevent = this.cfg.getProperty("focusevent");
2347
+ YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);
2348
+
2349
+ var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex");
2350
+ if (! isNaN(zIndex)) {
2351
+ overlay.cfg.setProperty("zIndex", parseInt(zIndex, 10));
2352
+ } else {
2353
+ overlay.cfg.setProperty("zIndex", 0);
2354
+ }
2355
+
2356
+ this.overlays.push(overlay);
2357
+ return true;
2358
+ } else if (overlay instanceof Array) {
2359
+ var regcount = 0;
2360
+ for (var i=0;i<overlay.length;i++) {
2361
+ if (this.register(overlay[i])) {
2362
+ regcount++;
2363
+ }
2364
+ }
2365
+ if (regcount > 0) {
2366
+ return true;
2367
+ }
2368
+ } else {
2369
+ return false;
2370
+ }
2371
+ },
2372
+
2373
+ /**
2374
+ * Attempts to locate an Overlay by instance or ID.
2375
+ * @method find
2376
+ * @param {YAHOO.widget.Overlay} overlay An Overlay to locate within the manager
2377
+ * @param {String} overlay An Overlay id to locate within the manager
2378
+ * @return {YAHOO.widget.Overlay} The requested Overlay, if found, or null if it cannot be located.
2379
+ */
2380
+ find : function(overlay) {
2381
+ if (overlay instanceof YAHOO.widget.Overlay) {
2382
+ for (var o=0;o<this.overlays.length;o++) {
2383
+ if (this.overlays[o] == overlay) {
2384
+ return this.overlays[o];
2385
+ }
2386
+ }
2387
+ } else if (typeof overlay == "string") {
2388
+ for (var p=0;p<this.overlays.length;p++) {
2389
+ if (this.overlays[p].id == overlay) {
2390
+ return this.overlays[p];
2391
+ }
2392
+ }
2393
+ }
2394
+ return null;
2395
+ },
2396
+
2397
+ /**
2398
+ * Used for sorting the manager's Overlays by z-index.
2399
+ * @method compareZIndexDesc
2400
+ * @private
2401
+ * @return {Number} 0, 1, or -1, depending on where the Overlay should fall in the stacking order.
2402
+ */
2403
+ compareZIndexDesc : function(o1, o2) {
2404
+ var zIndex1 = o1.cfg.getProperty("zIndex");
2405
+ var zIndex2 = o2.cfg.getProperty("zIndex");
2406
+
2407
+ if (zIndex1 > zIndex2) {
2408
+ return -1;
2409
+ } else if (zIndex1 < zIndex2) {
2410
+ return 1;
2411
+ } else {
2412
+ return 0;
2413
+ }
2414
+ },
2415
+
2416
+ /**
2417
+ * Shows all Overlays in the manager.
2418
+ * @method showAll
2419
+ */
2420
+ showAll : function() {
2421
+ for (var o=0;o<this.overlays.length;o++) {
2422
+ this.overlays[o].show();
2423
+ }
2424
+ },
2425
+
2426
+ /**
2427
+ * Hides all Overlays in the manager.
2428
+ * @method hideAll
2429
+ */
2430
+ hideAll : function() {
2431
+ for (var o=0;o<this.overlays.length;o++) {
2432
+ this.overlays[o].hide();
2433
+ }
2434
+ },
2435
+
2436
+ /**
2437
+ * Returns a string representation of the object.
2438
+ * @method toString
2439
+ * @return {String} The string representation of the OverlayManager
2440
+ */
2441
+ toString : function() {
2442
+ return "OverlayManager";
2443
+ }
2444
+
2445
+ };
2446
+
2447
+ /**
2448
+ * KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements.
2449
+ * @namespace YAHOO.util
2450
+ * @class KeyListener
2451
+ * @constructor
2452
+ * @param {HTMLElement} attachTo The element or element ID to which the key event should be attached
2453
+ * @param {String} attachTo The element or element ID to which the key event should be attached
2454
+ * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
2455
+ * @param {Function} handler The CustomEvent handler to fire when the key event is detected
2456
+ * @param {Object} handler An object literal representing the handler.
2457
+ * @param {String} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown.
2458
+ */
2459
+ YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
2460
+ if (! attachTo) {
2461
+ }
2462
+ if (! keyData) {
2463
+ }
2464
+ if (! handler) {
2465
+ }
2466
+
2467
+ if (! event) {
2468
+ event = YAHOO.util.KeyListener.KEYDOWN;
2469
+ }
2470
+
2471
+ /**
2472
+ * The CustomEvent fired internally when a key is pressed
2473
+ * @event keyEvent
2474
+ * @private
2475
+ * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
2476
+ */
2477
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
2478
+
2479
+ /**
2480
+ * The CustomEvent fired when the KeyListener is enabled via the enable() function
2481
+ * @event enabledEvent
2482
+ * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
2483
+ */
2484
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
2485
+
2486
+ /**
2487
+ * The CustomEvent fired when the KeyListener is disabled via the disable() function
2488
+ * @event disabledEvent
2489
+ * @param {Object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
2490
+ */
2491
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
2492
+
2493
+ if (typeof attachTo == 'string') {
2494
+ attachTo = document.getElementById(attachTo);
2495
+ }
2496
+
2497
+ if (typeof handler == 'function') {
2498
+ keyEvent.subscribe(handler);
2499
+ } else {
2500
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
2501
+ }
2502
+
2503
+ /**
2504
+ * Handles the key event when a key is pressed.
2505
+ * @method handleKeyPress
2506
+ * @param {DOMEvent} e The keypress DOM event
2507
+ * @param {Object} obj The DOM event scope object
2508
+ * @private
2509
+ */
2510
+ function handleKeyPress(e, obj) {
2511
+ if (! keyData.shift) {
2512
+ keyData.shift = false;
2513
+ }
2514
+ if (! keyData.alt) {
2515
+ keyData.alt = false;
2516
+ }
2517
+ if (! keyData.ctrl) {
2518
+ keyData.ctrl = false;
2519
+ }
2520
+
2521
+ // check held down modifying keys first
2522
+ if (e.shiftKey == keyData.shift &&
2523
+ e.altKey == keyData.alt &&
2524
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
2525
+
2526
+ var dataItem;
2527
+ var keyPressed;
2528
+
2529
+ if (keyData.keys instanceof Array) {
2530
+ for (var i=0;i<keyData.keys.length;i++) {
2531
+ dataItem = keyData.keys[i];
2532
+
2533
+ if (dataItem == e.charCode ) {
2534
+ keyEvent.fire(e.charCode, e);
2535
+ break;
2536
+ } else if (dataItem == e.keyCode) {
2537
+ keyEvent.fire(e.keyCode, e);
2538
+ break;
2539
+ }
2540
+ }
2541
+ } else {
2542
+ dataItem = keyData.keys;
2543
+ if (dataItem == e.charCode ) {
2544
+ keyEvent.fire(e.charCode, e);
2545
+ } else if (dataItem == e.keyCode) {
2546
+ keyEvent.fire(e.keyCode, e);
2547
+ }
2548
+ }
2549
+ }
2550
+ }
2551
+
2552
+ /**
2553
+ * Enables the KeyListener by attaching the DOM event listeners to the target DOM element
2554
+ * @method enable
2555
+ */
2556
+ this.enable = function() {
2557
+ if (! this.enabled) {
2558
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
2559
+ this.enabledEvent.fire(keyData);
2560
+ }
2561
+ /**
2562
+ * Boolean indicating the enabled/disabled state of the Tooltip
2563
+ * @property enabled
2564
+ * @type Boolean
2565
+ */
2566
+ this.enabled = true;
2567
+ };
2568
+
2569
+ /**
2570
+ * Disables the KeyListener by removing the DOM event listeners from the target DOM element
2571
+ * @method disable
2572
+ */
2573
+ this.disable = function() {
2574
+ if (this.enabled) {
2575
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
2576
+ this.disabledEvent.fire(keyData);
2577
+ }
2578
+ this.enabled = false;
2579
+ };
2580
+
2581
+ /**
2582
+ * Returns a String representation of the object.
2583
+ * @method toString
2584
+ * @return {String} The string representation of the KeyListener
2585
+ */
2586
+ this.toString = function() {
2587
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : "");
2588
+ };
2589
+
2590
+ };
2591
+
2592
+ /**
2593
+ * Constant representing the DOM "keydown" event.
2594
+ * @property YAHOO.util.KeyListener.KEYDOWN
2595
+ * @static
2596
+ * @final
2597
+ * @type String
2598
+ */
2599
+ YAHOO.util.KeyListener.KEYDOWN = "keydown";
2600
+
2601
+ /**
2602
+ * Constant representing the DOM "keyup" event.
2603
+ * @property YAHOO.util.KeyListener.KEYUP
2604
+ * @static
2605
+ * @final
2606
+ * @type String
2607
+ */
2608
+ YAHOO.util.KeyListener.KEYUP = "keyup";
2609
+
2610
+ /**
2611
+ * Tooltip is an implementation of Overlay that behaves like an OS tooltip, displaying when the user mouses over a particular element, and disappearing on mouse out.
2612
+ * @namespace YAHOO.widget
2613
+ * @class Tooltip
2614
+ * @extends YAHOO.widget.Overlay
2615
+ * @constructor
2616
+ * @param {String} el The element ID representing the Tooltip <em>OR</em>
2617
+ * @param {HTMLElement} el The element representing the Tooltip
2618
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
2619
+ */
2620
+ YAHOO.widget.Tooltip = function(el, userConfig) {
2621
+ YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
2622
+ };
2623
+
2624
+ YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
2625
+
2626
+ /**
2627
+ * Constant representing the Tooltip CSS class
2628
+ * @property YAHOO.widget.Tooltip.CSS_TOOLTIP
2629
+ * @static
2630
+ * @final
2631
+ * @type String
2632
+ */
2633
+ YAHOO.widget.Tooltip.CSS_TOOLTIP = "yui-tt";
2634
+
2635
+ /**
2636
+ * The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
2637
+ * @method init
2638
+ * @param {String} el The element ID representing the Tooltip <em>OR</em>
2639
+ * @param {HTMLElement} el The element representing the Tooltip
2640
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
2641
+ */
2642
+ YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
2643
+
2644
+ if (document.readyState && document.readyState != "complete") {
2645
+ var deferredInit = function() {
2646
+ this.init(el, userConfig);
2647
+ };
2648
+ YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
2649
+ } else {
2650
+ YAHOO.widget.Tooltip.superclass.init.call(this, el);
2651
+
2652
+ this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
2653
+
2654
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
2655
+
2656
+ if (userConfig) {
2657
+ this.cfg.applyConfig(userConfig, true);
2658
+ }
2659
+
2660
+ this.cfg.queueProperty("visible",false);
2661
+ this.cfg.queueProperty("constraintoviewport",true);
2662
+
2663
+ this.setBody("");
2664
+ this.render(this.cfg.getProperty("container"));
2665
+
2666
+ this.initEvent.fire(YAHOO.widget.Tooltip);
2667
+ }
2668
+ };
2669
+
2670
+ /**
2671
+ * Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
2672
+ * @method initDefaultConfig
2673
+ */
2674
+ YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
2675
+ YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
2676
+
2677
+ /**
2678
+ * Specifies whether the Tooltip should be kept from overlapping its context element.
2679
+ * @config preventoverlap
2680
+ * @type Boolean
2681
+ * @default true
2682
+ */
2683
+ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
2684
+
2685
+ /**
2686
+ * The number of milliseconds to wait before showing a Tooltip on mouseover.
2687
+ * @config showdelay
2688
+ * @type Number
2689
+ * @default 200
2690
+ */
2691
+ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
2692
+
2693
+ /**
2694
+ * The number of milliseconds to wait before automatically dismissing a Tooltip after the mouse has been resting on the context element.
2695
+ * @config autodismissdelay
2696
+ * @type Number
2697
+ * @default 5000
2698
+ */
2699
+ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
2700
+
2701
+ /**
2702
+ * The number of milliseconds to wait before hiding a Tooltip on mouseover.
2703
+ * @config hidedelay
2704
+ * @type Number
2705
+ * @default 250
2706
+ */
2707
+ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
2708
+
2709
+ /**
2710
+ * Specifies the Tooltip's text.
2711
+ * @config text
2712
+ * @type String
2713
+ * @default null
2714
+ */
2715
+ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
2716
+
2717
+ /**
2718
+ * Specifies the container element that the Tooltip's markup should be rendered into.
2719
+ * @config container
2720
+ * @type HTMLElement/String
2721
+ * @default document.body
2722
+ */
2723
+ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
2724
+
2725
+ /**
2726
+ * Specifies the element or elements that the Tooltip should be anchored to on mouseover.
2727
+ * @config context
2728
+ * @type HTMLElement[]/String[]
2729
+ * @default null
2730
+ */
2731
+
2732
+ };
2733
+
2734
+ // BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
2735
+
2736
+ /**
2737
+ * The default event handler fired when the "text" property is changed.
2738
+ * @method configText
2739
+ * @param {String} type The CustomEvent type (usually the property name)
2740
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
2741
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
2742
+ */
2743
+ YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
2744
+ var text = args[0];
2745
+ if (text) {
2746
+ this.setBody(text);
2747
+ }
2748
+ };
2749
+
2750
+ /**
2751
+ * The default event handler fired when the "container" property is changed.
2752
+ * @method configContainer
2753
+ * @param {String} type The CustomEvent type (usually the property name)
2754
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
2755
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
2756
+ */
2757
+ YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
2758
+ var container = args[0];
2759
+ if (typeof container == 'string') {
2760
+ this.cfg.setProperty("container", document.getElementById(container), true);
2761
+ }
2762
+ };
2763
+
2764
+ /**
2765
+ * The default event handler fired when the "context" property is changed.
2766
+ * @method configContext
2767
+ * @param {String} type The CustomEvent type (usually the property name)
2768
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
2769
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
2770
+ */
2771
+ YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
2772
+ var context = args[0];
2773
+ if (context) {
2774
+
2775
+ // Normalize parameter into an array
2776
+ if (! (context instanceof Array)) {
2777
+ if (typeof context == "string") {
2778
+ this.cfg.setProperty("context", [document.getElementById(context)], true);
2779
+ } else { // Assuming this is an element
2780
+ this.cfg.setProperty("context", [context], true);
2781
+ }
2782
+ context = this.cfg.getProperty("context");
2783
+ }
2784
+
2785
+
2786
+ // Remove any existing mouseover/mouseout listeners
2787
+ if (this._context) {
2788
+ for (var c=0;c<this._context.length;++c) {
2789
+ var el = this._context[c];
2790
+ YAHOO.util.Event.removeListener(el, "mouseover", this.onContextMouseOver);
2791
+ YAHOO.util.Event.removeListener(el, "mousemove", this.onContextMouseMove);
2792
+ YAHOO.util.Event.removeListener(el, "mouseout", this.onContextMouseOut);
2793
+ }
2794
+ }
2795
+
2796
+ // Add mouseover/mouseout listeners to context elements
2797
+ this._context = context;
2798
+ for (var d=0;d<this._context.length;++d) {
2799
+ var el2 = this._context[d];
2800
+ YAHOO.util.Event.addListener(el2, "mouseover", this.onContextMouseOver, this);
2801
+ YAHOO.util.Event.addListener(el2, "mousemove", this.onContextMouseMove, this);
2802
+ YAHOO.util.Event.addListener(el2, "mouseout", this.onContextMouseOut, this);
2803
+ }
2804
+ }
2805
+ };
2806
+
2807
+ // END BUILT-IN PROPERTY EVENT HANDLERS //
2808
+
2809
+ // BEGIN BUILT-IN DOM EVENT HANDLERS //
2810
+
2811
+ /**
2812
+ * The default event handler fired when the user moves the mouse while over the context element.
2813
+ * @method onContextMouseMove
2814
+ * @param {DOMEvent} e The current DOM event
2815
+ * @param {Object} obj The object argument
2816
+ */
2817
+ YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) {
2818
+ obj.pageX = YAHOO.util.Event.getPageX(e);
2819
+ obj.pageY = YAHOO.util.Event.getPageY(e);
2820
+
2821
+ };
2822
+
2823
+ /**
2824
+ * The default event handler fired when the user mouses over the context element.
2825
+ * @method onContextMouseOver
2826
+ * @param {DOMEvent} e The current DOM event
2827
+ * @param {Object} obj The object argument
2828
+ */
2829
+ YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) {
2830
+
2831
+ if (obj.hideProcId) {
2832
+ clearTimeout(obj.hideProcId);
2833
+ obj.hideProcId = null;
2834
+ }
2835
+
2836
+ var context = this;
2837
+ YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj);
2838
+
2839
+ if (context.title) {
2840
+ obj._tempTitle = context.title;
2841
+ context.title = "";
2842
+ }
2843
+
2844
+ /**
2845
+ * The unique process ID associated with the thread responsible for showing the Tooltip.
2846
+ * @type int
2847
+ */
2848
+ obj.showProcId = obj.doShow(e, context);
2849
+ };
2850
+
2851
+ /**
2852
+ * The default event handler fired when the user mouses out of the context element.
2853
+ * @method onContextMouseOut
2854
+ * @param {DOMEvent} e The current DOM event
2855
+ * @param {Object} obj The object argument
2856
+ */
2857
+ YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) {
2858
+ var el = this;
2859
+
2860
+ if (obj._tempTitle) {
2861
+ el.title = obj._tempTitle;
2862
+ obj._tempTitle = null;
2863
+ }
2864
+
2865
+ if (obj.showProcId) {
2866
+ clearTimeout(obj.showProcId);
2867
+ obj.showProcId = null;
2868
+ }
2869
+
2870
+ if (obj.hideProcId) {
2871
+ clearTimeout(obj.hideProcId);
2872
+ obj.hideProcId = null;
2873
+ }
2874
+
2875
+
2876
+ obj.hideProcId = setTimeout(function() {
2877
+ obj.hide();
2878
+ }, obj.cfg.getProperty("hidedelay"));
2879
+ };
2880
+
2881
+ // END BUILT-IN DOM EVENT HANDLERS //
2882
+
2883
+ /**
2884
+ * Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip.
2885
+ * @method doShow
2886
+ * @param {DOMEvent} e The current DOM event
2887
+ * @return {Number} The process ID of the timeout function associated with doShow
2888
+ */
2889
+ YAHOO.widget.Tooltip.prototype.doShow = function(e, context) {
2890
+
2891
+ var yOffset = 25;
2892
+ if (this.browser == "opera" && context.tagName == "A") {
2893
+ yOffset += 12;
2894
+ }
2895
+
2896
+ var me = this;
2897
+ return setTimeout(
2898
+ function() {
2899
+ if (me._tempTitle) {
2900
+ me.setBody(me._tempTitle);
2901
+ } else {
2902
+ me.cfg.refireEvent("text");
2903
+ }
2904
+
2905
+ me.moveTo(me.pageX, me.pageY + yOffset);
2906
+ if (me.cfg.getProperty("preventoverlap")) {
2907
+ me.preventOverlap(me.pageX, me.pageY);
2908
+ }
2909
+
2910
+ YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove);
2911
+
2912
+ me.show();
2913
+ me.hideProcId = me.doHide();
2914
+ },
2915
+ this.cfg.getProperty("showdelay"));
2916
+ };
2917
+
2918
+ /**
2919
+ * Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed.
2920
+ * @method doHide
2921
+ */
2922
+ YAHOO.widget.Tooltip.prototype.doHide = function() {
2923
+ var me = this;
2924
+ return setTimeout(
2925
+ function() {
2926
+ me.hide();
2927
+ },
2928
+ this.cfg.getProperty("autodismissdelay"));
2929
+ };
2930
+
2931
+ /**
2932
+ * Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element.
2933
+ * @method preventOverlay
2934
+ * @param {Number} pageX The x coordinate position of the mouse pointer
2935
+ * @param {Number} pageY The y coordinate position of the mouse pointer
2936
+ */
2937
+ YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) {
2938
+
2939
+ var height = this.element.offsetHeight;
2940
+
2941
+ var elementRegion = YAHOO.util.Dom.getRegion(this.element);
2942
+
2943
+ elementRegion.top -= 5;
2944
+ elementRegion.left -= 5;
2945
+ elementRegion.right += 5;
2946
+ elementRegion.bottom += 5;
2947
+
2948
+ var mousePoint = new YAHOO.util.Point(pageX, pageY);
2949
+
2950
+
2951
+ if (elementRegion.contains(mousePoint)) {
2952
+ this.cfg.setProperty("y", (pageY-height-5));
2953
+ }
2954
+ };
2955
+
2956
+ /**
2957
+ * Returns a string representation of the object.
2958
+ * @method toString
2959
+ * @return {String} The string representation of the Tooltip
2960
+ */
2961
+ YAHOO.widget.Tooltip.prototype.toString = function() {
2962
+ return "Tooltip " + this.id;
2963
+ };
2964
+
2965
+ /**
2966
+ * Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right.
2967
+ * @namespace YAHOO.widget
2968
+ * @class Panel
2969
+ * @extends YAHOO.widget.Overlay
2970
+ * @constructor
2971
+ * @param {String} el The element ID representing the Panel <em>OR</em>
2972
+ * @param {HTMLElement} el The element representing the Panel
2973
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
2974
+ */
2975
+ YAHOO.widget.Panel = function(el, userConfig) {
2976
+ YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
2977
+ };
2978
+
2979
+ YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
2980
+
2981
+ /**
2982
+ * Constant representing the default CSS class used for a Panel
2983
+ * @property YAHOO.widget.Panel.CSS_PANEL
2984
+ * @static
2985
+ * @final
2986
+ * @type String
2987
+ */
2988
+ YAHOO.widget.Panel.CSS_PANEL = "yui-panel";
2989
+
2990
+ /**
2991
+ * Constant representing the default CSS class used for a Panel's wrapping container
2992
+ * @property YAHOO.widget.Panel.CSS_PANEL_CONTAINER
2993
+ * @static
2994
+ * @final
2995
+ * @type String
2996
+ */
2997
+ YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "yui-panel-container";
2998
+
2999
+ /**
3000
+ * The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
3001
+ * @method init
3002
+ * @param {String} el The element ID representing the Overlay <em>OR</em>
3003
+ * @param {HTMLElement} el The element representing the Overlay
3004
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
3005
+ */
3006
+ YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
3007
+ YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
3008
+
3009
+ this.beforeInitEvent.fire(YAHOO.widget.Panel);
3010
+
3011
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
3012
+
3013
+ this.buildWrapper();
3014
+
3015
+ if (userConfig) {
3016
+ this.cfg.applyConfig(userConfig, true);
3017
+ }
3018
+
3019
+ this.beforeRenderEvent.subscribe(function() {
3020
+ var draggable = this.cfg.getProperty("draggable");
3021
+ if (draggable) {
3022
+ if (! this.header) {
3023
+ this.setHeader("&#160;");
3024
+ }
3025
+ }
3026
+ }, this, true);
3027
+
3028
+ var me = this;
3029
+
3030
+ var doBlur = function() {
3031
+ this.blur();
3032
+ };
3033
+
3034
+ this.showMaskEvent.subscribe(function() {
3035
+ var checkFocusable = function(el) {
3036
+ if ((el.tagName == "A" || el.tagName == "BUTTON" || el.tagName == "SELECT" || el.tagName == "INPUT" || el.tagName == "TEXTAREA") && el.type != "hidden") {
3037
+ if (! YAHOO.util.Dom.isAncestor(me.element, el)) {
3038
+ YAHOO.util.Event.addListener(el, "focus", doBlur, el, true);
3039
+ return true;
3040
+ }
3041
+ } else {
3042
+ return false;
3043
+ }
3044
+ };
3045
+
3046
+ this.focusableElements = YAHOO.util.Dom.getElementsBy(checkFocusable);
3047
+ }, this, true);
3048
+
3049
+ this.hideMaskEvent.subscribe(function() {
3050
+ for (var i=0;i<this.focusableElements.length;i++) {
3051
+ var el2 = this.focusableElements[i];
3052
+ YAHOO.util.Event.removeListener(el2, "focus", doBlur);
3053
+ }
3054
+ }, this, true);
3055
+
3056
+ this.beforeShowEvent.subscribe(function() {
3057
+ this.cfg.refireEvent("underlay");
3058
+ }, this, true);
3059
+ this.initEvent.fire(YAHOO.widget.Panel);
3060
+ };
3061
+
3062
+ /**
3063
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
3064
+ */
3065
+ YAHOO.widget.Panel.prototype.initEvents = function() {
3066
+ YAHOO.widget.Panel.superclass.initEvents.call(this);
3067
+
3068
+ /**
3069
+ * CustomEvent fired after the modality mask is shown
3070
+ * @event showMaskEvent
3071
+ */
3072
+ this.showMaskEvent = new YAHOO.util.CustomEvent("showMask");
3073
+
3074
+ /**
3075
+ * CustomEvent fired after the modality mask is hidden
3076
+ * @event hideMaskEvent
3077
+ */
3078
+ this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask");
3079
+
3080
+ /**
3081
+ * CustomEvent when the Panel is dragged
3082
+ * @event dragEvent
3083
+ */
3084
+ this.dragEvent = new YAHOO.util.CustomEvent("drag");
3085
+ };
3086
+
3087
+ /**
3088
+ * Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg).
3089
+ * @method initDefaultConfig
3090
+ */
3091
+ YAHOO.widget.Panel.prototype.initDefaultConfig = function() {
3092
+ YAHOO.widget.Panel.superclass.initDefaultConfig.call(this);
3093
+
3094
+ // Add panel config properties //
3095
+
3096
+ /**
3097
+ * True if the Panel should display a "close" button
3098
+ * @config close
3099
+ * @type Boolean
3100
+ * @default true
3101
+ */
3102
+ this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
3103
+
3104
+ /**
3105
+ * True if the Panel should be draggable
3106
+ * @config draggable
3107
+ * @type Boolean
3108
+ * @default true
3109
+ */
3110
+ this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
3111
+
3112
+ /**
3113
+ * Sets the type of underlay to display for the Panel. Valid values are "shadow", "matte", and "none".
3114
+ * @config underlay
3115
+ * @type String
3116
+ * @default shadow
3117
+ */
3118
+ this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } );
3119
+
3120
+ /**
3121
+ * True if the Panel should be displayed in a modal fashion, automatically creating a transparent mask over the document that will not be removed until the Panel is dismissed.
3122
+ * @config modal
3123
+ * @type Boolean
3124
+ * @default false
3125
+ */
3126
+ this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
3127
+
3128
+ /**
3129
+ * A KeyListener (or array of KeyListeners) that will be enabled when the Panel is shown, and disabled when the Panel is hidden.
3130
+ * @config keylisteners
3131
+ * @type YAHOO.util.KeyListener[]
3132
+ * @default null
3133
+ */
3134
+ this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } );
3135
+ };
3136
+
3137
+ // BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
3138
+
3139
+ /**
3140
+ * The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel.
3141
+ * @method configClose
3142
+ * @param {String} type The CustomEvent type (usually the property name)
3143
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3144
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3145
+ */
3146
+ YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) {
3147
+ var val = args[0];
3148
+
3149
+ var doHide = function(e, obj) {
3150
+ obj.hide();
3151
+ };
3152
+
3153
+ if (val) {
3154
+ if (! this.close) {
3155
+ this.close = document.createElement("span");
3156
+ YAHOO.util.Dom.addClass(this.close, "container-close");
3157
+ this.close.innerHTML = "&#160;";
3158
+ this.innerElement.appendChild(this.close);
3159
+ YAHOO.util.Event.addListener(this.close, "click", doHide, this);
3160
+ } else {
3161
+ this.close.style.display = "block";
3162
+ }
3163
+ } else {
3164
+ if (this.close) {
3165
+ this.close.style.display = "none";
3166
+ }
3167
+ }
3168
+ };
3169
+
3170
+ /**
3171
+ * The default event handler fired when the "draggable" property is changed.
3172
+ * @method configDraggable
3173
+ * @param {String} type The CustomEvent type (usually the property name)
3174
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3175
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3176
+ */
3177
+ YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) {
3178
+ var val = args[0];
3179
+ if (val) {
3180
+ if (this.header) {
3181
+ YAHOO.util.Dom.setStyle(this.header,"cursor","move");
3182
+ this.registerDragDrop();
3183
+ }
3184
+ } else {
3185
+ if (this.dd) {
3186
+ this.dd.unreg();
3187
+ }
3188
+ if (this.header) {
3189
+ YAHOO.util.Dom.setStyle(this.header,"cursor","auto");
3190
+ }
3191
+ }
3192
+ };
3193
+
3194
+ /**
3195
+ * The default event handler fired when the "underlay" property is changed.
3196
+ * @method configUnderlay
3197
+ * @param {String} type The CustomEvent type (usually the property name)
3198
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3199
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3200
+ */
3201
+ YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) {
3202
+ var val = args[0];
3203
+
3204
+ switch (val.toLowerCase()) {
3205
+ case "shadow":
3206
+ YAHOO.util.Dom.removeClass(this.element, "matte");
3207
+ YAHOO.util.Dom.addClass(this.element, "shadow");
3208
+
3209
+ if (! this.underlay) { // create if not already in DOM
3210
+ this.underlay = document.createElement("div");
3211
+ this.underlay.className = "underlay";
3212
+ this.underlay.innerHTML = "&#160;";
3213
+ this.element.appendChild(this.underlay);
3214
+ }
3215
+
3216
+ this.sizeUnderlay();
3217
+ break;
3218
+ case "matte":
3219
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
3220
+ YAHOO.util.Dom.addClass(this.element, "matte");
3221
+ break;
3222
+ default:
3223
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
3224
+ YAHOO.util.Dom.removeClass(this.element, "matte");
3225
+ break;
3226
+ }
3227
+ };
3228
+
3229
+ /**
3230
+ * The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask.
3231
+ * @method configModal
3232
+ * @param {String} type The CustomEvent type (usually the property name)
3233
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3234
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3235
+ */
3236
+ YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) {
3237
+ var modal = args[0];
3238
+
3239
+ if (modal) {
3240
+ this.buildMask();
3241
+
3242
+ if (! YAHOO.util.Config.alreadySubscribed( this.beforeShowEvent, this.showMask, this ) ) {
3243
+ this.beforeShowEvent.subscribe(this.showMask, this, true);
3244
+ }
3245
+ if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) {
3246
+ this.hideEvent.subscribe(this.hideMask, this, true);
3247
+ }
3248
+ if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) {
3249
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true);
3250
+ }
3251
+ if (! YAHOO.util.Config.alreadySubscribed( this.destroyEvent, this.removeMask, this) ) {
3252
+ this.destroyEvent.subscribe(this.removeMask, this, true);
3253
+ }
3254
+
3255
+ this.cfg.refireEvent("zIndex");
3256
+ } else {
3257
+ this.beforeShowEvent.unsubscribe(this.showMask, this);
3258
+ this.hideEvent.unsubscribe(this.hideMask, this);
3259
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask, this);
3260
+ this.destroyEvent.unsubscribe(this.removeMask, this);
3261
+ }
3262
+ };
3263
+
3264
+ /**
3265
+ * Removes the modality mask.
3266
+ * @method removeMask
3267
+ */
3268
+ YAHOO.widget.Panel.prototype.removeMask = function() {
3269
+ if (this.mask) {
3270
+ if (this.mask.parentNode) {
3271
+ this.mask.parentNode.removeChild(this.mask);
3272
+ }
3273
+ this.mask = null;
3274
+ }
3275
+ };
3276
+
3277
+ /**
3278
+ * The default event handler fired when the "keylisteners" property is changed.
3279
+ * @method configKeyListeners
3280
+ * @param {String} type The CustomEvent type (usually the property name)
3281
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3282
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3283
+ */
3284
+ YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) {
3285
+ var listeners = args[0];
3286
+
3287
+ if (listeners) {
3288
+ if (listeners instanceof Array) {
3289
+ for (var i=0;i<listeners.length;i++) {
3290
+ var listener = listeners[i];
3291
+
3292
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listener.enable, listener)) {
3293
+ this.showEvent.subscribe(listener.enable, listener, true);
3294
+ }
3295
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listener.disable, listener)) {
3296
+ this.hideEvent.subscribe(listener.disable, listener, true);
3297
+ this.destroyEvent.subscribe(listener.disable, listener, true);
3298
+ }
3299
+ }
3300
+ } else {
3301
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listeners.enable, listeners)) {
3302
+ this.showEvent.subscribe(listeners.enable, listeners, true);
3303
+ }
3304
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listeners.disable, listeners)) {
3305
+ this.hideEvent.subscribe(listeners.disable, listeners, true);
3306
+ this.destroyEvent.subscribe(listeners.disable, listeners, true);
3307
+ }
3308
+ }
3309
+ }
3310
+ };
3311
+
3312
+ /**
3313
+ * The default event handler fired when the "height" property is changed.
3314
+ * @method configHeight
3315
+ * @param {String} type The CustomEvent type (usually the property name)
3316
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3317
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3318
+ */
3319
+ YAHOO.widget.Panel.prototype.configHeight = function(type, args, obj) {
3320
+ var height = args[0];
3321
+ var el = this.innerElement;
3322
+ YAHOO.util.Dom.setStyle(el, "height", height);
3323
+ this.cfg.refireEvent("underlay");
3324
+ this.cfg.refireEvent("iframe");
3325
+ };
3326
+
3327
+ /**
3328
+ * The default event handler fired when the "width" property is changed.
3329
+ * @method configWidth
3330
+ * @param {String} type The CustomEvent type (usually the property name)
3331
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3332
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3333
+ */
3334
+ YAHOO.widget.Panel.prototype.configWidth = function(type, args, obj) {
3335
+ var width = args[0];
3336
+ var el = this.innerElement;
3337
+ YAHOO.util.Dom.setStyle(el, "width", width);
3338
+ this.cfg.refireEvent("underlay");
3339
+ this.cfg.refireEvent("iframe");
3340
+ };
3341
+
3342
+ /**
3343
+ * The default event handler fired when the "zIndex" property is changed.
3344
+ * @method configzIndex
3345
+ * @param {String} type The CustomEvent type (usually the property name)
3346
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3347
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3348
+ */
3349
+ YAHOO.widget.Panel.prototype.configzIndex = function(type, args, obj) {
3350
+ YAHOO.widget.Panel.superclass.configzIndex.call(this, type, args, obj);
3351
+
3352
+ var maskZ = 0;
3353
+ var currentZ = YAHOO.util.Dom.getStyle(this.element, "zIndex");
3354
+
3355
+ if (this.mask) {
3356
+ if (! currentZ || isNaN(currentZ)) {
3357
+ currentZ = 0;
3358
+ }
3359
+
3360
+ if (currentZ === 0) {
3361
+ this.cfg.setProperty("zIndex", 1);
3362
+ } else {
3363
+ maskZ = currentZ - 1;
3364
+ YAHOO.util.Dom.setStyle(this.mask, "zIndex", maskZ);
3365
+ }
3366
+
3367
+ }
3368
+ };
3369
+
3370
+ // END BUILT-IN PROPERTY EVENT HANDLERS //
3371
+
3372
+
3373
+ /**
3374
+ * Builds the wrapping container around the Panel that is used for positioning the shadow and matte underlays. The container element is assigned to a local instance variable called container, and the element is reinserted inside of it.
3375
+ * @method buildWrapper
3376
+ */
3377
+ YAHOO.widget.Panel.prototype.buildWrapper = function() {
3378
+ var elementParent = this.element.parentNode;
3379
+ var originalElement = this.element;
3380
+
3381
+ var wrapper = document.createElement("div");
3382
+ wrapper.className = YAHOO.widget.Panel.CSS_PANEL_CONTAINER;
3383
+ wrapper.id = originalElement.id + "_c";
3384
+
3385
+ if (elementParent) {
3386
+ elementParent.insertBefore(wrapper, originalElement);
3387
+ }
3388
+
3389
+ wrapper.appendChild(originalElement);
3390
+
3391
+ this.element = wrapper;
3392
+ this.innerElement = originalElement;
3393
+
3394
+ YAHOO.util.Dom.setStyle(this.innerElement, "visibility", "inherit");
3395
+ };
3396
+
3397
+ /**
3398
+ * Adjusts the size of the shadow based on the size of the element.
3399
+ * @method sizeUnderlay
3400
+ */
3401
+ YAHOO.widget.Panel.prototype.sizeUnderlay = function() {
3402
+ if (this.underlay && this.browser != "gecko" && this.browser != "safari") {
3403
+ this.underlay.style.width = this.innerElement.offsetWidth + "px";
3404
+ this.underlay.style.height = this.innerElement.offsetHeight + "px";
3405
+ }
3406
+ };
3407
+
3408
+ /**
3409
+ * Event handler fired when the resize monitor element is resized.
3410
+ * @method onDomResize
3411
+ * @param {DOMEvent} e The resize DOM event
3412
+ * @param {Object} obj The scope object
3413
+ */
3414
+ YAHOO.widget.Panel.prototype.onDomResize = function(e, obj) {
3415
+ YAHOO.widget.Panel.superclass.onDomResize.call(this, e, obj);
3416
+ var me = this;
3417
+ setTimeout(function() {
3418
+ me.sizeUnderlay();
3419
+ }, 0);
3420
+ };
3421
+
3422
+ /**
3423
+ * Registers the Panel's header for drag & drop capability.
3424
+ * @method registerDragDrop
3425
+ */
3426
+ YAHOO.widget.Panel.prototype.registerDragDrop = function() {
3427
+ if (this.header) {
3428
+ this.dd = new YAHOO.util.DD(this.element.id, this.id);
3429
+
3430
+ if (! this.header.id) {
3431
+ this.header.id = this.id + "_h";
3432
+ }
3433
+
3434
+ var me = this;
3435
+
3436
+ this.dd.startDrag = function() {
3437
+
3438
+ if (me.browser == "ie") {
3439
+ YAHOO.util.Dom.addClass(me.element,"drag");
3440
+ }
3441
+
3442
+ if (me.cfg.getProperty("constraintoviewport")) {
3443
+ var offsetHeight = me.element.offsetHeight;
3444
+ var offsetWidth = me.element.offsetWidth;
3445
+
3446
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
3447
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
3448
+
3449
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
3450
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
3451
+
3452
+ var topConstraint = scrollY + 10;
3453
+ var leftConstraint = scrollX + 10;
3454
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
3455
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
3456
+
3457
+ this.minX = leftConstraint;
3458
+ this.maxX = rightConstraint;
3459
+ this.constrainX = true;
3460
+
3461
+ this.minY = topConstraint;
3462
+ this.maxY = bottomConstraint;
3463
+ this.constrainY = true;
3464
+ } else {
3465
+ this.constrainX = false;
3466
+ this.constrainY = false;
3467
+ }
3468
+
3469
+ me.dragEvent.fire("startDrag", arguments);
3470
+ };
3471
+
3472
+ this.dd.onDrag = function() {
3473
+ me.syncPosition();
3474
+ me.cfg.refireEvent("iframe");
3475
+ if (this.platform == "mac" && this.browser == "gecko") {
3476
+ this.showMacGeckoScrollbars();
3477
+ }
3478
+
3479
+ me.dragEvent.fire("onDrag", arguments);
3480
+ };
3481
+
3482
+ this.dd.endDrag = function() {
3483
+ if (me.browser == "ie") {
3484
+ YAHOO.util.Dom.removeClass(me.element,"drag");
3485
+ }
3486
+
3487
+ me.dragEvent.fire("endDrag", arguments);
3488
+ };
3489
+
3490
+ this.dd.setHandleElId(this.header.id);
3491
+ this.dd.addInvalidHandleType("INPUT");
3492
+ this.dd.addInvalidHandleType("SELECT");
3493
+ this.dd.addInvalidHandleType("TEXTAREA");
3494
+ }
3495
+ };
3496
+
3497
+ /**
3498
+ * Builds the mask that is laid over the document when the Panel is configured to be modal.
3499
+ * @method buildMask
3500
+ */
3501
+ YAHOO.widget.Panel.prototype.buildMask = function() {
3502
+ if (! this.mask) {
3503
+ this.mask = document.createElement("div");
3504
+ this.mask.id = this.id + "_mask";
3505
+ this.mask.className = "mask";
3506
+ this.mask.innerHTML = "&#160;";
3507
+
3508
+ var maskClick = function(e, obj) {
3509
+ YAHOO.util.Event.stopEvent(e);
3510
+ };
3511
+
3512
+ var firstChild = document.body.firstChild;
3513
+ if (firstChild) {
3514
+ document.body.insertBefore(this.mask, document.body.firstChild);
3515
+ } else {
3516
+ document.body.appendChild(this.mask);
3517
+ }
3518
+ }
3519
+ };
3520
+
3521
+ /**
3522
+ * Hides the modality mask.
3523
+ * @method hideMask
3524
+ */
3525
+ YAHOO.widget.Panel.prototype.hideMask = function() {
3526
+ if (this.cfg.getProperty("modal") && this.mask) {
3527
+ this.mask.style.display = "none";
3528
+ this.hideMaskEvent.fire();
3529
+ YAHOO.util.Dom.removeClass(document.body, "masked");
3530
+ }
3531
+ };
3532
+
3533
+ /**
3534
+ * Shows the modality mask.
3535
+ * @method showMask
3536
+ */
3537
+ YAHOO.widget.Panel.prototype.showMask = function() {
3538
+ if (this.cfg.getProperty("modal") && this.mask) {
3539
+ YAHOO.util.Dom.addClass(document.body, "masked");
3540
+ this.sizeMask();
3541
+ this.mask.style.display = "block";
3542
+ this.showMaskEvent.fire();
3543
+ }
3544
+ };
3545
+
3546
+ /**
3547
+ * Sets the size of the modality mask to cover the entire scrollable area of the document
3548
+ * @method sizeMask
3549
+ */
3550
+ YAHOO.widget.Panel.prototype.sizeMask = function() {
3551
+ if (this.mask) {
3552
+ this.mask.style.height = YAHOO.util.Dom.getDocumentHeight()+"px";
3553
+ this.mask.style.width = YAHOO.util.Dom.getDocumentWidth()+"px";
3554
+ }
3555
+ };
3556
+
3557
+ /**
3558
+ * Renders the Panel by inserting the elements that are not already in the main Panel into their correct places. Optionally appends the Panel to the specified node prior to the render's execution. NOTE: For Panels without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
3559
+ * @method render
3560
+ * @param {String} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
3561
+ * @param {HTMLElement} appendToNode The element to which the Module should be appended to prior to rendering
3562
+ * @return {boolean} Success or failure of the render
3563
+ */
3564
+ YAHOO.widget.Panel.prototype.render = function(appendToNode) {
3565
+ return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
3566
+ };
3567
+
3568
+ /**
3569
+ * Returns a String representation of the object.
3570
+ * @method toString
3571
+ * @return {String} The string representation of the Panel.
3572
+ */
3573
+ YAHOO.widget.Panel.prototype.toString = function() {
3574
+ return "Panel " + this.id;
3575
+ };
3576
+
3577
+ /**
3578
+ * Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
3579
+ * @namespace YAHOO.widget
3580
+ * @class Dialog
3581
+ * @extends YAHOO.widget.Panel
3582
+ * @constructor
3583
+ * @param {String} el The element ID representing the Dialog <em>OR</em>
3584
+ * @param {HTMLElement} el The element representing the Dialog
3585
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
3586
+ */
3587
+ YAHOO.widget.Dialog = function(el, userConfig) {
3588
+ YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
3589
+ };
3590
+
3591
+ YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
3592
+
3593
+ /**
3594
+ * Constant representing the default CSS class used for a Dialog
3595
+ * @property YAHOO.widget.Dialog.CSS_DIALOG
3596
+ * @static
3597
+ * @final
3598
+ * @type String
3599
+ */
3600
+ YAHOO.widget.Dialog.CSS_DIALOG = "yui-dialog";
3601
+
3602
+ /**
3603
+ * Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
3604
+ * @method initDefaultConfig
3605
+ */
3606
+ YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
3607
+ YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
3608
+
3609
+ /**
3610
+ * The internally maintained callback object for use with the Connection utility
3611
+ * @property callback
3612
+ * @type Object
3613
+ */
3614
+ this.callback = {
3615
+ /**
3616
+ * The function to execute upon success of the Connection submission
3617
+ * @property callback.success
3618
+ * @type Function
3619
+ */
3620
+ success : null,
3621
+ /**
3622
+ * The function to execute upon failure of the Connection submission
3623
+ * @property callback.failure
3624
+ * @type Function
3625
+ */
3626
+ failure : null,
3627
+ /**
3628
+ * The arbitraty argument or arguments to pass to the Connection callback functions
3629
+ * @property callback.argument
3630
+ * @type Object
3631
+ */
3632
+ argument: null
3633
+ };
3634
+
3635
+ // Add form dialog config properties //
3636
+
3637
+ /**
3638
+ * The method to use for posting the Dialog's form. Possible values are "async", "form", and "manual".
3639
+ * @config postmethod
3640
+ * @type String
3641
+ * @default async
3642
+ */
3643
+ this.cfg.addProperty("postmethod", { value:"async", handler:this.configPostMethod, validator:function(val) {
3644
+ if (val != "form" && val != "async" && val != "none" && val != "manual") {
3645
+ return false;
3646
+ } else {
3647
+ return true;
3648
+ }
3649
+ } });
3650
+
3651
+ /**
3652
+ * Object literal(s) defining the buttons for the Dialog's footer.
3653
+ * @config buttons
3654
+ * @type Object[]
3655
+ * @default "none"
3656
+ */
3657
+ this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
3658
+ };
3659
+
3660
+ /**
3661
+ * Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
3662
+ * @method initEvents
3663
+ */
3664
+ YAHOO.widget.Dialog.prototype.initEvents = function() {
3665
+ YAHOO.widget.Dialog.superclass.initEvents.call(this);
3666
+
3667
+ /**
3668
+ * CustomEvent fired prior to submission
3669
+ * @event beforeSumitEvent
3670
+ */
3671
+ this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
3672
+
3673
+ /**
3674
+ * CustomEvent fired after submission
3675
+ * @event submitEvent
3676
+ */
3677
+ this.submitEvent = new YAHOO.util.CustomEvent("submit");
3678
+
3679
+ /**
3680
+ * CustomEvent fired prior to manual submission
3681
+ * @event manualSubmitEvent
3682
+ */
3683
+ this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
3684
+
3685
+ /**
3686
+ * CustomEvent fired prior to asynchronous submission
3687
+ * @event asyncSubmitEvent
3688
+ */
3689
+ this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
3690
+
3691
+ /**
3692
+ * CustomEvent fired prior to form-based submission
3693
+ * @event formSubmitEvent
3694
+ */
3695
+ this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
3696
+
3697
+ /**
3698
+ * CustomEvent fired after cancel
3699
+ * @event cancelEvent
3700
+ */
3701
+ this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
3702
+ };
3703
+
3704
+ /**
3705
+ * The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
3706
+ * @method init
3707
+ * @param {String} el The element ID representing the Dialog <em>OR</em>
3708
+ * @param {HTMLElement} el The element representing the Dialog
3709
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
3710
+ */
3711
+ YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
3712
+ YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
3713
+
3714
+ this.beforeInitEvent.fire(YAHOO.widget.Dialog);
3715
+
3716
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
3717
+
3718
+ this.cfg.setProperty("visible", false);
3719
+
3720
+ if (userConfig) {
3721
+ this.cfg.applyConfig(userConfig, true);
3722
+ }
3723
+
3724
+ this.showEvent.subscribe(this.focusFirst, this, true);
3725
+ this.beforeHideEvent.subscribe(this.blurButtons, this, true);
3726
+
3727
+ this.beforeRenderEvent.subscribe(function() {
3728
+ var buttonCfg = this.cfg.getProperty("buttons");
3729
+ if (buttonCfg && buttonCfg != "none") {
3730
+ if (! this.footer) {
3731
+ this.setFooter("");
3732
+ }
3733
+ }
3734
+ }, this, true);
3735
+
3736
+ this.initEvent.fire(YAHOO.widget.Dialog);
3737
+ };
3738
+
3739
+ /**
3740
+ * Performs the submission of the Dialog form depending on the value of "postmethod" property.
3741
+ * @method doSubmit
3742
+ */
3743
+ YAHOO.widget.Dialog.prototype.doSubmit = function() {
3744
+ var pm = this.cfg.getProperty("postmethod");
3745
+ switch (pm) {
3746
+ case "async":
3747
+ var method = this.form.getAttribute("method") || 'POST';
3748
+ method = method.toUpperCase();
3749
+ YAHOO.util.Connect.setForm(this.form);
3750
+ var cObj = YAHOO.util.Connect.asyncRequest(method, this.form.getAttribute("action"), this.callback);
3751
+ this.asyncSubmitEvent.fire();
3752
+ break;
3753
+ case "form":
3754
+ this.form.submit();
3755
+ this.formSubmitEvent.fire();
3756
+ break;
3757
+ case "none":
3758
+ case "manual":
3759
+ this.manualSubmitEvent.fire();
3760
+ break;
3761
+ }
3762
+ };
3763
+
3764
+ /**
3765
+ * Prepares the Dialog's internal FORM object, creating one if one is not currently present.
3766
+ * @method registerForm
3767
+ */
3768
+ YAHOO.widget.Dialog.prototype.registerForm = function() {
3769
+ var form = this.element.getElementsByTagName("form")[0];
3770
+
3771
+ if (! form) {
3772
+ var formHTML = "<form name=\"frm_" + this.id + "\" action=\"\"></form>";
3773
+ this.body.innerHTML += formHTML;
3774
+ form = this.element.getElementsByTagName("form")[0];
3775
+ }
3776
+
3777
+ this.firstFormElement = function() {
3778
+ for (var f=0;f<form.elements.length;f++ ) {
3779
+ var el = form.elements[f];
3780
+ if (el.focus && ! el.disabled) {
3781
+ if (el.type && el.type != "hidden") {
3782
+ return el;
3783
+ }
3784
+ }
3785
+ }
3786
+ return null;
3787
+ }();
3788
+
3789
+ this.lastFormElement = function() {
3790
+ for (var f=form.elements.length-1;f>=0;f-- ) {
3791
+ var el = form.elements[f];
3792
+ if (el.focus && ! el.disabled) {
3793
+ if (el.type && el.type != "hidden") {
3794
+ return el;
3795
+ }
3796
+ }
3797
+ }
3798
+ return null;
3799
+ }();
3800
+
3801
+ this.form = form;
3802
+
3803
+ if (this.cfg.getProperty("modal") && this.form) {
3804
+
3805
+ var me = this;
3806
+
3807
+ var firstElement = this.firstFormElement || this.firstButton;
3808
+ if (firstElement) {
3809
+ this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
3810
+ this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
3811
+ this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
3812
+ }
3813
+
3814
+ var lastElement = this.lastButton || this.lastFormElement;
3815
+ if (lastElement) {
3816
+ this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
3817
+ this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
3818
+ this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
3819
+ }
3820
+ }
3821
+ };
3822
+
3823
+ // BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
3824
+
3825
+ /**
3826
+ * The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Dialog.
3827
+ * @method configClose
3828
+ * @param {String} type The CustomEvent type (usually the property name)
3829
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3830
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3831
+ */
3832
+ YAHOO.widget.Dialog.prototype.configClose = function(type, args, obj) {
3833
+ var val = args[0];
3834
+
3835
+ var doCancel = function(e, obj) {
3836
+ obj.cancel();
3837
+ };
3838
+
3839
+ if (val) {
3840
+ if (! this.close) {
3841
+ this.close = document.createElement("div");
3842
+ YAHOO.util.Dom.addClass(this.close, "container-close");
3843
+
3844
+ this.close.innerHTML = "&#160;";
3845
+ this.innerElement.appendChild(this.close);
3846
+ YAHOO.util.Event.addListener(this.close, "click", doCancel, this);
3847
+ } else {
3848
+ this.close.style.display = "block";
3849
+ }
3850
+ } else {
3851
+ if (this.close) {
3852
+ this.close.style.display = "none";
3853
+ }
3854
+ }
3855
+ };
3856
+
3857
+ /**
3858
+ * The default event handler for the "buttons" configuration property
3859
+ * @method configButtons
3860
+ * @param {String} type The CustomEvent type (usually the property name)
3861
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
3862
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
3863
+ */
3864
+ YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
3865
+ var buttons = args[0];
3866
+ if (buttons != "none") {
3867
+ this.buttonSpan = null;
3868
+ this.buttonSpan = document.createElement("span");
3869
+ this.buttonSpan.className = "button-group";
3870
+
3871
+ for (var b=0;b<buttons.length;b++) {
3872
+ var button = buttons[b];
3873
+
3874
+ var htmlButton = document.createElement("button");
3875
+ htmlButton.setAttribute("type", "button");
3876
+
3877
+ if (button.isDefault) {
3878
+ htmlButton.className = "default";
3879
+ this.defaultHtmlButton = htmlButton;
3880
+ }
3881
+
3882
+ htmlButton.appendChild(document.createTextNode(button.text));
3883
+ YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true);
3884
+
3885
+ this.buttonSpan.appendChild(htmlButton);
3886
+ button.htmlButton = htmlButton;
3887
+
3888
+ if (b === 0) {
3889
+ this.firstButton = button.htmlButton;
3890
+ }
3891
+
3892
+ if (b == (buttons.length-1)) {
3893
+ this.lastButton = button.htmlButton;
3894
+ }
3895
+
3896
+ }
3897
+
3898
+ this.setFooter(this.buttonSpan);
3899
+
3900
+ this.cfg.refireEvent("iframe");
3901
+ this.cfg.refireEvent("underlay");
3902
+ } else { // Do cleanup
3903
+ if (this.buttonSpan) {
3904
+ if (this.buttonSpan.parentNode) {
3905
+ this.buttonSpan.parentNode.removeChild(this.buttonSpan);
3906
+ }
3907
+
3908
+ this.buttonSpan = null;
3909
+ this.firstButton = null;
3910
+ this.lastButton = null;
3911
+ this.defaultHtmlButton = null;
3912
+ }
3913
+ }
3914
+ };
3915
+
3916
+
3917
+ /**
3918
+ * The default event handler used to focus the first field of the form when the Dialog is shown.
3919
+ * @method focusFirst
3920
+ */
3921
+ YAHOO.widget.Dialog.prototype.focusFirst = function(type,args,obj) {
3922
+ if (args) {
3923
+ var e = args[1];
3924
+ if (e) {
3925
+ YAHOO.util.Event.stopEvent(e);
3926
+ }
3927
+ }
3928
+
3929
+ if (this.firstFormElement) {
3930
+ this.firstFormElement.focus();
3931
+ } else {
3932
+ this.focusDefaultButton();
3933
+ }
3934
+ };
3935
+
3936
+ /**
3937
+ * Sets the focus to the last button in the button or form element in the Dialog
3938
+ * @method focusLast
3939
+ */
3940
+ YAHOO.widget.Dialog.prototype.focusLast = function(type,args,obj) {
3941
+ if (args) {
3942
+ var e = args[1];
3943
+ if (e) {
3944
+ YAHOO.util.Event.stopEvent(e);
3945
+ }
3946
+ }
3947
+
3948
+ var buttons = this.cfg.getProperty("buttons");
3949
+ if (buttons && buttons instanceof Array) {
3950
+ this.focusLastButton();
3951
+ } else {
3952
+ if (this.lastFormElement) {
3953
+ this.lastFormElement.focus();
3954
+ }
3955
+ }
3956
+ };
3957
+
3958
+ /**
3959
+ * Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired.
3960
+ * @method focusDefaultButton
3961
+ */
3962
+ YAHOO.widget.Dialog.prototype.focusDefaultButton = function() {
3963
+ if (this.defaultHtmlButton) {
3964
+ this.defaultHtmlButton.focus();
3965
+ }
3966
+ };
3967
+
3968
+ /**
3969
+ * Blurs all the html buttons
3970
+ * @method blurButtons
3971
+ */
3972
+ YAHOO.widget.Dialog.prototype.blurButtons = function() {
3973
+ var buttons = this.cfg.getProperty("buttons");
3974
+ if (buttons && buttons instanceof Array) {
3975
+ var html = buttons[0].htmlButton;
3976
+ if (html) {
3977
+ html.blur();
3978
+ }
3979
+ }
3980
+ };
3981
+
3982
+ /**
3983
+ * Sets the focus to the first button in the button list
3984
+ * @method focusFirstButton
3985
+ */
3986
+ YAHOO.widget.Dialog.prototype.focusFirstButton = function() {
3987
+ var buttons = this.cfg.getProperty("buttons");
3988
+ if (buttons && buttons instanceof Array) {
3989
+ var html = buttons[0].htmlButton;
3990
+ if (html) {
3991
+ html.focus();
3992
+ }
3993
+ }
3994
+ };
3995
+
3996
+ /**
3997
+ * Sets the focus to the first button in the button list
3998
+ * @method focusLastButton
3999
+ */
4000
+ YAHOO.widget.Dialog.prototype.focusLastButton = function() {
4001
+ var buttons = this.cfg.getProperty("buttons");
4002
+ if (buttons && buttons instanceof Array) {
4003
+ var html = buttons[buttons.length-1].htmlButton;
4004
+ if (html) {
4005
+ html.focus();
4006
+ }
4007
+ }
4008
+ };
4009
+
4010
+ /**
4011
+ * The default event handler for the "postmethod" configuration property
4012
+ * @method configPostMethod
4013
+ * @param {String} type The CustomEvent type (usually the property name)
4014
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
4015
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
4016
+ */
4017
+ YAHOO.widget.Dialog.prototype.configPostMethod = function(type, args, obj) {
4018
+ var postmethod = args[0];
4019
+
4020
+ this.registerForm();
4021
+ YAHOO.util.Event.addListener(this.form, "submit", function(e) {
4022
+ YAHOO.util.Event.stopEvent(e);
4023
+ this.submit();
4024
+ this.form.blur();
4025
+ }, this, true);
4026
+ };
4027
+
4028
+ // END BUILT-IN PROPERTY EVENT HANDLERS //
4029
+
4030
+ /**
4031
+ * Built-in function hook for writing a validation function that will be checked for a "true" value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary.
4032
+ * @method validate
4033
+ */
4034
+ YAHOO.widget.Dialog.prototype.validate = function() {
4035
+ return true;
4036
+ };
4037
+
4038
+ /**
4039
+ * Executes a submit of the Dialog followed by a hide, if validation is successful.
4040
+ * @method submit
4041
+ */
4042
+ YAHOO.widget.Dialog.prototype.submit = function() {
4043
+ if (this.validate()) {
4044
+ this.beforeSubmitEvent.fire();
4045
+ this.doSubmit();
4046
+ this.submitEvent.fire();
4047
+ this.hide();
4048
+ return true;
4049
+ } else {
4050
+ return false;
4051
+ }
4052
+ };
4053
+
4054
+ /**
4055
+ * Executes the cancel of the Dialog followed by a hide.
4056
+ * @method cancel
4057
+ */
4058
+ YAHOO.widget.Dialog.prototype.cancel = function() {
4059
+ this.cancelEvent.fire();
4060
+ this.hide();
4061
+ };
4062
+
4063
+ /**
4064
+ * Returns a JSON-compatible data structure representing the data currently contained in the form.
4065
+ * @method getData
4066
+ * @return {Object} A JSON object reprsenting the data of the current form.
4067
+ */
4068
+ YAHOO.widget.Dialog.prototype.getData = function() {
4069
+
4070
+ var oForm = this.form;
4071
+
4072
+ if(oForm) {
4073
+
4074
+ var aElements = oForm.elements,
4075
+ nTotalElements = aElements.length,
4076
+ oData = {},
4077
+ sName,
4078
+ oElement;
4079
+
4080
+
4081
+ for(var i=0; i<nTotalElements; i++) {
4082
+
4083
+ sName = aElements[i].name,
4084
+ oElement = aElements[sName];
4085
+
4086
+
4087
+ if(oElement) {
4088
+
4089
+ if(oElement.tagName) {
4090
+
4091
+ var sType = oElement.type,
4092
+ sTagName = oElement.tagName.toUpperCase();
4093
+
4094
+ switch(sTagName) {
4095
+
4096
+ case "INPUT":
4097
+
4098
+ if(sType == "checkbox") {
4099
+
4100
+ oData[sName] = oElement.checked;
4101
+
4102
+ }
4103
+ else if(sType != "radio") {
4104
+
4105
+ oData[sName] = oElement.value;
4106
+
4107
+ }
4108
+
4109
+ break;
4110
+
4111
+ case "TEXTAREA":
4112
+
4113
+ oData[sName] = oElement.value;
4114
+
4115
+ break;
4116
+
4117
+ case "SELECT":
4118
+
4119
+ var aOptions = oElement.options,
4120
+ nOptions = aOptions.length,
4121
+ aValues = [],
4122
+ oOption,
4123
+ sValue;
4124
+
4125
+
4126
+ for(var n=0; n<nOptions; n++) {
4127
+
4128
+ oOption = aOptions[n];
4129
+
4130
+ if(oOption.selected) {
4131
+
4132
+ sValue = oOption.value;
4133
+
4134
+ if(!sValue || sValue === "") {
4135
+
4136
+ sValue = oOption.text;
4137
+
4138
+ }
4139
+
4140
+ aValues[aValues.length] = sValue;
4141
+
4142
+ }
4143
+
4144
+ }
4145
+
4146
+ oData[sName] = aValues;
4147
+
4148
+ break;
4149
+
4150
+ }
4151
+
4152
+
4153
+ }
4154
+ else {
4155
+
4156
+ var nElements = oElement.length,
4157
+ sType = oElement[0].type,
4158
+ sTagName = oElement[0].tagName.toUpperCase();
4159
+
4160
+
4161
+ switch(sType) {
4162
+
4163
+ case "radio":
4164
+
4165
+ var oRadio;
4166
+
4167
+ for(var n=0; n<nElements; n++) {
4168
+
4169
+ oRadio = oElement[n];
4170
+
4171
+ if(oRadio.checked) {
4172
+
4173
+ oData[sName] = oRadio.value;
4174
+ break;
4175
+
4176
+ }
4177
+
4178
+ }
4179
+
4180
+ break;
4181
+
4182
+ case "checkbox":
4183
+
4184
+ var aValues = [],
4185
+ oCheckbox;
4186
+
4187
+ for(var n=0; n<nElements; n++) {
4188
+
4189
+ oCheckbox = oElement[n];
4190
+
4191
+ if(oCheckbox.checked) {
4192
+
4193
+ aValues[aValues.length] = oCheckbox.value;
4194
+
4195
+ }
4196
+
4197
+ }
4198
+
4199
+ oData[sName] = aValues;
4200
+
4201
+ break;
4202
+
4203
+ }
4204
+
4205
+ }
4206
+
4207
+ }
4208
+
4209
+ }
4210
+
4211
+ }
4212
+
4213
+
4214
+ return oData;
4215
+
4216
+ };
4217
+
4218
+ /**
4219
+ * Returns a string representation of the object.
4220
+ * @method toString
4221
+ * @return {String} The string representation of the Dialog
4222
+ */
4223
+ YAHOO.widget.Dialog.prototype.toString = function() {
4224
+ return "Dialog " + this.id;
4225
+ };
4226
+
4227
+ /**
4228
+ * SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
4229
+ * @namespace YAHOO.widget
4230
+ * @class SimpleDialog
4231
+ * @extends YAHOO.widget.Dialog
4232
+ * @constructor
4233
+ * @param {String} el The element ID representing the SimpleDialog <em>OR</em>
4234
+ * @param {HTMLElement} el The element representing the SimpleDialog
4235
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
4236
+ */
4237
+ YAHOO.widget.SimpleDialog = function(el, userConfig) {
4238
+ YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
4239
+ };
4240
+
4241
+ YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
4242
+
4243
+ /**
4244
+ * Constant for the standard network icon for a blocking action
4245
+ * @property YAHOO.widget.SimpleDialog.ICON_BLOCK
4246
+ * @static
4247
+ * @final
4248
+ * @type String
4249
+ */
4250
+ YAHOO.widget.SimpleDialog.ICON_BLOCK = "blckicon";
4251
+
4252
+ /**
4253
+ * Constant for the standard network icon for alarm
4254
+ * @property YAHOO.widget.SimpleDialog.ICON_ALARM
4255
+ * @static
4256
+ * @final
4257
+ * @type String
4258
+ */
4259
+ YAHOO.widget.SimpleDialog.ICON_ALARM = "alrticon";
4260
+
4261
+ /**
4262
+ * Constant for the standard network icon for help
4263
+ * @property YAHOO.widget.SimpleDialog.ICON_HELP
4264
+ * @static
4265
+ * @final
4266
+ * @type String
4267
+ */
4268
+ YAHOO.widget.SimpleDialog.ICON_HELP = "hlpicon";
4269
+
4270
+ /**
4271
+ * Constant for the standard network icon for info
4272
+ * @property YAHOO.widget.SimpleDialog.ICON_INFO
4273
+ * @static
4274
+ * @final
4275
+ * @type String
4276
+ */
4277
+ YAHOO.widget.SimpleDialog.ICON_INFO = "infoicon";
4278
+
4279
+ /**
4280
+ * Constant for the standard network icon for warn
4281
+ * @property YAHOO.widget.SimpleDialog.ICON_WARN
4282
+ * @static
4283
+ * @final
4284
+ * @type String
4285
+ */
4286
+ YAHOO.widget.SimpleDialog.ICON_WARN = "warnicon";
4287
+
4288
+ /**
4289
+ * Constant for the standard network icon for a tip
4290
+ * @property YAHOO.widget.SimpleDialog.ICON_TIP
4291
+ * @static
4292
+ * @final
4293
+ * @type String
4294
+ */
4295
+ YAHOO.widget.SimpleDialog.ICON_TIP = "tipicon";
4296
+
4297
+ /**
4298
+ * Constant representing the default CSS class used for a SimpleDialog
4299
+ * @property YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG
4300
+ * @static
4301
+ * @final
4302
+ * @type String
4303
+ */
4304
+ YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "yui-simple-dialog";
4305
+
4306
+ /**
4307
+ * Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
4308
+ * @method initDefaultConfig
4309
+ */
4310
+ YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
4311
+ YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
4312
+
4313
+ // Add dialog config properties //
4314
+
4315
+ /**
4316
+ * Sets the informational icon for the SimpleDialog
4317
+ * @config icon
4318
+ * @type String
4319
+ * @default "none"
4320
+ */
4321
+ this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
4322
+
4323
+ /**
4324
+ * Sets the text for the SimpleDialog
4325
+ * @config text
4326
+ * @type String
4327
+ * @default ""
4328
+ */
4329
+ this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
4330
+ };
4331
+
4332
+
4333
+ /**
4334
+ * The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
4335
+ * @method init
4336
+ * @param {String} el The element ID representing the SimpleDialog <em>OR</em>
4337
+ * @param {HTMLElement} el The element representing the SimpleDialog
4338
+ * @param {Object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
4339
+ */
4340
+ YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
4341
+ YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
4342
+
4343
+ this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
4344
+
4345
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
4346
+
4347
+ this.cfg.queueProperty("postmethod", "manual");
4348
+
4349
+ if (userConfig) {
4350
+ this.cfg.applyConfig(userConfig, true);
4351
+ }
4352
+
4353
+ this.beforeRenderEvent.subscribe(function() {
4354
+ if (! this.body) {
4355
+ this.setBody("");
4356
+ }
4357
+ }, this, true);
4358
+
4359
+ this.initEvent.fire(YAHOO.widget.SimpleDialog);
4360
+
4361
+ };
4362
+ /**
4363
+ * Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
4364
+ * @method registerForm
4365
+ */
4366
+ YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
4367
+ YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
4368
+ this.form.innerHTML += "<input type=\"hidden\" name=\"" + this.id + "\" value=\"\"/>";
4369
+ };
4370
+
4371
+ // BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
4372
+
4373
+ /**
4374
+ * Fired when the "icon" property is set.
4375
+ * @method configIcon
4376
+ * @param {String} type The CustomEvent type (usually the property name)
4377
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
4378
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
4379
+ */
4380
+ YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
4381
+ var icon = args[0];
4382
+ if (icon && icon != "none") {
4383
+ var iconHTML = "";
4384
+ if (icon.indexOf(".") == -1) {
4385
+ iconHTML = "<span class=\"yui-icon " + icon +"\" >&#160;</span>";
4386
+ } else {
4387
+ iconHTML = "<img src=\"" + this.imageRoot + icon + "\" class=\"yui-icon\" />";
4388
+ }
4389
+ this.body.innerHTML = iconHTML + this.body.innerHTML;
4390
+ }
4391
+ };
4392
+
4393
+ /**
4394
+ * Fired when the "text" property is set.
4395
+ * @method configText
4396
+ * @param {String} type The CustomEvent type (usually the property name)
4397
+ * @param {Object[]} args The CustomEvent arguments. For configuration handlers, args[0] will equal the newly applied value for the property.
4398
+ * @param {Object} obj The scope object. For configuration handlers, this will usually equal the owner.
4399
+ */
4400
+ YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
4401
+ var text = args[0];
4402
+ if (text) {
4403
+ this.setBody(text);
4404
+ this.cfg.refireEvent("icon");
4405
+ }
4406
+ };
4407
+ // END BUILT-IN PROPERTY EVENT HANDLERS //
4408
+
4409
+ /**
4410
+ * Returns a string representation of the object.
4411
+ * @method toString
4412
+ * @return {String} The string representation of the SimpleDialog
4413
+ */
4414
+ YAHOO.widget.SimpleDialog.prototype.toString = function() {
4415
+ return "SimpleDialog " + this.id;
4416
+ };
4417
+
4418
+ /**
4419
+ * ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
4420
+ * @namespace YAHOO.widget
4421
+ * @class ContainerEffect
4422
+ * @constructor
4423
+ * @param {YAHOO.widget.Overlay} overlay The Overlay that the animation should be associated with
4424
+ * @param {Object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
4425
+ * @param {Object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(Number), and method(i.e. YAHOO.util.Easing.easeIn).
4426
+ * @param {HTMLElement} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
4427
+ * @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
4428
+ */
4429
+ YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
4430
+ if (! animClass) {
4431
+ animClass = YAHOO.util.Anim;
4432
+ }
4433
+
4434
+ /**
4435
+ * The overlay to animate
4436
+ * @property overlay
4437
+ * @type YAHOO.widget.Overlay
4438
+ */
4439
+ this.overlay = overlay;
4440
+ /**
4441
+ * The animation attributes to use when transitioning into view
4442
+ * @property attrIn
4443
+ * @type Object
4444
+ */
4445
+ this.attrIn = attrIn;
4446
+ /**
4447
+ * The animation attributes to use when transitioning out of view
4448
+ * @property attrOut
4449
+ * @type Object
4450
+ */
4451
+ this.attrOut = attrOut;
4452
+ /**
4453
+ * The target element to be animated
4454
+ * @property targetElement
4455
+ * @type HTMLElement
4456
+ */
4457
+ this.targetElement = targetElement || overlay.element;
4458
+ /**
4459
+ * The animation class to use for animating the overlay
4460
+ * @property animClass
4461
+ * @type class
4462
+ */
4463
+ this.animClass = animClass;
4464
+ };
4465
+
4466
+ /**
4467
+ * Initializes the animation classes and events.
4468
+ * @method init
4469
+ */
4470
+ YAHOO.widget.ContainerEffect.prototype.init = function() {
4471
+ this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
4472
+ this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
4473
+
4474
+ this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
4475
+ this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
4476
+
4477
+ this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
4478
+ this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
4479
+ this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
4480
+ this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
4481
+
4482
+ this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
4483
+ this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
4484
+ this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
4485
+ this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
4486
+ };
4487
+
4488
+ /**
4489
+ * Triggers the in-animation.
4490
+ * @method animateIn
4491
+ */
4492
+ YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
4493
+ this.beforeAnimateInEvent.fire();
4494
+ this.animIn.animate();
4495
+ };
4496
+
4497
+ /**
4498
+ * Triggers the out-animation.
4499
+ * @method animateOut
4500
+ */
4501
+ YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
4502
+ this.beforeAnimateOutEvent.fire();
4503
+ this.animOut.animate();
4504
+ };
4505
+
4506
+ /**
4507
+ * The default onStart handler for the in-animation.
4508
+ * @method handleStartAnimateIn
4509
+ * @param {String} type The CustomEvent type
4510
+ * @param {Object[]} args The CustomEvent arguments
4511
+ * @param {Object} obj The scope object
4512
+ */
4513
+ YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { };
4514
+ /**
4515
+ * The default onTween handler for the in-animation.
4516
+ * @method handleTweenAnimateIn
4517
+ * @param {String} type The CustomEvent type
4518
+ * @param {Object[]} args The CustomEvent arguments
4519
+ * @param {Object} obj The scope object
4520
+ */
4521
+ YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { };
4522
+ /**
4523
+ * The default onComplete handler for the in-animation.
4524
+ * @method handleCompleteAnimateIn
4525
+ * @param {String} type The CustomEvent type
4526
+ * @param {Object[]} args The CustomEvent arguments
4527
+ * @param {Object} obj The scope object
4528
+ */
4529
+ YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { };
4530
+
4531
+ /**
4532
+ * The default onStart handler for the out-animation.
4533
+ * @method handleStartAnimateOut
4534
+ * @param {String} type The CustomEvent type
4535
+ * @param {Object[]} args The CustomEvent arguments
4536
+ * @param {Object} obj The scope object
4537
+ */
4538
+ YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { };
4539
+ /**
4540
+ * The default onTween handler for the out-animation.
4541
+ * @method handleTweenAnimateOut
4542
+ * @param {String} type The CustomEvent type
4543
+ * @param {Object[]} args The CustomEvent arguments
4544
+ * @param {Object} obj The scope object
4545
+ */
4546
+ YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { };
4547
+ /**
4548
+ * The default onComplete handler for the out-animation.
4549
+ * @method handleCompleteAnimateOut
4550
+ * @param {String} type The CustomEvent type
4551
+ * @param {Object[]} args The CustomEvent arguments
4552
+ * @param {Object} obj The scope object
4553
+ */
4554
+ YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { };
4555
+
4556
+ /**
4557
+ * Returns a string representation of the object.
4558
+ * @method toString
4559
+ * @return {String} The string representation of the ContainerEffect
4560
+ */
4561
+ YAHOO.widget.ContainerEffect.prototype.toString = function() {
4562
+ var output = "ContainerEffect";
4563
+ if (this.overlay) {
4564
+ output += " [" + this.overlay.toString() + "]";
4565
+ }
4566
+ return output;
4567
+ };
4568
+
4569
+ /**
4570
+ * A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
4571
+ * @method FADE
4572
+ * @static
4573
+ * @param {Overlay} overlay The Overlay object to animate
4574
+ * @param {Number} dur The duration of the animation
4575
+ * @return {ContainerEffect} The configured ContainerEffect object
4576
+ */
4577
+ YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
4578
+ var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
4579
+
4580
+ fade.handleStartAnimateIn = function(type,args,obj) {
4581
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
4582
+
4583
+ if (! obj.overlay.underlay) {
4584
+ obj.overlay.cfg.refireEvent("underlay");
4585
+ }
4586
+
4587
+ if (obj.overlay.underlay) {
4588
+ obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
4589
+ obj.overlay.underlay.style.filter = null;
4590
+ }
4591
+
4592
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
4593
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
4594
+ };
4595
+
4596
+ fade.handleCompleteAnimateIn = function(type,args,obj) {
4597
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
4598
+
4599
+ if (obj.overlay.element.style.filter) {
4600
+ obj.overlay.element.style.filter = null;
4601
+ }
4602
+
4603
+ if (obj.overlay.underlay) {
4604
+ YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
4605
+ }
4606
+
4607
+ obj.overlay.cfg.refireEvent("iframe");
4608
+ obj.animateInCompleteEvent.fire();
4609
+ };
4610
+
4611
+ fade.handleStartAnimateOut = function(type, args, obj) {
4612
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
4613
+
4614
+ if (obj.overlay.underlay) {
4615
+ obj.overlay.underlay.style.filter = null;
4616
+ }
4617
+ };
4618
+
4619
+ fade.handleCompleteAnimateOut = function(type, args, obj) {
4620
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
4621
+ if (obj.overlay.element.style.filter) {
4622
+ obj.overlay.element.style.filter = null;
4623
+ }
4624
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
4625
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
4626
+
4627
+ obj.overlay.cfg.refireEvent("iframe");
4628
+
4629
+ obj.animateOutCompleteEvent.fire();
4630
+ };
4631
+
4632
+ fade.init();
4633
+ return fade;
4634
+ };
4635
+
4636
+
4637
+ /**
4638
+ * A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
4639
+ * @method SLIDE
4640
+ * @static
4641
+ * @param {Overlay} overlay The Overlay object to animate
4642
+ * @param {Number} dur The duration of the animation
4643
+ * @return {ContainerEffect} The configured ContainerEffect object
4644
+ */
4645
+ YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
4646
+ var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
4647
+ var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
4648
+
4649
+ var clientWidth = YAHOO.util.Dom.getClientWidth();
4650
+ var offsetWidth = overlay.element.offsetWidth;
4651
+
4652
+ var slide = new YAHOO.widget.ContainerEffect(overlay, {
4653
+ attributes:{ points: { to:[x, y] } },
4654
+ duration:dur,
4655
+ method:YAHOO.util.Easing.easeIn
4656
+ },
4657
+ {
4658
+ attributes:{ points: { to:[(clientWidth+25), y] } },
4659
+ duration:dur,
4660
+ method:YAHOO.util.Easing.easeOut
4661
+ },
4662
+ overlay.element,
4663
+ YAHOO.util.Motion);
4664
+
4665
+
4666
+ slide.handleStartAnimateIn = function(type,args,obj) {
4667
+ obj.overlay.element.style.left = (-25-offsetWidth) + "px";
4668
+ obj.overlay.element.style.top = y + "px";
4669
+ };
4670
+
4671
+ slide.handleTweenAnimateIn = function(type, args, obj) {
4672
+
4673
+
4674
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
4675
+
4676
+ var currentX = pos[0];
4677
+ var currentY = pos[1];
4678
+
4679
+ if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
4680
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
4681
+ }
4682
+
4683
+ obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
4684
+ obj.overlay.cfg.refireEvent("iframe");
4685
+ };
4686
+
4687
+ slide.handleCompleteAnimateIn = function(type, args, obj) {
4688
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
4689
+ obj.startX = x;
4690
+ obj.startY = y;
4691
+ obj.overlay.cfg.refireEvent("iframe");
4692
+ obj.animateInCompleteEvent.fire();
4693
+ };
4694
+
4695
+ slide.handleStartAnimateOut = function(type, args, obj) {
4696
+ var vw = YAHOO.util.Dom.getViewportWidth();
4697
+
4698
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
4699
+
4700
+ var yso = pos[1];
4701
+
4702
+ var currentTo = obj.animOut.attributes.points.to;
4703
+ obj.animOut.attributes.points.to = [(vw+25), yso];
4704
+ };
4705
+
4706
+ slide.handleTweenAnimateOut = function(type, args, obj) {
4707
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
4708
+
4709
+ var xto = pos[0];
4710
+ var yto = pos[1];
4711
+
4712
+ obj.overlay.cfg.setProperty("xy", [xto,yto], true);
4713
+ obj.overlay.cfg.refireEvent("iframe");
4714
+ };
4715
+
4716
+ slide.handleCompleteAnimateOut = function(type, args, obj) {
4717
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
4718
+
4719
+ obj.overlay.cfg.setProperty("xy", [x,y]);
4720
+ obj.animateOutCompleteEvent.fire();
4721
+ };
4722
+
4723
+ slide.init();
4724
+ return slide;
4725
+ };
4726
+
4727
+ YAHOO.register("container", YAHOO.widget.Module, {version: "2.2.0", build: "125"});