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 b22fca3376b1b0943cead2a30c1aa01198305cfa..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>> @@ -114,8 +114,18 @@ table.quicklist col { width: 8%; } </style> <br /> - <button data-quick-index="1">Quick Index</button> - <div id="list_index" class="hidden"> + <<set _tableCount = _tableCount || 0>> + <<set _tableCount++>> + /* + * 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>> @@ -151,7 +161,8 @@ * Use javascript scrollTop animation for in page navigation. */ $("[data-quick-index]").click(function () { - var $quick = $('div#list_index'); + var $this = $(this), which = $this.attr('data-quick-index'); + var $quick = $('div#list_index' + which); $quick.toggleClass("hidden"); }); $("[data-scroll-to]").click(function() { @@ -169,7 +180,7 @@ }); </script> <</if>> - </div> + <</htag>> <</if>> <</if>> <<switch _Pass>> @@ -747,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>>