Merge branch 'madjor5-U4-4413_-_maxlength' into dev-v7

This commit is contained in:
Warren Buckley
2017-07-13 13:39:20 +01:00
9 changed files with 103 additions and 8 deletions

View File

@@ -0,0 +1,26 @@
function textAreaController($rootScope, $scope, $log) {
$scope.model.maxlength = false;
if($scope.model.config.maxChars) {
$scope.model.maxlength = true;
if($scope.model.value == undefined) {
$scope.model.count = ($scope.model.config.maxChars * 1);
} else {
$scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length;
}
}
$scope.model.change = function() {
if($scope.model.config.maxChars) {
if($scope.model.value == undefined) {
$scope.model.count = ($scope.model.config.maxChars * 1);
} else {
$scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length;
}
if($scope.model.count < 0) {
$scope.model.value = $scope.model.value.substring(0, ($scope.model.config.maxChars * 1));
$scope.model.count = 0;
}
}
}
}
angular.module('umbraco').controller("Umbraco.PropertyEditors.textAreaController", textAreaController);

View File

@@ -1,3 +1,9 @@
<textarea ng-model="model.value" id="{{model.alias}}" name="textarea" rows="10" class="umb-editor umb-textarea textstring" val-server="value" ng-required="model.validation.mandatory"></textarea>
<span class="help-inline" val-msg-for="textarea" val-toggle-msg="required"><localize key="general_required">Required</localize></span>
<span class="help-inline" val-msg-for="textarea" val-toggle-msg="valServer"></span>
<div ng-controller="Umbraco.PropertyEditors.textAreaController">
<textarea ng-model="model.value" id="{{model.alias}}" name="textarea" rows="10" class="umb-editor umb-textarea textstring" val-server="value" ng-keyup="model.change()"></textarea>
<span class="help-inline" val-msg-for="textarea" val-toggle-msg="required"><localize key="general_required">Required</localize></span>
<span class="help-inline" val-msg-for="textarea" val-toggle-msg="valServer"></span>
<div class="help" ng-if="model.maxlength">
<strong>{{model.count}}</strong>
<localize key="textbox_characters_left">characters left</localize>
</div>
</div>

View File

@@ -0,0 +1,26 @@
function textboxController($rootScope, $scope, $log) {
$scope.model.maxlength = false;
if($scope.model.config.maxChars) {
$scope.model.maxlength = true;
if($scope.model.value == undefined) {
$scope.model.count = ($scope.model.config.maxChars * 1);
} else {
$scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length;
}
}
$scope.model.change = function() {
if($scope.model.config.maxChars) {
if($scope.model.value == undefined) {
$scope.model.count = ($scope.model.config.maxChars * 1);
} else {
$scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length;
}
if($scope.model.count < 0) {
$scope.model.value = $scope.model.value.substring(0, ($scope.model.config.maxChars * 1));
$scope.model.count = 0;
}
}
}
}
angular.module('umbraco').controller("Umbraco.PropertyEditors.textboxController", textboxController);

View File

@@ -1,9 +1,14 @@
<div>
<div ng-controller="Umbraco.PropertyEditors.textboxController">
<input type="text" name="textbox" ng-model="model.value" id="{{model.alias}}"
class="umb-editor umb-textstring textstring"
val-server="value"
ng-required="model.validation.mandatory"
ng-trim="false" />
ng-trim="false"
ng-keyup="model.change()" />
<span class="help-inline" val-msg-for="textbox" val-toggle-msg="valServer"></span>
<span class="help-inline" val-msg-for="textbox" val-toggle-msg="required"><localize key="general_required">Required</localize></span>
</div>
<div class="help" ng-if="model.maxlength">
<strong>{{model.count}}</strong>
<localize key="textbox_characters_left">characters left</localize>
</div>
</div>

View File

@@ -1291,4 +1291,7 @@ Mange hilsner fra Umbraco robotten
<key alias="enabledConfirm">URL tracker er nu slået fra.</key>
<key alias="enableError">Der opstod en fejl under forsøget på at slå URL trackeren til, der findes mere information i logfilen.</key>
</area>
<area alias="textbox">
<key alias="characters_left">Karakterer tilbage</key>
</area>
</language>

View File

@@ -1628,4 +1628,7 @@ To manage your website, simply open the Umbraco back office and start adding con
<area alias="emptyStates">
<key alias="emptyDictionaryTree">No Dictionary items to choose from</key>
</area>
</language>
<area alias="textbox">
<key alias="characters_left">characters left</key>
</area>
</language>

View File

@@ -1624,4 +1624,7 @@ To manage your website, simply open the Umbraco back office and start adding con
<area alias="emptyStates">
<key alias="emptyDictionaryTree">No Dictionary items to choose from</key>
</area>
<area alias="textbox">
<key alias="characters_left">characters left</key>
</area>
</language>

View File

@@ -6,5 +6,15 @@ namespace Umbraco.Web.PropertyEditors
[PropertyEditor(Constants.PropertyEditors.TextboxMultipleAlias, "Textarea", "textarea", IsParameterEditor = true, ValueType = PropertyEditorValueTypes.Text, Icon="icon-application-window-alt")]
public class TextAreaPropertyEditor : PropertyEditor
{
protected override PreValueEditor CreatePreValueEditor()
{
return new TextAreaPreValueEditor();
}
internal class TextAreaPreValueEditor : PreValueEditor
{
[PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")]
public bool MaxChars { get; set; }
}
}
}

View File

@@ -12,6 +12,19 @@ namespace Umbraco.Web.PropertyEditors
{
[PropertyEditor(Constants.PropertyEditors.TextboxAlias, "Textbox", "textbox", IsParameterEditor = true, Group = "Common")]
public class TextboxPropertyEditor : PropertyEditor
{
{
protected override PreValueEditor CreatePreValueEditor()
{
return new TextboxPreValueEditor();
}
internal class TextboxPreValueEditor : PreValueEditor
{
[PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")]
public bool MaxChars { get; set; }
}
}
}