Update to the embed rte plugin, adds code that makes the resize work

This commit is contained in:
Tim Geyssens
2013-09-18 14:52:03 +02:00
parent 44e7a915b4
commit 8eb07963ec
2 changed files with 24 additions and 2 deletions

View File

@@ -5,7 +5,9 @@
$scope.constrain = true;
$scope.preview = "";
$scope.success = false;
var origWidth = 500;
var origHeight = 300;
$scope.showPreview = function(){
if ($scope.url != "") {
@@ -26,6 +28,26 @@
};
$scope.changeSize = function (type) {
var width, height;
if ($scope.constrain) {
width = parseInt($scope.width, 10);
height = parseInt($scope.height, 10);
if (type == 'width') {
origHeight = Math.round((width / origWidth) * height);
$scope.height = origHeight;
} else {
origWidth = Math.round((height / origHeight) * width);
$scope.width = origWidth;
}
}
if ($scope.url != "") {
$scope.showPreview();
}
};
$scope.insert = function(){
$scope.submit($scope.preview);
};

View File

@@ -16,7 +16,7 @@
<input id="url" type="text" ng-model="url" ng-change="showPreview()"/>
<label>Size:</label>
<input type="text" ng-model="width"/> x <input type="text" ng-model="height" />
<input type="text" ng-model="width" on-blur="changeSize('width')"/> x <input type="text" ng-model="height" on-blur="changeSize('height')"/>
<label for="constrain">Constrain:</label>
<input id="constrain" type="checkbox" ng-model="constrain"/>