~canonical-sysadmins/wordpress/4.1.3

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/wpview/plugin.js

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
                var clipboard,
116
116
                        dom = editor.dom;
117
117
 
118
 
                // Bail if node is already selected.
119
 
                if ( ! viewNode || viewNode === selected ) {
 
118
                if ( ! viewNode ) {
 
119
                        return;
 
120
                }
 
121
 
 
122
                // Adjust the toolbar position and bail if node is already selected.
 
123
                if ( viewNode === selected ) {
 
124
                        adjustToolbarPosition( viewNode );
120
125
                        return;
121
126
                }
122
127
 
128
133
                deselect();
129
134
                selected = viewNode;
130
135
                dom.setAttrib( viewNode, 'data-mce-selected', 1 );
 
136
                adjustToolbarPosition( viewNode );
131
137
 
132
138
                clipboard = dom.create( 'div', {
133
139
                        'class': 'wpview-clipboard',
151
157
                editor.fire( 'wpview-selected', viewNode );
152
158
        }
153
159
 
 
160
        function adjustToolbarPosition( viewNode ) {
 
161
                var delta = 0,
 
162
                        toolbar = editor.$( viewNode ).find( '.toolbar' ),
 
163
                        editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0],
 
164
                        editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0;
 
165
                
 
166
                if ( toolbar.length && editor.iframeElement ) {
 
167
                        // 48 = 43 for the toolbar + 5 buffer
 
168
                        delta = viewNode.getBoundingClientRect().top + editor.iframeElement.getBoundingClientRect().top - editorToolbarBottom - 48;
 
169
                }
 
170
 
 
171
                if ( delta < 0 ) {
 
172
                        toolbar.removeClass( 'mce-arrow-down' ).css({ top: ( -43 + delta * -1 ) });
 
173
                } else if ( delta > 0 && ! toolbar.hasClass( 'mce-arrow-down' ) ) {
 
174
                        toolbar.addClass( 'mce-arrow-down' ).css({ top: '' });
 
175
                }
 
176
        }
 
177
 
154
178
        /**
155
179
         * Deselect a selected view and remove clipboard
156
180
         */