Merge "Limit topic length"
This commit is contained in:
commit
f5061ee565
@ -69,6 +69,7 @@ limitations under the License.
|
||||
<input
|
||||
is="iron-input"
|
||||
id="tagNameInput"
|
||||
maxlength="1024"
|
||||
bind-value="{{topic}}">
|
||||
</section>
|
||||
<section>
|
||||
|
@ -244,6 +244,7 @@ limitations under the License.
|
||||
<gr-editable-label
|
||||
label-text="Add a topic"
|
||||
value="[[change.topic]]"
|
||||
max-length="1024"
|
||||
placeholder="[[_computeTopicPlaceholder(_topicReadOnly)]]"
|
||||
read-only="[[_topicReadOnly]]"
|
||||
on-changed="_handleTopicChanged"></gr-editable-label>
|
||||
|
@ -90,6 +90,7 @@ limitations under the License.
|
||||
<paper-input
|
||||
id="input"
|
||||
label="[[labelText]]"
|
||||
maxlength="[[maxLength]]"
|
||||
value="{{_inputText}}"></paper-input>
|
||||
<div class="buttons">
|
||||
<gr-button link id="cancelBtn" on-tap="_cancel">cancel</gr-button>
|
||||
|
@ -51,6 +51,7 @@
|
||||
reflectToAttribute: true,
|
||||
value: false,
|
||||
},
|
||||
maxLength: Number,
|
||||
_inputText: String,
|
||||
// This is used to push the iron-input element up on the page, so
|
||||
// the input is placed in approximately the same position as the
|
||||
|
@ -39,10 +39,18 @@
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
|
||||
/**
|
||||
* The maximum number of characters to display in the tooltop.
|
||||
*/
|
||||
tooltipLimit: {
|
||||
type: Number,
|
||||
value: 1024,
|
||||
},
|
||||
},
|
||||
|
||||
observers: [
|
||||
'_updateTitle(text, limit)',
|
||||
'_updateTitle(text, limit, tooltipLimit)',
|
||||
],
|
||||
|
||||
behaviors: [
|
||||
@ -53,10 +61,10 @@
|
||||
* The text or limit have changed. Recompute whether a tooltip needs to be
|
||||
* enabled.
|
||||
*/
|
||||
_updateTitle(text, limit) {
|
||||
_updateTitle(text, limit, tooltipLimit) {
|
||||
this.hasTooltip = !!limit && !!text && text.length > limit;
|
||||
if (this.hasTooltip) {
|
||||
this.setAttribute('title', text);
|
||||
this.setAttribute('title', text.substr(0, tooltipLimit));
|
||||
} else {
|
||||
this.removeAttribute('title');
|
||||
}
|
||||
|
@ -66,15 +66,20 @@ limitations under the License.
|
||||
assert.equal(element.getAttribute('title'), 'abc 123');
|
||||
assert.isTrue(element.hasTooltip);
|
||||
|
||||
element.tooltipLimit = 3;
|
||||
flushAsynchronousOperations();
|
||||
assert.equal(element.getAttribute('title'), 'abc');
|
||||
|
||||
element.tooltipLimit = 1024;
|
||||
element.limit = 100;
|
||||
flushAsynchronousOperations();
|
||||
assert.equal(updateSpy.callCount, 4);
|
||||
assert.equal(updateSpy.callCount, 6);
|
||||
assert.isNotOk(element.getAttribute('title'));
|
||||
assert.isFalse(element.hasTooltip);
|
||||
|
||||
element.limit = null;
|
||||
flushAsynchronousOperations();
|
||||
assert.equal(updateSpy.callCount, 5);
|
||||
assert.equal(updateSpy.callCount, 7);
|
||||
assert.isNotOk(element.getAttribute('title'));
|
||||
assert.isFalse(element.hasTooltip);
|
||||
});
|
||||
|
@ -68,7 +68,9 @@ limitations under the License.
|
||||
</style>
|
||||
<div class$="container [[_getBackgroundClass(transparentBackground)]]">
|
||||
<a href$="[[href]]">
|
||||
<gr-limited-text limit="[[limit]]" text="[[text]]"></gr-limited-text>
|
||||
<gr-limited-text
|
||||
limit="[[limit]]"
|
||||
text="[[text]]"></gr-limited-text>
|
||||
</a>
|
||||
<gr-button
|
||||
id="remove"
|
||||
|
Loading…
Reference in New Issue
Block a user