diff --git a/src/js/hTagMacroJS.tw b/src/js/hTagMacroJS.tw new file mode 100644 index 0000000000000000000000000000000000000000..9e8c566b7eb23534f0753eb34b2c2b7e1cb0749d --- /dev/null +++ b/src/js/hTagMacroJS.tw @@ -0,0 +1,47 @@ +:: HTAG Macro JS [script] + +/* + * <<htag>> macro + * A simple macro which allows to create wrapping html elements with dynamic IDs. + * idea blatantly robbed from the spanMacroJS.tw but expanded to a more generic + * case, allowing <div>, <button> or whatever you want. elements, default is for + * the div though. In addition, you can pass an object in as the first argument + * instead of an id, and each of the object's attributes will become attributes + * of the generate tag. + * + * Usage: <<htag id>>...<</htag>> + * Usage: <<htag id tag>>...<</htag>> + * Usage: <<htag atributes>>...<</htag>> + * Usage: <<htag atributes tag>>...<</htag>> + */ +Macro.add('htag', { + tags : null, + + munge(val, key) { return key + '="' + val + '"'; }, + handler() { + const payload = this.payload[0].contents.replace(/(^\n+|\n+$)/, ''); + let htag = 'div'; + let attributes; + + if (1 > this.args.length) { + return this.error('invalid syntax, format: <<htag [id [ tag ] | attributes [ tag ] >>'); + } + if (1 < this.args.length) { + htag = String(this.args[1]).trim(); + } + if (typeof this.args[0] === "object") { + attributes = //$.map(this.args[0], munge).join(" "); + $.map( + this.args[0], + function (val, key) { return key + '="' + val + '"'; }) + .join(" "); + } else { + attributes = 'id="' + String(this.args[0]).trim() + '"'; + } + Config.debug && this.debugView.modes({block: true}); + + jQuery('<' + htag + ' ' + attributes + ' />') + .wiki(payload) + .appendTo(this.output); + } +}); diff --git a/src/uncategorized/slaveSummary.tw b/src/uncategorized/slaveSummary.tw index ba4cb47ea1840197424e80e752bd3bc055f80022..823b5f19a172c29017df7b44d87e470661a7a648 100644 --- a/src/uncategorized/slaveSummary.tw +++ b/src/uncategorized/slaveSummary.tw @@ -94,7 +94,7 @@ /* Useful for finding weird combinations -- usages of this passage that don't yet generate the quick index. * <<print 'pass/count/indexed/flag::[' + _Pass + '/' + _Count + '/' + _indexed + '/' + $Flag + ']'>> */ - <<if ((_Count > 1) && (_indexed == 0) && (((_Pass == 'Main') && (ndef $Flag)) || ($Flag == 1)))>> + <<if ((_Count > 1) && (_indexed == 0) && (((_Pass == 'Main') && (ndef $Flag) && (($useSlaveSummaryTabs == 0) || ($slaveAssignmentTab == "all"))) || ($Flag == 1)))>> <<set _indexed = 1, _counter = 0, _buttons = [], _offset = -50>> <<if (/Select/i.test(_Pass))>> <<set _offset = -25>> @@ -116,13 +116,16 @@ <br /> <<set _tableCount = _tableCount || 0>> <<set _tableCount++>> - <<set _quickList = '<button data-quick-index="' + _tableCount + '">Quick Index</button>'>> - <<set _listDivOpen = '<div id="list_index' + _tableCount + '" class="hidden">'>> - <<set _listDivClose = '</div><!-- ' + _tableCount + ' -->'>> - _quickList -/% <button data-quick-index="<<print _tableCount>>">Quick Index</button> %/ - _listDivOpen -/% <div id="list_index<<print _tableCount>>" class="hidden"> %/ + /* + * we want <button data-quick-index="<<= _tableCount>>"> ... + */ + <<set _buttonAttributes = { 'data-quick-index': _tableCount }>> + <<htag _buttonAttributes 'button'>>Quick Index<</htag>> + /* + * we want <div id="list_index3" class=" hidden">... + */ + <<set _divAttributes = { id: 'list_index' + _tableCount, class: 'hidden'}>> + <<htag _divAttributes>> <<for !_.isUndefined(_ssii = _indexSlavesIdxs.shift())>> <<set _IndexSlave = $slaves[_ssii]>> <<if $surnameOrder != 1>> @@ -177,8 +180,7 @@ }); </script> <</if>> - _listDivClose -/% </div> %/ + <</htag>> <</if>> <</if>> <<switch _Pass>> @@ -756,7 +758,10 @@ will <</if>> /* closes _numFacilities */ -<<print '<span id="slave-' + $slaves[_ssi].ID + '"> </span><br/>'>> +<<if ((_Pass != 'Main') || (def $Flag) || ($useSlaveSummaryTabs == 0) || ($slaveAssignmentTab == "all"))>> + <<print '<span id="slave-' + $slaves[_ssi].ID + '"> </span>'>> +<</if>> +<br/> <<if $seeImages != 1 || $seeSummaryImages != 1 || $imageChoice == 1>> <</if>> <<SlaveSummary _Slave>>