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.
 
 
 
 
 
 

92 rivejä
3.2 KiB

  1. // Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. //
  3. // MIT License (MIT)
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a
  6. // copy of this software and associated documentation files (the "Software"),
  7. // to deal in the Software without restriction, including without limitation
  8. // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. // and/or sell copies of the Software, and to permit persons to whom the
  10. // Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. //
  22. /* standard page header
  23. + wrapper
  24. + [table]
  25. + [r1c1]
  26. + main_head
  27. + sub_head
  28. + [r1c2]
  29. + close_btn
  30. + toolbar_area
  31. + tag_area
  32. + seperator
  33. */
  34. var def_ph_style = {
  35. wrapper: {marginBottom:'16px', backgroundColor:'#EEE'}
  36. ,main_heading: { }
  37. ,sub_heading: { marginBottom:'8px', color:'#555', display:'none' }
  38. ,separator: { borderTop:'3px solid #777' } // show this when there is no toolbar
  39. ,toolbar_area: { padding:'3px 0px', display:'none',borderBottom:'1px solid #AAA'}
  40. }
  41. function PageHeader(parent, main_text, sub_text) {
  42. this.wrapper = $a(parent,'div','page_header');
  43. this.t1 = make_table($a(this.wrapper,'div','',def_ph_style.wrapper.backgroundColor), 1, 2, '100%', [null, '100px'], {padding: '2px'});
  44. $y(this.t1, {borderCollapse:'collapse'})
  45. this.lhs = $td(this.t1, 0, 0);
  46. this.main_head = $a(this.lhs, 'h1', '', def_ph_style.main_heading);
  47. this.sub_head = $a(this.lhs, 'h4', '', def_ph_style.sub_heading);
  48. this.separator = $a(this.wrapper, 'div', '', def_ph_style.separator);
  49. this.toolbar_area = $a(this.wrapper, 'div', '', def_ph_style.toolbar_area);
  50. this.padding_area = $a(this.wrapper, 'div', '', {padding:'3px'});
  51. // close btn
  52. $y($td(this.t1, 0, 1),{textAlign:'right', padding:'3px'});
  53. this.close_btn = $a($td(this.t1, 0, 1), 'span', 'close', {}, '×');
  54. this.close_btn.onclick = function() { nav_obj.show_last_open(); };
  55. if(main_text) this.main_head.innerHTML = main_text;
  56. if(sub_text) this.sub_head.innerHTML = sub_text;
  57. this.buttons = {};
  58. this.buttons2 = {};
  59. }
  60. PageHeader.prototype.add_button = function(label, fn, bold, icon, green) {
  61. var tb = this.toolbar_area;
  62. if(this.buttons[label]) return;
  63. var btn = $btn(tb,label,fn,{marginRight:'4px'}, (green ? 'btn-info' : ''));
  64. if(bold) $y(btn,{fontWeight:'bold'});
  65. this.buttons[label]=btn;
  66. $ds(this.toolbar_area);
  67. return btn;
  68. }
  69. PageHeader.prototype.clear_toolbar = function() {
  70. this.toolbar_area.innerHTML = '';
  71. this.buttons = {};
  72. }
  73. PageHeader.prototype.make_buttonset = function() {
  74. $(this.toolbar_area).buttonset();
  75. }