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.
 
 
 
 
 
 

56 lines
1.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. var pending_req = 0;
  23. var fcount = 0;
  24. var dialog_back;
  25. function set_loading() {
  26. pending_req++;
  27. $('#spinner').css('visibility', 'visible');
  28. $('body').css('cursor', 'progress');
  29. }
  30. function hide_loading() {
  31. pending_req--;
  32. if(!pending_req){
  33. $('body').css('cursor', 'default');
  34. $('#spinner').css('visibility', 'hidden');
  35. }
  36. }
  37. function freeze() {
  38. // blur
  39. if(!dialog_back) {
  40. dialog_back = $a($i('body_div'), 'div', 'dialog_back');
  41. $(dialog_back).css('opacity', 0.6);
  42. }
  43. $ds(dialog_back);
  44. fcount++;
  45. }
  46. function unfreeze() {
  47. if(!fcount)return; // anything open?
  48. fcount--;
  49. if(!fcount) {
  50. $dh(dialog_back);
  51. }
  52. }