diff options
| author | Paramjit Singh Sahota <psa@tinyerp.com> | 2013-12-24 11:01:25 +0530 |
|---|---|---|
| committer | Paramjit Singh Sahota <psa@tinyerp.com> | 2013-12-24 11:01:25 +0530 |
| commit | 18d8368ee11eef0a74bacdb8f293414331bfa8da (patch) | |
| tree | fc21df70cbd2901396c2bcf2fee0b52d750abd43 /addons/website/static/lib/ckeditor/plugins/image2 | |
| parent | 5900672160c2bd5ae1d9257f20dbb5c51a193996 (diff) | |
| parent | 123185757f51ee7e146d7295864556999d2a6938 (diff) | |
[MERGE] Merged lp:~openerp-dev/openobject-addons/trunk-website-al
bzr revid: psa@tinyerp.com-20131224053125-3lrogsrgd3ccp0i6
Diffstat (limited to 'addons/website/static/lib/ckeditor/plugins/image2')
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image1.jpg | bin | 34316 -> 0 bytes | |||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image2.jpg | bin | 27711 -> 0 bytes | |||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/dev/contents.css | 32 | ||||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/dev/image2.html | 199 | ||||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/dialogs/image2.js | 480 | ||||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/icons/hidpi/image2.png | bin | 1745 -> 0 bytes | |||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/icons/image2.png | bin | 756 -> 0 bytes | |||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/lang/en.js | 14 | ||||
| -rw-r--r-- | addons/website/static/lib/ckeditor/plugins/image2/plugin.js | 940 |
9 files changed, 0 insertions, 1665 deletions
diff --git a/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image1.jpg b/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image1.jpg Binary files differdeleted file mode 100644 index 2fe79eb2cce..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image1.jpg +++ /dev/null diff --git a/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image2.jpg b/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image2.jpg Binary files differdeleted file mode 100644 index 453ece5d339..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/dev/assets/image2.jpg +++ /dev/null diff --git a/addons/website/static/lib/ckeditor/plugins/image2/dev/contents.css b/addons/website/static/lib/ckeditor/plugins/image2/dev/contents.css deleted file mode 100644 index 1392835036d..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/dev/contents.css +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. -For licensing, see LICENSE.md or http://ckeditor.com/license -*/ - -figure.caption { - text-align: center; - border: solid 1px #ccc; - border-radius: 2px; - background: rgba(0,0,0,0.05); - padding: 10px; - margin: 10px 20px; - display: block; /* For IE8 */ -} - -figure.caption figcaption { - text-align: center; - display: block; /* For IE8 */ -} - -.cke_widget_wrapper:hover:after { - content: "id: " attr(data-widget-id); - position: absolute; - top: 0; - right: 0; - padding: 2px 4px; - background: #EEE; - border: solid 1px #DDD; - border-radius: 2px; - color: #BBB; - font: bold 10px sans-serif; -}
\ No newline at end of file diff --git a/addons/website/static/lib/ckeditor/plugins/image2/dev/image2.html b/addons/website/static/lib/ckeditor/plugins/image2/dev/image2.html deleted file mode 100644 index 18a530843d9..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/dev/image2.html +++ /dev/null @@ -1,199 +0,0 @@ -<!DOCTYPE html> -<!-- -Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. -For licensing, see LICENSE.html or http://ckeditor.com/license ---> -<html> -<head> - <title>Widget image2 — CKEditor Sample</title> - <meta charset="utf-8"> - <script src="../../../ckeditor.js"></script> - <script src="../../../dev/console/console.js"></script> - <script src="../../../dev/console/focusconsole.js"></script> - <script src="../../widget/dev/console.js"></script> - <script> - if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) - CKEDITOR.tools.enableHtml5Elements( document ); - </script> - <link href="../../../samples/sample.css" rel="stylesheet"> - <meta name="ckeditor-sample-name" content="Widget image2"> - <meta name="ckeditor-sample-group" content="Plugins"> - <meta name="ckeditor-sample-description" content="Widget img showcase."> - <meta name="ckeditor-sample-isnew" content="1"> - - <style> - - body { - font-size: 13px; - } - .editable { - padding: 20px; - border: 2px solid #dfdfdf; - overflow: auto; - } - - body p { - line-height: 1.8em; - } - - /* Reset some styles from sample.css */ - .cke_editable.cke_editable_inline - { - cursor: auto; - } - .cke_editable.cke_editable_inline.cke_focus - { - box-shadow: none; - background: inherit; - cursor: auto; - } - - </style> - <link href="contents.css" rel="stylesheet"> -</head> -<body> - <h1 class="samples"> - <a href="../../../samples/index.html">CKEditor Samples</a> » Widget image2 - </h1> - - <h2>Framed sample</h2> - - <textarea id="editor1" cols="10" rows="10"> - <h1>Apollo 11</h1> - - <figure class="caption" style="float: right"> - <img alt="Saturn V" src="assets/image1.jpg" width="200" /> - <figcaption>Roll out of Saturn V on launch pad</figcaption> - </figure> - - <p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> - - <p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5 kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)" title="Michael Collins (astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module" title="Apollo Command/Service Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p> - - <h2>Broadcasting and <em>quotes</em> <a id="quotes" name="quotes"></a></h2> - - <p>Broadcast on live TV to a world-wide audience, Armstrong stepped onto the lunar surface and described the event as:</p> - - <blockquote> - <p>One small step for [a] man, one giant leap for mankind.</p> - </blockquote> - - <p>Apollo 11 effectively ended the <a href="http://en.wikipedia.org/wiki/Space_Race" title="Space Race">Space Race</a> and fulfilled a national goal proposed in 1961 by the late U.S. President <a href="http://en.wikipedia.org/wiki/John_F._Kennedy" title="John F. Kennedy">John F. Kennedy</a> in a speech before the United States Congress:</p> - - <blockquote> - <p>[...] before this decade is out, of landing a man on the Moon and returning him safely to the Earth.</p> - </blockquote> - - <figure class="caption" style="float: right"> - <img alt="The Eagle" src="assets/image2.jpg" style="width: 200px" /> - <figcaption>The Eagle in lunar orbit</figcaption> - </figure> - - <h2>Technical details <a id="tech-details" name="tech-details"></a></h2> - - <p>Launched by a <strong>Saturn V</strong> rocket from <a href="http://en.wikipedia.org/wiki/Kennedy_Space_Center" title="Kennedy Space Center">Kennedy Space Center</a> in Merritt Island, Florida on July 16, Apollo 11 was the fifth manned mission of <a href="http://en.wikipedia.org/wiki/NASA" title="NASA">NASA</a>'s Apollo program. The Apollo spacecraft had three parts:</p> - - <ol> - <li><strong>Command Module</strong> with a cabin for the three astronauts which was the only part which landed back on Earth</li> - <li><strong>Service Module</strong> which supported the Command Module with propulsion, electrical power, oxygen and water</li> - <li><strong>Lunar Module</strong> for landing on the Moon.</li> - </ol> - - <p>After being sent to the Moon by the Saturn V's upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the <a href="http://en.wikipedia.org/wiki/Mare_Tranquillitatis" title="Mare Tranquillitatis">Sea of Tranquility</a>. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the <a href="http://en.wikipedia.org/wiki/Pacific_Ocean" title="Pacific Ocean">Pacific Ocean</a> on July 24.</p> - - <p style="text-align:center"> - <img alt="Saturn V" src="assets/image1.jpg" width="200" /> - </p> - - <hr /> - <p style="text-align:right"><small>Source: <a href="http://en.wikipedia.org/wiki/Apollo_11">Wikipedia.org</a></small></p> - </textarea> - - <h2>Inline sample</h2> - - <div id="editor2" contenteditable="true" class="editable"> - <h2>Apollo 11</h2> - - <figure class="caption" style="float: right"> - <img alt="Saturn V" src="assets/image1.jpg" width="200" /> - <figcaption>Roll out of Saturn V on launch pad</figcaption> - </figure> - - <p><strong>Apollo 11</strong> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> - - <p>Armstrong spent about <s>three and a half</s> two and a half hours outside the spacecraft, Aldrin slightly less; and together they collected 47.5 pounds (21.5 kg) of lunar material for return to Earth. A third member of the mission, <a href="http://en.wikipedia.org/wiki/Michael_Collins_(astronaut)" title="Michael Collins (astronaut)">Michael Collins</a>, piloted the <a href="http://en.wikipedia.org/wiki/Apollo_Command/Service_Module" title="Apollo Command/Service Module">command</a> spacecraft alone in lunar orbit until Armstrong and Aldrin returned to it for the trip back to Earth.</p> - - <h2>Broadcasting and <em>quotes</em> <a id="quotes" name="quotes"></a></h2> - - <p>Broadcast on live TV to a world-wide audience, Armstrong stepped onto the lunar surface and described the event as:</p> - - <blockquote> - <p>One small step for [a] man, one giant leap for mankind.</p> - </blockquote> - - <p>Apollo 11 effectively ended the <a href="http://en.wikipedia.org/wiki/Space_Race" title="Space Race">Space Race</a> and fulfilled a national goal proposed in 1961 by the late U.S. President <a href="http://en.wikipedia.org/wiki/John_F._Kennedy" title="John F. Kennedy">John F. Kennedy</a> in a speech before the United States Congress:</p> - - <blockquote> - <p>[...] before this decade is out, of landing a man on the Moon and returning him safely to the Earth.</p> - </blockquote> - - <figure class="caption" style="float: right"> - <img alt="The Eagle" src="assets/image2.jpg" style="width: 200px" /> - <figcaption>The Eagle in lunar orbit</figcaption> - </figure> - - <h2>Technical details <a id="tech-details" name="tech-details"></a></h2> - - <p>Launched by a <strong>Saturn V</strong> rocket from <a href="http://en.wikipedia.org/wiki/Kennedy_Space_Center" title="Kennedy Space Center">Kennedy Space Center</a> in Merritt Island, Florida on July 16, Apollo 11 was the fifth manned mission of <a href="http://en.wikipedia.org/wiki/NASA" title="NASA">NASA</a>'s Apollo program. The Apollo spacecraft had three parts:</p> - - <ol> - <li><strong>Command Module</strong> with a cabin for the three astronauts which was the only part which landed back on Earth</li> - <li><strong>Service Module</strong> which supported the Command Module with propulsion, electrical power, oxygen and water</li> - <li><strong>Lunar Module</strong> for landing on the Moon.</li> - </ol> - - <p>After being sent to the Moon by the Saturn V's upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the <a href="http://en.wikipedia.org/wiki/Mare_Tranquillitatis" title="Mare Tranquillitatis">Sea of Tranquility</a>. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the <a href="http://en.wikipedia.org/wiki/Pacific_Ocean" title="Pacific Ocean">Pacific Ocean</a> on July 24.</p> - - <p style="text-align:center"> - <img alt="Saturn V" src="assets/image1.jpg" width="200" /> - </p> - - <hr /> - <p style="text-align:right"><small>Source: <a href="http://en.wikipedia.org/wiki/Apollo_11">Wikipedia.org</a></small></p> - </div> - - <script> - - CKEDITOR.disableAutoInline = true; - - CKEDITOR.replace( 'editor1', { - extraPlugins: 'image2', - height: 600, - removePlugins: 'image,forms', - contentsCss: [ '../../../contents.css', 'contents.css' ], - } ); - - CKEDITOR.inline( 'editor2', { - removePlugins: 'image,forms', - extraPlugins: 'image2,sourcedialog' - } ); - - CKCONSOLE.create( 'widget', { editor: 'editor1' } ); - CKCONSOLE.create( 'focus', { editor: 'editor1' } ); - CKCONSOLE.create( 'widget', { editor: 'editor2', folded: true } ); - CKCONSOLE.create( 'focus', { editor: 'editor2', folded: true } ); - - </script> - - <div id="footer"> - <hr> - <p> - CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> - </p> - <p id="copy"> - Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico - Knabben. All rights reserved. - </p> - </div> -</body> -</html> diff --git a/addons/website/static/lib/ckeditor/plugins/image2/dialogs/image2.js b/addons/website/static/lib/ckeditor/plugins/image2/dialogs/image2.js deleted file mode 100644 index 8c4b924bd42..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/dialogs/image2.js +++ /dev/null @@ -1,480 +0,0 @@ -/** - * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. - * For licensing, see LICENSE.html or http://ckeditor.com/license - */ - -'use strict'; - -CKEDITOR.dialog.add( 'image2', function( editor ) { - - // RegExp: 123, 123px, empty string "" - var regexGetSizeOrEmpty = /(^\s*(\d+)(px)?\s*$)|^$/i, - - lockButtonId = CKEDITOR.tools.getNextId(), - resetButtonId = CKEDITOR.tools.getNextId(), - - lang = editor.lang.image2, - commonLang = editor.lang.common, - - lockResetStyle = 'margin-top:18px;width:40px;height:20px;', - lockResetHtml = new CKEDITOR.template( - '<div>' + - '<a href="javascript:void(0)" tabindex="-1" title="' + lang.lockRatio + '" class="cke_btn_locked" id="{lockButtonId}" role="checkbox">' + - '<span class="cke_icon"></span>' + - '<span class="cke_label">' + lang.lockRatio + '</span>' + - '</a>' + - - '<a href="javascript:void(0)" tabindex="-1" title="' + lang.resetSize + '" class="cke_btn_reset" id="{resetButtonId}" role="button">' + - '<span class="cke_label">' + lang.resetSize + '</span>' + - '</a>' + - '</div>' ).output( { - lockButtonId: lockButtonId, - resetButtonId: resetButtonId - } ), - - // Global variables referring to the dialog's context. - doc, widget, image, - - // Global variable referring to this dialog's image pre-loader. - preLoader, - - // Global variables holding the original size of the image. - domWidth, domHeight, - - // Global variables related to image pre-loading. - preLoadedWidth, preLoadedHeight, srcChanged, - - // Global variables related to size locking. - lockRatio, userDefinedLock, - - // Global variables referring to dialog fields and elements. - lockButton, resetButton, widthField, heightField; - - // Validates dimension. Allowed values are: - // "123px", "123", "" (empty string) - function validateDimension() { - var match = this.getValue().match( regexGetSizeOrEmpty ), - isValid = !!( match && parseInt( match[ 1 ], 10 ) !== 0 ); - - if ( !isValid ) - alert( commonLang[ 'invalid' + CKEDITOR.tools.capitalize( this.id ) ] ); - - return isValid; - } - - // Creates a function that pre-loads images. The callback function passes - // [image, width, height] or null if loading failed. - // - // @returns {Function} - function createPreLoader() { - var image = doc.createElement( 'img' ), - listeners = []; - - function addListener( event, callback ) { - listeners.push( image.once( event, function( evt ) { - removeListeners(); - callback( evt ); - } ) ); - } - - function removeListeners() { - var l; - - while ( ( l = listeners.pop() ) ) - l.removeListener(); - } - - // @param {String} src. - // @param {Function} callback. - return function( src, callback, scope ) { - addListener( 'load', function() { - callback.call( scope, image, image.$.width, image.$.height ); - } ); - - addListener( 'error', function() { - callback( null ); - } ); - - addListener( 'abort', function() { - callback( null ); - } ); - - image.setAttribute( 'src', src + '?' + Math.random().toString( 16 ).substring( 2 ) ); - }; - } - - function onChangeDimension() { - // If ratio is un-locked, then we don't care what's next. - if ( !lockRatio ) - return; - - var value = this.getValue(); - - // No reason to auto-scale or unlock if the field is empty. - if ( !value ) - return; - - // If the value of the field is invalid (e.g. with %), unlock ratio. - if ( !value.match( regexGetSizeOrEmpty ) ) - toggleLockDimensions( false ); - - // No automatic re-scale when dimension is '0'. - if ( value === '0' ) - return; - - var isWidth = this.id == 'width', - // If dialog opened for the new image, domWidth and domHeight - // will be empty. Use dimensions from pre-loader in such case instead. - width = domWidth || preLoadedWidth, - height = domHeight || preLoadedHeight; - - // If changing width, then auto-scale height. - if ( isWidth ) - value = Math.round( height * ( value / width ) ); - - // If changing height, then auto-scale width. - else - value = Math.round( width * ( value / height ) ); - - // If the value is a number, apply it to the other field. - if ( !isNaN( value ) ) - ( isWidth ? heightField : widthField ).setValue( value ); - } - - // Set-up function for lock and reset buttons: - // * Adds lock and reset buttons to focusables. Check if button exist first - // because it may be disabled e.g. due to ACF restrictions. - // * Register mouseover and mouseout event listeners for UI manipulations. - // * Register click event listeners for buttons. - function onLoadLockReset() { - var dialog = this.getDialog(); - - function setupMouseClasses( el ) { - el.on( 'mouseover', function() { - this.addClass( 'cke_btn_over' ); - }, el ); - - el.on( 'mouseout', function() { - this.removeClass( 'cke_btn_over' ); - }, el ); - } - - // Create references to lock and reset buttons for this dialog instance. - lockButton = doc.getById( lockButtonId ); - resetButton = doc.getById( resetButtonId ); - - // Activate (Un)LockRatio button - if ( lockButton ) { - dialog.addFocusable( lockButton, 4 ); - - lockButton.on( 'click', function( evt ) { - toggleLockDimensions(); - evt.data && evt.data.preventDefault(); - }, this.getDialog() ); - - setupMouseClasses( lockButton ); - } - - // Activate the reset size button. - if ( resetButton ) { - dialog.addFocusable( resetButton, 5 ); - - // Fills width and height fields with the original dimensions of the - // image (stored in widget#data since widget#init). - resetButton.on( 'click', function( evt ) { - // If there's a new image loaded, reset button should revert - // cached dimensions of pre-loaded DOM element. - if ( srcChanged ) { - widthField.setValue( preLoadedWidth ); - heightField.setValue( preLoadedHeight ); - } - - // If the old image remains, reset button should revert - // dimensions as loaded when the dialog was first shown. - else { - widthField.setValue( domWidth ); - heightField.setValue( domHeight ); - } - - evt.data && evt.data.preventDefault(); - }, this ); - - setupMouseClasses( resetButton ); - } - } - - function toggleLockDimensions( enable ) { - // No locking if there's no radio (i.e. due to ACF). - if ( !lockButton ) - return; - - var width, height; - - // Check image ratio and original image ratio, but respecting user's - // preference. This is performed when a new image is pre-loaded - // but not if user already manually locked the ratio. - if ( enable == 'check' && !userDefinedLock ) { - width = widthField.getValue(); - height = heightField.getValue(); - - var domRatio = preLoadedWidth * 1000 / preLoadedHeight, - ratio = width * 1000 / height; - - lockRatio = false; - - // Lock ratio, if there is no width and no height specified. - if ( !width && !height ) - lockRatio = true; - - // Lock ratio if there is at least width or height specified, - // and the old ratio that matches the new one. - else if ( !isNaN( domRatio + ratio ) && Math.round( domRatio ) == Math.round( ratio ) ) - lockRatio = true; - } - - // True or false. - else if ( typeof enable == 'boolean' ) - lockRatio = enable; - - // Undefined. User changed lock value. - else { - userDefinedLock = true; - lockRatio = !lockRatio; - - width = widthField.getValue(); - - // Automatically adjust height to width to match - // the original ratio (based on dom- dimensions). - if ( lockRatio && width ) { - height = domHeight / domWidth * width; - - if ( !isNaN( height ) ) - heightField.setValue( Math.round( height ) ); - } - } - - lockButton[ lockRatio ? 'removeClass' : 'addClass' ]( 'cke_btn_unlocked' ); - lockButton.setAttribute( 'aria-checked', lockRatio ); - - // Ratio button hc presentation - WHITE SQUARE / BLACK SQUARE - if ( CKEDITOR.env.hc ) { - var icon = lockButton.getChild( 0 ); - icon.setHtml( lockRatio ? CKEDITOR.env.ie ? '\u25A0' : '\u25A3' : CKEDITOR.env.ie ? '\u25A1' : '\u25A2' ); - } - } - - function toggleDimensions( enable ) { - var method = enable ? 'enable' : 'disable'; - - widthField[ method ](); - heightField[ method ](); - } - - return { - title: lang.title, - minWidth: 250, - minHeight: 100, - onLoad: function() { - // Create a "global" reference to the document for this dialog instance. - doc = this._.element.getDocument(); - - // Create a pre-loader used for determining dimensions of new images. - preLoader = createPreLoader(); - }, - onShow: function() { - // Create a "global" reference to edited widget. - widget = this._.widget; - - // Create a "global" reference to widget's image. - image = widget.parts.image; - - // Reset global variables. - preLoadedWidth = preLoadedHeight = srcChanged = - userDefinedLock = lockRatio = false; - - // TODO: IE8 - // Get the natural width of the image. - domWidth = image.$.naturalWidth; - - // TODO: IE8 - // Get the natural height of the image. - domHeight = image.$.naturalHeight; - - // Determine image ratio lock on startup. Delayed, waiting for - // fields to be filled with setup functions. - setTimeout( function() { - toggleLockDimensions( 'check' ); - } ); - }, - contents: [ - { - id: 'info', - elements: [ - { - id: 'src', - type: 'text', - label: commonLang.url, - onKeyup: function() { - var value = this.getValue(); - - toggleDimensions( false ); - - // Remember that src is different than default. - if ( value !== widget.data.src ) { - // Update dimensions of the image once it's preloaded. - preLoader( value, function( image, width, height ) { - // Re-enable width and height fields. - toggleDimensions( true ); - - // There was problem loading the image. Unlock ratio. - if ( !image ) - return toggleLockDimensions( false ); - - // Fill width field with the width of the new image. - widthField.setValue( width ); - - // Fill height field with the height of the new image. - heightField.setValue( height ); - - // Cache the new width. - preLoadedWidth = width; - - // Cache the new height. - preLoadedHeight = height; - - // Check for new lock value if image exist. - toggleLockDimensions( 'check' ); - } ); - - srcChanged = true; - } - - // Value is the same as in widget data but is was - // modified back in time. Roll back dimensions when restoring - // default src. - else if ( srcChanged ) { - // Re-enable width and height fields. - toggleDimensions( true ); - - // Restore width field with cached width. - widthField.setValue( domWidth ); - - // Restore height field with cached height. - heightField.setValue( domHeight ); - - // Src equals default one back again. - srcChanged = false; - } - - // Value is the same as in widget data and it hadn't - // been modified. - else { - // Re-enable width and height fields. - toggleDimensions( true ); - } - }, - setup: function( widget ) { - this.setValue( widget.data.src ); - }, - commit: function( widget ) { - widget.setData( 'src', this.getValue() ); - }, - validate: CKEDITOR.dialog.validate.notEmpty( lang.urlMissing ) - }, - { - id: 'alt', - type: 'text', - label: lang.alt, - setup: function( widget ) { - this.setValue( widget.data.alt ); - }, - commit: function( widget ) { - widget.setData( 'alt', this.getValue() ); - } - }, - { - type: 'hbox', - widths: [ '25%', '25%', '50%' ], - requiredContent: 'img[width,height]', - children: [ - { - type: 'text', - width: '45px', - id: 'width', - label: commonLang.width, - validate: validateDimension, - onKeyUp: onChangeDimension, - onLoad: function() { - widthField = this; - }, - setup: function( widget ) { - this.setValue( widget.data.width ); - }, - commit: function( widget ) { - widget.setData( 'width', this.getValue() ); - } - }, - { - type: 'text', - id: 'height', - width: '45px', - label: commonLang.height, - validate: validateDimension, - onKeyUp: onChangeDimension, - onLoad: function() { - heightField = this; - }, - setup: function( widget ) { - this.setValue( widget.data.height ); - }, - commit: function( widget ) { - widget.setData( 'height', this.getValue() ); - } - }, - { - id: 'lock', - type: 'html', - style: lockResetStyle, - onLoad: onLoadLockReset, - html: lockResetHtml - } - ] - }, - { - type: 'hbox', - id: 'alignment', - children: [ - { - id: 'align', - type: 'radio', - items: [ - [ 'None', 'none' ], - [ 'Left', 'left' ], - [ 'Center', 'center' ], - [ 'Right', 'right' ] ], - label: commonLang.align, - setup: function( widget ) { - this.setValue( widget.data.align ); - }, - commit: function( widget ) { - widget.setData( 'align', this.getValue() ); - } - } - ] - }, - { - id: 'hasCaption', - type: 'checkbox', - label: lang.captioned, - setup: function( widget ) { - this.setValue( widget.data.hasCaption ); - }, - commit: function( widget ) { - widget.setData( 'hasCaption', this.getValue() ); - } - } - ] - } - ] - }; -} );
\ No newline at end of file diff --git a/addons/website/static/lib/ckeditor/plugins/image2/icons/hidpi/image2.png b/addons/website/static/lib/ckeditor/plugins/image2/icons/hidpi/image2.png Binary files differdeleted file mode 100644 index b3c7ade53ce..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/icons/hidpi/image2.png +++ /dev/null diff --git a/addons/website/static/lib/ckeditor/plugins/image2/icons/image2.png b/addons/website/static/lib/ckeditor/plugins/image2/icons/image2.png Binary files differdeleted file mode 100644 index fcf61b5f2b3..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/icons/image2.png +++ /dev/null diff --git a/addons/website/static/lib/ckeditor/plugins/image2/lang/en.js b/addons/website/static/lib/ckeditor/plugins/image2/lang/en.js deleted file mode 100644 index 6431dfc0089..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/lang/en.js +++ /dev/null @@ -1,14 +0,0 @@ -/* -Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. -For licensing, see LICENSE.md or http://ckeditor.com/license -*/ -CKEDITOR.plugins.setLang( 'image2', 'en', { - alt: 'Alternative Text', // Inherit from image plugin. - captioned: 'Captioned image', // NEW property. - lockRatio: 'Lock Ratio', // Inherit from image plugin. - menu: 'Image Properties', // Inherit from image plugin. - resetSize: 'Reset Size', // Inherit from image plugin. - resizer: 'Click and drag to resize', // NEW property. - title: 'Image Properties', // Inherit from image plugin. - urlMissing: 'Image source URL is missing.' // Inherit from image plugin. -} ); diff --git a/addons/website/static/lib/ckeditor/plugins/image2/plugin.js b/addons/website/static/lib/ckeditor/plugins/image2/plugin.js deleted file mode 100644 index 48ca3e98990..00000000000 --- a/addons/website/static/lib/ckeditor/plugins/image2/plugin.js +++ /dev/null @@ -1,940 +0,0 @@ -/** - * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. - * For licensing, see LICENSE.html or http://ckeditor.com/license - */ - -'use strict'; - -(function() { - - var template = - '<figure class="caption">' + - '<img alt="" src="" />' + - '<figcaption>Caption</figcaption>' + - '</figure>', - templateInline = '<img alt="" src="" />'; - - CKEDITOR.plugins.add( 'image2', { - lang: 'en', // %REMOVE_LINE_CORE% - requires: 'widget,dialog', - icons: 'image2', - hidpi: true, - - onLoad: function( editor ) { - CKEDITOR.addCss( '.cke_image2_resizer{' + - 'display:none;' + - 'position:absolute;' + - 'bottom:2px;' + - 'width: 0px;' + - 'height: 0px;' + - 'border-style:solid;' + - // Bottom-right corner style of the resizer. - 'right:2px;' + - 'border-width:0 0 10px 10px;' + - 'border-color:transparent transparent #ccc transparent;' + - CKEDITOR.tools.cssVendorPrefix( 'box-shadow', '1px 1px 0px #777', true ) + ';' + - 'cursor:se-resize;' + - '}' + - '.cke_image2_resizer_wrapper{' + - 'position:relative;' + - 'display:inline-block;' + - 'line-height:0;' + - '}' + - // Bottom-left corner style of the resizer. - '.cke_image2_resizer.cke_image2_resizer_left{' + - 'right:auto;' + - 'left:2px;' + - 'border-width:10px 0 0 10px;' + - 'border-color:transparent transparent transparent #ccc;' + - CKEDITOR.tools.cssVendorPrefix( 'box-shadow', '-1px 1px 0px #777', true ) + ';' + - 'cursor:sw-resize;' + - '}' + - '.cke_widget_wrapper:hover .cke_image2_resizer{display:block;}' ); - }, - - init: function( editor ) { - // Register the inline widget. - editor.widgets.add( 'image2inline', image2inline ); - - // Register the block widget. - editor.widgets.add( 'image2block', image2block ); - - // Add the command for this plugin. - editor.addCommand( 'image2', { - exec: function() { - var focused = getFocusedWidget( editor ); - - if ( focused ) - focused.edit(); - else - editor.execCommand( 'image2inline' ); - } - } ); - - // Add toolbar button for this plugin. - editor.ui.addButton && editor.ui.addButton( 'image2', { - label: editor.lang.common.image, - command: 'image2', - toolbar: 'insert,10' - } ); - - // Integrate the plugin with context menus. - if ( editor.contextMenu ) { - editor.addMenuGroup( 'image2', 10 ); - - // Define a menu item for the plguin. - editor.addMenuItem( 'image2', { - label: editor.lang.image2.menu, - command: 'image2', - group: 'image2' - } ); - - // Show the menu item in the context menu when a widget - // is focused. - editor.contextMenu.addListener( function() { - var focused = getFocusedWidget( editor ); - - if ( focused ) - return { image2: CKEDITOR.TRISTATE_OFF }; - - return null; - } ); - } - - // Add the dialog associated with both widgets. - CKEDITOR.dialog.add( 'image2', this.path + 'dialogs/image2.js' ); - }, - - afterInit: function( editor ) { - var align = { left:1,right:1,center:1,block:1 }, - integrate = alignCommandIntegrator( editor ); - - for ( var value in align ) - integrate( value ); - } - } ); - - // Default definition shared across widgets. - var image2 = { - // This widget converts style-driven dimensions to attributes. - contentTransformations: [ - [ 'img[width]: sizeToAttribute' ] - ], - - data: function() { - var widget = this, - editor = widget.editor, - oldState = widget.oldData, - newState = widget.data; - - // Convert the internal form of the widget - // from the old state to the new one. - widget.shiftState( { - element: widget.element, - oldState: oldState, - newState: newState, - - // Destroy the widget. - destroy: function() { - if ( this.destroyed ) - return; - - editor.widgets.destroy( widget ); - - // Mark widget was destroyed. - this.destroyed = true; - }, - - init: function( element ) { - // Create a new widget. This widget will be either captioned - // non-captioned, block or inline according to what is the - // new state of the widget. - if ( this.destroyed ) { - var name = 'image2' + ( newState.hasCaption || newState.align == 'center' ? 'block' : 'inline' ); - widget = editor.widgets.initOn( element, name, widget.data ); - } - - // If now widget was destroyed just update wrapper's alignment. - // According to the new state. - else - setWrapperAlign( widget ); - } - } ); - - // Get the <img> from the widget. As widget may have been - // re-initialized, this may be a totally different <img>. - var image = widget.parts.image; - - image.setAttributes( { - src: widget.data.src, - - // This internal is required by the editor. - 'data-cke-saved-src': widget.data.src, - - alt: widget.data.alt - } ); - - // Set dimensions of the image according to gathered data. - setDimensions( widget ); - - // Cache current data. - widget.oldData = CKEDITOR.tools.extend( {}, widget.data ); - }, - - // The name of this widget's dialog. - dialog: 'image2', - - // Initialization of this widget. - init: function() { - var image = this.parts.image, - data = { - // Check whether widget has caption. - hasCaption: !!this.parts.caption, - - // Read initial image SRC attribute. - src: image.getAttribute( 'src' ), - - // Read initial image ALT attribute. - alt: image.getAttribute( 'alt' ) || '', - - // Read initial width from either attribute or style. - width: image.getAttribute( 'width' ) || '', - - // Read initial height from either attribute or style. - height: image.getAttribute( 'height' ) || '' - }; - - // If element was marked as centered when upcasting, update - // the alignment both visually and in widget data. - if ( this.element.data( 'cke-centered' ) ) { - this.element.data( 'cke-centered', false ); - data.align = 'center'; - } - - // Otherwise, read initial float style from figure/image and - // then remove it. This style will be set on wrapper in #data listener. - else { - data.align = this.element.getStyle( 'float' ) || image.getStyle( 'float' ) || 'none'; - this.element.removeStyle( 'float' ); - image.removeStyle( 'float' ); - } - - // Get rid of extra vertical space when there's no caption. - // It will improve the look of the resizer. - if ( !data.hasCaption ) - this.wrapper.setStyle( 'line-height', '0' ); - - // Set collected data. - this.setData( data ); - - // Setup dynamic image resizing with mouse. - setupResizer( this ); - - // Create shift stater for this widget. - this.shiftState = CKEDITOR.plugins.image2.stateShifter( this.editor ); - }, - - // Widget downcasting. - downcast: downcastWidgetElement - }, - - image2inline = CKEDITOR.tools.extend( { - // Widget-specific rules for Allowed Content Filter. - allowedContent: { - // This widget needs <img>. - img: { - attributes: '!src,alt,width,height', - styles: 'float' - } - }, - - // This widget is inline. - inline: true, - - // Parts of this widget. - parts: { image: 'img' }, - - // Template of the widget: plain image. - template: templateInline, - - // Widget upcasting. - upcast: createUpcastFunction() - }, image2 ), - - image2block = CKEDITOR.tools.extend( { - // Widget-specific rules for Allowed Content Filter. - allowedContent: { - // This widget needs <figcaption>. - figcaption: true, - - // This widget needs <figure>. - figure: { - classes: '!caption', - styles: 'float,display' - }, - - // This widget needs <img>. - img: { - attributes: '!src,alt,width,height' - }, - - // This widget may need <div> centering wrapper. - div: { - match: isCenterWrapper, - styles: 'text-align' - }, - - // This widget may need <p> centering wrapper. - p: { - match: isCenterWrapper, - styles: 'text-align' - } - }, - - // This widget has an editable caption. - editables: { - caption: { - selector: 'figcaption', - allowedContent: 'br em strong sub sup u; a[!href]' - } - }, - - // Parts of this widget: image and caption. - parts: { - image: 'img', - caption: 'figcaption' - }, - - // Template of the widget: figure with image and caption. - template: template, - - // Widget upcasting. - upcast: createUpcastFunction( true ) - }, image2 ); - - CKEDITOR.plugins.image2 = { - stateShifter: function( editor ) { - // Tag name used for centering non-captioned widgets. - var centerElement = editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div', - - // The order that stateActions get executed. It matters! - shiftables = [ 'hasCaption', 'align' ], - - editable = editor.editable(), - - // Atomic procedures, one per state variable. - stateActions = { - align: function( data, oldValue, newValue ) { - var hasCaptionAfter = data.newState.hasCaption, - element = data.element; - - // Alignment changed. - if ( changed( data, 'align' ) ) { - // No caption in the new state. - if ( !hasCaptionAfter ) { - // Changed to "center" (non-captioned). - if ( newValue == 'center' ) { - data.destroy(); - data.element = wrapInCentering( element ); - } - - // Changed to "non-center" from "center" while caption removed. - if ( !changed( data, 'hasCaption' ) && oldValue == 'center' && newValue != 'center' ) { - data.destroy(); - data.element = unwrapFromCentering( element ); - } - } - } - - // Alignment remains and "center" removed caption. - else if ( newValue == 'center' && changed( data, 'hasCaption' ) && !hasCaptionAfter ) { - data.destroy(); - data.element = wrapInCentering( element ); - } - - // Finally set display for figure. - if ( element.is( 'figure' ) ) { - if ( newValue == 'center' ) - element.setStyle( 'display', 'inline-block' ); - else - element.removeStyle( 'display' ); - } - }, - hasCaption: function( data, oldValue, newValue ) { - // This action is for real state change only. - if ( !changed( data, 'hasCaption' ) ) - return; - - var element = data.element, - oldState = data.oldState, - newState = data.newState, - img; - - // Switching hasCaption always destroys the widget. - data.destroy(); - - // There was no caption, but the caption is to be added. - if ( newValue ) { - // Get <img> from element. As element may be either - // <img> or centering <p>, consider it now. - img = element.findOne( 'img' ) || element; - - // Create new <figure> from widget template. - var figure = CKEDITOR.dom.element.createFromHtml( template, editor.document ); - - // Replace element with <figure>. - replaceSafely( figure, element ); - - // Use old <img> instead of the one from the template, - // so we won't lose additional attributes. - img.replace( figure.findOne( 'img' ) ); - - // Update widget's element. - data.element = figure; - } - - // The caption was present, but now it's to be removed. - else { - // Unwrap <img> from figure. - img = element.findOne( 'img' ); - - // Replace <figure> with <img>. - img.replace( element ); - - // Update widget's element. - data.element = img; - } - } - }; - - function getValue( state, name ) { - return state && state[ name ] !== undefined ? state[ name ] : null; - } - - function changed( data, name ) { - if ( !data.oldState ) - return false; - else - return data.oldState[ name ] !== data.newState[ name ]; - } - - function wrapInCentering( element ) { - // When widget gets centered. Wrapper must be created. - // Create new <p|div> with text-align:center. - var center = editor.document.createElement( centerElement, { - // Centering wrapper is.. centering. - styles: { 'text-align': 'center' } - } ); - - // Replace element with centering wrapper. - replaceSafely( center, element ); - - // Append element into centering wrapper. - element.move( center ); - - return center; - } - - function unwrapFromCentering( element ) { - var img = element.findOne( 'img' ); - - img.replace( element ); - - return img; - } - - function replaceSafely( replacing, replaced ) { - if ( replaced.getParent() ) { - // Create a range that corresponds with old element's position. - var range = editor.createRange(); - - // Move the range before old element. - range.moveToPosition( replaced, CKEDITOR.POSITION_BEFORE_START ); - - // Insert element at range position. - editable.insertElementIntoRange( replacing, range ); - - // Remove old element. - replaced.remove(); - } - else - replacing.replace( replaced ); - } - - return function( data ) { - var oldState = data.oldState, - newState = data.newState, - name; - - // Iterate over possible state variables. - for ( var i = 0; i < shiftables.length; i++ ) { - name = shiftables[ i ]; - - stateActions[ name ]( data, - oldState ? oldState[ name ] : null, - newState[ name ] ); - } - - data.init( data.element ); - }; - } - }; - - function setWrapperAlign( widget ) { - var wrapper = widget.wrapper, - align = widget.data.align; - - if ( align == 'center' ) { - if ( !widget.inline ) - wrapper.setStyle( 'text-align', 'center' ); - - wrapper.removeStyle( 'float' ); - } else { - if ( !widget.inline ) - wrapper.removeStyle( 'text-align' ); - - if ( align == 'none' ) - wrapper.removeStyle( 'float' ); - else - wrapper.setStyle( 'float', align ); - } - } - - // Creates widgets from all <img> and <figure class="caption">. - // - // @param {CKEDITOR.htmlParser.element} el - function createUpcastFunction( isBlock ) { - var regexPercent = /^\s*(\d+\%)\s*$/i, - dimensions = { width:1,height:1 }; - - function upcastElement( el, isBlock, isCenter ) { - var name = el.name, - image; - - // Block widget to be upcasted. - if ( isBlock ) { - // If a center wrapper is found. - if ( isCenter ) { - // So the element is: - // <div style="text-align:center"><figure></figure></div>. - // Centering is done by widget.wrapper in such case. Hence, replace - // centering wrapper with figure. - // The other case is: - // <p style="text-align:center"><img></p>. - // Then <p> takes charge of <figure> and nothing is to be changed. - if ( name == 'div' ) { - var figure = el.getFirst( 'figure' ); - el.replaceWith( figure ); - el = figure; - } - - // Mark the element as centered, so widget.data.align - // can be correctly filled on init. - el.attributes[ 'data-cke-centered' ] = true; - - image = el.getFirst( 'img' ); - } - - // No center wrapper has been found. - else if ( name == 'figure' && el.hasClass( 'caption' ) ) - image = el.getFirst( 'img' ); - } - - // Inline widget from plain img. - else if ( name == 'img' ) - image = el; - - if ( !image ) - return; - - // If there's an image, then cool, we got a widget. - // Now just remove dimension attributes expressed with %. - for ( var d in dimensions ) { - var dimension = image.attributes[ d ]; - - if ( dimension && dimension.match( regexPercent ) ) - delete image.attributes[ d ]; - } - - return el; - } - - return isBlock ? - function( el ) { - return upcastElement( el, true, isCenterWrapper( el ) ); - } - : - function( el ) { - // Basically upcast the element if there is no special - // wrapper around. - return upcastElement( el ); - }; - } - - // Transforms the widget to the external format according to - // the current configuration. - // - // @param {CKEDITOR.htmlParser.element} el - function downcastWidgetElement( el ) { - var attrs = el.attributes, - align = this.data.align; - - // De-wrap the image from resize handle wrapper. - // Only block widgets have one. - if ( !this.inline ) { - var resizeWrapper = el.getFirst( 'span' ), - img = resizeWrapper.getFirst( 'img' ); - - resizeWrapper.replaceWith( img ); - } - - if ( align && align != 'none' ) { - // Parse element styles. Styles will be extended. - var styles = CKEDITOR.tools.parseCssText( attrs.style || '' ); - - // If centering, wrap downcasted element. - // Wrappers for <img> and <figure> are <p> and <div>, respectively. - if ( align == 'center' && el.name != 'p' ) { - var name = el.name == 'img' ? 'p' : 'div'; - - el = el.wrapWith( new CKEDITOR.htmlParser.element( name, { - 'style': 'text-align:center' - } ) ); - } - - // If left/right, add float style to the downcasted element. - else if ( align in { left:1,right:1 } ) - styles[ 'float' ] = align; - - // Update element styles. - if ( !CKEDITOR.tools.isEmpty( styles ) ) - attrs.style = CKEDITOR.tools.writeCssText( styles ); - } - - return el; - } - - function isCenterWrapper( el ) { - // Wrapper must be either <div> or <p>. - if ( !( el.name in { div:1,p:1 } ) ) - return false; - - var children = el.children; - - // Centering wrapper can have only one child. - if ( children.length !== 1 ) - return false; - - var styles = CKEDITOR.tools.parseCssText( el.attributes.style || '' ); - - // Centering wrapper got to be... centering. - if ( !styles[ 'text-align' ] || styles[ 'text-align' ] != 'center' ) - return false; - - var child = children[ 0 ], - childName = child.name; - - // The only child of centering wrapper can be <figure> with - // class="caption" or plain <img>. - if ( childName == 'img' || ( childName == 'figure' && child.hasClass( 'caption' ) ) ) - return true; - - return false; - } - - // Sets width and height of the widget image according to - // current widget data. - // - // @param {CKEDITOR.plugins.widget} widget - function setDimensions( widget ) { - var dimensions = CKEDITOR.tools.extend( {}, widget.data, false, { width:1,height:1 } ), - image = widget.parts.image; - - for ( var d in dimensions ) { - if ( dimensions[ d ] ) - image.setAttribute( d, dimensions[ d ] ); - else - image.removeAttribute( d ); - } - } - - // Defines all features related to drag-driven image resizing. - // @param {CKEDITOR.plugins.widget} widget - function setupResizer( widget ) { - var editor = widget.editor, - doc = editor.document, - resizer = doc.createElement( 'span' ); - - resizer.addClass( 'cke_image2_resizer' ); - resizer.setAttribute( 'title', editor.lang.image2.resizer ); - resizer.append( new CKEDITOR.dom.text( '\u200b', doc ) ); - - // Inline widgets don't need a resizer wrapper as an image spans the entire widget. - if ( !widget.inline ) { - var oldResizeWrapper = widget.element.getFirst(), - resizeWrapper = doc.createElement( 'span' ); - - resizeWrapper.addClass( 'cke_image2_resizer_wrapper' ); - resizeWrapper.append( widget.parts.image ); - resizeWrapper.append( resizer ); - widget.element.append( resizeWrapper, true ); - - // Remove the old wrapper which could came from e.g. pasted HTML - // and which could be corrupted (e.g. resizer span has been lost). - if ( oldResizeWrapper.is( 'span' ) ) - oldResizeWrapper.remove(); - } else - widget.wrapper.append( resizer ); - - // Calculate values of size variables and mouse offsets. - // Start observing mousemove. - resizer.on( 'mousedown', function( evt ) { - var image = widget.parts.image, - - // "factor" can be either 1 or -1. I.e.: For right-aligned images, we need to - // subtract the difference to get proper width, etc. Without "factor", - // resizer starts working the opposite way. - factor = widget.data.align == 'right' ? -1 : 1, - - // The x-coordinate of the mouse relative to the screen - // when button gets pressed. - startX = evt.data.$.screenX, - startY = evt.data.$.screenY, - - // The initial dimensions and aspect ratio of the image. - startWidth = image.$.clientWidth, - startHeight = image.$.clientHeight, - ratio = startWidth / startHeight, - - moveListeners = [], - - nativeEvt, newWidth, newHeight, updateData, - moveDiffX, moveDiffY, moveRatio; - - // Save the undo snapshot first: before resizing. - editor.fire( 'saveSnapshot' ); - - // Mousemove listeners are removed on mouseup. - attachToDocuments( 'mousemove', onMouseMove, moveListeners ); - - // Clean up the mousemove listener. Update widget data if valid. - attachToDocuments( 'mouseup', onMouseUp ); - - // Attaches an event to a global document if inline editor. - // Additionally, if framed, also attaches the same event to iframe's document. - function attachToDocuments( name, callback, collection ) { - var globalDoc = CKEDITOR.document, - listeners = []; - - if ( !doc.equals( globalDoc ) ) - listeners.push( globalDoc.on( name, callback ) ); - - listeners.push( doc.on( name, callback ) ); - - if ( collection ) { - for ( var i = listeners.length; i--; ) - collection.push( listeners.pop() ); - } - } - - // Calculate with first, and then adjust height, preserving ratio. - function adjustToX() { - newWidth = startWidth + factor * moveDiffX; - newHeight = 0 | newWidth / ratio; - } - - // Calculate height first, and then adjust width, preserving ratio. - function adjustToY() { - newHeight = startHeight - moveDiffY; - newWidth = 0 | newHeight * ratio; - } - - // This is how variables refer to the geometry. - // Note: x corresponds to moveOffset, this is the position of mouse - // Note: o corresponds to [startX, startY]. - // - // +--------------+--------------+ - // | | | - // | I | II | - // | | | - // +------------- o -------------+ _ _ _ - // | | | ^ - // | VI | III | | moveDiffY - // | | x _ _ _ _ _ v - // +--------------+---------|----+ - // | | - // <-------> - // moveDiffX - function onMouseMove( evt ) { - nativeEvt = evt.data.$; - - // This is how far the mouse is from the point the button was pressed. - moveDiffX = nativeEvt.screenX - startX; - moveDiffY = startY - nativeEvt.screenY; - - // This is the aspect ratio of the move difference. - moveRatio = Math.abs( moveDiffX / moveDiffY ); - - // Left, center or none-aligned widget. - if ( factor == 1 ) { - if ( moveDiffX <= 0 ) { - // Case: IV. - if ( moveDiffY <= 0 ) - adjustToX(); - - // Case: I. - else { - if ( moveRatio >= ratio ) - adjustToX(); - else - adjustToY(); - } - } else { - // Case: III. - if ( moveDiffY <= 0 ) { - if ( moveRatio >= ratio ) - adjustToY(); - else - adjustToX(); - } - - // Case: II. - else - adjustToY(); - } - } - - // Right-aligned widget. It mirrors behaviours, so I becomes II, - // IV becomes III and vice-versa. - else { - if ( moveDiffX <= 0 ) { - // Case: IV. - if ( moveDiffY <= 0 ) { - if ( moveRatio >= ratio ) - adjustToY(); - else - adjustToX(); - } - - // Case: I. - else - adjustToY(); - } else { - // Case: III. - if ( moveDiffY <= 0 ) - adjustToX(); - - // Case: II. - else { - if ( moveRatio >= ratio ) - adjustToX(); - else - adjustToY(); - } - } - } - - // Don't update attributes if less than 10. - // This is to prevent images to visually disappear. - if ( newWidth >= 15 && newHeight >= 15 ) { - image.setAttributes( { width: newWidth, height: newHeight } ); - updateData = true; - } else - updateData = false; - } - - function onMouseUp( evt ) { - var l; - - while ( ( l = moveListeners.pop() ) ) - l.removeListener(); - - if ( updateData ) { - widget.setData( { width: newWidth, height: newHeight } ); - - // Save another undo snapshot: after resizing. - editor.fire( 'saveSnapshot' ); - } - - // Don't update data twice or more. - updateData = false; - } - } ); - - // Change the position of the widget resizer when data changes. - widget.on( 'data', function() { - resizer[ widget.data.align == 'right' ? 'addClass' : 'removeClass' ]( 'cke_image2_resizer_left' ); - } ); - } - - // Integrates widget alignment setting with justify - // plugin's commands (execution and refreshment). - // @param {CKEDITOR.editor} editor - // @param {String} value 'left', 'right', 'center' or 'block' - function alignCommandIntegrator( editor ) { - var execCallbacks = []; - - return function( value ) { - var command = editor.getCommand( 'justify' + value ); - - // Most likely, the justify plugin isn't loaded. - if ( !command ) - return; - - // This command will be manually refreshed along with - // other commands after exec. - execCallbacks.push( function() { - command.refresh( editor, editor.elementPath() ); - } ); - - if ( value in { right:1,left:1,center:1 } ) { - command.on( 'exec', function( evt ) { - var widget = getFocusedWidget( editor ); - - if ( widget ) { - widget.setData( 'align', value ); - - // Once the widget changed its align, all the align commands - // must be refreshed: the event is to be cancelled. - for ( var i = execCallbacks.length; i--; ) - execCallbacks[ i ](); - - evt.cancel(); - } - } ); - } - - command.on( 'refresh', function( evt ) { - var widget = getFocusedWidget( editor ), - allowed = { right:1,left:1,center:1 }; - - if ( !widget ) - return; - - this.setState( - ( widget.data.align == value ) ? - CKEDITOR.TRISTATE_ON - : - ( value in allowed ) ? - CKEDITOR.TRISTATE_OFF - : - CKEDITOR.TRISTATE_DISABLED ); - - evt.cancel(); - } ); - }; - } - - // Returns the focused widget, if of the type specific for this plugin. - // If no widget is focused, `null` is returned. - // @param {CKEDITOR.editor} - // @returns {CKEDITOR.plugins.widget} - function getFocusedWidget( editor ) { - var widget = editor.widgets.focused; - - if ( widget && widget.name in { image2inline:1,image2block:1 } ) - return widget; - - return null; - } -})();
\ No newline at end of file |
