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.

button.js 1.1 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. wn.ui.Button = function(args) {
  2. wn.require('lib/css/ui/buttons.css')
  3. var me = this;
  4. $.extend(this, {
  5. make: function() {
  6. me.btn = wn.dom.add(args.parent, 'button', args.css_class || 'clean-gray');
  7. // ajax loading
  8. me.loading_img = wn.dom.add(args.parent,'img','',{margin:'0px 4px -2px 4px', display:'none'});
  9. me.loading_img.src= 'lib/images/ui/button-load.gif';
  10. if(args.is_ajax) wn.dom.css(me.btn,{marginRight:'24px'});
  11. // label
  12. me.btn.innerHTML = args.label;
  13. // onclick
  14. me.btn.user_onclick = args.onclick;
  15. $(me.btn).bind('click', function() {
  16. if(!this.disabled) this.user_onclick(this);
  17. })
  18. // bc
  19. me.btn.set_working = me.set_working;
  20. me.btn.done_working = me.done_working;
  21. // style
  22. if(args.style)
  23. wn.dom.css(me.btn, args.style);
  24. },
  25. set_working: function() {
  26. me.btn.disabled = 'disabled';
  27. wn.dom.show(me.loading_img, 'inline');
  28. if(args.is_ajax)
  29. wn.dom.css(me.btn,{marginRight:'0px'});
  30. },
  31. done_working: function() {
  32. me.btn.disabled = false;
  33. wn.dom.hide(me.loading_img);
  34. if(args.is_ajax)
  35. wn.dom.css(me.btn,{marginRight:'24px'});
  36. }
  37. });
  38. this.make();
  39. }