/
rte.controller.js
42 lines (36 loc) · 1.31 KB
/
rte.controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
angular.module("umbraco").controller("UIOMatic.FieldEditors.RTE", function ($scope) {
function init() {
var rowProps = $scope.property || { value : "" };
// RTE doesn't like value being undefined, so if it is, set it to empty string
if (rowProps.value == undefined)
rowProps.value = "";
$scope.property = {
alias: 'UIOMatic.FieldEditors.RTE',
view: 'rte',
config: {
editor: {
toolbar: JSON.parse(Umbraco.Sys.ServerVariables.uioMatic.settings.rteFieldEditorButtons),
stylesheets: [],
dimensions: { height: 400, width: '100%' }
}
},
value: rowProps.value
};
$scope.$watch('property', function () {
if ($scope.property != undefined) {
var result = $.grep($scope.properties, function (e) { return e.key === rowProps.key; });
if (result != null && result.length > 0) {
result[0].value = $scope.property.value;
}
}
}, true);
}
if ($scope.valuesLoaded) {
init();
} else {
var unsubscribe = $scope.$on('valuesLoaded', function () {
init();
unsubscribe();
});
}
});