| 130 | // Opera doesn't support 'contextmenu' event, we have duo approaches employed here: |
| 131 | // 1. Inherit the 'button override' hack we introduced in v2 (#4530), while this require the Opera browser |
| 132 | // option 'Allow script to detect context menu/right click events' to be always turned on. |
| 133 | // 2. Considering the fact that ctrl/meta key is not been occupied |
| 134 | // for multiple range selecting (like Gecko), we use this key |
| 135 | // combination as a fallback for triggering context-menu. (#4530) |
| 136 | if ( CKEDITOR.env.opera ) |
| 137 | { |
| 138 | var contextMenuOverrideButton; |
| 139 | element.on( 'mousedown', function( evt ) |
| 140 | { |
| 141 | evt = evt.data; |
| 142 | if( evt.$.button != 2 ) |
| 143 | { |
| 144 | if ( evt.getKeystroke() == CKEDITOR.CTRL + 1 ) |
| 145 | element.fire( 'contextmenu', evt ); |
| 146 | return; |
| 147 | } |
| 148 | |
| 149 | var target = evt.getTarget(); |
| 150 | |
| 151 | if( !contextMenuOverrideButton ) |
| 152 | { |
| 153 | var ownerDoc = target.getDocument(); |
| 154 | contextMenuOverrideButton = ownerDoc.createElement( 'input' ) ; |
| 155 | contextMenuOverrideButton.$.type = 'button' ; |
| 156 | ownerDoc.getBody().append( contextMenuOverrideButton ) ; |
| 157 | } |
| 158 | |
| 159 | contextMenuOverrideButton.setAttribute( 'style', 'position:absolute;top:' + ( evt.$.clientY - 2 ) + |
| 160 | 'px;left:' + ( evt.$.clientX - 2 ) + |
| 161 | 'px;width:5px;height:5px;opacity:0.01' ); |
| 162 | |
| 163 | } ); |
| 164 | |
| 165 | element.on( 'mouseup', function ( evt ) |
| 166 | { |
| 167 | if ( contextMenuOverrideButton ) |
| 168 | { |
| 169 | contextMenuOverrideButton.remove(); |
| 170 | contextMenuOverrideButton = undefined; |
| 171 | // Simulate 'contextmenu' event. |
| 172 | element.fire( 'contextmenu', evt.data ); |
| 173 | } |
| 174 | } ); |
| 175 | } |
| 176 | |
163 | | // Fix the "contextmenu" event for DOM elements. |
164 | | // We may do this if we identify browsers that don't support the context meny |
165 | | // event on element directly. Leaving here for reference. |
166 | | //if ( <specific browsers> ) |
167 | | //{ |
168 | | // CKEDITOR.dom.element.prototype.on = CKEDITOR.tools.override( CKEDITOR.dom.element.prototype.on, function( originalOn ) |
169 | | // { |
170 | | // return function( eventName ) |
171 | | // { |
172 | | // if ( eventName != 'contextmenu' ) |
173 | | // return originalOn.apply( this, arguments ); |
174 | | // |
175 | | // // TODO : Implement the fix. |
176 | | // }; |
177 | | // }); |
178 | | //} |