accurator/commit
Using switch to differentiate between fields, resolves #134
author | Chris Dijkshoorn |
---|---|
Mon Jun 20 11:51:52 2016 +0200 | |
committer | Chris Dijkshoorn |
Mon Jun 20 11:51:52 2016 +0200 | |
commit | a84dc799415f4a2e8f59cb0ebe113e5b0fc93670 |
tree | 51dc7a6e2dae7d1d3a34eccfd572bbaca1dcd8f5 |
parent | 5d633dd5a40028a7a4597776ae3ab6c93e3fd426 |
Diff style: patch stat
diff --git a/web/js/components/field.js b/web/js/components/field.js index 93dacd2..2795429 100644 --- a/web/js/components/field.js +++ b/web/js/components/field.js @@ -304,22 +304,23 @@ Field.prototype.dropdownField = function() { 'placeholder':this.comment})); } -// function annotationField(field) { -// switch (field.type) { -// case "DropdownField": -// var field = dropdownField(id, label, comment); -// addAutocompleteDropdown(id, field); -// return field; -// case "TextField": -// return textField(id, label, comment); -// case "RadioButtonField": -// return radioButtonField(id, label, comment, field.source); -// case "CheckboxField": -// return checkBoxField(id, label, comment, field.source); -// case "SelectField": -// return selectField(id, label, comment, field.source); -// } -// } +/******************************************************************************* +TypeAheadField +*******************************************************************************/ +function DropdownField (field, context) { + Field.call(this, field, context); +} + +DropdownField.prototype = Object.create(Field.prototype); // inherit + +/******************************************************************************* +TextField +*******************************************************************************/ +function TextField (field, context) { + Field.call(this, field, context); +} + +TextField.prototype = Object.create(Field.prototype); // inherit // function dropdownField(id, label, comment) { // return $.el.div({'class':'form-group'}, diff --git a/web/js/item.js b/web/js/item.js index fda7c01..cb506e7 100644 --- a/web/js/item.js +++ b/web/js/item.js @@ -225,10 +225,7 @@ function addAnnotationFields(metadata, user, uri, locale, domain, annotation_ui, context.fieldsId = page.wholeFieldsId; // create new field object - var wholeField = new Field( - fields.whole_fields[i], - context - ); + var wholeField = createField(fields.whole_fields[i], context); // add the field to div $("#" + wholeField.fieldsId).append(wholeField.node); @@ -251,10 +248,8 @@ function addAnnotationFields(metadata, user, uri, locale, domain, annotation_ui, context.fieldsId = page.fragmentFieldsId; // create new field object - var fragmentField = new Field( - fields.fragment_fields[i], - context - ); + var fragmentField = createField(fields.fragment_fields[i], context); + // append the field to div which will be embedded in annotorious $("#" + fragmentField.fieldsId).append(fragmentField.node); }