From fb4de621c003afc557faa4f2d3ef3f6eaf2de88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20J=C3=B8rgensen?= Date: Wed, 16 Apr 2014 20:10:53 +0200 Subject: [PATCH 1/3] Prevalue editor added to textbox --- .../PropertyEditors/TextboxPropertyEditor.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index 69bc1452cf..01cd2585f3 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)] public class TextboxPropertyEditor : PropertyEditor - { + { + + + protected override PreValueEditor CreatePreValueEditor() + { + return new TextboxPreValueEditor(); + } + + internal class TextboxPreValueEditor : PreValueEditor + { + [PreValueField("Maximum allowed characters", "number")] + public bool IsRequired { get; set; } + } + } } From 756d554b47956973a55a39d8c247fe25c9ea9b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20J=C3=B8rgensen?= Date: Wed, 16 Apr 2014 20:55:45 +0200 Subject: [PATCH 2/3] charlimit on textbox added --- .../textbox/textbox.controller.js | 26 +++++++++++++++++++ .../propertyeditors/textbox/textbox.html | 7 ++--- .../PropertyEditors/TextboxPropertyEditor.cs | 4 +-- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/textbox/textbox.controller.js 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..77052a70f5 --- /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 7df7e9fded..1e23b36718 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,10 @@ -
+
- + ng-required="model.validation.mandatory" + ng-keyup="model.change()" /> Required +
{{model.count}} characters left
diff --git a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs index 01cd2585f3..85b4155f57 100644 --- a/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/TextboxPropertyEditor.cs @@ -22,8 +22,8 @@ namespace Umbraco.Web.PropertyEditors internal class TextboxPreValueEditor : PreValueEditor { - [PreValueField("Maximum allowed characters", "number")] - public bool IsRequired { get; set; } + [PreValueField("maxChars", "Maximum allowed characters", "number", Description = "If empty - no character limit")] + public bool MaxChars { get; set; } } } From 53928c02f8b987acbe6556db66eff7ab177e0254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20J=C3=B8rgensen?= Date: Wed, 16 Apr 2014 22:20:55 +0200 Subject: [PATCH 3/3] Textarea made work --- .../textarea/textarea.controller.js | 26 +++++++++++++++++++ .../propertyeditors/textarea/textarea.html | 10 +++++-- .../textbox/textbox.controller.js | 14 +++++----- .../propertyeditors/textbox/textbox.html | 5 +++- src/Umbraco.Web.UI/umbraco/config/lang/da.xml | 3 +++ src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 3 +++ .../umbraco/config/lang/en_us.xml | 3 +++ .../PropertyEditors/TextAreaPropertyEditor.cs | 10 +++++++ 8 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/propertyeditors/textarea/textarea.controller.js 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 8601155bda..92735db301 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,2 +1,8 @@ - - \ No newline at end of file +
+ + +
+ {{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 index 77052a70f5..03f7510112 100644 --- 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 @@ -1,23 +1,23 @@ function textboxController($rootScope, $scope, $log) { $scope.model.maxlength = false; - if($scope.model.config.MaxChars) { + if($scope.model.config.maxChars) { $scope.model.maxlength = true; if($scope.model.value == undefined) { - $scope.model.count = ($scope.model.config.MaxChars * 1); + $scope.model.count = ($scope.model.config.maxChars * 1); } else { - $scope.model.count = ($scope.model.config.MaxChars * 1) - $scope.model.value.length; + $scope.model.count = ($scope.model.config.maxChars * 1) - $scope.model.value.length; } } $scope.model.change = function() { - if($scope.model.config.MaxChars) { + if($scope.model.config.maxChars) { if($scope.model.value == undefined) { - $scope.model.count = ($scope.model.config.MaxChars * 1); + $scope.model.count = ($scope.model.config.maxChars * 1); } else { - $scope.model.count = ($scope.model.config.MaxChars * 1) - $scope.model.value.length; + $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.value = $scope.model.value.substring(0, ($scope.model.config.maxChars * 1)); $scope.model.count = 0; } } 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 1e23b36718..699c677621 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 @@ -6,5 +6,8 @@ ng-keyup="model.change()" /> Required -
{{model.count}} characters left
+
+ {{model.count}} + characters left +
diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml index c4b85332fa..6244e8f7e1 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/da.xml @@ -801,4 +801,7 @@ Mange hilsner fra umbraco robotten Din historik Session udløber + + 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 5d57f57f42..a00131baba 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -985,4 +985,7 @@ To manage your website, simply open the umbraco back office and start adding con Your recent history Session expires in + + 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 54e4918126..758ae1efaf 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -998,4 +998,7 @@ To manage your website, simply open the umbraco back office and start adding con Your recent history Session expires in + + characters left + diff --git a/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/TextAreaPropertyEditor.cs index e92a78dea8..9d5052c7e2 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)] 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; } + } } } \ No newline at end of file