Black Studio TinyMCE Widget - Version 0.6.3

Version Description

  • Fixed Javascript issue preventing the plugin working correctly with some browsers
Download this release

Release Info

Developer marcochiesi
Plugin Icon 128x128 Black Studio TinyMCE Widget
Version 0.6.3
Comparing to
See all releases

Code changes from version 0.6.2 to 0.6.3

black-studio-tinymce-widget.js CHANGED
@@ -14,26 +14,44 @@ function black_studio_deactivate_visual_editor(id) {
14
}
15
}
16
}
17
- // Show editor (used upon opening the widget)
18
- function black_studio_deferred_show_visual_editor(id) {
19
jQuery('div.widget:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
20
- // If textarea is visible and animation has completed then trigger a click to Visual button and enable the editor
21
- if (typeof(tinyMCE.get(id)) != "object" && jQuery('div.widget:has(#' + id + ') :animated').size() == 0 && jQuery('#' + id).is(':visible')) {
22
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).click();
23
}
24
// Otherwise wait and retry later (animation ongoing)
25
- else {
26
- setTimeout(function(){black_studio_deferred_show_visual_editor(id);id=null;}, 100);
27
}
28
});
29
}
30
31
- var edCanvas;
32
jQuery(document).ready(function(){
33
// Event handler for widget opening button
34
jQuery('div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action').live('click', function(){
35
txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
36
- black_studio_deferred_show_visual_editor(txt_area.attr('id'));
37
return false;
38
});
39
// Event handler for widget saving button
@@ -43,9 +61,20 @@ jQuery(document).ready(function(){
43
if (typeof(editor) == "object") {
44
content = editor.getContent()
45
txt_area.val(content);
46
}
47
return true;
48
});
49
// Event handler for visual switch button
50
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]').live('click', function(){
51
jQuery(this).addClass('active');
14
}
15
}
16
}
17
+ // Activate editor deferred (used upon opening the widget)
18
+ function black_studio_open_deferred_activate_visual_editor(id) {
19
jQuery('div.widget:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
20
+ // If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
21
+ if (jQuery('div.widget:has(#' + id + ') :animated').size() == 0 && typeof(tinyMCE.get(id)) != "object" && jQuery('#' + id).is(':visible')) {
22
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).click();
23
}
24
// Otherwise wait and retry later (animation ongoing)
25
+ else if (typeof(tinyMCE.get(id)) != "object") {
26
+ setTimeout(function(){black_studio_open_deferred_activate_visual_editor(id);id=null;}, 100);
27
}
28
});
29
}
30
31
+ // Activate editor deferred (used upon ajax requests)
32
+ function black_studio_ajax_deferred_activate_visual_editor(id) {
33
+ jQuery('div.widget:has(#' + id + ') input[id^=widget-black-studio-tinymce][id$=type][value=visual]').each(function() {
34
+ // If textarea is visible and animation/ajax has completed then trigger a click to Visual button and enable the editor
35
+ if (jQuery.active == 0 && typeof(tinyMCE.get(id)) != "object" && jQuery('#' + id).is(':visible')) {
36
+ jQuery('a[id^=widget-black-studio-tinymce][id$=visual]', jQuery(this).parents('div.widget')).click();
37
+ }
38
+ // Otherwise wait and retry later (animation ongoing)
39
+ else if (jQuery('div.widget:has(#' + id + ') div.widget-inside').is(':visible') && typeof(tinyMCE.get(id)) != "object") {
40
+ setTimeout(function(){black_studio_ajax_deferred_activate_visual_editor(id);id=null;}, 100);
41
+ }
42
+ });
43
+ }
44
+
45
+
46
+ // This variable is necessary to handle media inserts into textarea (html mode)
47
+ var edCanvas;
48
+
49
+ // Document ready stuff
50
jQuery(document).ready(function(){
51
// Event handler for widget opening button
52
jQuery('div.widget:has(textarea[id^=widget-black-studio-tinymce]) a.widget-action').live('click', function(){
53
txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
54
+ black_studio_open_deferred_activate_visual_editor(txt_area.attr('id'));
55
return false;
56
});
57
// Event handler for widget saving button
61
if (typeof(editor) == "object") {
62
content = editor.getContent()
63
txt_area.val(content);
64
+ black_studio_deactivate_visual_editor(txt_area.attr('id'));
65
}
66
+ // Event handler for ajax complete
67
+ jQuery(this).unbind('ajaxSuccess').ajaxSuccess(function(event, xhr, settings) {
68
+ txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
69
+ black_studio_ajax_deferred_activate_visual_editor(txt_area.attr('id'));
70
+ });
71
return true;
72
});
73
+ // Event handler for ajax complete
74
+ //jQuery('input[id^=widget-black-studio-tinymce][id$=savewidget]').ajaxSuccess(function(event, xhr, settings) {
75
+ // txt_area = jQuery('textarea[id^=widget-black-studio-tinymce]', jQuery(this).parents('div.widget'));
76
+ // black_studio_ajax_deferred_activate_visual_editor(txt_area.attr('id'));
77
+ //});
78
// Event handler for visual switch button
79
jQuery('a[id^=widget-black-studio-tinymce][id$=visual]').live('click', function(){
80
jQuery(this).addClass('active');
black-studio-tinymce-widget.php CHANGED
@@ -3,12 +3,15 @@
3
Plugin Name: Black Studio TinyMCE Widget
4
Plugin URI: http://wordpress.org/extend/plugins/black-studio-tinymce-widget/
5
Description: Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
6
- Version: 0.6.2
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
10
*/
11
12
/* Widget class */
13
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
14
@@ -60,15 +63,6 @@ class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
60
<textarea class="widefat" rows="16" cols="40" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
61
</div>
62
<?php
63
- if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && $type == 'visual') {
64
- ?>
65
- <script type="text/javascript" language="javascript">
66
- /* <![CDATA[ */
67
- black_studio_activate_visual_editor('<?php echo $this->get_field_id('text'); ?>');
68
- /* ]]> */
69
- </script>
70
- <?php
71
- }
72
}
73
}
74
@@ -79,7 +73,7 @@ function black_studio_tinymce_load_tiny_mce() {
79
wp_tiny_mce(false, array());
80
}
81
82
- /* tinyMCE setup customization */
83
add_filter('tiny_mce_before_init', 'black_studio_tinymce_init_editor');
84
function black_studio_tinymce_init_editor($initArray) {
85
// Remove WP fullscreen mode and set the native tinyMCE fullscreen mode
@@ -108,9 +102,10 @@ function black_studio_tinymce_init() {
108
/* Widget js loading */
109
add_action("admin_print_scripts", "black_studio_tinymce_scripts");
110
function black_studio_tinymce_scripts() {
111
add_thickbox();
112
wp_enqueue_script('media-upload');
113
- wp_enqueue_script('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.js', __FILE__), array('jquery', 'editor', 'thickbox', 'media-upload'));
114
}
115
116
/* Widget css loading */
3
Plugin Name: Black Studio TinyMCE Widget
4
Plugin URI: http://wordpress.org/extend/plugins/black-studio-tinymce-widget/
5
Description: Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
6
+ Version: 0.6.3
7
Author: Black Studio
8
Author URI: http://www.blackstudio.it
9
License: GPL2
10
*/
11
12
+ global $black_studio_tinymce_widget_version;
13
+ $black_studio_tinymce_widget_version = "0.6.3";
14
+
15
/* Widget class */
16
class WP_Widget_Black_Studio_TinyMCE extends WP_Widget {
17
63
<textarea class="widefat" rows="16" cols="40" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
64
</div>
65
<?php
66
}
67
}
68
73
wp_tiny_mce(false, array());
74
}
75
76
+ /* TinyMCE setup customization */
77
add_filter('tiny_mce_before_init', 'black_studio_tinymce_init_editor');
78
function black_studio_tinymce_init_editor($initArray) {
79
// Remove WP fullscreen mode and set the native tinyMCE fullscreen mode
102
/* Widget js loading */
103
add_action("admin_print_scripts", "black_studio_tinymce_scripts");
104
function black_studio_tinymce_scripts() {
105
+ global $black_studio_tinymce_widget_version;
106
add_thickbox();
107
wp_enqueue_script('media-upload');
108
+ wp_enqueue_script('black-studio-tinymce-widget', plugins_url('black-studio-tinymce-widget.js', __FILE__), array('jquery', 'editor', 'thickbox', 'media-upload'), $black_studio_tinymce_widget_version);
109
}
110
111
/* Widget css loading */
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.blackstudio.it/pagamento/
4
Tags: wysiwyg, widget, tinymce, editor, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, visual editor widget
5
Requires at least: 3.2.0
6
Tested up to: 3.2.1
7
- Stable tag: 0.6.2
8
9
Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
10
@@ -34,6 +34,9 @@ This section describes how to install the plugin and get it working.
34
35
== Changelog ==
36
37
= 0.6.2 =
38
* Fixed Javascript issue with Media Library inserts in HTML mode
39
4
Tags: wysiwyg, widget, tinymce, editor, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, visual editor widget
5
Requires at least: 3.2.0
6
Tested up to: 3.2.1
7
+ Stable tag: 0.6.3
8
9
Adds a WYSIWYG widget based on the standard TinyMCE WordPress visual editor.
10
34
35
== Changelog ==
36
37
+ = 0.6.3 =
38
+ * Fixed Javascript issue preventing the plugin working correctly with some browsers
39
+
40
= 0.6.2 =
41
* Fixed Javascript issue with Media Library inserts in HTML mode
42