mui.dialog.confirm.js 711 B

12345678910111213141516171819202122232425262728293031323334353637
  1. (function($, window) {
  2. /**
  3. * 确认消息框
  4. */
  5. $.confirm = function(message, title, btnArray, callback) {
  6. if ($.os.plus) {
  7. if (typeof message === 'undefined') {
  8. return;
  9. } else {
  10. if (typeof title === 'function') {
  11. callback = title;
  12. title = null;
  13. btnArray = null;
  14. } else if (typeof btnArray === 'function') {
  15. callback = btnArray;
  16. btnArray = null;
  17. }
  18. $.plusReady(function() {
  19. plus.nativeUI.confirm(message, callback, title, btnArray);
  20. });
  21. }
  22. } else {
  23. //H5版本,0为确认,1为取消
  24. if (window.confirm(message)) {
  25. callback({
  26. index: 0
  27. });
  28. } else {
  29. callback({
  30. index: 1
  31. });
  32. }
  33. }
  34. };
  35. })(mui, window);