19 package org.turro.www.voteit;
21 import org.turro.string.Strings;
22 import org.turro.auth.Authentication;
23 import org.turro.elephant.context.ElephantContext;
24 import org.turro.elephant.context.IConstructor;
25 import org.turro.html.HTMLHelper;
26 import org.turro.i18n.I_;
27 import org.turro.marker.ElephantMarker;
28 import org.turro.plugin.contacts.ContactList;
29 import org.turro.plugin.contacts.IContact;
30 import org.turro.util.IdGenerator;
31 import org.turro.voteit.VoteItInfo;
32 import org.turro.voteit.VoteItUtil;
41 private String entityPath, allowedString;
43 private boolean forbiden, forbid, forceInternalRender;
47 this.constructor = constructor;
51 this.entityPath = entityPath;
55 this.forbiden = forbiden;
59 this.allowed = allowed;
63 this.allowedString = allowedString;
71 forceInternalRender = force;
76 if(!forbiden && forbid) {
77 forbiden = !(allowed !=
null && allowed.
contains(contact));
79 if(Strings.isBlank(allowedString)) {
83 String
id = container ?
"vic_" + IdGenerator.generate() : constructor.
getParameter(
"domid");
86 em.
put(
"control",
this);
87 em.
put(
"contact", contact);
88 em.
put(
"controlId",
id);
89 em.
put(
"container", container);
91 em.
put(
"forbiden", forbiden);
92 em.
put(
"entityPath", entityPath);
93 em.
process(
"widgets/webcomp",
"voteIt");
103 if(!forbiden && forbid) {
104 forbiden = !(allowed !=
null && allowed.
contains(contact));
106 if(Strings.isBlank(allowedString)) {
111 long positiveWidth = 0, negativeWidth = 0, nocareWidth = 0;
117 String
id = container ?
"vic_" + IdGenerator.generate() : constructor.
getParameter(
"domid");
119 html.
startTag(
"div",
"id='" +
id +
"'");
123 .
startTag(
"span",
"class='voteit-votes'")
127 .
startTag(
"span",
"class='voteit-string'")
132 .
startTag(
"div",
"style='width:60px' class='voteit-bar'")
133 .
startTable(
"cellpadding='0' cellspacing='0'")
134 .
startTableCol(
"class='voteit-positive' style='" + (positiveWidth == 0 ?
"display:none" :
"width:" + positiveWidth +
"px") +
"'")
135 .
startTableCol(
"class='voteit-nocare' style='" + (nocareWidth == 0 ?
"display:none" :
"width:" + nocareWidth +
"px") +
"'")
136 .
startTableCol(
"class='voteit-negative' style='" + (negativeWidth == 0 ?
"display:none" :
"width:" + negativeWidth +
"px") +
"'")
142 .
doTag(
"img",
new String[] {
161 String color =
"#333";
171 .
startTag(
"span",
"class='voteit-string' style='color:" + color +
"'")
175 .
startTag(
"span",
"class='voteit-string' style='color:" + color +
"'")
184 "{ action: \"vote-it\", path: \"" + entityPath +
"\"" +
185 (allowedString ==
null ?
"" :
", allowed: \"" + allowedString.replaceAll(
"'",
"-") +
"\"") +
186 ", vote: " + i +
", domid: \"" +
id +
"\" })" +
187 ".done(function(data) { $(\"#" +
id +
"\").html(data); });";
static IContact getIContact()
static String getRootWebPath()
HTMLGenerator endAllTags()
HTMLGenerator write(String value)
HTMLGenerator doTag(String tag)
HTMLGenerator endTableRow()
HTMLGenerator startTag(String tag)
HTMLGenerator startTableCol(String attributes)
HTMLGenerator startTable(String attributes)
static String get(String msg)
void process(String rootTmpl, String tmpl)
static boolean existsTemplate(IConstructor constructor, boolean mail, String root, String name)
Object put(Object key, Object value)
static VoteItInfo info(Object entity, IContact contact)
String getVoteUrl(String id, int i)
void setAllowed(ContactList allowed)
void renderTemplateVotes(boolean container)
void setForbiden(boolean forbiden)
VoteItCtrl(IConstructor constructor)
void setEntityPath(String entityPath)
void renderVotes(boolean container)
void setAllowedString(String allowedString)
void setForbid(boolean forbid)
void setForceInternalRender(boolean force)
String getParameter(String param)