Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

appframe.js 3.2 KiB

13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
13 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. wn.ui.AppFrame = Class.extend({
  2. init: function(parent, title) {
  3. this.buttons = {};
  4. this.$w = $('<div></div>').appendTo(parent);
  5. this.$titlebar = $('<div class="appframe-titlebar">\
  6. <span class="appframe-title"></span>\
  7. <span class="close">&times;</span>\
  8. </div>').appendTo(this.$w);
  9. this.$w.find('.close').click(function() {
  10. window.history.back();
  11. })
  12. if(title) this.title(title);
  13. },
  14. title: function(txt) {
  15. this.clear_breadcrumbs();
  16. this.add_breadcrumb(txt);
  17. },
  18. add_button: function(label, click, icon) {
  19. this.add_toolbar();
  20. args = { label: label, icon:'' };
  21. if(icon) {
  22. args.icon = '<i class="icon '+icon+'"></i>';
  23. }
  24. this.buttons[label] = $(repl('<button class="btn btn-small">\
  25. %(icon)s %(label)s</button>', args))
  26. .click(click)
  27. .appendTo(this.toolbar);
  28. return this.buttons[label];
  29. },
  30. add_help_button: function(txt) {
  31. this.make_toolbar();
  32. $('<button class="btn btn-small" style="float:right;" button-type="help">\
  33. <b>?</b></button>')
  34. .data('help-text', txt)
  35. .click(function() { msgprint($(this).data('help-text'), 'Help'); })
  36. .appendTo(this.toolbar);
  37. },
  38. clear_buttons: function() {
  39. this.toolbar && this.toolbar.empty();
  40. },
  41. add_breadcrumb: function(html) {
  42. if(!this.$breadcrumbs)
  43. this.$breadcrumbs = $('</span>\
  44. <span class="breadcrumb-area"></span>').appendTo(this.$titlebar);
  45. var crumb = $('<span>').html(html);
  46. // first breadcrumb is a title
  47. if(!this.$breadcrumbs.find('span').length) {
  48. crumb.addClass('appframe-title');
  49. }
  50. crumb.appendTo(this.$breadcrumbs);
  51. },
  52. clear_breadcrumbs: function() {
  53. this.$breadcrumbs && this.$breadcrumbs.empty();
  54. },
  55. add_toolbar: function() {
  56. if(!this.toolbar)
  57. this.$w.append('<div class="appframe-toolbar"></div>');
  58. this.toolbar = this.$w.find('.appframe-toolbar');
  59. },
  60. add_label: function(label) {
  61. return $("<span class='label'>"+label+" </span>").appendTo(this.toolbar);
  62. },
  63. add_select: function(label, options) {
  64. this.add_toolbar();
  65. return $("<select style='width: 160px;'>").add_options(options).appendTo(this.toolbar);
  66. },
  67. add_data: function(label) {
  68. this.add_toolbar();
  69. return $("<input style='width: 100px;' placeholder='"+ label +"'>")
  70. .appendTo(this.toolbar);
  71. },
  72. add_date: function(label, date) {
  73. this.add_toolbar();
  74. return $("<input style='width: 80px;'>").datepicker({
  75. dateFormat: sys_defaults.date_format.replace("yyyy", "yy"),
  76. changeYear: true,
  77. }).val(dateutil.str_to_user(date) || "").appendTo(this.toolbar);
  78. },
  79. });
  80. // parent, title, single_column
  81. // standard page with appframe
  82. wn.ui.make_app_page = function(opts) {
  83. if(opts.single_column) {
  84. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
  85. <div class="layout-appframe"></div>\
  86. <div class="layout-main"></div>\
  87. </div>');
  88. } else {
  89. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-background">\
  90. <div class="layout-appframe"></div>\
  91. <div class="layout-main-section"></div>\
  92. <div class="layout-side-section"></div>\
  93. <div class="clear"></div>\
  94. </div>');
  95. }
  96. opts.parent.appframe = new wn.ui.AppFrame($(opts.parent).find('.layout-appframe'));
  97. if(opts.title) opts.parent.appframe.title(opts.title);
  98. }