MCE Table Buttons - Version 3.1

Version Description

  • Updated core TinyMCE table plugin from 4.0.20 to 4.0.21 in sync with WordPress - mostly bug and accessibility fixes
  • Refactored for compatibility with plugins like Advanced Custom Fields that do not use the_editor hook
Download this release

Release Info

Developer jakemgold
Plugin Icon 128x128 MCE Table Buttons
Version 3.1
Comparing to
See all releases

Code changes from version 3.0 to 3.1

mce_table_buttons.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MCE Table Buttons
4
  Plugin URI: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
5
  Description: Add <strong>controls for table editing</strong> to the visual content editor with this <strong>light weight</strong> plug-in.
6
- Version: 3.0
7
  Author: Jake Goldman, 10up, Oomph
8
  Author URI: http://10up.com
9
  License: GPLv2 or later
@@ -22,7 +22,7 @@ class MCE_Table_Buttons {
22
 
23
  if ( null === $instance ) {
24
  $instance = new self();
25
- self::_add_actions();
26
  }
27
 
28
  return $instance;
@@ -36,85 +36,77 @@ class MCE_Table_Buttons {
36
  /**
37
  * Handles registering hooks that initialize this plugin.
38
  */
39
- public static function _add_actions() {
40
- add_filter( 'the_editor', array( __CLASS__, 'the_editor' ) ); // most convenient hook
 
41
  add_action( 'content_save_pre', array( __CLASS__, 'content_save_pre'), 100 );
42
  }
43
 
44
  /**
45
- * The Editor is really a filter, but happens to be our most convenient hook to set everything up
46
  *
47
- * @param string $editor
48
- * @return string Editor fields
49
  */
50
- public static function the_editor( $editor ) {
51
  global $tinymce_version;
52
 
53
  if ( version_compare( $tinymce_version, '400', '<' ) ) {
54
- add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins_3_8' ) );
55
- add_filter( 'mce_buttons_3', array( __CLASS__, 'mce_buttons_3_8' ) );
56
  wp_register_style( 'mce-table-buttons', plugin_dir_url( __FILE__ ) . 'tinymce3-assets/mce-table-buttons.css' );
57
  wp_print_styles( 'mce-table-buttons' );
 
 
 
 
 
58
  } else {
59
- add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins_3_9' ) );
60
- add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_3_9' ) );
61
- }
62
 
63
- remove_filter( 'the_editor', array( __CLASS__, 'the_editor' ) ); // only needs to run once
 
64
 
65
- return $editor;
66
- }
67
 
68
- /**
69
- * Initialize TinyMCE 3.x table plugin and custom TinyMCE plugin for third editor row
70
- *
71
- * @param array $plugin_array Array of TinyMCE plugins
72
- * @return array Array of TinyMCE plugins
73
- */
74
- public static function mce_external_plugins_3_8( $plugin_array ) {
75
- $plugin_dir_url = plugin_dir_url( __FILE__ );
76
- $plugin_array['table'] = $plugin_dir_url . 'tinymce3-table/editor_plugin.js';
77
- $plugin_array['mcetablebuttons'] = $plugin_dir_url . 'tinymce3-assets/mce-table-buttons.js';
78
  return $plugin_array;
79
  }
80
 
81
  /**
82
- * Add TinyMCE 3.x table control buttons to a third row of editor buttons
83
  *
84
- * @param array $buttons Buttons for the third row
85
- * @return array Buttons for the third row
86
  */
87
- public static function mce_buttons_3_8( $buttons ) {
88
- array_push( $buttons, 'tablecontrols' );
89
- return $buttons;
90
- }
91
 
92
- /**
93
- * Initialize TinyMCE 4.x table plugin
94
- *
95
- * @param array $plugin_array Array of TinyMCE plugins
96
- * @return array Array of TinyMCE plugins
97
- */
98
- public static function mce_external_plugins_3_9( $plugin_array ) {
99
- $variant = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
100
- $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce4-table/plugin' . $variant . '.js';
101
- return $plugin_array;
 
 
 
 
 
 
 
102
  }
103
 
104
  /**
105
- * Add TinyMCE 4.x table control to the second row, after other formatting controls
106
  *
107
  * @param array $buttons Buttons for the second row
108
  * @return array Buttons for the second row
109
  */
110
- public static function mce_buttons_3_9( $buttons ) {
111
- // in case someone is manipulating other buttons, drop table controls at the end of the row
112
- if ( ! $pos = array_search( 'undo', $buttons ) ) {
113
- array_push( $buttons, 'table' );
114
- return $buttons;
115
- }
116
-
117
- return array_merge( array_slice( $buttons, 0, $pos ), array( 'table' ), array_slice( $buttons, $pos ) );
118
  }
119
 
120
  /**
3
  Plugin Name: MCE Table Buttons
4
  Plugin URI: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
5
  Description: Add <strong>controls for table editing</strong> to the visual content editor with this <strong>light weight</strong> plug-in.
6
+ Version: 3.1
7
  Author: Jake Goldman, 10up, Oomph
8
  Author URI: http://10up.com
9
  License: GPLv2 or later
22
 
23
  if ( null === $instance ) {
24
  $instance = new self();
25
+ self::_setup_plugin();
26
  }
27
 
28
  return $instance;
36
  /**
37
  * Handles registering hooks that initialize this plugin.
38
  */
39
+ public static function _setup_plugin() {
40
+ add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins' ) );
41
+ add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
42
  add_action( 'content_save_pre', array( __CLASS__, 'content_save_pre'), 100 );
43
  }
44
 
45
  /**
46
+ * Initialize TinyMCE table plugin and custom TinyMCE plugin
47
  *
48
+ * @param array $plugin_array Array of TinyMCE plugins
49
+ * @return array Array of TinyMCE plugins
50
  */
51
+ public static function mce_external_plugins( $plugin_array ) {
52
  global $tinymce_version;
53
 
54
  if ( version_compare( $tinymce_version, '400', '<' ) ) {
55
+
 
56
  wp_register_style( 'mce-table-buttons', plugin_dir_url( __FILE__ ) . 'tinymce3-assets/mce-table-buttons.css' );
57
  wp_print_styles( 'mce-table-buttons' );
58
+
59
+ $plugin_dir_url = plugin_dir_url( __FILE__ );
60
+ $plugin_array['table'] = $plugin_dir_url . 'tinymce3-table/editor_plugin.js';
61
+ $plugin_array['mcetablebuttons'] = $plugin_dir_url . 'tinymce3-assets/mce-table-buttons.js';
62
+
63
  } else {
 
 
 
64
 
65
+ $variant = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
66
+ $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce4-table/plugin' . $variant . '.js';
67
 
68
+ }
 
69
 
 
 
 
 
 
 
 
 
 
 
70
  return $plugin_array;
71
  }
72
 
73
  /**
74
+ * Add TinyMCE table control buttons
75
  *
76
+ * @param array $buttons Buttons for the second row
77
+ * @return array Buttons for the second row
78
  */
79
+ public static function mce_buttons_2( $buttons ) {
80
+ global $tinymce_version;
 
 
81
 
82
+ if ( version_compare( $tinymce_version, '400', '<' ) ) {
83
+
84
+ add_filter( 'mce_buttons_3', array( __CLASS__, 'mce_buttons_3' ) );
85
+
86
+ } else {
87
+
88
+ // in case someone is manipulating other buttons, drop table controls at the end of the row
89
+ if ( ! $pos = array_search( 'undo', $buttons ) ) {
90
+ array_push( $buttons, 'table' );
91
+ return $buttons;
92
+ }
93
+
94
+ $buttons = array_merge( array_slice( $buttons, 0, $pos ), array( 'table' ), array_slice( $buttons, $pos ) );
95
+
96
+ }
97
+
98
+ return $buttons;
99
  }
100
 
101
  /**
102
+ * Add TinyMCE 3.x table control to the second row, after other formatting controls
103
  *
104
  * @param array $buttons Buttons for the second row
105
  * @return array Buttons for the second row
106
  */
107
+ public static function mce_buttons_3( $buttons ) {
108
+ array_push( $buttons, 'tablecontrols' );
109
+ return $buttons;
 
 
 
 
 
110
  }
111
 
112
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
4
  Tags: tables, table, editor, WYSIWYG, buttons, tinymce
5
  Requires at least: 3.4
6
  Tested up to: 3.9
7
- Stable tag: 3.0
8
 
9
  Adds table editing controls to the visual content editor (TinyMCE).
10
 
@@ -30,6 +30,10 @@ Note that the table controls are contained in the “kitchen sink” toolbar, to
30
 
31
  == Changelog ==
32
 
 
 
 
 
33
  = 3.0 =
34
  * Support for WordPress 3.9 and newer, which includes a major visual editor upgrade (TinyMCE 4)
35
 
4
  Tags: tables, table, editor, WYSIWYG, buttons, tinymce
5
  Requires at least: 3.4
6
  Tested up to: 3.9
7
+ Stable tag: 3.1
8
 
9
  Adds table editing controls to the visual content editor (TinyMCE).
10
 
30
 
31
  == Changelog ==
32
 
33
+ = 3.1 =
34
+ * Updated core TinyMCE table plugin from 4.0.20 to 4.0.21 in sync with WordPress - mostly bug and accessibility fixes
35
+ * Refactored for compatibility with plugins like Advanced Custom Fields that do not use the_editor hook
36
+
37
  = 3.0 =
38
  * Support for WordPress 3.9 and newer, which includes a major visual editor upgrade (TinyMCE 4)
39
 
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file
tinymce4-table/plugin.js CHANGED
@@ -1510,16 +1510,16 @@ define("tinymce/tableplugin/Plugin", [
1510
  }
1511
 
1512
  function tableDialog() {
1513
- var dom = editor.dom, tableElm, data;
1514
 
1515
  tableElm = dom.getParent(editor.selection.getStart(), 'table');
1516
 
1517
  data = {
1518
  width: removePxSuffix(dom.getStyle(tableElm, 'width') || dom.getAttrib(tableElm, 'width')),
1519
  height: removePxSuffix(dom.getStyle(tableElm, 'height') || dom.getAttrib(tableElm, 'height')),
1520
- cellspacing: dom.getAttrib(tableElm, 'cellspacing'),
1521
- cellpadding: dom.getAttrib(tableElm, 'cellpadding'),
1522
- border: dom.getAttrib(tableElm, 'border'),
1523
  caption: !!dom.select('caption', tableElm)[0]
1524
  };
1525
 
@@ -1529,6 +1529,11 @@ define("tinymce/tableplugin/Plugin", [
1529
  }
1530
  });
1531
 
 
 
 
 
 
1532
  editor.windowManager.open({
1533
  title: "Table properties",
1534
  items: {
@@ -1541,6 +1546,8 @@ define("tinymce/tableplugin/Plugin", [
1541
  maxWidth: 50
1542
  },
1543
  items: [
 
 
1544
  {label: 'Width', name: 'width'},
1545
  {label: 'Height', name: 'height'},
1546
  {label: 'Cell spacing', name: 'cellspacing'},
@@ -1568,6 +1575,10 @@ define("tinymce/tableplugin/Plugin", [
1568
  var data = this.toJSON(), captionElm;
1569
 
1570
  editor.undoManager.transact(function() {
 
 
 
 
1571
  editor.dom.setAttribs(tableElm, {
1572
  cellspacing: data.cellspacing,
1573
  cellpadding: data.cellpadding,
@@ -1869,7 +1880,7 @@ define("tinymce/tableplugin/Plugin", [
1869
  function insertTable(cols, rows) {
1870
  var y, x, html;
1871
 
1872
- html = '<table><tbody>';
1873
 
1874
  for (y = 0; y < rows; y++) {
1875
  html += '<tr>';
@@ -1884,6 +1895,11 @@ define("tinymce/tableplugin/Plugin", [
1884
  html += '</tbody></table>';
1885
 
1886
  editor.insertContent(html);
 
 
 
 
 
1887
  }
1888
 
1889
  function handleDisabledState(ctrl, selector) {
@@ -1982,99 +1998,116 @@ define("tinymce/tableplugin/Plugin", [
1982
  return focusCell.parentNode;
1983
  }
1984
 
1985
- editor.addMenuItem('inserttable', {
1986
- text: 'Insert table',
1987
- icon: 'table',
1988
- context: 'table',
1989
- onhide: function() {
1990
- var elements = this.menu.items()[0].getEl().getElementsByTagName('a');
1991
- editor.dom.removeClass(elements, 'mce-active');
1992
- editor.dom.addClass(elements[0], 'mce-active');
1993
- },
1994
- menu: [
1995
- {
1996
- type: 'container',
1997
- html: generateTableGrid(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1998
 
1999
- onPostRender: function() {
2000
- this.lastX = this.lastY = 0;
2001
- },
2002
 
2003
- onmousemove: function(e) {
2004
- var target = e.target, x, y;
2005
 
2006
- if (target.nodeName == 'A') {
2007
- x = parseInt(target.getAttribute('data-mce-x'), 10);
2008
- y = parseInt(target.getAttribute('data-mce-y'), 10);
2009
 
2010
- if (x !== this.lastX || y !== this.lastY) {
2011
- selectGrid(x, y, e.control);
2012
 
2013
- this.lastX = x;
2014
- this.lastY = y;
 
2015
  }
2016
- }
2017
- },
2018
 
2019
- onkeydown: function(e) {
2020
- var x = this.lastX, y = this.lastY, isHandled;
2021
 
2022
- switch (e.keyCode) {
2023
- case 37: // DOM_VK_LEFT
2024
- if (x > 0) {
2025
- x--;
2026
- isHandled = true;
2027
- }
2028
- break;
2029
 
2030
- case 39: // DOM_VK_RIGHT
2031
- isHandled = true;
2032
 
2033
- if (x < 9) {
2034
- x++;
2035
- }
2036
- break;
2037
 
2038
- case 38: // DOM_VK_UP
2039
- isHandled = true;
2040
 
2041
- if (y > 0) {
2042
- y--;
2043
- }
2044
- break;
2045
 
2046
- case 40: // DOM_VK_DOWN
2047
- isHandled = true;
2048
 
2049
- if (y < 9) {
2050
- y++;
2051
- }
2052
- break;
2053
- }
2054
 
2055
- if (isHandled) {
2056
- e.preventDefault();
2057
- e.stopPropagation();
2058
 
2059
- selectGrid(x, y, e.control).focus();
2060
 
2061
- this.lastX = x;
2062
- this.lastY = y;
2063
- }
2064
- },
2065
 
2066
- onclick: function(e) {
2067
- if (e.target.nodeName == 'A') {
2068
- e.preventDefault();
2069
- e.stopPropagation();
2070
- this.parent().cancel();
2071
 
2072
- insertTable(this.lastX + 1, this.lastY + 1);
 
2073
  }
2074
  }
2075
- }
2076
- ]
2077
- });
2078
 
2079
  editor.addMenuItem('tableprops', {
2080
  text: 'Table properties',
1510
  }
1511
 
1512
  function tableDialog() {
1513
+ var dom = editor.dom, tableElm, colsCtrl, rowsCtrl, data;
1514
 
1515
  tableElm = dom.getParent(editor.selection.getStart(), 'table');
1516
 
1517
  data = {
1518
  width: removePxSuffix(dom.getStyle(tableElm, 'width') || dom.getAttrib(tableElm, 'width')),
1519
  height: removePxSuffix(dom.getStyle(tableElm, 'height') || dom.getAttrib(tableElm, 'height')),
1520
+ cellspacing: tableElm ? dom.getAttrib(tableElm, 'cellspacing') : '',
1521
+ cellpadding: tableElm ? dom.getAttrib(tableElm, 'cellpadding') : '',
1522
+ border: tableElm ? dom.getAttrib(tableElm, 'border') : '',
1523
  caption: !!dom.select('caption', tableElm)[0]
1524
  };
1525
 
1529
  }
1530
  });
1531
 
1532
+ if (!tableElm) {
1533
+ colsCtrl = {label: 'Cols', name: 'cols'};
1534
+ rowsCtrl = {label: 'Rows', name: 'rows'};
1535
+ }
1536
+
1537
  editor.windowManager.open({
1538
  title: "Table properties",
1539
  items: {
1546
  maxWidth: 50
1547
  },
1548
  items: [
1549
+ colsCtrl,
1550
+ rowsCtrl,
1551
  {label: 'Width', name: 'width'},
1552
  {label: 'Height', name: 'height'},
1553
  {label: 'Cell spacing', name: 'cellspacing'},
1575
  var data = this.toJSON(), captionElm;
1576
 
1577
  editor.undoManager.transact(function() {
1578
+ if (!tableElm) {
1579
+ tableElm = insertTable(data.cols || 1, data.rows || 1);
1580
+ }
1581
+
1582
  editor.dom.setAttribs(tableElm, {
1583
  cellspacing: data.cellspacing,
1584
  cellpadding: data.cellpadding,
1880
  function insertTable(cols, rows) {
1881
  var y, x, html;
1882
 
1883
+ html = '<table id="__mce"><tbody>';
1884
 
1885
  for (y = 0; y < rows; y++) {
1886
  html += '<tr>';
1895
  html += '</tbody></table>';
1896
 
1897
  editor.insertContent(html);
1898
+
1899
+ var tableElm = editor.dom.get('__mce');
1900
+ editor.dom.setAttrib(tableElm, 'id', null);
1901
+
1902
+ return tableElm;
1903
  }
1904
 
1905
  function handleDisabledState(ctrl, selector) {
1998
  return focusCell.parentNode;
1999
  }
2000
 
2001
+ if (editor.settings.table_grid === false) {
2002
+ editor.addMenuItem('inserttable', {
2003
+ text: 'Insert table',
2004
+ icon: 'table',
2005
+ context: 'table',
2006
+ onclick: tableDialog
2007
+ });
2008
+ } else {
2009
+ editor.addMenuItem('inserttable', {
2010
+ text: 'Insert table',
2011
+ icon: 'table',
2012
+ context: 'table',
2013
+ ariaHideMenu: true,
2014
+ onclick: function(e) {
2015
+ if (e.aria) {
2016
+ this.parent().hideAll();
2017
+ e.stopImmediatePropagation();
2018
+ tableDialog();
2019
+ }
2020
+ },
2021
+ onhide: function() {
2022
+ var elements = this.menu.items()[0].getEl().getElementsByTagName('a');
2023
+ editor.dom.removeClass(elements, 'mce-active');
2024
+ editor.dom.addClass(elements[0], 'mce-active');
2025
+ },
2026
+ menu: [
2027
+ {
2028
+ type: 'container',
2029
+ html: generateTableGrid(),
2030
 
2031
+ onPostRender: function() {
2032
+ this.lastX = this.lastY = 0;
2033
+ },
2034
 
2035
+ onmousemove: function(e) {
2036
+ var target = e.target, x, y;
2037
 
2038
+ if (target.tagName.toUpperCase() == 'A') {
2039
+ x = parseInt(target.getAttribute('data-mce-x'), 10);
2040
+ y = parseInt(target.getAttribute('data-mce-y'), 10);
2041
 
2042
+ if (x !== this.lastX || y !== this.lastY) {
2043
+ selectGrid(x, y, e.control);
2044
 
2045
+ this.lastX = x;
2046
+ this.lastY = y;
2047
+ }
2048
  }
2049
+ },
 
2050
 
2051
+ onkeydown: function(e) {
2052
+ var x = this.lastX, y = this.lastY, isHandled;
2053
 
2054
+ switch (e.keyCode) {
2055
+ case 37: // DOM_VK_LEFT
2056
+ if (x > 0) {
2057
+ x--;
2058
+ isHandled = true;
2059
+ }
2060
+ break;
2061
 
2062
+ case 39: // DOM_VK_RIGHT
2063
+ isHandled = true;
2064
 
2065
+ if (x < 9) {
2066
+ x++;
2067
+ }
2068
+ break;
2069
 
2070
+ case 38: // DOM_VK_UP
2071
+ isHandled = true;
2072
 
2073
+ if (y > 0) {
2074
+ y--;
2075
+ }
2076
+ break;
2077
 
2078
+ case 40: // DOM_VK_DOWN
2079
+ isHandled = true;
2080
 
2081
+ if (y < 9) {
2082
+ y++;
2083
+ }
2084
+ break;
2085
+ }
2086
 
2087
+ if (isHandled) {
2088
+ e.preventDefault();
2089
+ e.stopPropagation();
2090
 
2091
+ selectGrid(x, y, e.control).focus();
2092
 
2093
+ this.lastX = x;
2094
+ this.lastY = y;
2095
+ }
2096
+ },
2097
 
2098
+ onclick: function(e) {
2099
+ if (e.target.tagName.toUpperCase() == 'A') {
2100
+ e.preventDefault();
2101
+ e.stopPropagation();
2102
+ this.parent().cancel();
2103
 
2104
+ insertTable(this.lastX + 1, this.lastY + 1);
2105
+ }
2106
  }
2107
  }
2108
+ ]
2109
+ });
2110
+ }
2111
 
2112
  editor.addMenuItem('tableprops', {
2113
  text: 'Table properties',
tinymce4-table/plugin.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"use strict";function n(e,t){for(var n,o=[],i=0;i<e.length;++i){if(n=l[e[i]]||r(e[i]),!n)throw"module definition dependecy not found: "+e[i];o.push(n)}t.apply(null,o)}function o(e,o,i){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(o===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(o,function(){l[e]=i.apply(null,arguments)})}function i(e){return!!l[e]}function r(t){for(var n=e,o=t.split(/[.\/]/),i=0;i<o.length;++i){if(!n[o[i]])return;n=n[o[i]]}return n}function a(n){for(var o=0;o<n.length;o++){for(var i=e,r=n[o],a=r.split(/[.\/]/),s=0;s<a.length-1;++s)i[a[s]]===t&&(i[a[s]]={}),i=i[a[s]];i[a[a.length-1]]=l[r]}}var l={},s="tinymce/tableplugin/TableGrid",c="tinymce/util/Tools",d="tinymce/Env",u="tinymce/tableplugin/Quirks",f="tinymce/util/VK",m="tinymce/tableplugin/CellSelection",p="tinymce/dom/TreeWalker",g="tinymce/tableplugin/Plugin",h="tinymce/PluginManager";o(s,[c,d],function(e,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=e.each;return function(r,a){function l(){var e=0;A=[],i(["thead","tbody","tfoot"],function(t){var n=I.select("> "+t+" tr",a);i(n,function(n,r){r+=e,i(I.select("> td, > th",n),function(e,n){var i,a,l,s;if(A[r])for(;A[r][n];)n++;for(l=o(e,"rowspan"),s=o(e,"colspan"),a=r;r+l>a;a++)for(A[a]||(A[a]=[]),i=n;n+s>i;i++)A[a][i]={part:t,real:a==r&&i==n,elm:e,rowspan:l,colspan:s}})}),e+=n.length})}function s(e,t){return e=e.cloneNode(t),e.removeAttribute("id"),e}function c(e,t){var n;return n=A[t],n?n[e]:void 0}function d(e,t,n){e&&(n=parseInt(n,10),1===n?e.removeAttribute(t,1):e.setAttribute(t,n,1))}function u(e){return e&&(I.hasClass(e.elm,"mce-item-selected")||e==M)}function f(){var e=[];return i(a.rows,function(t){i(t.cells,function(n){return I.hasClass(n,"mce-item-selected")||M&&n==M.elm?(e.push(t),!1):void 0})}),e}function m(){var e=I.createRng();e.setStartAfter(a),e.setEndAfter(a),E.setRng(e),I.remove(a)}function p(t){var o,a={};return r.settings.table_clone_elements!==!1&&(a=e.makeMap((r.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),e.walk(t,function(e){var r;return 3==e.nodeType?(i(I.getParents(e.parentNode,null,t).reverse(),function(e){a[e.nodeName]&&(e=s(e,!1),o?r&&r.appendChild(e):o=r=e,r=e)}),r&&(r.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=s(t,!1),d(t,"rowSpan",1),d(t,"colSpan",1),o?t.appendChild(o):n.ie||(t.innerHTML='<br data-mce-bogus="1" />'),t}function g(){var e=I.createRng(),t;return i(I.select("tr",a),function(e){0===e.cells.length&&I.remove(e)}),0===I.select("tr",a).length?(e.setStartBefore(a),e.setEndBefore(a),E.setRng(e),void I.remove(a)):(i(I.select("thead,tbody,tfoot",a),function(e){0===e.rows.length&&I.remove(e)}),l(),void(B&&(t=A[Math.min(A.length-1,B.y)],t&&(E.select(t[Math.min(t.length-1,B.x)].elm,!0),E.collapse(!0)))))}function h(e,t,n,o){var i,r,a,l,s;for(i=A[t][e].elm.parentNode,a=1;n>=a;a++)if(i=I.getNext(i,"tr")){for(r=e;r>=0;r--)if(s=A[t+a][r].elm,s.parentNode==i){for(l=1;o>=l;l++)I.insertAfter(p(s),s);break}if(-1==r)for(l=1;o>=l;l++)i.insertBefore(p(i.cells[0]),i.cells[0])}}function v(){i(A,function(e,t){i(e,function(e,n){var i,r,a;if(u(e)&&(e=e.elm,i=o(e,"colspan"),r=o(e,"rowspan"),i>1||r>1)){for(d(e,"rowSpan",1),d(e,"colSpan",1),a=0;i-1>a;a++)I.insertAfter(p(e),e);h(n,t,r-1,i)}})})}function b(t,n,o){var r,a,s,f,m,p,h,b,y,w,x;if(t?(r=S(t),a=r.x,s=r.y,f=a+(n-1),m=s+(o-1)):(B=_=null,i(A,function(e,t){i(e,function(e,n){u(e)&&(B||(B={x:n,y:t}),_={x:n,y:t})})}),B&&(a=B.x,s=B.y,f=_.x,m=_.y)),b=c(a,s),y=c(f,m),b&&y&&b.part==y.part){for(v(),l(),b=c(a,s).elm,d(b,"colSpan",f-a+1),d(b,"rowSpan",m-s+1),h=s;m>=h;h++)for(p=a;f>=p;p++)A[h]&&A[h][p]&&(t=A[h][p].elm,t!=b&&(w=e.grep(t.childNodes),i(w,function(e){b.appendChild(e)}),w.length&&(w=e.grep(b.childNodes),x=0,i(w,function(e){"BR"==e.nodeName&&I.getAttrib(e,"data-mce-bogus")&&x++<w.length-1&&b.removeChild(e)})),I.remove(t)));g()}}function y(e){var n,r,a,l,c,f,m,g,h;if(i(A,function(t,o){return i(t,function(t){return u(t)&&(t=t.elm,c=t.parentNode,f=s(c,!1),n=o,e)?!1:void 0}),e?!n:void 0}),n!==t){for(l=0;l<A[0].length;l++)if(A[n][l]&&(r=A[n][l].elm,r!=a)){if(e){if(n>0&&A[n-1][l]&&(g=A[n-1][l].elm,h=o(g,"rowSpan"),h>1)){d(g,"rowSpan",h+1);continue}}else if(h=o(r,"rowspan"),h>1){d(r,"rowSpan",h+1);continue}m=p(r),d(m,"colSpan",r.colSpan),f.appendChild(m),a=r}f.hasChildNodes()&&(e?c.parentNode.insertBefore(f,c):I.insertAfter(f,c))}}function w(e){var t,n;i(A,function(n){return i(n,function(n,o){return u(n)&&(t=o,e)?!1:void 0}),e?!t:void 0}),i(A,function(i,r){var a,l,s;i[t]&&(a=i[t].elm,a!=n&&(s=o(a,"colspan"),l=o(a,"rowspan"),1==s?e?(a.parentNode.insertBefore(p(a),a),h(t,r,l-1,s)):(I.insertAfter(p(a),a),h(t,r,l-1,s)):d(a,"colSpan",a.colSpan+1),n=a))})}function x(){var t=[];i(A,function(n){i(n,function(n,r){u(n)&&-1===e.inArray(t,r)&&(i(A,function(e){var t=e[r].elm,n;n=o(t,"colSpan"),n>1?d(t,"colSpan",n-1):I.remove(t)}),t.push(r))})}),g()}function C(){function e(e){var t,n,r;t=I.getNext(e,"tr"),i(e.cells,function(e){var t=o(e,"rowSpan");t>1&&(d(e,"rowSpan",t-1),n=S(e),h(n.x,n.y,1,1))}),n=S(e.cells[0]),i(A[n.y],function(e){var t;e=e.elm,e!=r&&(t=o(e,"rowSpan"),1>=t?I.remove(e):d(e,"rowSpan",t-1),r=e)})}var t;t=f(),i(t.reverse(),function(t){e(t)}),g()}function P(){var e=f();return I.remove(e),g(),e}function R(){var e=f();return i(e,function(t,n){e[n]=s(t,!0)}),e}function T(e,t){var n=f(),o=n[t?0:n.length-1],r=o.cells.length;e&&(i(A,function(e){var t;return r=0,i(e,function(e){e.real&&(r+=e.colspan),e.elm.parentNode==o&&(t=1)}),t?!1:void 0}),t||e.reverse(),i(e,function(e){var n,i=e.cells.length,a;for(n=0;i>n;n++)a=e.cells[n],d(a,"colSpan",1),d(a,"rowSpan",1);for(n=i;r>n;n++)e.appendChild(p(e.cells[i-1]));for(n=r;i>n;n++)I.remove(e.cells[n]);t?o.parentNode.insertBefore(e,o):I.insertAfter(e,o)}),I.removeClass(I.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function S(e){var t;return i(A,function(n,o){return i(n,function(n,i){return n.elm==e?(t={x:i,y:o},!1):void 0}),!t}),t}function N(e){B=S(e)}function k(){var e,t;return e=t=0,i(A,function(n,o){i(n,function(n,i){var r,a;u(n)&&(n=A[o][i],i>e&&(e=i),o>t&&(t=o),n.real&&(r=n.colspan-1,a=n.rowspan-1,r&&i+r>e&&(e=i+r),a&&o+a>t&&(t=o+a)))})}),{x:e,y:t}}function D(e){var t,n,o,i,r,a,l,s,c,d;if(_=S(e),B&&_){for(t=Math.min(B.x,_.x),n=Math.min(B.y,_.y),o=Math.max(B.x,_.x),i=Math.max(B.y,_.y),r=o,a=i,d=n;a>=d;d++)e=A[d][t],e.real||t-(e.colspan-1)<t&&(t-=e.colspan-1);for(c=t;r>=c;c++)e=A[n][c],e.real||n-(e.rowspan-1)<n&&(n-=e.rowspan-1);for(d=n;i>=d;d++)for(c=t;o>=c;c++)e=A[d][c],e.real&&(l=e.colspan-1,s=e.rowspan-1,l&&c+l>r&&(r=c+l),s&&d+s>a&&(a=d+s));for(I.removeClass(I.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=n;a>=d;d++)for(c=t;r>=c;c++)A[d][c]&&I.addClass(A[d][c].elm,"mce-item-selected")}}var A,B,_,M,E=r.selection,I=E.dom;a=a||I.getParent(E.getStart(),"table"),l(),M=I.getParent(E.getStart(),"th,td"),M&&(B=S(M),_=k(),M=c(B.x,B.y)),e.extend(this,{deleteTable:m,split:v,merge:b,insertRow:y,insertCol:w,deleteCols:x,deleteRows:C,cutRows:P,copyRows:R,pasteRows:T,getPos:S,setStartCell:N,setEndCell:D})}}),o(u,[f,d,c],function(e,t,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=n.each;return function(n){function r(){function t(t){function r(e,o){var i=e?"previousSibling":"nextSibling",r=n.dom.getParent(o,"tr"),l=r[i];if(l)return h(n,o,l,e),t.preventDefault(),!0;var d=n.dom.getParent(r,"table"),u=r.parentNode,f=u.nodeName.toLowerCase();if("tbody"===f||f===(e?"tfoot":"thead")){var m=a(e,d,u,"tbody");if(null!==m)return s(e,m,o)}return c(e,r,i,d)}function a(e,t,o,i){var r=n.dom.select(">"+i,t),a=r.indexOf(o);if(e&&0===a||!e&&a===r.length-1)return l(e,t);if(-1===a){var s="thead"===o.tagName.toLowerCase()?0:r.length-1;return r[s]}return r[a+(e?-1:1)]}function l(e,t){var o=e?"thead":"tfoot",i=n.dom.select(">"+o,t);return 0!==i.length?i[0]:null}function s(e,o,i){var r=d(o,e);return r&&h(n,i,r,e),t.preventDefault(),!0}function c(e,o,i,a){var l=a[i];if(l)return u(l),!0;var s=n.dom.getParent(a,"td,th");if(s)return r(e,s,t);var c=d(o,!e);return u(c),t.preventDefault(),!1}function d(e,t){var o=e&&e[t?"lastChild":"firstChild"];return o&&"BR"===o.nodeName?n.dom.getParent(o,"td,th"):o}function u(e){n.selection.setCursorLocation(e,0)}function f(){return y==e.UP||y==e.DOWN}function m(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"tr");return null!==n}function p(e){for(var t=0,n=e;n.previousSibling;)n=n.previousSibling,t+=o(n,"colspan");return t}function g(e,t){var n=0,r=0;return i(e.children,function(e,i){return n+=o(e,"colspan"),r=i,n>t?!1:void 0}),r}function h(e,t,o,i){var r=p(n.dom.getParent(t,"td,th")),a=g(o,r),l=o.childNodes[a],s=d(l,i);u(s||l)}function v(e){var t=n.selection.getNode(),o=n.dom.getParent(t,"td,th"),i=n.dom.getParent(e,"td,th");return o&&o!==i&&b(o,i)}function b(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var y=t.keyCode;if(f()&&m(n)){var w=n.selection.getNode();setTimeout(function(){v(w)&&r(!t.shiftKey&&y===e.UP,w,t)},0)}}n.on("KeyDown",function(e){t(e)})}function a(){function e(e,t){var n=t.ownerDocument,o=n.createRange(),i;return o.setStartBefore(t),o.setEnd(e.endContainer,e.endOffset),i=n.createElement("body"),i.appendChild(o.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var o,i,r=n.dom;(37==t.keyCode||38==t.keyCode)&&(o=n.selection.getRng(),i=r.getParent(o.startContainer,"table"),i&&n.getBody().firstChild==i&&e(o,i)&&(o=r.createRng(),o.setStartBefore(i),o.setEndBefore(i),n.selection.setRng(o),t.preventDefault()))})}function l(){n.on("KeyDown SetContent VisualAid",function(){var e;for(e=n.getBody().lastChild;e;e=e.previousSibling)if(3==e.nodeType){if(e.nodeValue.length>0)break}else if(1==e.nodeType&&!e.getAttribute("data-mce-bogus"))break;e&&"TABLE"==e.nodeName&&(n.settings.forced_root_block?n.dom.add(n.getBody(),n.settings.forced_root_block,n.settings.forced_root_block_attrs,t.ie&&t.ie<11?"&nbsp;":'<br data-mce-bogus="1" />'):n.dom.add(n.getBody(),"br",{"data-mce-bogus":"1"}))}),n.on("PreProcess",function(e){var t=e.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||"\xa0"==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&n.dom.remove(t)})}function s(){function e(e,t,n,o){var i=3,r=e.dom.getParent(t.startContainer,"TABLE"),a,l,s;return r&&(a=r.parentNode),l=t.startContainer.nodeType==i&&0===t.startOffset&&0===t.endOffset&&o&&("TR"==n.nodeName||n==a),s=("TD"==n.nodeName||"TH"==n.nodeName)&&!o,l||s}function t(){var t=n.selection.getRng(),o=n.selection.getNode(),i=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,o,i)){i||(i=o);for(var r=i.lastChild;r.lastChild;)r=r.lastChild;t.setEnd(r,r.nodeValue.length),n.selection.setRng(t)}}n.on("KeyDown",function(){t()}),n.on("MouseDown",function(e){2!=e.button&&t()})}function c(){n.on("keydown",function(t){if((t.keyCode==e.DELETE||t.keyCode==e.BACKSPACE)&&!t.isDefaultPrevented()){var o=n.dom.getParent(n.selection.getStart(),"table");if(o){for(var i=n.dom.select("td,th",o),r=i.length;r--;)if(!n.dom.hasClass(i[r],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(r(),s()),t.gecko&&(a(),l()),t.ie>10&&(a(),l())}}),o(m,[s,p,c],function(e,t,n){return function(o){function i(){o.getBody().style.webkitUserSelect="",d&&(o.dom.removeClass(o.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=!1)}function r(t){var n,i,r=t.target;if(s&&(l||r!=s)&&("TD"==r.nodeName||"TH"==r.nodeName)){i=a.getParent(r,"table"),i==c&&(l||(l=new e(o,i),l.setStartCell(s),o.getBody().style.webkitUserSelect="none"),l.setEndCell(r),d=!0),n=o.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(u){}t.preventDefault()}}var a=o.dom,l,s,c,d=!0;return o.on("MouseDown",function(e){2!=e.button&&(i(),s=a.getParent(e.target,"td,th"),c=a.getParent(s,"table"))}),o.on("mouseover",r),o.on("remove",function(){a.unbind(o.getDoc(),"mouseover",r)}),o.on("MouseUp",function(){function e(e,o){var r=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(o?i.setStart(e,0):i.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(o?i.setStartBefore(e):i.setEndBefore(e))}while(e=o?r.next():r.prev())}var i,r=o.selection,d,u,f,m,p;if(s){if(l&&(o.getBody().style.webkitUserSelect=""),d=a.select("td.mce-item-selected,th.mce-item-selected"),d.length>0){i=a.createRng(),f=d[0],p=d[d.length-1],i.setStartBefore(f),i.setEndAfter(f),e(f,1),u=new t(f,a.getParent(d[0],"table"));do if("TD"==f.nodeName||"TH"==f.nodeName){if(!a.hasClass(f,"mce-item-selected"))break;m=f}while(f=u.next());e(m),r.setRng(i)}o.nodeChanged(),s=l=c=null}}),o.on("KeyUp",function(){i()}),{clear:i}}}),o(g,[s,u,m,c,p,d,h],function(e,t,n,o,i,r,a){function l(o){function i(e){return e?e.replace(/px$/,""):""}function a(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function l(e){s("left center right".split(" "),function(t){o.formatter.remove("align"+t,{},e)})}function c(){var e=o.dom,t,n;t=e.getParent(o.selection.getStart(),"table"),n={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),cellspacing:e.getAttrib(t,"cellspacing"),cellpadding:e.getAttrib(t,"cellpadding"),border:e.getAttrib(t,"border"),caption:!!e.select("caption",t)[0]},s("left center right".split(" "),function(e){o.formatter.matchNode(t,"align"+e)&&(n.align=e)}),o.windowManager.open({title:"Table properties",items:{type:"form",layout:"grid",columns:2,data:n,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"},{label:"Alignment",minWidth:90,name:"align",type:"listbox",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var n=this.toJSON(),i;o.undoManager.transact(function(){o.dom.setAttribs(t,{cellspacing:n.cellspacing,cellpadding:n.cellpadding,border:n.border}),o.dom.setStyles(t,{width:a(n.width),height:a(n.height)}),i=e.select("caption",t)[0],i&&!n.caption&&e.remove(i),!i&&n.caption&&(i=e.create("caption"),i.innerHTML=r.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(i,t.firstChild)),l(t),n.align&&o.formatter.apply("align"+n.align,{},t),o.focus(),o.addVisual()})}})}function d(e,t){o.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",size:10},{label:"Rows",name:"rows",type:"textbox",size:10}],onsubmit:function(){var n=this.toJSON();o.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})}function u(){var e=o.dom,t,n,r=[];r=o.dom.select("td.mce-item-selected,th.mce-item-selected"),t=o.dom.getParent(o.selection.getStart(),"td,th"),!r.length&&t&&r.push(t),t=t||r[0],t&&(n={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),scope:e.getAttrib(t,"scope")},n.type=t.nodeName.toLowerCase(),s("left center right".split(" "),function(e){o.formatter.matchNode(t,"align"+e)&&(n.align=e)}),o.windowManager.open({title:"Cell properties",items:{type:"form",data:n,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"Alignment",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var t=this.toJSON();o.undoManager.transact(function(){s(r,function(n){o.dom.setAttrib(n,"scope",t.scope),o.dom.setStyles(n,{width:a(t.width),height:a(t.height)}),t.type&&n.nodeName.toLowerCase()!=t.type&&(n=e.rename(n,t.type)),l(n),t.align&&o.formatter.apply("align"+t.align,{},n)}),o.focus()})}}))}function f(){var e=o.dom,t,n,r,c,d=[];t=o.dom.getParent(o.selection.getStart(),"table"),n=o.dom.getParent(o.selection.getStart(),"td,th"),s(t.rows,function(t){s(t.cells,function(o){return e.hasClass(o,"mce-item-selected")||o==n?(d.push(t),!1):void 0})}),r=d[0],r&&(c={height:i(e.getStyle(r,"height")||e.getAttrib(r,"height")),scope:e.getAttrib(r,"scope")},c.type=r.parentNode.nodeName.toLowerCase(),s("left center right".split(" "),function(e){o.formatter.matchNode(r,"align"+e)&&(c.align=e)}),o.windowManager.open({title:"Row properties",items:{type:"form",data:c,columns:2,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"}]},onsubmit:function(){var t=this.toJSON(),n,i,r;o.undoManager.transact(function(){var c=t.type;s(d,function(s){o.dom.setAttrib(s,"scope",t.scope),o.dom.setStyles(s,{height:a(t.height)}),c!=s.parentNode.nodeName.toLowerCase()&&(n=e.getParent(s,"table"),i=s.parentNode,r=e.select(c,n)[0],r||(r=e.create(c),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)),r.appendChild(s),i.hasChildNodes()||e.remove(i)),l(s),t.align&&o.formatter.apply("align"+t.align,{},s)}),o.focus()})}}))}function m(e){return function(){o.execCommand(e)}}function p(e,t){var n,i,a;for(a="<table><tbody>",n=0;t>n;n++){for(a+="<tr>",i=0;e>i;i++)a+="<td>"+(r.ie?" ":"<br>")+"</td>";a+="</tr>"}a+="</tbody></table>",o.insertContent(a)}function g(e,t){function n(){e.disabled(!o.dom.getParent(o.selection.getStart(),t)),o.selection.selectorChanged(t,function(t){e.disabled(!t)})}o.initialized?n():o.on("init",n)}function h(){g(this,"table")}function v(){g(this,"td,th")}function b(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;10>t;t++){e+="<tr>";for(var n=0;10>n;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'" '+(n+t===0?' class="mce-active"':"")+"></a></td>";e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function y(e,t,n){var i=n.getEl().getElementsByTagName("table")[0],r=n.parent().rel,a,l,s,c;if(n.isRtl()||"tl-tr"==r){for(l=9;l>=0;l--)for(a=0;10>a;a++)c=i.rows[l].childNodes[a].firstChild,o.dom.toggleClass(c,"mce-active",a>=e&&t>=l),a>=e&&t>=l&&(s=c);e=9-e,i.nextSibling.innerHTML=e+" x "+(t+1)}else{for(l=0;10>l;l++)for(a=0;10>a;a++)c=i.rows[l].childNodes[a].firstChild,o.dom.toggleClass(c,"mce-active",e>=a&&t>=l),e>=a&&t>=l&&(s=c);i.nextSibling.innerHTML=e+1+" x "+(t+1)}return s.parentNode}var w,x,C=this;o.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");o.dom.removeClass(e,"mce-active"),o.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:b(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t=e.target,n,o;"A"==t.nodeName&&(n=parseInt(t.getAttribute("data-mce-x"),10),o=parseInt(t.getAttribute("data-mce-y"),10),(n!==this.lastX||o!==this.lastY)&&(y(n,o,e.control),this.lastX=n,this.lastY=o))},onkeydown:function(e){var t=this.lastX,n=this.lastY,o;switch(e.keyCode){case 37:t>0&&(t--,o=!0);break;case 39:o=!0,9>t&&t++;break;case 38:o=!0,n>0&&n--;break;case 40:o=!0,9>n&&n++}o&&(e.preventDefault(),e.stopPropagation(),y(t,n,e.control).focus(),this.lastX=t,this.lastY=n)},onclick:function(e){"A"==e.target.nodeName&&(e.preventDefault(),e.stopPropagation(),this.parent().cancel(),p(this.lastX+1,this.lastY+1))}}]}),o.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:h,onclick:c}),o.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:h,cmd:"mceTableDelete"}),o.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:m("mceTableCellProps"),onPostRender:v},{text:"Merge cells",onclick:m("mceTableMergeCells"),onPostRender:v},{text:"Split cell",onclick:m("mceTableSplitCells"),onPostRender:v}]}),o.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:m("mceTableInsertRowBefore"),onPostRender:v},{text:"Insert row after",onclick:m("mceTableInsertRowAfter"),onPostRender:v},{text:"Delete row",onclick:m("mceTableDeleteRow"),onPostRender:v},{text:"Row properties",onclick:m("mceTableRowProps"),onPostRender:v},{text:"-"},{text:"Cut row",onclick:m("mceTableCutRow"),onPostRender:v},{text:"Copy row",onclick:m("mceTableCopyRow"),onPostRender:v},{text:"Paste row before",onclick:m("mceTablePasteRowBefore"),onPostRender:v},{text:"Paste row after",onclick:m("mceTablePasteRowAfter"),onPostRender:v}]}),o.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:m("mceTableInsertColBefore"),onPostRender:v},{text:"Insert column after",onclick:m("mceTableInsertColAfter"),onPostRender:v},{text:"Delete column",onclick:m("mceTableDeleteCol"),onPostRender:v}]});var P=[];s("inserttable tableprops deletetable | cell row column".split(" "),function(e){P.push("|"==e?{text:"-"}:o.menuItems[e])}),o.addButton("table",{type:"menubutton",title:"Table",menu:P}),r.isIE||o.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(o.selection.select(e),o.nodeChanged())}),C.quirks=new t(o),o.on("Init",function(){w=o.windowManager,C.cellSelection=new n(o)}),s({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t,n,i;i=o.dom.getParent(o.selection.getStart(),"th,td"),i&&(t=i.rowSpan,n=i.colSpan),o.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():d(e,i)},mceTableInsertRowBefore:function(e){e.insertRow(!0)},mceTableInsertRowAfter:function(e){e.insertRow()},mceTableInsertColBefore:function(e){e.insertCol(!0)},mceTableInsertColAfter:function(e){e.insertCol()},mceTableDeleteCol:function(e){e.deleteCols()},mceTableDeleteRow:function(e){e.deleteRows()},mceTableCutRow:function(e){x=e.cutRows()},mceTableCopyRow:function(e){x=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(x,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(x)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){o.addCommand(n,function(){var n=new e(o);n&&(t(n),o.execCommand("mceRepaint"),C.cellSelection.clear())})}),s({mceInsertTable:function(){c()},mceTableRowProps:f,mceTableCellProps:u},function(e,t){o.addCommand(t,function(t,n){e(n)})})}var s=o.each;a.add("table",l)}),a([s,u,m,g])}(this);
1
+ !function(e,t){"use strict";function n(e,t){for(var n,o=[],i=0;i<e.length;++i){if(n=l[e[i]]||r(e[i]),!n)throw"module definition dependecy not found: "+e[i];o.push(n)}t.apply(null,o)}function o(e,o,i){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(o===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(o,function(){l[e]=i.apply(null,arguments)})}function i(e){return!!l[e]}function r(t){for(var n=e,o=t.split(/[.\/]/),i=0;i<o.length;++i){if(!n[o[i]])return;n=n[o[i]]}return n}function a(n){for(var o=0;o<n.length;o++){for(var i=e,r=n[o],a=r.split(/[.\/]/),s=0;s<a.length-1;++s)i[a[s]]===t&&(i[a[s]]={}),i=i[a[s]];i[a[a.length-1]]=l[r]}}var l={},s="tinymce/tableplugin/TableGrid",c="tinymce/util/Tools",d="tinymce/Env",u="tinymce/tableplugin/Quirks",f="tinymce/util/VK",m="tinymce/tableplugin/CellSelection",p="tinymce/dom/TreeWalker",g="tinymce/tableplugin/Plugin",h="tinymce/PluginManager";o(s,[c,d],function(e,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=e.each;return function(r,a){function l(){var e=0;A=[],i(["thead","tbody","tfoot"],function(t){var n=I.select("> "+t+" tr",a);i(n,function(n,r){r+=e,i(I.select("> td, > th",n),function(e,n){var i,a,l,s;if(A[r])for(;A[r][n];)n++;for(l=o(e,"rowspan"),s=o(e,"colspan"),a=r;r+l>a;a++)for(A[a]||(A[a]=[]),i=n;n+s>i;i++)A[a][i]={part:t,real:a==r&&i==n,elm:e,rowspan:l,colspan:s}})}),e+=n.length})}function s(e,t){return e=e.cloneNode(t),e.removeAttribute("id"),e}function c(e,t){var n;return n=A[t],n?n[e]:void 0}function d(e,t,n){e&&(n=parseInt(n,10),1===n?e.removeAttribute(t,1):e.setAttribute(t,n,1))}function u(e){return e&&(I.hasClass(e.elm,"mce-item-selected")||e==M)}function f(){var e=[];return i(a.rows,function(t){i(t.cells,function(n){return I.hasClass(n,"mce-item-selected")||M&&n==M.elm?(e.push(t),!1):void 0})}),e}function m(){var e=I.createRng();e.setStartAfter(a),e.setEndAfter(a),E.setRng(e),I.remove(a)}function p(t){var o,a={};return r.settings.table_clone_elements!==!1&&(a=e.makeMap((r.settings.table_clone_elements||"strong em b i span font h1 h2 h3 h4 h5 h6 p div").toUpperCase(),/[ ,]/)),e.walk(t,function(e){var r;return 3==e.nodeType?(i(I.getParents(e.parentNode,null,t).reverse(),function(e){a[e.nodeName]&&(e=s(e,!1),o?r&&r.appendChild(e):o=r=e,r=e)}),r&&(r.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=s(t,!1),d(t,"rowSpan",1),d(t,"colSpan",1),o?t.appendChild(o):n.ie||(t.innerHTML='<br data-mce-bogus="1" />'),t}function g(){var e=I.createRng(),t;return i(I.select("tr",a),function(e){0===e.cells.length&&I.remove(e)}),0===I.select("tr",a).length?(e.setStartBefore(a),e.setEndBefore(a),E.setRng(e),void I.remove(a)):(i(I.select("thead,tbody,tfoot",a),function(e){0===e.rows.length&&I.remove(e)}),l(),void(B&&(t=A[Math.min(A.length-1,B.y)],t&&(E.select(t[Math.min(t.length-1,B.x)].elm,!0),E.collapse(!0)))))}function h(e,t,n,o){var i,r,a,l,s;for(i=A[t][e].elm.parentNode,a=1;n>=a;a++)if(i=I.getNext(i,"tr")){for(r=e;r>=0;r--)if(s=A[t+a][r].elm,s.parentNode==i){for(l=1;o>=l;l++)I.insertAfter(p(s),s);break}if(-1==r)for(l=1;o>=l;l++)i.insertBefore(p(i.cells[0]),i.cells[0])}}function b(){i(A,function(e,t){i(e,function(e,n){var i,r,a;if(u(e)&&(e=e.elm,i=o(e,"colspan"),r=o(e,"rowspan"),i>1||r>1)){for(d(e,"rowSpan",1),d(e,"colSpan",1),a=0;i-1>a;a++)I.insertAfter(p(e),e);h(n,t,r-1,i)}})})}function v(t,n,o){var r,a,s,f,m,p,h,v,y,w,x;if(t?(r=T(t),a=r.x,s=r.y,f=a+(n-1),m=s+(o-1)):(B=D=null,i(A,function(e,t){i(e,function(e,n){u(e)&&(B||(B={x:n,y:t}),D={x:n,y:t})})}),B&&(a=B.x,s=B.y,f=D.x,m=D.y)),v=c(a,s),y=c(f,m),v&&y&&v.part==y.part){for(b(),l(),v=c(a,s).elm,d(v,"colSpan",f-a+1),d(v,"rowSpan",m-s+1),h=s;m>=h;h++)for(p=a;f>=p;p++)A[h]&&A[h][p]&&(t=A[h][p].elm,t!=v&&(w=e.grep(t.childNodes),i(w,function(e){v.appendChild(e)}),w.length&&(w=e.grep(v.childNodes),x=0,i(w,function(e){"BR"==e.nodeName&&I.getAttrib(e,"data-mce-bogus")&&x++<w.length-1&&v.removeChild(e)})),I.remove(t)));g()}}function y(e){var n,r,a,l,c,f,m,g,h;if(i(A,function(t,o){return i(t,function(t){return u(t)&&(t=t.elm,c=t.parentNode,f=s(c,!1),n=o,e)?!1:void 0}),e?!n:void 0}),n!==t){for(l=0;l<A[0].length;l++)if(A[n][l]&&(r=A[n][l].elm,r!=a)){if(e){if(n>0&&A[n-1][l]&&(g=A[n-1][l].elm,h=o(g,"rowSpan"),h>1)){d(g,"rowSpan",h+1);continue}}else if(h=o(r,"rowspan"),h>1){d(r,"rowSpan",h+1);continue}m=p(r),d(m,"colSpan",r.colSpan),f.appendChild(m),a=r}f.hasChildNodes()&&(e?c.parentNode.insertBefore(f,c):I.insertAfter(f,c))}}function w(e){var t,n;i(A,function(n){return i(n,function(n,o){return u(n)&&(t=o,e)?!1:void 0}),e?!t:void 0}),i(A,function(i,r){var a,l,s;i[t]&&(a=i[t].elm,a!=n&&(s=o(a,"colspan"),l=o(a,"rowspan"),1==s?e?(a.parentNode.insertBefore(p(a),a),h(t,r,l-1,s)):(I.insertAfter(p(a),a),h(t,r,l-1,s)):d(a,"colSpan",a.colSpan+1),n=a))})}function x(){var t=[];i(A,function(n){i(n,function(n,r){u(n)&&-1===e.inArray(t,r)&&(i(A,function(e){var t=e[r].elm,n;n=o(t,"colSpan"),n>1?d(t,"colSpan",n-1):I.remove(t)}),t.push(r))})}),g()}function C(){function e(e){var t,n,r;t=I.getNext(e,"tr"),i(e.cells,function(e){var t=o(e,"rowSpan");t>1&&(d(e,"rowSpan",t-1),n=T(e),h(n.x,n.y,1,1))}),n=T(e.cells[0]),i(A[n.y],function(e){var t;e=e.elm,e!=r&&(t=o(e,"rowSpan"),1>=t?I.remove(e):d(e,"rowSpan",t-1),r=e)})}var t;t=f(),i(t.reverse(),function(t){e(t)}),g()}function P(){var e=f();return I.remove(e),g(),e}function R(){var e=f();return i(e,function(t,n){e[n]=s(t,!0)}),e}function S(e,t){var n=f(),o=n[t?0:n.length-1],r=o.cells.length;e&&(i(A,function(e){var t;return r=0,i(e,function(e){e.real&&(r+=e.colspan),e.elm.parentNode==o&&(t=1)}),t?!1:void 0}),t||e.reverse(),i(e,function(e){var n,i=e.cells.length,a;for(n=0;i>n;n++)a=e.cells[n],d(a,"colSpan",1),d(a,"rowSpan",1);for(n=i;r>n;n++)e.appendChild(p(e.cells[i-1]));for(n=r;i>n;n++)I.remove(e.cells[n]);t?o.parentNode.insertBefore(e,o):I.insertAfter(e,o)}),I.removeClass(I.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function T(e){var t;return i(A,function(n,o){return i(n,function(n,i){return n.elm==e?(t={x:i,y:o},!1):void 0}),!t}),t}function k(e){B=T(e)}function N(){var e,t;return e=t=0,i(A,function(n,o){i(n,function(n,i){var r,a;u(n)&&(n=A[o][i],i>e&&(e=i),o>t&&(t=o),n.real&&(r=n.colspan-1,a=n.rowspan-1,r&&i+r>e&&(e=i+r),a&&o+a>t&&(t=o+a)))})}),{x:e,y:t}}function _(e){var t,n,o,i,r,a,l,s,c,d;if(D=T(e),B&&D){for(t=Math.min(B.x,D.x),n=Math.min(B.y,D.y),o=Math.max(B.x,D.x),i=Math.max(B.y,D.y),r=o,a=i,d=n;a>=d;d++)e=A[d][t],e.real||t-(e.colspan-1)<t&&(t-=e.colspan-1);for(c=t;r>=c;c++)e=A[n][c],e.real||n-(e.rowspan-1)<n&&(n-=e.rowspan-1);for(d=n;i>=d;d++)for(c=t;o>=c;c++)e=A[d][c],e.real&&(l=e.colspan-1,s=e.rowspan-1,l&&c+l>r&&(r=c+l),s&&d+s>a&&(a=d+s));for(I.removeClass(I.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=n;a>=d;d++)for(c=t;r>=c;c++)A[d][c]&&I.addClass(A[d][c].elm,"mce-item-selected")}}var A,B,D,M,E=r.selection,I=E.dom;a=a||I.getParent(E.getStart(),"table"),l(),M=I.getParent(E.getStart(),"th,td"),M&&(B=T(M),D=N(),M=c(B.x,B.y)),e.extend(this,{deleteTable:m,split:b,merge:v,insertRow:y,insertCol:w,deleteCols:x,deleteRows:C,cutRows:P,copyRows:R,pasteRows:S,getPos:T,setStartCell:k,setEndCell:_})}}),o(u,[f,d,c],function(e,t,n){function o(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=n.each;return function(n){function r(){function t(t){function r(e,o){var i=e?"previousSibling":"nextSibling",r=n.dom.getParent(o,"tr"),l=r[i];if(l)return h(n,o,l,e),t.preventDefault(),!0;var d=n.dom.getParent(r,"table"),u=r.parentNode,f=u.nodeName.toLowerCase();if("tbody"===f||f===(e?"tfoot":"thead")){var m=a(e,d,u,"tbody");if(null!==m)return s(e,m,o)}return c(e,r,i,d)}function a(e,t,o,i){var r=n.dom.select(">"+i,t),a=r.indexOf(o);if(e&&0===a||!e&&a===r.length-1)return l(e,t);if(-1===a){var s="thead"===o.tagName.toLowerCase()?0:r.length-1;return r[s]}return r[a+(e?-1:1)]}function l(e,t){var o=e?"thead":"tfoot",i=n.dom.select(">"+o,t);return 0!==i.length?i[0]:null}function s(e,o,i){var r=d(o,e);return r&&h(n,i,r,e),t.preventDefault(),!0}function c(e,o,i,a){var l=a[i];if(l)return u(l),!0;var s=n.dom.getParent(a,"td,th");if(s)return r(e,s,t);var c=d(o,!e);return u(c),t.preventDefault(),!1}function d(e,t){var o=e&&e[t?"lastChild":"firstChild"];return o&&"BR"===o.nodeName?n.dom.getParent(o,"td,th"):o}function u(e){n.selection.setCursorLocation(e,0)}function f(){return y==e.UP||y==e.DOWN}function m(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"tr");return null!==n}function p(e){for(var t=0,n=e;n.previousSibling;)n=n.previousSibling,t+=o(n,"colspan");return t}function g(e,t){var n=0,r=0;return i(e.children,function(e,i){return n+=o(e,"colspan"),r=i,n>t?!1:void 0}),r}function h(e,t,o,i){var r=p(n.dom.getParent(t,"td,th")),a=g(o,r),l=o.childNodes[a],s=d(l,i);u(s||l)}function b(e){var t=n.selection.getNode(),o=n.dom.getParent(t,"td,th"),i=n.dom.getParent(e,"td,th");return o&&o!==i&&v(o,i)}function v(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var y=t.keyCode;if(f()&&m(n)){var w=n.selection.getNode();setTimeout(function(){b(w)&&r(!t.shiftKey&&y===e.UP,w,t)},0)}}n.on("KeyDown",function(e){t(e)})}function a(){function e(e,t){var n=t.ownerDocument,o=n.createRange(),i;return o.setStartBefore(t),o.setEnd(e.endContainer,e.endOffset),i=n.createElement("body"),i.appendChild(o.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var o,i,r=n.dom;(37==t.keyCode||38==t.keyCode)&&(o=n.selection.getRng(),i=r.getParent(o.startContainer,"table"),i&&n.getBody().firstChild==i&&e(o,i)&&(o=r.createRng(),o.setStartBefore(i),o.setEndBefore(i),n.selection.setRng(o),t.preventDefault()))})}function l(){n.on("KeyDown SetContent VisualAid",function(){var e;for(e=n.getBody().lastChild;e;e=e.previousSibling)if(3==e.nodeType){if(e.nodeValue.length>0)break}else if(1==e.nodeType&&!e.getAttribute("data-mce-bogus"))break;e&&"TABLE"==e.nodeName&&(n.settings.forced_root_block?n.dom.add(n.getBody(),n.settings.forced_root_block,n.settings.forced_root_block_attrs,t.ie&&t.ie<11?"&nbsp;":'<br data-mce-bogus="1" />'):n.dom.add(n.getBody(),"br",{"data-mce-bogus":"1"}))}),n.on("PreProcess",function(e){var t=e.node.lastChild;t&&("BR"==t.nodeName||1==t.childNodes.length&&("BR"==t.firstChild.nodeName||"\xa0"==t.firstChild.nodeValue))&&t.previousSibling&&"TABLE"==t.previousSibling.nodeName&&n.dom.remove(t)})}function s(){function e(e,t,n,o){var i=3,r=e.dom.getParent(t.startContainer,"TABLE"),a,l,s;return r&&(a=r.parentNode),l=t.startContainer.nodeType==i&&0===t.startOffset&&0===t.endOffset&&o&&("TR"==n.nodeName||n==a),s=("TD"==n.nodeName||"TH"==n.nodeName)&&!o,l||s}function t(){var t=n.selection.getRng(),o=n.selection.getNode(),i=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,o,i)){i||(i=o);for(var r=i.lastChild;r.lastChild;)r=r.lastChild;t.setEnd(r,r.nodeValue.length),n.selection.setRng(t)}}n.on("KeyDown",function(){t()}),n.on("MouseDown",function(e){2!=e.button&&t()})}function c(){n.on("keydown",function(t){if((t.keyCode==e.DELETE||t.keyCode==e.BACKSPACE)&&!t.isDefaultPrevented()){var o=n.dom.getParent(n.selection.getStart(),"table");if(o){for(var i=n.dom.select("td,th",o),r=i.length;r--;)if(!n.dom.hasClass(i[r],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(r(),s()),t.gecko&&(a(),l()),t.ie>10&&(a(),l())}}),o(m,[s,p,c],function(e,t,n){return function(o){function i(){o.getBody().style.webkitUserSelect="",d&&(o.dom.removeClass(o.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=!1)}function r(t){var n,i,r=t.target;if(s&&(l||r!=s)&&("TD"==r.nodeName||"TH"==r.nodeName)){i=a.getParent(r,"table"),i==c&&(l||(l=new e(o,i),l.setStartCell(s),o.getBody().style.webkitUserSelect="none"),l.setEndCell(r),d=!0),n=o.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(u){}t.preventDefault()}}var a=o.dom,l,s,c,d=!0;return o.on("MouseDown",function(e){2!=e.button&&(i(),s=a.getParent(e.target,"td,th"),c=a.getParent(s,"table"))}),o.on("mouseover",r),o.on("remove",function(){a.unbind(o.getDoc(),"mouseover",r)}),o.on("MouseUp",function(){function e(e,o){var r=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(o?i.setStart(e,0):i.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(o?i.setStartBefore(e):i.setEndBefore(e))}while(e=o?r.next():r.prev())}var i,r=o.selection,d,u,f,m,p;if(s){if(l&&(o.getBody().style.webkitUserSelect=""),d=a.select("td.mce-item-selected,th.mce-item-selected"),d.length>0){i=a.createRng(),f=d[0],p=d[d.length-1],i.setStartBefore(f),i.setEndAfter(f),e(f,1),u=new t(f,a.getParent(d[0],"table"));do if("TD"==f.nodeName||"TH"==f.nodeName){if(!a.hasClass(f,"mce-item-selected"))break;m=f}while(f=u.next());e(m),r.setRng(i)}o.nodeChanged(),s=l=c=null}}),o.on("KeyUp",function(){i()}),{clear:i}}}),o(g,[s,u,m,c,p,d,h],function(e,t,n,o,i,r,a){function l(o){function i(e){return e?e.replace(/px$/,""):""}function a(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function l(e){s("left center right".split(" "),function(t){o.formatter.remove("align"+t,{},e)})}function c(){var e=o.dom,t,n,c,d;t=e.getParent(o.selection.getStart(),"table"),d={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),cellspacing:t?e.getAttrib(t,"cellspacing"):"",cellpadding:t?e.getAttrib(t,"cellpadding"):"",border:t?e.getAttrib(t,"border"):"",caption:!!e.select("caption",t)[0]},s("left center right".split(" "),function(e){o.formatter.matchNode(t,"align"+e)&&(d.align=e)}),t||(n={label:"Cols",name:"cols"},c={label:"Rows",name:"rows"}),o.windowManager.open({title:"Table properties",items:{type:"form",layout:"grid",columns:2,data:d,defaults:{type:"textbox",maxWidth:50},items:[n,c,{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"},{label:"Alignment",minWidth:90,name:"align",type:"listbox",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var n=this.toJSON(),i;o.undoManager.transact(function(){t||(t=p(n.cols||1,n.rows||1)),o.dom.setAttribs(t,{cellspacing:n.cellspacing,cellpadding:n.cellpadding,border:n.border}),o.dom.setStyles(t,{width:a(n.width),height:a(n.height)}),i=e.select("caption",t)[0],i&&!n.caption&&e.remove(i),!i&&n.caption&&(i=e.create("caption"),i.innerHTML=r.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(i,t.firstChild)),l(t),n.align&&o.formatter.apply("align"+n.align,{},t),o.focus(),o.addVisual()})}})}function d(e,t){o.windowManager.open({title:"Merge cells",body:[{label:"Cols",name:"cols",type:"textbox",size:10},{label:"Rows",name:"rows",type:"textbox",size:10}],onsubmit:function(){var n=this.toJSON();o.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})}function u(){var e=o.dom,t,n,r=[];r=o.dom.select("td.mce-item-selected,th.mce-item-selected"),t=o.dom.getParent(o.selection.getStart(),"td,th"),!r.length&&t&&r.push(t),t=t||r[0],t&&(n={width:i(e.getStyle(t,"width")||e.getAttrib(t,"width")),height:i(e.getStyle(t,"height")||e.getAttrib(t,"height")),scope:e.getAttrib(t,"scope")},n.type=t.nodeName.toLowerCase(),s("left center right".split(" "),function(e){o.formatter.matchNode(t,"align"+e)&&(n.align=e)}),o.windowManager.open({title:"Cell properties",items:{type:"form",data:n,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width"},{label:"Height",name:"height"},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"Alignment",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]},onsubmit:function(){var t=this.toJSON();o.undoManager.transact(function(){s(r,function(n){o.dom.setAttrib(n,"scope",t.scope),o.dom.setStyles(n,{width:a(t.width),height:a(t.height)}),t.type&&n.nodeName.toLowerCase()!=t.type&&(n=e.rename(n,t.type)),l(n),t.align&&o.formatter.apply("align"+t.align,{},n)}),o.focus()})}}))}function f(){var e=o.dom,t,n,r,c,d=[];t=o.dom.getParent(o.selection.getStart(),"table"),n=o.dom.getParent(o.selection.getStart(),"td,th"),s(t.rows,function(t){s(t.cells,function(o){return e.hasClass(o,"mce-item-selected")||o==n?(d.push(t),!1):void 0})}),r=d[0],r&&(c={height:i(e.getStyle(r,"height")||e.getAttrib(r,"height")),scope:e.getAttrib(r,"scope")},c.type=r.parentNode.nodeName.toLowerCase(),s("left center right".split(" "),function(e){o.formatter.matchNode(r,"align"+e)&&(c.align=e)}),o.windowManager.open({title:"Row properties",items:{type:"form",data:c,columns:2,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"None",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"}]},onsubmit:function(){var t=this.toJSON(),n,i,r;o.undoManager.transact(function(){var c=t.type;s(d,function(s){o.dom.setAttrib(s,"scope",t.scope),o.dom.setStyles(s,{height:a(t.height)}),c!=s.parentNode.nodeName.toLowerCase()&&(n=e.getParent(s,"table"),i=s.parentNode,r=e.select(c,n)[0],r||(r=e.create(c),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)),r.appendChild(s),i.hasChildNodes()||e.remove(i)),l(s),t.align&&o.formatter.apply("align"+t.align,{},s)}),o.focus()})}}))}function m(e){return function(){o.execCommand(e)}}function p(e,t){var n,i,a;for(a='<table id="__mce"><tbody>',n=0;t>n;n++){for(a+="<tr>",i=0;e>i;i++)a+="<td>"+(r.ie?" ":"<br>")+"</td>";a+="</tr>"}a+="</tbody></table>",o.insertContent(a);var l=o.dom.get("__mce");return o.dom.setAttrib(l,"id",null),l}function g(e,t){function n(){e.disabled(!o.dom.getParent(o.selection.getStart(),t)),o.selection.selectorChanged(t,function(t){e.disabled(!t)})}o.initialized?n():o.on("init",n)}function h(){g(this,"table")}function b(){g(this,"td,th")}function v(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;10>t;t++){e+="<tr>";for(var n=0;10>n;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'" '+(n+t===0?' class="mce-active"':"")+"></a></td>";e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function y(e,t,n){var i=n.getEl().getElementsByTagName("table")[0],r=n.parent().rel,a,l,s,c;if(n.isRtl()||"tl-tr"==r){for(l=9;l>=0;l--)for(a=0;10>a;a++)c=i.rows[l].childNodes[a].firstChild,o.dom.toggleClass(c,"mce-active",a>=e&&t>=l),a>=e&&t>=l&&(s=c);e=9-e,i.nextSibling.innerHTML=e+" x "+(t+1)}else{for(l=0;10>l;l++)for(a=0;10>a;a++)c=i.rows[l].childNodes[a].firstChild,o.dom.toggleClass(c,"mce-active",e>=a&&t>=l),e>=a&&t>=l&&(s=c);i.nextSibling.innerHTML=e+1+" x "+(t+1)}return s.parentNode}var w,x,C=this;o.settings.table_grid===!1?o.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:c}):o.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),c())},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");o.dom.removeClass(e,"mce-active"),o.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:v(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t=e.target,n,o;"A"==t.tagName.toUpperCase()&&(n=parseInt(t.getAttribute("data-mce-x"),10),o=parseInt(t.getAttribute("data-mce-y"),10),(n!==this.lastX||o!==this.lastY)&&(y(n,o,e.control),this.lastX=n,this.lastY=o))},onkeydown:function(e){var t=this.lastX,n=this.lastY,o;switch(e.keyCode){case 37:t>0&&(t--,o=!0);break;case 39:o=!0,9>t&&t++;break;case 38:o=!0,n>0&&n--;break;case 40:o=!0,9>n&&n++}o&&(e.preventDefault(),e.stopPropagation(),y(t,n,e.control).focus(),this.lastX=t,this.lastY=n)},onclick:function(e){"A"==e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),this.parent().cancel(),p(this.lastX+1,this.lastY+1))}}]}),o.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:h,onclick:c}),o.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:h,cmd:"mceTableDelete"}),o.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:m("mceTableCellProps"),onPostRender:b},{text:"Merge cells",onclick:m("mceTableMergeCells"),onPostRender:b},{text:"Split cell",onclick:m("mceTableSplitCells"),onPostRender:b}]}),o.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:m("mceTableInsertRowBefore"),onPostRender:b},{text:"Insert row after",onclick:m("mceTableInsertRowAfter"),onPostRender:b},{text:"Delete row",onclick:m("mceTableDeleteRow"),onPostRender:b},{text:"Row properties",onclick:m("mceTableRowProps"),onPostRender:b},{text:"-"},{text:"Cut row",onclick:m("mceTableCutRow"),onPostRender:b},{text:"Copy row",onclick:m("mceTableCopyRow"),onPostRender:b},{text:"Paste row before",onclick:m("mceTablePasteRowBefore"),onPostRender:b},{text:"Paste row after",onclick:m("mceTablePasteRowAfter"),onPostRender:b}]}),o.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:m("mceTableInsertColBefore"),onPostRender:b},{text:"Insert column after",onclick:m("mceTableInsertColAfter"),onPostRender:b},{text:"Delete column",onclick:m("mceTableDeleteCol"),onPostRender:b}]});var P=[];s("inserttable tableprops deletetable | cell row column".split(" "),function(e){P.push("|"==e?{text:"-"}:o.menuItems[e])}),o.addButton("table",{type:"menubutton",title:"Table",menu:P}),r.isIE||o.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(o.selection.select(e),o.nodeChanged())}),C.quirks=new t(o),o.on("Init",function(){w=o.windowManager,C.cellSelection=new n(o)}),s({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t,n,i;i=o.dom.getParent(o.selection.getStart(),"th,td"),i&&(t=i.rowSpan,n=i.colSpan),o.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():d(e,i)},mceTableInsertRowBefore:function(e){e.insertRow(!0)},mceTableInsertRowAfter:function(e){e.insertRow()},mceTableInsertColBefore:function(e){e.insertCol(!0)},mceTableInsertColAfter:function(e){e.insertCol()},mceTableDeleteCol:function(e){e.deleteCols()},mceTableDeleteRow:function(e){e.deleteRows()},mceTableCutRow:function(e){x=e.cutRows()},mceTableCopyRow:function(e){x=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(x,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(x)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){o.addCommand(n,function(){var n=new e(o);n&&(t(n),o.execCommand("mceRepaint"),C.cellSelection.clear())})}),s({mceInsertTable:function(){c()},mceTableRowProps:f,mceTableCellProps:u},function(e,t){o.addCommand(t,function(t,n){e(n)})})}var s=o.each;a.add("table",l)}),a([s,u,m,g])}(this);