_RowManager.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.grid._RowManager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.grid._RowManager"] = true;
  8. dojo.provide("dojox.grid._RowManager");
  9. (function(){
  10. var setStyleText = function(inNode, inStyleText){
  11. if(inNode.style.cssText == undefined){
  12. inNode.setAttribute("style", inStyleText);
  13. }else{
  14. inNode.style.cssText = inStyleText;
  15. }
  16. };
  17. dojo.declare("dojox.grid._RowManager", null, {
  18. // Stores information about grid rows. Owned by grid and used internally.
  19. constructor: function(inGrid){
  20. this.grid = inGrid;
  21. },
  22. linesToEms: 2,
  23. overRow: -2,
  24. // styles
  25. prepareStylingRow: function(inRowIndex, inRowNode){
  26. return {
  27. index: inRowIndex,
  28. node: inRowNode,
  29. odd: Boolean(inRowIndex&1),
  30. selected: !!this.grid.selection.isSelected(inRowIndex),
  31. over: this.isOver(inRowIndex),
  32. customStyles: "",
  33. customClasses: "dojoxGridRow"
  34. };
  35. },
  36. styleRowNode: function(inRowIndex, inRowNode){
  37. var row = this.prepareStylingRow(inRowIndex, inRowNode);
  38. this.grid.onStyleRow(row);
  39. this.applyStyles(row);
  40. },
  41. applyStyles: function(inRow){
  42. var i = inRow;
  43. i.node.className = i.customClasses;
  44. var h = i.node.style.height;
  45. setStyleText(i.node, i.customStyles + ';' + (i.node._style||''));
  46. i.node.style.height = h;
  47. },
  48. updateStyles: function(inRowIndex){
  49. this.grid.updateRowStyles(inRowIndex);
  50. },
  51. // states and events
  52. setOverRow: function(inRowIndex){
  53. var last = this.overRow;
  54. this.overRow = inRowIndex;
  55. if((last!=this.overRow)&&(dojo.isString(last) || last >= 0)){
  56. this.updateStyles(last);
  57. }
  58. this.updateStyles(this.overRow);
  59. },
  60. isOver: function(inRowIndex){
  61. return (this.overRow == inRowIndex && !dojo.hasClass(this.grid.domNode, "dojoxGridColumnResizing"));
  62. }
  63. });
  64. })();
  65. }