/** * @filename : editor_plugin.js * @description : jQuery UI Inline Popups plugin to replace the default inlinepopups * @developer : badsyntax (Richard Willis) * @contact : http://badsyntax.co * @moreinfo : http://is.gd/j1FuI */ (function() { var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each; // Create the editor plugin tinymce.create('tinymce.plugins.jQueryInlinePopups', { init : function(ed, url) { // Replace window manager ed.onBeforeRenderUI.add(function() { ed.windowManager = new tinymce.InlineWindowManager(ed); }); }, getInfo : function() { return { longname : 'jQuery UI Inline Popups', author : 'Richard Willis', authorurl : 'http://badsyntax.co', infourl : 'http://is.gd/j1FuI', version : '0.1b' }; } }); // Create the window manager tinymce.create('tinymce.InlineWindowManager:tinymce.WindowManager', { InlineWindowManager : function(ed) { this.parent(ed); this.windows = {}; }, open : function(f, p) { console.log(f); f = f || {}; p = p || {}; // Run native windows if (!f.inline) { return t.parent(f, p); } var t = this, id = DOM.uniqueId(), // Dialog config config = { title: f.title || '', width: 'auto', height: 'auto', modal: true, resizable: false, draggable: true, dialogClass: 'ui-dialog-tinymce', // match the tinymce inlinepopups starting z-index (fixes #3) zIndex: 300000 }, // Dialog element dialog = $('
') .attr('id', 'dialog-' + id) .hide() .appendTo('body'), // Window info w = { id : id, features : f, element: dialog }; // Only store selection if the type is a normal window. // This is required at least for IE to remeber the position // before the focus from editor is lost. if (!f.type) { this.bookmark = this.editor.selection.getBookmark(1); } // Inline content if (f.content){ if (f.type == 'confirm'){ config.buttons = [{ 'text': 'Ok', 'click': function(e){ f.button_func(true); } }, { 'text': 'Cancel', 'click': function(e){ f.button_func(false); } }]; } else if (f.type == 'alert'){ config.buttons = [{ 'text': 'Ok', 'click': function(e){ f.button_func(true); } }]; } config.width = f.width; dialog.html($('
', { 'class': 'ui-dialog-tinymce-content', 'html': f.content })); } // iFramed document else { console.log(f); var iframe = $('