Skip to content

Commit

Permalink
[Skybrud] added nocrop option
Browse files Browse the repository at this point in the history
  • Loading branch information
rpjengaard committed Jun 5, 2018
1 parent 497bcf9 commit 35c111f
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
$scope.descriptionMode = $scope.propertyModes[0];
$scope.linkMode = $scope.propertyModes[0];


// Update the values for "titleMode", "descriptionMode" and "linkMode"
angular.forEach($scope.propertyModes, function (mode) {
if (cfg.items.title && cfg.items.title.mode == mode.alias) $scope.titleMode = mode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
scope.cfg.items.description.hidden = scope.cfg.items.description.mode == 'hidden';
scope.cfg.items.link.required = scope.cfg.items.link.mode == 'required';
scope.cfg.items.link.hidden = scope.cfg.items.link.mode == 'hidden';

if (!scope.cfg.items.nocrop) scope.cfg.items.nocrop = {};
scope.cfg.items.nocrop.visible = scope.cfg.items.nocrop.mode === 'visible';
scope.cfg.items.nocrop.default = scope.cfg.items.nocrop.default === true;

scope.itemStyles = {
width: scope.cfg.image.width + 'px',
Expand Down Expand Up @@ -189,7 +193,8 @@
title: '',
description: '',
imageId: 0,
link: null
link: null,
nocrop: scope.cfg.items.nocrop.default
};

// Collapse all open rows
Expand Down Expand Up @@ -235,7 +240,8 @@
imageId: image.id,
$image: image,
link: null,
$showInfo: scope.layout == 'list' && model.selectedImages.length == 1
$showInfo: scope.layout == 'list' && model.selectedImages.length == 1,
nocrop: scope.cfg.items.nocrop.default
};

item.$imageUrl = item.imageUrl = getImageUrl(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<key alias="labelTitle_placeholder">Angiv titel her</key>
<key alias="labelDescription">Beskrivelse</key>
<key alias="labelDescriptionPlaceholder">Angiv beskrivelse her</key>
<key alias="labelNoCrop">Beskær ikke billede</key>

<key alias="labelLink">Link</key>
<key alias="labelLinkType">Type</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<key alias="labelTitlePlaceholder">Specify title here</key>
<key alias="labelDescription">Description</key>
<key alias="labelDescriptionPlaceholder">Specify description here</key>
<key alias="labelNoCrop">Don´t crop image</key>

<key alias="labelLink">Link</key>
<key alias="labelLinkType">Type</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<key alias="labelTitlePlaceholder">Specify title here</key>
<key alias="labelDescription">Description</key>
<key alias="labelDescriptionPlaceholder">Specify description here</key>
<key alias="labelNoCrop">Don´t crop image</key>

<key alias="labelLink">Link</key>
<key alias="labelLinkType">Type</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
<label>
<input type="checkbox" ng-model="config.items.hideLink" /> Hide link
</label>
<label>
<input type="checkbox" ng-model="config.items.nocrop.default" /> NoCrop default
</label>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@
</div>
<input type="hidden" ng-model="item.$link" ng-required="cfg.items.link.required" id="imagePickerRowLink{{item.$uniqueId}}" />
</div>
<div class="subpart" ng-hide="!config.items.nocrop.visible">
<div class="title">
<localize key="imagepicker_labelNoCrop">Don´t crop image</localize>
</div>
<input type="checkbox" ng-model="item.nocrop" />
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
</a>
</div>
</div>
<div class="subpart" ng-hide="!config.items.nocrop.visible">
<div class="title">
<localize key="imagepicker_labelNoCrop">No crop</localize>
</div>
<input type="checkbox" ng-model="item.nocrop" />
</div>
<input type="hidden" ng-model="item.imageUrl" required id="imagePickerRowImage{{item.$uniqueId}}" />
<input type="hidden" ng-model="item.$link" ng-required="cfg.items.link.required" id="imagePickerRowLink{{item.$uniqueId}}" />
</div>
Expand Down
25 changes: 24 additions & 1 deletion src/Skybrud.ImagePicker/ImagePickerItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ public class ImagePickerItem {
[JsonConverter(typeof(LinkPickerItemConverter))]
public LinkPickerItem Link { get; private set; }

/// <summary>
[JsonProperty("noCrop")]
public bool NoCrop { get; private set; }



/// <summary>
/// Gets whether a valid link has been specified for this item.
/// </summary>
[JsonIgnore]
Expand Down Expand Up @@ -104,6 +109,23 @@ public ImagePickerItem(ImagePickerImage image, string title, string description,
Link = link ?? LinkPickerItem.Parse(new JObject());
}

/// <summary>
/// Initializes a new image picker item based on the specified <paramref name="image"/>, <paramref name="title"/>,
/// <paramref name="description"/> and <paramref name="link"/>.
/// </summary>
/// <param name="image">An instance of <see cref="IPublishedContent"/> representing the selected image.</param>
/// <param name="title">The title of the item.</param>
/// <param name="description">The description of the item.</param>
/// <param name="link">An instance of <see cref="LinkPickerItem"/> representing the link of the item.</param>
/// <param name="noCrop">The NoCrop property value</param>
public ImagePickerItem(ImagePickerImage image, string title, string description, LinkPickerItem link, bool noCrop) {
Image = image;
Title = title;
Description = description;
Link = link ?? LinkPickerItem.Parse(new JObject());
NoCrop = noCrop;
}

/// <summary>
/// Initializes a new image picker item based on the specified <see cref="JObject"/>.
/// </summary>
Expand All @@ -114,6 +136,7 @@ protected ImagePickerItem(JObject obj) {
Title = obj.GetString("title") ?? "";
Description = obj.GetString("description") ?? "";
Link = obj.GetObject("link", LinkPickerItem.Parse) ?? LinkPickerItem.Parse(new JObject());
NoCrop = obj.GetBoolean("nocrop");
}

#endregion
Expand Down
6 changes: 3 additions & 3 deletions src/Skybrud.ImagePicker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyInformationalVersion("1.1.7")]
[assembly: AssemblyVersion("1.1.7.0")]
[assembly: AssemblyFileVersion("1.1.7.0")]
[assembly: AssemblyInformationalVersion("1.1.8")]
[assembly: AssemblyVersion("1.1.8.0")]
[assembly: AssemblyFileVersion("1.1.8.0")]
6 changes: 3 additions & 3 deletions src/Skybrud.ImagePicker/Properties/AssemblyInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"company": "Skybrud.dk",
"product": "Skybrud.ImagePicker",
"copyright": "Copyright © 2018",
"version": "1.1.7.0",
"informationalVersion": "1.1.7",
"fileVersion": "1.1.7.0"
"version": "1.1.8.0",
"informationalVersion": "1.1.8",
"fileVersion": "1.1.8.0"
}

0 comments on commit 35c111f

Please sign in to comment.