-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathresponsive-tooltip-tinyMCE.js
More file actions
119 lines (102 loc) · 2.97 KB
/
responsive-tooltip-tinyMCE.js
File metadata and controls
119 lines (102 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*---------------------Dialog backend-----------------------*/
var RMFtooltip;
( function( $ ) {
var editor,
inputs = {};
RMFtooltip = {
init: function() {
inputs.wrap = $('#rmf-tooltip-wrap');
inputs.dialog = $( '#rmf-tooltip' );
inputs.backdrop = $( '#rmf-tooltip-backdrop' );
inputs.submit = $( '#rmf-tooltip-submit' );
inputs.close = $( '#rmf-tooltip-close' );
// Input
inputs.text = $( '#rmf-tooltip-text' );
inputs.tip = $( '#rmf-tooltip-tip' );
// Bind event handlers
inputs.submit.click( function( event ) {
event.preventDefault();
RMFtooltip.update();
});
inputs.close.add( inputs.backdrop ).add( '#rmf-tooltip-cancel a' ).click( function( event ) {
event.preventDefault();
RMFtooltip.close();
});
},
open: function( editorId ) {
var ed,
$body = $( document.body );
$body.addClass( 'modal-open' );
RMFtooltip.range = null;
if ( editorId ) {
window.wpActiveEditor = editorId;
}
if ( ! window.wpActiveEditor ) {
return;
}
this.textarea = $( '#' + window.wpActiveEditor ).get( 0 );
if ( typeof tinymce !== 'undefined' ) {
// Make sure the tooltip wrapper is the last element in the body,
// or the inline editor toolbar may show above the backdrop.
$body.append( inputs.backdrop, inputs.wrap );
ed = tinymce.get( wpActiveEditor );
if ( ed && ! ed.isHidden() ) {
editor = ed;
} else {
editor = null;
}
}
inputs.wrap.show();
inputs.backdrop.show();
},
close: function() {
$( document.body ).removeClass( 'modal-open' );
RMFtooltip.textarea.focus();
inputs.backdrop.hide();
inputs.wrap.hide();
RMFtooltip_tip = inputs.tip.val();
RMFtooltip_text = inputs.text.val();
inputs.tip.val('');
inputs.text.val('');
},
update: function update () {
/*var attrs = RMFtooltip.getAttrs(),
link, text;*/
RMFtooltip.close();
editor.focus();
if (RMFtooltip_text != null && RMFtooltip_text != '' && RMFtooltip_tip != null && RMFtooltip_tip != ''){
editor.execCommand('mceInsertContent', false, '[tooltip tip="'+RMFtooltip_tip+'"]'+RMFtooltip_text+'[/tooltip]');
}
editor.nodeChanged();
},
}
$( document ).ready( RMFtooltip.init );
})( jQuery );
/*---------------Integrate with TinyMCE---------------------*/
(function() {
tinymce.create('tinymce.plugins.RMFtooltip', {
init : function(ed, url) {
ed.addButton('RMFtooltip', {
title : 'ToolTip',
image : url+'/RMFtooltipbutton.png',
cmd : 'RMFtooltip_cmd'
});
ed.addCommand('RMFtooltip_cmd', function() {
window.RMFtooltip && window.RMFtooltip.open( ed.id );
});
},
createControl : function(n, cm) {
return null;
},
getInfo : function() {
return {
longname : "Responsive Mobile-Friendly Tooltip",
author : 'ItayXD',
authorurl : 'itayxd.com',
infourl : 'https://github.com/ItayXD/responsive-tooltip',
version : "1.6.6"
};
}
});
tinymce.PluginManager.add('RMFtooltip', tinymce.plugins.RMFtooltip);
})();