Merge branch '7.1.0' of https://github.com/umbraco/Umbraco-CMS into 7.1.0

This commit is contained in:
Sebastiaan Janssen
2014-04-03 09:30:12 +02:00
9 changed files with 73 additions and 57 deletions

View File

@@ -24,9 +24,8 @@ angular.module("umbraco.directives.html")
scope.clickHandler = scope.$eval(element.attr('on-click'));
//todo: this doesn't do anything
var imagesOnly = element.attr('imagesOnly');
var imagesOnly = element.attr('images-only') === "true";
var margin = element.attr('border') ? parseInt(element.attr('border'), 10) : 5;
var startingIndex = element.attr('baseline') ? parseInt(element.attr('baseline'), 10) : 0;
var minWidth = element.attr('min-width') ? parseInt(element.attr('min-width'), 10) : 420;
@@ -36,7 +35,7 @@ angular.module("umbraco.directives.html")
var fixedRowWidth = Math.max(element.width(), minWidth);
scope.containerStyle = { width: fixedRowWidth + "px" };
scope.rows = umbPhotoFolderHelper.buildGrid(photos, fixedRowWidth, maxHeight, startingIndex, minHeight, idealImgPerRow, margin);
scope.rows = umbPhotoFolderHelper.buildGrid(photos, fixedRowWidth, maxHeight, startingIndex, minHeight, idealImgPerRow, margin, imagesOnly);
if (attrs.filterBy) {
@@ -51,7 +50,7 @@ angular.module("umbraco.directives.html")
if (newVal && newVal !== oldVal) {
var p = $filter('filter')(photos, newVal, false);
scope.baseline = 0;
var m = umbPhotoFolderHelper.buildGrid(p, fixedRowWidth, maxHeight, startingIndex, minHeight, idealImgPerRow, margin);
var m = umbPhotoFolderHelper.buildGrid(p, fixedRowWidth, maxHeight, startingIndex, minHeight, idealImgPerRow, margin, imagesOnly);
scope.rows = m;
}
});

View File

@@ -106,7 +106,6 @@ angular.module("umbraco.directives")
//when loading an image without any crop info, we center and fit it
var resizeImageToEditor = function(){
//returns size fitting the cropper
var size = cropperHelper.calculateAspectRatioFit(
scope.dimensions.image.width,
@@ -254,7 +253,7 @@ angular.module("umbraco.directives")
var throttledResizing = _.throttle(function(){
resizeImageToScale(scope.dimensions.scale.current);
calculateCropBox();
}, 300);
}, 100);
//happens when we change the scale

View File

@@ -162,6 +162,36 @@ function mediaHelper(umbRequestHelper) {
return result;
},
/*jshint loopfunc: true */
hasFilePropertyType : function(mediaItem){
function _iterateProps(props){
var result = false;
for(var resolver in _mediaFileResolvers) {
var property = _.find(props, function(property){ return property.editor === resolver; });
if(property){
result = true;
break;
}
}
return result;
}
//we either have properties raw on the object, or spread out on tabs
var result = false;
if(mediaItem.properties){
result = _iterateProps(mediaItem.properties);
}else if(mediaItem.tabs){
for(var tab in mediaItem.tabs) {
if(mediaItem.tabs[tab].properties){
result = _iterateProps(mediaItem.tabs[tab].properties);
if(result){
break;
}
}
}
}
return result;
},
/**
* @ngdoc function

View File

@@ -23,15 +23,15 @@ angular.module('umbraco.services').factory('packageHelper', packageHelper);
function umbPhotoFolderHelper($compile, $log, $timeout, $filter, imageHelper, mediaHelper, umbRequestHelper) {
return {
/** sets the image's url - will check if it is a folder or a real image */
setImageUrl: function(img) {
//get the image property (if one exists)
img.thumbnail = mediaHelper.resolveFile(img, true);
img.image = mediaHelper.resolveFile(img, false);
/** sets the image's url, thumbnail and if its a folder */
setImageData: function(img) {
img.isFolder = !mediaHelper.hasFilePropertyType(img);
// if (!img.thumbnail){
// img.thumbnail = "none";
// }
if(!img.isFolder){
img.thumbnail = mediaHelper.resolveFile(img, true);
img.image = mediaHelper.resolveFile(img, false);
}
},
/** sets the images original size properties - will check if it is a folder and if so will just make it square */
@@ -252,15 +252,22 @@ function umbPhotoFolderHelper($compile, $log, $timeout, $filter, imageHelper, me
},
/** Creates the image grid with calculated widths/heights for images to fill the grid nicely */
buildGrid: function(images, maxRowWidth, maxRowHeight, startingIndex, minDisplayHeight, idealImgPerRow, margin) {
buildGrid: function(images, maxRowWidth, maxRowHeight, startingIndex, minDisplayHeight, idealImgPerRow, margin,imagesOnly) {
var rows = [];
var imagesProcessed = 0;
//first fill in all of the original image sizes and URLs
for (var i = startingIndex; i < images.length; i++) {
this.setImageUrl(images[i]);
var item = images[0];
this.setImageData(images[i]);
this.setOriginalSize(images[i], maxRowHeight);
if(imagesOnly && !item.isFolder && !item.thumbnail){
images.splice(i, 1);
i--;
}
}
while ((imagesProcessed + startingIndex) < images.length) {

View File

@@ -304,6 +304,10 @@ ul.color-picker li a {
line-height: 120px
}
.umb-folderbrowser .selector-overlay{
display: none !important;
}
.umb-upload-drop-zone .info, .umb-upload-button-big{
display: block;
padding: 20px;
@@ -343,6 +347,8 @@ ul.color-picker li a {
position: relative;
}
.umb-photo-folder .picrow div, .umb-photo-preview{
margin: 0px;
padding: 0px;
@@ -396,7 +402,7 @@ ul.color-picker li a {
line-height: 80px;
display: block;
margin: auto;
padding-top: 25%;
padding-top: 20px;
}
.umb-photo-folder .selected{

View File

@@ -67,19 +67,8 @@ angular.module("umbraco")
//mediaResource.rootMedia()
mediaResource.getChildren(folder.id)
.then(function(data) {
$scope.images = [];
$scope.searchTerm = "";
if(data.items){
$scope.images = data.items;
}
if($scope.onlyImages){
$scope.images = _.reject($scope.images, function(item) {
return item.contentTypeAlias.toLowerCase() !== "folder" && item.thumbnail === "";
});
}
$scope.images = data.items ? data.items : [];
});
$scope.options.formData.currentFolder = folder.id;
@@ -93,7 +82,7 @@ angular.module("umbraco")
$scope.clickHandler = function(image, ev, select) {
ev.preventDefault();
if (image.contentTypeAlias.toLowerCase() == 'folder' && !select) {
if (image.isFolder && !select) {
$scope.gotoFolder(image);
}else{
eventsService.emit("dialogs.mediaPicker.select", image);
@@ -119,30 +108,7 @@ angular.module("umbraco")
$scope.target = undefined;
};
/*
$scope.selectFolder= function(folder) {
if ($scope.multiPicker) {
$scope.select(folder);
}
else {
$scope.submit(folder);
}
};
$scope.selectMediaItem = function(image) {
if (image.contentTypeAlias.toLowerCase() == 'folder') {
$scope.gotoFolder(image);
}else{
eventsService.emit("dialogs.mediaPicker.select", image);
if ($scope.multiPicker) {
$scope.select(image);
}
else {
$scope.submit(image);
}
}
};*/
//default root item
if(!$scope.target){

View File

@@ -108,6 +108,7 @@ data-file-upload="options" data-file-upload-progress="" data-ng-class="{'fileupl
ideal-items-per-row="3"
on-click="clickHandler"
ng-model="images"
images-only="true"
filter-by="searchTerm"/>
</div>

View File

@@ -17,10 +17,10 @@
<div ng-if="img.thumbnail" class="umb-photo" ng-style="img.thumbStyle" alt="{{img.name}}"></div>
</a>
<a href ng-click="clickHandler(img, $event, true)" ng-show="img.contentTypeAlias === 'Folder'" class="selector-overlay">
<a href ng-click="clickHandler(img, $event, true)"
ng-if="img.isFolder" class="selector-overlay">
<localize key="buttons_select">Select</localize>
</a>
</div>
</div>
</div>

View File

@@ -87,6 +87,14 @@ angular.module('umbraco')
reader.readAsDataURL(args.files[0]);
}
});
var unsubscribe = $scope.$on("formSubmitting", function () {
$scope.done();
});
$scope.$on('$destroy', function () {
unsubscribe();
});
})
.run(function (mediaHelper, umbRequestHelper) {
if (mediaHelper && mediaHelper.registerFileResolver) {