You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

appframe.js 2.5 KiB

13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. make_toolbar: function() {
  18. if(!this.$w.find('.appframe-toolbar').length)
  19. this.$w.append('<div class="appframe-toolbar"></div>');
  20. },
  21. add_button: function(label, click, icon) {
  22. this.make_toolbar();
  23. args = { label: label, icon:'' };
  24. if(icon) {
  25. args.icon = '<i class="icon '+icon+'"></i>';
  26. }
  27. this.buttons[label] = $(repl('<button class="btn btn-small">\
  28. %(icon)s %(label)s</button>', args))
  29. .click(click)
  30. .appendTo(this.$w.find('.appframe-toolbar'));
  31. return this.buttons[label];
  32. },
  33. add_help_button: function(txt) {
  34. this.make_toolbar();
  35. $('<button class="btn btn-small" style="float:right;" button-type="help">\
  36. <b>?</b></button>')
  37. .data('help-text', txt)
  38. .click(function() { msgprint($(this).data('help-text'), 'Help'); })
  39. .appendTo(this.$w.find('.appframe-toolbar'));
  40. },
  41. clear_buttons: function() {
  42. this.$w.find('.appframe-toolbar').empty();
  43. },
  44. add_breadcrumb: function(html) {
  45. if(!this.$breadcrumbs)
  46. this.$breadcrumbs = $('</span>\
  47. <span class="breadcrumb-area"></span>').appendTo(this.$titlebar);
  48. var crumb = $('<span>').html(html);
  49. // first breadcrumb is a title
  50. if(!this.$breadcrumbs.find('span').length) {
  51. crumb.addClass('appframe-title');
  52. }
  53. crumb.appendTo(this.$breadcrumbs);
  54. },
  55. clear_breadcrumbs: function() {
  56. this.$breadcrumbs && this.$breadcrumbs.empty();
  57. }
  58. });
  59. // parent, title, single_column
  60. // standard page with appframe
  61. wn.ui.make_app_page = function(opts) {
  62. if(opts.single_column) {
  63. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
  64. <div class="layout-appframe"></div>\
  65. <div class="layout-main"></div>\
  66. </div>');
  67. } else {
  68. $(opts.parent).html('<div class="layout-wrapper layout-wrapper-background">\
  69. <div class="layout-appframe"></div>\
  70. <div class="layout-main-section"></div>\
  71. <div class="layout-side-section"></div>\
  72. <div class="clear"></div>\
  73. </div>');
  74. }
  75. opts.parent.appframe = new wn.ui.AppFrame($(opts.parent).find('.layout-appframe'));
  76. if(opts.title) opts.parent.appframe.title(opts.title);
  77. }