[REF] web_editor: update the cropper library
Just after we first added the library in Odoo (in april 2018), the library was released in its last and deprecated version (4.0.0). At the same time, the author indeed split its 'cropper' library into 2 parts: 'cropperjs' which is the core of the original library without jquery and 'jquery-cropper' which is a jquery wrapper of the 'cropperjs' library. This commit updates our code to use the latest version of those two libraries. Note: the commit also removes the lazy loading of the library which is useless and maybe breaking since it comes with the editor assets which are themself lazy loaded. Note 2: we may want to remove the jquery wrapper in another update and simply use the standard JS library. Part of https://github.com/odoo/odoo/pull/36880 task-2059480 closes odoo/odoo#36880 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2015-present Chen Fengyuan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+22
-24
@@ -1,14 +1,14 @@
|
||||
/*!
|
||||
* Cropper v3.1.4
|
||||
* https://github.com/fengyuanchen/cropper
|
||||
* Cropper.js v1.5.5
|
||||
* https://fengyuanchen.github.io/cropperjs
|
||||
*
|
||||
* Copyright (c) 2014-2018 Chen Fengyuan
|
||||
* Copyright 2015-present Chen Fengyuan
|
||||
* Released under the MIT license
|
||||
*
|
||||
* Date: 2018-01-13T09:37:21.486Z
|
||||
* Date: 2019-08-04T02:26:27.232Z
|
||||
*/
|
||||
|
||||
.cropper-container {
|
||||
.cropper-container {
|
||||
direction: ltr;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
@@ -21,8 +21,7 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cropper-container img {/*Avoid margin top issue (Occur only when margin-top <= -height)
|
||||
*/
|
||||
.cropper-container img {
|
||||
display: block;
|
||||
height: 100%;
|
||||
image-orientation: 0deg;
|
||||
@@ -57,14 +56,14 @@
|
||||
|
||||
.cropper-modal {
|
||||
background-color: #000;
|
||||
opacity: .5;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.cropper-view-box {
|
||||
display: block;
|
||||
height: 100%;
|
||||
outline-color: rgba(51, 153, 255, 0.75);
|
||||
outline: 1px solid #39f;
|
||||
outline-color: rgba(51, 153, 255, 0.75);
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -72,16 +71,16 @@
|
||||
.cropper-dashed {
|
||||
border: 0 dashed #eee;
|
||||
display: block;
|
||||
opacity: .5;
|
||||
opacity: 0.5;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.cropper-dashed.dashed-h {
|
||||
border-bottom-width: 1px;
|
||||
border-top-width: 1px;
|
||||
height: 33.33333%;
|
||||
height: calc(100% / 3);
|
||||
left: 0;
|
||||
top: 33.33333%;
|
||||
top: calc(100% / 3);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -89,37 +88,37 @@
|
||||
border-left-width: 1px;
|
||||
border-right-width: 1px;
|
||||
height: 100%;
|
||||
left: 33.33333%;
|
||||
left: calc(100% / 3);
|
||||
top: 0;
|
||||
width: 33.33333%;
|
||||
width: calc(100% / 3);
|
||||
}
|
||||
|
||||
.cropper-center {
|
||||
display: block;
|
||||
height: 0;
|
||||
left: 50%;
|
||||
opacity: .75;
|
||||
opacity: 0.75;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.cropper-center:before,
|
||||
.cropper-center:after {
|
||||
.cropper-center::before,
|
||||
.cropper-center::after {
|
||||
background-color: #eee;
|
||||
content: ' ';
|
||||
display: block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.cropper-center:before {
|
||||
.cropper-center::before {
|
||||
height: 1px;
|
||||
left: -3px;
|
||||
top: 0;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
.cropper-center:after {
|
||||
.cropper-center::after {
|
||||
height: 7px;
|
||||
left: 0;
|
||||
top: -3px;
|
||||
@@ -131,7 +130,7 @@
|
||||
.cropper-point {
|
||||
display: block;
|
||||
height: 100%;
|
||||
opacity: .1;
|
||||
opacity: 0.1;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -177,7 +176,7 @@
|
||||
.cropper-point {
|
||||
background-color: #39f;
|
||||
height: 5px;
|
||||
opacity: .75;
|
||||
opacity: 0.75;
|
||||
width: 5px;
|
||||
}
|
||||
|
||||
@@ -253,12 +252,12 @@
|
||||
@media (min-width: 1200px) {
|
||||
.cropper-point.point-se {
|
||||
height: 5px;
|
||||
opacity: .75;
|
||||
opacity: 0.75;
|
||||
width: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.cropper-point.point-se:before {
|
||||
.cropper-point.point-se::before {
|
||||
background-color: #39f;
|
||||
bottom: -50%;
|
||||
content: ' ';
|
||||
@@ -303,4 +302,3 @@
|
||||
.cropper-disabled .cropper-point {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 Chen Fengyuan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,75 @@
|
||||
/*!
|
||||
* jQuery Cropper v1.0.0
|
||||
* https://github.com/fengyuanchen/jquery-cropper
|
||||
*
|
||||
* Copyright (c) 2018 Chen Fengyuan
|
||||
* Released under the MIT license
|
||||
*
|
||||
* Date: 2018-04-01T06:20:13.168Z
|
||||
*/
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery'), require('cropperjs')) :
|
||||
typeof define === 'function' && define.amd ? define(['jquery', 'cropperjs'], factory) :
|
||||
(factory(global.jQuery,global.Cropper));
|
||||
}(this, (function ($,Cropper) { 'use strict';
|
||||
|
||||
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
|
||||
Cropper = Cropper && Cropper.hasOwnProperty('default') ? Cropper['default'] : Cropper;
|
||||
|
||||
if ($.fn) {
|
||||
var AnotherCropper = $.fn.cropper;
|
||||
var NAMESPACE = 'cropper';
|
||||
|
||||
$.fn.cropper = function jQueryCropper(option) {
|
||||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
var result = void 0;
|
||||
|
||||
this.each(function (i, element) {
|
||||
var $element = $(element);
|
||||
var isDestroy = option === 'destroy';
|
||||
var cropper = $element.data(NAMESPACE);
|
||||
|
||||
if (!cropper) {
|
||||
if (isDestroy) {
|
||||
return;
|
||||
}
|
||||
|
||||
var options = $.extend({}, $element.data(), $.isPlainObject(option) && option);
|
||||
|
||||
cropper = new Cropper(element, options);
|
||||
$element.data(NAMESPACE, cropper);
|
||||
}
|
||||
|
||||
if (typeof option === 'string') {
|
||||
var fn = cropper[option];
|
||||
|
||||
if ($.isFunction(fn)) {
|
||||
result = fn.apply(cropper, args);
|
||||
|
||||
if (result === cropper) {
|
||||
result = undefined;
|
||||
}
|
||||
|
||||
if (isDestroy) {
|
||||
$element.removeData(NAMESPACE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result !== undefined ? result : this;
|
||||
};
|
||||
|
||||
$.fn.cropper.Constructor = Cropper;
|
||||
$.fn.cropper.setDefaults = Cropper.setDefaults;
|
||||
$.fn.cropper.noConflict = function noConflict() {
|
||||
$.fn.cropper = AnotherCropper;
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
})));
|
||||
@@ -14,12 +14,6 @@ var CropImageDialog = Dialog.extend({
|
||||
xmlDependencies: Dialog.prototype.xmlDependencies.concat(
|
||||
['/web_editor/static/src/xml/wysiwyg.xml']
|
||||
),
|
||||
jsLibs: [
|
||||
'/web_editor/static/lib/cropper/js/cropper.js',
|
||||
],
|
||||
cssLibs: [
|
||||
'/web_editor/static/lib/cropper/css/cropper.css',
|
||||
],
|
||||
events: _.extend({}, Dialog.prototype.events, {
|
||||
'click .o_crop_options [data-event]': '_onCropOptionClick',
|
||||
}),
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
|
||||
<t t-call-assets="web_editor.summernote"/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/web_editor/static/lib/cropper/css/cropper.css"/>
|
||||
<script type="text/javascript" src="/web_editor/static/lib/cropper/js/cropper.js"/>
|
||||
<link rel="stylesheet" type="text/css" href="/web_editor/static/lib/cropperjs/cropper.css"/>
|
||||
<script type="text/javascript" src="/web_editor/static/lib/cropperjs/cropper.js"/>
|
||||
<script type="text/javascript" src="/web_editor/static/lib/jquery-cropper/jquery-cropper.js"/>
|
||||
<script type="text/javascript" src="/web_editor/static/lib/jQuery.transfo.js"/>
|
||||
<script type="text/javascript" src="/web_editor/static/lib/nearest/jquery.nearest.js"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user