]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/charmap/plugin.js
WordPress 4.3.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / charmap / plugin.js
index 27b6a46da43bd5bf8c75b9904ca159c04f667bc6..91181b9f30bb2a22309414ae5f4b603a30437946 100644 (file)
@@ -1,8 +1,8 @@
 /**
  * plugin.js
  *
- * Copyright, Moxiecode Systems AB
  * Released under LGPL License.
+ * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
  *
  * License: http://www.tinymce.com/license
  * Contributing: http://www.tinymce.com/contributing
@@ -13,7 +13,7 @@
 tinymce.PluginManager.add('charmap', function(editor) {
        var charmap = [
                ['160', 'no-break space'],
-               ['38', 'ampersand'],
+               ['173', 'soft hyphen'],
                ['34', 'quotation mark'],
        // finance
                ['162', 'cent sign'],
@@ -225,9 +225,9 @@ tinymce.PluginManager.add('charmap', function(editor) {
                ['969', 'omega'],
        // symbols
                ['8501', 'alef symbol'],
-               ['982',  'pi symbol'],
+               ['982', 'pi symbol'],
                ['8476', 'real part symbol'],
-               ['978',  'upsilon - hook symbol'],
+               ['978', 'upsilon - hook symbol'],
                ['8472', 'Weierstrass p'],
                ['8465', 'imaginary part'],
        // arrows
@@ -269,8 +269,7 @@ tinymce.PluginManager.add('charmap', function(editor) {
                ['8204', 'zero width non-joiner'],
                ['8205', 'zero width joiner'],
                ['8206', 'left-to-right mark'],
-               ['8207', 'right-to-left mark'],
-               ['173',  'soft hyphen']
+               ['8207', 'right-to-left mark']
        ];
 
        function showDialog() {
@@ -289,14 +288,20 @@ tinymce.PluginManager.add('charmap', function(editor) {
                gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>';
 
                var width = 25;
-               for (y = 0; y < 10; y++) {
+               var height = Math.ceil(charmap.length / width);
+               for (y = 0; y < height; y++) {
                        gridHtml += '<tr>';
 
                        for (x = 0; x < width; x++) {
-                               var chr = charmap[y * width + x];
+                               var index = y * width + x;
+                               if (index < charmap.length) {
+                                       var chr = charmap[index];
 
-                               gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
-                                       (chr ? String.fromCharCode(parseInt(chr[0], 10)) : '&nbsp;') + '</div></td>';
+                                       gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
+                                               (chr ? String.fromCharCode(parseInt(chr[0], 10)) : '&nbsp;') + '</div></td>';
+                               } else {
+                                       gridHtml += '<td />';
+                               }
                        }
 
                        gridHtml += '</tr>';
@@ -309,24 +314,25 @@ tinymce.PluginManager.add('charmap', function(editor) {
                        html: gridHtml,
                        onclick: function(e) {
                                var target = e.target;
+                               if (/^(TD|DIV)$/.test(target.nodeName)) {
+                                       if (getParentTd(target).firstChild) {
+                                               editor.execCommand('mceInsertContent', false, tinymce.trim(target.innerText || target.textContent));
 
-                               if (target.tagName == 'TD') {
-                                       target = target.firstChild;
-                               }
-
-                               if (target.tagName == 'DIV') {
-                                       editor.execCommand('mceInsertContent', false, target.firstChild.data);
-
-                                       if (!e.ctrlKey) {
-                                               win.close();
+                                               if (!e.ctrlKey) {
+                                                       win.close();
+                                               }
                                        }
                                }
                        },
                        onmouseover: function(e) {
                                var td = getParentTd(e.target);
 
-                               if (td) {
+                               if (td && td.firstChild) {
                                        win.find('#preview').text(td.firstChild.firstChild.data);
+                                       win.find('#previewTitle').text(td.title);
+                               } else {
+                                       win.find('#preview').text(' ');
+                                       win.find('#previewTitle').text(' ');
                                }
                        }
                };
@@ -338,13 +344,33 @@ tinymce.PluginManager.add('charmap', function(editor) {
                        items: [
                                charMapPanel,
                                {
-                                       type: 'label',
-                                       name: 'preview',
-                                       text: ' ',
-                                       style: 'font-size: 40px; text-align: center',
-                                       border: 1,
-                                       minWidth: 100,
-                                       minHeight: 80
+                                       type: 'container',
+                                       layout: 'flex',
+                                       direction: 'column',
+                                       align: 'center',
+                                       spacing: 5,
+                                       minWidth: 160,
+                                       minHeight: 160,
+                                       items: [
+                                               {
+                                                       type: 'label',
+                                                       name: 'preview',
+                                                       text: ' ',
+                                                       style: 'font-size: 40px; text-align: center',
+                                                       border: 1,
+                                                       minWidth: 140,
+                                                       minHeight: 80
+                                               },
+                                               {
+                                                       type: 'label',
+                                                       name: 'previewTitle',
+                                                       text: ' ',
+                                                       style: 'text-align: center',
+                                                       border: 1,
+                                                       minWidth: 140,
+                                                       minHeight: 80
+                                               }
+                                       ]
                                }
                        ],
                        buttons: [
@@ -355,16 +381,18 @@ tinymce.PluginManager.add('charmap', function(editor) {
                });
        }
 
+       editor.addCommand('mceShowCharmap', showDialog);
+
        editor.addButton('charmap', {
                icon: 'charmap',
                tooltip: 'Special character',
-               onclick: showDialog
+               cmd: 'mceShowCharmap'
        });
 
        editor.addMenuItem('charmap', {
                icon: 'charmap',
                text: 'Special character',
-               onclick: showDialog,
+               cmd: 'mceShowCharmap',
                context: 'insert'
        });
 });
\ No newline at end of file