use of web.Dropdown in project common by zenlunatics.
the class SelectDropdown method write.
@Override
public String write(View view, Request request) throws IOException {
Dropdown dropdown = new Dropdown("select", "btn-xs", request.writer);
dropdown.open();
dropdown.aOnClick("all", "cb_set_all($(this).ancestor('FORM'),'db_check',true)");
dropdown.aOnClick("none", "cb_set_all($(this).ancestor('FORM'),'db_check',false)");
ResultSet rs = request.db.select("SELECT * FROM people_mail_lists WHERE people_id=" + request.getUser().getId() + " ORDER BY name");
try {
if (rs.isBeforeFirst())
dropdown.divider();
while (rs.next()) dropdown.aOnClick(rs.getString("name"), "cb_select('" + rs.getString("people_ids") + "')");
rs.getStatement().close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
dropdown.divider();
dropdown.aOnClick("save currently checked people as list...", "save_list(this)");
dropdown.close();
request.writer.scriptOpen();
request.writer.jsFunction("cb_select", "ids", "var c=ids.split(',');" + "for(var i=0;i<c.length;i++){" + "var cb=$('cb'+c[i]);" + "if(cb)" + "cb.checked=true;" + "}");
request.writer.jsFunction("save_list", "a", "var l=prompt('enter name for list');" + "if(l){" + "var f=$(a).ancestor('FORM');" + "f.cmd.value='save';" + "f.list.value=l;" + "send_form(a,function(t){" + "var p=$('dropdown_select');" + "if(p)" + "p.dispose();" + "c_(a).replace();" + "dialog_alert('','list saved');" + "});" + "}");
request.writer.scriptClose();
return null;
}
use of web.Dropdown in project common by zenlunatics.
the class ColumnBase method writeInputWithDropdown.
// --------------------------------------------------------------------------
protected static void writeInputWithDropdown(String name, List<String> values, View view, String default_value, Request request) throws IOException {
JDBCColumn jdbc_column = request.db.getTable(view.getViewDef().getFrom()).getColumn(name);
HTMLWriter writer = request.writer;
// flex display is to prevent firefox from expanding div to 100% width
writer.write("<div class=\"input-group\" style=\"display:flex\">");
String id = UUID.randomUUID().toString();
writer.setAttribute("id", id);
if (values.size() > 0)
writer.setAttribute("onkeyup", "fill_choice(this,$(this).getNext().getElement('ul'))");
writer.textInput(name, Integer.toString(jdbc_column.size), getValue(jdbc_column, default_value, view, request));
if (values.size() > 0) {
Dropdown dropdown = new Dropdown(null, "dropdown-toggle", request.writer).setDivClass("input-group-btn").setDropdownMenuRight(true).open();
for (String value : values) dropdown.aOnClick(value, "$(this).ancestor('DIV').getPrevious().value=this.get('text');");
dropdown.close();
}
writer.write("</div>");
}
use of web.Dropdown in project common by zenlunatics.
the class View method writeColumnsPopup.
// --------------------------------------------------------------------------
private void writeColumnsPopup() throws IOException {
String[] column_names_all = m_state.getColumnNamesAll(this);
String[] column_names_table = m_state.getColumnNamesTable(this);
m_writer.setAttribute("style", "display:inline-block;");
Dropdown dropdown = new Dropdown("<img src=\"" + m_request.getContext() + "/images/columns.png\">", "btn-xs", m_writer).open();
for (String column_name : column_names_all) {
ColumnBase<?> column = getColumn(column_name);
if (!canViewColumn(column))
continue;
String text = column == null ? ColumnBase.getDisplayName(column_name, true) : column.getDisplayName(true);
if (column_names_table == null || Util.indexOf(column_names_table, column_name) != -1)
text = "<img src=\"" + m_request.getContext() + "/images/check.png\"> " + text;
else
text = "<img src=\"" + m_request.getContext() + "/images/check.png\" style=\"visibility:hidden;\"> " + text;
dropdown.aOnClick(text, "XHR_post(context+'/db','db_cmd=toggle_column&db_view_def=" + m_view_def.getName() + "&db_column=" + column_name + "',function(){c_(this).replace()}.bind(this))");
}
dropdown.close();
}
use of web.Dropdown in project common by zenlunatics.
the class CalendarPicker method write.
// --------------------------------------------------------------------------
public void write(Request request) throws IOException {
EventProvider main_event_provider = (EventProvider) request.site.getModule(m_event_provider_name);
Collection<EventProvider> event_providers = getCalendarsSorted(request);
if (event_providers.size() > 1) {
request.writer.setAttribute("id", "calendar_picker");
String display_name = main_event_provider.getDisplayName();
request.writer.setAttribute("data-main", display_name);
request.writer.setAttribute("data-name", m_event_provider_name);
request.writer.setAttribute("style", "float:left;text-align:left;");
Dropdown dropdown = new Dropdown(display_name, null, request.writer).open();
for (EventProvider event_provider : event_providers) if (!m_event_provider_name.equals(event_provider.getName())) {
request.writer.setAttribute("data-name", event_provider.getName());
dropdown.aOnClick(event_provider.getDisplayName(), "$('calendar').calendar.set_name(this.innerText,this.dataset.name);");
}
dropdown.close();
}
}
Aggregations