diff --git a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js index cf66236b25..d6391f0c9d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/utill.service.js @@ -5,61 +5,61 @@ * @name umbraco.services:umbImageHelper * @description A helper object used for parsing image paths **/ -function umbImageHelper() { +function umbImageHelper() { return { /** Returns the actual image path associated with the image property if there is one */ - getImagePropertyVaue: function(options) { - if (!options && !options.imageModel && !options.scope) { - throw "The options objet does not contain the required parameters: imageModel, scope"; - } - if (options.imageModel.contentTypeAlias.toLowerCase() == "image") { - var imageProp = _.find(options.imageModel.properties, function (item) { - return item.alias == 'umbracoFile'; - }); - var imageVal; - //Legacy images will be saved as a string, not an array so we will convert the legacy values - // to our required structure. - if (imageProp.value.startsWith('[')) { - imageVal = options.scope.$eval(imageProp.value); - } - else { - imageVal = [{ file: imageProp.value, isImage: this.detectIfImageByExtension(imageProp.value) }]; - } - - if (imageVal.length && imageVal.length > 0 && imageVal[0].isImage) { - return imageVal[0].file; - } - } - return ""; + getImagePropertyVaue: function(options) { + if (!options && !options.imageModel && !options.scope) { + throw "The options objet does not contain the required parameters: imageModel, scope"; + } + if (options.imageModel.contentTypeAlias.toLowerCase() == "image") { + var imageProp = _.find(options.imageModel.properties, function (item) { + return item.alias == 'umbracoFile'; + }); + var imageVal; + //Legacy images will be saved as a string, not an array so we will convert the legacy values + // to our required structure. + if (imageProp.value.startsWith('[')) { + imageVal = options.scope.$eval(imageProp.value); + } + else { + imageVal = [{ file: imageProp.value, isImage: this.detectIfImageByExtension(imageProp.value) }]; + } + + if (imageVal.length && imageVal.length > 0 && imageVal[0].isImage) { + return imageVal[0].file; + } + } + return ""; }, /** formats the display model used to display the content to the model used to save the content */ getThumbnail: function (options) { - if (!options && !options.imageModel && !options.scope) { - throw "The options objet does not contain the required parameters: imageModel, scope"; - } - + if (!options && !options.imageModel && !options.scope) { + throw "The options objet does not contain the required parameters: imageModel, scope"; + } + var imagePropVal = this.getImagePropertyVaue(options); - if (imagePropVal != "") { - return this.getThumbnailFromPath(imagePropVal); - } - return ""; - }, - getThumbnailFromPath: function(imagePath) { - var ext = imagePath.substr(imagePath.lastIndexOf('.')); - return imagePath.substr(0, imagePath.lastIndexOf('.')) + "_thumb" + ".jpg"; - }, - detectIfImageByExtension: function(imagePath) { - var lowered = imagePath; - if (lowered.endsWith(".jpg") || lowered.endsWith(".gif") || lowered.endsWith(".jpeg") || lowered.endsWith(".png")) { - return true; - } - return false; - } - }; + if (imagePropVal != "") { + return this.getThumbnailFromPath(imagePropVal); + } + return ""; + }, + getThumbnailFromPath: function(imagePath) { + var ext = imagePath.substr(imagePath.lastIndexOf('.')); + return imagePath.substr(0, imagePath.lastIndexOf('.')) + "_thumb" + ".jpg"; + }, + detectIfImageByExtension: function(imagePath) { + var lowered = imagePath; + if (lowered.endsWith(".jpg") || lowered.endsWith(".gif") || lowered.endsWith(".jpeg") || lowered.endsWith(".png")) { + return true; + } + return false; + } + }; } -angular.module('umbraco.services').factory('umbImageHelper', umbImageHelper); - +angular.module('umbraco.services').factory('umbImageHelper', umbImageHelper); + /** * @ngdoc factory * @name umbraco.services:umbRequestHelper @@ -68,47 +68,47 @@ angular.module('umbraco.services').factory('umbImageHelper', umbImageHelper); function umbRequestHelper($http, $q, umbDataFormatter) { return { - postSaveContent: function (restApiUrl, content, action, files) { - var deferred = $q.defer(); - - //save the active tab id so we can set it when the data is returned. - var activeTab = _.find(content.tabs, function (item) { - return item.active; - }); - var activeTabIndex = (activeTab === undefined ? 0 : _.indexOf(content.tabs, activeTab)); - - //save the data - this.postMultiPartRequest( - restApiUrl, - { key: "contentItem", value: umbDataFormatter.formatContentPostData(content, action) }, - function (data, formData) { - //now add all of the assigned files - for (var f in files) { - //each item has a property id and the file object, we'll ensure that the id is suffixed to the key - // so we know which property it belongs to on the server side - formData.append("file_" + files[f].id, files[f].file); - } - - }, - function (data, status, headers, config) { - //success callback - - //reset the tabs and set the active one - _.each(data.tabs, function (item) { - item.active = false; - }); - data.tabs[activeTabIndex].active = true; - - //the data returned is the up-to-date data so the UI will refresh - deferred.resolve(data); - }, - function (data, status, headers, config) { - //failure callback - - deferred.reject('Failed to save data for media id ' + content.id); - }); - - return deferred.promise; + postSaveContent: function (restApiUrl, content, action, files) { + var deferred = $q.defer(); + + //save the active tab id so we can set it when the data is returned. + var activeTab = _.find(content.tabs, function (item) { + return item.active; + }); + var activeTabIndex = (activeTab === undefined ? 0 : _.indexOf(content.tabs, activeTab)); + + //save the data + this.postMultiPartRequest( + restApiUrl, + { key: "contentItem", value: umbDataFormatter.formatContentPostData(content, action) }, + function (data, formData) { + //now add all of the assigned files + for (var f in files) { + //each item has a property id and the file object, we'll ensure that the id is suffixed to the key + // so we know which property it belongs to on the server side + formData.append("file_" + files[f].id, files[f].file); + } + + }, + function (data, status, headers, config) { + //success callback + + //reset the tabs and set the active one + _.each(data.tabs, function (item) { + item.active = false; + }); + data.tabs[activeTabIndex].active = true; + + //the data returned is the up-to-date data so the UI will refresh + deferred.resolve(data); + }, + function (data, status, headers, config) { + //failure callback + + deferred.reject('Failed to save data for media id ' + content.id); + }); + + return deferred.promise; }, /** Posts a multi-part mime request to the server */ @@ -254,12 +254,14 @@ angular.module('umbraco.services').factory('umbFormHelper', umbFormHelper); function treeIconHelper() { var converter = [ - { oldIcon: ".sprTreeFolder", newIcon: "icon-folder-close" }, - { oldIcon: ".sprTreeFolder_o", newIcon: "icon-folder-open" }, - { oldIcon: ".sprTreeMediaFile", newIcon: "icon-music" }, - { oldIcon: ".sprTreeMediaMovie", newIcon: "icon-movie" }, - { oldIcon: ".sprTreeMediaPhoto", newIcon: "icon-picture" } - ]; + { oldIcon: ".sprTreeSettingDomain", newIcon: "icon-home" }, + { oldIcon: ".sprTreeDoc", newIcon: "icon-file-alt" }, + { oldIcon: ".sprTreeFolder", newIcon: "icon-folder-close" }, + { oldIcon: ".sprTreeFolder_o", newIcon: "icon-folder-open" }, + { oldIcon: ".sprTreeMediaFile", newIcon: "icon-music" }, + { oldIcon: ".sprTreeMediaMovie", newIcon: "icon-movie" }, + { oldIcon: ".sprTreeMediaPhoto", newIcon: "icon-picture" } + ]; return { /** If the tree node has a legacy icon */