Add WebCms
This commit is contained in:
@@ -0,0 +1,335 @@
|
||||
(function () {
|
||||
|
||||
//JavaScript extension methods on the core JavaScript objects (like String, Date, etc...)
|
||||
if (!Date.prototype.toIsoDateTimeString) {
|
||||
/** Converts a Date object to a globally acceptable ISO string, NOTE: This is different from the built in
|
||||
JavaScript toISOString method which returns date/time like "2013-08-07T02:04:11.487Z" but we want "yyyy-MM-dd HH:mm:ss" */
|
||||
Date.prototype.toIsoDateTimeString = function (str) {
|
||||
var month = (this.getMonth() + 1).toString();
|
||||
if (month.length === 1) {
|
||||
month = "0" + month;
|
||||
}
|
||||
var day = this.getDate().toString();
|
||||
if (day.length === 1) {
|
||||
day = "0" + day;
|
||||
}
|
||||
var hour = this.getHours().toString();
|
||||
if (hour.length === 1) {
|
||||
hour = "0" + hour;
|
||||
}
|
||||
var mins = this.getMinutes().toString();
|
||||
if (mins.length === 1) {
|
||||
mins = "0" + mins;
|
||||
}
|
||||
var secs = this.getSeconds().toString();
|
||||
if (secs.length === 1) {
|
||||
secs = "0" + secs;
|
||||
}
|
||||
return this.getFullYear() + "-" + month + "-" + day + " " + hour + ":" + mins + ":" + secs;
|
||||
};
|
||||
}
|
||||
|
||||
if (!Date.prototype.toIsoDateString) {
|
||||
/** Converts a Date object to a globally acceptable ISO string, NOTE: This is different from the built in
|
||||
JavaScript toISOString method which returns date/time like "2013-08-07T02:04:11.487Z" but we want "yyyy-MM-dd" */
|
||||
Date.prototype.toIsoDateString = function (str) {
|
||||
var month = (this.getMonth() + 1).toString();
|
||||
if (month.length === 1) {
|
||||
month = "0" + month;
|
||||
}
|
||||
var day = this.getDate().toString();
|
||||
if (day.length === 1) {
|
||||
day = "0" + day;
|
||||
}
|
||||
|
||||
return this.getFullYear() + "-" + month + "-" + day;
|
||||
};
|
||||
}
|
||||
|
||||
//create guid method on the String
|
||||
if (String.CreateGuid == null) {
|
||||
|
||||
/** generates a new Guid */
|
||||
String.CreateGuid = function () {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
if (!window.__debug__) {
|
||||
|
||||
/** global method to send debug statements to console that is cross browser (or at least checks if its possible)*/
|
||||
window.__debug__ = function (msg, category, isErr) {
|
||||
if (((typeof console) != "undefined") && console.log && console.error) {
|
||||
if (isErr) console.error(category + ": " + msg);
|
||||
else console.log(category + ": " + msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
/** startsWith extension method for string */
|
||||
String.prototype.startsWith = function (str) {
|
||||
return this.substr(0, str.length) === str;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.endsWith) {
|
||||
|
||||
/** endsWith extension method for string*/
|
||||
String.prototype.endsWith = function (str) {
|
||||
return this.substr(this.length - str.length) === str;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.trimStart) {
|
||||
|
||||
/** trims the start of the string*/
|
||||
String.prototype.trimStart = function (str) {
|
||||
if (this.startsWith(str)) {
|
||||
return this.substring(str.length);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.trimEnd) {
|
||||
|
||||
/** trims the end of the string*/
|
||||
String.prototype.trimEnd = function (str) {
|
||||
if (this.endsWith(str)) {
|
||||
return this.substring(0, this.length - str.length);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.utf8Encode) {
|
||||
|
||||
/** UTF8 encoder for string*/
|
||||
String.prototype.utf8Encode = function () {
|
||||
var str = this.replace(/\r\n/g, "\n");
|
||||
var utftext = "";
|
||||
for (var n = 0; n < str.length; n++) {
|
||||
var c = str.charCodeAt(n);
|
||||
if (c < 128) {
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
else if ((c > 127) && (c < 2048)) {
|
||||
utftext += String.fromCharCode((c >> 6) | 192);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
else {
|
||||
utftext += String.fromCharCode((c >> 12) | 224);
|
||||
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
||||
utftext += String.fromCharCode((c & 63) | 128);
|
||||
}
|
||||
}
|
||||
return utftext;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.utf8Decode) {
|
||||
|
||||
/** UTF8 decoder for string*/
|
||||
String.prototype.utf8Decode = function () {
|
||||
var utftext = this;
|
||||
var string = "";
|
||||
var i = 0;
|
||||
var c = c1 = c2 = 0;
|
||||
|
||||
while (i < utftext.length) {
|
||||
|
||||
c = utftext.charCodeAt(i);
|
||||
|
||||
if (c < 128) {
|
||||
string += String.fromCharCode(c);
|
||||
i++;
|
||||
}
|
||||
else if ((c > 191) && (c < 224)) {
|
||||
c2 = utftext.charCodeAt(i + 1);
|
||||
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
||||
i += 2;
|
||||
}
|
||||
else {
|
||||
c2 = utftext.charCodeAt(i + 1);
|
||||
c3 = utftext.charCodeAt(i + 2);
|
||||
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
||||
i += 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return string;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.base64Encode) {
|
||||
|
||||
/** Base64 encoder for string*/
|
||||
String.prototype.base64Encode = function () {
|
||||
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
var input = this.utf8Encode();
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
} else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output +
|
||||
keyStr.charAt(enc1) + keyStr.charAt(enc2) +
|
||||
keyStr.charAt(enc3) + keyStr.charAt(enc4);
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.base64Decode) {
|
||||
|
||||
/** Base64 decoder for string*/
|
||||
String.prototype.base64Decode = function () {
|
||||
|
||||
var input = this;
|
||||
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
enc1 = keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output.utf8Decode();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (!Math.randomRange) {
|
||||
|
||||
/** randomRange extension for math*/
|
||||
Math.randomRange = function (from, to) {
|
||||
return Math.floor(Math.random() * (to - from + 1) + from);
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.toCamelCase) {
|
||||
|
||||
/** toCamelCase extension method for string*/
|
||||
String.prototype.toCamelCase = function () {
|
||||
|
||||
var s = this.toPascalCase();
|
||||
if ($.trim(s) == "")
|
||||
return "";
|
||||
if (s.length > 1) {
|
||||
var regex = /^([A-Z]*)([A-Z].*)/g;
|
||||
if (s.match(regex)) {
|
||||
var match = regex.exec(s);
|
||||
s = match[1].toLowerCase() + match[2];
|
||||
s = s.substr(0, 1).toLowerCase() + s.substr(1);
|
||||
}
|
||||
} else {
|
||||
s = s.toLowerCase();
|
||||
}
|
||||
return s;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.toPascalCase) {
|
||||
|
||||
/** toPascalCase extension method for string*/
|
||||
String.prototype.toPascalCase = function () {
|
||||
|
||||
var s = "";
|
||||
$.each($.trim(this).split(/[\s\.-]+/g), function (idx, val) {
|
||||
if ($.trim(val) == "")
|
||||
return;
|
||||
if (val.length > 1)
|
||||
s += val.substr(0, 1).toUpperCase() + val.substr(1);
|
||||
else
|
||||
s += val.toUpperCase();
|
||||
});
|
||||
return s;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.toUmbracoAlias) {
|
||||
|
||||
/** toUmbracoAlias extension method for string*/
|
||||
String.prototype.toUmbracoAlias = function () {
|
||||
|
||||
var s = this.replace(/[^a-zA-Z0-9\s\.-]+/g, ''); // Strip none alphanumeric chars
|
||||
return s.toCamelCase(); // Convert to camelCase
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.toFunction) {
|
||||
|
||||
/** Converts a string into a function if it is found */
|
||||
String.prototype.toFunction = function () {
|
||||
var arr = this.split(".");
|
||||
var fn = (window || this);
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
fn = fn[arr[i]];
|
||||
}
|
||||
if (typeof fn !== "function") {
|
||||
throw new Error("function not found");
|
||||
}
|
||||
return fn;
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.detectIsJson) {
|
||||
|
||||
/** Rudimentary check to see if the string is a json encoded string */
|
||||
String.prototype.detectIsJson = function () {
|
||||
if ((this.startsWith("{") && this.endsWith("}")) || (this.startsWith("[") || this.endsWith("]"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
//TODO: WE NEED TO CONVERT ALL OF THESE METHODS TO PROXY TO OUR APPLICATION SINCE MANY CUSTOM APPS USE THIS!
|
||||
|
||||
Umbraco.Sys.registerNamespace("Umbraco.Application");
|
||||
|
||||
(function($) {
|
||||
Umbraco.Application.SpeechBubble = function() {
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name getRootScope
|
||||
* @methodOf UmbClientMgr
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Returns the root angular scope
|
||||
*/
|
||||
function getRootScope() {
|
||||
return angular.element(document.getElementById("umbracoMainPageBody")).scope();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name getRootInjector
|
||||
* @methodOf UmbClientMgr
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Returns the root angular injector
|
||||
*/
|
||||
function getRootInjector() {
|
||||
return angular.element(document.getElementById("umbracoMainPageBody")).injector();
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name ShowMessage
|
||||
* @methodOf Umbraco.Application.SpeechBubble
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Proxies a legacy call to the new notification service
|
||||
*/
|
||||
ShowMessage: function (icon, header, message) {
|
||||
//get our angular navigation service
|
||||
var injector = getRootInjector();
|
||||
var notifyService = injector.get("notificationsService");
|
||||
|
||||
switch(icon){
|
||||
case "save":
|
||||
notifyService.success(header, message);
|
||||
break;
|
||||
case "success":
|
||||
notifyService.success(header, message);
|
||||
break;
|
||||
case "warning":
|
||||
notifyService.warning(header, message);
|
||||
break;
|
||||
case "error":
|
||||
notifyService.error(header, message);
|
||||
break;
|
||||
default:
|
||||
notifyService.info(header, message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
//define alias for use throughout application
|
||||
var UmbSpeechBubble = new Umbraco.Application.SpeechBubble();
|
||||
@@ -0,0 +1,427 @@
|
||||
|
||||
//TODO: WE NEED TO CONVERT ALL OF THESE METHODS TO PROXY TO OUR APPLICATION SINCE MANY CUSTOM APPS USE THIS!
|
||||
|
||||
//TEST to mock iframe, this intercepts calls directly
|
||||
//to the old iframe, and funnels requests to angular directly
|
||||
//var right = {document: {location: {}}};
|
||||
/**/
|
||||
|
||||
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
|
||||
* @methodOf UmbClientMgr
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Returns the root angular scope
|
||||
*/
|
||||
function getRootScope() {
|
||||
return angular.element(document.getElementById("umbracoMainPageBody")).scope();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name getRootInjector
|
||||
* @methodOf UmbClientMgr
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Returns the root angular injector
|
||||
*/
|
||||
function getRootInjector() {
|
||||
return angular.element(document.getElementById("umbracoMainPageBody")).injector();
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
_isDirty: false,
|
||||
_isDebug: false,
|
||||
_mainTree: null,
|
||||
_appActions: null,
|
||||
_historyMgr: null,
|
||||
_rootPath: "/umbraco", //this is the default
|
||||
_modal: new Array(), //track all modal window objects (they get stacked)
|
||||
|
||||
historyManager: function () {
|
||||
|
||||
throw "Not implemented!";
|
||||
|
||||
//if (!this._historyMgr) {
|
||||
// this._historyMgr = new Umbraco.Controls.HistoryManager();
|
||||
//}
|
||||
//return this._historyMgr;
|
||||
},
|
||||
|
||||
setUmbracoPath: function(strPath) {
|
||||
/// <summary>
|
||||
/// sets the Umbraco root path folder
|
||||
/// </summary>
|
||||
this._debug("setUmbracoPath: " + strPath);
|
||||
this._rootPath = strPath;
|
||||
},
|
||||
|
||||
mainWindow: function() {
|
||||
return top;
|
||||
},
|
||||
mainTree: function () {
|
||||
|
||||
var injector = getRootInjector();
|
||||
var navService = injector.get("navigationService");
|
||||
var appState = injector.get("appState");
|
||||
var angularHelper = injector.get("angularHelper");
|
||||
var $rootScope = injector.get("$rootScope");
|
||||
|
||||
//mimic the API of the legacy tree
|
||||
var tree = {
|
||||
setActiveTreeType: function (treeType) {
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
navService._setActiveTreeType(treeType);
|
||||
});
|
||||
},
|
||||
syncTree: function (path, forceReload) {
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
navService._syncPath(path, forceReload);
|
||||
});
|
||||
},
|
||||
clearTreeCache: function(){
|
||||
var treeService = injector.get("treeService");
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
treeService.clearCache();
|
||||
});
|
||||
},
|
||||
reloadActionNode: function () {
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
var currentMenuNode = appState.getMenuState("currentNode");
|
||||
if (currentMenuNode) {
|
||||
navService.reloadNode(currentMenuNode);
|
||||
}
|
||||
});
|
||||
},
|
||||
refreshTree: function (treeAlias) {
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
navService._setActiveTreeType(treeAlias, true);
|
||||
});
|
||||
},
|
||||
moveNode: function (id, path) {
|
||||
angularHelper.safeApply($rootScope, function() {
|
||||
var currentMenuNode = appState.getMenuState("currentNode");
|
||||
if (currentMenuNode) {
|
||||
var treeService = injector.get("treeService");
|
||||
var treeRoot = treeService.getTreeRoot(currentMenuNode);
|
||||
if (treeRoot) {
|
||||
var found = treeService.getDescendantNode(treeRoot, id);
|
||||
if (found) {
|
||||
treeService.removeNode(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
navService._syncPath(path, true);
|
||||
});
|
||||
},
|
||||
getActionNode: function () {
|
||||
//need to replicate the legacy tree node
|
||||
var currentMenuNode = appState.getMenuState("currentNode");
|
||||
if (!currentMenuNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var legacyNode = {
|
||||
nodeId: currentMenuNode.id,
|
||||
nodeName: currentMenuNode.name,
|
||||
nodeType: currentMenuNode.nodeType,
|
||||
treeType: currentMenuNode.nodeType,
|
||||
sourceUrl: currentMenuNode.childNodesUrl,
|
||||
updateDefinition: function() {
|
||||
throw "'updateDefinition' method is not supported in Umbraco 7, consider upgrading to the new v7 APIs";
|
||||
}
|
||||
};
|
||||
//defined getters that will throw a not implemented/supported exception
|
||||
Object.defineProperty(legacyNode, "menu", {
|
||||
get: function () {
|
||||
throw "'menu' property is not supported in Umbraco 7, consider upgrading to the new v7 APIs";
|
||||
}
|
||||
});
|
||||
Object.defineProperty(legacyNode, "jsNode", {
|
||||
get: function () {
|
||||
throw "'jsNode' property is not supported in Umbraco 7, consider upgrading to the new v7 APIs";
|
||||
}
|
||||
});
|
||||
Object.defineProperty(legacyNode, "jsTree", {
|
||||
get: function () {
|
||||
throw "'jsTree' property is not supported in Umbraco 7, consider upgrading to the new v7 APIs";
|
||||
}
|
||||
});
|
||||
|
||||
return legacyNode;
|
||||
}
|
||||
};
|
||||
|
||||
return tree;
|
||||
},
|
||||
appActions: function() {
|
||||
var injector = getRootInjector();
|
||||
var navService = injector.get("navigationService");
|
||||
var localizationService = injector.get("localizationService");
|
||||
var userResource = injector.get("userResource");
|
||||
//var appState = injector.get("appState");
|
||||
var angularHelper = injector.get("angularHelper");
|
||||
var $rootScope = injector.get("$rootScope");
|
||||
|
||||
var actions = {
|
||||
openDashboard : function(section){
|
||||
navService.changeSection(section);
|
||||
},
|
||||
actionDisable: function () {
|
||||
localizationService.localize("defaultdialogs_confirmdisable").then(function (txtConfirmDisable) {
|
||||
var currentMenuNode = UmbClientMgr.mainTree().getActionNode();
|
||||
if (currentMenuNode) {
|
||||
if (confirm(txtConfirmDisable + ' "' + UmbClientMgr.mainTree().getActionNode().nodeName + '"?\n\n')) {
|
||||
angularHelper.safeApply($rootScope, function () {
|
||||
userResource.disableUser(currentMenuNode.nodeId).then(function () {
|
||||
UmbClientMgr.mainTree().syncTree("-1," + currentMenuNode.nodeId, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return actions;
|
||||
},
|
||||
uiKeys: function() {
|
||||
|
||||
throw "Not implemented!";
|
||||
|
||||
////TODO: If there is no main window, we need to go retrieve the appActions from the server!
|
||||
//return this.mainWindow().uiKeys;
|
||||
},
|
||||
contentFrameAndSection: function(app, rightFrameUrl) {
|
||||
|
||||
throw "Not implemented!";
|
||||
|
||||
////this.appActions().shiftApp(app, this.uiKeys()['sections_' + app]);
|
||||
//var self = this;
|
||||
//self.mainWindow().UmbClientMgr.historyManager().addHistory(app, true);
|
||||
//window.setTimeout(function() {
|
||||
// self.mainWindow().UmbClientMgr.contentFrame(rightFrameUrl);
|
||||
//}, 200);
|
||||
},
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name contentFrame
|
||||
* @methodOf UmbClientMgr
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* This will tell our angular app to create and load in an iframe at the specified location
|
||||
* @param strLocation {String} The URL to load the iframe in
|
||||
*/
|
||||
contentFrame: function (strLocation) {
|
||||
|
||||
if (!strLocation || strLocation == "") {
|
||||
//SD: NOTE: We used to return the content iframe object but now I'm not sure we should do that ?!
|
||||
|
||||
if (typeof top.right != "undefined") {
|
||||
return top.right;
|
||||
}
|
||||
else {
|
||||
return top; //return the current window if the content frame doesn't exist in the current context
|
||||
}
|
||||
//return;
|
||||
}
|
||||
|
||||
this._debug("contentFrame: " + strLocation);
|
||||
|
||||
//get our angular navigation service
|
||||
var injector = getRootInjector();
|
||||
|
||||
var rootScope = injector.get("$rootScope");
|
||||
var angularHelper = injector.get("angularHelper");
|
||||
var navService = injector.get("navigationService");
|
||||
var locationService = injector.get("$location");
|
||||
|
||||
var self = this;
|
||||
|
||||
angularHelper.safeApply(rootScope, function() {
|
||||
if (strLocation.startsWith("#")) {
|
||||
locationService.path(strLocation.trimStart("#")).search("");
|
||||
}
|
||||
else {
|
||||
//if the path doesn't start with "/" or with the root path then
|
||||
//prepend the root path
|
||||
if (!strLocation.startsWith("/")) {
|
||||
strLocation = self._rootPath + "/" + strLocation;
|
||||
}
|
||||
else if (strLocation.length >= self._rootPath.length
|
||||
&& strLocation.substr(0, self._rootPath.length) != self._rootPath) {
|
||||
strLocation = self._rootPath + "/" + strLocation;
|
||||
}
|
||||
|
||||
navService.loadLegacyIFrame(strLocation);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getFakeFrame : function() {
|
||||
return fakeFrame;
|
||||
},
|
||||
|
||||
/** This is used to launch an angular based modal window instead of the legacy window */
|
||||
openAngularModalWindow: function (options) {
|
||||
|
||||
//get our angular navigation service
|
||||
var injector = getRootInjector();
|
||||
var dialogService = injector.get("dialogService");
|
||||
|
||||
var dialog = dialogService.open(options);
|
||||
|
||||
////add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked.
|
||||
//dialog.element.data("modalCb", onCloseCallback);
|
||||
|
||||
//this._modal.push(dialog);
|
||||
//return dialog;
|
||||
},
|
||||
|
||||
openModalWindow: function(url, name, showHeader, width, height, top, leftOffset, closeTriggers, onCloseCallback) {
|
||||
//need to create the modal on the top window if the top window has a client manager, if not, create it on the current window
|
||||
|
||||
//get our angular navigation service
|
||||
var injector = getRootInjector();
|
||||
var navService = injector.get("navigationService");
|
||||
var dialogService = injector.get("dialogService");
|
||||
|
||||
var self = this;
|
||||
|
||||
//based on what state the nav ui is in, depends on how we are going to launch a model / dialog. A modal
|
||||
// will show up on the right hand side and a dialog will show up as if it is in the menu.
|
||||
// with the legacy API we cannot know what is expected so we can only check if the menu is active, if it is
|
||||
// we'll launch a dialog, otherwise a modal.
|
||||
var appState = injector.get("appState");
|
||||
var navMode = appState.getGlobalState("navMode");
|
||||
var dialog;
|
||||
if (navMode === "menu") {
|
||||
dialog = navService.showDialog({
|
||||
//create a 'fake' action to passin with the specified actionUrl since it needs to load into an iframe
|
||||
action: {
|
||||
name: name,
|
||||
metaData: {
|
||||
actionUrl: url
|
||||
}
|
||||
},
|
||||
node: {}
|
||||
});
|
||||
}
|
||||
else {
|
||||
dialog = dialogService.open({
|
||||
template: url,
|
||||
width: width,
|
||||
height: height,
|
||||
iframe: true,
|
||||
show: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//add the callback to the jquery data for the modal so we can call it on close to support the legacy way dialogs worked.
|
||||
dialog.element.data("modalCb", onCloseCallback);
|
||||
//add the close triggers
|
||||
if (angular.isArray(closeTriggers)) {
|
||||
for (var i = 0; i < closeTriggers.length; i++) {
|
||||
var e = dialog.find(closeTriggers[i]);
|
||||
if (e.length > 0) {
|
||||
e.click(function () {
|
||||
self.closeModalWindow();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._modal.push(dialog);
|
||||
return dialog;
|
||||
},
|
||||
rootScope : function(){
|
||||
return getRootScope();
|
||||
},
|
||||
|
||||
reloadLocation: function() {
|
||||
var injector = getRootInjector();
|
||||
var $route = injector.get("$route");
|
||||
$route.reload();
|
||||
},
|
||||
|
||||
closeModalWindow: function(rVal) {
|
||||
|
||||
//get our angular navigation service
|
||||
var injector = getRootInjector();
|
||||
var dialogService = injector.get("dialogService");
|
||||
|
||||
// all legacy calls to closeModalWindow are expecting to just close the last opened one so we'll ensure
|
||||
// that this is still the case.
|
||||
if (this._modal != null && this._modal.length > 0) {
|
||||
|
||||
var lastModal = this._modal.pop();
|
||||
|
||||
//if we've stored a callback on this modal call it before we close.
|
||||
var self = this;
|
||||
//get the compat callback from the modal element
|
||||
var onCloseCallback = lastModal.element.data("modalCb");
|
||||
if (typeof onCloseCallback == "function") {
|
||||
onCloseCallback.apply(self, [{ outVal: rVal }]);
|
||||
}
|
||||
|
||||
//just call the native dialog close() method to remove the dialog
|
||||
lastModal.close();
|
||||
|
||||
//if it's the last one close them all
|
||||
if (this._modal.length == 0) {
|
||||
getRootScope().$emit("app.closeDialogs", undefined);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//instead of calling just the dialog service we funnel it through the global
|
||||
//event emitter
|
||||
getRootScope().$emit("app.closeDialogs", undefined);
|
||||
}
|
||||
},
|
||||
/* This is used for the package installer to call in order to reload all app assets so we don't have to reload the window */
|
||||
_packageInstalled: function() {
|
||||
var injector = getRootInjector();
|
||||
var packageHelper = injector.get("packageHelper");
|
||||
packageHelper.packageInstalled();
|
||||
},
|
||||
_debug: function(strMsg) {
|
||||
if (this._isDebug) {
|
||||
Sys.Debug.trace("UmbClientMgr: " + strMsg);
|
||||
}
|
||||
},
|
||||
get_isDirty: function() {
|
||||
return this._isDirty;
|
||||
},
|
||||
set_isDirty: function(value) {
|
||||
this._isDirty = value;
|
||||
}
|
||||
};
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
//define alias for use throughout application
|
||||
var UmbClientMgr = new Umbraco.Application.ClientManager();
|
||||
@@ -0,0 +1,17 @@
|
||||
if (typeof Umbraco == 'undefined') var Umbraco = {};
|
||||
if (!Umbraco.Sys) Umbraco.Sys = {};
|
||||
|
||||
Umbraco.Sys.registerNamespace = function(namespace) {
|
||||
/// <summary>
|
||||
/// Used to easily register namespaces for classes without doing the syntax listed on line 1/2 for each class.
|
||||
/// Pretty much the same as ASP.NET's Type.registerNamespace, except in order to use it, you must register
|
||||
/// all of your scripts with ScriptManager, this class doesn't require this.
|
||||
/// </summary>
|
||||
namespace = namespace.split('.');
|
||||
if (!window[namespace[0]]) window[namespace[0]] = {};
|
||||
var strFullNamespace = namespace[0];
|
||||
for (var i = 1; i < namespace.length; i++) {
|
||||
strFullNamespace += "." + namespace[i];
|
||||
eval("if(!window." + strFullNamespace + ")window." + strFullNamespace + "={};");
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
/* contains random bits and pieces we neede to make the U6 UI behave */
|
||||
|
||||
(function ($) {
|
||||
|
||||
$(document).ready(function () {
|
||||
scaleScrollables("body");
|
||||
|
||||
$(window).bind("resize", function () {
|
||||
scaleScrollables("body");
|
||||
});
|
||||
|
||||
$("body").click(function (event) {
|
||||
var el = event.target.nodeName;
|
||||
var els = ["INPUT","A","BUTTON"];
|
||||
|
||||
if(els.indexOf(el) >= 0){return;}
|
||||
|
||||
var parents = $(event.target).parents("a,button");
|
||||
if(parents.length > 0){
|
||||
return;
|
||||
}
|
||||
|
||||
var click = $(event.target).attr('onClick');
|
||||
if(click){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UmbClientMgr.closeModalWindow(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
function scaleScrollables(selector) {
|
||||
$(".umb-scrollable").each(function() {
|
||||
var el = jQuery(this);
|
||||
var totalOffset = 0;
|
||||
var offsety = el.data("offset-y");
|
||||
|
||||
if (offsety != undefined)
|
||||
totalOffset += offsety;
|
||||
|
||||
el.height($(window).height() - (el.offset().top + totalOffset));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user