@Override public void outputHtml(SafeHtmlBuilder output) { open(output, id, css.panel(), TypeCodes.kind(Type.PARTICIPANTS)); { open(output, null, css.flow(), null); { open(output, Components.CONTAINER.getDomId(id), null, null); { participantUis.outputHtml(output); // Overflow-mode panel. openSpan(output, null, css.extra(), null); { openSpanWith(output, null, css.toggleGroup(), null, "onclick=\"" + onClickJs() + "\""); { appendSpan(output, null, css.expandButton(), null); openSpan(output, null, null, null); { output.appendPlainText("more"); } closeSpan(output); } closeSpan(output); appendSpan(output, null, css.addButton(), TypeCodes.kind(Type.ADD_PARTICIPANT)); button( output, null, css.newWaveWithParticipantsButton(), TypeCodes.kind(Type.NEW_WAVE_WITH_PARTICIPANTS), "New wave with the participants of current wave", "New wave"); } closeSpan(output); // Single-line mode panel. openSpan(output, null, css.simple(), null); { appendSpan(output, null, css.addButton(), TypeCodes.kind(Type.ADD_PARTICIPANT)); button( output, null, css.newWaveWithParticipantsButton(), TypeCodes.kind(Type.NEW_WAVE_WITH_PARTICIPANTS), "New wave with the participants of current wave", "New wave"); } closeSpan(output); } close(output); } close(output); } close(output); }
/** @return a JS click handler for toggling expanded and collapsed modes. */ private String onClickJs() { String js = "" // + "var p=document.getElementById('" + id + "');" // + "var x=p.getAttribute('s')=='e';" // + "var l=this.lastChild;" // + "p.style.height=x?'':'auto';" // + "p.setAttribute('s',x?'':'e');" // + "lastChild.innerHTML=x?'more':'less';" // + "firstChild.className=x?'" + css.expandButton() + "':'" + css.collapseButton() + "';" // + "parentNode.nextSibling.style.display=x?'':'none';" // ; // The constructed string has no double-quote characters in it, so it can be // double-quoted verbatim. assert !js.contains("\""); return js; }