TinyMCE Advanced - Version 4.0.2

Version Description

  • Fix showing of the second, third and forth button rows when the Toolbar Toggle button is not used.
  • Fix adding the ''directionality'' plugin when RTL or LTR button is selected.
  • Show the ''Advanced Options'' to super admins on multisite installs.
  • Add the ''link'' plugin including link rel setting. Replaces the Insert/Edit Link dialog when enabled.
  • Include updated ''table'' plugin that has support for vertical align for cells.
Download this release

Release Info

Developer azaozz
Plugin Icon 128x128 TinyMCE Advanced
Version 4.0.2
Comparing to
See all releases

Code changes from version 4.0.1 to 4.0.2

css/tadv-styles.css CHANGED
@@ -9,14 +9,36 @@
9
  }
10
 
11
  .advanced-options {
12
- padding: 0 12px;
13
- border: 1px solid red;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
  .tadv-submit .button-large {
17
  float: right;
18
  }
19
 
 
 
 
 
20
  #tadv-confirm-uninstall {
21
  display: none;
22
  background: #FFFFE0;
@@ -45,15 +67,12 @@ ul.container,
45
  position: relative;
46
  }
47
 
48
- #unused .tadvmodule div {
49
- margin: 1px 4px 0 3px;
50
- }
51
-
52
  .tadvitem i.mce-ico {
53
  width: 20px;
54
  height: 20px;
55
  line-height: 20px;
56
  text-align: center;
 
57
  margin: 0;
58
  padding: 0;
59
  color: #555;
@@ -84,17 +103,11 @@ ul.container,
84
  filter: alpha(opacity=100);
85
  }
86
 
87
- .tadvmodule {
88
- position: relative;
89
- top: 0px;
90
- left: 0px;
91
- z-index: 0;
92
- }
93
-
94
  #tadvzones,
95
  #unused {
 
96
  -moz-user-select: none;
97
- -khtml-user-select: none;
98
  user-select: none;
99
  }
100
 
@@ -124,7 +137,7 @@ ul.container,
124
  .tadvdropzone .tadvmodule .tadvitem {
125
  border: 1px solid transparent;
126
  display: block;
127
- margin: 1px;
128
  padding: 2px 3px;
129
  width: 20px;
130
  height: 20px;
@@ -141,36 +154,34 @@ ul.container,
141
  width: 100%;
142
  margin: 0;
143
  padding: 1px 0 0;
 
144
  }
145
 
146
- #tadvadmin .tadvmodule {
147
- cursor: move;
148
- position: relative;
149
  }
150
 
151
- .tadvdropzone .tadvmodule {
152
- width: 32px;
153
- height: 28px;
154
- margin: 0;
155
- padding: 0;
156
- float: left;
157
  }
158
 
159
  #unused li,
160
  .tadvdropzone li {
161
- float: left;
162
  margin: 0;
163
  padding: 0;
164
  border: none;
165
- margin-bottom: 0;
 
 
 
 
 
 
166
  }
167
 
168
  #unused {
169
- border: 1px solid #bbb;
170
- background-color: ##f6f3f6;
171
- height: 64px;
172
- padding: 4px;
173
- margin: 8px 0;
174
  }
175
 
176
  #unused .tadvmodule .tadvitem {
@@ -179,7 +190,7 @@ ul.container,
179
  width: 140px;
180
  border: 1px solid #bbb;
181
  background-color: #fff;
182
- margin: 4px;
183
  padding: 1px 3px;
184
  -webkit-border-radius: 2px;
185
  border-radius: 2px;
@@ -229,27 +240,29 @@ ul.container,
229
  border-color: #bbb;
230
  }
231
 
232
- .tadvdropzone #tablecontrols {
233
- width: 294px;
234
- }
235
-
236
- .tadvdropzone #tablecontrols .tadvitem {
237
- width: 285px;
238
- }
239
-
240
  div.tadv-error {
241
  color: #ff0000;
242
  font-weight: bold;
243
  height: 26px;
244
  line-height: 26px;
245
- visibility: hidden;
246
  }
247
 
248
- .wp-adv-error #wp-adv-error-message,
249
- .length-error #length-error-message {
250
  visibility: visible;
251
  }
252
 
253
  .wp-adv-error #wp_adv .tadvitem {
254
  border-color: red;
255
  }
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
 
11
  .advanced-options {
12
+ margin-bottom: 20px;
13
+ border: 1px solid #ccc;
14
+ padding: 0 15px;
15
+ }
16
+
17
+ .advanced-options div {
18
+ margin: 1.2em 0;
19
+ }
20
+
21
+ .advanced-options p {
22
+ margin-left: 22px;
23
+ margin-top: 5px;
24
+ }
25
+
26
+ .advanced-options h3 {
27
+ margin-top: 15px;
28
+ }
29
+
30
+ .tadv-more-plugins {
31
+ margin-bottom: 30px;
32
  }
33
 
34
  .tadv-submit .button-large {
35
  float: right;
36
  }
37
 
38
+ #tadv-import-error {
39
+ height: 22px;
40
+ }
41
+
42
  #tadv-confirm-uninstall {
43
  display: none;
44
  background: #FFFFE0;
67
  position: relative;
68
  }
69
 
 
 
 
 
70
  .tadvitem i.mce-ico {
71
  width: 20px;
72
  height: 20px;
73
  line-height: 20px;
74
  text-align: center;
75
+ vertical-align: text-top;
76
  margin: 0;
77
  padding: 0;
78
  color: #555;
103
  filter: alpha(opacity=100);
104
  }
105
 
 
 
 
 
 
 
 
106
  #tadvzones,
107
  #unused {
108
+ -webkit-user-select: none;
109
  -moz-user-select: none;
110
+ -ms-user-select: none;
111
  user-select: none;
112
  }
113
 
137
  .tadvdropzone .tadvmodule .tadvitem {
138
  border: 1px solid transparent;
139
  display: block;
140
+ margin: 1px 2px;
141
  padding: 2px 3px;
142
  width: 20px;
143
  height: 20px;
154
  width: 100%;
155
  margin: 0;
156
  padding: 1px 0 0;
157
+ line-height: 1;
158
  }
159
 
160
+ #unuseddiv {
161
+ padding: 10px;
162
+ border: 1px solid #ccc;
163
  }
164
 
165
+ #unuseddiv h3 {
166
+ margin: 5px 5px 12px;
 
 
 
 
167
  }
168
 
169
  #unused li,
170
  .tadvdropzone li {
 
171
  margin: 0;
172
  padding: 0;
173
  border: none;
174
+ display: inline-block;
175
+ cursor: move;
176
+ vertical-align: top;
177
+ }
178
+
179
+ #unused li {
180
+ margin: 4px;
181
  }
182
 
183
  #unused {
184
+ margin: 0;
 
 
 
 
185
  }
186
 
187
  #unused .tadvmodule .tadvitem {
190
  width: 140px;
191
  border: 1px solid #bbb;
192
  background-color: #fff;
193
+ margin: 1px;
194
  padding: 1px 3px;
195
  -webkit-border-radius: 2px;
196
  border-radius: 2px;
240
  border-color: #bbb;
241
  }
242
 
 
 
 
 
 
 
 
 
243
  div.tadv-error {
244
  color: #ff0000;
245
  font-weight: bold;
246
  height: 26px;
247
  line-height: 26px;
248
+ display: none;
249
  }
250
 
251
+ .wp-adv-error #wp-adv-error-message {
 
252
  visibility: visible;
253
  }
254
 
255
  .wp-adv-error #wp_adv .tadvitem {
256
  border-color: red;
257
  }
258
+
259
+ .tadv-placeholder {
260
+ vertical-align: bottom;
261
+ display: inline-block;
262
+ position: static;
263
+ visibility: hidden;
264
+ }
265
+
266
+ .tadvdropzone .tadv-placeholder {
267
+ height: 28px;
268
+ }
js/tadv.js CHANGED
@@ -1,151 +1,59 @@
1
  // TinyMCE Advanced
2
- ( function($) {
3
- tadvSortable = {
4
-
5
- init : function() {
6
- var self = this;
7
-
8
- $('#tb1').sortable({
9
- connectWith: '#tb2, #tb3, #tb4, #unused',
10
- items : 'li',
11
- cursor: 'move',
12
- stop : self.update,
13
- revert : true,
14
- opacity : 0.7,
15
- containment : '#contain'
16
- });
17
-
18
- $('#tb2').sortable({
19
- connectWith: '#tb1, #tb3, #tb4, #unused',
20
- items : 'li',
21
- stop : self.update,
22
- revert : true,
23
- opacity : 0.7,
24
- containment : '#contain'
25
- });
26
-
27
- $('#tb3').sortable({
28
- connectWith: '#tb1, #tb2, #tb4, #unused',
29
- items : 'li',
30
- stop : self.update,
31
- revert : true,
32
- opacity : 0.7,
33
- containment : '#contain'
34
- });
35
-
36
- $('#tb4').sortable({
37
- connectWith: '#tb1, #tb2, #tb3, #unused',
38
- items : 'li',
39
- stop : self.update,
40
- revert : true,
41
- opacity : 0.7,
42
- containment : '#contain'
43
- });
44
-
45
- $('#unused').sortable({
46
- connectWith: '#tb1, #tb2, #tb3, #tb4',
47
- items : 'li',
48
- stop : self.update,
49
- revert : true,
50
- opacity : 0.7,
51
- containment : '#contain'
52
- });
53
-
54
- this.update();
55
-
56
- $(window).resize( function() {
57
- self.update();
58
- });
59
-
60
- $('#tadvadmin').on( 'submit', function(e) {
61
- var toolbars234 = $('#tb2, #tb3, #tb4');
62
 
63
- if ( toolbars234.find('li#wp_adv').length || ! toolbars234.find('li').length ) {
64
- $(document.body).addClass('wp-adv-error');
65
- e.preventDefault();
66
- }
67
- });
68
  },
69
-
70
- reset : function() {
71
- var el = $('#unused'), el_node = el.get(0), last, w, i;
72
-
73
- if ( !el.length )
74
- return;
75
-
76
- $(document.body).removeClass('wp-adv-error length-error');
77
-
78
- $('.container').each( function( num, ul ) {
79
- var kids = ul.childNodes, tbwidth = ul.clientWidth, W = 0;
80
-
81
- for ( i in kids ) {
82
- if ( w = kids[i].offsetWidth )
83
- W += w;
84
- }
85
-
86
- if ( ( W + 8 ) > tbwidth )
87
- $(document.body).addClass('length-error');
88
- });
89
-
90
- if ( el_node.childNodes.length > 6 ) {
91
- last = el_node.lastChild.previousSibling;
92
- el.height( last.offsetTop + last.offsetHeight + 30 );
93
- } else {
94
- el.height(60);
95
  }
96
  },
 
 
 
 
 
 
 
 
 
 
97
 
98
- update : function(e, ui) {
99
- var toolbar_id;
100
-
101
- tadvSortable.reset();
102
-
103
- if ( ui && ( toolbar_id = ui.item.parent().attr('id') ) )
104
- ui.item.find('input.tadv-button').attr('name', toolbar_id + '[]');
105
- }
106
- }
107
-
108
- $( document ).ready( function() {
109
- var $uninstall = $('#tadv-confirm-uninstall'),
110
- $importElement = $('#tadv-import'),
111
- $importError = $('#tadv-import-error');
112
-
113
- tadvSortable.init();
114
-
115
- $( '#menubar' ).on( 'change', function() {
116
- $( '#tadv-menu-img' ).toggleClass( 'enabled', $(this).prop('checked') );
117
- });
118
-
119
- $('#tadv-remove-settings').click( function() {
120
- $uninstall.show();
121
- });
122
-
123
- $('#tadv-cancel').click( function() {
124
- $uninstall.hide();
125
- });
126
-
127
- $('#tadv-export-select').click( function() {
128
- $('#tadv-export').focus().select();
129
- });
130
 
131
- $importElement.change( function() {
132
- $importError.empty();
133
- });
134
 
135
- $('#tadv-import-verify').click( function() {
136
- var string, parsed;
 
137
 
138
- string = ( $importElement.val() || '' ).replace( /^[^{]*/, '' ).replace( /[^}]*$/, '' );
139
- $importElement.val( string );
140
 
141
- try {
142
- parsed = JSON.parse( string );
143
- } catch( error ) {
144
- $importError.text( error );
145
- return;
146
- }
147
 
 
 
148
  $importError.text( 'No errors.' );
149
- });
 
 
150
  });
151
- }(jQuery));
1
  // TinyMCE Advanced
2
+ jQuery( document ).ready( function( $ ) {
3
+ var $importElement = $('#tadv-import'),
4
+ $importError = $('#tadv-import-error');
5
+
6
+ $('.container').sortable({
7
+ connectWith: '.container',
8
+ items: '> li',
9
+ cursor: 'move',
10
+ stop: function( event, ui ) {
11
+ var toolbar_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ if ( ui && ( toolbar_id = ui.item.parent().attr('id') ) ) {
14
+ ui.item.find('input.tadv-button').attr('name', toolbar_id + '[]');
15
+ }
 
 
16
  },
17
+ /*
18
+ activate: function( event, ui ) {
19
+ if ( this.id !== ui.sender.attr('id') ) {
20
+ $(this).parent().css({ 'border-color': '#888' }); // , 'background-color': '#fafff9'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
  },
23
+ deactivate: function( event, ui ) {
24
+ $(this).parent().css({ 'border-color': '' }); // , 'background-color': ''
25
+ },
26
+ */
27
+ revert: 300,
28
+ opacity: 0.7,
29
+ placeholder: 'tadv-placeholder',
30
+ forcePlaceholderSize: true,
31
+ containment: 'document'
32
+ });
33
 
34
+ $( '#menubar' ).on( 'change', function() {
35
+ $( '#tadv-menu-img' ).toggleClass( 'enabled', $(this).prop('checked') );
36
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
+ $('#tadv-export-select').click( function() {
39
+ $('#tadv-export').focus().select();
40
+ });
41
 
42
+ $importElement.change( function() {
43
+ $importError.empty();
44
+ });
45
 
46
+ $('#tadv-import-verify').click( function() {
47
+ var string;
48
 
49
+ string = ( $importElement.val() || '' ).replace( /^[^{]*/, '' ).replace( /[^}]*$/, '' );
50
+ $importElement.val( string );
 
 
 
 
51
 
52
+ try {
53
+ JSON.parse( string );
54
  $importError.text( 'No errors.' );
55
+ } catch( error ) {
56
+ $importError.text( error );
57
+ }
58
  });
59
+ });
mce/importcss/plugin.js CHANGED
@@ -33,11 +33,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
33
  function append(styleSheet, imported) {
34
  var href = styleSheet.href, rules;
35
 
36
- if (!imported && !contentCSSUrls[href]) {
37
- return;
38
- }
39
-
40
- if (fileFilter && !fileFilter(href)) {
41
  return;
42
  }
43
 
@@ -67,6 +63,12 @@ tinymce.PluginManager.add('importcss', function(editor) {
67
  contentCSSUrls[url] = true;
68
  });
69
 
 
 
 
 
 
 
70
  try {
71
  each(doc.styleSheets, function(styleSheet) {
72
  append(styleSheet);
@@ -127,10 +129,10 @@ tinymce.PluginManager.add('importcss', function(editor) {
127
  editor.on('renderFormatsMenu', function(e) {
128
  var settings = editor.settings, selectors = {};
129
  var selectorConverter = settings.importcss_selector_converter || convertSelectorToFormat;
130
- var selectorFilter = compileFilter(settings.importcss_selector_filter);
131
 
132
  if (!editor.settings.importcss_append) {
133
- e.control.items().remove();
134
  }
135
 
136
  // Setup new groups collection by cloning the configured one
@@ -141,7 +143,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
141
  groups.push(group);
142
  });
143
 
144
- each(getSelectors(editor.getDoc(), compileFilter(settings.importcss_file_filter)), function(selector) {
145
  if (selector.indexOf('.mce-') === -1) {
146
  if (!selectors[selector] && (!selectorFilter || selectorFilter(selector))) {
147
  var format = selectorConverter.call(self, selector), menu;
@@ -164,7 +166,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
164
 
165
  editor.formatter.register(formatName, format);
166
 
167
- var menuItem = tinymce.extend({}, e.control.settings.itemDefaults, {
168
  text: format.title,
169
  format: formatName
170
  });
@@ -172,7 +174,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
172
  if (menu) {
173
  menu.push(menuItem);
174
  } else {
175
- e.control.add(menuItem);
176
  }
177
  }
178
 
@@ -182,7 +184,7 @@ tinymce.PluginManager.add('importcss', function(editor) {
182
  });
183
 
184
  each(groups, function(group) {
185
- e.control.add(group.item);
186
  });
187
 
188
  e.control.renderNew();
33
  function append(styleSheet, imported) {
34
  var href = styleSheet.href, rules;
35
 
36
+ if (!href || !fileFilter(href, imported)) {
 
 
 
 
37
  return;
38
  }
39
 
63
  contentCSSUrls[url] = true;
64
  });
65
 
66
+ if (!fileFilter) {
67
+ fileFilter = function(href, imported) {
68
+ return imported || contentCSSUrls[href];
69
+ };
70
+ }
71
+
72
  try {
73
  each(doc.styleSheets, function(styleSheet) {
74
  append(styleSheet);
129
  editor.on('renderFormatsMenu', function(e) {
130
  var settings = editor.settings, selectors = {};
131
  var selectorConverter = settings.importcss_selector_converter || convertSelectorToFormat;
132
+ var selectorFilter = compileFilter(settings.importcss_selector_filter), ctrl = e.control;
133
 
134
  if (!editor.settings.importcss_append) {
135
+ ctrl.items().remove();
136
  }
137
 
138
  // Setup new groups collection by cloning the configured one
143
  groups.push(group);
144
  });
145
 
146
+ each(getSelectors(e.doc || editor.getDoc(), compileFilter(settings.importcss_file_filter)), function(selector) {
147
  if (selector.indexOf('.mce-') === -1) {
148
  if (!selectors[selector] && (!selectorFilter || selectorFilter(selector))) {
149
  var format = selectorConverter.call(self, selector), menu;
166
 
167
  editor.formatter.register(formatName, format);
168
 
169
+ var menuItem = tinymce.extend({}, ctrl.settings.itemDefaults, {
170
  text: format.title,
171
  format: formatName
172
  });
174
  if (menu) {
175
  menu.push(menuItem);
176
  } else {
177
+ ctrl.add(menuItem);
178
  }
179
  }
180
 
184
  });
185
 
186
  each(groups, function(group) {
187
+ ctrl.add(group.item);
188
  });
189
 
190
  e.control.renderNew();
mce/importcss/plugin.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.PluginManager.add("importcss",function(t){function e(t){return"string"==typeof t?function(e){return-1!==e.indexOf(t)}:t instanceof RegExp?function(e){return t.test(e)}:t}function n(e,n){function i(t,e){var o,l=t.href;if((e||c[l])&&(!n||n(l))){s(t.imports,function(t){i(t,!0)});try{o=t.cssRules||t.rules}catch(a){}s(o,function(t){t.styleSheet?i(t.styleSheet,!0):t.selectorText&&s(t.selectorText.split(","),function(t){r.push(tinymce.trim(t))})})}}var r=[],c={};s(t.contentCSS,function(t){c[t]=!0});try{s(e.styleSheets,function(t){i(t)})}catch(o){}return r}function i(e){var n,i=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(e);if(i){var r=i[1],s=i[2].substr(1).split(".").join(" "),c=tinymce.makeMap("a,img");return i[1]?(n={title:e},t.schema.getTextBlockElements()[r]?n.block=r:t.schema.getBlockElements()[r]||c[r.toLowerCase()]?n.selector=r:n.inline=r):i[2]&&(n={inline:"span",title:e.substr(1),classes:s}),t.settings.importcss_merge_classes!==!1?n.classes=s:n.attributes={"class":s},n}}var r=this,s=tinymce.each;t.on("renderFormatsMenu",function(c){var o=t.settings,l={},a=o.importcss_selector_converter||i,m=e(o.importcss_selector_filter);t.settings.importcss_append||c.control.items().remove();var f=[];tinymce.each(o.importcss_groups,function(t){t=tinymce.extend({},t),t.filter=e(t.filter),f.push(t)}),s(n(t.getDoc(),e(o.importcss_file_filter)),function(e){if(-1===e.indexOf(".mce-")&&!l[e]&&(!m||m(e))){var n,i=a.call(r,e);if(i){var s=i.name||tinymce.DOM.uniqueId();if(f)for(var o=0;o<f.length;o++)if(!f[o].filter||f[o].filter(e)){f[o].item||(f[o].item={text:f[o].title,menu:[]}),n=f[o].item.menu;break}t.formatter.register(s,i);var u=tinymce.extend({},c.control.settings.itemDefaults,{text:i.title,format:s});n?n.push(u):c.control.add(u)}l[e]=!0}}),s(f,function(t){c.control.add(t.item)}),c.control.renderNew()}),r.convertSelectorToFormat=i});
1
+ tinymce.PluginManager.add("importcss",function(t){function e(t){return"string"==typeof t?function(e){return-1!==e.indexOf(t)}:t instanceof RegExp?function(e){return t.test(e)}:t}function n(e,n){function i(t,e){var c,o=t.href;if(o&&n(o,e)){s(t.imports,function(t){i(t,!0)});try{c=t.cssRules||t.rules}catch(a){}s(c,function(t){t.styleSheet?i(t.styleSheet,!0):t.selectorText&&s(t.selectorText.split(","),function(t){r.push(tinymce.trim(t))})})}}var r=[],c={};s(t.contentCSS,function(t){c[t]=!0}),n||(n=function(t,e){return e||c[t]});try{s(e.styleSheets,function(t){i(t)})}catch(o){}return r}function i(e){var n,i=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(e);if(i){var r=i[1],s=i[2].substr(1).split(".").join(" "),c=tinymce.makeMap("a,img");return i[1]?(n={title:e},t.schema.getTextBlockElements()[r]?n.block=r:t.schema.getBlockElements()[r]||c[r.toLowerCase()]?n.selector=r:n.inline=r):i[2]&&(n={inline:"span",title:e.substr(1),classes:s}),t.settings.importcss_merge_classes!==!1?n.classes=s:n.attributes={"class":s},n}}var r=this,s=tinymce.each;t.on("renderFormatsMenu",function(c){var o=t.settings,a={},l=o.importcss_selector_converter||i,f=e(o.importcss_selector_filter),m=c.control;t.settings.importcss_append||m.items().remove();var u=[];tinymce.each(o.importcss_groups,function(t){t=tinymce.extend({},t),t.filter=e(t.filter),u.push(t)}),s(n(c.doc||t.getDoc(),e(o.importcss_file_filter)),function(e){if(-1===e.indexOf(".mce-")&&!a[e]&&(!f||f(e))){var n,i=l.call(r,e);if(i){var s=i.name||tinymce.DOM.uniqueId();if(u)for(var c=0;c<u.length;c++)if(!u[c].filter||u[c].filter(e)){u[c].item||(u[c].item={text:u[c].title,menu:[]}),n=u[c].item.menu;break}t.formatter.register(s,i);var o=tinymce.extend({},m.settings.itemDefaults,{text:i.title,format:s});n?n.push(o):m.add(o)}a[e]=!0}}),s(u,function(t){m.add(t.item)}),c.control.renderNew()}),r.convertSelectorToFormat=i});
mce/link/plugin.js ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /*global tinymce:true */
12
+
13
+ tinymce.PluginManager.add('link', function(editor) {
14
+ function createLinkList(callback) {
15
+ return function() {
16
+ var linkList = editor.settings.link_list;
17
+
18
+ if (typeof(linkList) == "string") {
19
+ tinymce.util.XHR.send({
20
+ url: linkList,
21
+ success: function(text) {
22
+ callback(tinymce.util.JSON.parse(text));
23
+ }
24
+ });
25
+ } else {
26
+ callback(linkList);
27
+ }
28
+ };
29
+ }
30
+
31
+ function showDialog(linkList) {
32
+ var data = {}, selection = editor.selection, dom = editor.dom, selectedElm, anchorElm, initialText;
33
+ var win, onlyText, textListCtrl, linkListCtrl, relListCtrl, targetListCtrl, classListCtrl, linkTitleCtrl;
34
+
35
+ function linkListChangeHandler(e) {
36
+ var textCtrl = win.find('#text');
37
+
38
+ if (!textCtrl.value() || (e.lastControl && textCtrl.value() == e.lastControl.text())) {
39
+ textCtrl.value(e.control.text());
40
+ }
41
+
42
+ win.find('#href').value(e.control.value());
43
+ }
44
+
45
+ function buildLinkList() {
46
+ var linkListItems = [{text: 'None', value: ''}];
47
+
48
+ tinymce.each(linkList, function(link) {
49
+ linkListItems.push({
50
+ text: link.text || link.title,
51
+ value: editor.convertURL(link.value || link.url, 'href'),
52
+ menu: link.menu
53
+ });
54
+ });
55
+
56
+ return linkListItems;
57
+ }
58
+
59
+ function applyPreview(items) {
60
+ tinymce.each(items, function(item) {
61
+ item.textStyle = function() {
62
+ return editor.formatter.getCssText({inline: 'a', classes: [item.value]});
63
+ };
64
+ });
65
+
66
+ return items;
67
+ }
68
+
69
+ function buildValues(listSettingName, dataItemName, defaultItems) {
70
+ var selectedItem, items = [];
71
+
72
+ tinymce.each(editor.settings[listSettingName] || defaultItems, function(target) {
73
+ var item = {
74
+ text: target.text || target.title,
75
+ value: target.value
76
+ };
77
+
78
+ items.push(item);
79
+
80
+ if (data[dataItemName] === target.value || (!selectedItem && target.selected)) {
81
+ selectedItem = item;
82
+ }
83
+ });
84
+
85
+ if (selectedItem && !data[dataItemName]) {
86
+ data[dataItemName] = selectedItem.value;
87
+ selectedItem.selected = true;
88
+ }
89
+
90
+ return items;
91
+ }
92
+
93
+ function buildAnchorListControl(url) {
94
+ var anchorList = [];
95
+
96
+ tinymce.each(editor.dom.select('a:not([href])'), function(anchor) {
97
+ var id = anchor.name || anchor.id;
98
+
99
+ if (id) {
100
+ anchorList.push({
101
+ text: id,
102
+ value: '#' + id,
103
+ selected: url.indexOf('#' + id) != -1
104
+ });
105
+ }
106
+ });
107
+
108
+ if (anchorList.length) {
109
+ anchorList.unshift({text: 'None', value: ''});
110
+
111
+ return {
112
+ name: 'anchor',
113
+ type: 'listbox',
114
+ label: 'Anchors',
115
+ values: anchorList,
116
+ onselect: linkListChangeHandler
117
+ };
118
+ }
119
+ }
120
+
121
+ function urlChange() {
122
+ if (linkListCtrl) {
123
+ linkListCtrl.value(editor.convertURL(this.value(), 'href'));
124
+ }
125
+
126
+ if (!initialText && data.text.length === 0 && onlyText) {
127
+ this.parent().parent().find('#text')[0].value(this.value());
128
+ }
129
+ }
130
+
131
+ function isOnlyTextSelected(anchorElm) {
132
+ var html = selection.getContent();
133
+
134
+ // Partial html and not a fully selected anchor element
135
+ if (/</.test(html) && (!/^<a [^>]+>[^<]+<\/a>$/.test(html) || html.indexOf('href=') == -1)) {
136
+ return false;
137
+ }
138
+
139
+ if (anchorElm) {
140
+ var nodes = anchorElm.childNodes, i;
141
+
142
+ if (nodes.length === 0) {
143
+ return false;
144
+ }
145
+
146
+ for (i = nodes.length - 1; i >= 0; i--) {
147
+ if (nodes[i].nodeType != 3) {
148
+ return false;
149
+ }
150
+ }
151
+ }
152
+
153
+ return true;
154
+ }
155
+
156
+ selectedElm = selection.getNode();
157
+ anchorElm = dom.getParent(selectedElm, 'a[href]');
158
+ onlyText = isOnlyTextSelected();
159
+
160
+ data.text = initialText = anchorElm ? (anchorElm.innerText || anchorElm.textContent) : selection.getContent({format: 'text'});
161
+ data.href = anchorElm ? dom.getAttrib(anchorElm, 'href') : '';
162
+ data.target = anchorElm ? dom.getAttrib(anchorElm, 'target') : (editor.settings.default_link_target || null);
163
+ data.rel = anchorElm ? dom.getAttrib(anchorElm, 'rel') : null;
164
+ data['class'] = anchorElm ? dom.getAttrib(anchorElm, 'class') : null;
165
+ data.title = anchorElm ? dom.getAttrib(anchorElm, 'title') : '';
166
+
167
+ if (onlyText) {
168
+ textListCtrl = {
169
+ name: 'text',
170
+ type: 'textbox',
171
+ size: 40,
172
+ label: 'Text to display',
173
+ onchange: function() {
174
+ data.text = this.value();
175
+ }
176
+ };
177
+ }
178
+
179
+ if (linkList) {
180
+ linkListCtrl = {
181
+ type: 'listbox',
182
+ label: 'Link list',
183
+ values: buildLinkList(),
184
+ onselect: linkListChangeHandler,
185
+ value: editor.convertURL(data.href, 'href'),
186
+ onPostRender: function() {
187
+ linkListCtrl = this;
188
+ }
189
+ };
190
+ }
191
+
192
+ if (editor.settings.target_list !== false) {
193
+ targetListCtrl = {
194
+ name: 'target',
195
+ type: 'listbox',
196
+ label: 'Target',
197
+ values: buildValues('target_list', 'target', [{text: 'None', value: ''}, {text: 'New window', value: '_blank'}])
198
+ };
199
+ }
200
+
201
+ if (editor.settings.rel_list) {
202
+ relListCtrl = {
203
+ name: 'rel',
204
+ type: 'listbox',
205
+ label: 'Rel',
206
+ values: buildValues('rel_list', 'rel', [{text: 'None', value: ''}])
207
+ };
208
+ }
209
+
210
+ if (editor.settings.link_class_list) {
211
+ classListCtrl = {
212
+ name: 'class',
213
+ type: 'listbox',
214
+ label: 'Class',
215
+ values: applyPreview(buildValues('link_class_list', 'class'))
216
+ };
217
+ }
218
+
219
+ if (editor.settings.link_title !== false) {
220
+ linkTitleCtrl = {
221
+ name: 'title',
222
+ type: 'textbox',
223
+ label: 'Title',
224
+ value: data.title
225
+ };
226
+ }
227
+
228
+ win = editor.windowManager.open({
229
+ title: 'Insert link',
230
+ data: data,
231
+ body: [
232
+ {
233
+ name: 'href',
234
+ type: 'filepicker',
235
+ filetype: 'file',
236
+ size: 40,
237
+ autofocus: true,
238
+ label: 'Url',
239
+ onchange: urlChange,
240
+ onkeyup: urlChange
241
+ },
242
+ textListCtrl,
243
+ linkTitleCtrl,
244
+ buildAnchorListControl(data.href),
245
+ linkListCtrl,
246
+ relListCtrl,
247
+ targetListCtrl,
248
+ classListCtrl
249
+ ],
250
+ onSubmit: function(e) {
251
+ var href;
252
+
253
+ data = tinymce.extend(data, e.data);
254
+ href = data.href;
255
+
256
+ // Delay confirm since onSubmit will move focus
257
+ function delayedConfirm(message, callback) {
258
+ var rng = editor.selection.getRng();
259
+
260
+ window.setTimeout(function() {
261
+ editor.windowManager.confirm(message, function(state) {
262
+ editor.selection.setRng(rng);
263
+ callback(state);
264
+ });
265
+ }, 0);
266
+ }
267
+
268
+ function insertLink() {
269
+ var linkAttrs = {
270
+ href: href,
271
+ target: data.target ? data.target : null,
272
+ rel: data.rel ? data.rel : null,
273
+ "class": data["class"] ? data["class"] : null,
274
+ title: data.title ? data.title : null
275
+ };
276
+
277
+ if (anchorElm) {
278
+ editor.focus();
279
+
280
+ if (onlyText && data.text != initialText) {
281
+ if ("innerText" in anchorElm) {
282
+ anchorElm.innerText = data.text;
283
+ } else {
284
+ anchorElm.textContent = data.text;
285
+ }
286
+ }
287
+
288
+ dom.setAttribs(anchorElm, linkAttrs);
289
+
290
+ selection.select(anchorElm);
291
+ editor.undoManager.add();
292
+ } else {
293
+ if (onlyText) {
294
+ editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(data.text)));
295
+ } else {
296
+ editor.execCommand('mceInsertLink', false, linkAttrs);
297
+ }
298
+ }
299
+ }
300
+
301
+ if (!href) {
302
+ editor.execCommand('unlink');
303
+ return;
304
+ }
305
+
306
+ // Is email and not //user@domain.com
307
+ if (href.indexOf('@') > 0 && href.indexOf('//') == -1 && href.indexOf('mailto:') == -1) {
308
+ delayedConfirm(
309
+ 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
310
+ function(state) {
311
+ if (state) {
312
+ href = 'mailto:' + href;
313
+ }
314
+
315
+ insertLink();
316
+ }
317
+ );
318
+
319
+ return;
320
+ }
321
+
322
+ // Is www. prefixed
323
+ if (/^\s*www\./i.test(href)) {
324
+ delayedConfirm(
325
+ 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?',
326
+ function(state) {
327
+ if (state) {
328
+ href = 'http://' + href;
329
+ }
330
+
331
+ insertLink();
332
+ }
333
+ );
334
+
335
+ return;
336
+ }
337
+
338
+ insertLink();
339
+ }
340
+ });
341
+ }
342
+
343
+ editor.addButton('link', {
344
+ icon: 'link',
345
+ tooltip: 'Insert/edit link',
346
+ shortcut: 'Ctrl+K',
347
+ onclick: createLinkList(showDialog),
348
+ stateSelector: 'a[href]'
349
+ });
350
+
351
+ editor.addButton('unlink', {
352
+ icon: 'unlink',
353
+ tooltip: 'Remove link',
354
+ cmd: 'unlink',
355
+ stateSelector: 'a[href]'
356
+ });
357
+
358
+ editor.addShortcut('Ctrl+K', '', createLinkList(showDialog));
359
+
360
+ this.showDialog = showDialog;
361
+
362
+ editor.addMenuItem('link', {
363
+ icon: 'link',
364
+ text: 'Insert link',
365
+ shortcut: 'Ctrl+K',
366
+ onclick: createLinkList(showDialog),
367
+ stateSelector: 'a[href]',
368
+ context: 'insert',
369
+ prependToContext: true
370
+ });
371
+ });
mce/link/plugin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ tinymce.PluginManager.add("link",function(t){function e(e){return function(){var n=t.settings.link_list;"string"==typeof n?tinymce.util.XHR.send({url:n,success:function(t){e(tinymce.util.JSON.parse(t))}}):e(n)}}function n(e){function n(t){var e=d.find("#text");(!e.value()||t.lastControl&&e.value()==t.lastControl.text())&&e.value(t.control.text()),d.find("#href").value(t.control.value())}function l(){var n=[{text:"None",value:""}];return tinymce.each(e,function(e){n.push({text:e.text||e.title,value:t.convertURL(e.value||e.url,"href"),menu:e.menu})}),n}function i(e){return tinymce.each(e,function(e){e.textStyle=function(){return t.formatter.getCssText({inline:"a",classes:[e.value]})}}),e}function a(e,n,l){var i,a=[];return tinymce.each(t.settings[e]||l,function(t){var e={text:t.text||t.title,value:t.value};a.push(e),(b[n]===t.value||!i&&t.selected)&&(i=e)}),i&&!b[n]&&(b[n]=i.value,i.selected=!0),a}function r(e){var l=[];return tinymce.each(t.dom.select("a:not([href])"),function(t){var n=t.name||t.id;n&&l.push({text:n,value:"#"+n,selected:-1!=e.indexOf("#"+n)})}),l.length?(l.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:l,onselect:n}):void 0}function o(){h&&h.value(t.convertURL(this.value(),"href")),!f&&0===b.text.length&&x&&this.parent().parent().find("#text")[0].value(this.value())}function s(t){var e=k.getContent();if(/</.test(e)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(e)||-1==e.indexOf("href=")))return!1;if(t){var n,l=t.childNodes;if(0===l.length)return!1;for(n=l.length-1;n>=0;n--)if(3!=l[n].nodeType)return!1}return!0}var u,c,f,d,x,v,h,g,m,p,y,b={},k=t.selection,w=t.dom;u=k.getNode(),c=w.getParent(u,"a[href]"),x=s(),b.text=f=c?c.innerText||c.textContent:k.getContent({format:"text"}),b.href=c?w.getAttrib(c,"href"):"",b.target=c?w.getAttrib(c,"target"):t.settings.default_link_target||null,b.rel=c?w.getAttrib(c,"rel"):null,b["class"]=c?w.getAttrib(c,"class"):null,b.title=c?w.getAttrib(c,"title"):"",x&&(v={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){b.text=this.value()}}),e&&(h={type:"listbox",label:"Link list",values:l(),onselect:n,value:t.convertURL(b.href,"href"),onPostRender:function(){h=this}}),t.settings.target_list!==!1&&(m={name:"target",type:"listbox",label:"Target",values:a("target_list","target",[{text:"None",value:""},{text:"New window",value:"_blank"}])}),t.settings.rel_list&&(g={name:"rel",type:"listbox",label:"Rel",values:a("rel_list","rel",[{text:"None",value:""}])}),t.settings.link_class_list&&(p={name:"class",type:"listbox",label:"Class",values:i(a("link_class_list","class"))}),t.settings.link_title!==!1&&(y={name:"title",type:"textbox",label:"Title",value:b.title}),d=t.windowManager.open({title:"Insert link",data:b,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:o,onkeyup:o},v,y,r(b.href),h,g,m,p],onSubmit:function(e){function n(e,n){var l=t.selection.getRng();window.setTimeout(function(){t.windowManager.confirm(e,function(e){t.selection.setRng(l),n(e)})},0)}function l(){var e={href:i,target:b.target?b.target:null,rel:b.rel?b.rel:null,"class":b["class"]?b["class"]:null,title:b.title?b.title:null};c?(t.focus(),x&&b.text!=f&&("innerText"in c?c.innerText=b.text:c.textContent=b.text),w.setAttribs(c,e),k.select(c),t.undoManager.add()):x?t.insertContent(w.createHTML("a",e,w.encode(b.text))):t.execCommand("mceInsertLink",!1,e)}var i;return b=tinymce.extend(b,e.data),(i=b.href)?i.indexOf("@")>0&&-1==i.indexOf("//")&&-1==i.indexOf("mailto:")?void n("The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(i="mailto:"+i),l()}):/^\s*www\./i.test(i)?void n("The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(i="http://"+i),l()}):void l():void t.execCommand("unlink")}})}t.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Ctrl+K",onclick:e(n),stateSelector:"a[href]"}),t.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",stateSelector:"a[href]"}),t.addShortcut("Ctrl+K","",e(n)),this.showDialog=n,t.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Ctrl+K",onclick:e(n),stateSelector:"a[href]",context:"insert",prependToContext:!0})});
mce/table/plugin.js CHANGED
@@ -432,7 +432,7 @@ define("tinymce/tableplugin/TableGrid", [
432
  cell = grid[y][x].elm;
433
 
434
  /*jshint loopfunc:true */
435
- /*eslint loop-func:0 */
436
  if (cell != startCell) {
437
  // Move children to startCell
438
  children = Tools.grep(cell.childNodes);
@@ -1449,8 +1449,9 @@ define("tinymce/tableplugin/CellSelection", [
1449
  }
1450
  });
1451
 
1452
- editor.on('KeyUp', function() {
1453
  clear();
 
1454
  });
1455
 
1456
  return {
@@ -1508,6 +1509,16 @@ define("tinymce/tableplugin/Plugin", [
1508
  editor.formatter.remove('align' + name, {}, elm);
1509
  });
1510
  }
 
 
 
 
 
 
 
 
 
 
1511
 
1512
  function tableDialog() {
1513
  var dom = editor.dom, tableElm, colsCtrl, rowsCtrl, data;
@@ -1663,6 +1674,12 @@ define("tinymce/tableplugin/Plugin", [
1663
  }
1664
  });
1665
 
 
 
 
 
 
 
1666
  editor.windowManager.open({
1667
  title: "Cell properties",
1668
  items: {
@@ -1705,7 +1722,7 @@ define("tinymce/tableplugin/Plugin", [
1705
  ]
1706
  },
1707
  {
1708
- label: 'Alignment',
1709
  name: 'align',
1710
  type: 'listbox',
1711
  text: 'None',
@@ -1717,6 +1734,20 @@ define("tinymce/tableplugin/Plugin", [
1717
  {text: 'Center', value: 'center'},
1718
  {text: 'Right', value: 'right'}
1719
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1720
  }
1721
  ]
1722
  },
@@ -1743,6 +1774,16 @@ define("tinymce/tableplugin/Plugin", [
1743
  if (data.align) {
1744
  editor.formatter.apply('align' + data.align, {}, cellElm);
1745
  }
 
 
 
 
 
 
 
 
 
 
1746
  });
1747
 
1748
  editor.focus();
@@ -1938,8 +1979,7 @@ define("tinymce/tableplugin/Plugin", [
1938
 
1939
  for (var x = 0; x < 10; x++) {
1940
  html += '<td role="gridcell" tabindex="-1"><a id="mcegrid' + (y * 10 + x) + '" href="#" ' +
1941
- 'data-mce-x="' + x + '" data-mce-y="' + y + '" ' +
1942
- '' + (x + y === 0 ? ' class="mce-active"' : '') + '></a></td>';
1943
  }
1944
 
1945
  html += '</tr>';
@@ -1954,45 +1994,26 @@ define("tinymce/tableplugin/Plugin", [
1954
 
1955
  function selectGrid(tx, ty, control) {
1956
  var table = control.getEl().getElementsByTagName('table')[0];
1957
- var rel = control.parent().rel, x, y, focusCell, cell;
 
1958
 
1959
- if (control.isRtl() || rel == 'tl-tr') {
1960
- for (y = 9; y >= 0; y--) {
1961
- for (x = 0; x < 10; x++) {
1962
- cell = table.rows[y].childNodes[x].firstChild;
1963
 
1964
- editor.dom.toggleClass(
1965
- cell,
1966
- 'mce-active',
1967
- x >= tx && y <= ty
1968
- );
1969
 
1970
- if (x >= tx && y <= ty) {
1971
- focusCell = cell;
1972
- }
1973
- }
1974
- }
1975
 
1976
- tx = 9 - tx;
1977
- table.nextSibling.innerHTML = tx + ' x ' + (ty + 1);
1978
- } else {
1979
- for (y = 0; y < 10; y++) {
1980
- for (x = 0; x < 10; x++) {
1981
- cell = table.rows[y].childNodes[x].firstChild;
1982
-
1983
- editor.dom.toggleClass(
1984
- cell,
1985
- 'mce-active',
1986
- x <= tx && y <= ty
1987
- );
1988
 
1989
- if (x <= tx && y <= ty) {
1990
- focusCell = cell;
1991
- }
1992
  }
1993
  }
1994
-
1995
- table.nextSibling.innerHTML = (tx + 1) + ' x ' + (ty + 1);
1996
  }
1997
 
1998
  return focusCell.parentNode;
@@ -2018,6 +2039,9 @@ define("tinymce/tableplugin/Plugin", [
2018
  tableDialog();
2019
  }
2020
  },
 
 
 
2021
  onhide: function() {
2022
  var elements = this.menu.items()[0].getEl().getElementsByTagName('a');
2023
  editor.dom.removeClass(elements, 'mce-active');
@@ -2039,6 +2063,10 @@ define("tinymce/tableplugin/Plugin", [
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
 
@@ -2290,4 +2318,4 @@ define("tinymce/tableplugin/Plugin", [
2290
  });
2291
 
2292
  expose(["tinymce/tableplugin/TableGrid","tinymce/tableplugin/Quirks","tinymce/tableplugin/CellSelection","tinymce/tableplugin/Plugin"]);
2293
- })(this);
432
  cell = grid[y][x].elm;
433
 
434
  /*jshint loopfunc:true */
435
+ /*eslint no-loop-func:0 */
436
  if (cell != startCell) {
437
  // Move children to startCell
438
  children = Tools.grep(cell.childNodes);
1449
  }
1450
  });
1451
 
1452
+ editor.on('KeyUp Drop', function() {
1453
  clear();
1454
+ startCell = tableGrid = startTable = null;
1455
  });
1456
 
1457
  return {
1509
  editor.formatter.remove('align' + name, {}, elm);
1510
  });
1511
  }
1512
+
1513
+ function unApplyVAlign(elm) {
1514
+
1515
+ console.log( elm );
1516
+ return;
1517
+
1518
+ each('top middle bottom'.split(' '), function(name) {
1519
+ editor.formatter.remove('valign' + name, {}, elm);
1520
+ });
1521
+ }
1522
 
1523
  function tableDialog() {
1524
  var dom = editor.dom, tableElm, colsCtrl, rowsCtrl, data;
1674
  }
1675
  });
1676
 
1677
+ each('top middle bottom'.split(' '), function(name) {
1678
+ if (editor.formatter.matchNode(cellElm, 'valign' + name)) {
1679
+ data.valign = name;
1680
+ }
1681
+ });
1682
+
1683
  editor.windowManager.open({
1684
  title: "Cell properties",
1685
  items: {
1722
  ]
1723
  },
1724
  {
1725
+ label: 'H Align',
1726
  name: 'align',
1727
  type: 'listbox',
1728
  text: 'None',
1734
  {text: 'Center', value: 'center'},
1735
  {text: 'Right', value: 'right'}
1736
  ]
1737
+ },
1738
+ {
1739
+ label: 'V Align',
1740
+ name: 'valign',
1741
+ type: 'listbox',
1742
+ text: 'None',
1743
+ minWidth: 90,
1744
+ maxWidth: null,
1745
+ values: [
1746
+ {text: 'None', value: ''},
1747
+ {text: 'Top', value: 'top'},
1748
+ {text: 'Middle', value: 'middle'},
1749
+ {text: 'Bottom', value: 'bottom'}
1750
+ ]
1751
  }
1752
  ]
1753
  },
1774
  if (data.align) {
1775
  editor.formatter.apply('align' + data.align, {}, cellElm);
1776
  }
1777
+
1778
+ // Apply/remove vertical alignment
1779
+ unApplyVAlign(cellElm);
1780
+ if (data.valign) {
1781
+
1782
+ console.log( data.valign )
1783
+
1784
+ editor.formatter.apply('valign' + data.valign, {}, cellElm);
1785
+ }
1786
+
1787
  });
1788
 
1789
  editor.focus();
1979
 
1980
  for (var x = 0; x < 10; x++) {
1981
  html += '<td role="gridcell" tabindex="-1"><a id="mcegrid' + (y * 10 + x) + '" href="#" ' +
1982
+ 'data-mce-x="' + x + '" data-mce-y="' + y + '"></a></td>';
 
1983
  }
1984
 
1985
  html += '</tr>';
1994
 
1995
  function selectGrid(tx, ty, control) {
1996
  var table = control.getEl().getElementsByTagName('table')[0];
1997
+ var x, y, focusCell, cell, active;
1998
+ var rtl = control.isRtl() || control.parent().rel == 'tl-tr';
1999
 
2000
+ table.nextSibling.innerHTML = (tx + 1) + ' x ' + (ty + 1);
 
 
 
2001
 
2002
+ if (rtl) {
2003
+ tx = 9 - tx;
2004
+ }
 
 
2005
 
2006
+ for (y = 0; y < 10; y++) {
2007
+ for (x = 0; x < 10; x++) {
2008
+ cell = table.rows[y].childNodes[x].firstChild;
2009
+ active = (rtl ? x >= tx : x <= tx) && y <= ty;
 
2010
 
2011
+ editor.dom.toggleClass(cell, 'mce-active', active);
 
 
 
 
 
 
 
 
 
 
 
2012
 
2013
+ if (active) {
2014
+ focusCell = cell;
 
2015
  }
2016
  }
 
 
2017
  }
2018
 
2019
  return focusCell.parentNode;
2039
  tableDialog();
2040
  }
2041
  },
2042
+ onshow: function() {
2043
+ selectGrid(0, 0, this.menu.items()[0]);
2044
+ },
2045
  onhide: function() {
2046
  var elements = this.menu.items()[0].getEl().getElementsByTagName('a');
2047
  editor.dom.removeClass(elements, 'mce-active');
2063
  x = parseInt(target.getAttribute('data-mce-x'), 10);
2064
  y = parseInt(target.getAttribute('data-mce-y'), 10);
2065
 
2066
+ if (this.isRtl() || this.parent().rel == 'tl-tr') {
2067
+ x = 9 - x;
2068
+ }
2069
+
2070
  if (x !== this.lastX || y !== this.lastY) {
2071
  selectGrid(x, y, e.control);
2072
 
2318
  });
2319
 
2320
  expose(["tinymce/tableplugin/TableGrid","tinymce/tableplugin/Quirks","tinymce/tableplugin/CellSelection","tinymce/tableplugin/Plugin"]);
2321
+ })(this);
mce/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 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=k(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=k(e),h(n.x,n.y,1,1))}),n=k(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 S(){var e=f();return i(e,function(t,n){e[n]=s(t,!0)}),e}function R(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 k(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 T(e){B=k(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=k(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=k(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:S,pasteRows:R,getPos:k,setStartCell:T,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);
1
+ !function(e,t){"use strict";function n(e,t){for(var n,r=[],i=0;i<e.length;++i){if(n=s[e[i]]||o(e[i]),!n)throw"module definition dependecy not found: "+e[i];r.push(n)}t.apply(null,r)}function r(e,r,i){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(r===t)throw"invalid module definition, dependencies must be specified";if(i===t)throw"invalid module definition, definition function must be specified";n(r,function(){s[e]=i.apply(null,arguments)})}function i(e){return!!s[e]}function o(t){for(var n=e,r=t.split(/[.\/]/),i=0;i<r.length;++i){if(!n[r[i]])return;n=n[r[i]]}return n}function a(n){for(var r=0;r<n.length;r++){for(var i=e,o=n[r],a=o.split(/[.\/]/),l=0;l<a.length-1;++l)i[a[l]]===t&&(i[a[l]]={}),i=i[a[l]];i[a[a.length-1]]=s[o]}}var s={},l="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",h="tinymce/tableplugin/Plugin",g="tinymce/PluginManager";r(l,[c,d],function(e,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=e.each;return function(o,a){function s(){var e=0;A=[],i(["thead","tbody","tfoot"],function(t){var n=M.select("> "+t+" tr",a);i(n,function(n,o){o+=e,i(M.select("> td, > th",n),function(e,n){var i,a,s,l;if(A[o])for(;A[o][n];)n++;for(s=r(e,"rowspan"),l=r(e,"colspan"),a=o;o+s>a;a++)for(A[a]||(A[a]=[]),i=n;n+l>i;i++)A[a][i]={part:t,real:a==o&&i==n,elm:e,rowspan:s,colspan:l}})}),e+=n.length})}function l(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&&(M.hasClass(e.elm,"mce-item-selected")||e==D)}function f(){var e=[];return i(a.rows,function(t){i(t.cells,function(n){return M.hasClass(n,"mce-item-selected")||D&&n==D.elm?(e.push(t),!1):void 0})}),e}function m(){var e=M.createRng();e.setStartAfter(a),e.setEndAfter(a),L.setRng(e),M.remove(a)}function p(t){var r,a={};return o.settings.table_clone_elements!==!1&&(a=e.makeMap((o.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 o;return 3==e.nodeType?(i(M.getParents(e.parentNode,null,t).reverse(),function(e){a[e.nodeName]&&(e=l(e,!1),r?o&&o.appendChild(e):r=o=e,o=e)}),o&&(o.innerHTML=n.ie?"&nbsp;":'<br data-mce-bogus="1" />'),!1):void 0},"childNodes"),t=l(t,!1),d(t,"rowSpan",1),d(t,"colSpan",1),r?t.appendChild(r):n.ie||(t.innerHTML='<br data-mce-bogus="1" />'),t}function h(){var e=M.createRng(),t;return i(M.select("tr",a),function(e){0===e.cells.length&&M.remove(e)}),0===M.select("tr",a).length?(e.setStartBefore(a),e.setEndBefore(a),L.setRng(e),void M.remove(a)):(i(M.select("thead,tbody,tfoot",a),function(e){0===e.rows.length&&M.remove(e)}),s(),void(B&&(t=A[Math.min(A.length-1,B.y)],t&&(L.select(t[Math.min(t.length-1,B.x)].elm,!0),L.collapse(!0)))))}function g(e,t,n,r){var i,o,a,s,l;for(i=A[t][e].elm.parentNode,a=1;n>=a;a++)if(i=M.getNext(i,"tr")){for(o=e;o>=0;o--)if(l=A[t+a][o].elm,l.parentNode==i){for(s=1;r>=s;s++)M.insertAfter(p(l),l);break}if(-1==o)for(s=1;r>=s;s++)i.insertBefore(p(i.cells[0]),i.cells[0])}}function v(){i(A,function(e,t){i(e,function(e,n){var i,o,a;if(u(e)&&(e=e.elm,i=r(e,"colspan"),o=r(e,"rowspan"),i>1||o>1)){for(d(e,"rowSpan",1),d(e,"colSpan",1),a=0;i-1>a;a++)M.insertAfter(p(e),e);g(n,t,o-1,i)}})})}function y(t,n,r){var o,a,l,f,m,p,g,y,b,C,x;if(t?(o=S(t),a=o.x,l=o.y,f=a+(n-1),m=l+(r-1)):(B=P=null,i(A,function(e,t){i(e,function(e,n){u(e)&&(B||(B={x:n,y:t}),P={x:n,y:t})})}),B&&(a=B.x,l=B.y,f=P.x,m=P.y)),y=c(a,l),b=c(f,m),y&&b&&y.part==b.part){for(v(),s(),y=c(a,l).elm,d(y,"colSpan",f-a+1),d(y,"rowSpan",m-l+1),g=l;m>=g;g++)for(p=a;f>=p;p++)A[g]&&A[g][p]&&(t=A[g][p].elm,t!=y&&(C=e.grep(t.childNodes),i(C,function(e){y.appendChild(e)}),C.length&&(C=e.grep(y.childNodes),x=0,i(C,function(e){"BR"==e.nodeName&&M.getAttrib(e,"data-mce-bogus")&&x++<C.length-1&&y.removeChild(e)})),M.remove(t)));h()}}function b(e){var n,o,a,s,c,f,m,h,g;if(i(A,function(t,r){return i(t,function(t){return u(t)&&(t=t.elm,c=t.parentNode,f=l(c,!1),n=r,e)?!1:void 0}),e?!n:void 0}),n!==t){for(s=0;s<A[0].length;s++)if(A[n][s]&&(o=A[n][s].elm,o!=a)){if(e){if(n>0&&A[n-1][s]&&(h=A[n-1][s].elm,g=r(h,"rowSpan"),g>1)){d(h,"rowSpan",g+1);continue}}else if(g=r(o,"rowspan"),g>1){d(o,"rowSpan",g+1);continue}m=p(o),d(m,"colSpan",o.colSpan),f.appendChild(m),a=o}f.hasChildNodes()&&(e?c.parentNode.insertBefore(f,c):M.insertAfter(f,c))}}function C(e){var t,n;i(A,function(n){return i(n,function(n,r){return u(n)&&(t=r,e)?!1:void 0}),e?!t:void 0}),i(A,function(i,o){var a,s,l;i[t]&&(a=i[t].elm,a!=n&&(l=r(a,"colspan"),s=r(a,"rowspan"),1==l?e?(a.parentNode.insertBefore(p(a),a),g(t,o,s-1,l)):(M.insertAfter(p(a),a),g(t,o,s-1,l)):d(a,"colSpan",a.colSpan+1),n=a))})}function x(){var t=[];i(A,function(n){i(n,function(n,o){u(n)&&-1===e.inArray(t,o)&&(i(A,function(e){var t=e[o].elm,n;n=r(t,"colSpan"),n>1?d(t,"colSpan",n-1):M.remove(t)}),t.push(o))})}),h()}function w(){function e(e){var t,n,o;t=M.getNext(e,"tr"),i(e.cells,function(e){var t=r(e,"rowSpan");t>1&&(d(e,"rowSpan",t-1),n=S(e),g(n.x,n.y,1,1))}),n=S(e.cells[0]),i(A[n.y],function(e){var t;e=e.elm,e!=o&&(t=r(e,"rowSpan"),1>=t?M.remove(e):d(e,"rowSpan",t-1),o=e)})}var t;t=f(),i(t.reverse(),function(t){e(t)}),h()}function _(){var e=f();return M.remove(e),h(),e}function N(){var e=f();return i(e,function(t,n){e[n]=l(t,!0)}),e}function E(e,t){var n=f(),r=n[t?0:n.length-1],o=r.cells.length;e&&(i(A,function(e){var t;return o=0,i(e,function(e){e.real&&(o+=e.colspan),e.elm.parentNode==r&&(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;o>n;n++)e.appendChild(p(e.cells[i-1]));for(n=o;i>n;n++)M.remove(e.cells[n]);t?r.parentNode.insertBefore(e,r):M.insertAfter(e,r)}),M.removeClass(M.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"))}function S(e){var t;return i(A,function(n,r){return i(n,function(n,i){return n.elm==e?(t={x:i,y:r},!1):void 0}),!t}),t}function k(e){B=S(e)}function T(){var e,t;return e=t=0,i(A,function(n,r){i(n,function(n,i){var o,a;u(n)&&(n=A[r][i],i>e&&(e=i),r>t&&(t=r),n.real&&(o=n.colspan-1,a=n.rowspan-1,o&&i+o>e&&(e=i+o),a&&r+a>t&&(t=r+a)))})}),{x:e,y:t}}function R(e){var t,n,r,i,o,a,s,l,c,d;if(P=S(e),B&&P){for(t=Math.min(B.x,P.x),n=Math.min(B.y,P.y),r=Math.max(B.x,P.x),i=Math.max(B.y,P.y),o=r,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;o>=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;r>=c;c++)e=A[d][c],e.real&&(s=e.colspan-1,l=e.rowspan-1,s&&c+s>o&&(o=c+s),l&&d+l>a&&(a=d+l));for(M.removeClass(M.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=n;a>=d;d++)for(c=t;o>=c;c++)A[d][c]&&M.addClass(A[d][c].elm,"mce-item-selected")}}var A,B,P,D,L=o.selection,M=L.dom;a=a||M.getParent(L.getStart(),"table"),s(),D=M.getParent(L.getStart(),"th,td"),D&&(B=S(D),P=T(),D=c(B.x,B.y)),e.extend(this,{deleteTable:m,split:v,merge:y,insertRow:b,insertCol:C,deleteCols:x,deleteRows:w,cutRows:_,copyRows:N,pasteRows:E,getPos:S,setStartCell:k,setEndCell:R})}}),r(u,[f,d,c],function(e,t,n){function r(e,t){return parseInt(e.getAttribute(t)||1,10)}var i=n.each;return function(n){function o(){function t(t){function o(e,r){var i=e?"previousSibling":"nextSibling",o=n.dom.getParent(r,"tr"),s=o[i];if(s)return g(n,r,s,e),t.preventDefault(),!0;var d=n.dom.getParent(o,"table"),u=o.parentNode,f=u.nodeName.toLowerCase();if("tbody"===f||f===(e?"tfoot":"thead")){var m=a(e,d,u,"tbody");if(null!==m)return l(e,m,r)}return c(e,o,i,d)}function a(e,t,r,i){var o=n.dom.select(">"+i,t),a=o.indexOf(r);if(e&&0===a||!e&&a===o.length-1)return s(e,t);if(-1===a){var l="thead"===r.tagName.toLowerCase()?0:o.length-1;return o[l]}return o[a+(e?-1:1)]}function s(e,t){var r=e?"thead":"tfoot",i=n.dom.select(">"+r,t);return 0!==i.length?i[0]:null}function l(e,r,i){var o=d(r,e);return o&&g(n,i,o,e),t.preventDefault(),!0}function c(e,r,i,a){var s=a[i];if(s)return u(s),!0;var l=n.dom.getParent(a,"td,th");if(l)return o(e,l,t);var c=d(r,!e);return u(c),t.preventDefault(),!1}function d(e,t){var r=e&&e[t?"lastChild":"firstChild"];return r&&"BR"===r.nodeName?n.dom.getParent(r,"td,th"):r}function u(e){n.selection.setCursorLocation(e,0)}function f(){return b==e.UP||b==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+=r(n,"colspan");return t}function h(e,t){var n=0,o=0;return i(e.children,function(e,i){return n+=r(e,"colspan"),o=i,n>t?!1:void 0}),o}function g(e,t,r,i){var o=p(n.dom.getParent(t,"td,th")),a=h(r,o),s=r.childNodes[a],l=d(s,i);u(l||s)}function v(e){var t=n.selection.getNode(),r=n.dom.getParent(t,"td,th"),i=n.dom.getParent(e,"td,th");return r&&r!==i&&y(r,i)}function y(e,t){return n.dom.getParent(e,"TABLE")===n.dom.getParent(t,"TABLE")}var b=t.keyCode;if(f()&&m(n)){var C=n.selection.getNode();setTimeout(function(){v(C)&&o(!t.shiftKey&&b===e.UP,C,t)},0)}}n.on("KeyDown",function(e){t(e)})}function a(){function e(e,t){var n=t.ownerDocument,r=n.createRange(),i;return r.setStartBefore(t),r.setEnd(e.endContainer,e.endOffset),i=n.createElement("body"),i.appendChild(r.cloneContents()),0===i.innerHTML.replace(/<(br|img|object|embed|input|textarea)[^>]*>/gi,"-").replace(/<[^>]+>/g,"").length}n.on("KeyDown",function(t){var r,i,o=n.dom;(37==t.keyCode||38==t.keyCode)&&(r=n.selection.getRng(),i=o.getParent(r.startContainer,"table"),i&&n.getBody().firstChild==i&&e(r,i)&&(r=o.createRng(),r.setStartBefore(i),r.setEndBefore(i),n.selection.setRng(r),t.preventDefault()))})}function s(){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 l(){function e(e,t,n,r){var i=3,o=e.dom.getParent(t.startContainer,"TABLE"),a,s,l;return o&&(a=o.parentNode),s=t.startContainer.nodeType==i&&0===t.startOffset&&0===t.endOffset&&r&&("TR"==n.nodeName||n==a),l=("TD"==n.nodeName||"TH"==n.nodeName)&&!r,s||l}function t(){var t=n.selection.getRng(),r=n.selection.getNode(),i=n.dom.getParent(t.startContainer,"TD,TH");if(e(n,t,r,i)){i||(i=r);for(var o=i.lastChild;o.lastChild;)o=o.lastChild;t.setEnd(o,o.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 r=n.dom.getParent(n.selection.getStart(),"table");if(r){for(var i=n.dom.select("td,th",r),o=i.length;o--;)if(!n.dom.hasClass(i[o],"mce-item-selected"))return;t.preventDefault(),n.execCommand("mceTableDelete")}}})}c(),t.webkit&&(o(),l()),t.gecko&&(a(),s()),t.ie>10&&(a(),s())}}),r(m,[l,p,c],function(e,t,n){return function(r){function i(){r.getBody().style.webkitUserSelect="",d&&(r.dom.removeClass(r.dom.select("td.mce-item-selected,th.mce-item-selected"),"mce-item-selected"),d=!1)}function o(t){var n,i,o=t.target;if(l&&(s||o!=l)&&("TD"==o.nodeName||"TH"==o.nodeName)){i=a.getParent(o,"table"),i==c&&(s||(s=new e(r,i),s.setStartCell(l),r.getBody().style.webkitUserSelect="none"),s.setEndCell(o),d=!0),n=r.selection.getSel();try{n.removeAllRanges?n.removeAllRanges():n.empty()}catch(u){}t.preventDefault()}}var a=r.dom,s,l,c,d=!0;return r.on("MouseDown",function(e){2!=e.button&&(i(),l=a.getParent(e.target,"td,th"),c=a.getParent(l,"table"))}),r.on("mouseover",o),r.on("remove",function(){a.unbind(r.getDoc(),"mouseover",o)}),r.on("MouseUp",function(){function e(e,r){var o=new t(e,e);do{if(3==e.nodeType&&0!==n.trim(e.nodeValue).length)return void(r?i.setStart(e,0):i.setEnd(e,e.nodeValue.length));if("BR"==e.nodeName)return void(r?i.setStartBefore(e):i.setEndBefore(e))}while(e=r?o.next():o.prev())}var i,o=r.selection,d,u,f,m,p;if(l){if(s&&(r.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),o.setRng(i)}r.nodeChanged(),l=s=c=null}}),r.on("KeyUp Drop",function(){i(),l=s=c=null}),{clear:i}}}),r(h,[l,u,m,c,p,d,g],function(e,t,n,r,i,o,a){function s(r){function i(e){return e?e.replace(/px$/,""):""}function a(e){return/^[0-9]+$/.test(e)&&(e+="px"),e}function s(e){l("left center right".split(" "),function(t){r.formatter.remove("align"+t,{},e)})}function c(e){l("top middle bottom".split(" "),function(t){r.formatter.remove("valign"+t,{},e)})}function d(){var e=r.dom,t,n,c,d;t=e.getParent(r.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]},l("left center right".split(" "),function(e){r.formatter.matchNode(t,"align"+e)&&(d.align=e)}),t||(n={label:"Cols",name:"cols"},c={label:"Rows",name:"rows"}),r.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;r.undoManager.transact(function(){t||(t=h(n.cols||1,n.rows||1)),r.dom.setAttribs(t,{cellspacing:n.cellspacing,cellpadding:n.cellpadding,border:n.border}),r.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=o.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(i,t.firstChild)),s(t),n.align&&r.formatter.apply("align"+n.align,{},t),r.focus(),r.addVisual()})}})}function u(e,t){r.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();r.undoManager.transact(function(){e.merge(t,n.cols,n.rows)})}})}function f(){var e=r.dom,t,n,o=[];o=r.dom.select("td.mce-item-selected,th.mce-item-selected"),t=r.dom.getParent(r.selection.getStart(),"td,th"),!o.length&&t&&o.push(t),t=t||o[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(),l("left center right".split(" "),function(e){r.formatter.matchNode(t,"align"+e)&&(n.align=e)}),l("top middle bottom".split(" "),function(e){r.formatter.matchNode(t,"valign"+e)&&(n.valign=e)}),r.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:"H Align",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"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},onsubmit:function(){var t=this.toJSON();r.undoManager.transact(function(){l(o,function(n){r.dom.setAttrib(n,"scope",t.scope),r.dom.setStyles(n,{width:a(t.width),height:a(t.height)}),t.type&&n.nodeName.toLowerCase()!=t.type&&(n=e.rename(n,t.type)),s(n),t.align&&r.formatter.apply("align"+t.align,{},n),c(n),t.valign&&r.formatter.apply("valign"+t.valign,{},n)}),r.focus()})}}))}function m(){var e=r.dom,t,n,o,c,d=[];t=r.dom.getParent(r.selection.getStart(),"table"),n=r.dom.getParent(r.selection.getStart(),"td,th"),l(t.rows,function(t){l(t.cells,function(r){return e.hasClass(r,"mce-item-selected")||r==n?(d.push(t),!1):void 0})}),o=d[0],o&&(c={height:i(e.getStyle(o,"height")||e.getAttrib(o,"height")),scope:e.getAttrib(o,"scope")},c.type=o.parentNode.nodeName.toLowerCase(),l("left center right".split(" "),function(e){r.formatter.matchNode(o,"align"+e)&&(c.align=e)}),r.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,o;r.undoManager.transact(function(){var c=t.type;l(d,function(l){r.dom.setAttrib(l,"scope",t.scope),r.dom.setStyles(l,{height:a(t.height)}),c!=l.parentNode.nodeName.toLowerCase()&&(n=e.getParent(l,"table"),i=l.parentNode,o=e.select(c,n)[0],o||(o=e.create(c),n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o)),o.appendChild(l),i.hasChildNodes()||e.remove(i)),s(l),t.align&&r.formatter.apply("align"+t.align,{},l)}),r.focus()})}}))}function p(e){return function(){r.execCommand(e)}}function h(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>"+(o.ie?" ":"<br>")+"</td>";a+="</tr>"}a+="</tbody></table>",r.insertContent(a);var s=r.dom.get("__mce");return r.dom.setAttrib(s,"id",null),s}function g(e,t){function n(){e.disabled(!r.dom.getParent(r.selection.getStart(),t)),r.selection.selectorChanged(t,function(t){e.disabled(!t)})}r.initialized?n():r.on("init",n)}function v(){g(this,"table")}function y(){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+'"></a></td>';e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}function C(e,t,n){var i=n.getEl().getElementsByTagName("table")[0],o,a,s,l,c,d=n.isRtl()||"tl-tr"==n.parent().rel;for(i.nextSibling.innerHTML=e+1+" x "+(t+1),d&&(e=9-e),a=0;10>a;a++)for(o=0;10>o;o++)l=i.rows[a].childNodes[o].firstChild,c=(d?o>=e:e>=o)&&t>=a,r.dom.toggleClass(l,"mce-active",c),c&&(s=l);return s.parentNode}var x,w,_=this;r.settings.table_grid===!1?r.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",onclick:d}):r.addMenuItem("inserttable",{text:"Insert table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),d())},onshow:function(){C(0,0,this.menu.items()[0])},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");r.dom.removeClass(e,"mce-active"),r.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,r;"A"==t.tagName.toUpperCase()&&(n=parseInt(t.getAttribute("data-mce-x"),10),r=parseInt(t.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"==this.parent().rel)&&(n=9-n),(n!==this.lastX||r!==this.lastY)&&(C(n,r,e.control),this.lastX=n,this.lastY=r))},onkeydown:function(e){var t=this.lastX,n=this.lastY,r;switch(e.keyCode){case 37:t>0&&(t--,r=!0);break;case 39:r=!0,9>t&&t++;break;case 38:r=!0,n>0&&n--;break;case 40:r=!0,9>n&&n++}r&&(e.preventDefault(),e.stopPropagation(),C(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(),h(this.lastX+1,this.lastY+1))}}]}),r.addMenuItem("tableprops",{text:"Table properties",context:"table",onPostRender:v,onclick:d}),r.addMenuItem("deletetable",{text:"Delete table",context:"table",onPostRender:v,cmd:"mceTableDelete"}),r.addMenuItem("cell",{separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:p("mceTableCellProps"),onPostRender:y},{text:"Merge cells",onclick:p("mceTableMergeCells"),onPostRender:y},{text:"Split cell",onclick:p("mceTableSplitCells"),onPostRender:y}]}),r.addMenuItem("row",{text:"Row",context:"table",menu:[{text:"Insert row before",onclick:p("mceTableInsertRowBefore"),onPostRender:y},{text:"Insert row after",onclick:p("mceTableInsertRowAfter"),onPostRender:y},{text:"Delete row",onclick:p("mceTableDeleteRow"),onPostRender:y},{text:"Row properties",onclick:p("mceTableRowProps"),onPostRender:y},{text:"-"},{text:"Cut row",onclick:p("mceTableCutRow"),onPostRender:y},{text:"Copy row",onclick:p("mceTableCopyRow"),onPostRender:y},{text:"Paste row before",onclick:p("mceTablePasteRowBefore"),onPostRender:y},{text:"Paste row after",onclick:p("mceTablePasteRowAfter"),onPostRender:y}]}),r.addMenuItem("column",{text:"Column",context:"table",menu:[{text:"Insert column before",onclick:p("mceTableInsertColBefore"),onPostRender:y},{text:"Insert column after",onclick:p("mceTableInsertColAfter"),onPostRender:y},{text:"Delete column",onclick:p("mceTableDeleteCol"),onPostRender:y}]});var N=[];l("inserttable tableprops deletetable | cell row column".split(" "),function(e){N.push("|"==e?{text:"-"}:r.menuItems[e])}),r.addButton("table",{type:"menubutton",title:"Table",menu:N}),o.isIE||r.on("click",function(e){e=e.target,"TABLE"===e.nodeName&&(r.selection.select(e),r.nodeChanged())}),_.quirks=new t(r),r.on("Init",function(){x=r.windowManager,_.cellSelection=new n(r)}),l({mceTableSplitCells:function(e){e.split()},mceTableMergeCells:function(e){var t,n,i;i=r.dom.getParent(r.selection.getStart(),"th,td"),i&&(t=i.rowSpan,n=i.colSpan),r.dom.select("td.mce-item-selected,th.mce-item-selected").length?e.merge():u(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){w=e.cutRows()},mceTableCopyRow:function(e){w=e.copyRows()},mceTablePasteRowBefore:function(e){e.pasteRows(w,!0)},mceTablePasteRowAfter:function(e){e.pasteRows(w)},mceTableDelete:function(e){e.deleteTable()}},function(t,n){r.addCommand(n,function(){var n=new e(r);n&&(t(n),r.execCommand("mceRepaint"),_.cellSelection.clear())})}),l({mceInsertTable:function(){d()},mceTableRowProps:m,mceTableCellProps:f},function(e,t){r.addCommand(t,function(t,n){e(n)})})}var l=r.each;a.add("table",s)}),a([l,u,m,h])}(this);
mce/wptadv/plugin.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global tinymce:true */
2
+
3
+ tinymce.PluginManager.add('wptadv', function( editor ) {
4
+
5
+ editor.on( 'init', function() {
6
+ editor.formatter.register({
7
+ valigntop: [{selector: 'td,th', styles: {'verticalAlign': 'top'}}],
8
+ valignmiddle: [{selector: 'td,th', styles: {'verticalAlign': 'middle'}}],
9
+ valignbottom: [{selector: 'td,th', styles: {'verticalAlign': 'bottom'}}]
10
+ });
11
+
12
+ if ( ! editor.settings.wpautop && editor.settings.tadv_noautop ) {
13
+ editor.on( 'SaveContent', function( event ) {
14
+ var regex = [
15
+ new RegExp('https?://(www\.)?youtube\.com/watch.*', 'i'),
16
+ new RegExp('http://youtu.be/*'),
17
+ new RegExp('http://blip.tv/*'),
18
+ new RegExp('https?://(www\.)?vimeo\.com/.*', 'i'),
19
+ new RegExp('https?://(www\.)?dailymotion\.com/.*', 'i'),
20
+ new RegExp('http://dai.ly/*'),
21
+ new RegExp('https?://(www\.)?flickr\.com/.*', 'i'),
22
+ new RegExp('http://flic.kr/*'),
23
+ new RegExp('https?://(.+\.)?smugmug\.com/.*', 'i'),
24
+ new RegExp('https?://(www\.)?hulu\.com/watch/.*', 'i'),
25
+ new RegExp('https?://(www\.)?viddler\.com/.*', 'i'),
26
+ new RegExp('http://qik.com/*'),
27
+ new RegExp('http://revision3.com/*'),
28
+ new RegExp('http://i*.photobucket.com/albums/*'),
29
+ new RegExp('http://gi*.photobucket.com/groups/*'),
30
+ new RegExp('https?://(www\.)?scribd\.com/.*', 'i'),
31
+ new RegExp('http://wordpress.tv/*'),
32
+ new RegExp('https?://(.+\.)?polldaddy\.com/.*', 'i'),
33
+ new RegExp('https?://(www\.)?funnyordie\.com/videos/.*', 'i'),
34
+ new RegExp('https?://(www\.)?twitter\.com/.+?/status(es)?/.*', 'i'),
35
+ new RegExp('https?://(www\.)?soundcloud\.com/.*', 'i'),
36
+ new RegExp('https?://(www\.)?slideshare\.net/*', 'i'),
37
+ new RegExp('http://instagr(\.am|am\.com)/p/.*', 'i'),
38
+ new RegExp('https?://(www\.)?rdio\.com/.*', 'i'),
39
+ new RegExp('https?://rd\.io/x/.*', 'i'),
40
+ new RegExp('https?://(open|play)\.spotify\.com/.*', 'i')
41
+ ];
42
+
43
+ event.content = event.content.replace( /<p>(https?:\/\/[^<> "]+?)<\/p>/ig, function( all, match ) {
44
+ for( var i in regex ) {
45
+ if ( regex[i].test( match ) ) {
46
+ return '\n' + match + '\n';
47
+ }
48
+ }
49
+ return all;
50
+ })
51
+ .replace( /caption\]\[caption/g, 'caption] [caption' )
52
+ .replace( /<(object|audio|video)[\s\S]+?<\/\1>/g, function( match ) {
53
+ return match.replace( /[\r\n]+/g, ' ' );
54
+ }).replace( /<pre[^>]*>[\s\S]+?<\/pre>/g, function( match ) {
55
+ match = match.replace( /<br ?\/?>(\r\n|\n)?/g, '\n' );
56
+ return match.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '\n' );
57
+ });
58
+ });
59
+ }
60
+ });
61
+ });
mce/wptadv/plugin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ tinymce.PluginManager.add("wptadv",function(a){a.on("init",function(){a.formatter.register({valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}]}),!a.settings.wpautop&&a.settings.tadv_noautop&&a.on("SaveContent",function(a){var b=[new RegExp("https?://(www.)?youtube.com/watch.*","i"),new RegExp("http://youtu.be/*"),new RegExp("http://blip.tv/*"),new RegExp("https?://(www.)?vimeo.com/.*","i"),new RegExp("https?://(www.)?dailymotion.com/.*","i"),new RegExp("http://dai.ly/*"),new RegExp("https?://(www.)?flickr.com/.*","i"),new RegExp("http://flic.kr/*"),new RegExp("https?://(.+.)?smugmug.com/.*","i"),new RegExp("https?://(www.)?hulu.com/watch/.*","i"),new RegExp("https?://(www.)?viddler.com/.*","i"),new RegExp("http://qik.com/*"),new RegExp("http://revision3.com/*"),new RegExp("http://i*.photobucket.com/albums/*"),new RegExp("http://gi*.photobucket.com/groups/*"),new RegExp("https?://(www.)?scribd.com/.*","i"),new RegExp("http://wordpress.tv/*"),new RegExp("https?://(.+.)?polldaddy.com/.*","i"),new RegExp("https?://(www.)?funnyordie.com/videos/.*","i"),new RegExp("https?://(www.)?twitter.com/.+?/status(es)?/.*","i"),new RegExp("https?://(www.)?soundcloud.com/.*","i"),new RegExp("https?://(www.)?slideshare.net/*","i"),new RegExp("http://instagr(.am|am.com)/p/.*","i"),new RegExp("https?://(www.)?rdio.com/.*","i"),new RegExp("https?://rd.io/x/.*","i"),new RegExp("https?://(open|play).spotify.com/.*","i")];a.content=a.content.replace(/<p>(https?:\/\/[^<> "]+?)<\/p>/gi,function(a,c){for(var d in b)if(b[d].test(c))return"\n"+c+"\n";return a}).replace(/caption\]\[caption/g,"caption] [caption").replace(/<(object|audio|video)[\s\S]+?<\/\1>/g,function(a){return a.replace(/[\r\n]+/g," ")}).replace(/<pre[^>]*>[\s\S]+?<\/pre>/g,function(a){return a=a.replace(/<br ?\/?>(\r\n|\n)?/g,"\n"),a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"\n")})})})});
readme.txt CHANGED
@@ -11,14 +11,14 @@ Enables the advanced features of TinyMCE, the WordPress WYSIWYG editor.
11
  == Description ==
12
 
13
  This plugin will let you add, remove and arrange the buttons that are shown on the Visual Editor toolbar.
14
- It includes 14 plugins for [TinyMCE](http://tinymce.com/) that are automatically enabled or disabled depending on what buttons are chosen.
15
 
16
  = Some of the features added by this plugin =
17
 
18
  * Support for creating and editing tables.
19
  * More options when inserting lists.
20
  * Search and Replace in the editor.
21
- * Abitity to set Font Family and Font Size.
22
  * And many others.
23
 
24
  With this plugin you will also be able to enable the TinyMCE menu. It is a convenient way to access a lot of features that are not used frequently.
@@ -29,6 +29,13 @@ Best is to install directly from WordPress. If manual installation is required,
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
 
 
32
  = 4.0.1 =
33
  Fix warnings on pages other than Edit Post. Update the description.
34
 
@@ -57,7 +64,7 @@ Updated for WordPress 3.3 or later and TinyMCE 3.4.5.
57
  Fix the removal of the *media* plugin so it does not require re-saving the settings.
58
 
59
  = 3.4.2 =
60
- Compatibility with WordPress 3.2 and TinyMCE 3.4.2, removed the options for suport for iframe and HTML 5.0 elements as they are supported by default in WordPress 3.2, removed the *media* plugin as it is included by default.
61
 
62
  = 3.3.9.1 =
63
  Added advanced options: stop removing iframes, stop removing HTML 5.0 elements, moved the support for custom editor styles to editor-style.css in the current theme.
@@ -77,7 +84,7 @@ Compatibility with WordPress 2.8 and TinyMCE 3.2.4, minor bug fixes.
77
  Compatibility with WordPress 2.7 and TinyMCE 3.2, minor bug fixes.
78
 
79
  = 3.1 =
80
- Compatibility with WordPress 2.6 and TinyMCE 3.1, keeps empty paragrarhs when disabling the removal of P and BR tags, the buttons for MCImageManager and MCFileManager can be arranged (if installed).
81
 
82
  = 3.0.1 =
83
  Compatibility with WordPress 2.5.1 and TinyMCE 3.0.7, added option to disable the removal of P and BR tags when saving and in the HTML editor (autop), added two more buttons to the HTML editor: autop and undo, fixed the removal of non-default TinyMCE buttons.
@@ -94,6 +101,10 @@ Improved language selection, improved compatibility with WordPress 2.3 and TinyM
94
  = 2.0 =
95
  Includes an admin page for arranging the TinyMCE toolbar buttons, easy installation, a lot of bugfixes, customized "Smilies" plugin that uses the built-in WordPress smilies, etc. The admin page uses jQuery and jQuery UI that lets you "drag and drop" the TinyMCE buttons to arrange your own toolbars and enables/disables the corresponding plugins depending on the used buttons.
96
 
 
 
 
 
97
 
98
  == Frequently Asked Questions ==
99
 
11
  == Description ==
12
 
13
  This plugin will let you add, remove and arrange the buttons that are shown on the Visual Editor toolbar.
14
+ It includes 15 plugins for [TinyMCE](http://tinymce.com/) that are automatically enabled or disabled depending on what buttons are chosen.
15
 
16
  = Some of the features added by this plugin =
17
 
18
  * Support for creating and editing tables.
19
  * More options when inserting lists.
20
  * Search and Replace in the editor.
21
+ * Ability to set Font Family and Font Size.
22
  * And many others.
23
 
24
  With this plugin you will also be able to enable the TinyMCE menu. It is a convenient way to access a lot of features that are not used frequently.
29
 
30
  == Changelog ==
31
 
32
+ = 4.0.2 =
33
+ * Fix showing of the second, third and forth button rows when the Toolbar Toggle button is not used.
34
+ * Fix adding the ''directionality'' plugin when RTL or LTR button is selected.
35
+ * Show the ''Advanced Options'' to super admins on multisite installs.
36
+ * Add the ''link'' plugin including link rel setting. Replaces the Insert/Edit Link dialog when enabled.
37
+ * Include updated ''table'' plugin that has support for vertical align for cells.
38
+
39
  = 4.0.1 =
40
  Fix warnings on pages other than Edit Post. Update the description.
41
 
64
  Fix the removal of the *media* plugin so it does not require re-saving the settings.
65
 
66
  = 3.4.2 =
67
+ Compatibility with WordPress 3.2 and TinyMCE 3.4.2, removed the options for support for iframe and HTML 5.0 elements as they are supported by default in WordPress 3.2, removed the *media* plugin as it is included by default.
68
 
69
  = 3.3.9.1 =
70
  Added advanced options: stop removing iframes, stop removing HTML 5.0 elements, moved the support for custom editor styles to editor-style.css in the current theme.
84
  Compatibility with WordPress 2.7 and TinyMCE 3.2, minor bug fixes.
85
 
86
  = 3.1 =
87
+ Compatibility with WordPress 2.6 and TinyMCE 3.1, keeps empty paragraphs when disabling the removal of P and BR tags, the buttons for MCImageManager and MCFileManager can be arranged (if installed).
88
 
89
  = 3.0.1 =
90
  Compatibility with WordPress 2.5.1 and TinyMCE 3.0.7, added option to disable the removal of P and BR tags when saving and in the HTML editor (autop), added two more buttons to the HTML editor: autop and undo, fixed the removal of non-default TinyMCE buttons.
101
  = 2.0 =
102
  Includes an admin page for arranging the TinyMCE toolbar buttons, easy installation, a lot of bugfixes, customized "Smilies" plugin that uses the built-in WordPress smilies, etc. The admin page uses jQuery and jQuery UI that lets you "drag and drop" the TinyMCE buttons to arrange your own toolbars and enables/disables the corresponding plugins depending on the used buttons.
103
 
104
+ == Upgrade Notice ==
105
+
106
+ = 4.0.2 =
107
+ Fixes for showing of all toolbars, advanced options for superadmins, vertical align for table cells, and more.
108
 
109
  == Frequently Asked Questions ==
110
 
tadv_admin.php CHANGED
@@ -12,19 +12,6 @@ if ( ! current_user_can( 'manage_options' ) ) {
12
  $message = '';
13
 
14
  // TODO admin || SA
15
- if ( isset( $_POST['tadv_uninstall'] ) ) {
16
- check_admin_referer( 'tadv-uninstall' );
17
- $this->remove_settings(true);
18
-
19
- ?>
20
- <div class="updated" style="margin-top:30px;">
21
- <p><?php _e( 'All options have been removed from the database. You can', 'tadv'); ?> <a href="plugins.php"><?php _e('deactivate TinyMCE Advanced', 'tadv'); ?></a> <?php _e('or', 'tadv'); ?> <a href=""> <?php _e('reload this page', 'tadv'); ?></a> <?php _e('to reset them to the default values.', 'tadv'); ?></p>
22
- </div>
23
- <?php
24
-
25
- return;
26
- }
27
-
28
  if ( ! $this->check_minimum_supported_version() ) {
29
  ?>
30
  <div class="error" style="margin-top:30px;">
@@ -45,7 +32,15 @@ if ( isset( $_POST['tadv-save'] ) ) {
45
 
46
  // User settings
47
  for ( $i = 1; $i < 5; $i++ ) {
48
- $buttons = $this->parse_buttons( 'tb' . $i );
 
 
 
 
 
 
 
 
49
  // Layer plugin buttons??
50
  $buttons = str_replace( 'insertlayer', 'insertlayer,moveforward,movebackward,absolute', $buttons );
51
  $settings['toolbar_' . $i] = $buttons;
@@ -59,6 +54,10 @@ if ( isset( $_POST['tadv-save'] ) ) {
59
  $options_array[] = 'contextmenu';
60
  }
61
 
 
 
 
 
62
  if ( ! empty( $_POST['menubar'] ) ) {
63
  $options_array[] = 'menubar';
64
  $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace', 'table', 'visualblocks', 'visualchars' );
@@ -94,12 +93,21 @@ if ( isset( $_POST['tadv-save'] ) ) {
94
 
95
  // User options
96
  // TODO allow editors, authors and contributors some access
 
 
 
 
 
 
 
 
97
  $settings['options'] = implode( ',', $options_array );
98
  $this->settings = $settings;
99
  $this->load_settings();
100
 
101
  // Merge the submitted plugins and from the buttons
102
  $settings['plugins'] = implode( ',', $this->get_plugins( $plugins_array ) );
 
103
  $this->plugins = $settings['plugins'];
104
 
105
  // Save the new settings
@@ -275,15 +283,13 @@ for ( $i = 1; $i < 5; $i++ ) {
275
  if ( strpos( $name, '<!' ) === 0 )
276
  $name = '';
277
 
278
- ?>
279
- <li class="tadvmodule" id="<?php echo $button; ?>">
280
  <div class="tadvitem">
281
  <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
282
  <span class="descr"> <?php echo $name; ?></span>
283
  <input type="hidden" class="tadv-button" name="tb<?php echo $i; ?>[]" value="<?php echo $button; ?>" />
284
  </div>
285
- </li>
286
- <?php
287
 
288
  }
289
 
@@ -295,14 +301,11 @@ for ( $i = 1; $i < 5; $i++ ) {
295
  ?>
296
  </div>
297
 
298
- <p><?php _e('Drag and drop buttons onto the toolbars above, or drag the buttons to rearrange them.', 'tadv'); ?></p>
299
- <!--
300
- <div id="length-error-message" class="tadv-error">
301
- <?php _e('Adding too many buttons will make the toolbar too long and will not display correctly in TinyMCE!', 'tadv'); ?>
302
- </div>
303
- -->
304
  <div id="unuseddiv">
305
- <ul id="unused">
 
306
  <?php
307
 
308
  foreach( $all_buttons as $button => $name ) {
@@ -335,58 +338,63 @@ foreach( $all_buttons as $button => $name ) {
335
  </label>
336
 
337
  <label>
338
- <input type="checkbox" name="contextmenu" id="contextmenu" <?php if ( $this->check_setting('contextmenu') ) echo ' checked="checked"'; ?> />
339
  <?php _e('Context Menu', 'tadv'); ?>
340
  </label>
 
 
 
 
 
341
  </p>
342
 
343
  <?php
344
 
345
- if ( ! is_multisite() && current_user_can( 'manage_options' ) ) {
346
 
347
  ?>
348
  <div class="advanced-options">
349
  <h3><?php _e('Advanced Options', 'tadv'); ?></h3>
350
  <?php
351
 
352
- if ( ! current_theme_supports( 'editor-style' ) ) {
353
 
354
  ?>
355
- <p><?php
356
- _e('It seems your theme doesn\'t support customised styles for the editor. ', 'tadv');
357
- _e('You can create a CSS file named <code>editor-style.css</code> and upload it to your theme\'s directory. ', 'tadv');
358
- _e('After that, enable this setting.', 'tadv');
359
- ?></p>
360
-
361
- <p>
362
- <label><input type="checkbox" name="editorstyle" id="editorstyle" <?php if ( $this->check_setting( 'editorstyle', true ) ) echo ' checked="checked"'; ?> />
363
  <?php _e('Import editor-style.css.', 'tadv'); ?></label>
364
- </p>
 
 
 
 
 
365
  <?php
366
  }
367
 
368
  ?>
369
- <p>
370
- <label><input type="checkbox" name="importcss" id="importcss" <?php if ( $this->check_setting( 'importcss', true ) ) echo ' checked="checked"'; ?> />
371
- <?php _e('Load the CSS classes used in editor-style.css and replace the Styles sub-menu.', 'tadv'); ?></label>
372
- </p>
373
 
374
- <p>
375
- <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_setting( 'no_autop', true ) ) echo ' checked="checked"'; ?> />
376
  <?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the Text editor', 'tadv'); ?></label>
377
- <br>
378
- <?php
379
  _e('This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. ', 'tadv');
380
  _e('However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. ', 'tadv');
381
  _e('Line breaks in the HTML editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tadv');
382
- ?>
383
- </p>
384
-
385
- <p>
386
- <button class="button" type="button" id="tadv-remove-settings"><?php _e('Remove Settings', 'tadv'); ?></button>
387
- <input type="submit" class="button" name="tadv-export-settings" value="<?php _e( 'Export Settings', 'tadv' ); ?>" />
 
 
388
  <input type="submit" class="button" name="tadv-import-settings" value="<?php _e( 'Import Settings', 'tadv' ); ?>" />
389
- </p>
390
  </div>
391
  <?php
392
 
@@ -403,14 +411,4 @@ if ( ! is_multisite() && current_user_can( 'manage_options' ) ) {
403
  <div id="wp-adv-error-message" class="tadv-error">
404
  <?php _e('The "Toolbar toggle" button shows/hides the second, third, and forth button rows. It will only work when it is in the first row and there are buttons in the second row.', 'tadv'); ?>
405
  </div>
406
-
407
- <div id="tadv-confirm-uninstall" style="">
408
- <form method="post" action="">
409
- <?php wp_nonce_field('tadv-uninstall'); ?>
410
- <div><?php _e('Remove all settings from the database?', 'tadv'); ?>
411
- <input class="button" type="button" id="tadv-cancel" value="<?php _e('Cancel', 'tadv'); ?>" />
412
- <input class="button" type="submit" name="tadv_uninstall" value="<?php _e('Continue', 'tadv'); ?>" />
413
- </div>
414
- </form>
415
- </div>
416
- </div>
12
  $message = '';
13
 
14
  // TODO admin || SA
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  if ( ! $this->check_minimum_supported_version() ) {
16
  ?>
17
  <div class="error" style="margin-top:30px;">
32
 
33
  // User settings
34
  for ( $i = 1; $i < 5; $i++ ) {
35
+ $tb = 'tb' . $i;
36
+
37
+ if ( $i > 1 && ! empty( $_POST[$tb] ) && is_array( $_POST[$tb] ) &&
38
+ ( $wp_adv = array_search( 'wp_adv', $_POST[$tb] ) ) !== false ) {
39
+ // Remove the "Toolbar toggle" button from row 2, 3 or 4.
40
+ unset( $_POST[$tb][$wp_adv] );
41
+ }
42
+
43
+ $buttons = $this->parse_buttons( $tb );
44
  // Layer plugin buttons??
45
  $buttons = str_replace( 'insertlayer', 'insertlayer,moveforward,movebackward,absolute', $buttons );
46
  $settings['toolbar_' . $i] = $buttons;
54
  $options_array[] = 'contextmenu';
55
  }
56
 
57
+ if ( ! empty( $_POST['advlink'] ) ) {
58
+ $options_array[] = 'advlink';
59
+ }
60
+
61
  if ( ! empty( $_POST['menubar'] ) ) {
62
  $options_array[] = 'menubar';
63
  $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace', 'table', 'visualblocks', 'visualchars' );
93
 
94
  // User options
95
  // TODO allow editors, authors and contributors some access
96
+ $this->settings = $settings;
97
+ $this->load_settings();
98
+
99
+ // Special case
100
+ if ( in_array( 'image', $this->used_buttons, true ) ) {
101
+ $options_array[] = 'image';
102
+ }
103
+
104
  $settings['options'] = implode( ',', $options_array );
105
  $this->settings = $settings;
106
  $this->load_settings();
107
 
108
  // Merge the submitted plugins and from the buttons
109
  $settings['plugins'] = implode( ',', $this->get_plugins( $plugins_array ) );
110
+ $this->settings = $settings;
111
  $this->plugins = $settings['plugins'];
112
 
113
  // Save the new settings
283
  if ( strpos( $name, '<!' ) === 0 )
284
  $name = '';
285
 
286
+ ?><li class="tadvmodule" id="<?php echo $button; ?>">
 
287
  <div class="tadvitem">
288
  <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
289
  <span class="descr"> <?php echo $name; ?></span>
290
  <input type="hidden" class="tadv-button" name="tb<?php echo $i; ?>[]" value="<?php echo $button; ?>" />
291
  </div>
292
+ </li><?php
 
293
 
294
  }
295
 
301
  ?>
302
  </div>
303
 
304
+ <p><?php _e('Drag buttons from the unused buttons below and drop them in the toolbars above, or drag the buttons in the toolbars to rearrange them.', 'tadv'); ?></p>
305
+
 
 
 
 
306
  <div id="unuseddiv">
307
+ <h3><?php _e('Unused Buttons', 'tadv'); ?></h3>
308
+ <ul id="unused" class="container">
309
  <?php
310
 
311
  foreach( $all_buttons as $button => $name ) {
338
  </label>
339
 
340
  <label>
341
+ <input type="checkbox" name="contextmenu" id="contextmenu" <?php if ( $this->check_setting('contextmenu') ) echo ' checked="checked"'; ?> />
342
  <?php _e('Context Menu', 'tadv'); ?>
343
  </label>
344
+
345
+ <label>
346
+ <input type="checkbox" name="advlink" id="advlink" <?php if ( $this->check_setting('advlink') ) echo ' checked="checked"'; ?> />
347
+ <?php _e('Link (replaces the Insert/Edit Link dialog)', 'tadv'); ?>
348
+ </label>
349
  </p>
350
 
351
  <?php
352
 
353
+ if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
354
 
355
  ?>
356
  <div class="advanced-options">
357
  <h3><?php _e('Advanced Options', 'tadv'); ?></h3>
358
  <?php
359
 
360
+ if ( ! is_multisite() && ! current_theme_supports( 'editor-style' ) ) {
361
 
362
  ?>
363
+ <div>
364
+ <label><input type="checkbox" name="editorstyle" id="editorstyle" <?php if ( $this->check_admin_setting( 'editorstyle' ) ) echo ' checked="checked"'; ?> />
 
 
 
 
 
 
365
  <?php _e('Import editor-style.css.', 'tadv'); ?></label>
366
+ <p><?php
367
+ _e('It seems your theme doesn\'t support customised styles for the editor. ', 'tadv');
368
+ _e('You can create a CSS file named <code>editor-style.css</code> and upload it to your theme\'s directory. ', 'tadv');
369
+ _e('After that, enable this setting.', 'tadv');
370
+ ?></p>
371
+ </div>
372
  <?php
373
  }
374
 
375
  ?>
376
+ <div>
377
+ <label><input type="checkbox" name="importcss" id="importcss" <?php if ( $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; ?> />
378
+ <?php _e('Load the CSS classes used in editor-style.css and replace the Formats button and sub-menu.', 'tadv'); ?></label>
379
+ </div>
380
 
381
+ <div>
382
+ <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
383
  <?php _e('Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the Text editor', 'tadv'); ?></label>
384
+ <p><?php
 
385
  _e('This will make it possible to use more advanced coding in the HTML editor without the back-end filtering affecting it much. ', 'tadv');
386
  _e('However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently. ', 'tadv');
387
  _e('Line breaks in the HTML editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tadv');
388
+ ?></p>
389
+ </div>
390
+ </div>
391
+
392
+ <div class="advanced-options">
393
+ <h3><?php _e('Administration', 'tadv'); ?></h3>
394
+ <div>
395
+ <input type="submit" class="button" name="tadv-export-settings" value="<?php _e( 'Export Settings', 'tadv' ); ?>" /> &nbsp;
396
  <input type="submit" class="button" name="tadv-import-settings" value="<?php _e( 'Import Settings', 'tadv' ); ?>" />
397
+ </div>
398
  </div>
399
  <?php
400
 
411
  <div id="wp-adv-error-message" class="tadv-error">
412
  <?php _e('The "Toolbar toggle" button shows/hides the second, third, and forth button rows. It will only work when it is in the first row and there are buttons in the second row.', 'tadv'); ?>
413
  </div>
414
+ </div><!-- /wrap -->
 
 
 
 
 
 
 
 
 
 
tinymce-advanced.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
- Version: 4.0.1
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
9
 
@@ -29,10 +29,10 @@ class Tinymce_Advanced {
29
  private $toolbar_2;
30
  private $toolbar_3;
31
  private $toolbar_4;
32
- private $used_buttons;
33
- private $all_buttons;
34
- private $buttons_filter;
35
- private $all_plugins = array( 'advlist','anchor','code','contextmenu','emoticons','importcss','insertdatetime','nonbreaking','print','searchreplace','table','visualblocks','visualchars' );
36
 
37
  private $default_settings = array(
38
  'options' => 'menubar,advlist',
@@ -58,15 +58,15 @@ class Tinymce_Advanced {
58
  return;
59
  }
60
 
61
- add_filter( 'mce_buttons', array( &$this, 'mce_buttons_1' ), 999 );
62
  add_filter( 'mce_buttons_2', array( &$this, 'mce_buttons_2' ), 999 );
63
  add_filter( 'mce_buttons_3', array( &$this, 'mce_buttons_3' ), 999 );
64
  add_filter( 'mce_buttons_4', array( &$this, 'mce_buttons_4' ), 999 );
65
 
66
  add_filter( 'tiny_mce_before_init', array( &$this, 'mce_options' ) );
67
  add_filter( 'htmledit_pre', array( &$this, 'htmledit' ), 999 );
68
- add_action( 'after_wp_tiny_mce', array( &$this, 'tmce_replace' ) );
69
- add_filter( 'mce_external_plugins', array( &$this, 'load_plugins' ), 999 );
70
  }
71
 
72
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
@@ -280,7 +280,10 @@ class Tinymce_Advanced {
280
  if ( $this->check_setting( 'advlist' ) )
281
  $plugins[] = 'advlist';
282
 
283
- if ( $this->check_setting( 'importcss', true ) )
 
 
 
284
  $plugins[] = 'importcss';
285
 
286
  if ( $this->check_setting( 'contextmenu' ) )
@@ -301,77 +304,98 @@ class Tinymce_Advanced {
301
  return in_array( $setting, $array, true );
302
  }
303
 
304
- function mce_buttons_1($orig) {
 
 
 
 
305
  if ( ! is_array( $this->options ) ) {
306
  $this->load_settings();
307
  }
308
 
309
  $buttons_1 = $this->toolbar_1;
310
 
311
- if ( is_array($orig) && ! empty($orig) ) {
312
- $orig = array_diff( $orig, $this->buttons_filter );
313
- $buttons_1 = array_merge( $buttons_1, $orig );
 
 
 
 
314
  }
315
 
316
  return $buttons_1;
317
  }
318
 
319
- function mce_buttons_2($orig) {
320
  if ( ! is_array( $this->options ) ) {
321
  $this->load_settings();
322
  }
323
 
324
  $buttons_2 = $this->toolbar_2;
325
 
326
- if ( is_array($orig) && ! empty($orig) ) {
327
- $orig = array_diff( $orig, $this->buttons_filter );
328
- $buttons_2 = array_merge( $buttons_2, $orig );
329
  }
330
 
331
  return $buttons_2;
332
  }
333
 
334
- function mce_buttons_3($orig) {
335
  if ( ! is_array( $this->options ) ) {
336
  $this->load_settings();
337
  }
338
 
339
  $buttons_3 = $this->toolbar_3;
340
 
341
- if ( is_array($orig) && ! empty($orig) ) {
342
- $orig = array_diff( $orig, $this->buttons_filter );
343
- $buttons_3 = array_merge( $buttons_3, $orig );
344
  }
345
 
346
  return $buttons_3;
347
  }
348
 
349
- function mce_buttons_4($orig) {
350
  if ( ! is_array( $this->options ) ) {
351
  $this->load_settings();
352
  }
353
 
354
  $buttons_4 = $this->toolbar_4;
355
 
356
- if ( is_array($orig) && ! empty($orig) ) {
357
- $orig = array_diff( $orig, $this->buttons_filter );
358
- $buttons_4 = array_merge( $buttons_4, $orig );
359
  }
360
 
361
  return $buttons_4;
362
  }
363
 
364
  function mce_options( $init ) {
365
- if ( $this->check_setting( 'no_autop', true ) ) {
366
- // $init['wpautop'] = false;
367
  $init['indent'] = true;
 
368
  }
369
 
370
  if ( $this->check_setting('menubar') ) {
371
  $init['menubar'] = true;
372
  }
373
 
374
- if ( $this->check_setting( 'importcss', true ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
375
  // $init['importcss_selector_filter'] = 'function(sel){return /^\.[a-z0-9]+$/i.test(sel);}';
376
  $init['importcss_file_filter'] = 'editor-style.css';
377
  }
@@ -380,7 +404,7 @@ class Tinymce_Advanced {
380
  }
381
 
382
  function htmledit( $c ) {
383
- if ( $this->check_setting( 'no_autop', true ) ) {
384
  $c = str_replace( array('&amp;', '&lt;', '&gt;'), array('&', '<', '>'), $c );
385
  $c = wpautop( $c );
386
  $c = preg_replace( '/^<p>(https?:\/\/[^<> "]+?)<\/p>$/im', '$1', $c );
@@ -389,76 +413,18 @@ class Tinymce_Advanced {
389
  return $c;
390
  }
391
 
392
- function tmce_replace( $mce_settings ) {
393
- if ( empty( $mce_settings ) || ! $this->check_setting( 'no_autop', true ) ) {
394
- return;
395
- }
396
-
397
- ?>
398
- <script type="text/javascript">
399
- if ( typeof(jQuery) != 'undefined' ) {
400
- jQuery('body').on( 'afterPreWpautop', function( event, obj ) {
401
- var regex = [
402
- new RegExp('https?://(www\.)?youtube\.com/watch.*', 'i'),
403
- new RegExp('http://youtu.be/*'),
404
- new RegExp('http://blip.tv/*'),
405
- new RegExp('https?://(www\.)?vimeo\.com/.*', 'i'),
406
- new RegExp('https?://(www\.)?dailymotion\.com/.*', 'i'),
407
- new RegExp('http://dai.ly/*'),
408
- new RegExp('https?://(www\.)?flickr\.com/.*', 'i'),
409
- new RegExp('http://flic.kr/*'),
410
- new RegExp('https?://(.+\.)?smugmug\.com/.*', 'i'),
411
- new RegExp('https?://(www\.)?hulu\.com/watch/.*', 'i'),
412
- new RegExp('https?://(www\.)?viddler\.com/.*', 'i'),
413
- new RegExp('http://qik.com/*'),
414
- new RegExp('http://revision3.com/*'),
415
- new RegExp('http://i*.photobucket.com/albums/*'),
416
- new RegExp('http://gi*.photobucket.com/groups/*'),
417
- new RegExp('https?://(www\.)?scribd\.com/.*', 'i'),
418
- new RegExp('http://wordpress.tv/*'),
419
- new RegExp('https?://(.+\.)?polldaddy\.com/.*', 'i'),
420
- new RegExp('https?://(www\.)?funnyordie\.com/videos/.*', 'i'),
421
- new RegExp('https?://(www\.)?twitter\.com/.+?/status(es)?/.*', 'i'),
422
- new RegExp('https?://(www\.)?soundcloud\.com/.*', 'i'),
423
- new RegExp('https?://(www\.)?slideshare\.net/*', 'i'),
424
- new RegExp('http://instagr(\.am|am\.com)/p/.*', 'i'),
425
- new RegExp('https?://(www\.)?rdio\.com/.*', 'i'),
426
- new RegExp('https?://rd\.io/x/.*', 'i'),
427
- new RegExp('https?://(open|play)\.spotify\.com/.*', 'i')
428
- ];
429
-
430
- obj.data = obj.unfiltered
431
- .replace(/<p>(https?:\/\/[^<> "]+?)<\/p>/ig, function( all, match ) {
432
- for( var i in regex ) {
433
- if ( regex[i].test( match ) ) {
434
- return '\n' + match + '\n';
435
- }
436
- }
437
- return all;
438
- })
439
- .replace(/caption\]\[caption/g, 'caption] [caption')
440
- .replace(/<object[\s\S]+?<\/object>/g, function(a) {
441
- return a.replace(/[\r\n]+/g, ' ');
442
- }).replace( /<pre[^>]*>[\s\S]+?<\/pre>/g, function( match ) {
443
- match = match.replace( /<br ?\/?>(\r\n|\n)?/g, '\n' );
444
- return match.replace( /<\/?p( [^>]*)?>(\r\n|\n)?/g, '\n' );
445
- });
446
- }).on( 'afterWpautop', function( event, obj ) {
447
- obj.data = obj.unfiltered;
448
- });
449
- }
450
- </script>
451
- <?php
452
- }
453
-
454
- function load_plugins( $mce_plugins ) {
455
  // import user created editor-style.css
456
- if ( $this->check_setting( 'editorstyle', true ) ) {
457
  add_editor_style();
458
  }
459
 
460
- if ( empty( $this->plugins ) || ! is_array( $this->plugins ) ) {
461
- return $mce_plugins;
 
 
 
 
462
  }
463
 
464
  $plugpath = TADV_URL . 'mce/';
@@ -472,6 +438,29 @@ class Tinymce_Advanced {
472
  return $mce_plugins;
473
  }
474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  private function parse_buttons( $toolbar_id = false, $buttons = false ) {
476
  if ( $toolbar_id && ! $buttons && ! empty( $_POST[$toolbar_id] ) )
477
  $buttons = $_POST[$toolbar_id];
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
+ Version: 4.0.2
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
9
 
29
  private $toolbar_2;
30
  private $toolbar_3;
31
  private $toolbar_4;
32
+ private $used_buttons = array();
33
+ private $all_buttons = array();
34
+ private $buttons_filter = array();
35
+ private $all_plugins = array( 'advlist','anchor','code','contextmenu','emoticons','importcss','insertdatetime','nonbreaking','print','searchreplace','table','visualblocks','visualchars','link' );
36
 
37
  private $default_settings = array(
38
  'options' => 'menubar,advlist',
58
  return;
59
  }
60
 
61
+ add_filter( 'mce_buttons', array( &$this, 'mce_buttons_1' ), 999, 2 );
62
  add_filter( 'mce_buttons_2', array( &$this, 'mce_buttons_2' ), 999 );
63
  add_filter( 'mce_buttons_3', array( &$this, 'mce_buttons_3' ), 999 );
64
  add_filter( 'mce_buttons_4', array( &$this, 'mce_buttons_4' ), 999 );
65
 
66
  add_filter( 'tiny_mce_before_init', array( &$this, 'mce_options' ) );
67
  add_filter( 'htmledit_pre', array( &$this, 'htmledit' ), 999 );
68
+ add_filter( 'mce_external_plugins', array( &$this, 'mce_external_plugins' ), 999 );
69
+ add_filter( 'tiny_mce_plugins', array( &$this, 'tiny_mce_plugins' ), 999 );
70
  }
71
 
72
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
280
  if ( $this->check_setting( 'advlist' ) )
281
  $plugins[] = 'advlist';
282
 
283
+ if ( $this->check_setting( 'advlink' ) )
284
+ $plugins[] = 'link';
285
+
286
+ if ( $this->check_admin_setting( 'importcss' ) )
287
  $plugins[] = 'importcss';
288
 
289
  if ( $this->check_setting( 'contextmenu' ) )
304
  return in_array( $setting, $array, true );
305
  }
306
 
307
+ private function check_admin_setting( $setting ) {
308
+ return $this->check_setting( $setting, true );
309
+ }
310
+
311
+ function mce_buttons_1( $original, $editor_id ) {
312
  if ( ! is_array( $this->options ) ) {
313
  $this->load_settings();
314
  }
315
 
316
  $buttons_1 = $this->toolbar_1;
317
 
318
+ if ( 'content' === $editor_id && ! in_array( 'wp_adv', $buttons_1, true ) ) {
319
+ add_action( 'wp_enqueue_editor', array( &$this, 'wp_enqueue_editor' ) );
320
+ }
321
+
322
+ if ( is_array( $original ) && ! empty( $original ) ) {
323
+ $original = array_diff( $original, $this->buttons_filter );
324
+ $buttons_1 = array_merge( $buttons_1, $original );
325
  }
326
 
327
  return $buttons_1;
328
  }
329
 
330
+ function mce_buttons_2( $original ) {
331
  if ( ! is_array( $this->options ) ) {
332
  $this->load_settings();
333
  }
334
 
335
  $buttons_2 = $this->toolbar_2;
336
 
337
+ if ( is_array( $original ) && ! empty( $original ) ) {
338
+ $original = array_diff( $original, $this->buttons_filter );
339
+ $buttons_2 = array_merge( $buttons_2, $original );
340
  }
341
 
342
  return $buttons_2;
343
  }
344
 
345
+ function mce_buttons_3( $original ) {
346
  if ( ! is_array( $this->options ) ) {
347
  $this->load_settings();
348
  }
349
 
350
  $buttons_3 = $this->toolbar_3;
351
 
352
+ if ( is_array( $original ) && ! empty( $original ) ) {
353
+ $original = array_diff( $original, $this->buttons_filter );
354
+ $buttons_3 = array_merge( $buttons_3, $original );
355
  }
356
 
357
  return $buttons_3;
358
  }
359
 
360
+ function mce_buttons_4( $original ) {
361
  if ( ! is_array( $this->options ) ) {
362
  $this->load_settings();
363
  }
364
 
365
  $buttons_4 = $this->toolbar_4;
366
 
367
+ if ( is_array( $original ) && ! empty( $original ) ) {
368
+ $original = array_diff( $original, $this->buttons_filter );
369
+ $buttons_4 = array_merge( $buttons_4, $original );
370
  }
371
 
372
  return $buttons_4;
373
  }
374
 
375
  function mce_options( $init ) {
376
+ if ( $this->check_admin_setting( 'no_autop' ) ) {
377
+ $init['wpautop'] = false;
378
  $init['indent'] = true;
379
+ $init['tadv_noautop'] = true;
380
  }
381
 
382
  if ( $this->check_setting('menubar') ) {
383
  $init['menubar'] = true;
384
  }
385
 
386
+ if ( $this->check_setting('image') ) {
387
+ $init['image_advtab'] = true;
388
+ }
389
+
390
+ if ( $this->check_setting( 'advlink' ) ) {
391
+ $init['rel_list'] = '[{text: "None", value: ""}, {text: "Nofollow", value: "nofollow"}]';
392
+ }
393
+
394
+ if ( ! in_array( 'wp_adv', $this->toolbar_1, true ) ) {
395
+ $init['wordpress_adv_hidden'] = false;
396
+ }
397
+
398
+ if ( $this->check_admin_setting( 'importcss' ) ) {
399
  // $init['importcss_selector_filter'] = 'function(sel){return /^\.[a-z0-9]+$/i.test(sel);}';
400
  $init['importcss_file_filter'] = 'editor-style.css';
401
  }
404
  }
405
 
406
  function htmledit( $c ) {
407
+ if ( $this->check_admin_setting( 'no_autop' ) ) {
408
  $c = str_replace( array('&amp;', '&lt;', '&gt;'), array('&', '<', '>'), $c );
409
  $c = wpautop( $c );
410
  $c = preg_replace( '/^<p>(https?:\/\/[^<> "]+?)<\/p>$/im', '$1', $c );
413
  return $c;
414
  }
415
 
416
+ function mce_external_plugins( $mce_plugins ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  // import user created editor-style.css
418
+ if ( $this->check_admin_setting( 'editorstyle' ) ) {
419
  add_editor_style();
420
  }
421
 
422
+ if ( ! is_array( $this->plugins ) ) {
423
+ $this->plugins = array();
424
+ }
425
+
426
+ if ( $this->check_admin_setting( 'no_autop' ) || in_array( 'table', $this->plugins, true ) ) {
427
+ $this->plugins[] = 'wptadv';
428
  }
429
 
430
  $plugpath = TADV_URL . 'mce/';
438
  return $mce_plugins;
439
  }
440
 
441
+ function tiny_mce_plugins( $plugins ) {
442
+ // This calls load_settings()
443
+ if ( $this->check_setting('image') && ! in_array( 'image', $plugins, true ) ) {
444
+ $plugins[] = 'image';
445
+ }
446
+
447
+ if ( ( in_array( 'rtl', $this->used_buttons, true ) || in_array( 'ltr', $this->used_buttons, true ) ) &&
448
+ ! in_array( 'directionality', (array) $plugins, true ) ) {
449
+
450
+ $plugins[] = 'directionality';
451
+ }
452
+
453
+ return $plugins;
454
+ }
455
+
456
+ function wp_enqueue_editor( $array ) {
457
+ if ( ! empty( $array['tinymce'] ) ) {
458
+ ?>
459
+ <script>if ( typeof setUserSetting !== 'undefined' ) setUserSetting( 'hidetb', '1' );</script>
460
+ <?php
461
+ }
462
+ }
463
+
464
  private function parse_buttons( $toolbar_id = false, $buttons = false ) {
465
  if ( $toolbar_id && ! $buttons && ! empty( $_POST[$toolbar_id] ) )
466
  $buttons = $_POST[$toolbar_id];
uninstall.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN ||
4
+ dirname( WP_UNINSTALL_PLUGIN ) != dirname( plugin_basename( __FILE__ ) ) ) {
5
+
6
+ exit;
7
+ }
8
+
9
+ delete_option( 'tadv_settings' );
10
+ delete_option( 'tadv_admin_settings' );
11
+ delete_option( 'tadv_version' );
12
+
13
+ // Delete old options
14
+ delete_option('tadv_options');
15
+ delete_option('tadv_toolbars');
16
+ delete_option('tadv_plugins');
17
+ delete_option('tadv_btns1');
18
+ delete_option('tadv_btns2');
19
+ delete_option('tadv_btns3');
20
+ delete_option('tadv_btns4');
21
+ delete_option('tadv_allbtns');