use infinite editor in grid embed

This commit is contained in:
Mads Rasmussen
2018-08-21 19:42:49 +02:00
parent 08c1a2d095
commit dcdf21d86c
3 changed files with 29 additions and 30 deletions

View File

@@ -4,6 +4,7 @@
// -------------------------
.umb-grid IFRAME {
overflow: hidden;
width: 100%;
}

View File

@@ -1,28 +1,33 @@
angular.module("umbraco")
.controller("Umbraco.PropertyEditors.Grid.EmbedController",
function ($scope, $rootScope, $timeout) {
function ($scope, $timeout, $sce, editorService) {
function onInit() {
$scope.trustedValue = null;
$scope.trustedValue = $sce.trustAsHtml($scope.control.value);
if(!$scope.control.value) {
$timeout(function(){
if($scope.control.$initializing){
$scope.setEmbed();
}
}, 200);
}
}
$scope.setEmbed = function(){
$scope.embedDialog = {};
$scope.embedDialog.view = "embed";
$scope.embedDialog.show = true;
$scope.embedDialog.submit = function(model) {
$scope.control.value = model.embed.preview;
$scope.embedDialog.show = false;
$scope.embedDialog = null;
var embed = {
submit: function(model) {
$scope.control.value = model.embed.preview;
$scope.trustedValue = $sce.trustAsHtml(model.embed.preview);
editorService.close();
},
close: function() {
editorService.close();
}
};
editorService.embed(embed);
};
$scope.embedDialog.close = function(oldModel) {
$scope.embedDialog.show = false;
$scope.embedDialog = null;
};
};
$timeout(function(){
if($scope.control.$initializing){
$scope.setEmbed();
}
}, 200);
onInit();
});

View File

@@ -1,17 +1,10 @@
<div ng-controller="Umbraco.PropertyEditors.Grid.EmbedController">
<div class="umb-editor-placeholder" ng-click="setEmbed()" ng-if="control.value === null">
<div class="umb-editor-placeholder" ng-click="setEmbed()" ng-if="trustedValue === null">
<i class="icon icon-movie-alt"></i>
<div class="help-text"><localize key="grid_clickToEmbed">Click to embed</localize></div>
</div>
<div ng-if="control.value" ng-bind-html="control.value"></div>
<umb-overlay
ng-if="embedDialog.show"
model="embedDialog"
view="embedDialog.view"
position="right">
</umb-overlay>
<div ng-if="control.value" ng-bind-html="trustedValue"></div>
</div>