diff --git a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.controllers.js b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.controllers.js index 05a07b1..72d4aac 100644 --- a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.controllers.js +++ b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.controllers.js @@ -1,4 +1,4 @@ -angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.DocTypePickerController", [ +angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.DocTypePickerController", [ "$scope", "Our.Umbraco.NestedContent.Resources.NestedContentResources", @@ -8,7 +8,7 @@ $scope.add = function () { $scope.model.value.push({ // As per PR #4, all stored content type aliases must be prefixed "nc" for easier recognition. - // For good measure we'll also prefix the tab alias "nc" + // For good measure we'll also prefix the tab alias "nc" ncAlias: "", ncTabAlias: "", nameTemplate: "" @@ -305,7 +305,7 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest var initIfAllScaffoldsHaveLoaded = function () { // Initialize when all scaffolds have loaded if ($scope.model.config.contentTypes.length == scaffoldsLoaded) { - // Because we're loading the scaffolds async one at a time, we need to + // Because we're loading the scaffolds async one at a time, we need to // sort them explicitly according to the sort order defined by the data type. var contentTypeAliases = []; _.each($scope.model.config.contentTypes, function (contentType) { @@ -356,7 +356,7 @@ angular.module("umbraco").controller("Our.Umbraco.NestedContent.Controllers.Nest var prop = tab.properties[p]; prop.propertyAlias = prop.alias; prop.alias = $scope.model.alias + "___" + prop.alias; - // Force validation to occur server side as this is the + // Force validation to occur server side as this is the // only way we can have consistancy between mandatory and // regex validation messages. Not ideal, but it works. prop.validation = { diff --git a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.directives.js b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.directives.js index 01e3794..a2fc50c 100644 --- a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.directives.js +++ b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.directives.js @@ -1,6 +1,8 @@ angular.module("umbraco.directives").directive('nestedContentEditor', [ - function () { + "Our.Umbraco.NestedContent.Services.NestedContentCallbacks", + + function (NestedContentCallbacks) { var link = function ($scope) { @@ -29,6 +31,9 @@ var unsubscribe = $scope.$on("ncSyncVal", function (ev, args) { if (args.id === $scope.model.id) { + // Run callback + NestedContentCallbacks.call("ncBeforeFormSubmitting", { scope: $scope }); + // Tell inner controls we are submitting $scope.$broadcast("formSubmitting", { scope: $scope }); @@ -94,4 +99,4 @@ // }, // link: link // } -//}); \ No newline at end of file +//}); diff --git a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.services.js b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.services.js new file mode 100644 index 0000000..cfbf763 --- /dev/null +++ b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/Js/nestedcontent.services.js @@ -0,0 +1,25 @@ +angular.module('umbraco.services').factory('Our.Umbraco.NestedContent.Services.NestedContentCallbacks', + + function() { + // Define available callbacks + var callbacks = { + 'ncBeforeFormSubmitting': [] + }; + + return { + + callbacks: callbacks, + + call: function(cb, args) { + cb = this.callbacks[cb]; + if ( cb && Array.isArray(cb) && cb.length ) { + cb.forEach(function(func) { + typeof func != "function" || func(args); + }); + } + } + + }; + } + +); diff --git a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/package.manifest b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/package.manifest index 62fa763..a475a70 100644 --- a/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/package.manifest +++ b/src/Our.Umbraco.NestedContent/Web/UI/App_Plugins/NestedContent/package.manifest @@ -3,7 +3,8 @@ '~/App_Plugins/NestedContent/Js/nestedcontent.filters.js', '~/App_Plugins/NestedContent/Js/nestedcontent.resources.js', '~/App_Plugins/NestedContent/Js/nestedcontent.directives.js', - '~/App_Plugins/NestedContent/Js/nestedcontent.controllers.js' + '~/App_Plugins/NestedContent/Js/nestedcontent.controllers.js', + '~/App_Plugins/NestedContent/Js/nestedcontent.services.js' ], "css" : [ "~/App_Plugins/NestedContent/Css/nestedcontent.css"