diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 80404e528f..509e5ad01e 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -372,6 +372,35 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { 'Failed to retreive data for empty content item type ' + alias); }, + /** + * @ngdoc method + * @name umbraco.resources.contentResource#getNiceUrl + * @methodOf umbraco.resources.contentResource + * + * @description + * Returns a url, given a node ID + * + * ##usage + *
+ * contentResource.getNiceUrl()
+ * .then(function(stylesheets) {
+ * alert('its here!');
+ * });
+ *
+ *
+ * @param {Int} id Id of node to return the public url to
+ * @returns {Promise} resourcePromise object containing the url.
+ *
+ */
+ getNiceUrl: function (id) {
+ return umbRequestHelper.resourcePromise(
+ $http.get(
+ umbRequestHelper.getApiUrl(
+ "contentApiBaseUrl",
+ "GetNiceUrl",[{id: id}])),
+ 'Failed to retrieve url for id:' + id);
+ },
+
/**
* @ngdoc method
* @name umbraco.resources.contentResource#getChildren
diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js
index 9956ebf723..0d83028cc3 100644
--- a/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js
+++ b/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js
@@ -12,34 +12,7 @@ function publishedContentResource($q, $http, umbRequestHelper) {
//the factory object returned
return {
- /**
- * @ngdoc method
- * @name umbraco.resources.publishedContentResource#getUrl
- * @methodOf umbraco.resources.publishedContentResource
- *
- * @description
- * Returns a url, given a node ID
- *
- * ##usage
- *
- * publishedContentResource.getUrl()
- * .then(function(stylesheets) {
- * alert('its here!');
- * });
- *
- *
- * @param {Int} id Id of node to return the public url to
- * @returns {Promise} resourcePromise object containing the url.
- *
- */
- getUrl: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "publishedContentApiBaseUrl",
- "GetUrl",[{id: id}])),
- 'Failed to retreive url for id:' + id);
- }
+
};
}
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js
index 422a0546a7..08f1690a1b 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js
@@ -318,6 +318,24 @@ angular.module('umbraco.services')
return openDialog(options);
},
+ /**
+ * @ngdoc method
+ * @name umbraco.services.dialogService#linkPicker
+ * @methodOf umbraco.services.dialogService
+ *
+ * @description
+ * Opens a link picker tree in a modal, the callback returns a single link
+ * @param {Object} options content picker dialog options object
+ * @param {$scope} options.scope dialog scope
+ * @param {Function} options.callback callback function
+ * @returns {Object} modal object
+ */
+ linkPicker: function (options) {
+ options.template = 'views/common/dialogs/linkPicker.html';
+ options.show = true;
+ return openDialog(options);
+ },
+
/**
* @ngdoc method
* @name umbraco.services.dialogService#macroPicker
diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js
index e3f992c88e..04f371fd90 100644
--- a/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js
+++ b/src/Umbraco.Web.UI.Client/src/common/services/tinymce.service.js
@@ -102,6 +102,38 @@ function tinyMceService(dialogService, $log, imageHelper, $http, $timeout, macro
});
},
+ /**
+ * @ngdoc method
+ * @name umbraco.services.tinyMceService#createLinkPicker
+ * @methodOf umbraco.services.tinyMceService
+ *
+ * @description
+ * Creates the umbrco insert link tinymce plugin
+ *
+ * @param {Object} editor the TinyMCE editor instance
+ * @param {Object} $scope the current controller scope
+ */
+ createLinkPicker: function (editor, $scope) {
+ editor.addButton('link', {
+ icon: 'custom icon-link',
+ tooltip: 'Link Picker',
+ onclick: function () {
+ dialogService.linkPicker({
+ scope: $scope, callback: function (link) {
+ if (link) {
+ var data = {
+ title: "Some description",
+ href: "",
+ id: '__mcenew'
+ };
+ editor.insertContent(editor.dom.createHTML('a', data));
+ }
+ }
+ });
+ }
+ });
+ },
+
/**
* @ngdoc method
* @name umbraco.services.tinyMceService#createUmbracoMacro
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
index d5d954b600..f8629dc6cd 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js
@@ -1,8 +1,10 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
- function ($scope, eventsService, $log) {
+ function ($scope, eventsService, contentResource, $log) {
var dialogOptions = $scope.$parent.dialogOptions;
+
$scope.dialogTreeEventHandler = $({});
+ $scope.target = {};
$scope.dialogTreeEventHandler.bind("treeNodeSelect", function(ev, args){
args.event.preventDefault();
@@ -15,11 +17,19 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController",
$scope.selectedEl.find("i.umb-tree-icon").show();
}
- c.find("i.umb-tree-icon").hide()
- .after("");
+ c.find("i.umb-tree-icon")
+ .hide()
+ .after("");
- $scope.target = args.node;
$scope.selectedEl = c;
+ $scope.target = args.node;
+ $scope.target.title = args.node.name;
+
+ if(args.node.id < 0){
+ $scope.target.url = "/";
+ }else{
+ $scope.target.url = contentResource.getNiceUrl(args.node.id);
+ }
});
});
diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
index 51ad6cf783..ff471b6a43 100644
--- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
+++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.html
@@ -1,5 +1,5 @@