Sha256: 7a7b1b48e5f2006ffa68ad610b222882d9c978deb52387595e61616c0c1fbe38

Contents?: true

Size: 1.78 KB

Versions: 40

Compression:

Stored size: 1.78 KB

Contents

/**
 * Buttons.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

define('tinymce/inlite/ui/Buttons', [
	'tinymce/inlite/ui/Panel',
	'tinymce/inlite/file/Conversions',
	'tinymce/inlite/file/Picker',
	'tinymce/inlite/core/Actions'
], function (Panel, Conversions, Picker, Actions) {
	var addHeaderButtons = function (editor) {
		var formatBlock = function (name) {
			return function () {
				Actions.formatBlock(editor, name);
			};
		};

		for (var i = 1; i < 6; i++) {
			var name = 'h' + i;

			editor.addButton(name, {
				text: name.toUpperCase(),
				tooltip: 'Heading ' + i,
				stateSelector: name,
				onclick: formatBlock(name),
				onPostRender: function () {
					// TODO: Remove this hack that produces bold H1-H6 when we have proper icons
					var span = this.getEl().firstChild.firstChild;
					span.style.fontWeight = 'bold';
				}
			});
		}
	};

	var addToEditor = function (editor, panel) {
		editor.addButton('quicklink', {
			icon: 'link',
			tooltip: 'Insert/Edit link',
			stateSelector: 'a[href]',
			onclick: function () {
				panel.showForm(editor, 'quicklink');
			}
		});

		editor.addButton('quickimage', {
			icon: 'image',
			tooltip: 'Insert image',
			onclick: function () {
				Picker.pickFile().then(function (files) {
					var blob = files[0];

					Conversions.blobToBase64(blob).then(function (base64) {
						Actions.insertBlob(editor, base64, blob);
					});
				});
			}
		});

		editor.addButton('quicktable', {
			icon: 'table',
			tooltip: 'Insert table',
			onclick: function () {
				panel.hide();
				Actions.insertTable(editor, 2, 2);
			}
		});

		addHeaderButtons(editor);
	};

	return {
		addToEditor: addToEditor
	};
});

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
wbase-0.3.20 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.19 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.18 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.17 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.16 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.15 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.14 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.13 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.12 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.11 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.10 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.9 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.8 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.7 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.6 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.5 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.4 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.3 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.2 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js
wbase-0.3.1 lib/vendor/admin/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js