(function() { tinymce.PluginManager.add('abc_booking_button', function( editor, url ) { editor.addButton( 'abc_booking_button', { title: 'Advanced Booking Calendar', type: 'menubutton', icon: 'icon dashicons-calendar-alt', menu: [ { text: editor.getLang('advanced-booking-calendar.bookingform'), value: '[abc-bookingform]', onclick: function() { editor.insertContent(this.value()); } }, { text: editor.getLang('advanced-booking-calendar.calendaroverview'), value: '[abc-overview]', onclick: function() { editor.insertContent(this.value()); } }, { text: editor.getLang('advanced-booking-calendar.singlecalendar'), value: '[abc-overview]', onclick: function() { editor.windowManager.open( { title: editor.getLang('advanced-booking-calendar.addsingle'), width: 400, height: 100, body: [ { type: 'listbox', name: 'calendar', label: editor.getLang('advanced-booking-calendar.calendar'), 'values': abc_tinymce_calendars }, { type: 'checkbox', name: 'legendBox', checked: true, text: editor.getLang('advanced-booking-calendar.legend') } ], onsubmit: function( e ) { var legend = ""; if(e.data.legendBox){ legend = ' legend="1"'; } editor.insertContent( '[abc-single calendar="' + e.data.calendar + '"'+ legend + ']'); } }); } } ] }); }); })();