Diffstat (limited to 'frontend/beta/js/YUI-extensions/dd/StatusProxy.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/dd/StatusProxy.js | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/dd/StatusProxy.js b/frontend/beta/js/YUI-extensions/dd/StatusProxy.js new file mode 100644 index 0000000..97de4d9 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/dd/StatusProxy.js | |||
@@ -0,0 +1,110 @@ | |||
1 | YAHOO.ext.dd.StatusProxy = function(config){ | ||
2 | YAHOO.ext.util.Config.apply(this, config); | ||
3 | this.id = this.id || YAHOO.util.Dom.generateId(); | ||
4 | this.el = new YAHOO.ext.Layer({ | ||
5 | dh: { | ||
6 | id: this.id, tag: 'div', cls: 'ydd-drag-proxy '+this.dropNotAllowed, children: [ | ||
7 | {tag: 'div', cls: 'ydd-drop-icon'}, | ||
8 | {tag: 'div', cls: 'ydd-drag-ghost'} | ||
9 | ] | ||
10 | }, | ||
11 | shadow: !config || config.shadow !== false | ||
12 | }); | ||
13 | /*this.el = YAHOO.ext.DomHelper.insertBefore(document.body.firstChild, { | ||
14 | id: this.id, tag: 'div', cls: 'ydd-drag-proxy '+this.dropNotAllowed, children: [ | ||
15 | {tag: 'div', cls: 'ydd-drop-icon'}, | ||
16 | {tag: 'div', cls: 'ydd-drag-ghost'} | ||
17 | ] | ||
18 | }, true);*/ | ||
19 | this.ghost = getEl(this.el.dom.childNodes[1]); | ||
20 | this.dropStatus = this.dropNotAllowed; | ||
21 | }; | ||
22 | |||
23 | YAHOO.ext.dd.StatusProxy.prototype = { | ||
24 | dropAllowed : 'ydd-drop-ok', | ||
25 | dropNotAllowed : 'ydd-drop-nodrop', | ||
26 | /** | ||
27 | * Updates the DD visual element to allow/not allow a drop | ||
28 | * @param {String} cssClass The css class for the new drop status indicator image | ||
29 | */ | ||
30 | setStatus : function(cssClass){ | ||
31 | cssClass = cssClass || this.dropNotAllowed; | ||
32 | if(this.dropStatus != cssClass){ | ||
33 | this.el.replaceClass(this.dropStatus, cssClass); | ||
34 | this.dropStatus = cssClass; | ||
35 | } | ||
36 | }, | ||
37 | |||
38 | reset : function(clearGhost){ | ||
39 | this.el.dom.className = 'ydd-drag-proxy ' + this.dropNotAllowed; | ||
40 | this.dropStatus = this.dropNotAllowed; | ||
41 | if(clearGhost){ | ||
42 | this.ghost.update(''); | ||
43 | } | ||
44 | }, | ||
45 | |||
46 | update : function(html){ | ||
47 | if(typeof html == 'string'){ | ||
48 | this.ghost.update(html); | ||
49 | }else{ | ||
50 | this.ghost.update(''); | ||
51 | html.style.margin = '0'; | ||
52 | this.ghost.dom.appendChild(html); | ||
53 | } | ||
54 | }, | ||
55 | |||
56 | getEl : function(){ | ||
57 | return this.el; | ||
58 | }, | ||
59 | |||
60 | getGhost : function(){ | ||
61 | return this.ghost; | ||
62 | }, | ||
63 | |||
64 | hide : function(clear){ | ||
65 | this.el.hide(); | ||
66 | if(clear){ | ||
67 | this.reset(true); | ||
68 | } | ||
69 | }, | ||
70 | |||
71 | stop : function(){ | ||
72 | if(this.anim && this.anim.isAnimated()){ | ||
73 | this.anim.stop(); | ||
74 | } | ||
75 | }, | ||
76 | |||
77 | show : function(){ | ||
78 | this.el.show(); | ||
79 | }, | ||
80 | |||
81 | sync : function(){ | ||
82 | this.el.syncLocalXY(); | ||
83 | }, | ||
84 | |||
85 | repair : function(xy, callback, scope){ | ||
86 | this.callback = callback; | ||
87 | this.scope = scope; | ||
88 | if(xy && this.animRepair !== false && YAHOO.util.Anim){ | ||
89 | this.el.addClass('ydd-drag-repair'); | ||
90 | this.el.hideUnders(true); | ||
91 | if(!this.anim){ | ||
92 | this.anim = new YAHOO.util.Motion(this.el.dom, {}, this.repairDuration || .5, YAHOO.util.Easing.easeOut); | ||
93 | this.anim.onComplete.subscribe(this.afterRepair, this, true); | ||
94 | } | ||
95 | this.anim.attributes = {points: {to:xy}}; | ||
96 | this.anim.animate(); | ||
97 | }else{ | ||
98 | this.afterRepair(); | ||
99 | } | ||
100 | }, | ||
101 | |||
102 | afterRepair : function(){ | ||
103 | this.hide(true); | ||
104 | if(typeof this.callback == 'function'){ | ||
105 | this.callback.call(this.scope || this); | ||
106 | } | ||
107 | this.callback == null; | ||
108 | this.scope == null; | ||
109 | } | ||
110 | }; | ||