JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / plugins / image / dialogs / image.js
index 9b127c9..9c4ceec 100644 (file)
@@ -85,14 +85,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        // size change should alter inline-style text as well.\r
        function commitInternally( targetFields )\r
        {\r
-               if( incommit )\r
+               if ( incommit )\r
                        return;\r
 \r
                incommit = 1;\r
 \r
                var dialog = this.getDialog(),\r
                        element = dialog.imageElement;\r
-               if( element )\r
+               if ( element )\r
                {\r
                        // Commit this field and broadcast to target fields.\r
                        this.commit( IMAGE, element );\r
@@ -385,7 +385,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                this.commitContent( LINK, this.linkElement );\r
 \r
                                // Remove empty style attribute.\r
-                               if( !this.imageElement.getAttribute( 'style' ) )\r
+                               if ( !this.imageElement.getAttribute( 'style' ) )\r
                                        this.imageElement.removeAttribute( 'style' );\r
 \r
                                // Insert a new Image.\r
@@ -682,7 +682,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                        else if ( !value && this.isChanged( ) )\r
                                                                                                                                                element.removeStyle( 'height' );\r
 \r
-                                                                                                                                       if( !internalCommit && type == IMAGE )\r
+                                                                                                                                       if ( !internalCommit && type == IMAGE )\r
                                                                                                                                                element.removeAttribute( 'height' );\r
                                                                                                                                }\r
                                                                                                                                else if ( type == PREVIEW )\r
@@ -716,9 +716,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                        ratioButton = CKEDITOR.document.getById( 'btnLockSizes' );\r
                                                                                                                if ( resetButton )\r
                                                                                                                {\r
-                                                                                                                       resetButton.on( 'click', function()\r
+                                                                                                                       resetButton.on( 'click', function(evt)\r
                                                                                                                                {\r
                                                                                                                                        resetSize( this );\r
+                                                                                                                                       evt.data.preventDefault();\r
                                                                                                                                }, this.getDialog() );\r
                                                                                                                        resetButton.on( 'mouseover', function()\r
                                                                                                                                {\r
@@ -732,7 +733,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                // Activate (Un)LockRatio button\r
                                                                                                                if ( ratioButton )\r
                                                                                                                {\r
-                                                                                                                       ratioButton.on( 'click', function()\r
+                                                                                                                       ratioButton.on( 'click', function(evt)\r
                                                                                                                                {\r
                                                                                                                                        var locked = switchLockRatio( this ),\r
                                                                                                                                                oImageOriginal = this.originalElement,\r
@@ -747,6 +748,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                                        updatePreview( this );\r
                                                                                                                                                }\r
                                                                                                                                        }\r
+                                                                                                                                       evt.data.preventDefault();\r
                                                                                                                                }, this.getDialog() );\r
                                                                                                                        ratioButton.on( 'mouseover', function()\r
                                                                                                                                {\r
@@ -798,11 +800,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                {\r
                                                                                                                        var value,\r
                                                                                                                                borderStyle = element.getStyle( 'border-width' );\r
-\r
                                                                                                                        borderStyle = borderStyle && borderStyle.match( /^(\d+px)(?: \1 \1 \1)?$/ );\r
                                                                                                                        value = borderStyle && parseInt( borderStyle[ 1 ], 10 );\r
-                                                                                                                       !value && ( value = element.getAttribute( 'border' ) );\r
-\r
+                                                                                                                       isNaN ( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'border' ) );\r
                                                                                                                        this.setValue( value );\r
                                                                                                                }\r
                                                                                                        },\r
@@ -811,7 +811,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                var value = parseInt( this.getValue(), 10 );\r
                                                                                                                if ( type == IMAGE || type == PREVIEW )\r
                                                                                                                {\r
-                                                                                                                       if ( value )\r
+                                                                                                                       if ( !isNaN( value ) )\r
                                                                                                                        {\r
                                                                                                                                element.setStyle( 'border-width', CKEDITOR.tools.cssLength( value ) );\r
                                                                                                                                element.setStyle( 'border-style', 'solid' );\r
@@ -823,7 +823,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                element.removeStyle( 'border-color' );\r
                                                                                                                        }\r
 \r
-                                                                                                                       if( !internalCommit && type == IMAGE )\r
+                                                                                                                       if ( !internalCommit && type == IMAGE )\r
                                                                                                                                element.removeAttribute( 'border' );\r
                                                                                                                }\r
                                                                                                                else if ( type == CLEANUP )\r
@@ -871,7 +871,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                        marginRightPx = parseInt( marginRightStyle, 10 );\r
 \r
                                                                                                                        value = ( marginLeftPx == marginRightPx ) && marginLeftPx;\r
-                                                                                                                       !value && ( value = element.getAttribute( 'hspace' ) );\r
+                                                                                                                       isNaN( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'hspace' ) );\r
 \r
                                                                                                                        this.setValue( value );\r
                                                                                                                }\r
@@ -881,7 +881,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                var value = parseInt( this.getValue(), 10 );\r
                                                                                                                if ( type == IMAGE || type == PREVIEW )\r
                                                                                                                {\r
-                                                                                                                       if ( value )\r
+                                                                                                                       if ( !isNaN( value ) )\r
                                                                                                                        {\r
                                                                                                                                element.setStyle( 'margin-left', CKEDITOR.tools.cssLength( value ) );\r
                                                                                                                                element.setStyle( 'margin-right', CKEDITOR.tools.cssLength( value ) );\r
@@ -892,7 +892,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                element.removeStyle( 'margin-right' );\r
                                                                                                                        }\r
 \r
-                                                                                                                       if( !internalCommit && type == IMAGE )\r
+                                                                                                                       if ( !internalCommit && type == IMAGE )\r
                                                                                                                                element.removeAttribute( 'hspace' );\r
                                                                                                                }\r
                                                                                                                else if ( type == CLEANUP )\r
@@ -939,7 +939,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                        marginBottomPx = parseInt( marginBottomStyle, 10 );\r
 \r
                                                                                                                        value = ( marginTopPx == marginBottomPx ) && marginTopPx;\r
-                                                                                                                       !value && ( value = element.getAttribute( 'vspace' ) );\r
+                                                                                                                       isNaN ( parseInt( value, 10 ) ) && ( value = element.getAttribute( 'vspace' ) );\r
                                                                                                                        this.setValue( value );\r
                                                                                                                }\r
                                                                                                        },\r
@@ -948,7 +948,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                var value = parseInt( this.getValue(), 10 );\r
                                                                                                                if ( type == IMAGE || type == PREVIEW )\r
                                                                                                                {\r
-                                                                                                                       if ( value )\r
+                                                                                                                       if ( !isNaN( value ) )\r
                                                                                                                        {\r
                                                                                                                                element.setStyle( 'margin-top', CKEDITOR.tools.cssLength( value ) );\r
                                                                                                                                element.setStyle( 'margin-bottom', CKEDITOR.tools.cssLength( value ) );\r
@@ -959,7 +959,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                                element.removeStyle( 'margin-bottom' );\r
                                                                                                                        }\r
 \r
-                                                                                                                       if( !internalCommit && type == IMAGE )\r
+                                                                                                                       if ( !internalCommit && type == IMAGE )\r
                                                                                                                                element.removeAttribute( 'vspace' );\r
                                                                                                                }\r
                                                                                                                else if ( type == CLEANUP )\r
@@ -1022,10 +1022,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                                                {\r
                                                                                                                        if ( value )\r
                                                                                                                                element.setStyle( 'float', value );\r
-                                                                                                                       else if ( !value && this.isChanged( ) )\r
+                                                                                                                       else\r
                                                                                                                                element.removeStyle( 'float' );\r
 \r
-                                                                                                                       if( !internalCommit && type == IMAGE )\r
+                                                                                                                       if ( !internalCommit && type == IMAGE )\r
                                                                                                                        {\r
                                                                                                                                value = ( element.getAttribute( 'align' ) || '' ).toLowerCase();\r
                                                                                                                                switch( value )\r
@@ -1111,7 +1111,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                {\r
                                                        type : 'button',\r
                                                        id : 'browse',\r
-                                                       filebrowser : 'Link:txtUrl',\r
+                                                       filebrowser :\r
+                                                       {\r
+                                                               action : 'Browse',\r
+                                                               target: 'Link:txtUrl',\r
+                                                               url: editor.config.filebrowserImageBrowseLinkUrl || editor.config.filebrowserBrowseUrl\r
+                                                       },\r
                                                        style : 'float:right',\r
                                                        hidden : true,\r
                                                        label : editor.lang.common.browseServer\r