# HG changeset patch # User Guido Berhoerster # Date 1411320129 -7200 # Node ID 64272f2105da8b89343dc4a0178311a7cd2ea977 # Parent fb5fb3b38c0d7df144dc48ac55506762169aee20 Show four tag input elements by default diff -r fb5fb3b38c0d -r 64272f2105da booket.js --- a/booket.js Thu Sep 18 20:36:21 2014 +0200 +++ b/booket.js Sun Sep 21 19:22:09 2014 +0200 @@ -1043,6 +1043,7 @@ var importFormElement; var exportFormElement; var newNode; + var i; ObservableMixin.call(this); @@ -1083,7 +1084,10 @@ this.editTagListElement = this.editorFormElement.querySelector('ul.tag-input-list'); - this.editTagListElement.appendChild(this.createTagInputElement('')); + // add four tag input elements for convenience + for (i = 0; i < 4; i++) { + this.editTagListElement.appendChild(this.createTagInputElement('')); + } saveFormElement.parentNode.insertBefore(newNode, saveFormElement.nextSibling); @@ -1107,6 +1111,7 @@ var parsedData; var tags = []; var i; + var tagInputElements; switch (e.type) { case 'error': @@ -1201,12 +1206,12 @@ e.target.querySelector('img.bookmark-favicon').src = this.missingFaviconUri; - // remove all but one tag input element - while (this.editTagListElement.firstChild !== null) { - this.editTagListElement.removeChild( - this.editTagListElement.firstChild); + // remove all but the first four tag input elements + tagInputElements = + this.editTagListElement.querySelectorAll('li:nth-child(n+5)'); + for (i = 0; i < tagInputElements.length; i++) { + this.editTagListElement.removeChild(tagInputElements[i]); } - this.editTagListElement.appendChild(this.createTagInputElement('')); } break; }