src/pyams_skin/resources/js/ext/tinymce/dev/plugins/example/plugin.js
changeset 69 a361355b55c7
equal deleted inserted replaced
68:fd8fb93e1b6a 69:a361355b55c7
       
     1 /**
       
     2  * plugin.js
       
     3  *
       
     4  * Copyright, Moxiecode Systems AB
       
     5  * Released under LGPL License.
       
     6  *
       
     7  * License: http://www.tinymce.com/license
       
     8  * Contributing: http://www.tinymce.com/contributing
       
     9  */
       
    10 
       
    11 /*jshint unused:false */
       
    12 /*global tinymce:true */
       
    13 
       
    14 /**
       
    15  * Example plugin that adds a toolbar button and menu item.
       
    16  */
       
    17 tinymce.PluginManager.add('example', function(editor, url) {
       
    18 	// Add a button that opens a window
       
    19 	editor.addButton('example', {
       
    20 		text: 'My button',
       
    21 		icon: false,
       
    22 		onclick: function() {
       
    23 			// Open window
       
    24 			editor.windowManager.open({
       
    25 				title: 'Example plugin',
       
    26 				body: [
       
    27 					{type: 'textbox', name: 'title', label: 'Title'}
       
    28 				],
       
    29 				onsubmit: function(e) {
       
    30 					// Insert content when the window form is submitted
       
    31 					editor.insertContent('Title: ' + e.data.title);
       
    32 				}
       
    33 			});
       
    34 		}
       
    35 	});
       
    36 
       
    37 	// Adds a menu item to the tools menu
       
    38 	editor.addMenuItem('example', {
       
    39 		text: 'Example plugin',
       
    40 		context: 'tools',
       
    41 		onclick: function() {
       
    42 			// Open window with a specific url
       
    43 			editor.windowManager.open({
       
    44 				title: 'TinyMCE site',
       
    45 				url: url + '/dialog.html',
       
    46 				width: 600,
       
    47 				height: 400,
       
    48 				buttons: [
       
    49 					{
       
    50 						text: 'Insert',
       
    51 						onclick: function() {
       
    52 							// Top most window object
       
    53 							var win = editor.windowManager.getWindows()[0];
       
    54 
       
    55 							// Insert the contents of the dialog.html textarea into the editor
       
    56 							editor.insertContent(win.getContentWindow().document.getElementById('content').value);
       
    57 
       
    58 							// Close the window
       
    59 							win.close();
       
    60 						}
       
    61 					},
       
    62 
       
    63 					{text: 'Close', onclick: 'close'}
       
    64 				]
       
    65 			});
       
    66 		}
       
    67 	});
       
    68 });