25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

appframe.js 2.3 KiB

13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.$titlebar.find('.appframe-title').html(txt);
  16. },
  17. add_button: function(label, click, icon) {
  18. this.add_toolbar();
  19. args = { label: label, icon:'' };
  20. if(icon) {
  21. args.icon = '<i class="'+icon+'"></i>';
  22. }
  23. this.buttons[label] = $(repl('<button class="btn btn-small">\
  24. %(icon)s %(label)s</button>', args))
  25. .click(click)
  26. .appendTo(this.toolbar);
  27. return this.buttons[label];
  28. },
  29. clear_buttons: function() {
  30. this.toolbar && this.toolbar.empty();
  31. },
  32. add_toolbar: function() {
  33. if(!this.toolbar)
  34. this.$w.append('<div class="appframe-toolbar"></div>');
  35. this.toolbar = this.$w.find('.appframe-toolbar');
  36. },
  37. add_label: function(label) {
  38. return $("<span style='margin: 2px 4px;'>"+label+" </span>").appendTo(this.toolbar);
  39. },
  40. add_select: function(label, options) {
  41. this.add_toolbar();
  42. return $("<select style='width: 160px; margin: 2px 4px;'>").add_options(options).appendTo(this.toolbar);
  43. },
  44. add_date: function(label, date) {
  45. this.add_toolbar();
  46. return $("<input style='width: 80px; margin: 2px 4px;'>").datepicker({
  47. dateFormat: sys_defaults.date_format.replace("yyyy", "yy"),
  48. changeYear: true,
  49. }).val(dateutil.str_to_user(date) || "").appendTo(this.toolbar);
  50. },
  51. });
  52. // parent, title, single_column
  53. // standard page with appframe
  54. wn.ui.make_app_page = function(opts) {
  55. if(opts.single_column) {
  56. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
  57. <div class="layout-appframe"></div>\
  58. <div class="layout-main"></div>\
  59. </div>');
  60. } else {
  61. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-background">\
  62. <div class="layout-appframe"></div>\
  63. <div class="layout-main-section"></div>\
  64. <div class="layout-side-section"></div>\
  65. <div class="clear"></div>\
  66. </div>');
  67. }
  68. opts.parent.appframe = new wn.ui.AppFrame($(opts.parent).find('.layout-appframe'));
  69. if(opts.title) opts.parent.appframe.title(opts.title);
  70. }