Replace angular.copy with Utilities.copy

This commit is contained in:
BatJan
2020-04-11 22:11:13 +02:00
committed by Sebastiaan Janssen
parent 7f64abb224
commit bd26cb36ec
25 changed files with 2092 additions and 2094 deletions
@@ -18,14 +18,14 @@
];
// when a user logs out or timesout
evts.push(eventsService.on("app.notAuthenticated", function() {
evts.push(eventsService.on("app.notAuthenticated", function () {
scope.authenticated = false;
scope.user = null;
}));
// when the application is ready and the user is authorized setup the data
evts.push(eventsService.on("app.ready", function(evt, data) {
evts.push(eventsService.on("app.ready", function (evt, data) {
scope.authenticated = true;
scope.user = data.user;
@@ -40,10 +40,10 @@
}));
evts.push(eventsService.on("app.userRefresh", function(evt) {
userService.refreshCurrentUser().then(function(data) {
evts.push(eventsService.on("app.userRefresh", function (evt) {
userService.refreshCurrentUser().then(function (data) {
scope.user = data;
if (scope.user.avatars) {
scope.avatar = [];
if (Utilities.isArray(scope.user.avatars)) {
@@ -54,10 +54,10 @@
}
});
}));
scope.rememberFocus = focusService.rememberFocus;
scope.searchClick = function() {
scope.searchClick = function () {
var showSearch = appState.getSearchState("show");
appState.setSearchState("show", !showSearch);
};
@@ -71,7 +71,7 @@
};
scope.avatarClick = function () {
if(!scope.userDialog) {
if (!scope.userDialog) {
scope.userDialog = {
view: "user",
show: true,
@@ -38,7 +38,7 @@
//watch for changes to isNew, set the page.isNew accordingly and load the breadcrumb if we can
$scope.$watch('isNew', function (newVal, oldVal) {
$scope.page.isNew = Object.toBoolean(newVal);
//We fetch all ancestors of the node to generate the footer breadcrumb navigation
@@ -182,32 +182,32 @@
}
}));
evts.push(eventsService.on("editors.content.reload", function (name, args) {
evts.push(eventsService.on("editors.content.reload", function (name, args) {
if (args && args.node && $scope.content.id === args.node.id) {
reload();
loadBreadcrumb();
syncTreeNode($scope.content, $scope.content.path);
}
}));
evts.push(eventsService.on("rte.file.uploading", function(){
evts.push(eventsService.on("rte.file.uploading", function () {
$scope.page.saveButtonState = "busy";
$scope.page.buttonGroupState = "busy";
}));
evts.push(eventsService.on("rte.file.uploaded", function(){
evts.push(eventsService.on("rte.file.uploaded", function () {
$scope.page.saveButtonState = "success";
$scope.page.buttonGroupState = "success";
}));
evts.push(eventsService.on("rte.shortcut.save", function(){
evts.push(eventsService.on("rte.shortcut.save", function () {
if ($scope.page.showSaveButton) {
$scope.save();
}
}));
evts.push(eventsService.on("content.saved", function(){
evts.push(eventsService.on("content.saved", function () {
// Clear out localstorage keys that start with tinymce__
// When we save/perist a content node
// NOTE: clearAll supports a RegEx pattern of items to remove
@@ -323,7 +323,7 @@
.then(function (syncArgs) {
$scope.page.menu.currentNode = syncArgs.node;
if (reloadChildren && syncArgs.node.expanded) {
treeService.loadNodeChildren({node: syncArgs.node});
treeService.loadNodeChildren({ node: syncArgs.node });
}
}, function () {
//handle the rejection
@@ -784,7 +784,7 @@
var dialog = {
parentScope: $scope,
view: "views/content/overlays/schedule.html",
variants: angular.copy($scope.content.variants), //set a model property for the dialog
variants: Utilities.copy($scope.content.variants), //set a model property for the dialog
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
submitButtonLabelKey: "buttons_schedulePublish",
submit: function (model) {
@@ -818,7 +818,7 @@
}
model.submitButtonState = "error";
//re-map the dialog model since we've re-bound the properties
dialog.variants = angular.copy($scope.content.variants);
dialog.variants = Utilities.copy($scope.content.variants);
//don't reject, we've handled the error
return $q.when(err);
});
@@ -44,7 +44,7 @@
/** Called when the component initializes */
function onInit() {
prevContentDateUpdated = angular.copy(vm.content.updateDate);
prevContentDateUpdated = Utilities.copy(vm.content.updateDate);
setActiveCulture();
}
@@ -68,7 +68,7 @@
function doCheck() {
if (!angular.equals(vm.content.updateDate, prevContentDateUpdated)) {
setActiveCulture();
prevContentDateUpdated = angular.copy(vm.content.updateDate);
prevContentDateUpdated = Utilities.copy(vm.content.updateDate);
}
}
@@ -152,7 +152,7 @@
//copy the apps from the main model if not assigned yet to the variant
if (!variant.apps) {
variant.apps = angular.copy(vm.content.apps);
variant.apps = Utilities.copy(vm.content.apps);
}
//if this is a variant has a culture/language than we need to assign the language drop down info
@@ -185,7 +185,7 @@
// keep track of the open variants across the different split views
// push the first variant then update the variant index based on the editor index
if(vm.openVariants && vm.openVariants.length === 0) {
if (vm.openVariants && vm.openVariants.length === 0) {
vm.openVariants.push(variant.language.culture);
} else {
vm.openVariants[editorIndex] = variant.language.culture;
@@ -205,10 +205,10 @@
}
// make sure the same app it set to active in the new variant
if(activeAppAlias) {
angular.forEach(variant.apps, function(app) {
if (activeAppAlias) {
angular.forEach(variant.apps, function (app) {
app.active = false;
if(app.alias === activeAppAlias) {
if (app.alias === activeAppAlias) {
app.active = true;
}
});
@@ -283,10 +283,10 @@
function selectVariant(variant, editorIndex) {
// prevent variants already open in a split view to be opened
if(vm.openVariants.indexOf(variant.language.culture) !== -1) {
if (vm.openVariants.indexOf(variant.language.culture) !== -1) {
return;
}
//if the editor index is zero, then update the query string to track the lang selection, otherwise if it's part
//of a 2nd split view editor then update the model directly.
if (editorIndex === 0) {
@@ -313,7 +313,7 @@
//update the editors collection
insertVariantEditor(editorIndex, contentVariant);
}
}
@@ -322,21 +322,21 @@
* @param {any} app This is the model of the selected app
*/
function selectApp(app) {
if(vm.onSelectApp) {
vm.onSelectApp({"app": app});
if (vm.onSelectApp) {
vm.onSelectApp({ "app": app });
}
}
function selectAppAnchor(app, anchor) {
if(vm.onSelectAppAnchor) {
vm.onSelectAppAnchor({"app": app, "anchor": anchor});
if (vm.onSelectAppAnchor) {
vm.onSelectAppAnchor({ "app": app, "anchor": anchor });
}
}
$scope.$on("editors.apps.appChanged", function($event, $args) {
$scope.$on("editors.apps.appChanged", function ($event, $args) {
var app = $args.app;
if(app && app.alias) {
if (app && app.alias) {
activeAppAlias = app.alias;
}
});
@@ -9,91 +9,91 @@ will override element type to textarea and add own attribute ngModel tied to jso
*/
angular.module("umbraco.directives")
.directive('umbRawModel', function () {
return {
restrict: 'A',
require: 'ngModel',
template: '<textarea ng-model="jsonEditing"></textarea>',
replace : true,
scope: {
model: '=umbRawModel',
validateOn:'='
},
link: function (scope, element, attrs, ngModelCtrl) {
.directive('umbRawModel', function () {
return {
restrict: 'A',
require: 'ngModel',
template: '<textarea ng-model="jsonEditing"></textarea>',
replace: true,
scope: {
model: '=umbRawModel',
validateOn: '='
},
link: function (scope, element, attrs, ngModelCtrl) {
function setEditing (value) {
scope.jsonEditing = angular.copy( jsonToString(value));
}
function setEditing(value) {
scope.jsonEditing = Utilities.copy(jsonToString(value));
}
function updateModel (value) {
scope.model = stringToJson(value);
}
function updateModel(value) {
scope.model = stringToJson(value);
}
function setValid() {
ngModelCtrl.$setValidity('json', true);
}
function setValid() {
ngModelCtrl.$setValidity('json', true);
}
function setInvalid () {
ngModelCtrl.$setValidity('json', false);
}
function setInvalid() {
ngModelCtrl.$setValidity('json', false);
}
function stringToJson(text) {
try {
return angular.fromJson(text);
} catch (err) {
setInvalid();
return text;
}
}
function stringToJson(text) {
try {
return angular.fromJson(text);
} catch (err) {
setInvalid();
return text;
}
}
function jsonToString(object) {
// better than JSON.stringify(), because it formats + filters $$hashKey etc.
// NOTE that this will remove all $-prefixed values
return Utilities.toJson(object, true);
}
function jsonToString(object) {
// better than JSON.stringify(), because it formats + filters $$hashKey etc.
// NOTE that this will remove all $-prefixed values
return Utilities.toJson(object, true);
}
function isValidJson(model) {
var flag = true;
try {
angular.fromJson(model);
} catch (err) {
flag = false;
}
return flag;
}
function isValidJson(model) {
var flag = true;
try {
angular.fromJson(model);
} catch (err) {
flag = false;
}
return flag;
}
//init
setEditing(scope.model);
//init
setEditing(scope.model);
var onInputChange = function(newval,oldval){
if (newval !== oldval) {
if (isValidJson(newval)) {
setValid();
updateModel(newval);
} else {
setInvalid();
}
}
};
var onInputChange = function (newval, oldval) {
if (newval !== oldval) {
if (isValidJson(newval)) {
setValid();
updateModel(newval);
} else {
setInvalid();
}
}
};
if(scope.validateOn){
element.on(scope.validateOn, function(){
scope.$apply(function(){
onInputChange(scope.jsonEditing);
});
});
}else{
//check for changes going out
scope.$watch('jsonEditing', onInputChange, true);
}
if (scope.validateOn) {
element.on(scope.validateOn, function () {
scope.$apply(function () {
onInputChange(scope.jsonEditing);
});
});
} else {
//check for changes going out
scope.$watch('jsonEditing', onInputChange, true);
}
//check for changes coming in
scope.$watch('model', function (newval, oldval) {
if (newval !== oldval) {
setEditing(newval);
}
}, true);
//check for changes coming in
scope.$watch('model', function (newval, oldval) {
if (newval !== oldval) {
setEditing(newval);
}
}, true);
}
};
});
}
};
});
@@ -193,352 +193,351 @@ Opens an overlay to show a custom YSOD. </br>
@param {string} position The overlay position ("left", "right", "center": "target").
**/
(function() {
'use strict';
(function () {
'use strict';
function OverlayDirective($timeout, formHelper, overlayHelper, localizationService, $q, $templateCache, $http, $compile) {
function link(scope, el, attr, ctrl) {
function link(scope, el, attr, ctrl) {
scope.directive = {
enableConfirmButton: false
};
var overlayNumber = 0;
var numberOfOverlays = 0;
var isRegistered = false;
var modelCopy = {};
var unsubscribe = [];
function activate() {
setView();
setButtonText();
modelCopy = makeModelCopy(scope.model);
$timeout(function() {
if (scope.position === "target" && scope.model.event) {
setTargetPosition();
// update the position of the overlay on content changes
// as these affect the layout/size of the overlay
if ('ResizeObserver' in window)
{
var resizeObserver = new ResizeObserver(setTargetPosition);
var contentArea = document.getElementById("contentwrapper");
resizeObserver.observe(el[0]);
if (contentArea) {
resizeObserver.observe(contentArea);
}
unsubscribe.push(function () {
resizeObserver.disconnect();
});
}
}
// this has to be done inside a timeout to ensure the destroy
// event on other overlays is run before registering a new one
registerOverlay();
setOverlayIndent();
focusOnOverlayHeading()
});
}
// Ideally this would focus on the first natively focusable element in the overlay, but as the content can be dynamic, it is focusing on the heading.
function focusOnOverlayHeading() {
var heading = el.find(".umb-overlay__title");
if(heading) {
heading.focus();
}
}
function setView() {
if (scope.view) {
if (scope.view.indexOf(".html") === -1) {
var viewAlias = scope.view.toLowerCase();
scope.view = "views/common/overlays/" + viewAlias + "/" + viewAlias + ".html";
}
//if a custom parent scope is defined then we need to manually compile the view
if (scope.parentScope) {
var element = el.find(".scoped-view");
$http.get(scope.view, { cache: $templateCache })
.then(function (response) {
var templateScope = scope.parentScope.$new();
unsubscribe.push(function() {
templateScope.$destroy();
});
templateScope.model = scope.model;
element.html(response.data);
element.show();
$compile(element.contents())(templateScope);
});
}
}
}
function setButtonText() {
var labelKeys = [
"general_close",
"general_submit"
];
localizationService.localizeMany(labelKeys).then(function (values) {
if (!scope.model.closeButtonLabelKey && !scope.model.closeButtonLabel) {
scope.model.closeButtonLabel = values[0];
}
if (!scope.model.submitButtonLabelKey && !scope.model.submitButtonLabel) {
scope.model.submitButtonLabel = values[1];
}
});
}
function registerOverlay() {
overlayNumber = overlayHelper.registerOverlay();
$(document).on("keydown.overlay-" + overlayNumber, function(event) {
if (event.which === 27) {
numberOfOverlays = overlayHelper.getNumberOfOverlays();
if (numberOfOverlays === overlayNumber && !scope.model.disableEscKey) {
scope.$apply(function () {
scope.closeOverLay();
});
}
event.stopPropagation();
event.preventDefault();
}
if (event.which === 13) {
numberOfOverlays = overlayHelper.getNumberOfOverlays();
if(numberOfOverlays === overlayNumber) {
var activeElementType = document.activeElement.tagName;
var clickableElements = ["A", "BUTTON"];
var submitOnEnter = document.activeElement.hasAttribute("overlay-submit-on-enter");
var submitOnEnterValue = submitOnEnter ? document.activeElement.getAttribute("overlay-submit-on-enter") : "";
if(clickableElements.indexOf(activeElementType) >= 0) {
// don't do anything, let the browser Enter key handle this
} else if(activeElementType === "TEXTAREA" && !submitOnEnter) {
} else if (submitOnEnter && submitOnEnterValue === "false") {
// don't do anything
}else {
scope.$apply(function () {
scope.submitForm(scope.model);
});
event.preventDefault();
}
}
}
});
isRegistered = true;
}
function unregisterOverlay() {
if(isRegistered) {
overlayHelper.unregisterOverlay();
$(document).off("keydown.overlay-" + overlayNumber);
isRegistered = false;
}
}
function makeModelCopy(object) {
var newObject = {};
for (var key in object) {
if (key !== "event" && key !== "parentScope") {
newObject[key] = angular.copy(object[key]);
}
}
return newObject;
}
function setOverlayIndent() {
var overlayIndex = overlayNumber - 1;
var indentSize = overlayIndex * 20;
var overlayWidth = el[0].clientWidth;
el.css('width', overlayWidth - indentSize);
if(scope.position === "center" && overlayIndex > 0 || scope.position === "target" && overlayIndex > 0) {
var overlayTopPosition = el[0].offsetTop;
el.css('top', overlayTopPosition + indentSize);
}
}
function setTargetPosition() {
var container = $("#contentwrapper");
var containerLeft = container[0].offsetLeft;
var containerRight = containerLeft + container[0].offsetWidth;
var containerTop = container[0].offsetTop;
var containerBottom = containerTop + container[0].offsetHeight;
var mousePositionClickX = null;
var mousePositionClickY = null;
var elementHeight = null;
var elementWidth = null;
var position = {
right: "inherit",
left: "inherit",
top: "inherit",
bottom: "inherit"
scope.directive = {
enableConfirmButton: false
};
// click position
mousePositionClickX = scope.model.event.pageX;
mousePositionClickY = scope.model.event.pageY;
var overlayNumber = 0;
var numberOfOverlays = 0;
var isRegistered = false;
// element size
elementHeight = el[0].clientHeight;
elementWidth = el[0].clientWidth;
// move element to this position
position.left = mousePositionClickX - (elementWidth / 2);
position.top = mousePositionClickY - (elementHeight / 2);
var modelCopy = {};
var unsubscribe = [];
function activate() {
setView();
setButtonText();
modelCopy = makeModelCopy(scope.model);
$timeout(function () {
if (scope.position === "target" && scope.model.event) {
setTargetPosition();
// update the position of the overlay on content changes
// as these affect the layout/size of the overlay
if ('ResizeObserver' in window) {
var resizeObserver = new ResizeObserver(setTargetPosition);
var contentArea = document.getElementById("contentwrapper");
resizeObserver.observe(el[0]);
if (contentArea) {
resizeObserver.observe(contentArea);
}
unsubscribe.push(function () {
resizeObserver.disconnect();
});
}
}
// this has to be done inside a timeout to ensure the destroy
// event on other overlays is run before registering a new one
registerOverlay();
setOverlayIndent();
focusOnOverlayHeading()
});
// check to see if element is outside screen
// outside right
if (position.left + elementWidth > containerRight) {
position.right = 10;
position.left = "inherit";
}
// outside bottom
if (position.top + elementHeight > containerBottom) {
position.bottom = 10;
position.top = "inherit";
// Ideally this would focus on the first natively focusable element in the overlay, but as the content can be dynamic, it is focusing on the heading.
function focusOnOverlayHeading() {
var heading = el.find(".umb-overlay__title");
if (heading) {
heading.focus();
}
}
// outside left
if (position.left < containerLeft) {
position.left = containerLeft + 10;
position.right = "inherit";
function setView() {
if (scope.view) {
if (scope.view.indexOf(".html") === -1) {
var viewAlias = scope.view.toLowerCase();
scope.view = "views/common/overlays/" + viewAlias + "/" + viewAlias + ".html";
}
//if a custom parent scope is defined then we need to manually compile the view
if (scope.parentScope) {
var element = el.find(".scoped-view");
$http.get(scope.view, { cache: $templateCache })
.then(function (response) {
var templateScope = scope.parentScope.$new();
unsubscribe.push(function () {
templateScope.$destroy();
});
templateScope.model = scope.model;
element.html(response.data);
element.show();
$compile(element.contents())(templateScope);
});
}
}
}
// outside top
if (position.top < containerTop) {
position.top = 10;
position.bottom = "inherit";
function setButtonText() {
var labelKeys = [
"general_close",
"general_submit"
];
localizationService.localizeMany(labelKeys).then(function (values) {
if (!scope.model.closeButtonLabelKey && !scope.model.closeButtonLabel) {
scope.model.closeButtonLabel = values[0];
}
if (!scope.model.submitButtonLabelKey && !scope.model.submitButtonLabel) {
scope.model.submitButtonLabel = values[1];
}
});
}
el.css(position);
}
function registerOverlay() {
scope.submitForm = function(model) {
if(scope.model.submit) {
if (formHelper.submitForm({ scope: scope, skipValidation: scope.model.skipFormValidation})) {
if (scope.model.confirmSubmit && scope.model.confirmSubmit.enable && !scope.directive.enableConfirmButton) {
//wrap in a when since we don't know if this is a promise or not
$q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
function() {
formHelper.resetForm({ scope: scope });
});
} else {
unregisterOverlay();
//wrap in a when since we don't know if this is a promise or not
$q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
function() {
formHelper.resetForm({ scope: scope });
});
}
overlayNumber = overlayHelper.registerOverlay();
}
}
};
$(document).on("keydown.overlay-" + overlayNumber, function (event) {
scope.cancelConfirmSubmit = function() {
scope.model.confirmSubmit.show = false;
};
if (event.which === 27) {
scope.closeOverLay = function() {
numberOfOverlays = overlayHelper.getNumberOfOverlays();
unregisterOverlay();
if (numberOfOverlays === overlayNumber && !scope.model.disableEscKey) {
scope.$apply(function () {
scope.closeOverLay();
});
}
event.stopPropagation();
event.preventDefault();
}
if (event.which === 13) {
numberOfOverlays = overlayHelper.getNumberOfOverlays();
if (numberOfOverlays === overlayNumber) {
var activeElementType = document.activeElement.tagName;
var clickableElements = ["A", "BUTTON"];
var submitOnEnter = document.activeElement.hasAttribute("overlay-submit-on-enter");
var submitOnEnterValue = submitOnEnter ? document.activeElement.getAttribute("overlay-submit-on-enter") : "";
if (clickableElements.indexOf(activeElementType) >= 0) {
// don't do anything, let the browser Enter key handle this
} else if (activeElementType === "TEXTAREA" && !submitOnEnter) {
} else if (submitOnEnter && submitOnEnterValue === "false") {
// don't do anything
} else {
scope.$apply(function () {
scope.submitForm(scope.model);
});
event.preventDefault();
}
}
}
});
isRegistered = true;
if (scope.model && scope.model.close) {
scope.model = modelCopy;
scope.model.close(scope.model);
} else {
scope.model.show = false;
scope.model = null;
}
};
function unregisterOverlay() {
if (isRegistered) {
overlayHelper.unregisterOverlay();
$(document).off("keydown.overlay-" + overlayNumber);
isRegistered = false;
}
scope.outSideClick = function() {
if(!scope.model.disableBackdropClick) {
scope.closeOverLay();
}
function makeModelCopy(object) {
var newObject = {};
for (var key in object) {
if (key !== "event" && key !== "parentScope") {
newObject[key] = Utilities.copy(object[key]);
}
}
return newObject;
}
function setOverlayIndent() {
var overlayIndex = overlayNumber - 1;
var indentSize = overlayIndex * 20;
var overlayWidth = el[0].clientWidth;
el.css('width', overlayWidth - indentSize);
if (scope.position === "center" && overlayIndex > 0 || scope.position === "target" && overlayIndex > 0) {
var overlayTopPosition = el[0].offsetTop;
el.css('top', overlayTopPosition + indentSize);
}
}
function setTargetPosition() {
var container = $("#contentwrapper");
var containerLeft = container[0].offsetLeft;
var containerRight = containerLeft + container[0].offsetWidth;
var containerTop = container[0].offsetTop;
var containerBottom = containerTop + container[0].offsetHeight;
var mousePositionClickX = null;
var mousePositionClickY = null;
var elementHeight = null;
var elementWidth = null;
var position = {
right: "inherit",
left: "inherit",
top: "inherit",
bottom: "inherit"
};
// click position
mousePositionClickX = scope.model.event.pageX;
mousePositionClickY = scope.model.event.pageY;
// element size
elementHeight = el[0].clientHeight;
elementWidth = el[0].clientWidth;
// move element to this position
position.left = mousePositionClickX - (elementWidth / 2);
position.top = mousePositionClickY - (elementHeight / 2);
// check to see if element is outside screen
// outside right
if (position.left + elementWidth > containerRight) {
position.right = 10;
position.left = "inherit";
}
// outside bottom
if (position.top + elementHeight > containerBottom) {
position.bottom = 10;
position.top = "inherit";
}
// outside left
if (position.left < containerLeft) {
position.left = containerLeft + 10;
position.right = "inherit";
}
// outside top
if (position.top < containerTop) {
position.top = 10;
position.bottom = "inherit";
}
el.css(position);
}
scope.submitForm = function (model) {
if (scope.model.submit) {
if (formHelper.submitForm({ scope: scope, skipValidation: scope.model.skipFormValidation })) {
if (scope.model.confirmSubmit && scope.model.confirmSubmit.enable && !scope.directive.enableConfirmButton) {
//wrap in a when since we don't know if this is a promise or not
$q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
function () {
formHelper.resetForm({ scope: scope });
});
} else {
unregisterOverlay();
//wrap in a when since we don't know if this is a promise or not
$q.when(scope.model.submit(model, modelCopy, scope.directive.enableConfirmButton)).then(
function () {
formHelper.resetForm({ scope: scope });
});
}
}
}
};
scope.cancelConfirmSubmit = function () {
scope.model.confirmSubmit.show = false;
};
scope.closeOverLay = function () {
unregisterOverlay();
if (scope.model && scope.model.close) {
scope.model = modelCopy;
scope.model.close(scope.model);
} else {
scope.model.show = false;
scope.model = null;
}
};
scope.outSideClick = function () {
if (!scope.model.disableBackdropClick) {
scope.closeOverLay();
}
};
unsubscribe.push(unregisterOverlay);
scope.$on('$destroy', function () {
for (var i = 0; i < unsubscribe.length; i++) {
unsubscribe[i]();
}
});
activate();
}
var directive = {
transclude: true,
restrict: 'E',
replace: true,
templateUrl: 'views/components/overlays/umb-overlay.html',
scope: {
ngShow: "=",
model: "=",
view: "=",
position: "@",
size: "=?",
parentScope: "=?"
},
link: link
};
unsubscribe.push(unregisterOverlay);
scope.$on('$destroy', function () {
for (var i = 0; i < unsubscribe.length; i++) {
unsubscribe[i]();
}
});
return directive;
}
activate();
}
var directive = {
transclude: true,
restrict: 'E',
replace: true,
templateUrl: 'views/components/overlays/umb-overlay.html',
scope: {
ngShow: "=",
model: "=",
view: "=",
position: "@",
size: "=?",
parentScope: "=?"
},
link: link
};
return directive;
}
angular.module('umbraco.directives').directive('umbOverlay', OverlayDirective);
angular.module('umbraco.directives').directive('umbOverlay', OverlayDirective);
})();
@@ -3,12 +3,12 @@
function () {
var link = function ($scope) {
// Clone the model because some property editors
// do weird things like updating and config values
// so we want to ensure we start from a fresh every
// time, we'll just sync the value back when we need to
$scope.model = angular.copy($scope.ngModel);
$scope.model = Utilities.copy($scope.ngModel);
$scope.nodeContext = $scope.model;
// Find the selected tab
@@ -31,7 +31,7 @@
// Tell inner controls we are submitting
$scope.$broadcast("formSubmitting", { scope: $scope });
// Sync the values back
angular.forEach($scope.ngModel.variants[0].tabs, function (tab) {
if (tab.alias.toLowerCase() === selectedTab.alias.toLowerCase()) {
@@ -1,40 +1,40 @@
(function() {
'use strict';
(function () {
'use strict';
function removeProperty(obj, propertyPrefix) {
for (var property in obj) {
if (obj.hasOwnProperty(property)) {
if (property.startsWith(propertyPrefix) && obj[property] !== undefined) {
obj[property] = undefined;
}
if (typeof obj[property] === "object") {
removeProperty(obj[property], propertyPrefix);
}
}
}
}
function transform(data){
function transform(data) {
removeProperty(data, "$");
}
function doNotPostDollarVariablesRequestInterceptor($q, urlHelper) {
return {
//dealing with requests:
'request': function(config) {
if(config.method === "POST"){
var clone = angular.copy(config);
'request': function (config) {
if (config.method === "POST") {
var clone = Utilities.copy(config);
transform(clone.data);
return clone;
}
return config;
}
};
}
}
angular.module('umbraco.interceptors').factory('doNotPostDollarVariablesOnPostRequestInterceptor', doNotPostDollarVariablesRequestInterceptor);
})();
@@ -7,21 +7,21 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var contentTypeHelperService = {
createIdArray: function(array) {
createIdArray: function (array) {
var newArray = [];
var newArray = [];
angular.forEach(array, function(arrayItem){
angular.forEach(array, function (arrayItem) {
if(Utilities.isObject(arrayItem)) {
newArray.push(arrayItem.id);
} else {
newArray.push(arrayItem);
}
if (Utilities.isObject(arrayItem)) {
newArray.push(arrayItem.id);
} else {
newArray.push(arrayItem);
}
});
});
return newArray;
return newArray;
},
@@ -30,18 +30,18 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var modelsResource = $injector.has("modelsBuilderManagementResource") ? $injector.get("modelsBuilderManagementResource") : null;
var modelsBuilderEnabled = Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled;
if (modelsBuilderEnabled && modelsResource) {
modelsResource.buildModels().then(function(result) {
modelsResource.buildModels().then(function (result) {
deferred.resolve(result);
//just calling this to get the servar back to life
modelsResource.getModelsOutOfDateStatus();
}, function(e) {
}, function (e) {
deferred.reject(e);
});
}
else {
deferred.resolve(false);
else {
deferred.resolve(false);
}
return deferred.promise;
},
@@ -49,10 +49,10 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
checkModelsBuilderStatus: function () {
var deferred = $q.defer();
var modelsResource = $injector.has("modelsBuilderManagementResource") ? $injector.get("modelsBuilderManagementResource") : null;
var modelsBuilderEnabled = (Umbraco && Umbraco.Sys && Umbraco.Sys.ServerVariables && Umbraco.Sys.ServerVariables.umbracoPlugins && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled === true);
var modelsBuilderEnabled = (Umbraco && Umbraco.Sys && Umbraco.Sys.ServerVariables && Umbraco.Sys.ServerVariables.umbracoPlugins && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder && Umbraco.Sys.ServerVariables.umbracoPlugins.modelsBuilder.enabled === true);
if (modelsBuilderEnabled && modelsResource) {
modelsResource.getModelsOutOfDateStatus().then(function(result) {
modelsResource.getModelsOutOfDateStatus().then(function (result) {
//Generate models buttons should be enabled if it is 0
deferred.resolve(result.status === 0);
});
@@ -64,37 +64,37 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
},
makeObjectArrayFromId: function (idArray, objectArray) {
var newArray = [];
var newArray = [];
for (var idIndex = 0; idArray.length > idIndex; idIndex++) {
var id = idArray[idIndex];
for (var idIndex = 0; idArray.length > idIndex; idIndex++) {
var id = idArray[idIndex];
for (var objectIndex = 0; objectArray.length > objectIndex; objectIndex++) {
var object = objectArray[objectIndex];
if (id === object.id) {
newArray.push(object);
}
}
for (var objectIndex = 0; objectArray.length > objectIndex; objectIndex++) {
var object = objectArray[objectIndex];
if (id === object.id) {
newArray.push(object);
}
}
}
}
return newArray;
return newArray;
},
validateAddingComposition: function(contentType, compositeContentType) {
validateAddingComposition: function (contentType, compositeContentType) {
//Validate that by adding this group that we are not adding duplicate property type aliases
var propertiesAdding = _.flatten(_.map(compositeContentType.groups, function(g) {
return _.map(g.properties, function(p) {
var propertiesAdding = _.flatten(_.map(compositeContentType.groups, function (g) {
return _.map(g.properties, function (p) {
return p.alias;
});
}));
var propAliasesExisting = _.filter(_.flatten(_.map(contentType.groups, function(g) {
return _.map(g.properties, function(p) {
var propAliasesExisting = _.filter(_.flatten(_.map(contentType.groups, function (g) {
return _.map(g.properties, function (p) {
return p.alias;
});
})), function(f) {
})), function (f) {
return f !== null && f !== undefined;
});
@@ -108,7 +108,7 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
return [];
},
mergeCompositeContentType: function(contentType, compositeContentType) {
mergeCompositeContentType: function (contentType, compositeContentType) {
//Validate that there are no overlapping aliases
var overlappingAliases = this.validateAddingComposition(contentType, compositeContentType);
@@ -116,107 +116,107 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
throw new Error("Cannot add this composition, these properties already exist on the content type: " + overlappingAliases.join());
}
angular.forEach(compositeContentType.groups, function(compositionGroup) {
angular.forEach(compositeContentType.groups, function (compositionGroup) {
// order composition groups based on sort order
compositionGroup.properties = $filter('orderBy')(compositionGroup.properties, 'sortOrder');
// order composition groups based on sort order
compositionGroup.properties = $filter('orderBy')(compositionGroup.properties, 'sortOrder');
// get data type details
angular.forEach(compositionGroup.properties, function(property) {
dataTypeResource.getById(property.dataTypeId)
.then(function(dataType) {
property.dataTypeIcon = dataType.icon;
property.dataTypeName = dataType.name;
});
});
// get data type details
angular.forEach(compositionGroup.properties, function (property) {
dataTypeResource.getById(property.dataTypeId)
.then(function (dataType) {
property.dataTypeIcon = dataType.icon;
property.dataTypeName = dataType.name;
});
});
// set inherited state on tab
compositionGroup.inherited = true;
// set inherited state on tab
compositionGroup.inherited = true;
// set inherited state on properties
angular.forEach(compositionGroup.properties, function(compositionProperty) {
compositionProperty.inherited = true;
});
// set inherited state on properties
angular.forEach(compositionGroup.properties, function (compositionProperty) {
compositionProperty.inherited = true;
});
// set tab state
compositionGroup.tabState = "inActive";
// set tab state
compositionGroup.tabState = "inActive";
// if groups are named the same - merge the groups
angular.forEach(contentType.groups, function(contentTypeGroup) {
// if groups are named the same - merge the groups
angular.forEach(contentType.groups, function (contentTypeGroup) {
if (contentTypeGroup.name === compositionGroup.name) {
if (contentTypeGroup.name === compositionGroup.name) {
// set flag to show if properties has been merged into a tab
compositionGroup.groupIsMerged = true;
// set flag to show if properties has been merged into a tab
compositionGroup.groupIsMerged = true;
// make group inherited
contentTypeGroup.inherited = true;
// make group inherited
contentTypeGroup.inherited = true;
// add properties to the top of the array
contentTypeGroup.properties = compositionGroup.properties.concat(contentTypeGroup.properties);
// add properties to the top of the array
contentTypeGroup.properties = compositionGroup.properties.concat(contentTypeGroup.properties);
// update sort order on all properties in merged group
contentTypeGroup.properties = contentTypeHelperService.updatePropertiesSortOrder(contentTypeGroup.properties);
// update sort order on all properties in merged group
contentTypeGroup.properties = contentTypeHelperService.updatePropertiesSortOrder(contentTypeGroup.properties);
// make parentTabContentTypeNames to an array so we can push values
if (contentTypeGroup.parentTabContentTypeNames === null || contentTypeGroup.parentTabContentTypeNames === undefined) {
contentTypeGroup.parentTabContentTypeNames = [];
}
// push name to array of merged composite content types
contentTypeGroup.parentTabContentTypeNames.push(compositeContentType.name);
// make parentTabContentTypes to an array so we can push values
if (contentTypeGroup.parentTabContentTypes === null || contentTypeGroup.parentTabContentTypes === undefined) {
contentTypeGroup.parentTabContentTypes = [];
}
// push id to array of merged composite content types
contentTypeGroup.parentTabContentTypes.push(compositeContentType.id);
// get sort order from composition
contentTypeGroup.sortOrder = compositionGroup.sortOrder;
// splice group to the top of the array
var contentTypeGroupCopy = Utilities.copy(contentTypeGroup);
var index = contentType.groups.indexOf(contentTypeGroup);
contentType.groups.splice(index, 1);
contentType.groups.unshift(contentTypeGroupCopy);
}
});
// if group is not merged - push it to the end of the array - before init tab
if (compositionGroup.groupIsMerged === false || compositionGroup.groupIsMerged === undefined) {
// make parentTabContentTypeNames to an array so we can push values
if (contentTypeGroup.parentTabContentTypeNames === null || contentTypeGroup.parentTabContentTypeNames === undefined) {
contentTypeGroup.parentTabContentTypeNames = [];
if (compositionGroup.parentTabContentTypeNames === null || compositionGroup.parentTabContentTypeNames === undefined) {
compositionGroup.parentTabContentTypeNames = [];
}
// push name to array of merged composite content types
contentTypeGroup.parentTabContentTypeNames.push(compositeContentType.name);
compositionGroup.parentTabContentTypeNames.push(compositeContentType.name);
// make parentTabContentTypes to an array so we can push values
if (contentTypeGroup.parentTabContentTypes === null || contentTypeGroup.parentTabContentTypes === undefined) {
contentTypeGroup.parentTabContentTypes = [];
if (compositionGroup.parentTabContentTypes === null || compositionGroup.parentTabContentTypes === undefined) {
compositionGroup.parentTabContentTypes = [];
}
// push id to array of merged composite content types
contentTypeGroup.parentTabContentTypes.push(compositeContentType.id);
compositionGroup.parentTabContentTypes.push(compositeContentType.id);
// get sort order from composition
contentTypeGroup.sortOrder = compositionGroup.sortOrder;
// push group before placeholder tab
contentType.groups.unshift(compositionGroup);
// splice group to the top of the array
var contentTypeGroupCopy = angular.copy(contentTypeGroup);
var index = contentType.groups.indexOf(contentTypeGroup);
contentType.groups.splice(index, 1);
contentType.groups.unshift(contentTypeGroupCopy);
}
}
});
});
// sort all groups by sortOrder property
contentType.groups = $filter('orderBy')(contentType.groups, 'sortOrder');
// if group is not merged - push it to the end of the array - before init tab
if (compositionGroup.groupIsMerged === false || compositionGroup.groupIsMerged === undefined) {
// make parentTabContentTypeNames to an array so we can push values
if (compositionGroup.parentTabContentTypeNames === null || compositionGroup.parentTabContentTypeNames === undefined) {
compositionGroup.parentTabContentTypeNames = [];
}
// push name to array of merged composite content types
compositionGroup.parentTabContentTypeNames.push(compositeContentType.name);
// make parentTabContentTypes to an array so we can push values
if (compositionGroup.parentTabContentTypes === null || compositionGroup.parentTabContentTypes === undefined) {
compositionGroup.parentTabContentTypes = [];
}
// push id to array of merged composite content types
compositionGroup.parentTabContentTypes.push(compositeContentType.id);
// push group before placeholder tab
contentType.groups.unshift(compositionGroup);
}
});
// sort all groups by sortOrder property
contentType.groups = $filter('orderBy')(contentType.groups, 'sortOrder');
return contentType;
return contentType;
},
@@ -224,22 +224,22 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
var groups = [];
angular.forEach(contentType.groups, function(contentTypeGroup){
angular.forEach(contentType.groups, function (contentTypeGroup) {
if( contentTypeGroup.tabState !== "init" ) {
if (contentTypeGroup.tabState !== "init") {
var idIndex = contentTypeGroup.parentTabContentTypes.indexOf(compositeContentType.id);
var nameIndex = contentTypeGroup.parentTabContentTypeNames.indexOf(compositeContentType.name);
var groupIndex = contentType.groups.indexOf(contentTypeGroup);
if( idIndex !== -1 ) {
if (idIndex !== -1) {
var properties = [];
// remove all properties from composite content type
angular.forEach(contentTypeGroup.properties, function(property){
if(property.contentTypeId !== compositeContentType.id) {
angular.forEach(contentTypeGroup.properties, function (property) {
if (property.contentTypeId !== compositeContentType.id) {
properties.push(property);
}
});
@@ -252,22 +252,22 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
contentTypeGroup.parentTabContentTypeNames.splice(nameIndex, 1);
// remove inherited state if there are no inherited properties
if(contentTypeGroup.parentTabContentTypes.length === 0) {
if (contentTypeGroup.parentTabContentTypes.length === 0) {
contentTypeGroup.inherited = false;
}
// remove group if there are no properties left
if(contentTypeGroup.properties.length > 1) {
if (contentTypeGroup.properties.length > 1) {
//contentType.groups.splice(groupIndex, 1);
groups.push(contentTypeGroup);
}
} else {
groups.push(contentTypeGroup);
groups.push(contentTypeGroup);
}
} else {
groups.push(contentTypeGroup);
groups.push(contentTypeGroup);
}
// update sort order on properties
@@ -281,67 +281,67 @@ function contentTypeHelper(contentTypeResource, dataTypeResource, $filter, $inje
updatePropertiesSortOrder: function (properties) {
var sortOrder = 0;
var sortOrder = 0;
angular.forEach(properties, function(property) {
if( !property.inherited && property.propertyState !== "init") {
property.sortOrder = sortOrder;
}
sortOrder++;
});
angular.forEach(properties, function (property) {
if (!property.inherited && property.propertyState !== "init") {
property.sortOrder = sortOrder;
}
sortOrder++;
});
return properties;
return properties;
},
getTemplatePlaceholder: function() {
getTemplatePlaceholder: function () {
var templatePlaceholder = {
"name": "",
"icon": "icon-layout",
"alias": "templatePlaceholder",
"placeholder": true
};
var templatePlaceholder = {
"name": "",
"icon": "icon-layout",
"alias": "templatePlaceholder",
"placeholder": true
};
return templatePlaceholder;
return templatePlaceholder;
},
insertDefaultTemplatePlaceholder: function(defaultTemplate) {
insertDefaultTemplatePlaceholder: function (defaultTemplate) {
// get template placeholder
var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
// get template placeholder
var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
// add as default template
defaultTemplate = templatePlaceholder;
// add as default template
defaultTemplate = templatePlaceholder;
return defaultTemplate;
return defaultTemplate;
},
insertTemplatePlaceholder: function(array) {
insertTemplatePlaceholder: function (array) {
// get template placeholder
var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
// get template placeholder
var templatePlaceholder = contentTypeHelperService.getTemplatePlaceholder();
// add as selected item
array.push(templatePlaceholder);
// add as selected item
array.push(templatePlaceholder);
return array;
return array;
},
},
insertChildNodePlaceholder: function (array, name, icon, id) {
insertChildNodePlaceholder: function (array, name, icon, id) {
var placeholder = {
"name": name,
"icon": icon,
"id": id
};
var placeholder = {
"name": name,
"icon": icon,
"id": id
};
array.push(placeholder);
array.push(placeholder);
}
}
};
@@ -164,14 +164,14 @@ When building a custom infinite editor view you can use the same components as a
"use strict";
function editorService(eventsService, keyboardService, $timeout) {
let editorsKeyboardShorcuts = [];
var editors = [];
var isEnabled = true;
var lastElementInFocus = null;
// events for backdrop
eventsService.on("appState.backdrop", function (name, args) {
if (args.show === true) {
@@ -180,7 +180,7 @@ When building a custom infinite editor view you can use the same components as a
focus();
}
});
/**
* @ngdoc method
@@ -205,7 +205,7 @@ When building a custom infinite editor view you can use the same components as a
function getNumberOfEditors() {
return editors.length;
};
/**
* @ngdoc method
* @name umbraco.services.editorService#blur
@@ -232,7 +232,7 @@ When building a custom infinite editor view you can use the same components as a
* Method to tell editors that they are gaining focus again.
*/
function focus() {
if(isEnabled === false) {
if (isEnabled === false) {
/* keyboard shortcuts will be overwritten by the new infinite editor
so we need to store the shortcuts for the current editor so they can be rebound
when the infinite editor closes
@@ -241,7 +241,7 @@ When building a custom infinite editor view you can use the same components as a
isEnabled = true;
}
}
/**
* @ngdoc method
* @name umbraco.services.editorService#open
@@ -305,7 +305,7 @@ When building a custom infinite editor view you can use the same components as a
// delay required to map the properties to the correct editor due
// to another delay in the closing animation of the editor
$timeout(function() {
$timeout(function () {
// rebind keyboard shortcuts for the new editor in focus
rebindKeyboardShortcuts();
@@ -651,7 +651,7 @@ When building a custom infinite editor view you can use the same components as a
editor.view = "views/mediatypes/edit.html";
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#memberTypeEditor
@@ -928,21 +928,21 @@ When building a custom infinite editor view you can use the same components as a
open(editor);
}
/**
* @ngdoc method
* @name umbraco.services.editorService#memberPicker
* @methodOf umbraco.services.editorService
*
* @description
* Opens a member picker in infinite editing, the submit callback returns an array of selected items
*
* @param {Object} editor rendering options
* @param {Boolean} editor.multiPicker Pick one or multiple items
* @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
* @param {Function} editor.close Callback function when the close button is clicked.
*
* @returns {Object} editor object
*/
/**
* @ngdoc method
* @name umbraco.services.editorService#memberPicker
* @methodOf umbraco.services.editorService
*
* @description
* Opens a member picker in infinite editing, the submit callback returns an array of selected items
*
* @param {Object} editor rendering options
* @param {Boolean} editor.multiPicker Pick one or multiple items
* @param {Function} editor.submit Callback function when the submit button is clicked. Returns the editor model object
* @param {Function} editor.close Callback function when the close button is clicked.
*
* @returns {Object} editor object
*/
function memberPicker(editor) {
editor.view = "views/common/infiniteeditors/treepicker/treepicker.html";
if (!editor.size) editor.size = "small";
@@ -985,7 +985,7 @@ When building a custom infinite editor view you can use the same components as a
*
*/
function unbindKeyboardShortcuts() {
const shortcuts = angular.copy(keyboardService.keyboardEvent);
const shortcuts = Utilities.copy(keyboardService.keyboardEvent);
editorsKeyboardShorcuts.push(shortcuts);
// unbind the current shortcuts because we only want to
@@ -26,60 +26,60 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
navReadyPromise.resolve(mainTreeApi);
});
//A list of query strings defined that when changed will not cause a reload of the route
var nonRoutingQueryStrings = ["mculture", "cculture", "lq", "sr"];
var retainedQueryStrings = ["mculture"];
function setMode(mode) {
switch (mode) {
case 'tree':
appState.setGlobalState("navMode", "tree");
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", false);
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showTray", false);
break;
case 'menu':
appState.setGlobalState("navMode", "menu");
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", true);
appState.setMenuState("showMenuDialog", false);
appState.setGlobalState("stickyNavigation", true);
break;
case 'dialog':
appState.setGlobalState("navMode", "dialog");
appState.setGlobalState("stickyNavigation", true);
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", true);
appState.setMenuState("allowHideMenuDialog", true);
break;
case 'search':
appState.setGlobalState("navMode", "search");
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setSectionState("showSearchResults", true);
appState.setMenuState("showMenuDialog", false);
break;
default:
appState.setGlobalState("navMode", "default");
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", false);
appState.setMenuState("allowHideMenuDialog", true);
appState.setSectionState("showSearchResults", false);
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showTray", false);
appState.setMenuState("currentNode", null);
case 'tree':
appState.setGlobalState("navMode", "tree");
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", false);
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showTray", false);
break;
case 'menu':
appState.setGlobalState("navMode", "menu");
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", true);
appState.setMenuState("showMenuDialog", false);
appState.setGlobalState("stickyNavigation", true);
break;
case 'dialog':
appState.setGlobalState("navMode", "dialog");
appState.setGlobalState("stickyNavigation", true);
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", true);
appState.setMenuState("allowHideMenuDialog", true);
break;
case 'search':
appState.setGlobalState("navMode", "search");
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showNavigation", true);
appState.setMenuState("showMenu", false);
appState.setSectionState("showSearchResults", true);
appState.setMenuState("showMenuDialog", false);
break;
default:
appState.setGlobalState("navMode", "default");
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", false);
appState.setMenuState("allowHideMenuDialog", true);
appState.setSectionState("showSearchResults", false);
appState.setGlobalState("stickyNavigation", false);
appState.setGlobalState("showTray", false);
appState.setMenuState("currentNode", null);
if (appState.getGlobalState("isTablet") === true) {
appState.setGlobalState("showNavigation", false);
}
if (appState.getGlobalState("isTablet") === true) {
appState.setGlobalState("showNavigation", false);
}
break;
break;
}
}
@@ -114,7 +114,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
}
var service = {
/**
* @ngdoc method
* @name umbraco.services.navigationService#isRouteChangingNavigation
@@ -151,7 +151,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
var nextRoutingKeys = _.difference(_.keys(nextUrlParams), nonRoutingQueryStrings);
var diff1 = _.difference(currRoutingKeys, nextRoutingKeys);
var diff2 = _.difference(nextRoutingKeys, currRoutingKeys);
//if the routing parameter keys are the same, we'll compare their values to see if any have changed and if so then the routing will be allowed.
if (diff1.length === 0 && diff2.length === 0) {
var partsChanged = 0;
@@ -223,7 +223,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @param {Object} nextRouteParams The next route parameters
*/
retainQueryStrings: function (currRouteParams, nextRouteParams) {
var toRetain = angular.copy(nextRouteParams);
var toRetain = Utilities.copy(nextRouteParams);
var updated = false;
_.each(retainedQueryStrings, function (r) {
@@ -260,7 +260,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* and load the dashboard related to the section
* @param {string} sectionAlias The alias of the section
*/
changeSection: function(sectionAlias, force) {
changeSection: function (sectionAlias, force) {
setMode("default-opensection");
if (force && appState.getSectionState("currentSection") === sectionAlias) {
@@ -360,19 +360,19 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
TODO: Delete this if not required
*/
_syncPath: function(path, forceReload) {
_syncPath: function (path, forceReload) {
return navReadyPromise.promise.then(function () {
return mainTreeApi.syncTree({ path: path, forceReload: forceReload });
});
},
reloadNode: function(node) {
reloadNode: function (node) {
return navReadyPromise.promise.then(function () {
return mainTreeApi.reloadNode(node);
});
},
reloadSection: function(sectionAlias) {
reloadSection: function (sectionAlias) {
return navReadyPromise.promise.then(function () {
treeService.clearCache({ section: sectionAlias });
return mainTreeApi.load(sectionAlias);
@@ -387,11 +387,11 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* Hides the tree by hiding the containing dom element
*/
hideTree: function() {
hideTree: function () {
if (appState.getGlobalState("isTablet") === true && !appState.getGlobalState("stickyNavigation")) {
//reset it to whatever is in the url
appState.setSectionState("currentSection", $routeParams.section);
appState.setSectionState("currentSection", $routeParams.section);
setMode("default-hidesectiontree");
}
@@ -409,19 +409,19 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
*
* @param {Event} event the click event triggering the method, passed from the DOM element
*/
showMenu: function(args) {
showMenu: function (args) {
var self = this;
return treeService.getMenu({ treeNode: args.node })
.then(function(data) {
.then(function (data) {
//check for a default
//NOTE: event will be undefined when a call to hideDialog is made so it won't re-load the default again.
// but perhaps there's a better way to deal with with an additional parameter in the args ? it works though.
if (data.defaultAlias && !args.skipDefault) {
var found = _.find(data.menuItems, function(item) {
var found = _.find(data.menuItems, function (item) {
return item.alias = data.defaultAlias;
});
@@ -450,7 +450,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
return $q.resolve();
});
},
/**
@@ -461,7 +461,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* Hides the menu by hiding the containing dom element
*/
hideMenu: function() {
hideMenu: function () {
//SD: Would we ever want to access the last action'd node instead of clearing it here?
appState.setMenuState("currentNode", null);
appState.setMenuState("menuActions", []);
@@ -532,7 +532,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
});
}
},
/**
* @ngdoc method
@@ -553,7 +553,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @param {Scope} args.scope current scope passed to the dialog
* @param {Object} args.action the clicked action containing `name` and `alias`
*/
showDialog: function(args) {
showDialog: function (args) {
if (!args) {
throw "showDialog is missing the args parameter";
@@ -578,20 +578,20 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
if (args.action.metaData["actionView"]) {
templateUrl = args.action.metaData["actionView"];
}
else {
else {
var treeAlias = treeService.getTreeAlias(args.node);
if (!treeAlias) {
throw "Could not get tree alias for node " + args.node.id;
}
}
templateUrl = this.getTreeTemplateUrl(treeAlias, args.action.alias);
}
setMode("dialog");
if(templateUrl) {
if (templateUrl) {
appState.setMenuState("dialogTemplateUrl", templateUrl);
}
},
/**
* @ngdoc method
@@ -607,7 +607,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* we will also check for a 'packageName' for the current tree, if it exists then the convention will be:
* for example: /App_Plugins/{mypackage}/backoffice/{treetype}/create.html
*/
getTreeTemplateUrl: function(treeAlias, action) {
getTreeTemplateUrl: function (treeAlias, action) {
var packageTreeFolder = treeService.getTreePackageFolder(treeAlias);
if (packageTreeFolder) {
return Umbraco.Sys.ServerVariables.umbracoSettings.appPluginsPath +
@@ -661,7 +661,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* shows the search pane
*/
showSearch: function() {
showSearch: function () {
setMode("search");
},
/**
@@ -672,7 +672,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* hides the search pane
*/
hideSearch: function() {
hideSearch: function () {
setMode("default-hidesearch");
},
/**
@@ -683,7 +683,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @description
* hides any open navigation panes and resets the tree, actions and the currently selected node
*/
hideNavigation: function() {
hideNavigation: function () {
appState.setMenuState("menuActions", []);
setMode("default");
}
+5 -5
View File
@@ -34,7 +34,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
else {
const introTourShown = localStorageService.get("introTourShown");
if(!introTourShown){
if (!introTourShown) {
// Go & show email marketing tour (ONLY when intro tour is completed or been dismissed)
tourService.getTourByAlias("umbEmailMarketing").then(function (emailMarketingTour) {
// Only show the email marketing tour one time - dismissing it or saying no will make sure it never appears again
@@ -45,7 +45,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
// Only show the email tour once per logged in session
// The localstorage key is removed on logout or user session timeout
const emailMarketingTourShown = localStorageService.get("emailMarketingTourShown");
if(!emailMarketingTourShown){
if (!emailMarketingTourShown) {
tourService.startTour(emailMarketingTour);
localStorageService.set("emailMarketingTourShown", true);
}
@@ -89,7 +89,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams = toRetain;
}
else {
currentRouteParams = angular.copy(current.params);
currentRouteParams = Utilities.copy(current.params);
}
@@ -183,7 +183,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams = toRetain;
}
else {
currentRouteParams = angular.copy(next.params);
currentRouteParams = Utilities.copy(next.params);
}
//always clear the 'sr' query string (soft redirect) if it exists
@@ -191,7 +191,7 @@ app.run(['$rootScope', '$route', '$location', 'urlHelper', 'navigationService',
currentRouteParams.sr = null;
$route.updateParams(currentRouteParams);
}
}
}
});
@@ -17,7 +17,7 @@
/* make a copy of the init model so it is possible to roll
back the changes on cancel */
oldModel = angular.copy($scope.model);
oldModel = Utilities.copy($scope.model);
if (!$scope.model.title) {
$scope.model.title = "Compositions";
@@ -39,7 +39,7 @@
});
}
function isSelected(alias) {
if ($scope.model.contentType.compositeContentTypes.indexOf(alias) !== -1) {
@@ -68,7 +68,7 @@
or the confirm checkbox has been checked */
if (compositionRemoved) {
vm.allowSubmit = false;
localizationService.localize("general_remove").then(function(value) {
localizationService.localize("general_remove").then(function (value) {
const dialog = {
view: "views/common/infiniteeditors/compositions/overlays/confirmremove.html",
title: value,
@@ -1,7 +1,7 @@
//used for the media picker dialog
angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
function ($scope, eventsService, entityResource, mediaResource, mediaHelper, udiParser, userService, localizationService, editorService) {
var vm = this;
var dialogOptions = $scope.model;
@@ -16,7 +16,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
if (!$scope.model.title) {
localizationService.localize("defaultdialogs_selectLink")
.then(function(value) {
.then(function (value) {
$scope.model.title = value;
});
}
@@ -59,7 +59,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
if (dialogOptions.currentTarget) {
// clone the current target so we don't accidentally update the caller's model while manipulating $scope.model.target
$scope.model.target = angular.copy(dialogOptions.currentTarget);
$scope.model.target = Utilities.copy(dialogOptions.currentTarget);
// if we have a node ID, we fetch the current node to build the form data
if ($scope.model.target.id || $scope.model.target.udi) {
@@ -194,7 +194,7 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
tree: "content"
});
},
close: function() {
close: function () {
editorService.close();
}
};
@@ -251,13 +251,13 @@ angular.module("umbraco").controller("Umbraco.Editors.LinkPickerController",
}
function close() {
if($scope.model && $scope.model.close) {
if ($scope.model && $scope.model.close) {
$scope.model.close();
}
}
function submit() {
if($scope.model && $scope.model.submit) {
if ($scope.model && $scope.model.submit) {
$scope.model.submit($scope.model);
}
}
@@ -57,7 +57,7 @@
};
if ($routeParams.create) {
vm.page.name = vm.labels.addLanguage;
vm.page.name = vm.labels.addLanguage;
}
});
@@ -87,14 +87,14 @@
if (!$routeParams.create) {
promises.push(languageResource.getById($routeParams.id).then(function(lang) {
promises.push(languageResource.getById($routeParams.id).then(function (lang) {
vm.language = lang;
vm.page.name = vm.language.name;
/* we need to store the initial default state so we can disable the toggle if it is the default.
we need to prevent from not having a default language. */
vm.initIsDefault = angular.copy(vm.language.isDefault);
vm.initIsDefault = Utilities.copy(vm.language.isDefault);
makeBreadcrumbs();
@@ -182,12 +182,12 @@
function toggleDefault() {
// it shouldn't be possible to uncheck the default language
if(vm.initIsDefault) {
if (vm.initIsDefault) {
return;
}
vm.language.isDefault = !vm.language.isDefault;
if(vm.language.isDefault) {
if (vm.language.isDefault) {
vm.showDefaultLanguageInfo = true;
} else {
vm.showDefaultLanguageInfo = false;
@@ -40,7 +40,7 @@
vm.versionRegex = /^(\d+\.)(\d+\.)(\*|\d+)$/;
function onInit() {
if (create) {
// Pre populate package with some values
packageResource.getEmpty().then(scaffold => {
@@ -78,7 +78,7 @@
});
localizationService.localizeMany(["buttons_save", "packager_includeAllChildNodes"]).then(function (values) {
vm.labels.button = values[0];
vm.labels.includeAllChildNodes = values[1];
@@ -232,7 +232,7 @@
function openFilePicker() {
let selection = angular.copy(vm.package.files);
let selection = Utilities.copy(vm.package.files);
const filePicker = {
title: "Select files",
@@ -185,7 +185,7 @@ angular.module("umbraco")
var rteId = value.id;
if ($.inArray(rteId, notIncludedRte) < 0) {
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId })
if (editor) {
@@ -197,17 +197,17 @@ angular.module("umbraco")
}
else {
$(event.target).find(".umb-rte").each(function () {
var rteId = $(this).attr("id");
if ($.inArray(rteId, notIncludedRte) < 0) {
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId })
if (editor) {
draggedRteSettings[rteId] = editor.settings;
}
notIncludedRte.splice(0, 0, $(this).attr("id"));
}
});
@@ -227,12 +227,12 @@ angular.module("umbraco")
// reset dragged RTE settings in case a RTE isn't dragged
draggedRteSettings = {};
notIncludedRte = [];
ui.item[0].style.display = "block";
ui.item.find(".umb-rte").each(function (key, value) {
var rteId = value.id;
// remember this RTEs settings, cause we need to update it later.
var editor = _.findWhere(tinyMCE.editors, { id: rteId });
@@ -255,17 +255,17 @@ angular.module("umbraco")
ui.item.offsetParent().find(".umb-rte").each(function (key, value) {
var rteId = value.id;
if ($.inArray(rteId, notIncludedRte) < 0) {
var editor = _.findWhere(tinyMCE.editors, { id: rteId });
if (editor) {
draggedRteSettings[rteId] = editor.settings;
}
// add all dragged's neighbouring RTEs in the new cell
notIncludedRte.splice(0, 0, rteId);
}
});
// reconstruct the dragged RTE (could be undefined when dragging something else than RTE)
if (draggedRteSettings !== undefined) {
tinyMCE.init(draggedRteSettings);
@@ -327,13 +327,13 @@ angular.module("umbraco")
title: title,
availableItems: area.$allowedEditors,
event: event,
submit: function(model) {
submit: function (model) {
if (model.selectedItem) {
$scope.addControl(model.selectedItem, area, index);
overlayService.close();
}
},
close: function() {
close: function () {
overlayService.close();
}
});
@@ -345,7 +345,7 @@ angular.module("umbraco")
// *********************************************
$scope.addTemplate = function (template) {
$scope.model.value = angular.copy(template);
$scope.model.value = Utilities.copy(template);
//default row data
_.forEach($scope.model.value.sections, function (section) {
@@ -387,7 +387,7 @@ angular.module("umbraco")
$scope.addRow = function (section, layout, isInit) {
//copy the selected layout into the rows collection
var row = angular.copy(layout);
var row = Utilities.copy(layout);
// Init row value
row = $scope.initRow(row);
@@ -408,7 +408,7 @@ angular.module("umbraco")
setTimeout(function () {
var newRowEl = $element.find("[data-rowid='" + row.$uniqueId + "']");
if(newRowEl !== null) {
if (newRowEl !== null) {
newRowEl.focus();
}
}, 0);
@@ -467,10 +467,10 @@ angular.module("umbraco")
var styles, config;
if (itemType === 'control') {
styles = null;
config = angular.copy(gridItem.editor.config.settings);
config = Utilities.copy(gridItem.editor.config.settings);
} else {
styles = _.filter(angular.copy($scope.model.config.items.styles), function (item) { return shouldApply(item, itemType, gridItem); });
config = _.filter(angular.copy($scope.model.config.items.config), function (item) { return shouldApply(item, itemType, gridItem); });
styles = _.filter(Utilities.copy($scope.model.config.items.styles), function (item) { return shouldApply(item, itemType, gridItem); });
config = _.filter(Utilities.copy($scope.model.config.items.config), function (item) { return shouldApply(item, itemType, gridItem); });
}
if (Utilities.isObject(gridItem.config)) {
@@ -763,7 +763,7 @@ angular.module("umbraco")
// allowed for this template based on the current config.
_.each(found.sections, function (templateSection, index) {
angular.extend($scope.model.value.sections[index], angular.copy(templateSection));
angular.extend($scope.model.value.sections[index], Utilities.copy(templateSection));
});
}
@@ -835,7 +835,7 @@ angular.module("umbraco")
return null;
} else {
//make a copy to not touch the original config
original = angular.copy(original);
original = Utilities.copy(original);
original.styles = row.styles;
original.config = row.config;
original.hasConfig = gridItemHasConfig(row.styles, row.config);
@@ -1,296 +1,296 @@
angular.module("umbraco")
.controller("Umbraco.PropertyEditors.GridPrevalueEditorController",
function ($scope, gridService, editorService) {
function ($scope, gridService, editorService) {
var emptyModel = {
styles:[
{
label: "Set a background image",
description: "Set a row background",
key: "background-image",
view: "imagepicker",
modifier: "url({0})"
}
],
config:[
{
label: "Class",
description: "Set a css class",
key: "class",
view: "textstring"
}
],
columns: 12,
templates:[
{
name: "1 column layout",
sections: [
{
grid: 12
}
]
},
{
name: "2 column layout",
sections: [
{
grid: 4
},
{
grid: 8
}
]
}
],
layouts:[
{
label: "Headline",
name: "Headline",
areas: [
{
grid: 12,
editors: ["headline"]
}
]
},
{
label: "Article",
name: "Article",
areas: [
{
grid: 4
},
{
grid: 8
}
]
}
]
};
/****************
template
*****************/
$scope.configureTemplate = function(template) {
var index = $scope.model.value.templates.indexOf(template);
if (template === undefined) {
template = {
name: "",
sections: [
]
};
}
var layoutConfigOverlay = {
currentLayout: angular.copy(template),
rows: $scope.model.value.layouts,
columns: $scope.model.value.columns,
view: "views/propertyEditors/grid/dialogs/layoutconfig.html",
size: "small",
submit: function (model) {
if (index === -1) {
$scope.model.value.templates.push(model);
} else {
$scope.model.value.templates[index] = model;
var emptyModel = {
styles: [
{
label: "Set a background image",
description: "Set a row background",
key: "background-image",
view: "imagepicker",
modifier: "url({0})"
}
editorService.close();
},
close: function(model) {
editorService.close();
}
],
config: [
{
label: "Class",
description: "Set a css class",
key: "class",
view: "textstring"
}
],
columns: 12,
templates: [
{
name: "1 column layout",
sections: [
{
grid: 12
}
]
},
{
name: "2 column layout",
sections: [
{
grid: 4
},
{
grid: 8
}
]
}
],
layouts: [
{
label: "Headline",
name: "Headline",
areas: [
{
grid: 12,
editors: ["headline"]
}
]
},
{
label: "Article",
name: "Article",
areas: [
{
grid: 4
},
{
grid: 8
}
]
}
]
};
editorService.open(layoutConfigOverlay);
};
/****************
template
*****************/
$scope.deleteTemplate = function(index){
$scope.model.value.templates.splice(index, 1);
};
$scope.configureTemplate = function (template) {
/****************
Row
*****************/
var index = $scope.model.value.templates.indexOf(template);
$scope.configureLayout = function(layout) {
if (template === undefined) {
template = {
name: "",
sections: [
var index = $scope.model.value.layouts.indexOf(layout);
if(layout === undefined){
layout = {
name: "",
areas:[
]
};
}
]
var layoutConfigOverlay = {
currentLayout: Utilities.copy(template),
rows: $scope.model.value.layouts,
columns: $scope.model.value.columns,
view: "views/propertyEditors/grid/dialogs/layoutconfig.html",
size: "small",
submit: function (model) {
if (index === -1) {
$scope.model.value.templates.push(model);
} else {
$scope.model.value.templates[index] = model;
}
editorService.close();
},
close: function (model) {
editorService.close();
}
};
}
var rowConfigOverlay = {
currentRow: angular.copy(layout),
editors: $scope.editors,
columns: $scope.model.value.columns,
view: "views/propertyEditors/grid/dialogs/rowconfig.html",
size: "small",
submit: function (model) {
if (index === -1) {
$scope.model.value.layouts.push(model);
} else {
$scope.model.value.layouts[index] = model;
}
editorService.close();
},
close: function(model) {
editorService.close();
}
};
editorService.open(rowConfigOverlay);
};
editorService.open(layoutConfigOverlay);
//var rowDeletesPending = false;
$scope.deleteLayout = function(index) {
var rowDeleteOverlay = {
dialogData: {
rowName: $scope.model.value.layouts[index].name
},
view: "views/propertyEditors/grid/dialogs/rowdeleteconfirm.html",
size: "small",
submit: function(model) {
$scope.model.value.layouts.splice(index, 1);
editorService.close();
},
close: function(model) {
editorService.close();
};
$scope.deleteTemplate = function (index) {
$scope.model.value.templates.splice(index, 1);
};
/****************
Row
*****************/
$scope.configureLayout = function (layout) {
var index = $scope.model.value.layouts.indexOf(layout);
if (layout === undefined) {
layout = {
name: "",
areas: [
]
};
}
var rowConfigOverlay = {
currentRow: Utilities.copy(layout),
editors: $scope.editors,
columns: $scope.model.value.columns,
view: "views/propertyEditors/grid/dialogs/rowconfig.html",
size: "small",
submit: function (model) {
if (index === -1) {
$scope.model.value.layouts.push(model);
} else {
$scope.model.value.layouts[index] = model;
}
editorService.close();
},
close: function (model) {
editorService.close();
}
};
editorService.open(rowConfigOverlay);
};
//var rowDeletesPending = false;
$scope.deleteLayout = function (index) {
var rowDeleteOverlay = {
dialogData: {
rowName: $scope.model.value.layouts[index].name
},
view: "views/propertyEditors/grid/dialogs/rowdeleteconfirm.html",
size: "small",
submit: function (model) {
$scope.model.value.layouts.splice(index, 1);
editorService.close();
},
close: function (model) {
editorService.close();
}
};
editorService.open(rowDeleteOverlay);
};
/****************
utillities
*****************/
$scope.toggleCollection = function (collection, toggle) {
if (toggle) {
collection = [];
} else {
collection = null;
}
};
editorService.open(rowDeleteOverlay);
};
$scope.percentage = function (spans) {
return ((spans / $scope.model.value.columns) * 100).toFixed(8);
};
/****************
utillities
*****************/
$scope.toggleCollection = function(collection, toggle){
if(toggle){
collection = [];
}else{
collection = null;
}
};
$scope.percentage = function(spans){
return ((spans / $scope.model.value.columns) * 100).toFixed(8);
};
$scope.zeroWidthFilter = function (cell) {
$scope.zeroWidthFilter = function (cell) {
return cell.grid > 0;
};
/****************
Config
*****************/
$scope.removeConfigValue = function(collection, index){
collection.splice(index, 1);
};
var editConfigCollection = function(configValues, title, callback) {
var editConfigCollectionOverlay = {
config: configValues,
title: title,
view: "views/propertyeditors/grid/dialogs/editconfig.html",
size: "small",
submit: function(model) {
callback(model.config);
editorService.close();
},
close: function(model) {
editorService.close();
}
};
editorService.open(editConfigCollectionOverlay);
};
/****************
Config
*****************/
$scope.editConfig = function() {
editConfigCollection($scope.model.value.config, "Settings", function(data) {
$scope.model.value.config = data;
});
};
$scope.removeConfigValue = function (collection, index) {
collection.splice(index, 1);
};
$scope.editStyles = function() {
editConfigCollection($scope.model.value.styles, "Styling", function(data){
$scope.model.value.styles = data;
});
};
var editConfigCollection = function (configValues, title, callback) {
/****************
editors
*****************/
gridService.getGridEditors().then(function(response){
$scope.editors = response.data;
});
var editConfigCollectionOverlay = {
config: configValues,
title: title,
view: "views/propertyeditors/grid/dialogs/editconfig.html",
size: "small",
submit: function (model) {
callback(model.config);
editorService.close();
},
close: function (model) {
editorService.close();
}
};
editorService.open(editConfigCollectionOverlay);
};
/* init grid data */
if (!$scope.model.value || $scope.model.value === "" || !$scope.model.value.templates) {
$scope.model.value = emptyModel;
} else {
$scope.editConfig = function () {
editConfigCollection($scope.model.value.config, "Settings", function (data) {
$scope.model.value.config = data;
});
};
if (!$scope.model.value.columns) {
$scope.model.value.columns = emptyModel.columns;
}
$scope.editStyles = function () {
editConfigCollection($scope.model.value.styles, "Styling", function (data) {
$scope.model.value.styles = data;
});
};
if (!$scope.model.value.config) {
$scope.model.value.config = [];
}
if (!$scope.model.value.styles) {
$scope.model.value.styles = [];
}
}
/****************
Clean up
*****************/
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
var ts = $scope.model.value.templates;
var ls = $scope.model.value.layouts;
_.each(ts, function(t){
_.each(t.sections, function(section, index){
if(section.grid === 0){
t.sections.splice(index, 1);
}
});
/****************
editors
*****************/
gridService.getGridEditors().then(function (response) {
$scope.editors = response.data;
});
_.each(ls, function(l){
_.each(l.areas, function(area, index){
if(area.grid === 0){
l.areas.splice(index, 1);
}
});
/* init grid data */
if (!$scope.model.value || $scope.model.value === "" || !$scope.model.value.templates) {
$scope.model.value = emptyModel;
} else {
if (!$scope.model.value.columns) {
$scope.model.value.columns = emptyModel.columns;
}
if (!$scope.model.value.config) {
$scope.model.value.config = [];
}
if (!$scope.model.value.styles) {
$scope.model.value.styles = [];
}
}
/****************
Clean up
*****************/
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
var ts = $scope.model.value.templates;
var ls = $scope.model.value.layouts;
_.each(ts, function (t) {
_.each(t.sections, function (section, index) {
if (section.grid === 0) {
t.sections.splice(index, 1);
}
});
});
_.each(ls, function (l) {
_.each(l.areas, function (area, index) {
if (area.grid === 0) {
l.areas.splice(index, 1);
}
});
});
});
});
//when the scope is destroyed we need to unsubscribe
$scope.$on('$destroy', function () {
unsubscribe();
});
//when the scope is destroyed we need to unsubscribe
$scope.$on('$destroy', function () {
unsubscribe();
});
});
});
@@ -1,223 +1,223 @@
angular.module('umbraco')
.controller("Umbraco.PropertyEditors.ImageCropperController",
function ($scope, fileManager, $timeout) {
function ($scope, fileManager, $timeout) {
var config = angular.copy($scope.model.config);
var config = Utilities.copy($scope.model.config);
$scope.filesSelected = onFileSelected;
$scope.filesChanged = onFilesChanged;
$scope.fileUploaderInit = onFileUploaderInit;
$scope.imageLoaded = imageLoaded;
$scope.crop = crop;
$scope.done = done;
$scope.clear = clear;
$scope.reset = reset;
$scope.close = close;
$scope.isCustomCrop = isCustomCrop;
$scope.focalPointChanged = focalPointChanged;
//declare a special method which will be called whenever the value has changed from the server
$scope.model.onValueChanged = onValueChanged;
$scope.filesSelected = onFileSelected;
$scope.filesChanged = onFilesChanged;
$scope.fileUploaderInit = onFileUploaderInit;
$scope.imageLoaded = imageLoaded;
$scope.crop = crop;
$scope.done = done;
$scope.clear = clear;
$scope.reset = reset;
$scope.close = close;
$scope.isCustomCrop = isCustomCrop;
$scope.focalPointChanged = focalPointChanged;
//declare a special method which will be called whenever the value has changed from the server
$scope.model.onValueChanged = onValueChanged;
/**
* Called when the umgImageGravity component updates the focal point value
* @param {any} left
* @param {any} top
*/
function focalPointChanged(left, top) {
//update the model focalpoint value
$scope.model.value.focalPoint = {
left: left,
top: top
/**
* Called when the umgImageGravity component updates the focal point value
* @param {any} left
* @param {any} top
*/
function focalPointChanged(left, top) {
//update the model focalpoint value
$scope.model.value.focalPoint = {
left: left,
top: top
};
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
/**
* Used to assign a new model value
* @param {any} src
*/
function setModelValueWithSrc(src) {
if (!$scope.model.value || !$scope.model.value.src) {
//we are copying to not overwrite the original config
$scope.model.value = angular.extend(Utilities.copy($scope.model.config), { src: src });
}
}
/**
* called whenever the value has changed from the server
* @param {any} newVal
* @param {any} oldVal
*/
function onValueChanged(newVal, oldVal) {
//clear current uploaded files
fileManager.setFiles({
propertyAlias: $scope.model.alias,
culture: $scope.model.culture,
files: []
});
}
/**
* Called when the a new file is selected
* @param {any} value
*/
function onFileSelected(value, files) {
setModelValueWithSrc(value);
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
function imageLoaded(isCroppable, hasDimensions) {
$scope.isCroppable = isCroppable;
$scope.hasDimensions = hasDimensions;
};
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
/**
* Used to assign a new model value
* @param {any} src
*/
function setModelValueWithSrc(src) {
if (!$scope.model.value || !$scope.model.value.src) {
//we are copying to not overwrite the original config
$scope.model.value = angular.extend(angular.copy($scope.model.config), { src: src });
}
}
/**
* called whenever the value has changed from the server
* @param {any} newVal
* @param {any} oldVal
*/
function onValueChanged(newVal, oldVal) {
//clear current uploaded files
fileManager.setFiles({
propertyAlias: $scope.model.alias,
culture: $scope.model.culture,
files: []
});
}
/**
* Called when the a new file is selected
* @param {any} value
*/
function onFileSelected(value, files) {
setModelValueWithSrc(value);
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
function imageLoaded (isCroppable, hasDimensions) {
$scope.isCroppable = isCroppable;
$scope.hasDimensions = hasDimensions;
};
/**
* Called when the file collection changes
* @param {any} value
* @param {any} files
*/
function onFilesChanged(files) {
if (files && files[0]) {
$scope.imageSrc = files[0].fileSrc;
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
}
/**
* Called when the file uploader initializes
* @param {any} value
*/
function onFileUploaderInit(value, files) {
//move previously saved value to the editor
if ($scope.model.value) {
//backwards compat with the old file upload (incase some-one swaps them..)
if (Utilities.isString($scope.model.value)) {
setModelValueWithSrc($scope.model.value);
}
else {
//sync any config changes with the editor and drop outdated crops
_.each($scope.model.value.crops, function (saved) {
var configured = _.find(config.crops, function (item) { return item.alias === saved.alias });
if (configured && configured.height === saved.height && configured.width === saved.width) {
configured.coordinates = saved.coordinates;
}
});
$scope.model.value.crops = config.crops;
//restore focalpoint if missing
if (!$scope.model.value.focalPoint) {
$scope.model.value.focalPoint = { left: 0.5, top: 0.5 };
}
}
//if there are already files in the client assigned then set the src
/**
* Called when the file collection changes
* @param {any} value
* @param {any} files
*/
function onFilesChanged(files) {
if (files && files[0]) {
$scope.imageSrc = files[0].fileSrc;
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
}
/**
* Called when the file uploader initializes
* @param {any} value
*/
function onFileUploaderInit(value, files) {
//move previously saved value to the editor
if ($scope.model.value) {
//backwards compat with the old file upload (incase some-one swaps them..)
if (Utilities.isString($scope.model.value)) {
setModelValueWithSrc($scope.model.value);
}
else {
//sync any config changes with the editor and drop outdated crops
_.each($scope.model.value.crops, function (saved) {
var configured = _.find(config.crops, function (item) { return item.alias === saved.alias });
if (configured && configured.height === saved.height && configured.width === saved.width) {
configured.coordinates = saved.coordinates;
}
});
$scope.model.value.crops = config.crops;
//restore focalpoint if missing
if (!$scope.model.value.focalPoint) {
$scope.model.value.focalPoint = { left: 0.5, top: 0.5 };
}
}
//if there are already files in the client assigned then set the src
if (files && files[0]) {
$scope.imageSrc = files[0].fileSrc;
}
else {
$scope.imageSrc = $scope.model.value.src;
}
}
}
/**
* crop a specific crop
* @param {any} targetCrop
*/
function crop(targetCrop) {
if (!$scope.currentCrop) {
// clone the crop so we can discard the changes
$scope.currentCrop = Utilities.copy(targetCrop);
$scope.currentPoint = null;
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
else {
$scope.imageSrc = $scope.model.value.src;
}
}
}
// we have a crop open already - close the crop (this will discard any changes made)
close();
/**
* crop a specific crop
* @param {any} targetCrop
*/
function crop(targetCrop) {
if (!$scope.currentCrop) {
// clone the crop so we can discard the changes
$scope.currentCrop = angular.copy(targetCrop);
$scope.currentPoint = null;
// the crop editor needs a digest cycle to close down properly, otherwise its state
// is reused for the new crop... and that's really bad
$timeout(function () {
crop(targetCrop);
$scope.pendingCrop = false;
});
// this is necessary to keep the screen from flickering too badly while we wait for the new crop to open
// - check the view for its usage (basically it makes sure we keep the space reserved for the new crop)
$scope.pendingCrop = true;
}
};
/** done cropping */
function done() {
if (!$scope.currentCrop) {
return;
}
// find the original crop by crop alias and update its coordinates
var editedCrop = _.find($scope.model.value.crops, crop => crop.alias === $scope.currentCrop.alias);
editedCrop.coordinates = $scope.currentCrop.coordinates;
$scope.close();
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
}
else {
// we have a crop open already - close the crop (this will discard any changes made)
close();
};
// the crop editor needs a digest cycle to close down properly, otherwise its state
// is reused for the new crop... and that's really bad
$timeout(function () {
crop(targetCrop);
$scope.pendingCrop = false;
function reset() {
$scope.currentCrop.coordinates = undefined;
$scope.done();
}
function close() {
$scope.currentCrop = undefined;
$scope.currentPoint = undefined;
}
/**
* crop a specific crop
* @param {any} crop
*/
function clear(crop) {
//clear current uploaded files
fileManager.setFiles({
propertyAlias: $scope.model.alias,
culture: $scope.model.culture,
files: []
});
// this is necessary to keep the screen from flickering too badly while we wait for the new crop to open
// - check the view for its usage (basically it makes sure we keep the space reserved for the new crop)
$scope.pendingCrop = true;
//clear the ui
$scope.imageSrc = null;
if ($scope.model.value) {
$scope.model.value = null;
}
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
};
function isCustomCrop(crop) {
return !!crop.coordinates;
}
};
/** done cropping */
function done() {
if (!$scope.currentCrop) {
return;
}
// find the original crop by crop alias and update its coordinates
var editedCrop = _.find($scope.model.value.crops, crop => crop.alias === $scope.currentCrop.alias);
editedCrop.coordinates = $scope.currentCrop.coordinates;
$scope.close();
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
};
function reset() {
$scope.currentCrop.coordinates = undefined;
$scope.done();
}
function close() {
$scope.currentCrop = undefined;
$scope.currentPoint = undefined;
}
/**
* crop a specific crop
* @param {any} crop
*/
function clear(crop) {
//clear current uploaded files
fileManager.setFiles({
propertyAlias: $scope.model.alias,
culture: $scope.model.culture,
files: []
var unsubscribe = $scope.$on("formSubmitting", function () {
$scope.currentCrop = null;
$scope.currentPoint = null;
});
//clear the ui
$scope.imageSrc = null;
if ($scope.model.value) {
$scope.model.value = null;
}
//set form to dirty to track changes
$scope.imageCropperForm.$setDirty();
};
function isCustomCrop(crop) {
return !!crop.coordinates;
}
var unsubscribe = $scope.$on("formSubmitting", function () {
$scope.currentCrop = null;
$scope.currentPoint = null;
});
$scope.$on('$destroy', function () {
unsubscribe();
});
})
$scope.$on('$destroy', function () {
unsubscribe();
});
})
.run(function (mediaHelper, umbRequestHelper) {
if (mediaHelper && mediaHelper.registerFileResolver) {
//NOTE: The 'entity' can be either a normal media entity or an "entity" returned from the entityResource
// they contain different data structures so if we need to query against it we need to be aware of this.
mediaHelper.registerFileResolver("Umbraco.ImageCropper", function (property, entity, thumbnail) {
@@ -14,7 +14,7 @@
});
function NestedContentController($scope, $interpolate, $filter, $timeout, contentResource, localizationService, iconHelper, clipboardService, eventsService, overlayService, $routeParams, editorState) {
var vm = this;
var model = $scope.$parent.$parent.model;
@@ -58,9 +58,9 @@
updateModel();
vm.currentNode = node;
}
var copyAllEntries = function() {
var copyAllEntries = function () {
syncCurrentNode();
// list aliases
@@ -68,14 +68,14 @@
// remove dublicates
aliases = aliases.filter((item, index) => aliases.indexOf(item) === index);
var nodeName = "";
if(vm.umbVariantContent) {
if (vm.umbVariantContent) {
nodeName = vm.umbVariantContent.editor.content.name;
}
localizationService.localize("clipboard_labelForArrayOfItemsFrom", [model.label, nodeName]).then(function(data) {
localizationService.localize("clipboard_labelForArrayOfItemsFrom", [model.label, nodeName]).then(function (data) {
clipboardService.copyArray("elementTypeArray", aliases, vm.nodes, data, "icon-thumbnail-list", model.id);
});
}
@@ -146,7 +146,7 @@
orderBy: "$index",
view: "itempicker",
event: $event,
clickPasteItem: function(item) {
clickPasteItem: function (item) {
if (item.type === "elementTypeArray") {
_.each(item.data, function (entry) {
pasteFromClipboard(entry);
@@ -183,9 +183,9 @@
if (vm.overlayMenu.availableItems.length === 0) {
return;
}
vm.overlayMenu.size = vm.overlayMenu.availableItems.length > 6 ? "medium" : "small";
vm.overlayMenu.pasteItems = [];
var singleEntriesForPaste = clipboardService.retriveEntriesOfType("elementType", contentTypeAliases);
@@ -197,7 +197,7 @@
icon: entry.icon
});
});
var arrayEntriesForPaste = clipboardService.retriveEntriesOfType("elementTypeArray", contentTypeAliases);
_.each(arrayEntriesForPaste, function (entry) {
vm.overlayMenu.pasteItems.push({
@@ -393,10 +393,10 @@
clipboardService.copy("elementType", node.contentTypeAlias, node);
$event.stopPropagation();
}
function pasteFromClipboard(newNode) {
if (newNode === undefined) {
return;
}
@@ -407,7 +407,7 @@
vm.nodes.push(newNode);
setDirty();
//updateModel();// done by setting current node...
setCurrentNode(newNode);
}
@@ -515,7 +515,7 @@
}
function createNode(scaffold, fromNcEntry) {
var node = angular.copy(scaffold);
var node = Utilities.copy(scaffold);
node.key = fromNcEntry && fromNcEntry.key ? fromNcEntry.key : String.CreateGuid();
@@ -596,12 +596,12 @@
}
var propertyActions = [
copyAllEntriesAction,
removeAllEntriesAction
];
this.$onInit = function () {
if (this.umbProperty) {
this.umbProperty.setPropertyActions(propertyActions);
@@ -8,7 +8,7 @@
var infiniteMode = $scope.model && $scope.model.infiniteMode;
var id = infiniteMode ? $scope.model.id : $routeParams.id;
var create = infiniteMode ? $scope.model.create : $routeParams.create;
vm.header = {};
vm.header.editorfor = "template_template";
vm.header.setPageTitle = true;
@@ -26,7 +26,7 @@
vm.page.insertDefaultButton = {
labelKey: "general_insert",
addEllipsis: "true",
handler: function() {
handler: function () {
vm.openInsertOverlay();
}
};
@@ -68,16 +68,16 @@
//Keyboard shortcuts for help dialog
vm.page.keyboardShortcutsOverview = [];
templateHelper.getGeneralShortcuts().then(function(data){
templateHelper.getGeneralShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
templateHelper.getEditorShortcuts().then(function(data){
templateHelper.getEditorShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
templateHelper.getTemplateEditorShortcuts().then(function(data){
templateHelper.getTemplateEditorShortcuts().then(function (data) {
vm.page.keyboardShortcutsOverview.push(data);
});
vm.save = function (suppressNotification) {
vm.page.saveButtonState = "busy";
@@ -87,36 +87,36 @@
saveMethod: templateResource.save,
scope: $scope,
content: vm.template,
rebindCallback: function (orignal, saved) {}
rebindCallback: function (orignal, saved) { }
}).then(function (saved) {
if (!suppressNotification) {
localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function(data){
if (!suppressNotification) {
localizationService.localizeMany(["speechBubbles_templateSavedHeader", "speechBubbles_templateSavedText"]).then(function (data) {
var header = data[0];
var message = data[1];
notificationsService.success(header, message);
});
}
}
vm.page.saveButtonState = "success";
vm.template = saved;
//sync state
if(!infiniteMode) {
if (!infiniteMode) {
editorState.set(vm.template);
}
// sync tree
// if master template alias has changed move the node to it's new location
if(!infiniteMode && oldMasterTemplateAlias !== vm.template.masterTemplateAlias) {
if (!infiniteMode && oldMasterTemplateAlias !== vm.template.masterTemplateAlias) {
// When creating a new template the id is -1. Make sure We don't remove the root node.
if (vm.page.menu.currentNode.id !== "-1") {
// move node to new location in tree
//first we need to remove the node that we're working on
treeService.removeNode(vm.page.menu.currentNode);
}
// update stored alias to the new one so the node won't move again unless the alias is changed again
oldMasterTemplateAlias = vm.template.masterTemplateAlias;
@@ -127,7 +127,7 @@
} else {
// normal tree sync
if(!infiniteMode) {
if (!infiniteMode) {
navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) {
vm.page.menu.currentNode = syncArgs.node;
});
@@ -138,7 +138,7 @@
// clear $dirty state on form
setFormState("pristine");
if(infiniteMode) {
if (infiniteMode) {
submit();
}
@@ -164,16 +164,16 @@
// load templates - used in the master template picker
templateResource.getAll()
.then(function(templates) {
.then(function (templates) {
vm.templates = templates;
});
if(create) {
if (create) {
templateResource.getScaffold((id)).then(function (template) {
vm.ready(template);
});
vm.ready(template);
});
} else {
templateResource.getById(id).then(function(template){
templateResource.getById(id).then(function (template) {
vm.ready(template);
});
}
@@ -181,26 +181,26 @@
};
vm.ready = function(template){
vm.page.loading = false;
vm.ready = function (template) {
vm.page.loading = false;
vm.template = template;
// if this is a new template, bind to the blur event on the name
if (create) {
$timeout(function() {
var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]'));
if (nameField) {
nameField.on('blur', function(event) {
if (event.target.value) {
vm.save(true);
}
});
}
});
}
// if this is a new template, bind to the blur event on the name
if (create) {
$timeout(function () {
var nameField = angular.element(document.querySelector('[data-element="editor-name-field"]'));
if (nameField) {
nameField.on('blur', function (event) {
if (event.target.value) {
vm.save(true);
}
});
}
});
}
// sync state
if(!infiniteMode) {
if (!infiniteMode) {
editorState.set(vm.template);
navigationService.syncTree({ tree: "templates", path: vm.template.path, forceReload: true }).then(function (syncArgs) {
vm.page.menu.currentNode = syncArgs.node;
@@ -208,7 +208,7 @@
}
// save state of master template to use for comparison when syncing the tree on save
oldMasterTemplateAlias = angular.copy(template.masterTemplateAlias);
oldMasterTemplateAlias = Utilities.copy(template.masterTemplateAlias);
// ace configuration
vm.aceOption = {
@@ -221,12 +221,12 @@
enableBasicAutocompletion: true,
enableLiveAutocompletion: false
},
onLoad: function(_editor) {
onLoad: function (_editor) {
vm.editor = _editor;
//Update the auto-complete method to use ctrl+alt+space
_editor.commands.bindKey("ctrl-alt-space", "startAutocomplete");
// Unassigns the keybinding (That was previously auto-complete)
// As conflicts with our own tree search shortcut
_editor.commands.bindKey("ctrl-space", null);
@@ -238,20 +238,20 @@
{
name: 'unSelectOrFindPrevious',
bindKey: 'Alt-Shift-K',
exec: function() {
exec: function () {
// Toggle the show keyboard shortcuts overlay
$scope.$apply(function(){
$scope.$apply(function () {
vm.showKeyboardShortcut = !vm.showKeyboardShortcut;
});
},
readOnly: true
},
{
name: 'insertUmbracoValue',
bindKey: 'Alt-Shift-V',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openPageFieldOverlay();
});
},
@@ -260,18 +260,18 @@
{
name: 'insertPartialView',
bindKey: 'Alt-Shift-P',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openPartialOverlay();
});
},
readOnly: true
},
{
{
name: 'insertDictionary',
bindKey: 'Alt-Shift-D',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openDictionaryItemOverlay();
});
},
@@ -280,8 +280,8 @@
{
name: 'insertUmbracoMacro',
bindKey: 'Alt-Shift-M',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openMacroOverlay();
});
},
@@ -290,8 +290,8 @@
{
name: 'insertQuery',
bindKey: 'Alt-Shift-Q',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openQueryBuilderOverlay();
});
},
@@ -300,8 +300,8 @@
{
name: 'insertSection',
bindKey: 'Alt-Shift-S',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openSectionsOverlay();
});
},
@@ -310,21 +310,21 @@
{
name: 'chooseMasterTemplate',
bindKey: 'Alt-Shift-T',
exec: function() {
$scope.$apply(function(){
exec: function () {
$scope.$apply(function () {
openMasterTemplateOverlay();
});
},
readOnly: true
}
]);
// initial cursor placement
// Keep cursor in name field if we are create a new template
// else set the cursor at the bottom of the code editor
if(!create) {
$timeout(function(){
if (!create) {
$timeout(function () {
vm.editor.navigateFileEnd();
vm.editor.focus();
persistCurrentLocation();
@@ -335,9 +335,9 @@
vm.editor.on("blur", persistCurrentLocation);
vm.editor.on("focus", persistCurrentLocation);
vm.editor.on("change", changeAceEditor);
}
}
}
};
vm.openPageFieldOverlay = openPageFieldOverlay;
@@ -363,15 +363,15 @@
partial: true,
umbracoField: true
},
submit: function(model) {
switch(model.insert.type) {
submit: function (model) {
switch (model.insert.type) {
case "macro":
var macroObject = macroService.collectValueData(model.insert.selectedMacro, model.insert.macroParams, "Mvc");
insert(macroObject.syntax);
break;
case "dictionary":
var code = templateHelper.getInsertDictionarySnippet(model.insert.node.name);
insert(code);
var code = templateHelper.getInsertDictionarySnippet(model.insert.node.name);
insert(code);
break;
case "partial":
var code = templateHelper.getInsertPartialSnippet(model.insert.node.parentId, model.insert.node.name);
@@ -383,7 +383,7 @@
}
editorService.close();
},
close: function(oldModel) {
close: function (oldModel) {
// close the dialog
editorService.close();
// focus editor
@@ -401,7 +401,7 @@
insert(macroObject.syntax);
editorService.close();
},
close: function() {
close: function () {
editorService.close();
vm.editor.focus();
}
@@ -431,7 +431,7 @@
"emptyStates_emptyDictionaryTree"
];
localizationService.localizeMany(labelKeys).then(function(values){
localizationService.localizeMany(labelKeys).then(function (values) {
var title = values[0];
var emptyStateMessage = values[1];
@@ -442,7 +442,7 @@
multiPicker: false,
title: title,
emptyStateMessage: emptyStateMessage,
select: function(node){
select: function (node) {
var code = templateHelper.getInsertDictionarySnippet(node.name);
insert(code);
editorService.close();
@@ -463,22 +463,22 @@
function openPartialOverlay() {
localizationService.localize("template_insertPartialView").then(function(value){
localizationService.localize("template_insertPartialView").then(function (value) {
var title = value;
var partialItem = {
section: "settings",
section: "settings",
treeAlias: "partialViews",
entityType: "partialView",
multiPicker: false,
title: title,
filter: function(i) {
if(i.name.indexOf(".cshtml") === -1 && i.name.indexOf(".vbhtml") === -1) {
filter: function (i) {
if (i.name.indexOf(".cshtml") === -1 && i.name.indexOf(".vbhtml") === -1) {
return true;
}
},
filterCssClass: "not-allowed",
select: function(node){
select: function (node) {
var code = templateHelper.getInsertPartialSnippet(node.parentId, node.name);
insert(code);
editorService.close();
@@ -505,7 +505,7 @@
close: function () {
editorService.close();
// focus editor
vm.editor.focus();
vm.editor.focus();
}
};
editorService.queryBuilder(queryBuilder);
@@ -515,7 +515,7 @@
function openSectionsOverlay() {
var templateSections = {
isMaster: vm.template.isMasterTemplate,
submit: function(model) {
submit: function (model) {
if (model.insertType === 'renderBody') {
var code = templateHelper.getRenderBodySnippet();
@@ -535,7 +535,7 @@
editorService.close();
},
close: function(model) {
close: function (model) {
editorService.close();
vm.editor.focus();
}
@@ -559,12 +559,12 @@
}
});
localizationService.localize("template_mastertemplate").then(function(value){
localizationService.localize("template_mastertemplate").then(function (value) {
var title = value;
var masterTemplate = {
title: title,
availableItems: availableMasterTemplates,
submit: function(model) {
submit: function (model) {
var template = model.selectedItem;
if (template && template.alias) {
vm.template.masterTemplateAlias = template.alias;
@@ -575,7 +575,7 @@
}
editorService.close();
},
close: function(oldModel) {
close: function (oldModel) {
// close dialog
editorService.close();
// focus editor
@@ -596,14 +596,14 @@
vm.template.masterTemplateAlias = null;
setLayout(null);
}
}
function getMasterTemplateName(masterTemplateAlias, templates) {
if(masterTemplateAlias) {
if (masterTemplateAlias) {
var templateName = "";
angular.forEach(templates, function(template){
if(template.alias === masterTemplateAlias) {
angular.forEach(templates, function (template) {
if (template.alias === masterTemplateAlias) {
templateName = template.name;
}
});
@@ -620,8 +620,8 @@
}
function setLayout(templatePath){
function setLayout(templatePath) {
var templateCode = vm.editor.getValue();
var newValue = templatePath;
var layoutDefRegex = new RegExp("(@{[\\s\\S]*?Layout\\s*?=\\s*?)(\"[^\"]*?\"|null)(;[\\s\\S]*?})", "gi");
@@ -645,7 +645,7 @@
vm.editor.setValue(templateCode);
vm.editor.clearSelection();
vm.editor.navigateFileStart();
vm.editor.focus();
// set form state to $dirty
setFormState("dirty");
@@ -668,7 +668,7 @@
str = str.replace("{0}", selectedContent);
vm.editor.insert(str);
vm.editor.focus();
// set form state to $dirty
setFormState("dirty");
}
@@ -682,14 +682,14 @@
}
function setFormState(state) {
// get the current form
var currentForm = angularHelper.getCurrentForm($scope);
// set state
if(state === "dirty") {
if (state === "dirty") {
currentForm.$setDirty();
} else if(state === "pristine") {
} else if (state === "pristine") {
currentForm.$setPristine();
}
}
@@ -699,18 +699,18 @@
}
function submit() {
if($scope.model.submit) {
if ($scope.model.submit) {
$scope.model.template = vm.template;
$scope.model.submit($scope.model);
}
}
function close() {
if($scope.model.close) {
if ($scope.model.close) {
$scope.model.close();
}
}
vm.init();
}
@@ -6,7 +6,7 @@
var vm = this;
var contentPickerOpen = false;
vm.page = {};
vm.page = {};
vm.page.rootIcon = "icon-folder";
vm.userGroup = {};
vm.labels = {};
@@ -63,9 +63,9 @@
});
} else {
// get user group
userGroupsResource.getUserGroup($routeParams.id).then(function (userGroup) {
vm.userGroup = userGroup;
formatGranularPermissionSelection();
userGroupsResource.getUserGroup($routeParams.id).then(function (userGroup) {
vm.userGroup = userGroup;
formatGranularPermissionSelection();
setSectionIcon(vm.userGroup.sections);
makeBreadcrumbs();
vm.loading = false;
@@ -101,7 +101,7 @@
function openSectionPicker() {
var currentSelection = [];
angular.copy(vm.userGroup.sections, currentSelection);
Utilities.copy(vm.userGroup.sections, currentSelection);
var sectionPicker = {
selection: currentSelection,
submit: function (model) {
@@ -166,7 +166,7 @@
function openUserPicker() {
var currentSelection = [];
angular.copy(vm.userGroup.users, currentSelection);
Utilities.copy(vm.userGroup.users, currentSelection);
var userPicker = {
selection: currentSelection,
submit: function (model) {
@@ -212,8 +212,8 @@
if (model.selection) {
var node = model.selection[0];
//check if this is already in our selection
var found = _.find(vm.userGroup.assignedPermissions, function(i) {
return i.id === node.id;
var found = _.find(vm.userGroup.assignedPermissions, function (i) {
return i.id === node.id;
});
node = found ? found : node;
setPermissionsForNode(node);
@@ -231,7 +231,7 @@
//clone the current defaults to pass to the model
if (!node.permissions) {
node.permissions = angular.copy(vm.userGroup.defaultPermissions);
node.permissions = Utilities.copy(vm.userGroup.defaultPermissions);
}
vm.nodePermissions = {
@@ -257,7 +257,7 @@
editorService.close();
if(contentPickerOpen) {
if (contentPickerOpen) {
editorService.close();
contentPickerOpen = false;
}
@@ -8,7 +8,7 @@
vm.page = {};
vm.page.rootIcon = "icon-folder";
vm.user = {
changePassword: null
changePassword: null
};
vm.breadcrumbs = [];
vm.showBackButton = true;
@@ -17,12 +17,12 @@
vm.maxFileSize = Umbraco.Sys.ServerVariables.umbracoSettings.maxFileSize + "KB";
vm.acceptedFileTypes = mediaHelper.formatFileTypes(Umbraco.Sys.ServerVariables.umbracoSettings.imageFileTypes);
vm.usernameIsEmail = Umbraco.Sys.ServerVariables.umbracoSettings.usernameIsEmail;
//create the initial model for change password
vm.changePasswordModel = {
config: {},
isChanging: false,
value: {}
config: {},
isChanging: false,
value: {}
};
vm.goToPage = goToPage;
@@ -38,7 +38,7 @@
vm.changeAvatar = changeAvatar;
vm.clearAvatar = clearAvatar;
vm.save = save;
vm.changePassword = changePassword;
vm.toggleChangePassword = toggleChangePassword;
@@ -83,40 +83,39 @@
//go get the config for the membership provider and add it to the model
authResource.getMembershipProviderConfig().then(function (data) {
vm.changePasswordModel.config = data;
vm.changePasswordModel.config = data;
//the user has a password if they are not states: Invited, NoCredentials
vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
//the user has a password if they are not states: Invited, NoCredentials
vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
vm.changePasswordModel.config.disableToggle = true;
vm.changePasswordModel.config.disableToggle = true;
//this is only relavent for membership providers now (it's basically obsolete)
vm.changePasswordModel.config.enableReset = false;
//this is only relavent for membership providers now (it's basically obsolete)
vm.changePasswordModel.config.enableReset = false;
//in the ASP.NET Identity world, this config option will allow an admin user to change another user's password
//if the user has access to the user section. So if this editor is being access, the user of course has access to this section.
//the authorization check is also done on the server side when submitted.
// only update the setting if not the current logged in user, otherwise leave the value as it is
// currently set in the web.config
if (!vm.user.isCurrentUser)
{
vm.changePasswordModel.config.allowManuallyChangingPassword = true;
}
vm.loading = false;
//in the ASP.NET Identity world, this config option will allow an admin user to change another user's password
//if the user has access to the user section. So if this editor is being access, the user of course has access to this section.
//the authorization check is also done on the server side when submitted.
// only update the setting if not the current logged in user, otherwise leave the value as it is
// currently set in the web.config
if (!vm.user.isCurrentUser) {
vm.changePasswordModel.config.allowManuallyChangingPassword = true;
}
vm.loading = false;
});
});
}
function getLocalDate(date, culture, format) {
if(date) {
if (date) {
var dateVal;
var serverOffset = Umbraco.Sys.ServerVariables.application.serverTimeOffset;
var localOffset = new Date().getTimezoneOffset();
var serverTimeNeedsOffsetting = (-serverOffset !== localOffset);
if(serverTimeNeedsOffsetting) {
if (serverTimeNeedsOffsetting) {
dateVal = dateHelper.convertToLocalMomentTime(date, serverOffset);
} else {
dateVal = moment(date, "YYYY-MM-DD HH:mm:ss");
@@ -144,11 +143,11 @@
submit: model => {
overlayService.close();
vm.changePasswordModel.value = model.changePassword;
changePassword();
changePassword();
}
};
overlayService.open(overlay);
});
});
}
function save() {
@@ -165,16 +164,16 @@
.then(function (saved) {
//if the user saved, then try to execute all extended save options
extendedSave(saved).then(function(result) {
extendedSave(saved).then(function (result) {
//if all is good, then reset the form
formHelper.resetForm({ scope: $scope });
}, Utilities.noop);
vm.user = _.omit(saved, "navigation");
//restore
vm.user.navigation = currentNav;
setUserDisplayState();
formatDatesToLocal(vm.user);
formatDatesToLocal(vm.user);
vm.page.saveButtonState = "success";
@@ -184,7 +183,7 @@
err: err,
showNotifications: true
});
vm.page.saveButtonState = "error";
});
}
@@ -201,15 +200,15 @@
//if allowManuallyChangingPassword=false, then we are using default settings and the user will need to enter their old password to change their own password.
vm.changePasswordModel.value.reset = (!vm.changePasswordModel.value.oldPassword && !vm.user.isCurrentUser) || vm.changePasswordModel.config.allowManuallyChangingPassword;
}
// since we don't send the entire user model, the id is required
vm.changePasswordModel.value.id = vm.user.id;
usersResource.changePassword(vm.changePasswordModel.value)
.then(() => {
vm.changePasswordModel.isChanging = false;
vm.changePasswordModel.value = {};
//the user has a password if they are not states: Invited, NoCredentials
vm.changePasswordModel.config.hasPassword = vm.user.userState !== 3 && vm.user.userState !== 4;
}, err => {
@@ -219,7 +218,7 @@
});
});
}
/**
* Used to emit the save event and await any async operations being performed by editor extensions
* @param {any} savedUser
@@ -228,7 +227,7 @@
//used to track any promises added by the event handlers to be awaited
var promises = [];
var args = {
//getPromise: getPromise,
user: savedUser,
@@ -240,10 +239,10 @@
//emit the event
eventsService.emit("editors.user.editController.save", args);
//await all promises to complete
var resultPromise = $q.all(promises);
return resultPromise;
}
@@ -253,7 +252,7 @@
function openUserGroupPicker() {
var currentSelection = [];
angular.copy(vm.user.userGroups, currentSelection);
Utilities.copy(vm.user.userGroups, currentSelection);
var userGroupPicker = {
selection: currentSelection,
submit: function (model) {
@@ -263,7 +262,7 @@
}
editorService.close();
},
close: function () {
close: function () {
editorService.close();
}
};
@@ -355,10 +354,10 @@
vm.user.userState = 1;
setUserDisplayState();
vm.disableUserButtonState = "success";
}, function (error) {
vm.disableUserButtonState = "error";
});
}
@@ -380,7 +379,7 @@
vm.user.failedPasswordAttempts = 0;
setUserDisplayState();
vm.unlockUserButtonState = "success";
}, function (error) {
vm.unlockUserButtonState = "error";
});
@@ -448,7 +447,7 @@
function clearAvatar() {
// get user
usersResource.clearAvatar(vm.user.id).then(function (data) {
vm.user.avatars = data;
vm.user.avatars = data;
});
}
@@ -469,15 +468,15 @@
}).progress(function (evt) {
if (vm.avatarFile.uploadStatus !== "done" && vm.avatarFile.uploadStatus !== "error") {
// set uploading status on file
vm.avatarFile.uploadStatus = "uploading";
// set uploading status on file
vm.avatarFile.uploadStatus = "uploading";
// calculate progress in percentage
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total, 10);
// calculate progress in percentage
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total, 10);
// set percentage property on file
vm.avatarFile.uploadProgress = progressPercentage;
}
// set percentage property on file
vm.avatarFile.uploadProgress = progressPercentage;
}
}).success(function (data, status, headers, config) {
@@ -67,7 +67,7 @@
];
// Get last selected layout for "users" (defaults to first layout = card layout)
vm.activeLayout = listViewHelper.getLayout("users", vm.layouts);
vm.activeLayout = listViewHelper.getLayout("users", vm.layouts);
// Don't show the invite button if no email is configured
if (Umbraco.Sys.ServerVariables.umbracoSettings.showUserInvite) {
@@ -247,19 +247,19 @@
function selectLayout(selectedLayout) {
// save the selected layout for "users" so it's applied next time the user visits this section
vm.activeLayout = listViewHelper.setLayout("users", selectedLayout, vm.layouts);
vm.activeLayout = listViewHelper.setLayout("users", selectedLayout, vm.layouts);
}
function isSelectable(user) {
return !user.isCurrentUser;
}
function selectUser(user) {
if (!isSelectable(user)) {
return;
}
if (user.selected) {
var index = vm.selection.indexOf(user.id);
vm.selection.splice(index, 1);
@@ -268,9 +268,9 @@
user.selected = true;
vm.selection.push(user.id);
}
setBulkActions(vm.users);
}
function clearSelection() {
@@ -279,14 +279,14 @@
});
vm.selection = [];
}
function clickUser(user, $event) {
$event.stopPropagation();
if ($event) {
// targeting a new tab/window?
if ($event.ctrlKey ||
if ($event.ctrlKey ||
$event.shiftKey ||
$event.metaKey || // apple
($event.button && $event.button === 1) // middle click, >IE9 + everyone else
@@ -295,7 +295,7 @@
return;
}
}
goToUser(user);
$event.preventDefault();
@@ -398,7 +398,7 @@
function openUserGroupPicker() {
var currentSelection = [];
angular.copy(vm.newUser.userGroups, currentSelection);
Utilities.copy(vm.newUser.userGroups, currentSelection);
var userGroupPicker = {
selection: currentSelection,
submit: function (model) {
@@ -611,7 +611,7 @@
// copy to clip board success
function copySuccess() {
if (vm.page.copyPasswordButtonState !== "success") {
$timeout(function(){
$timeout(function () {
vm.page.copyPasswordButtonState = "success";
});
$timeout(function () {
@@ -623,7 +623,7 @@
// copy to clip board error
function copyError() {
if (vm.page.copyPasswordButtonState !== "error") {
$timeout(function() {
$timeout(function () {
vm.page.copyPasswordButtonState = "error";
});
$timeout(function () {
@@ -654,7 +654,7 @@
return null;
}
function getEditPath(user) {
return pathToUser(user) + usersOptionsAsQueryString();
}
@@ -699,7 +699,7 @@
vm.usersOptions.pageSize = data.pageSize;
vm.usersOptions.totalItems = data.totalItems;
vm.usersOptions.totalPages = data.totalPages;
formatDates(vm.users);
setUserDisplayState(vm.users);
vm.userStatesFilter = usersHelper.getUserStatesFilter(data.userStates);
@@ -753,19 +753,19 @@
var firstSelectedUserGroups;
angular.forEach(users, function (user) {
if (!user.selected) {
return;
}
// if the current user is selected prevent any bulk actions with the user included
if (user.isCurrentUser) {
vm.allowDisableUser = false;
vm.allowEnableUser = false;
vm.allowUnlockUser = false;
vm.allowSetUserGroup = false;
return false;
}
+16 -16
View File
@@ -51,12 +51,12 @@ angular.mock.$Browser = function () {
self.onUrlChange = function (listener) {
self.pollFns.push(
function () {
if (self.$$lastUrl != self.$$url) {
self.$$lastUrl = self.$$url;
listener(self.$$url);
}
}
function () {
if (self.$$lastUrl != self.$$url) {
self.$$lastUrl = self.$$url;
listener(self.$$url);
}
}
);
return listener;
@@ -172,8 +172,8 @@ angular.mock.$Browser.prototype = {
}
} else {
if (!angular.equals(this.cookieHash, this.lastCookieHash)) {
this.lastCookieHash = angular.copy(this.cookieHash);
this.cookieHash = angular.copy(this.cookieHash);
this.lastCookieHash = Utilities.copy(this.cookieHash);
this.cookieHash = Utilities.copy(this.cookieHash);
}
return this.cookieHash;
}
@@ -397,7 +397,7 @@ angular.mock.$LogProvider = function () {
});
if (errors.length) {
errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or an expected " +
"log message was not checked and removed:");
"log message was not checked and removed:");
errors.push('');
throw new Error(errors.join('\n---------\n'));
}
@@ -581,12 +581,12 @@ angular.mock.$LogProvider = function () {
if (self.toISOString) {
self.toISOString = function () {
return padNumber(self.origDate.getUTCFullYear(), 4) + '-' +
padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
padNumber(self.origDate.getUTCDate(), 2) + 'T' +
padNumber(self.origDate.getUTCHours(), 2) + ':' +
padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'
padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
padNumber(self.origDate.getUTCDate(), 2) + 'T' +
padNumber(self.origDate.getUTCHours(), 2) + ':' +
padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z'
}
}
@@ -1004,7 +1004,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
throw wasExpected ?
Error('No response defined !') :
Error('Unexpected request: ' + method + ' ' + url + '\n' +
(expectation ? 'Expected ' + expectation : 'No more request expected'));
(expectation ? 'Expected ' + expectation : 'No more request expected'));
}
/**