Mercurial > projects > booket
comparison booket.js @ 16:64272f2105da
Show four tag input elements by default
author | Guido Berhoerster <guido+booket@berhoerster.name> |
---|---|
date | Sun, 21 Sep 2014 19:22:09 +0200 |
parents | 948048e40fab |
children | 3642bb668af1 |
comparison
equal
deleted
inserted
replaced
15:fb5fb3b38c0d | 16:64272f2105da |
---|---|
1041 var saveFormElement; | 1041 var saveFormElement; |
1042 var loadFormElement; | 1042 var loadFormElement; |
1043 var importFormElement; | 1043 var importFormElement; |
1044 var exportFormElement; | 1044 var exportFormElement; |
1045 var newNode; | 1045 var newNode; |
1046 var i; | |
1046 | 1047 |
1047 ObservableMixin.call(this); | 1048 ObservableMixin.call(this); |
1048 | 1049 |
1049 this.tagInputTemplate = document.querySelector('#tag-input-template'); | 1050 this.tagInputTemplate = document.querySelector('#tag-input-template'); |
1050 saveFormElement = document.querySelector('form#save-form'); | 1051 saveFormElement = document.querySelector('form#save-form'); |
1081 | 1082 |
1082 this.missingFaviconUri = this.faviconImageElement.src; | 1083 this.missingFaviconUri = this.faviconImageElement.src; |
1083 | 1084 |
1084 this.editTagListElement = | 1085 this.editTagListElement = |
1085 this.editorFormElement.querySelector('ul.tag-input-list'); | 1086 this.editorFormElement.querySelector('ul.tag-input-list'); |
1086 this.editTagListElement.appendChild(this.createTagInputElement('')); | 1087 // add four tag input elements for convenience |
1088 for (i = 0; i < 4; i++) { | |
1089 this.editTagListElement.appendChild(this.createTagInputElement('')); | |
1090 } | |
1087 | 1091 |
1088 saveFormElement.parentNode.insertBefore(newNode, | 1092 saveFormElement.parentNode.insertBefore(newNode, |
1089 saveFormElement.nextSibling); | 1093 saveFormElement.nextSibling); |
1090 | 1094 |
1091 document.querySelector('a#bookmarklet-link').href = BOOKMARKLET_URI; | 1095 document.querySelector('a#bookmarklet-link').href = BOOKMARKLET_URI; |
1105 ActionsView.prototype.handleEvent = function (e) { | 1109 ActionsView.prototype.handleEvent = function (e) { |
1106 var bookmarkletData; | 1110 var bookmarkletData; |
1107 var parsedData; | 1111 var parsedData; |
1108 var tags = []; | 1112 var tags = []; |
1109 var i; | 1113 var i; |
1114 var tagInputElements; | |
1110 | 1115 |
1111 switch (e.type) { | 1116 switch (e.type) { |
1112 case 'error': | 1117 case 'error': |
1113 if (e.target.classList.contains('bookmark-favicon')) { | 1118 if (e.target.classList.contains('bookmark-favicon')) { |
1114 if (e.target.src !== this.missingFaviconUri) { | 1119 if (e.target.src !== this.missingFaviconUri) { |
1199 e.target.blur(); | 1204 e.target.blur(); |
1200 | 1205 |
1201 e.target.querySelector('img.bookmark-favicon').src = | 1206 e.target.querySelector('img.bookmark-favicon').src = |
1202 this.missingFaviconUri; | 1207 this.missingFaviconUri; |
1203 | 1208 |
1204 // remove all but one tag input element | 1209 // remove all but the first four tag input elements |
1205 while (this.editTagListElement.firstChild !== null) { | 1210 tagInputElements = |
1206 this.editTagListElement.removeChild( | 1211 this.editTagListElement.querySelectorAll('li:nth-child(n+5)'); |
1207 this.editTagListElement.firstChild); | 1212 for (i = 0; i < tagInputElements.length; i++) { |
1208 } | 1213 this.editTagListElement.removeChild(tagInputElements[i]); |
1209 this.editTagListElement.appendChild(this.createTagInputElement('')); | 1214 } |
1210 } | 1215 } |
1211 break; | 1216 break; |
1212 } | 1217 } |
1213 }; | 1218 }; |
1214 | 1219 |