Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

65 righe
2.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. wn.ui.Button = function(args) {
  23. var me = this;
  24. $.extend(this, {
  25. make: function() {
  26. me.btn = wn.dom.add(args.parent, 'button', 'btn ' + (args.css_class || 'btn-default'));
  27. me.btn.args = args;
  28. // ajax loading
  29. me.loading_img = wn.dom.add(me.btn.args.parent,'img','',{margin:'0px 4px -2px 4px', display:'none'});
  30. me.loading_img.src= 'lib/images/ui/button-load.gif';
  31. // label
  32. me.btn.innerHTML = args.label;
  33. // onclick
  34. me.btn.user_onclick = args.onclick;
  35. $(me.btn).bind('click', function() {
  36. if(!this.disabled && this.user_onclick)
  37. this.user_onclick(this);
  38. })
  39. // bc
  40. me.btn.set_working = me.set_working;
  41. me.btn.done_working = me.done_working;
  42. // style
  43. if(me.btn.args.style)
  44. wn.dom.css(me.btn, args.style);
  45. },
  46. set_working: function() {
  47. me.btn.disabled = 'disabled';
  48. $(me.loading_img).css('display','inline');
  49. },
  50. done_working: function() {
  51. me.btn.disabled = false;
  52. $(me.loading_img).toggle(false);
  53. }
  54. });
  55. this.make();
  56. }