projects/booket

changeset 16:64272f2105da

Show four tag input elements by default
author Guido Berhoerster <guido+booket@berhoerster.name>
date Sun Sep 21 19:22:09 2014 +0200 (2014-09-21)
parents fb5fb3b38c0d
children 8445c729ba97
files booket.js
line diff
     1.1 --- a/booket.js	Thu Sep 18 20:36:21 2014 +0200
     1.2 +++ b/booket.js	Sun Sep 21 19:22:09 2014 +0200
     1.3 @@ -1043,6 +1043,7 @@
     1.4      var importFormElement;
     1.5      var exportFormElement;
     1.6      var newNode;
     1.7 +    var i;
     1.8  
     1.9      ObservableMixin.call(this);
    1.10  
    1.11 @@ -1083,7 +1084,10 @@
    1.12  
    1.13      this.editTagListElement =
    1.14          this.editorFormElement.querySelector('ul.tag-input-list');
    1.15 -    this.editTagListElement.appendChild(this.createTagInputElement(''));
    1.16 +    // add four tag input elements for convenience
    1.17 +    for (i = 0; i < 4; i++) {
    1.18 +        this.editTagListElement.appendChild(this.createTagInputElement(''));
    1.19 +    }
    1.20  
    1.21      saveFormElement.parentNode.insertBefore(newNode,
    1.22          saveFormElement.nextSibling);
    1.23 @@ -1107,6 +1111,7 @@
    1.24      var parsedData;
    1.25      var tags = [];
    1.26      var i;
    1.27 +    var tagInputElements;
    1.28  
    1.29      switch (e.type) {
    1.30      case 'error':
    1.31 @@ -1201,12 +1206,12 @@
    1.32              e.target.querySelector('img.bookmark-favicon').src =
    1.33                  this.missingFaviconUri;
    1.34  
    1.35 -            // remove all but one tag input element
    1.36 -            while (this.editTagListElement.firstChild !== null) {
    1.37 -                this.editTagListElement.removeChild(
    1.38 -                    this.editTagListElement.firstChild);
    1.39 +            // remove all but the first four tag input elements
    1.40 +            tagInputElements =
    1.41 +                this.editTagListElement.querySelectorAll('li:nth-child(n+5)');
    1.42 +            for (i = 0; i < tagInputElements.length; i++) {
    1.43 +                this.editTagListElement.removeChild(tagInputElements[i]);
    1.44              }
    1.45 -            this.editTagListElement.appendChild(this.createTagInputElement(''));
    1.46          }
    1.47          break;
    1.48      }