diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index fb18786b5e..4e080d02e6 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -4,21 +4,25 @@ //TEST to mock iframe, this intercepts calls directly //to the old iframe, and funnels requests to angular directly //var right = {document: {location: {}}}; -/*Object.defineProperty(right.document.location, "href", { - get: function() { - return this._href ? this._href : ""; - }, - set: function(value) { - this._href = value; - UmbClientMgr.contentFrame(value); - }, -});*/ +/**/ Umbraco.Sys.registerNamespace("Umbraco.Application"); (function($) { Umbraco.Application.ClientManager = function() { + //to support those trying to call right.document.etc + var fakeFrame = {}; + Object.defineProperty(fakeFrame, "href", { + get: function() { + return this._href ? this._href : ""; + }, + set: function(value) { + this._href = value; + UmbClientMgr.contentFrame(value); + }, + }); + /** * @ngdoc function * @name getRootScope @@ -175,6 +179,10 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); }, + getFakeFrame : function() { + return fakeFrame; + }, + /** This is used to launch an angular based modal window instead of the legacy window */ openAngularModalWindow: function (options) { diff --git a/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs b/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs index e44eae552d..e411bd907e 100644 --- a/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs +++ b/src/Umbraco.Web/Trees/LegacyTreeJavascript.cs @@ -28,7 +28,8 @@ namespace Umbraco.Web.Trees { bTree.RenderJS(ref javascript); } - return javascript.ToString(); + + return ReplaceLegacyJs(javascript.ToString()); } /// @@ -65,7 +66,14 @@ namespace Umbraco.Web.Trees js.Insert(0, "// This javascript is autogenerated by Umbraco to ensure legacy compatiblity with old context menu items\n\n"); } - return js.ToString(); + return ReplaceLegacyJs(js.ToString()); + } + + private static string ReplaceLegacyJs(string js){ + js = js.Replace("parent.right.document.location", "UmbClientMgr.getFakeFrame()"); + js = js.Replace("right.document.location", "UmbClientMgr.getFakeFrame()"); + + return js; } } } \ No newline at end of file