From ecafdddeadca5a01aef2847ef076ce0114af80c7 Mon Sep 17 00:00:00 2001 From: Dave Woestenborghs Date: Tue, 9 Mar 2021 12:13:26 +0100 Subject: [PATCH] Make compatible with V8 2 small changes to make it compatible with Umbraco V8 In 8 tabs are not stored on the current editorState but on the variants property. So updated the code to get them from the active variant when there is a variants property on the editorState. jQuery load is deprecated in the version used in V8. So updated that as well. I did not test my changes on V7. --- .../ImageColorPicker.Controller.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/App_Plugins/our.umbraco.imagecolorpicker/ImageColorPicker.Controller.js b/src/App_Plugins/our.umbraco.imagecolorpicker/ImageColorPicker.Controller.js index ffce40d..696bcf0 100644 --- a/src/App_Plugins/our.umbraco.imagecolorpicker/ImageColorPicker.Controller.js +++ b/src/App_Plugins/our.umbraco.imagecolorpicker/ImageColorPicker.Controller.js @@ -22,7 +22,19 @@ $scope.getMediaId = function (alias) { if (editorState.current) { - var tabs = editorState.current.tabs; + var tabs = []; + + if(editorState.current.variants) { + // V8 tabs from active variant + tabs = _.find(editorState.current.variants, function(v) { + return v.active; + }).tabs; + } + else { + // V7 + tabs = editorState.current.tabs; + } + var id = null; var prop = null; @@ -57,7 +69,7 @@ var image = new Image(); image.src = $scope.imageSrc; - $(image).load(function () { + $(image).on('load', function () { //set the height either from configuration or defaults if ($scope.model.config.width && $scope.model.config.height) { @@ -158,4 +170,4 @@ $scope.init(); -}); \ No newline at end of file +});