diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.controller.js new file mode 100644 index 0000000000..2d4e114dcf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.controller.js @@ -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); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.html index aba4c52ed3..ffb692ced0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.html @@ -1,3 +1,9 @@ - -Required - +
+ + Required + +
+ {{model.count}} + characters left +
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js new file mode 100644 index 0000000000..03f7510112 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js @@ -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); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html index 1848574f8b..d8c51ce9e0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html +++ b/src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.html @@ -1,9 +1,14 @@ -
+
+ ng-trim="false" + ng-keyup="model.change()" /> Required -
+
+ {{model.count}} + characters left +
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml index bc3fccfd34..c25f3ce562 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml @@ -1291,4 +1291,7 @@ Mange hilsner fra Umbraco robotten URL tracker er nu slået fra. Der opstod en fejl under forsøget på at slå URL trackeren til, der findes mere information i logfilen. + + Karakterer tilbage + diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 05571a55d9..d449465fac 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -1628,4 +1628,7 @@ To manage your website, simply open the Umbraco back office and start adding con No Dictionary items to choose from - + + characters left + + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 2eece34dd3..f0934ced54 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -1624,4 +1624,7 @@ To manage your website, simply open the Umbraco back office and start adding con No Dictionary items to choose from + + characters left + diff --git a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs index 3bec23f004..7006befdcd 100644 --- a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs @@ -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; } + } } } diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index bcfbbbf682..0fd243180c 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -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; } + } + } }