simple-job-board-admin-shortcodes-generator.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /**
  2. * Simple Job Board Shortcode Builder JS File - V 1.0.0
  3. *
  4. * @author PressTigers <support@presstigers.com>, 2016
  5. *
  6. * Actions List
  7. * - Tinymce Button Callback (Fired onclick & onsubmit events)
  8. */
  9. (function ($) {
  10. 'use strict';
  11. $(function () {
  12. tinymce.PluginManager.add('sjb_shortcodes_mce_button', function (editor, url) {
  13. editor.addButton('sjb_shortcodes_mce_button', {
  14. title: 'Simple Job Board',
  15. icon: 'icon sjb-icon',
  16. onclick: function () {
  17. editor.windowManager.open({
  18. title: 'Insert Simple Job Board Shortcode',
  19. body: [
  20. // Number of jobs
  21. {
  22. type: 'textbox',
  23. subtype: 'number',
  24. name: 'job_posts',
  25. label: 'Posts',
  26. },
  27. // Job category
  28. {
  29. type: 'textbox',
  30. name: 'job_category',
  31. label: 'Category',
  32. },
  33. // Job Type
  34. {
  35. type: 'textbox',
  36. name: 'job_type',
  37. label: 'Type',
  38. },
  39. // Job Location
  40. {
  41. type: 'textbox',
  42. name: 'job_location',
  43. label: 'Location',
  44. },
  45. // Job Search
  46. {
  47. type: 'listbox',
  48. name: 'job_search',
  49. label: 'Search',
  50. values: [
  51. {text: 'True', value: 'true'},
  52. {text: 'False', value: 'false'},
  53. ]
  54. },
  55. ],
  56. onsubmit: function (e) {
  57. // If user enter number less than -1
  58. if (e.data.job_posts < -1) {
  59. // Change value with -1
  60. e.data.job_posts = -1;
  61. }
  62. editor.insertContent('[jobpost posts="' + e.data.job_posts + '" category="' + e.data.job_category + '" type="' + e.data.job_type + '" location="' + e.data.job_location + '" search="' + e.data.job_search + '"]');
  63. }
  64. });
  65. }
  66. });
  67. });
  68. });
  69. })(jQuery);