diff --git a/UmbracoPackages/App_Plugins/brothers.uNesting/elements.json b/UmbracoPackages/App_Plugins/brothers.uNesting/elements.json
new file mode 100644
index 0000000..10b4376
--- /dev/null
+++ b/UmbracoPackages/App_Plugins/brothers.uNesting/elements.json
@@ -0,0 +1,15 @@
+{
+ "text": {
+ "html": "text"
+ },
+ "button": {
+ "text": "text",
+ "link": "url"
+ },
+ "images": {
+ "items": "media"
+ },
+ "xblocks": {
+ "items": "list"
+ }
+}
\ No newline at end of file
diff --git a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.controller.js b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.controller.js
index 9f8575e..4ba2a6b 100644
--- a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.controller.js
+++ b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.controller.js
@@ -1,26 +1,101 @@
-angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController", function ($scope, $controller)
+angular.module("umbraco").controller("brothers.uNesting.PropertyEditorController", function ($scope, $controller, $http)
{
angular.extend(this, $controller('Umbraco.PropertyEditors.NestedContent.PropertyEditorController', { $scope: $scope }));
- $scope.getView = function (node, idx)
+ var elementsConfig = {};
+
+ var init = function ()
{
- if ($scope.model.value[idx])
+ $http.get("/App_Plugins/brothers.uNesting/elements.json").then(function (res)
{
- var contentType = $scope.getContentTypeConfig($scope.model.value[idx].ncContentTypeAlias);
+ elementsConfig = res.data;
- if (contentType !== null && contentType.nameExp)
+ _.each($scope.nodes, function (node, idx)
{
- // Run the expression against the stored dictionary value, NOT the node object
- var item = $scope.model.value[idx];
- var newName = contentType.nameExp(item);
+ node.uNestingContent = getContent(node, $scope.model.value[idx], elementsConfig[node.contentTypeAlias]);
+ });
+ });
+ };
- if (newName && (newName = $.trim(newName)))
+ $scope.$watch("inited", function (newVal)
+ {
+ if (newVal)
+ {
+ init();
+ }
+ });
+
+ var getContent = function (node, item, config)
+ {
+ if (!item)
+ {
+ return '';
+ }
+ if (!config)
+ {
+ return node.documentType.description;
+ }
+
+ var lines = [];
+
+ _.each(config, function (type, alias)
+ {
+ var value = item[alias];
+ if (value)
+ {
+ if (type === 'text')
{
- return newName;
+ lines.push(stripHtml(value));
+ }
+ if (type === 'url')
+ {
+ lines.push(value[0].url);
}
}
+ });
+
+ if (lines.length < 1)
+ {
+ return node.documentType.description;
+ }
+ else
+ {
+ return lines.join('
');
}
- return node.documentType.description || 'Enter data ...';
};
+
+
+ var stripHtml = function (html)
+ {
+ if (!html)
+ {
+ return '';
+ }
+
+ var stripped = html.replace('
', ' ').replace('
', ' ').replace('
', ' ').replace(/<[^>]+>/gm, '');
+
+ return stripped.length > 120 ? (stripped.substring(0, 120) + '...') : stripped;
+ };
+
+ //$scope.getView = function (node, idx)
+ //{
+ // if ($scope.model.value[idx])
+ // {
+ // var contentType = $scope.getContentTypeConfig($scope.model.value[idx].ncContentTypeAlias);
+
+ // if (contentType !== null && contentType.nameExp)
+ // {
+ // // Run the expression against the stored dictionary value, NOT the node object
+ // var item = $scope.model.value[idx];
+ // var newName = contentType.nameExp(item);
+
+ // if (newName && (newName = $.trim(newName)))
+ // {
+ // return newName;
+ // }
+ // }
+ // }
+ // return node.documentType.description || 'Enter data ...';
+ //};
});
\ No newline at end of file
diff --git a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.css b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.css
index f1396f3..08bb538 100644
--- a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.css
+++ b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.css
@@ -72,6 +72,7 @@
{
color: #817f85;
font-size: 13px;
+ overflow: hidden;
}
/* icons */
diff --git a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.html b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.html
index c0c5681..799c8d1 100644
--- a/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.html
+++ b/UmbracoPackages/App_Plugins/brothers.uNesting/uNesting.html
@@ -22,7 +22,7 @@