[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/tinymce/plugins/directionality/ -> plugin.js (source)

   1  (function () {
   2  var directionality = (function () {
   3      'use strict';
   4  
   5      var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
   6  
   7      var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
   8  
   9      var setDir = function (editor, dir) {
  10        var dom = editor.dom;
  11        var curDir;
  12        var blocks = editor.selection.getSelectedBlocks();
  13        if (blocks.length) {
  14          curDir = dom.getAttrib(blocks[0], 'dir');
  15          global$1.each(blocks, function (block) {
  16            if (!dom.getParent(block.parentNode, '*[dir="' + dir + '"]', dom.getRoot())) {
  17              dom.setAttrib(block, 'dir', curDir !== dir ? dir : null);
  18            }
  19          });
  20          editor.nodeChanged();
  21        }
  22      };
  23      var Direction = { setDir: setDir };
  24  
  25      var register = function (editor) {
  26        editor.addCommand('mceDirectionLTR', function () {
  27          Direction.setDir(editor, 'ltr');
  28        });
  29        editor.addCommand('mceDirectionRTL', function () {
  30          Direction.setDir(editor, 'rtl');
  31        });
  32      };
  33      var Commands = { register: register };
  34  
  35      var generateSelector = function (dir) {
  36        var selector = [];
  37        global$1.each('h1 h2 h3 h4 h5 h6 div p'.split(' '), function (name) {
  38          selector.push(name + '[dir=' + dir + ']');
  39        });
  40        return selector.join(',');
  41      };
  42      var register$1 = function (editor) {
  43        editor.addButton('ltr', {
  44          title: 'Left to right',
  45          cmd: 'mceDirectionLTR',
  46          stateSelector: generateSelector('ltr')
  47        });
  48        editor.addButton('rtl', {
  49          title: 'Right to left',
  50          cmd: 'mceDirectionRTL',
  51          stateSelector: generateSelector('rtl')
  52        });
  53      };
  54      var Buttons = { register: register$1 };
  55  
  56      global.add('directionality', function (editor) {
  57        Commands.register(editor);
  58        Buttons.register(editor);
  59      });
  60      function Plugin () {
  61      }
  62  
  63      return Plugin;
  64  
  65  }());
  66  })();


Generated: Sun Dec 22 01:00:02 2024 Cross-referenced by PHPXref 0.7.1