mui.dialog.prompt.js 942 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function($, window) {
  2. /**
  3. * 输入对话框
  4. */
  5. $.prompt = function(text, defaultText, title, btnArray, callback) {
  6. if ($.os.plus) {
  7. if (typeof message === 'undefined') {
  8. return;
  9. } else {
  10. if (typeof defaultText === 'function') {
  11. callback = defaultText;
  12. defaultText = null;
  13. title = null;
  14. btnArray = null;
  15. } else if (typeof title === 'function') {
  16. callback = title;
  17. title = null;
  18. btnArray = null;
  19. } else if (typeof btnArray === 'function') {
  20. callback = btnArray;
  21. btnArray = null;
  22. }
  23. $.plusReady(function() {
  24. plus.nativeUI.prompt(text, callback, title, defaultText, btnArray);
  25. });
  26. }
  27. } else {
  28. //H5版本(确认index为0,取消index为1)
  29. var result = window.prompt(text);
  30. if (result) {
  31. callback({
  32. index: 0,
  33. value: result
  34. });
  35. } else {
  36. callback({
  37. index: 1,
  38. value: ''
  39. });
  40. }
  41. }
  42. };
  43. })(mui, window);