mirror of
https://github.com/moodle/moodle.git
synced 2025-04-11 11:23:52 +02:00
Merge branch 'MDL-72884' of git://github.com/paulholden/moodle
This commit is contained in:
commit
ad7a38872d
lib/editor/atto/plugins/image/yui
build/moodle-atto_image-button
src/button/js
27
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js
vendored
27
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-debug.js
vendored
@ -92,7 +92,10 @@ var CSS = {
|
||||
margin: '0 0 0 0.5em'
|
||||
}
|
||||
],
|
||||
|
||||
DEFAULTS = {
|
||||
WIDTH: 160,
|
||||
HEIGHT: 160,
|
||||
},
|
||||
REGEX = {
|
||||
ISPERCENT: /\d+%/
|
||||
},
|
||||
@ -550,22 +553,23 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
image.onload = function() {
|
||||
var input, currentwidth, currentheight, widthRatio, heightRatio;
|
||||
|
||||
// Store dimensions of the raw image, falling back to defaults for images without dimensions (e.g. SVG).
|
||||
self._rawImageDimensions = {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
width: this.width || DEFAULTS.WIDTH,
|
||||
height: this.height || DEFAULTS.HEIGHT,
|
||||
};
|
||||
|
||||
input = self._form.one('.' + CSS.INPUTWIDTH);
|
||||
currentwidth = input.get('value');
|
||||
if (currentwidth === '') {
|
||||
input.set('value', this.width);
|
||||
currentwidth = "" + this.width;
|
||||
input.set('value', self._rawImageDimensions.width);
|
||||
currentwidth = "" + self._rawImageDimensions.width;
|
||||
}
|
||||
input = self._form.one('.' + CSS.INPUTHEIGHT);
|
||||
currentheight = input.get('value');
|
||||
if (currentheight === '') {
|
||||
input.set('value', this.height);
|
||||
currentheight = "" + this.height;
|
||||
input.set('value', self._rawImageDimensions.height);
|
||||
currentheight = "" + self._rawImageDimensions.height;
|
||||
}
|
||||
input = self._form.one('.' + CSS.IMAGEPREVIEW);
|
||||
input.setAttribute('src', this.src);
|
||||
@ -576,13 +580,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
input = self._form.one('.' + CSS.INPUTCONSTRAIN);
|
||||
if (currentwidth.match(REGEX.ISPERCENT) && currentheight.match(REGEX.ISPERCENT)) {
|
||||
input.set('checked', currentwidth === currentheight);
|
||||
} else if (this.width === 0 || this.height === 0) {
|
||||
// If we don't have both dimensions of the image, we can't auto-size it, so disable control.
|
||||
input.set('disabled', 'disabled');
|
||||
} else {
|
||||
if (this.width === 0) {
|
||||
this.width = 1;
|
||||
}
|
||||
if (this.height === 0) {
|
||||
this.height = 1;
|
||||
}
|
||||
// This is the same as comparing to 3 decimal places.
|
||||
widthRatio = Math.round(1000 * parseInt(currentwidth, 10) / this.width);
|
||||
heightRatio = Math.round(1000 * parseInt(currentheight, 10) / this.height);
|
||||
|
6
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js
vendored
6
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button-min.js
vendored
File diff suppressed because one or more lines are too long
27
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js
vendored
27
lib/editor/atto/plugins/image/yui/build/moodle-atto_image-button/moodle-atto_image-button.js
vendored
@ -92,7 +92,10 @@ var CSS = {
|
||||
margin: '0 0 0 0.5em'
|
||||
}
|
||||
],
|
||||
|
||||
DEFAULTS = {
|
||||
WIDTH: 160,
|
||||
HEIGHT: 160,
|
||||
},
|
||||
REGEX = {
|
||||
ISPERCENT: /\d+%/
|
||||
},
|
||||
@ -550,22 +553,23 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
image.onload = function() {
|
||||
var input, currentwidth, currentheight, widthRatio, heightRatio;
|
||||
|
||||
// Store dimensions of the raw image, falling back to defaults for images without dimensions (e.g. SVG).
|
||||
self._rawImageDimensions = {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
width: this.width || DEFAULTS.WIDTH,
|
||||
height: this.height || DEFAULTS.HEIGHT,
|
||||
};
|
||||
|
||||
input = self._form.one('.' + CSS.INPUTWIDTH);
|
||||
currentwidth = input.get('value');
|
||||
if (currentwidth === '') {
|
||||
input.set('value', this.width);
|
||||
currentwidth = "" + this.width;
|
||||
input.set('value', self._rawImageDimensions.width);
|
||||
currentwidth = "" + self._rawImageDimensions.width;
|
||||
}
|
||||
input = self._form.one('.' + CSS.INPUTHEIGHT);
|
||||
currentheight = input.get('value');
|
||||
if (currentheight === '') {
|
||||
input.set('value', this.height);
|
||||
currentheight = "" + this.height;
|
||||
input.set('value', self._rawImageDimensions.height);
|
||||
currentheight = "" + self._rawImageDimensions.height;
|
||||
}
|
||||
input = self._form.one('.' + CSS.IMAGEPREVIEW);
|
||||
input.setAttribute('src', this.src);
|
||||
@ -576,13 +580,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
input = self._form.one('.' + CSS.INPUTCONSTRAIN);
|
||||
if (currentwidth.match(REGEX.ISPERCENT) && currentheight.match(REGEX.ISPERCENT)) {
|
||||
input.set('checked', currentwidth === currentheight);
|
||||
} else if (this.width === 0 || this.height === 0) {
|
||||
// If we don't have both dimensions of the image, we can't auto-size it, so disable control.
|
||||
input.set('disabled', 'disabled');
|
||||
} else {
|
||||
if (this.width === 0) {
|
||||
this.width = 1;
|
||||
}
|
||||
if (this.height === 0) {
|
||||
this.height = 1;
|
||||
}
|
||||
// This is the same as comparing to 3 decimal places.
|
||||
widthRatio = Math.round(1000 * parseInt(currentwidth, 10) / this.width);
|
||||
heightRatio = Math.round(1000 * parseInt(currentheight, 10) / this.height);
|
||||
|
@ -90,7 +90,10 @@ var CSS = {
|
||||
margin: '0 0 0 0.5em'
|
||||
}
|
||||
],
|
||||
|
||||
DEFAULTS = {
|
||||
WIDTH: 160,
|
||||
HEIGHT: 160,
|
||||
},
|
||||
REGEX = {
|
||||
ISPERCENT: /\d+%/
|
||||
},
|
||||
@ -548,22 +551,23 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
image.onload = function() {
|
||||
var input, currentwidth, currentheight, widthRatio, heightRatio;
|
||||
|
||||
// Store dimensions of the raw image, falling back to defaults for images without dimensions (e.g. SVG).
|
||||
self._rawImageDimensions = {
|
||||
width: this.width,
|
||||
height: this.height
|
||||
width: this.width || DEFAULTS.WIDTH,
|
||||
height: this.height || DEFAULTS.HEIGHT,
|
||||
};
|
||||
|
||||
input = self._form.one('.' + CSS.INPUTWIDTH);
|
||||
currentwidth = input.get('value');
|
||||
if (currentwidth === '') {
|
||||
input.set('value', this.width);
|
||||
currentwidth = "" + this.width;
|
||||
input.set('value', self._rawImageDimensions.width);
|
||||
currentwidth = "" + self._rawImageDimensions.width;
|
||||
}
|
||||
input = self._form.one('.' + CSS.INPUTHEIGHT);
|
||||
currentheight = input.get('value');
|
||||
if (currentheight === '') {
|
||||
input.set('value', this.height);
|
||||
currentheight = "" + this.height;
|
||||
input.set('value', self._rawImageDimensions.height);
|
||||
currentheight = "" + self._rawImageDimensions.height;
|
||||
}
|
||||
input = self._form.one('.' + CSS.IMAGEPREVIEW);
|
||||
input.setAttribute('src', this.src);
|
||||
@ -574,13 +578,10 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
input = self._form.one('.' + CSS.INPUTCONSTRAIN);
|
||||
if (currentwidth.match(REGEX.ISPERCENT) && currentheight.match(REGEX.ISPERCENT)) {
|
||||
input.set('checked', currentwidth === currentheight);
|
||||
} else if (this.width === 0 || this.height === 0) {
|
||||
// If we don't have both dimensions of the image, we can't auto-size it, so disable control.
|
||||
input.set('disabled', 'disabled');
|
||||
} else {
|
||||
if (this.width === 0) {
|
||||
this.width = 1;
|
||||
}
|
||||
if (this.height === 0) {
|
||||
this.height = 1;
|
||||
}
|
||||
// This is the same as comparing to 3 decimal places.
|
||||
widthRatio = Math.round(1000 * parseInt(currentwidth, 10) / this.width);
|
||||
heightRatio = Math.round(1000 * parseInt(currentheight, 10) / this.height);
|
||||
|
Loading…
x
Reference in New Issue
Block a user