JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.5
[ckeditor.git] / _source / plugins / image / dialogs / image.js
index c604ebd..496827b 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -115,6 +115,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                var switchLockRatio = function( dialog, value )\r
                {\r
+                       if ( !dialog.getContentElement( 'info', 'ratioLock' ) )\r
+                               return null;\r
+\r
                        var oImageOriginal = dialog.originalElement;\r
 \r
                        // Dialog may already closed. (#5505)\r
@@ -155,11 +158,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        else\r
                                ratioButton.addClass( 'cke_btn_unlocked' );\r
 \r
-                       var lang = dialog._.editor.lang.image,\r
-                               label =  lang[  dialog.lockRatio ? 'unlockRatio' : 'lockRatio' ];\r
+                       ratioButton.setAttribute( 'aria-checked', dialog.lockRatio );\r
 \r
-                       ratioButton.setAttribute( 'title', label );\r
-                       ratioButton.getFirst().setText( label );\r
+                       // Ratio button hc presentation - WHITE SQUARE / BLACK SQUARE\r
+                       if ( CKEDITOR.env.hc )\r
+                       {\r
+                               var icon = ratioButton.getChild( 0 );\r
+                               icon.setHtml(  dialog.lockRatio ? CKEDITOR.env.ie ? '\u25A0': '\u25A3' : CKEDITOR.env.ie ? '\u25A1' : '\u25A2' );\r
+                       }\r
 \r
                        return dialog.lockRatio;\r
                };\r
@@ -169,8 +175,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        var oImageOriginal = dialog.originalElement;\r
                        if ( oImageOriginal.getCustomData( 'isReady' ) == 'true' )\r
                        {\r
-                               dialog.setValueOf( 'info', 'txtWidth', oImageOriginal.$.width );\r
-                               dialog.setValueOf( 'info', 'txtHeight', oImageOriginal.$.height );\r
+                               var widthField = dialog.getContentElement( 'info', 'txtWidth' ),\r
+                                       heightField = dialog.getContentElement( 'info', 'txtHeight' );\r
+                               widthField && widthField.setValue( oImageOriginal.$.width );\r
+                               heightField && heightField.setValue( oImageOriginal.$.height );\r
                        }\r
                        updatePreview( dialog );\r
                };\r
@@ -258,7 +266,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        btnLockSizesId = numbering( 'btnLockSizes' ),\r
                        btnResetSizeId = numbering( 'btnResetSize' ),\r
                        imagePreviewLoaderId = numbering( 'ImagePreviewLoader' ),\r
-                       imagePreviewBoxId = numbering( 'ImagePreviewBox' ),\r
                        previewLinkId = numbering( 'previewLink' ),\r
                        previewImageId = numbering( 'previewImage' );\r
 \r
@@ -282,8 +289,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                this.addLink = false;\r
 \r
                                var editor = this.getParentEditor(),\r
-                                       sel = this.getParentEditor().getSelection(),\r
-                                       element = sel.getSelectedElement(),\r
+                                       sel = editor.getSelection(),\r
+                                       element = sel && sel.getSelectedElement(),\r
                                        link = element && element.getAscendant( 'a' );\r
 \r
                                //Hide loader.\r
@@ -451,8 +458,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                if ( dialogType != 'image' )\r
                                        this.hidePage( 'Link' );                //Hide Link tab.\r
                                var doc = this._.element.getDocument();\r
-                               this.addFocusable( doc.getById( btnResetSizeId ), 5 );\r
-                               this.addFocusable( doc.getById( btnLockSizesId ), 5 );\r
+\r
+                               if ( this.getContentElement( 'info', 'ratioLock' ) )\r
+                               {\r
+                                       this.addFocusable( doc.getById( btnResetSizeId ), 5 );\r
+                                       this.addFocusable( doc.getById( btnLockSizesId ), 5 );\r
+                               }\r
 \r
                                this.commitContent = commitContent;\r
                        },\r
@@ -612,6 +623,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        children :\r
                                                        [\r
                                                                {\r
+                                                                       id : 'basic',\r
                                                                        type : 'vbox',\r
                                                                        children :\r
                                                                        [\r
@@ -728,6 +740,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                        ]\r
                                                                                                },\r
                                                                                                {\r
+                                                                                                       id : 'ratioLock',\r
                                                                                                        type : 'html',\r
                                                                                                        style : 'margin-top:30px;width:40px;height:40px;',\r
                                                                                                        onLoad : function()\r
@@ -769,7 +782,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                                        updatePreview( this );\r
                                                                                                                                                }\r
                                                                                                                                        }\r
-                                                                                                                                       evt.data.preventDefault();\r
+                                                                                                                                       evt.data && evt.data.preventDefault();\r
                                                                                                                                }, this.getDialog() );\r
                                                                                                                        ratioButton.on( 'mouseover', function()\r
                                                                                                                                {\r
@@ -782,8 +795,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                }\r
                                                                                                        },\r
                                                                                                        html : '<div>'+\r
-                                                                                                               '<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.unlockRatio +\r
-                                                                                                               '" class="cke_btn_locked" id="' + btnLockSizesId + '" role="button"><span class="cke_label">' + editor.lang.image.unlockRatio + '</span></a>' +\r
+                                                                                                               '<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.lockRatio +\r
+                                                                                                               '" class="cke_btn_locked" id="' + btnLockSizesId + '" role="checkbox"><span class="cke_icon"></span><span class="cke_label">' + editor.lang.image.lockRatio + '</span></a>' +\r
                                                                                                                '<a href="javascript:void(0)" tabindex="-1" title="' + editor.lang.image.resetSize +\r
                                                                                                                '" class="cke_btn_reset" id="' + btnResetSizeId + '" role="button"><span class="cke_label">' + editor.lang.image.resetSize + '</span></a>'+\r
                                                                                                                '</div>'\r
@@ -833,11 +846,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                element.setStyle( 'border-style', 'solid' );\r
                                                                                                                        }\r
                                                                                                                        else if ( !value && this.isChanged() )\r
-                                                                                                                       {\r
-                                                                                                                               element.removeStyle( 'border-width' );\r
-                                                                                                                               element.removeStyle( 'border-style' );\r
-                                                                                                                               element.removeStyle( 'border-color' );\r
-                                                                                                                       }\r
+                                                                                                                               element.removeStyle( 'border' );\r
 \r
                                                                                                                        if ( !internalCommit && type == IMAGE )\r
                                                                                                                                element.removeAttribute( 'border' );\r
@@ -1059,10 +1068,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        [\r
                                                                                {\r
                                                                                        type : 'html',\r
+                                                                                       id : 'htmlPreview',\r
                                                                                        style : 'width:95%;',\r
                                                                                        html : '<div>' + CKEDITOR.tools.htmlEncode( editor.lang.common.preview ) +'<br>'+\r
                                                                                        '<div id="' + imagePreviewLoaderId + '" class="ImagePreviewLoader" style="display:none"><div class="loading">&nbsp;</div></div>'+\r
-                                                                                       '<div id="' + imagePreviewBoxId + '" class="ImagePreviewBox"><table><tr><td>'+\r
+                                                                                       '<div class="ImagePreviewBox"><table><tr><td>'+\r
                                                                                        '<a href="javascript:void(0)" target="_blank" onclick="return false;" id="' + previewLinkId + '">'+\r
                                                                                        '<img id="' + previewImageId + '" alt="" /></a>' +\r
                                                                                        ( editor.config.image_previewText ||\r
@@ -1334,6 +1344,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        type : 'text',\r
                                                        id : 'txtdlgGenStyle',\r
                                                        label : editor.lang.common.cssStyle,\r
+                                                       validate : CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ),\r
                                                        'default' : '',\r
                                                        setup : function( type, element )\r
                                                        {\r