1 (function ($, rf) { 2 3 rf.ui = rf.ui || {}; 4 5 rf.ui.PopupPanel.Sizer = function(id, modalPanel, cursor, sizer) { 6 7 $super.constructor.call(this, id); 8 9 }; 10 11 var $super = rf.BaseComponent.extend(rf.ui.PopupPanel.Sizer); 12 var $super = rf.ui.PopupPanel.Sizer.$super; 13 $.extend(rf.ui.PopupPanel.Sizer.prototype, (function (options) { 14 return { 15 16 name: "richfaces.ui.PopupPanel.Sizer", 17 18 doSetupSize: function (modalPanel, elt) { 19 var width = 0; 20 var height = 0; 21 var element = $(rf.getDomElement(elt)); 22 var reductionData = modalPanel.reductionData; 23 24 if (reductionData) { 25 if (reductionData.w) { 26 width = reductionData.w / 2; 27 } 28 29 if (reductionData.h) { 30 height = reductionData.h / 2; 31 } 32 } 33 34 if (width > 0) { 35 if (elt.clientWidth > width) { 36 if (!elt.reducedWidth) { 37 elt.reducedWidth = element.css('width'); 38 } 39 element.css('width', width + 'px'); 40 } else if (width < 4 && elt.reducedWidth == 4 + 'px') { 41 element.css('width', width + 'px'); 42 } 43 } else { 44 if (elt.reducedWidth) { 45 element.css('width', elt.reducedWidth); 46 elt.reducedWidth = undefined; 47 } 48 } 49 50 if (height > 0) { 51 if (elt.clientHeight > height) { 52 if (!elt.reducedHeight) { 53 elt.reducedHeight = element.css('height'); 54 } 55 elt.style.height = height + 'px'; 56 } else if (height < 4 && elt.reducedHeight == 4 + 'px') { 57 element.css('height', height + 'px'); 58 } 59 } else { 60 if (elt.reducedHeight) { 61 element.css('height', elt.reducedHeight); 62 elt.reducedHeight = undefined; 63 } 64 } 65 }, 66 67 doSetupPosition: function (modalPanel, elt, left, top) { 68 var element = $(rf.getDomElement(elt)); 69 if (!isNaN(left) && !isNaN(top)) { 70 element.css('left', left + 'px'); 71 element.css('top', top + 'px'); 72 } 73 }, 74 75 doPosition: function (modalPanel, elt) { 76 77 }, 78 79 doDiff: function (dx, dy) { 80 81 } 82 } 83 84 })()); 85 rf.ui.PopupPanel.Sizer.Diff = function(dX, dY, dWidth, dHeight) { 86 87 this.deltaX = dX; 88 this.deltaY = dY; 89 90 this.deltaWidth = dWidth; 91 this.deltaHeight = dHeight; 92 93 }; 94 95 rf.ui.PopupPanel.Sizer.Diff.EMPTY = new rf.ui.PopupPanel.Sizer.Diff(0, 0, 0, 0), 96 97 rf.ui.PopupPanel.Sizer.N = function() { 98 99 } 100 101 $.extend(rf.ui.PopupPanel.Sizer.N.prototype, rf.ui.PopupPanel.Sizer.prototype); 102 $.extend(rf.ui.PopupPanel.Sizer.N.prototype, { 103 104 105 name: "richfaces.ui.PopupPanel.Sizer.N", 106 107 doPosition : function (popupPanel, elt) { 108 var element = $(rf.getDomElement(elt)); 109 element.css('width', popupPanel.width() + 'px'); 110 this.doSetupPosition(popupPanel, elt, 0, 0); 111 }, 112 113 doDiff : function(dx, dy) { 114 return new rf.ui.PopupPanel.Sizer.Diff(0, dy, 0, -dy); 115 } 116 117 }); 118 119 rf.ui.PopupPanel.Sizer.NW = function() { 120 121 } 122 $.extend(rf.ui.PopupPanel.Sizer.NW.prototype, rf.ui.PopupPanel.Sizer.prototype); 123 $.extend(rf.ui.PopupPanel.Sizer.NW.prototype, { 124 125 name: "richfaces.ui.PopupPanel.Sizer.NW", 126 127 doPosition : function (popupPanel, elt) { 128 this.doSetupSize(popupPanel, elt); 129 this.doSetupPosition(popupPanel, elt, 0, 0); 130 }, 131 132 doDiff : function(dx, dy) { 133 return new rf.ui.PopupPanel.Sizer.Diff(dx, dy, -dx, -dy); 134 } 135 136 }); 137 138 rf.ui.PopupPanel.Sizer.NE = function() { 139 140 } 141 $.extend(rf.ui.PopupPanel.Sizer.NE.prototype, rf.ui.PopupPanel.Sizer.prototype); 142 $.extend(rf.ui.PopupPanel.Sizer.NE.prototype, { 143 144 name: "richfaces.ui.PopupPanel.Sizer.NE", 145 146 doPosition : function (popupPanel, elt) { 147 this.doSetupSize(popupPanel, elt); 148 this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0); 149 }, 150 151 doDiff : function(dx, dy) { 152 return new rf.ui.PopupPanel.Sizer.Diff(0, dy, dx, -dy); 153 } 154 155 }); 156 157 rf.ui.PopupPanel.Sizer.E = function() { 158 159 } 160 $.extend(rf.ui.PopupPanel.Sizer.E.prototype, rf.ui.PopupPanel.Sizer.prototype); 161 $.extend(rf.ui.PopupPanel.Sizer.E.prototype, { 162 163 name: "richfaces.ui.PopupPanel.Sizer.E", 164 165 doPosition : function (popupPanel, elt) { 166 var element = $(rf.getDomElement(elt)); 167 element.css('height', popupPanel.height() + 'px'); 168 this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 0); 169 }, 170 171 doDiff : function(dx, dy) { 172 return new rf.ui.PopupPanel.Sizer.Diff(0, 0, dx, 0); 173 } 174 175 }); 176 177 rf.ui.PopupPanel.Sizer.SE = function() { 178 179 } 180 $.extend(rf.ui.PopupPanel.Sizer.SE.prototype, rf.ui.PopupPanel.Sizer.prototype); 181 $.extend(rf.ui.PopupPanel.Sizer.SE.prototype, { 182 183 name: "richfaces.ui.PopupPanel.Sizer.SE", 184 185 doPosition : function (popupPanel, elt) { 186 this.doSetupSize(popupPanel, elt); 187 this.doSetupPosition(popupPanel, elt, popupPanel.width() - elt.clientWidth, 188 popupPanel.height() - elt.clientHeight); 189 }, 190 191 doDiff : function(dx, dy) { 192 return new rf.ui.PopupPanel.Sizer.Diff(0, 0, dx, dy); 193 } 194 195 }); 196 197 rf.ui.PopupPanel.Sizer.S = function() { 198 199 } 200 $.extend(rf.ui.PopupPanel.Sizer.S.prototype, rf.ui.PopupPanel.Sizer.prototype); 201 $.extend(rf.ui.PopupPanel.Sizer.S.prototype, { 202 203 name: "richfaces.ui.PopupPanel.Sizer.S", 204 205 doPosition : function (popupPanel, elt) { 206 var element = $(rf.getDomElement(elt)); 207 element.css('width', popupPanel.width() + 'px'); 208 this.doSetupPosition(popupPanel, elt, 0, popupPanel.height() - elt.clientHeight); 209 }, 210 211 doDiff : function(dx, dy) { 212 return new rf.ui.PopupPanel.Sizer.Diff(0, 0, 0, dy); 213 } 214 215 }); 216 217 218 rf.ui.PopupPanel.Sizer.SW = function() { 219 220 } 221 $.extend(rf.ui.PopupPanel.Sizer.SW.prototype, rf.ui.PopupPanel.Sizer.prototype); 222 $.extend(rf.ui.PopupPanel.Sizer.SW.prototype, { 223 224 225 name: "richfaces.ui.PopupPanel.Sizer.SW", 226 227 doPosition : function (popupPanel, elt) { 228 this.doSetupSize(popupPanel, elt); 229 this.doSetupPosition(popupPanel, elt, 0, popupPanel.height() - elt.clientHeight); 230 }, 231 232 doDiff : function(dx, dy) { 233 return new rf.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, dy); 234 } 235 236 }); 237 238 rf.ui.PopupPanel.Sizer.W = function() { 239 240 } 241 $.extend(rf.ui.PopupPanel.Sizer.W.prototype, rf.ui.PopupPanel.Sizer.prototype); 242 $.extend(rf.ui.PopupPanel.Sizer.W.prototype, { 243 244 245 name: "richfaces.ui.PopupPanel.Sizer.W", 246 247 doPosition : function (popupPanel, elt) { 248 var element = $(rf.getDomElement(elt)); 249 element.css('height', popupPanel.height() + 'px'); 250 this.doSetupPosition(popupPanel, elt, 0, 0); 251 }, 252 253 doDiff : function(dx, dy) { 254 return new rf.ui.PopupPanel.Sizer.Diff(dx, 0, -dx, 0); 255 } 256 257 258 }); 259 260 261 rf.ui.PopupPanel.Sizer.Header = function() { 262 263 } 264 $.extend(rf.ui.PopupPanel.Sizer.Header.prototype, rf.ui.PopupPanel.Sizer.prototype); 265 $.extend(rf.ui.PopupPanel.Sizer.Header.prototype, { 266 267 268 name: "richfaces.ui.PopupPanel.Sizer.Header", 269 270 doPosition : function (popupPanel, elt) { 271 272 }, 273 274 doDiff : function(dx, dy) { 275 return new rf.ui.PopupPanel.Sizer.Diff(dx, dy, 0, 0); 276 } 277 278 279 }); 280 281 282 })(RichFaces.jQuery, window.RichFaces);