Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

87 строки
2.6 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. var msg_dialog;
  23. function msgprint(msg, title) {
  24. if(!msg) return;
  25. if(msg instanceof Array) {
  26. $.each(msg, function(i,v) {
  27. if(v)msgprint(v);
  28. })
  29. return;
  30. }
  31. if(typeof(msg)!='string')
  32. msg = JSON.stringify(msg);
  33. // small message
  34. if(msg.substr(0,8)=='__small:') {
  35. show_alert(msg.substr(8)); return;
  36. }
  37. if(!msg_dialog) {
  38. msg_dialog = new wn.ui.Dialog({
  39. title:"Message",
  40. onhide: function() {
  41. msg_dialog.msg_area.empty();
  42. }
  43. });
  44. msg_dialog.msg_area = $('<div class="msgprint">')
  45. .appendTo(msg_dialog.body);
  46. }
  47. if(msg.search(/<br>|<p>|<li>/)==-1)
  48. msg = replace_newlines(msg);
  49. msg_dialog.set_title(title || 'Message')
  50. msg_dialog.msg_area.append(msg);
  51. msg_dialog.show();
  52. return msg_dialog;
  53. }
  54. // Floating Message
  55. var growl_area;
  56. function show_alert(txt, id) {
  57. if(!growl_area) {
  58. if(!$('#dialog-container').length) {
  59. $('<div id="dialog-container">').appendTo('body');
  60. }
  61. growl_area = $a($i('dialog-container'), 'div', '', {position:'fixed', bottom:'8px', right:'8px', width: '320px', zIndex:10});
  62. }
  63. var wrapper = $a(growl_area, 'div', '', {position:'relative'});
  64. var body = $a(wrapper, 'div', 'notice');
  65. // close
  66. var c = $a(body, 'i', 'icon-remove-sign', {cssFloat:'right', cursor: 'pointer'});
  67. $(c).click(function() { $dh(this.wrapper) });
  68. c.wrapper = wrapper;
  69. // text
  70. var t = $a(body, 'div', '', { color:'#FFF' });
  71. $(t).html(txt);
  72. if(id) { $(t).attr('id', id); }
  73. $(wrapper).hide().fadeIn(1000);
  74. }