Add attribute-parsing code to widget constructor.
authorMike Taylor <mike@indexdata.com>
Mon, 31 Mar 2014 15:26:51 +0000 (16:26 +0100)
committerMike Taylor <mike@indexdata.com>
Mon, 31 Mar 2014 15:26:51 +0000 (16:26 +0100)
commitc6cff5a726e217e9c35f7fca0ecbfb931df7d393
tree29c3126d0f7ad65d8ff2ea2c4b0cc8aca572d6fb
parentbfde53879d93c48509569052c83e80a2b0c94e2a
Add attribute-parsing code to widget constructor.

Handles three cases:

1. data-mkws-config -- argument is a JSON fragment containing any
number of key=value pairs to be added to the configuration
2. Any other data-mkws-NAME -- argument is a string, and is set as the
value of the configuration item NAME.
3. Any other attribute NAME that is not one of a hardwired set that are
recognised and discarded -- argument is a string, and is set
as the value of the attribute name.

Case 1 is the industrial-strength one that can be used when setting a
complex value, such as a list of facets:
data-mkws-config='{ "facets": ["xtargets", "author", "subject"] }'
Case 2 is the general-purpose way of setting any string value simply:
data-mkws-perpage="50"
Case 3 is a simplifying short-cut for case 2:
perpage="20"
src/mkws-widgets.js