Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

86 wiersze
2.8 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. // recent document list
  23. wn.ui.toolbar.RecentDocs = Class.extend({
  24. init:function() {
  25. $('.navbar .nav:first').append('<li class="dropdown">\
  26. <a class="dropdown-toggle" data-toggle="dropdown" href="#" \
  27. title="'+wn._("History")+'"\
  28. onclick="return false;">'+wn._("History")+'</i></a>\
  29. <ul class="dropdown-menu" id="toolbar-recent"></ul>\
  30. </li>');
  31. this.setup();
  32. this.bind_events();
  33. },
  34. bind_events: function() {
  35. // notify on rename
  36. var me = this;
  37. $(document).bind('rename', function(event, dt, old_name, new_name) {
  38. me.rename_notify(dt, old_name, new_name)
  39. });
  40. },
  41. rename_notify: function(dt, old, name) {
  42. this.remove(dt, old);
  43. this.add(dt, name, 1);
  44. },
  45. add: function(dt, dn, on_top) {
  46. if(this.istable(dt)) return;
  47. this.remove(dt, dn);
  48. var html = repl('<li data-docref="%(dt)s/%(dn)s">\
  49. <a href="#Form/%(dt)s/%(dn)s">\
  50. <i class="icon-fixed-width %(icon)s"></i> \
  51. %(dn)s</span>\
  52. </a></li>',
  53. {dt:dt, dn:dn, icon:wn.boot.doctype_icons[dt]});
  54. if(on_top) {
  55. $('#toolbar-recent').prepend(html);
  56. } else {
  57. $('#toolbar-recent').append(html);
  58. }
  59. },
  60. istable: function(dt) {
  61. return locals.DocType[dt] && locals.DocType[dt].istable || false;
  62. },
  63. remove: function(dt, dn) {
  64. $(repl('#toolbar-recent li[data-docref="%(dt)s/%(dn)s"]', {dt:dt, dn:dn})).remove();
  65. },
  66. setup: function() {
  67. // add menu items
  68. var rlist = JSON.parse(profile.recent||"[]");
  69. var m = rlist.length;
  70. if(m>15)m=15;
  71. for (var i=0;i<m;i++) {
  72. var rd = rlist[i]
  73. if(rd[1]) {
  74. var dt = rd[0]; var dn = rd[1];
  75. try {
  76. this.add(dt, dn, 0);
  77. } catch(e) {
  78. // don't crash
  79. }
  80. }
  81. }
  82. }
  83. });