diff --git a/www/js/directives.js b/www/js/directives.js index 8bedee67bc0d044225d3c99ed8cf0d350c8b6003..1f20010ae85a6f4d5df6139318ed0d30e5aef112 100644 --- a/www/js/directives.js +++ b/www/js/directives.js @@ -121,8 +121,9 @@ angular.module('cesium.directives', []) link: function (scope, element, attrs) { var showCopyPopover = function (event) { var value = attrs.copyOnClick; - if (value && Device.clipboard.enable) { - // copy to clipboard + if (value === undefined || value === null) return; // Skip if no value + if (Device.clipboard.enable) { + // copy to clipboard, using cordova Device.clipboard.copy(value) .then(function(){ UIUtils.toast.show('INFO.COPY_TO_CLIPBOARD_DONE'); @@ -138,7 +139,17 @@ angular.module('cesium.directives', []) value: attrs.copyOnClick, rows: rows }, - autoselect: '.popover-copy ' + (rows <= 1 ? 'input' : 'textarea') + autoselect: '.popover-copy ' + (rows <= 1 ? 'input' : 'textarea'), + + // After popover, try to copy the selection + afterShow: document.execCommand ? function(popover) { + try { + document.execCommand("copy"); + UIUtils.toast.show('INFO.COPY_TO_CLIPBOARD_DONE', 1000); + } catch (err) { + console.error("[copy-on-click] Failed to copy using document.execCommand('copy')", err); + } + } : undefined }); } }; diff --git a/www/plugins/es/templates/user/edit_profile.html b/www/plugins/es/templates/user/edit_profile.html index dcf19f97c49e9dd9fbbb3d7f8d547bcb87aebcdc..0efadbbaba066cc359dd0ee2c8c5322a72afb660 100644 --- a/www/plugins/es/templates/user/edit_profile.html +++ b/www/plugins/es/templates/user/edit_profile.html @@ -82,6 +82,7 @@ id="profile-name" ng-model="formData.title" ng-model-options="{ debounce: 350 }" + ng-minlength="3" ng-maxlength="50" required> </ion-item> @@ -91,6 +92,9 @@ <div class="form-error" ng-message="required"> <span translate="ERROR.FIELD_REQUIRED"></span> </div> + <div class="form-error" ng-message="minlength"> + <span translate="ERROR.FIELD_TOO_SHORT"></span> + </div> <div class="form-error" ng-message="maxlength"> <span translate="ERROR.FIELD_TOO_LONG_WITH_LENGTH" translate-values="{maxLength: 50}"></span> </div>