source: ether_statistics/web/resources/js/windows_js_1.3/javascripts/window_effects.js @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 5.4 KB
Line 
1Effect.ResizeWindow = Class.create();
2Object.extend(Object.extend(Effect.ResizeWindow.prototype, Effect.Base.prototype), {
3  initialize: function(win, top, left, width, height) {
4    this.window = win;
5    this.window.resizing = true;
6   
7    var size = win.getSize();
8    this.initWidth    = parseFloat(size.width);
9    this.initHeight   = parseFloat(size.height);
10
11    var location = win.getLocation();
12    this.initTop    = parseFloat(location.top);
13    this.initLeft   = parseFloat(location.left);
14
15    this.width    = width != null  ? parseFloat(width)  : this.initWidth;
16    this.height   = height != null ? parseFloat(height) : this.initHeight;
17    this.top      = top != null    ? parseFloat(top)    : this.initTop;
18    this.left     = left != null   ? parseFloat(left)   : this.initLeft;
19
20    this.dx     = this.left   - this.initLeft;
21    this.dy     = this.top    - this.initTop;
22    this.dw     = this.width  - this.initWidth;
23    this.dh     = this.height - this.initHeight;
24   
25    this.r2      = $(this.window.getId() + "_row2");
26    this.content = $(this.window.getId() + "_content");
27       
28    this.contentOverflow = this.content.getStyle("overflow") || "auto";
29    this.content.setStyle({overflow: "hidden"});
30   
31    // Wired mode
32    if (this.window.options.wiredDrag) {
33      this.window.currentDrag = win._createWiredElement();
34      this.window.currentDrag.show();
35      this.window.element.hide();
36    }
37
38    this.start(arguments[5]);
39  },
40 
41  update: function(position) {
42    var width  = Math.floor(this.initWidth  + this.dw * position);
43    var height = Math.floor(this.initHeight + this.dh * position);
44    var top    = Math.floor(this.initTop    + this.dy * position);
45    var left   = Math.floor(this.initLeft   + this.dx * position);
46
47    if (window.ie) {
48      if (Math.floor(height) == 0) 
49        this.r2.hide();
50      else if (Math.floor(height) >1) 
51        this.r2.show();
52    }     
53    this.r2.setStyle({height: height});
54    this.window.setSize(width, height);
55    this.window.setLocation(top, left);
56  },
57 
58  finish: function(position) {
59    // Wired mode
60    if (this.window.options.wiredDrag) {
61      this.window._hideWiredElement();
62      this.window.element.show();
63    }
64
65    this.window.setSize(this.width, this.height);
66    this.window.setLocation(this.top, this.left);
67    this.r2.setStyle({height: null});
68   
69    this.content.setStyle({overflow: this.contentOverflow});
70     
71    this.window.resizing = false;
72  }
73});
74
75Effect.ModalSlideDown = function(element) {
76  var windowScroll = WindowUtilities.getWindowScroll();   
77  var height = element.getStyle("height"); 
78  element.setStyle({top: - (parseFloat(height) - windowScroll.top) + "px"});
79 
80  element.show();
81  return new Effect.Move(element, Object.extend({ x: 0, y: parseFloat(height) }, arguments[1] || {}));
82};
83
84
85Effect.ModalSlideUp = function(element) {
86  var height = element.getStyle("height");
87  return new Effect.Move(element, Object.extend({ x: 0, y: -parseFloat(height) }, arguments[1] || {}));
88};
89
90PopupEffect = Class.create();
91PopupEffect.prototype = {   
92  initialize: function(htmlElement) {
93    this.html = $(htmlElement);     
94    this.options = Object.extend({className: "popup_effect", duration: 0.4}, arguments[1] || {});
95   
96  },
97  show: function(element, options) { 
98    var position = Position.cumulativeOffset(this.html);     
99    var size = this.html.getDimensions();
100    var bounds = element.win.getBounds();
101    this.window =  element.win;     
102    // Create a div
103    if (!this.div) {
104      this.div = document.createElement("div");
105      this.div.className = this.options.className;
106      this.div.style.height = size.height + "px";
107      this.div.style.width  = size.width  + "px";
108      this.div.style.top    = position[1] + "px";
109      this.div.style.left   = position[0] + "px";   
110      this.div.style.position = "absolute"
111      document.body.appendChild(this.div);
112    }                                                   
113    if (this.options.fromOpacity)
114      this.div.setStyle({opacity: this.options.fromOpacity})
115    this.div.show();         
116    var style = "top:" + bounds.top + ";left:" +bounds.left + ";width:" + bounds.width +";height:" + bounds.height;
117    if (this.options.toOpacity)
118      style += ";opacity:" + this.options.toOpacity;
119   
120    new Effect.Morph(this.div ,{style: style, duration: this.options.duration, afterFinish: this._showWindow.bind(this)});   
121  },
122
123  hide: function(element, options) {     
124    var position = Position.cumulativeOffset(this.html);     
125    var size = this.html.getDimensions();   
126    this.window.visible = true; 
127    var bounds = this.window.getBounds();
128    this.window.visible = false; 
129
130    this.window.element.hide();
131
132    this.div.style.height = bounds.height;
133    this.div.style.width  = bounds.width;
134    this.div.style.top    = bounds.top;
135    this.div.style.left   = bounds.left;
136   
137    if (this.options.toOpacity)
138      this.div.setStyle({opacity: this.options.toOpacity})
139
140    this.div.show();                                 
141    var style = "top:" + position[1] + "px;left:" + position[0] + "px;width:" + size.width +"px;height:" + size.height + "px";
142
143    if (this.options.fromOpacity)
144      style += ";opacity:" + this.options.fromOpacity;
145    new Effect.Morph(this.div ,{style: style, duration: this.options.duration, afterFinish: this._hideDiv.bind(this)});   
146  },
147 
148  _showWindow: function() {
149    this.div.hide();
150    this.window.element.show(); 
151  },
152 
153  _hideDiv: function() {
154    this.div.hide();
155  }
156}
157
Note: See TracBrowser for help on using the repository browser.