Changeset 2568
- Timestamp:
- 04/16/10 15:26:03 (14 years ago)
- Location:
- trunk/phpgwapi/templates/default/js/jscode
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpgwapi/templates/default/js/jscode
-
Property
svn:ignore
set to
*.jspack.js
-
Property
svn:ignore
set to
-
trunk/phpgwapi/templates/default/js/jscode/slidereffects.js
r2565 r2568 11 11 *****************************************************/ 12 12 13 ypSlideOutMenu.Registry = [] 14 ypSlideOutMenu.aniLen = 250 15 ypSlideOutMenu.hideDelay = 1000 16 ypSlideOutMenu.minCPUResolution = 10 13 ypSlideOutMenu.Registry = []; 14 ypSlideOutMenu.aniLen = 250; 15 ypSlideOutMenu.hideDelay = 1000; 16 ypSlideOutMenu.minCPUResolution = 10; 17 17 18 18 // constructor 19 19 function ypSlideOutMenu(id, dir, left, top, width, height,pos) 20 20 { 21 this.ie = document.all ? 1 : 0 22 this.ns4 = document.layers ? 1 : 0 23 this.dom = document.getElementById ? 1 : 0 21 this.ie = document.all ? 1 : 0; 22 this.ns4 = document.layers ? 1 : 0; 23 this.dom = document.getElementById ? 1 : 0; 24 24 25 25 if (this.ie || this.ns4 || this.dom) { 26 this.id = id27 this.dir = dir 28 this.orientation = dir == "left" || dir == "right" ? "h" : "v" 29 this.dirType = dir == "right" || dir == "down" ? "-" : "+" 30 this.dim = this.orientation == "h" ? width : height 31 this.hideTimer = false 32 this.aniTimer = false 33 this.open = false 34 this.over = false 35 this.startTime = 0 26 this.id = id; 27 this.dir = dir; 28 this.orientation = dir == "left" || dir == "right" ? "h" : "v"; 29 this.dirType = dir == "right" || dir == "down" ? "-" : "+"; 30 this.dim = this.orientation == "h" ? width : height; 31 this.hideTimer = false; 32 this.aniTimer = false; 33 this.open = false; 34 this.over = false; 35 this.startTime = 0; 36 36 37 37 // global reference to this object 38 this.gRef = "ypSlideOutMenu_"+id 39 eval(this.gRef+"=this") 38 this.gRef = "ypSlideOutMenu_"+id; 39 eval(this.gRef+"=this"); 40 40 41 41 // add this menu object to an internal list of all menus 42 ypSlideOutMenu.Registry[id] = this 43 44 var d = document 42 ypSlideOutMenu.Registry[id] = this; 43 44 var d = document; 45 45 46 46 var strCSS = '<style type="text/css">'; 47 strCSS += '#' + this.id + 'Container { visibility:hidden; ' 47 strCSS += '#' + this.id + 'Container { visibility:hidden; '; 48 48 if(pos) 49 49 { 50 strCSS += pos+':' + left + 'px; ' 50 strCSS += pos+':' + left + 'px; '; 51 51 } 52 52 else 53 53 { 54 strCSS += 'left:' + left + 'px; ' 54 strCSS += 'left:' + left + 'px; '; 55 55 } 56 strCSS += 'top:' + top + 'px; ' 57 strCSS += 'overflow:visible; z-index:10000; }' 58 strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; ' 59 strCSS += 'width:' + width + 'px; ' 60 // strCSS += 'height:' + height + 'px; ' 61 // strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); ' 62 strCSS += '}' 56 strCSS += 'top:' + top + 'px; '; 57 strCSS += 'overflow:visible; z-index:10000; }'; 58 strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '; 59 strCSS += 'width:' + width + 'px; '; 60 // strCSS += 'height:' + height + 'px; '; 61 // strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '; 62 strCSS += '}'; 63 63 strCSS += '</style>'; 64 64 65 d.write(strCSS) 66 67 this.load() 65 d.write(strCSS); 66 67 this.load(); 68 68 } 69 69 } 70 70 71 71 ypSlideOutMenu.prototype.load = function() { 72 var d = document 73 var lyrId1 = this.id + "Container" 74 var lyrId2 = this.id + "Content" 75 var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1] 76 if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2) 77 var temp 78 79 if (!obj1 || !obj2) window.setTimeout(this.gRef + ".load()", 100) 72 var d = document; 73 var lyrId1 = this.id + "Container"; 74 var lyrId2 = this.id + "Content"; 75 var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]; 76 if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2); 77 var temp; 78 79 if (!obj1 || !obj2) 80 window.setTimeout(this.gRef + ".load()", 100); 80 81 else { 81 this.container = obj1 82 this.menu = obj2 83 this.style = this.ns4 ? this.menu : this.menu.style 84 this.homePos = eval("0" + this.dirType + this.dim) 85 this.outPos = 0 86 this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 82 this.container = obj1; 83 this.menu = obj2; 84 this.style = this.ns4 ? this.menu : this.menu.style; 85 this.homePos = eval("0" + this.dirType + this.dim); 86 this.outPos = 0; 87 this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen ; 87 88 88 89 // set event handlers. 89 90 if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT); 90 this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')") 91 this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')") 91 this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')"); 92 this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')"); 92 93 93 94 //set initial state 94 this.endSlide() 95 this.endSlide(); 95 96 } 96 } 97 }; 97 98 98 99 ypSlideOutMenu.showMenu = function(id) 99 100 { 100 var reg = ypSlideOutMenu.Registry 101 var obj = ypSlideOutMenu.Registry[id] 101 var reg = ypSlideOutMenu.Registry; 102 var obj = ypSlideOutMenu.Registry[id]; 102 103 103 104 //document.all.select.style="visibily:hidden"; … … 105 106 106 107 //temporarly hide all selectboxes to fix IE bug with z-index 107 if(document.all) 108 if(document.all); 108 109 { 109 110 for (var i=0; i<document.all.length; i++) { 110 o = document.all(i) 111 o = document.all(i); 111 112 if (o.type == 'select-one' || o.type == 'select-multiple') { 112 113 // todo: add check for select in div? … … 118 119 119 120 if (obj.container) { 120 obj.over = true 121 obj.over = true; 121 122 122 123 // close other menus. 123 for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu) 124 for (menu in reg) if (id != menu) ypSlideOutMenu.hide(menu); 124 125 125 126 // if this menu is scheduled to close, cancel it. 126 if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) } 127 if (obj.hideTimer) { 128 reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer); 129 } 127 130 128 131 // if this menu is closed, open it. 129 if (!obj.open && !obj.aniTimer) reg[id].startSlide(true) 132 if (!obj.open && !obj.aniTimer) reg[id].startSlide(true); 130 133 } 131 } 134 }; 132 135 133 136 ypSlideOutMenu.hideMenu = function(id) … … 135 138 // schedules the menu to close after <hideDelay> ms, which 136 139 // gives the user time to cancel the action if they accidentally moused out 137 var obj = ypSlideOutMenu.Registry[id] 140 var obj = ypSlideOutMenu.Registry[id]; 138 141 if (obj.container) { 139 if (obj.hideTimer) window.clearTimeout(obj.hideTimer) 142 if (obj.hideTimer) window.clearTimeout(obj.hideTimer); 140 143 obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay); 141 144 } 142 } 145 }; 143 146 144 147 ypSlideOutMenu.hide = function(id) 145 148 { 146 var obj = ypSlideOutMenu.Registry[id] 147 obj.over = false 148 149 if (obj.hideTimer) window.clearTimeout(obj.hideTimer) 149 var obj = ypSlideOutMenu.Registry[id]; 150 obj.over = false; 151 152 if (obj.hideTimer) window.clearTimeout(obj.hideTimer); 150 153 151 154 // flag that this scheduled event has occured. 152 obj.hideTimer = 0 155 obj.hideTimer = 0; 153 156 154 157 // if this menu is open, close it. 155 if (obj.open && !obj.aniTimer) obj.startSlide(false) 158 if (obj.open && !obj.aniTimer) obj.startSlide(false); 156 159 157 160 //show all selectboxes again to fix IE bug with z-index … … 159 162 { 160 163 for (var i=0; i<document.all.length; i++) { 161 o = document.all(i) 164 o = document.all(i); 162 165 if (o.type == 'select-one' || o.type == 'select-multiple') { 163 166 // todo: add check for select in div? … … 169 172 170 173 174 }; 175 176 ypSlideOutMenu.prototype.startSlide = function(open) { 177 this[open ? "onactivate" : "ondeactivate"](); 178 this.open = open; 179 if (open) this.setVisibility(true); 180 this.startTime = (new Date()).getTime() ; 181 this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution); 182 }; 183 184 ypSlideOutMenu.prototype.slide = function() { 185 var elapsed = (new Date()).getTime() - this.startTime; 186 if (elapsed > ypSlideOutMenu.aniLen) this.endSlide(); 187 else { 188 var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst); 189 if (this.open && this.dirType == "-") d = -d; 190 else if (this.open && this.dirType == "+") d = -d; 191 else if (!this.open && this.dirType == "-") d = -this.dim + d; 192 else d = this.dim + d; 193 194 this.moveTo(d); 171 195 } 172 173 ypSlideOutMenu.prototype.startSlide = function(open) { 174 this[open ? "onactivate" : "ondeactivate"]() 175 this.open = open 176 if (open) this.setVisibility(true) 177 this.startTime = (new Date()).getTime() 178 this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution) 179 } 180 181 ypSlideOutMenu.prototype.slide = function() { 182 var elapsed = (new Date()).getTime() - this.startTime 183 if (elapsed > ypSlideOutMenu.aniLen) this.endSlide() 184 else { 185 var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst) 186 if (this.open && this.dirType == "-") d = -d 187 else if (this.open && this.dirType == "+") d = -d 188 else if (!this.open && this.dirType == "-") d = -this.dim + d 189 else d = this.dim + d 190 191 this.moveTo(d) 196 }; 197 198 ypSlideOutMenu.prototype.endSlide = function() { 199 this.aniTimer = window.clearTimeout(this.aniTimer); 200 this.moveTo(this.open ? this.outPos : this.homePos); 201 if (!this.open) this.setVisibility(false); 202 if ((this.open && !this.over) || (!this.open && this.over)) { 203 this.startSlide(this.over); 192 204 } 193 } 194 195 ypSlideOutMenu.prototype.endSlide = function() { 196 this.aniTimer = window.clearTimeout(this.aniTimer) 197 this.moveTo(this.open ? this.outPos : this.homePos) 198 if (!this.open) this.setVisibility(false) 199 if ((this.open && !this.over) || (!this.open && this.over)) { 200 this.startSlide(this.over) 201 } 202 } 205 }; 203 206 204 207 ypSlideOutMenu.prototype.setVisibility = function(bShow) { 205 var s = this.ns4 ? this.container : this.container.style 206 s.visibility = bShow ? "visible" : "hidden" 207 } 208 var s = this.ns4 ? this.container : this.container.style; 209 s.visibility = bShow ? "visible" : "hidden"; 210 }; 208 211 ypSlideOutMenu.prototype.moveTo = function(p) { 209 this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px" 210 } 212 this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"; 213 }; 211 214 ypSlideOutMenu.prototype.getPos = function(c) { 212 return parseInt(this.style[c]) 213 } 215 return parseInt(this.style[c]); 216 }; 214 217 215 218 // events 216 ypSlideOutMenu.prototype.onactivate = function() { } 217 ypSlideOutMenu.prototype.ondeactivate = function() { } 219 ypSlideOutMenu.prototype.onactivate = function() { }; 220 ypSlideOutMenu.prototype.ondeactivate = function() { };
Note: See TracChangeset
for help on using the changeset viewer.