Remove the yui-ext dependency on the Datagrid javascript file
Updated 6 months, 1 week ago
| Christian Hammond | Reviewers | ||
| trunk | reviewboard | ||
| None | Navi | ||
This removes the YUI-ext requirement from the DataGrid script. We take advantage of YUI-ext in one place if it's present, but otherwise we handle things ourselves. This will make it easier for other people to directly take advantage of datagrids without needing the old, deprecated YUI-ext library.
Made sure everything's still working on both Firefox and IE.
Diff revision 1 (Latest)
- /trunk/djblets/djblets/media/js/datagrid.js: 4 changes [ 1 2 3 4 ]
| /trunk/djblets/djblets/media/js/datagrid.js | |||
|---|---|---|---|
| Revision 11765 | New Change | ||
| ... | 149 lines hidden [Expand] | ||
| 150 | 150 | ||
| 151 | /* The resulting text *should* be datagrid HTML. */ |
151 | /* The resulting text *should* be datagrid HTML. */ |
| 152 | var oldEl = getEl(gridId); |
152 | var oldEl = getEl(gridId); |
| 153 | oldEl.dom.id = ""; |
153 | oldEl.dom.id = ""; |
| 154 | 154 | ||
| 155 | YAHOO.ext.DomHelper.insertHtml("beforeBegin", oldEl.dom, |
155 | var html = res.responseText; |
| 156 | res.responseText); |
156 | |
| 157 | if (oldEl.dom.insertAdjacentHTML) { |
||
| 158 | /* Supported by IE */ |
||
| 159 | oldEl.dom.insertAdjacentHTML("beforeBegin", html); |
||
| 160 | } else { |
||
| 161 | /* Everybody else. */ |
||
| 162 | var range = oldEl.dom.ownerDocument.createRange(); |
||
| 163 | range.setStartBefore(oldEl.dom); |
||
| 164 | var newEl = range.createContextualFragment(html); |
||
| 165 | oldEl.dom.parentNode.insertBefore(newEl, oldEl.dom); |
||
| 166 | } |
||
| 157 | oldEl.remove(); |
167 | oldEl.remove(); |
| 158 | 168 | ||
| 159 | this.registerDataGrid(document.getElementById(gridId)); |
169 | this.registerDataGrid(document.getElementById(gridId)); |
| 160 | }.createDelegate(this)); |
170 | }.createDelegate(this)); |
| 161 | } |
171 | } |
| ... | 32 lines hidden [Expand] | ||
| 194 | * Initializes the object. This just wraps DDProxy.init and calls |
204 | * Initializes the object. This just wraps DDProxy.init and calls |
| 195 | * initConstraints(). |
205 | * initConstraints(). |
| 196 | */ |
206 | */ |
| 197 | init: function() { |
207 | init: function() { |
| 198 | DJBLETS.datagrids.DDColumn.superclass.init.apply(this, arguments); |
208 | DJBLETS.datagrids.DDColumn.superclass.init.apply(this, arguments); |
| 209 | |||
| 210 | /* |
||
| 211 | * YAHOO.ext.EventManager has a nice buffered onWindowResize |
||
| 212 | * function that gives us buffered resizes. It depends on some |
||
| 213 | * additional YAHOO.ext code, which is why we don't (yet) re-implement |
||
| 214 | * it. However, we may wish to do so in the future to remove the |
||
| 215 | * deprecated yui-ext support from this file. |
||
| 216 | */ |
||
| 217 | if (YAHOO.ext) { |
||
| 218 | YAHOO.ext.EventManager.onWindowResize(this.initConstraints, |
||
| 219 | this, true); |
||
| 220 | } else { |
||
| 221 | YAHOO.util.Event.on(window, "resize", |
||
| 222 | this.initConstraints.createDelegate(this)); |
||
| 223 | } |
||
| 224 | |||
| 199 | this.initConstraints(); |
225 | this.initConstraints(); |
| 200 | }, |
226 | }, |
| 201 | 227 | ||
| 202 | /* |
228 | /* |
| 203 | * Sets up the movement constraints for this column. This locks the |
229 | * Sets up the movement constraints for this column. This locks the |
| ... | 7 lines hidden [Expand] | ||
| 211 | 237 | ||
| 212 | this.setXConstraint(colRegion.left - headerRegion.left, |
238 | this.setXConstraint(colRegion.left - headerRegion.left, |
| 213 | headerRegion.right - colRegion.right); |
239 | headerRegion.right - colRegion.right); |
| 214 | this.setYConstraint(colRegion.top - headerRegion.top, |
240 | this.setYConstraint(colRegion.top - headerRegion.top, |
| 215 | headerRegion.bottom - colRegion.bottom); |
241 | headerRegion.bottom - colRegion.bottom); |
| 216 | |||
| 217 | YAHOO.ext.EventManager.onWindowResize(this.initConstraints, this, true); |
||
| 218 | }, |
242 | }, |
| 219 | 243 | ||
| 220 | /* |
244 | /* |
| 221 | * Handles the beginning of the drag. |
245 | * Handles the beginning of the drag. |
| 222 | * |
246 | * |
| ... | 169 lines hidden [Expand] | ||
- /trunk/djblets/djblets/media/js/datagrid.js: 4 changes [ 1 2 3 4 ]
Other reviews