_RowManager.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. define("dojox/grid/_RowManager", [
  2. "dojo/_base/declare",
  3. "dojo/_base/lang",
  4. "dojo/dom-class"
  5. ], function(declare, lang, domClass){
  6. var setStyleText = function(inNode, inStyleText){
  7. if(inNode.style.cssText == undefined){
  8. inNode.setAttribute("style", inStyleText);
  9. }else{
  10. inNode.style.cssText = inStyleText;
  11. }
  12. };
  13. return declare("dojox.grid._RowManager", null, {
  14. // Stores information about grid rows. Owned by grid and used internally.
  15. constructor: function(inGrid){
  16. this.grid = inGrid;
  17. },
  18. linesToEms: 2,
  19. overRow: -2,
  20. // styles
  21. prepareStylingRow: function(inRowIndex, inRowNode){
  22. return {
  23. index: inRowIndex,
  24. node: inRowNode,
  25. odd: Boolean(inRowIndex&1),
  26. selected: !!this.grid.selection.isSelected(inRowIndex),
  27. over: this.isOver(inRowIndex),
  28. customStyles: "",
  29. customClasses: "dojoxGridRow"
  30. };
  31. },
  32. styleRowNode: function(inRowIndex, inRowNode){
  33. var row = this.prepareStylingRow(inRowIndex, inRowNode);
  34. this.grid.onStyleRow(row);
  35. this.applyStyles(row);
  36. },
  37. applyStyles: function(inRow){
  38. var i = inRow;
  39. i.node.className = i.customClasses;
  40. var h = i.node.style.height;
  41. setStyleText(i.node, i.customStyles + ';' + (i.node._style||''));
  42. i.node.style.height = h;
  43. },
  44. updateStyles: function(inRowIndex){
  45. this.grid.updateRowStyles(inRowIndex);
  46. },
  47. // states and events
  48. setOverRow: function(inRowIndex){
  49. var last = this.overRow;
  50. this.overRow = inRowIndex;
  51. if((last!=this.overRow)&&(lang.isString(last) || last >= 0)){
  52. this.updateStyles(last);
  53. }
  54. this.updateStyles(this.overRow);
  55. },
  56. isOver: function(inRowIndex){
  57. return (this.overRow == inRowIndex && !domClass.contains(this.grid.domNode, "dojoxGridColumnResizing"));
  58. }
  59. });
  60. });