~canonical-sysadmins/wordpress/3.9.x

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js

  • Committer: Chris Jones
  • Date: 2010-01-19 13:17:33 UTC
  • Revision ID: cmsj@tenshu.net-20100119131733-rf31jv9k1v0xzo2h
[CJ] Import wordpress 2.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
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;
14
15
 
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' );
22
23
                        });
23
24
 
24
 
                        ed.onInit.add(function(ed) {
25
 
                                tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
26
 
                                        ed.plugins.wpgallery.hideButtons();
27
 
                                });
28
 
                        });
29
 
 
30
 
                        ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
31
 
                                ed.plugins.wpgallery.hideButtons();
32
 
                        });
33
 
 
34
 
                        ed.onSaveContent.add(function(ed, o) {
35
 
                                ed.plugins.wpgallery.hideButtons();
36
 
                        });
37
 
 
38
 
                        ed.onMouseUp.add(function(ed, e) {
39
 
                                if ( tinymce.isOpera ) {
40
 
                                        if ( e.target.nodeName == 'IMG' )
41
 
                                                ed.plugins.wpgallery.showButtons(e.target);
42
 
                                }
43
 
 
44
 
                        });
45
 
 
46
25
                        ed.onMouseDown.add(function(ed, e) {
47
 
                                if ( tinymce.isOpera || e.target.nodeName != 'IMG' ) {
48
 
                                        t.hideButtons();
49
 
                                        return;
50
 
                                }
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');
52
28
                        });
53
29
 
54
30
                        ed.onBeforeSetContent.add(function(ed, o) {
84
60
                        });
85
61
                },
86
62
 
87
 
                showButtons : function(n) {
88
 
                        var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
89
 
 
90
 
                        if (ed.dom.getAttrib(n, 'class').indexOf('wpGallery') == -1)
91
 
                                return;
92
 
 
93
 
                        vp = ed.dom.getViewPort(ed.getWin());
94
 
                        p1 = DOM.getPos(ed.getContentAreaContainer());
95
 
                        p2 = ed.dom.getPos(n);
96
 
 
97
 
                        X = Math.max(p2.x - vp.x, 0) + p1.x;
98
 
                        Y = Math.max(p2.y - vp.y, 0) + p1.y;
99
 
 
100
 
                        DOM.setStyles('wp_gallerybtns', {
101
 
                                'top' : Y+5+'px',
102
 
                                'left' : X+5+'px',
103
 
                                'display' : 'block'
104
 
                        });
105
 
 
106
 
                        t.btnsTout = window.setTimeout( function(){ed.plugins.wpgallery.hideButtons();}, 5000 );
107
 
                },
108
 
 
109
 
                hideButtons : function() {
110
 
                        if ( tinymce.DOM.isHidden('wp_gallerybtns') ) return;
111
 
 
112
 
                        tinymce.DOM.hide('wp_gallerybtns');
113
 
                        window.clearTimeout(this.btnsTout);
114
 
                },
115
 
 
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;
118
65
 
119
66
                        DOM.remove('wp_gallerybtns');
120
67
 
121
 
                        wp_gallerybtns = DOM.add(document.body, 'div', {
 
68
                        DOM.add(document.body, 'div', {
122
69
                                id : 'wp_gallerybtns',
123
70
                                style : 'display:none;'
124
71
                        });
125
72
 
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',
129
76
                                width : '24',
131
78
                                title : ed.getLang('wordpress.editgallery')
132
79
                        });
133
80
 
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';
139
 
                        };
 
85
                        });
140
86
 
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',
144
90
                                width : '24',
146
92
                                title : ed.getLang('wordpress.delgallery')
147
93
                        });
148
94
 
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();
151
97
 
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);
154
100
 
155
 
                                        this.parentNode.style.display = 'none';
156
101
                                        ed.execCommand('mceRepaint');
157
102
                                        return false;
158
103
                                }
159
 
                        };
 
104
                        });
160
105
                },
161
106
 
162
107
                getInfo : function() {