11
11
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
12
12
ed.addCommand('WP_Gallery', function() {
13
var el = ed.selection.getNode(), post_id, vp = tinymce.DOM.getViewPort(), H = vp.h - 80, W = ( 640 < vp.w ) ? 640 : vp.w;
13
var el = ed.selection.getNode(), post_id, vp = tinymce.DOM.getViewPort(),
14
H = vp.h - 80, W = ( 640 < vp.w ) ? 640 : vp.w;
15
16
if ( el.nodeName != 'IMG' ) return;
16
17
if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return;
21
22
tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
24
ed.onInit.add(function(ed) {
25
tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
26
ed.plugins.wpgallery.hideButtons();
30
ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
31
ed.plugins.wpgallery.hideButtons();
34
ed.onSaveContent.add(function(ed, o) {
35
ed.plugins.wpgallery.hideButtons();
38
ed.onMouseUp.add(function(ed, e) {
39
if ( tinymce.isOpera ) {
40
if ( e.target.nodeName == 'IMG' )
41
ed.plugins.wpgallery.showButtons(e.target);
46
25
ed.onMouseDown.add(function(ed, e) {
47
if ( tinymce.isOpera || e.target.nodeName != 'IMG' ) {
51
ed.plugins.wpgallery.showButtons(e.target);
26
if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') )
27
ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns');
54
30
ed.onBeforeSetContent.add(function(ed, o) {
87
showButtons : function(n) {
88
var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
90
if (ed.dom.getAttrib(n, 'class').indexOf('wpGallery') == -1)
93
vp = ed.dom.getViewPort(ed.getWin());
94
p1 = DOM.getPos(ed.getContentAreaContainer());
95
p2 = ed.dom.getPos(n);
97
X = Math.max(p2.x - vp.x, 0) + p1.x;
98
Y = Math.max(p2.y - vp.y, 0) + p1.y;
100
DOM.setStyles('wp_gallerybtns', {
106
t.btnsTout = window.setTimeout( function(){ed.plugins.wpgallery.hideButtons();}, 5000 );
109
hideButtons : function() {
110
if ( tinymce.DOM.isHidden('wp_gallerybtns') ) return;
112
tinymce.DOM.hide('wp_gallerybtns');
113
window.clearTimeout(this.btnsTout);
116
63
_createButtons : function() {
117
var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM, wp_gallerybtns, wp_editgallery, wp_delgallery;
64
var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM, editButton, dellButton;
119
66
DOM.remove('wp_gallerybtns');
121
wp_gallerybtns = DOM.add(document.body, 'div', {
68
DOM.add(document.body, 'div', {
122
69
id : 'wp_gallerybtns',
123
70
style : 'display:none;'
126
wp_editgallery = DOM.add('wp_gallerybtns', 'img', {
73
editButton = DOM.add('wp_gallerybtns', 'img', {
127
74
src : t.url+'/img/edit.png',
128
75
id : 'wp_editgallery',
131
78
title : ed.getLang('wordpress.editgallery')
134
wp_editgallery.onmousedown = function(e) {
81
tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
135
82
var ed = tinyMCE.activeEditor;
136
83
ed.windowManager.bookmark = ed.selection.getBookmark('simple');
137
84
ed.execCommand("WP_Gallery");
138
this.parentNode.style.display = 'none';
141
wp_delgallery = DOM.add('wp_gallerybtns', 'img', {
87
dellButton = DOM.add('wp_gallerybtns', 'img', {
142
88
src : t.url+'/img/delete.png',
143
89
id : 'wp_delgallery',
146
92
title : ed.getLang('wordpress.delgallery')
149
wp_delgallery.onmousedown = function(e) {
95
tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
150
96
var ed = tinyMCE.activeEditor, el = ed.selection.getNode();
152
if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('wpGallery') != -1 ) {
98
if ( el.nodeName == 'IMG' && ed.dom.hasClass(el, 'wpGallery') ) {
153
99
ed.dom.remove(el);
155
this.parentNode.style.display = 'none';
156
101
ed.execCommand('mceRepaint');
162
107
getInfo : function() {