Geen omschrijving

EmailComposerProxy.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright 2013-2016 appPlant UG
  3. Licensed to the Apache Software Foundation (ASF) under one
  4. or more contributor license agreements. See the NOTICE file
  5. distributed with this work for additional information
  6. regarding copyright ownership. The ASF licenses this file
  7. to you under the Apache License, Version 2.0 (the
  8. "License"); you may not use this file except in compliance
  9. with the License. You may obtain a copy of the License at
  10. http://www.apache.org/licenses/LICENSE-2.0
  11. Unless required by applicable law or agreed to in writing,
  12. software distributed under the License is distributed on an
  13. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. KIND, either express or implied. See the License for the
  15. specific language governing permissions and limitations
  16. under the License.
  17. */
  18. /**
  19. * Verifies if sending emails is supported on the device.
  20. *
  21. * @param {Function} success
  22. * Success callback function
  23. * @param {Function} error
  24. * Error callback function
  25. * @param {Array} args
  26. * Interface arguments
  27. */
  28. exports.isAvailable = function (success, error, args) {
  29. success(true,false);
  30. };
  31. /**
  32. * Displays the email composer pre-filled with data.
  33. *
  34. * @param {Function} success
  35. * Success callback function
  36. * @param {Function} error
  37. * Error callback function
  38. * @param {Array} args
  39. * Interface arguments
  40. */
  41. exports.open = function (success, error, args) {
  42. var props = args[0],
  43. mailto = 'mailto:' + props.to,
  44. options = '';
  45. if (props.subject !== '') {
  46. options = options + '&subject=' + props.subject;
  47. }
  48. if (props.body !== '') {
  49. options = options + '&body=' + props.body;
  50. }
  51. if (props.cc !== '') {
  52. options = options + '&cc=' + props.cc;
  53. }
  54. if (props.bcc !== '') {
  55. options = options + '&bcc=' + props.bcc;
  56. }
  57. if (options !== '') {
  58. mailto = mailto + '?' + options.substring(1);
  59. }
  60. window.location.href = mailto;
  61. success();
  62. };
  63. require('cordova/exec/proxy').add('EmailComposer', exports);