Auto-resizing input for org and title layout + header improvements fix #286

This commit is contained in:
skjnldsv 2016-04-05 14:21:36 +02:00
parent 5869a3a216
commit fd04eac1af
3 changed files with 35 additions and 13 deletions

View File

@ -12,27 +12,31 @@
top: 15px;
left: 100px;
}
.contactdetails__header #details-org-container {
position: absolute;
display: flex;
top: 50px;
left: 100px;
width: 70%;
}
.contactdetails__header .contactdetails__name,
.contactdetails__header .contactdetails__org,
.contactdetails__header .contactdetails__title {
font-size: inherit !important;
width: 100% !important;
width: auto !important;
color: #fff !important;
background: transparent !important;
border: none !important;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 100%;
min-width: 25%;
margin: 3px 0;
}
.contactdetails__header .contactdetails__org {
position: absolute;
left: 101px;
width: 100px !important;
}
.contactdetails__header .contactdetails__org,
.contactdetails__header .contactdetails__title {
position: absolute;
left: 201px;
width: 125px !important;
max-width: 50%;
}
/* fix placeholder color */
.contactdetails__header .contactdetails__name::-webkit-input-placeholder,

View File

@ -0,0 +1,15 @@
angular.module('contactsApp')
.directive('inputresize', function() {
return {
restrict: 'A',
link : function (scope, element) {
var elInput = element.val();
element.bind('keydown keyup load focus', function() {
elInput = element.val();
// If set to 0, the min-width css data is ignored
var length = elInput.length > 1 ? elInput.length : 1;
element.attr('size', length);
});
}
};
});

View File

@ -11,13 +11,16 @@
<img ng-if="ctrl.photo!==undefined" class="contactdetails__logo avatar" data-ng-src="data:image/png;base64,{{ctrl.photo}}" />
<h2>
<input type="text" id="details-fullName" class="contactdetails__name" placeholder="{{ctrl.t.placeholderName}}" autocomplete="off"
name="email" ng-model="ctrl.contact.fullName" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value="" />
name="email" ng-model="ctrl.contact.fullName" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
inputresize size="{{ctrl.contact.fullName().length > 1 ? ctrl.contact.fullName().length : '1'}}" />
</h2>
<div>
<div id="details-org-container">
<input type="text" id="details-org" class="contactdetails__org" placeholder="{{ctrl.t.placeholderOrg}}" autocomplete="off"
name="email" ng-model="ctrl.contact.org" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value="" />
name="email" ng-model="ctrl.contact.org" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
inputresize size="{{ctrl.contact.org().length > 1 ? ctrl.contact.org().length : '1'}}" />
<input type="text" id="details-title" class="contactdetails__title" placeholder="{{ctrl.t.placeholderTitle}}" autocomplete="off"
name="email" ng-model="ctrl.contact.title" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value="" />
name="email" ng-model="ctrl.contact.title" ng-model-options="{ getterSetter: true, debounce: 500 }" ng-change="ctrl.updateContact()" value=""
inputresize size="{{ctrl.contact.title().length > 1 ? ctrl.contact.title().length : '1'}}" />
</div>
<button ng-click="ctrl.deleteContact()" class="icon-delete-white" title="Delete"></button>
</header>