ligerToolBar.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * jQuery ligerUI 1.1.9
  3. *
  4. * http://ligerui.com
  5. *
  6. * Author daomi 2012 [ gd_star@163.com ]
  7. *
  8. */
  9. (function ($)
  10. {
  11. $.fn.ligerToolBar = function (options)
  12. {
  13. return $.ligerui.run.call(this, "ligerToolBar", arguments);
  14. };
  15. $.fn.ligerGetToolBarManager = function ()
  16. {
  17. return $.ligerui.run.call(this, "ligerGetToolBarManager", arguments);
  18. };
  19. $.ligerDefaults.ToolBar = {};
  20. $.ligerMethos.ToolBar = {};
  21. $.ligerui.controls.ToolBar = function (element, options)
  22. {
  23. $.ligerui.controls.ToolBar.base.constructor.call(this, element, options);
  24. };
  25. $.ligerui.controls.ToolBar.ligerExtend($.ligerui.core.UIComponent, {
  26. __getType: function ()
  27. {
  28. return 'ToolBar';
  29. },
  30. __idPrev: function ()
  31. {
  32. return 'ToolBar';
  33. },
  34. _extendMethods: function ()
  35. {
  36. return $.ligerMethos.ToolBar;
  37. },
  38. _render: function ()
  39. {
  40. var g = this, p = this.options;
  41. g.toolBar = $(this.element);
  42. g.toolBar.addClass("l-toolbar");
  43. g.set(p);
  44. },
  45. _setItems: function (items)
  46. {
  47. var g = this;
  48. $(items).each(function (i, item)
  49. {
  50. g.addItem(item);
  51. });
  52. },
  53. addItem: function (item)
  54. {
  55. var g = this, p = this.options;
  56. if (item.line)
  57. {
  58. g.toolBar.append('<div class="l-bar-separator"></div>');
  59. return;
  60. }
  61. var ditem = $('<div class="l-toolbar-item l-panel-btn"><span></span><div class="l-panel-btn-l"></div><div class="l-panel-btn-r"></div></div>');
  62. g.toolBar.append(ditem);
  63. item.id && ditem.attr("toolbarid", item.id);
  64. if (item.img)
  65. {
  66. ditem.append("<img src='" + item.img + "' />");
  67. ditem.addClass("l-toolbar-item-hasicon");
  68. }
  69. else if (item.icon)
  70. {
  71. ditem.append("<div class='l-icon l-icon-" + item.icon + "'></div>");
  72. ditem.addClass("l-toolbar-item-hasicon");
  73. }
  74. item.text && $("span:first", ditem).html(item.text);
  75. item.disable && ditem.addClass("l-toolbar-item-disable");
  76. item.click && ditem.click(function () { item.click(item); });
  77. ditem.hover(function ()
  78. {
  79. $(this).addClass("l-panel-btn-over");
  80. }, function ()
  81. {
  82. $(this).removeClass("l-panel-btn-over");
  83. });
  84. }
  85. });
  86. })(jQuery);