mce-button.js
112 lines
| 1 | jQuery(document).ready(function($){ |
| 2 | 'use strict'; |
| 3 | |
| 4 | /*======================================================================== |
| 5 | * Tutor WP Editor Button |
| 6 | *======================================================================== */ |
| 7 | /** |
| 8 | * editor.getLang translation support added |
| 9 | * |
| 10 | * @since 1.9.7 |
| 11 | */ |
| 12 | tinymce.PluginManager.add('tutor_button', function( editor, url ) { |
| 13 | editor.addButton( 'tutor_button', { |
| 14 | text: editor.getLang('tutor_button.tutor_shortcode'), |
| 15 | icon: false, |
| 16 | type: 'menubutton', |
| 17 | menu: [ |
| 18 | { |
| 19 | text: editor.getLang('tutor_button.student_registration_form'), |
| 20 | onclick: function() { |
| 21 | editor.insertContent('[tutor_student_registration_form]'); |
| 22 | } |
| 23 | }, |
| 24 | /*{ |
| 25 | text: 'Student Dashboard', |
| 26 | onclick: function() { |
| 27 | editor.insertContent('[tutor_dashboard]'); |
| 28 | } |
| 29 | },*/{ |
| 30 | text: editor.getLang('tutor_button.instructor_registration_form'), |
| 31 | onclick: function() { |
| 32 | editor.insertContent('[tutor_instructor_registration_form]'); |
| 33 | } |
| 34 | }, |
| 35 | /* { |
| 36 | text: 'Courses', |
| 37 | onclick: function() { |
| 38 | editor.insertContent('[tutor_course]'); |
| 39 | } |
| 40 | },*/ |
| 41 | |
| 42 | |
| 43 | |
| 44 | { |
| 45 | text: editor.getLang('tutor_button.courses'), |
| 46 | onclick: function() { |
| 47 | editor.windowManager.open( { |
| 48 | title: editor.getLang('tutor_button.courses_shortcode'), |
| 49 | body: [ |
| 50 | { |
| 51 | type: 'textbox', |
| 52 | name: 'id', |
| 53 | label: editor.getLang('tutor_button.courses_separate_by'), |
| 54 | value: '' |
| 55 | },{ |
| 56 | type: 'textbox', |
| 57 | name: 'exclude_ids', |
| 58 | label: editor.getLang('tutor_button.exclude_course_ids'), |
| 59 | value: '' |
| 60 | }, |
| 61 | { |
| 62 | type: 'textbox', |
| 63 | name: 'category', |
| 64 | label: editor.getLang('tutor_button.category_ids'), |
| 65 | value: '' |
| 66 | }, |
| 67 | {type: 'listbox', |
| 68 | name: 'orderby', |
| 69 | label: editor.getLang('tutor_button.order_by'), |
| 70 | onselect: function(e) { |
| 71 | |
| 72 | }, |
| 73 | 'values': [ |
| 74 | {text: 'ID', value: 'ID'}, |
| 75 | {text: 'title', value: 'title'}, |
| 76 | {text: 'rand', value: 'rand'}, |
| 77 | {text: 'date', value: 'date'}, |
| 78 | {text: 'menu_order', value: 'menu_order'}, |
| 79 | {text: 'post__in', value: 'post__in'}, |
| 80 | ] |
| 81 | }, |
| 82 | {type: 'listbox', |
| 83 | name: 'order', |
| 84 | label: editor.getLang('tutor_button.order'), |
| 85 | onselect: function(e) { |
| 86 | |
| 87 | }, |
| 88 | 'values': [ |
| 89 | {text: 'DESC', value: 'DESC'}, |
| 90 | {text: 'ASC', value: 'ASC'} |
| 91 | ] |
| 92 | }, |
| 93 | ,{ |
| 94 | type: 'textbox', |
| 95 | name: 'count', |
| 96 | label: editor.getLang('tutor_button.count'), |
| 97 | value: '6', |
| 98 | } |
| 99 | ], |
| 100 | onsubmit: function( e ) { |
| 101 | editor.insertContent( '[tutor_course id="' + e.data.id + '" exclude_ids="'+e.data.exclude_ids+'" category="'+e.data.category+'" orderby="'+e.data.orderby+'" order="'+e.data.order+'" count="'+e.data.count+'"]'); |
| 102 | } |
| 103 | }); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | |
| 108 | ] |
| 109 | }); |
| 110 | }); |
| 111 | |
| 112 | }); |