PollWidget v2
26
widgets/pollWidget/conf/info.xml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<widget version="0.2">
|
||||
<title xml:lang="ko">설문조사 위젯</title>
|
||||
<description xml:lang="ko">설문조사를 표시하는 위젯입니다.</description>
|
||||
<version>2.0</version>
|
||||
<date>2015-06-09</date>
|
||||
|
||||
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
|
||||
<name xml:lang="ko">NAVER</name>
|
||||
<name xml:lang="jp">NAVER</name>
|
||||
<name xml:lang="vi">NAVER</name>
|
||||
<name xml:lang="zh-CN">NAVER</name>
|
||||
<name xml:lang="en">NAVER</name>
|
||||
<name xml:lang="es">NAVER</name>
|
||||
<name xml:lang="ru">NAVER</name>
|
||||
<name xml:lang="zh-TW">NAVER</name>
|
||||
<name xml:lang="tr">NAVER</name>
|
||||
</author>
|
||||
|
||||
<extra_vars>
|
||||
<var id="poll_srl" type="text">
|
||||
<name xml:lang="ko">설문 SRL</name>
|
||||
<description xml:lang="ko">설문 SRL은 투표 코드의 poll_srl="(숫자)"입니다.</description>
|
||||
</var>
|
||||
</extra_vars>
|
||||
</widget>
|
||||
33
widgets/pollWidget/pollWidget.class.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/* Copyright (C) NAVER <http://www.navercorp.com> */
|
||||
/**
|
||||
* @class language_select
|
||||
* @author NAVER (developers@xpressengine.com)
|
||||
* @brief Language selector
|
||||
* @version 0.1
|
||||
*/
|
||||
class pollWidget extends WidgetHandler
|
||||
{
|
||||
/**
|
||||
* @brief Widget execution
|
||||
*
|
||||
* Get extra_vars declared in ./widgets/widget/conf/info.xml as arguments
|
||||
* After generating the result, do not print but return it.
|
||||
*/
|
||||
function proc($args)
|
||||
{
|
||||
// Set a path of the template skin (values of skin, colorset settings)
|
||||
$tpl_path = sprintf('%sskins/%s', $this->widget_path, $args->skin);
|
||||
$tpl_file = 'pollview';
|
||||
|
||||
Context::set('colorset', $args->colorset);
|
||||
Context::set('poll_srl', $args->poll_srl);
|
||||
Context::set('style', $args->style);
|
||||
|
||||
// Compile a template
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
}
|
||||
/* End of file language_select.class.php */
|
||||
/* Location: ./widgets/language_select/language_select.class.php */
|
||||
12
widgets/pollWidget/skins/default/_header.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!--%load_js_plugin("handlebars")-->
|
||||
|
||||
<!--@if(__DEBUG__)-->
|
||||
<load target="css/poll.css" />
|
||||
<load target="js/poll.js" />
|
||||
<!--@else-->
|
||||
<load target="css/poll.min.css" />
|
||||
<load target="js/poll.min.js" />
|
||||
<!--@end-->
|
||||
{@
|
||||
Context::loadLang(_XE_PATH_ . 'modules/poll/lang');
|
||||
}
|
||||
31
widgets/pollWidget/skins/default/css/poll.css
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
.pollWidget{padding:5px;}
|
||||
.poll_table{table-layout:fixed;width:100%;padding:0;border:none}
|
||||
.poll_table td{padding:0;margin:0}
|
||||
.poll_table td.h{background:url(../images/top_bg.png) repeat-x left top}
|
||||
.poll_table td.title{height:28px;background:url(../images/top_title_bg.png) repeat-x left top;padding:0 20px 0 20px;color:#C3C3C4}
|
||||
.poll_table td.title strong{color:#FFFFFF;font-weight:bold}
|
||||
.poll_table td.l{border-left:1px solid #E5E5E5}
|
||||
.poll_table td.r{border-right:1px solid #E5E5E5}
|
||||
.poll_table td.poll_content{padding:18px 13px 18px 13px}
|
||||
.poll_table td.poll_button{border:1px solid #E5E5E5;border-bottom:none;background-color:#F6F6F5}
|
||||
.poll_table td.poll_button div{padding:5px 0 2px 0;text-align:center}
|
||||
.poll_table td.b{background-color:#F6F6F5;height:7px}
|
||||
.poll_table td.b img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}
|
||||
.poll_table td.bb{height:7px}
|
||||
.poll_table td.bb img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}
|
||||
.poll_table td.poll_content div.title{color:#000000;background-color:#F5F5F5;border-top:2px solid #C1C0BD;border-bottom:2px solid #C1C0BD;font-weight:bold;padding:7px 0 7px 10px;margin-bottom:10px}
|
||||
.poll_table td.poll_content div.item_text{color:#636363;padding:0 10px 0 10px;margin-top:10px}
|
||||
.poll_table td.poll_content div.item_text strong{font-weight:bold;color:#000000;font-family:돋움;font-size:12px}
|
||||
.poll_table td.poll_content table.item_bar_table{width:100%;table-layout:fixed;border-bottom:1px solid #EDEDED;margin-top:10px}
|
||||
.poll_table td.poll_content table.noborder{border-bottom:none;margin-bottom:10px}
|
||||
.poll_table td.poll_content table.item_bar_table td.bar{padding:0 0 5px 0;background:url(../images/back_bar.png) repeat-x left center}
|
||||
.poll_table td.poll_content table.item_bar_table td.bar img{width:100%;height:6px}
|
||||
.poll_table td.poll_content table.item_bar_table td.status{font-size:.9em;padding-bottom:5px;color:#636363;padding-left:15px}
|
||||
.poll_table td.poll_content table.item_bar_table td.status strong{font-weight:bold;color:#58C011}
|
||||
.poll_table td.poll_content div.item{color:#636363;border-bottom:1px solid #EDEDED;padding:5px 0 8px 10px;margin-bottom:3px}
|
||||
.poll_table td.poll_content div.noborder{border-bottom:none;margin-bottom:10px}
|
||||
.poll_table td.poll_content div.checkcount{border-bottom:1px dashed #EDEDED;padding:0 0 8px 10px;margin-bottom:3px;text-align:right;color:#636363}
|
||||
.poll_table tr.cap>td{font-size:0;line-height:0;height:7px;overflow:hidden}
|
||||
.item.add{-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box; }
|
||||
.item.add *{-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box; }
|
||||
.item.add input[type='text']{width:90%;width:-webkit-calc(100% - 35px);width:-moz-calc(100% - 35px);width:calc(100% - 35px);}
|
||||
1
widgets/pollWidget/skins/default/css/poll.min.css
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.poll_table{table-layout:fixed;width:100%;padding:0;border:0}.poll_table td{padding:0;margin:0}.poll_table td.h{background:url(../images/top_bg.png) repeat-x left top}.poll_table td.title{height:28px;background:url(../images/top_title_bg.png) repeat-x left top;padding:0 20px;color:#C3C3C4}.poll_table td.title strong{color:#FFF;font-weight:700}.poll_table td.l{border-left:1px solid #E5E5E5}.poll_table td.r{border-right:1px solid #E5E5E5}.poll_table td.poll_content{padding:18px 13px}.poll_table td.poll_button{border:1px solid #E5E5E5;border-bottom:0;background-color:#F6F6F5}.poll_table td.poll_button div{padding:5px 0 2px;text-align:center}.poll_table td.b{background-color:#F6F6F5;height:7px}.poll_table td.b img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}.poll_table td.bb{height:7px}.poll_table td.bb img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}.poll_table td.poll_content div.title{color:#000;background-color:#F5F5F5;border-top:2px solid #C1C0BD;border-bottom:2px solid #C1C0BD;font-weight:700;padding:7px 0 7px 10px;margin-bottom:10px}.poll_table td.poll_content div.item_text{color:#636363;padding:0 10px;margin-top:10px}.poll_table td.poll_content div.item_text strong{font-weight:700;color:#000;font-family:돋움;font-size:12px}.poll_table td.poll_content table.item_bar_table{width:100%;table-layout:fixed;border-bottom:1px solid #EDEDED;margin-top:10px}.poll_table td.poll_content table.noborder{border-bottom:0;margin-bottom:10px}.poll_table td.poll_content table.item_bar_table td.bar{padding:0 0 5px;background:url(../images/back_bar.png) repeat-x left center}.poll_table td.poll_content table.item_bar_table td.bar img{width:100%;height:6px}.poll_table td.poll_content table.item_bar_table td.status{font-size:.9em;padding-bottom:5px;color:#636363;padding-left:15px}.poll_table td.poll_content table.item_bar_table td.status strong{font-weight:700;color:#58C011}.poll_table td.poll_content div.item{color:#636363;border-bottom:1px solid #EDEDED;padding:5px 0 8px 10px;margin-bottom:3px}.poll_table td.poll_content div.noborder{border-bottom:0;margin-bottom:10px}.poll_table td.poll_content div.checkcount{border-bottom:1px dashed #EDEDED;padding:0 0 8px 10px;margin-bottom:3px;text-align:right;color:#636363}.poll_table tr.cap>td{font-size:0;line-height:0;height:7px;overflow:hidden}
|
||||
BIN
widgets/pollWidget/skins/default/images/back_bar.png
Normal file
|
After Width: | Height: | Size: 159 B |
BIN
widgets/pollWidget/skins/default/images/blank.gif
Normal file
|
After Width: | Height: | Size: 43 B |
BIN
widgets/pollWidget/skins/default/images/color_bar.png
Normal file
|
After Width: | Height: | Size: 328 B |
BIN
widgets/pollWidget/skins/default/images/lb.png
Normal file
|
After Width: | Height: | Size: 216 B |
BIN
widgets/pollWidget/skins/default/images/lh.png
Normal file
|
After Width: | Height: | Size: 272 B |
BIN
widgets/pollWidget/skins/default/images/pipe.png
Normal file
|
After Width: | Height: | Size: 177 B |
BIN
widgets/pollWidget/skins/default/images/rb.png
Normal file
|
After Width: | Height: | Size: 211 B |
BIN
widgets/pollWidget/skins/default/images/rh.png
Normal file
|
After Width: | Height: | Size: 262 B |
BIN
widgets/pollWidget/skins/default/images/rlb.png
Normal file
|
After Width: | Height: | Size: 215 B |
BIN
widgets/pollWidget/skins/default/images/rrb.png
Normal file
|
After Width: | Height: | Size: 212 B |
BIN
widgets/pollWidget/skins/default/images/top_bg.png
Normal file
|
After Width: | Height: | Size: 299 B |
BIN
widgets/pollWidget/skins/default/images/top_title_bg.png
Normal file
|
After Width: | Height: | Size: 523 B |
404
widgets/pollWidget/skins/default/js/poll.js
Normal file
|
|
@ -0,0 +1,404 @@
|
|||
function initTemplete(type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 'poll':
|
||||
if(typeof window.template == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template").html();
|
||||
window.template = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
case 'result':
|
||||
if(typeof window.template_result == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template-result").html();
|
||||
window.template_result = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
case 'members':
|
||||
if(typeof window.template_member == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template-members").html();
|
||||
window.template_member = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* 설문 참여 함수 */
|
||||
function doPoll(fo_obj) {
|
||||
|
||||
var checkcount = new Array();
|
||||
var item = new Array();
|
||||
|
||||
for(var i=0;i<fo_obj.length;i++) {
|
||||
var obj = fo_obj[i];
|
||||
if(obj.nodeName != 'INPUT') continue;
|
||||
|
||||
var name = obj.name;
|
||||
if(name.indexOf('checkcount')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl_index = parseInt(t[1],10);
|
||||
checkcount[poll_srl_index] = obj.value;
|
||||
item[poll_srl_index] = new Array();
|
||||
|
||||
} else if(name.indexOf('item_')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl = parseInt(t[1],10);
|
||||
var poll_srl_index = parseInt(t[2],10);
|
||||
if(obj.checked == true) item[poll_srl_index][item[poll_srl_index].length] = obj.value;
|
||||
}
|
||||
}
|
||||
|
||||
var poll_srl_indexes = "";
|
||||
for(var poll_srl_index in checkcount) {
|
||||
if(!checkcount.hasOwnProperty(poll_srl_index)) continue;
|
||||
var count = checkcount[poll_srl_index];
|
||||
var items = item[poll_srl_index];
|
||||
if(items.length < 1 || count < items.length) {
|
||||
alert(poll_alert_lang);
|
||||
return false;
|
||||
}
|
||||
|
||||
poll_srl_indexes += items.join(',')+',';
|
||||
}
|
||||
fo_obj.poll_srl_indexes.value = poll_srl_indexes;
|
||||
|
||||
jQuery.exec_json("poll.procPoll", {"poll_srl":poll_srl,"poll_srl_indexes":poll_srl_indexes}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
loadPollResult(poll_srl);
|
||||
jQuery("#poll_" + poll_srl + "_gotoresult_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 항목 추가 함수 */
|
||||
function addItem(poll_srl,poll_srl_indexes) {
|
||||
jQuery.exec_json("poll.procPollInsertItem", {"srl":poll_srl,"index_srl":poll_srl_indexes,"title":jQuery("#new_item_" + poll_srl_indexes).val()}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
jQuery("#poll_" + poll_srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(poll_srl);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 항목 삭제 함수 */
|
||||
function deleteItem(poll_srl,poll_srl_indexes,poll_item_srl) {
|
||||
jQuery.exec_json("poll.procPollDeleteItem", {"srl":poll_srl,"index_srl":poll_srl_indexes,"item_srl":poll_item_srl}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
jQuery("#poll_" + poll_srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(poll_srl);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadPoll(poll_srl)
|
||||
{
|
||||
jQuery.exec_json("poll.getPollinfo", {"poll_srl":poll_srl}, function(data){
|
||||
jQuery("#stop_date_"+poll_srl).html(data.poll.stop_date);
|
||||
|
||||
initTemplete('poll');
|
||||
var template = window.template;
|
||||
var context = Object;
|
||||
var additem = data.caniadditem;
|
||||
context.questions = {};
|
||||
for (var i in data.poll.poll) {
|
||||
var poll = data.poll.poll[i];
|
||||
context.questions[i] = {};
|
||||
context.questions[i].poll_index_srl = poll.poll_index_srl;
|
||||
context.questions[i].checkcount = poll.checkcount;
|
||||
context.questions[i].title = poll.title;
|
||||
context.questions[i].items = poll.item;
|
||||
context.questions[i].poll_srl = poll_srl;
|
||||
context.questions[i].isMultipleChoice = (poll.checkcount>1);
|
||||
context.questions[i].additem = additem;
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#poll_content_" + poll_srl).html(html);
|
||||
|
||||
jQuery("#poll_" + poll_srl).css({
|
||||
display: "block"
|
||||
});
|
||||
jQuery("#poll_" + poll_srl + '_result').css({
|
||||
display: "none"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showPollMemberNext(poll_srl,poll_item_srl)
|
||||
{
|
||||
if(typeof window.cur_page == 'undefined')
|
||||
{
|
||||
window.cur_page = 1;
|
||||
}
|
||||
|
||||
window.cur_page++;
|
||||
|
||||
jQuery.exec_json("poll.getPollitemInfo", {"poll_srl":poll_srl,"poll_item":poll_item_srl,"page":window.cur_page}, function(data){
|
||||
initTemplete('members');
|
||||
var template = window.template_member;
|
||||
var context = Object;
|
||||
|
||||
context.poll_srl = poll_srl;
|
||||
context.poll_item_srl = poll_item_srl;
|
||||
context.page = window.cur_page;
|
||||
context.isPage = ((data.page.total_count>5) && (window.cur_page<data.page.total_page));
|
||||
|
||||
context.members = {};
|
||||
|
||||
for (var i in data.item.member) {
|
||||
var member = data.item.member[i];
|
||||
|
||||
context.members[i] = {};
|
||||
context.members[i].profile_image = member.profile_image;
|
||||
context.members[i].member_srl = member.member_srl;
|
||||
context.members[i].nick_name = member.nick_name;
|
||||
context.members[i].isImage = (member.profile_image != '');
|
||||
context.members[i].dummy_profile = data.dummy_profile;
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#btn_load_more_" + poll_item_srl).replaceWith(html);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function showPollMember(poll_srl,poll_item_srl)
|
||||
{
|
||||
window.cur_page = 1;
|
||||
|
||||
jQuery.exec_json("poll.getPollitemInfo", {"poll_srl":poll_srl,"poll_item":poll_item_srl,"page":window.cur_page}, function(data){
|
||||
initTemplete('members');
|
||||
var template = window.template_member;
|
||||
var context = Object;
|
||||
var title = poll_member_lang;
|
||||
title = title.replace("%s",data.item.title);
|
||||
var html = '<div class="title">' + title + '</div><ul>';
|
||||
context.poll_srl = poll_srl;
|
||||
context.poll_item_srl = poll_item_srl;
|
||||
context.page = window.cur_page;
|
||||
context.isPage = ((data.page.total_count>5) && (window.cur_page<data.page.total_count));
|
||||
|
||||
context.members = {};
|
||||
|
||||
for (var i in data.item.member) {
|
||||
var member = data.item.member[i];
|
||||
|
||||
context.members[i] = {};
|
||||
context.members[i].profile_image = member.profile_image;
|
||||
context.members[i].member_srl = member.member_srl;
|
||||
context.members[i].nick_name = member.nick_name;
|
||||
context.members[i].isImage = (member.profile_image != '');
|
||||
context.members[i].dummy_profile = data.dummy_profile;
|
||||
}
|
||||
html = html + template(context) + '</ul>';
|
||||
|
||||
jQuery("#poll_content_" + poll_srl + "_result").html(html);
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_gotoresult_button").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadPollResult(poll_srl)
|
||||
{
|
||||
jQuery.exec_json("poll.getPollinfo", {"poll_srl":poll_srl}, function(data){
|
||||
/*
|
||||
<block cond="$val->poll_count">
|
||||
{@$per = (int)(( $item->poll_count / $val->poll_count)*100) }
|
||||
</block>
|
||||
<block cond="!$val->poll_count">
|
||||
{@$per = 0}
|
||||
</block>
|
||||
*/
|
||||
jQuery("#stop_date_result_" + poll_srl).html(data.poll.stop_date);
|
||||
jQuery("#poll_count_result_" + poll_srl).html(data.poll.poll_count);
|
||||
|
||||
initTemplete('result');
|
||||
var template = window.template_result;
|
||||
var context = Object;
|
||||
var showMembers = (data.poll.poll_type==1 || data.poll.poll_type==3);
|
||||
context.questions = {};
|
||||
for (var i in data.poll.poll) {
|
||||
var poll = data.poll.poll[i];
|
||||
context.questions[i] = {};
|
||||
context.questions[i].poll_index_srl = poll.poll_index_srl;
|
||||
context.questions[i].checkcount = poll.checkcount;
|
||||
context.questions[i].title = poll.title;
|
||||
context.questions[i].poll_count = poll.poll_count;
|
||||
context.questions[i].showMembers = showMembers;
|
||||
context.questions[i].items = poll.item;
|
||||
var count = 0;
|
||||
for (var j in poll.item) {
|
||||
var item = poll.item[j];
|
||||
count++;
|
||||
if(poll.poll_count>0)
|
||||
{
|
||||
context.questions[i].items[j].per = Math.round((item.poll_count / poll.poll_count)*100);
|
||||
context.questions[i].items[j].isVote = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.questions[i].items[j].per = 0;
|
||||
context.questions[i].items[j].isVote = false;
|
||||
}
|
||||
context.questions[i].items[j].number = count;
|
||||
}
|
||||
context.questions[i].items = poll.item;
|
||||
context.questions[i].poll_srl = poll_srl;
|
||||
context.questions[i].isMultipleChoice = (poll.checkcount>1);
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#poll_content_" + poll_srl + "_result").html(html);
|
||||
jQuery("#poll_" + poll_srl).css({
|
||||
display: "none"
|
||||
});
|
||||
jQuery("#poll_" + poll_srl + '_result').css({
|
||||
display: "block"
|
||||
});
|
||||
/*
|
||||
<!--@foreach($poll->poll as $poll_srl_index => $val)-->
|
||||
<!--@foreach($val->item as $item_srl => $item)-->
|
||||
<!--@end-->
|
||||
<!--@end-->
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
jQuery(function($){
|
||||
/* View poll result */
|
||||
$('._poll_result').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_result_button").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
loadPollResult(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/* goto poll result */
|
||||
$('._gotoresult_screen').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_gotoresult_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPollResult(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/* View poll screen */
|
||||
$('._poll_screen').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
1
widgets/pollWidget/skins/default/js/poll.min.js
vendored
Normal file
205
widgets/pollWidget/skins/default/pollview.html
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
<include target="_header.html" />
|
||||
<script>
|
||||
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
||||
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
||||
var poll_member_lang = "{$lang->poll_item_members}";
|
||||
jQuery.exec_json("poll.getPollstatus", {/**/"poll_srl":{$poll_srl}/**/}, function(data){/**/
|
||||
if(data.is_polled==0) loadPoll({$poll_srl});
|
||||
else
|
||||
{
|
||||
loadPollResult({$poll_srl});
|
||||
jQuery("#poll_{$poll_srl}_result_button").css({/**/
|
||||
display: "none"
|
||||
/**/});
|
||||
|
||||
jQuery("#poll_{$poll_srl}_result_nobutton").css({/**/
|
||||
display: "table-row"
|
||||
/**/});
|
||||
|
||||
jQuery("#poll_{$poll_srl}_result_yesbutton").css({/**/
|
||||
display: "none"
|
||||
/**/});
|
||||
}
|
||||
/**/});
|
||||
</script>
|
||||
<div style="{$style}">
|
||||
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
||||
<script id="entry-template" type="text/x-handlebars-template">
|
||||
{{#each questions as |question questionid|}}
|
||||
<input type="hidden" name="checkcount_{{question.poll_index_srl}}" value="{{question.checkcount}}" />
|
||||
<div class="title">Q : {{question.title}}</div>
|
||||
|
||||
{{#if question.isMultipleChoice}}
|
||||
<div class="checkcount">
|
||||
{$lang->poll_checkcount} : {{question.checkcount}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each question.items as |item itemid|}}
|
||||
<div class="item">
|
||||
{{#if question.isMultipleChoice}}
|
||||
<input type="checkbox" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
|
||||
{{else}}
|
||||
<input type="radio" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
|
||||
{{/if}}
|
||||
<label for="item_{{item.poll_item_srl}}">{{item.title}}</label>
|
||||
{{#if item.my_item}}
|
||||
<input type="button" value="x" onclick="deleteItem({{question.poll_srl}},{{question.poll_index_srl}},{{item.poll_item_srl}})" style="float: right;" class="btn poll_button _poll_delete_item" />
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#if question.additem}}
|
||||
<div class="item add">
|
||||
<input type="text" name="new_item" id="new_item_{{question.poll_index_srl}}" value="" /> <input type="button" value="+" onclick="addItem({{question.poll_srl}},{{question.poll_index_srl}})" style="float: right;" class="btn poll_button _poll_add_item" />
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</script>
|
||||
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'widgets/pollWidget/skins/default/form/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
<form ruleset="poll" action="./" method="post" onsubmit="return doPoll(this)">
|
||||
<input type="hidden" name="module" value="poll" />
|
||||
<input type="hidden" name="act" value="procPoll" />
|
||||
<input type="hidden" name="poll_srl" value="{$poll_srl}" />
|
||||
<input type="hidden" name="poll_srl_indexes" value="" />
|
||||
<input type="hidden" name="skin" value="{$skin}" />
|
||||
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
|
||||
<input type="hidden" name="xe_validator_id" value="widgets/pollWidget/skins/default/form/1" />
|
||||
<table cellspacing="0" class="poll_table">
|
||||
<col width="7" />
|
||||
<col />
|
||||
<col width="7" />
|
||||
<tr class="cap">
|
||||
<td><img src="./images/lh.png" alt="lh" width="7" height="7" /></td>
|
||||
<td class="h"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
<td><img src="./images/rh.png" alt="rh" width="7" height="7" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title" colspan="3">
|
||||
{$lang->poll_stop_date}: <strong id="stop_date_{$poll_srl}"></strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
<td id="poll_content_{$poll_srl}" class="poll_content">
|
||||
|
||||
</td>
|
||||
<td class="r"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="poll_button">
|
||||
<div>
|
||||
<input type="button" value="{$lang->cmd_view_result}" class="btn poll_button _poll_result _srl_{$poll_srl}" />
|
||||
<input type="submit" value="{$lang->cmd_apply_poll}" class="btn poll_button" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="cap">
|
||||
<td class="lb" ><img src="./images/lb.png" alt="lb" width="7" height="7" /></td>
|
||||
<td class="b"><img src="./images/blank.gif" alt="blank" /></td>
|
||||
<td class="rb" ><img src="./images/rb.png" alt="rb" width="7" height="7" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div id="poll_{$poll_srl}_result" class="pollWidget poll_box" style="display:none;">
|
||||
<script id="entry-template-result" type="text/x-handlebars-template">
|
||||
{{#each questions as |question questionid|}}
|
||||
<div class="title">{{question.title}} ({{question.poll_count}})</div>
|
||||
{{#each question.items as |item itemid|}}
|
||||
<div class="item_text">
|
||||
{{#if question.showMembers}}
|
||||
<strong>{{item.number}}</strong> <img src="./images/pipe.png" alt="" /> <a href="#" onclick="showPollMember({{question.poll_srl}},{{item.poll_item_srl}});return false;">{{item.title}}</a>
|
||||
{{else}}
|
||||
<strong>{{item.number}}</strong> <img src="./images/pipe.png" alt="" /> {{item.title}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="item_bar_table">
|
||||
<col width="30" />
|
||||
<col/>
|
||||
<col width="75" />
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td class="bar">
|
||||
{{#if item.isVote}}
|
||||
<img src="./images/color_bar.png" style="width:{{item.per}}%;height:6px;" alt="bar" />
|
||||
{{else}}
|
||||
<img src="./images/blank.gif" width="1" height="1" alt="" />
|
||||
{{/if}}
|
||||
</td>
|
||||
<td class="status"><strong>{{item.poll_count}}</strong> ({{item.per}}%)</td>
|
||||
</tr>
|
||||
</table>
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
</script>
|
||||
<script id="entry-template-members" type="text/x-handlebars-template">
|
||||
{{#each members as |member memberid|}}
|
||||
{{#if member.isImage}}
|
||||
<li><img src="{{member.profile_image}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
|
||||
{{else}}
|
||||
<li><img class="dummy" src="{{dummy_profile}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if isPage}}
|
||||
<input type="button" id="btn_load_more_{{poll_item_srl}}" value="More..." onclick="showPollMemberNext({{poll_srl}},{{poll_item_srl}});return false;" style="width:100%;" class="btn poll_button" />
|
||||
{{/if}}
|
||||
</script>
|
||||
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/poll/skins/default/form/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="poll_table">
|
||||
<col width="7" />
|
||||
<col />
|
||||
<col width="7" />
|
||||
<tr class="cap">
|
||||
<td><img src="./images/lh.png" alt="lh" width="7" height="7" /></td>
|
||||
<td class="h"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
<td><img src="./images/rh.png" alt="rh" width="7" height="7" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="title" colspan="3">
|
||||
<div style="float:left">
|
||||
{$lang->poll_stop_date}: <strong id="stop_date_result_{$poll_srl}"></strong> 24:00
|
||||
</div>
|
||||
<div style="float:right">
|
||||
{$lang->poll_join_count}: <strong id="poll_count_result_{$poll_srl}"></strong>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="l"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
<td id="poll_content_{$poll_srl}_result" class="poll_content">
|
||||
</td>
|
||||
<td class="r"><img src="./images/blank.gif" height="7" alt="blank" /></td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_result_button" style="width:100%;display: none;">
|
||||
<td colspan="3" class="poll_button">
|
||||
<div>
|
||||
<input type="button" value="{$lang->btn_poll_gotovote}" class="btn poll_button _poll_screen _srl_{$poll_srl}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_gotoresult_button" style="width:100%;display: none;">
|
||||
<td colspan="3" class="poll_button">
|
||||
<div>
|
||||
<input type="button" value="{$lang->btn_poll_gotoresult}" class="btn poll_button _gotoresult_screen _srl_{$poll_srl}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_result_nobutton" class="cap">
|
||||
<td class="rlb" ><img src="./images/rlb.png" alt="lb" width="7" height="7" /></td>
|
||||
<td class="bb"><img src="./images/blank.gif" alt="blank" /></td>
|
||||
<td class="rrb" ><img src="./images/rrb.png" alt="rb" width="7" height="7" /></td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_result_yesbutton" class="cap">
|
||||
<td class="lb" ><img src="./images/lb.png" alt="lb" width="7" height="7" /></td>
|
||||
<td class="b"><img src="./images/blank.gif" alt="blank" /></td>
|
||||
<td class="rb" ><img src="./images/rb.png" alt="rb" width="7" height="7" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
41
widgets/pollWidget/skins/default/skin.xml
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<skin version="0.2">
|
||||
<title xml:lang="ko">설문조사 기본 스킨</title>
|
||||
<title xml:lang="zh-CN">投票系统默认皮肤</title>
|
||||
<title xml:lang="jp">アンケート調査デフォルトスキン</title>
|
||||
<title xml:lang="en">Default Skin of teh Poll</title>
|
||||
<title xml:lang="vi">Skin mặc định của thăm dò</title>
|
||||
<title xml:lang="zh-TW">投票系統預設面板</title>
|
||||
<title xml:lang="tr">Oylamanın Varsayılan Dış Görünümü</title>
|
||||
<description xml:lang="ko">설문조사 기본 스킨</description>
|
||||
<description xml:lang="zh-CN">投票系统默认皮肤。</description>
|
||||
<description xml:lang="jp">アンケート調査デフォルトスキン</description>
|
||||
<description xml:lang="en">Default Skin of the Poll</description>
|
||||
<description xml:lang="vi">Skin mặc định của thăm dò.</description>
|
||||
<description xml:lang="zh-TW">投票系統預設面板。</description>
|
||||
<description xml:lang="tr">Oylamanın Varsayılan Dış Görünümü</description>
|
||||
<version>2.0</version>
|
||||
<date>2015-06-09</date>
|
||||
|
||||
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
|
||||
<name xml:lang="ko">NAVER</name>
|
||||
<name xml:lang="vi">NAVER</name>
|
||||
<name xml:lang="zh-CN">NAVER</name>
|
||||
<name xml:lang="jp">NAVER</name>
|
||||
<name xml:lang="en">NAVER</name>
|
||||
<name xml:lang="zh-TW">NAVER</name>
|
||||
<name xml:lang="tr">NAVER</name>
|
||||
</author>
|
||||
|
||||
<colorset>
|
||||
<color name="normal">
|
||||
<title xml:lang="ko">기본</title>
|
||||
<title xml:lang="vi">Mặc định</title>
|
||||
<title xml:lang="zh-CN">默认</title>
|
||||
<title xml:lang="jp">デフォルト</title>
|
||||
<title xml:lang="en">Default</title>
|
||||
<title xml:lang="zh-TW">預設</title>
|
||||
<title xml:lang="tr">Varsayılan</title>
|
||||
</color>
|
||||
</colorset>
|
||||
</skin>
|
||||
12
widgets/pollWidget/skins/simple/_header.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!--%load_js_plugin("handlebars")-->
|
||||
|
||||
<!--@if(__DEBUG__)-->
|
||||
<load target="css/poll.css" />
|
||||
<load target="js/poll.js" />
|
||||
<!--@else-->
|
||||
<load target="css/poll.min.css" />
|
||||
<load target="js/poll.min.js" />
|
||||
<!--@end-->
|
||||
{@
|
||||
Context::loadLang(_XE_PATH_ . 'modules/poll/lang');
|
||||
}
|
||||
30
widgets/pollWidget/skins/simple/css/poll.css
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
.simple_poll { table-layout:fixed; padding:0; margin:0; border:none;}
|
||||
|
||||
.simple_poll td { padding:0; margin:0; }
|
||||
.simple_poll td.title { text-align:right; }
|
||||
|
||||
.simple_poll td .itemDiv { border-top:1px solid #BBBBBB; margin-top:3px; padding:3px 0 3px 0; }
|
||||
.simple_poll td .title { color:#000000; font-weight:bold; letter-spacing:-1px;}
|
||||
.simple_poll td .checkcount { color:#AAAAAA; }
|
||||
|
||||
.simple_poll td .item { color:#636363; margin:5px 0 5px 0; }
|
||||
.simple_poll td .item input { margin:0; padding:0; }
|
||||
.simple_poll td .item label { letter-spacing:-1px; }
|
||||
|
||||
.simple_poll td .resultItem { color:#636363; margin:6px 0 0 10px; letter-spacing:-1px;}
|
||||
|
||||
.simple_poll td .barBox { margin-left:10px; }
|
||||
.simple_poll td .barBox .bar { margin:3px 0;}
|
||||
.simple_poll td .barBox .status {color:#AAAAAA; }
|
||||
|
||||
.simple_poll td.stopDate { color:#AAAAAA; border-top:1px solid #BBBBBB; padding-top:3px;}
|
||||
.simple_poll td.stopDate a { color:#AAAAAA; text-decoration:none; }
|
||||
|
||||
.simple_poll td.poll_button { text-align:left; padding-top:3px;}
|
||||
.simple_poll td.poll_button .poll_button { border:1px solid #EEEEEE; background-color:#AAAAAA; color:#FFFFFF; font-weight:bold; padding:1px 3px 1px 3px; height:20px; }
|
||||
|
||||
|
||||
.simple_poll td.b { background-color:#F6F6F5; height:7px; }
|
||||
.simple_poll td.b img { width:100%; height:6px; border-bottom:1px solid #E5E5E5; }
|
||||
.simple_poll td.bb { height:7px; }
|
||||
.simple_poll td.bb img { width:100%; height:6px; border-bottom:1px solid #E5E5E5; }
|
||||
1
widgets/pollWidget/skins/simple/css/poll.min.css
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.simple_poll{table-layout:fixed;padding:0;margin:0;border:0}.simple_poll td{padding:0;margin:0}.simple_poll td.title{text-align:right}.simple_poll td .itemDiv{border-top:1px solid #BBB;margin-top:3px;padding:3px 0}.simple_poll td .title{color:#000;font-weight:700;letter-spacing:-1px}.simple_poll td .checkcount{color:#AAA}.simple_poll td .item{color:#636363;margin:5px 0}.simple_poll td .item input{margin:0;padding:0}.simple_poll td .item label{letter-spacing:-1px}.simple_poll td .resultItem{color:#636363;margin:6px 0 0 10px;letter-spacing:-1px}.simple_poll td .barBox{margin-left:10px}.simple_poll td .barBox .bar{margin:3px 0}.simple_poll td .barBox .status{color:#AAA}.simple_poll td.stopDate{color:#AAA;border-top:1px solid #BBB;padding-top:3px}.simple_poll td.stopDate a{color:#AAA;text-decoration:none}.simple_poll td.poll_button{text-align:left;padding-top:3px}.simple_poll td.poll_button .poll_button{border:1px solid #EEE;background-color:#AAA;color:#FFF;font-weight:700;padding:1px 3px;height:20px}.simple_poll td.b{background-color:#F6F6F5;height:7px}.simple_poll td.b img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}.simple_poll td.bb{height:7px}.simple_poll td.bb img{width:100%;height:6px;border-bottom:1px solid #E5E5E5}
|
||||
BIN
widgets/pollWidget/skins/simple/images/color_bar.png
Normal file
|
After Width: | Height: | Size: 328 B |
404
widgets/pollWidget/skins/simple/js/poll.js
Normal file
|
|
@ -0,0 +1,404 @@
|
|||
function initTemplete(type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 'poll':
|
||||
if(typeof window.template == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template").html();
|
||||
window.template = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
case 'result':
|
||||
if(typeof window.template_result == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template-result").html();
|
||||
window.template_result = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
case 'members':
|
||||
if(typeof window.template_member == 'undefined')
|
||||
{
|
||||
var source = jQuery("#entry-template-members").html();
|
||||
window.template_member = Handlebars.compile(source);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* 설문 참여 함수 */
|
||||
function doPoll(fo_obj) {
|
||||
|
||||
var checkcount = new Array();
|
||||
var item = new Array();
|
||||
|
||||
for(var i=0;i<fo_obj.length;i++) {
|
||||
var obj = fo_obj[i];
|
||||
if(obj.nodeName != 'INPUT') continue;
|
||||
|
||||
var name = obj.name;
|
||||
if(name.indexOf('checkcount')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl_index = parseInt(t[1],10);
|
||||
checkcount[poll_srl_index] = obj.value;
|
||||
item[poll_srl_index] = new Array();
|
||||
|
||||
} else if(name.indexOf('item_')>-1) {
|
||||
var t = name.split('_');
|
||||
var poll_srl = parseInt(t[1],10);
|
||||
var poll_srl_index = parseInt(t[2],10);
|
||||
if(obj.checked == true) item[poll_srl_index][item[poll_srl_index].length] = obj.value;
|
||||
}
|
||||
}
|
||||
|
||||
var poll_srl_indexes = "";
|
||||
for(var poll_srl_index in checkcount) {
|
||||
if(!checkcount.hasOwnProperty(poll_srl_index)) continue;
|
||||
var count = checkcount[poll_srl_index];
|
||||
var items = item[poll_srl_index];
|
||||
if(items.length < 1 || count < items.length) {
|
||||
alert(poll_alert_lang);
|
||||
return false;
|
||||
}
|
||||
|
||||
poll_srl_indexes += items.join(',')+',';
|
||||
}
|
||||
fo_obj.poll_srl_indexes.value = poll_srl_indexes;
|
||||
|
||||
jQuery.exec_json("poll.procPoll", {"poll_srl":poll_srl,"poll_srl_indexes":poll_srl_indexes}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
loadPollResult(poll_srl);
|
||||
jQuery("#poll_" + poll_srl + "_gotoresult_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 항목 추가 함수 */
|
||||
function addItem(poll_srl,poll_srl_indexes) {
|
||||
jQuery.exec_json("poll.procPollInsertItem", {"srl":poll_srl,"index_srl":poll_srl_indexes,"title":jQuery("#new_item_" + poll_srl_indexes).val()}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
jQuery("#poll_" + poll_srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(poll_srl);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 항목 삭제 함수 */
|
||||
function deleteItem(poll_srl,poll_srl_indexes,poll_item_srl) {
|
||||
jQuery.exec_json("poll.procPollDeleteItem", {"srl":poll_srl,"index_srl":poll_srl_indexes,"item_srl":poll_item_srl}, function(data){
|
||||
if(data.error!=0) alert(data.message);
|
||||
else
|
||||
{
|
||||
jQuery("#poll_" + poll_srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(poll_srl);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadPoll(poll_srl)
|
||||
{
|
||||
jQuery.exec_json("poll.getPollinfo", {"poll_srl":poll_srl}, function(data){
|
||||
jQuery("#stop_date_"+poll_srl).html(data.poll.stop_date);
|
||||
|
||||
initTemplete('poll');
|
||||
var template = window.template;
|
||||
var context = Object;
|
||||
var additem = data.caniadditem;
|
||||
context.questions = {};
|
||||
for (var i in data.poll.poll) {
|
||||
var poll = data.poll.poll[i];
|
||||
context.questions[i] = {};
|
||||
context.questions[i].poll_index_srl = poll.poll_index_srl;
|
||||
context.questions[i].checkcount = poll.checkcount;
|
||||
context.questions[i].title = poll.title;
|
||||
context.questions[i].items = poll.item;
|
||||
context.questions[i].poll_srl = poll_srl;
|
||||
context.questions[i].isMultipleChoice = (poll.checkcount>1);
|
||||
context.questions[i].additem = additem;
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#poll_content_" + poll_srl).html(html);
|
||||
|
||||
jQuery("#poll_" + poll_srl).css({
|
||||
display: "block"
|
||||
});
|
||||
jQuery("#poll_" + poll_srl + '_result').css({
|
||||
display: "none"
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showPollMemberNext(poll_srl,poll_item_srl)
|
||||
{
|
||||
if(typeof window.cur_page == 'undefined')
|
||||
{
|
||||
window.cur_page = 1;
|
||||
}
|
||||
|
||||
window.cur_page++;
|
||||
|
||||
jQuery.exec_json("poll.getPollitemInfo", {"poll_srl":poll_srl,"poll_item":poll_item_srl,"page":window.cur_page}, function(data){
|
||||
initTemplete('members');
|
||||
var template = window.template_member;
|
||||
var context = Object;
|
||||
|
||||
context.poll_srl = poll_srl;
|
||||
context.poll_item_srl = poll_item_srl;
|
||||
context.page = window.cur_page;
|
||||
context.isPage = ((data.page.total_count>5) && (window.cur_page<data.page.total_page));
|
||||
|
||||
context.members = {};
|
||||
|
||||
for (var i in data.item.member) {
|
||||
var member = data.item.member[i];
|
||||
|
||||
context.members[i] = {};
|
||||
context.members[i].profile_image = member.profile_image;
|
||||
context.members[i].member_srl = member.member_srl;
|
||||
context.members[i].nick_name = member.nick_name;
|
||||
context.members[i].isImage = (member.profile_image != '');
|
||||
context.members[i].dummy_profile = data.dummy_profile;
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#btn_load_more_" + poll_item_srl).replaceWith(html);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function showPollMember(poll_srl,poll_item_srl)
|
||||
{
|
||||
window.cur_page = 1;
|
||||
|
||||
jQuery.exec_json("poll.getPollitemInfo", {"poll_srl":poll_srl,"poll_item":poll_item_srl,"page":window.cur_page}, function(data){
|
||||
initTemplete('members');
|
||||
var template = window.template_member;
|
||||
var context = Object;
|
||||
var title = poll_member_lang;
|
||||
title = title.replace("%s",data.item.title);
|
||||
var html = '<div class="itemDiv"><div class="title">' + title + '</div><ul>';
|
||||
context.poll_srl = poll_srl;
|
||||
context.poll_item_srl = poll_item_srl;
|
||||
context.page = window.cur_page;
|
||||
context.isPage = ((data.page.total_count>5) && (window.cur_page<data.page.total_count));
|
||||
|
||||
context.members = {};
|
||||
|
||||
for (var i in data.item.member) {
|
||||
var member = data.item.member[i];
|
||||
|
||||
context.members[i] = {};
|
||||
context.members[i].profile_image = member.profile_image;
|
||||
context.members[i].member_srl = member.member_srl;
|
||||
context.members[i].nick_name = member.nick_name;
|
||||
context.members[i].isImage = (member.profile_image != '');
|
||||
context.members[i].dummy_profile = data.dummy_profile;
|
||||
}
|
||||
html = html + template(context) + '</ul></div>';
|
||||
|
||||
jQuery("#poll_content_" + poll_srl + "_result").html(html);
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_gotoresult_button").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_nobutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + poll_srl + "_result_yesbutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function loadPollResult(poll_srl)
|
||||
{
|
||||
jQuery.exec_json("poll.getPollinfo", {"poll_srl":poll_srl}, function(data){
|
||||
/*
|
||||
<block cond="$val->poll_count">
|
||||
{@$per = (int)(( $item->poll_count / $val->poll_count)*100) }
|
||||
</block>
|
||||
<block cond="!$val->poll_count">
|
||||
{@$per = 0}
|
||||
</block>
|
||||
*/
|
||||
jQuery("#stop_date_result_" + poll_srl).html(data.poll.stop_date);
|
||||
jQuery("#poll_count_result_" + poll_srl).html(data.poll.poll_count);
|
||||
|
||||
initTemplete('result');
|
||||
var template = window.template_result;
|
||||
var context = Object;
|
||||
var showMembers = (data.poll.poll_type==1 || data.poll.poll_type==3);
|
||||
context.questions = {};
|
||||
for (var i in data.poll.poll) {
|
||||
var poll = data.poll.poll[i];
|
||||
context.questions[i] = {};
|
||||
context.questions[i].poll_index_srl = poll.poll_index_srl;
|
||||
context.questions[i].checkcount = poll.checkcount;
|
||||
context.questions[i].title = poll.title;
|
||||
context.questions[i].poll_count = poll.poll_count;
|
||||
context.questions[i].showMembers = showMembers;
|
||||
context.questions[i].items = poll.item;
|
||||
var count = 0;
|
||||
for (var j in poll.item) {
|
||||
var item = poll.item[j];
|
||||
count++;
|
||||
if(poll.poll_count>0)
|
||||
{
|
||||
context.questions[i].items[j].per = Math.round((item.poll_count / poll.poll_count)*100);
|
||||
context.questions[i].items[j].isVote = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.questions[i].items[j].per = 0;
|
||||
context.questions[i].items[j].isVote = false;
|
||||
}
|
||||
context.questions[i].items[j].number = count;
|
||||
}
|
||||
context.questions[i].items = poll.item;
|
||||
context.questions[i].poll_srl = poll_srl;
|
||||
context.questions[i].isMultipleChoice = (poll.checkcount>1);
|
||||
}
|
||||
var html = template(context);
|
||||
|
||||
jQuery("#poll_content_" + poll_srl + "_result").html(html);
|
||||
jQuery("#poll_" + poll_srl).css({
|
||||
display: "none"
|
||||
});
|
||||
jQuery("#poll_" + poll_srl + '_result').css({
|
||||
display: "block"
|
||||
});
|
||||
/*
|
||||
<!--@foreach($poll->poll as $poll_srl_index => $val)-->
|
||||
<!--@foreach($val->item as $item_srl => $item)-->
|
||||
<!--@end-->
|
||||
<!--@end-->
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
jQuery(function($){
|
||||
/* View poll result */
|
||||
$('._poll_result').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_result_button").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
loadPollResult(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/* goto poll result */
|
||||
$('._gotoresult_screen').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_gotoresult_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPollResult(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
/* View poll screen */
|
||||
$('._poll_screen').click(function(){
|
||||
var cls = $(this).attr('class'), srl, skin;
|
||||
|
||||
try{
|
||||
srl = cls.match(/\b_srl_(\d+)\b/)[1];
|
||||
}catch(e){ };
|
||||
|
||||
if(!srl) return false;
|
||||
|
||||
jQuery("#poll_" + srl + "_result_button").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_nobutton").css({
|
||||
display: "table-row"
|
||||
});
|
||||
|
||||
jQuery("#poll_" + srl + "_result_yesbutton").css({
|
||||
display: "none"
|
||||
});
|
||||
|
||||
loadPoll(srl);
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
1
widgets/pollWidget/skins/simple/js/poll.min.js
vendored
Normal file
148
widgets/pollWidget/skins/simple/pollview.html
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<include target="_header.html" />
|
||||
<script>
|
||||
var poll_alert_lang = "{$lang->msg_check_poll_item}";
|
||||
var poll_checkcount_lang = "{$lang->poll_checkcount}";
|
||||
var poll_member_lang = "{$lang->poll_item_members}";
|
||||
jQuery.exec_json("poll.getPollstatus", {/**/"poll_srl":{$poll_srl}/**/}, function(data){/**/
|
||||
if(data.is_polled==0) loadPoll({$poll_srl});
|
||||
else
|
||||
{
|
||||
loadPollResult({$poll_srl});
|
||||
jQuery("#poll_{$poll_srl}_result_button").css({/**/
|
||||
display: "none"
|
||||
/**/});
|
||||
|
||||
jQuery("#poll_{$poll_srl}_result_nobutton").css({/**/
|
||||
display: "table-row"
|
||||
/**/});
|
||||
|
||||
jQuery("#poll_{$poll_srl}_result_yesbutton").css({/**/
|
||||
display: "none"
|
||||
/**/});
|
||||
}
|
||||
/**/});
|
||||
</script>
|
||||
<div style="{$style}">
|
||||
<div id="poll_{$poll_srl}" class="pollWidget" style="display:none;">
|
||||
<script id="entry-template" type="text/x-handlebars-template">
|
||||
{{#each questions as |question questionid|}}
|
||||
<div class="itemDiv">
|
||||
<input type="hidden" name="checkcount_{{question.poll_index_srl}}" value="{{question.checkcount}}" />
|
||||
<div class="title">{{question.title}}</div>
|
||||
|
||||
{{#if question.isMultipleChoice}}
|
||||
<div class="checkcount">
|
||||
{$lang->poll_checkcount} : {{question.checkcount}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each question.items as |item itemid|}}
|
||||
<div class="item">
|
||||
{{#if question.isMultipleChoice}}
|
||||
<input type="checkbox" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
|
||||
{{else}}
|
||||
<input type="radio" name="item_{{question.poll_srl}}_{{question.poll_index_srl}}" value="{{item.poll_item_srl}}" id="item_{{item.poll_item_srl}}" />
|
||||
{{/if}}
|
||||
<label for="item_{{item.poll_item_srl}}">{{item.title}}</label>
|
||||
{{#if item.my_item}}
|
||||
<input type="button" value="x" onclick="deleteItem({{question.poll_srl}},{{question.poll_index_srl}},{{item.poll_item_srl}})" style="float: right;" class="btn poll_button _poll_delete_item" />
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
{{#if question.additem}}
|
||||
<div class="item add">
|
||||
<input type="text" name="new_item" id="new_item_{{question.poll_index_srl}}" value="" /> <input type="button" value="+" onclick="addItem({{question.poll_srl}},{{question.poll_index_srl}})" style="float: right;" class="btn poll_button _poll_add_item" />
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</script>
|
||||
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'widgets/pollWidget/skins/default/form/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
<form ruleset="poll" action="./" method="post" onsubmit="return doPoll(this)">
|
||||
<input type="hidden" name="module" value="poll" />
|
||||
<input type="hidden" name="act" value="procPoll" />
|
||||
<input type="hidden" name="poll_srl" value="{$poll_srl}" />
|
||||
<input type="hidden" name="poll_srl_indexes" value="" />
|
||||
<input type="hidden" name="skin" value="{$skin}" />
|
||||
<input type="hidden" name="success_return_url" value="{getRequestUriByServerEnviroment()}" />
|
||||
<input type="hidden" name="xe_validator_id" value="widgets/pollWidget/skins/default/form/1" />
|
||||
<table cellspacing="0" class="simple_poll">
|
||||
<tr>
|
||||
<td id="poll_content_{$poll_srl}" class="poll_content">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="stopDate">
|
||||
~<strong id="stop_date_{$poll_srl}"></strong> (<a href="#" class="_poll_result _srl_{$poll_srl}">{$lang->cmd_view_result}</a>)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="poll_button">
|
||||
<input type="submit" value="{$lang->cmd_apply_poll}" class="poll_button" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div id="poll_{$poll_srl}_result" class="pollWidget poll_box" style="display:none;">
|
||||
<script id="entry-template-result" type="text/x-handlebars-template">
|
||||
<div class="itemDiv">
|
||||
{{#each questions as |question questionid|}}
|
||||
<div class="title">{{question.title}} ({{question.poll_count}})</div>
|
||||
{{#each question.items as |item itemid|}}
|
||||
<div class="resultItem">
|
||||
{{#if question.showMembers}}
|
||||
<a href="#" onclick="showPollMember({{question.poll_srl}},{{item.poll_item_srl}});return false;">{{item.title}}</a>
|
||||
{{else}}
|
||||
{{item.title}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
<div class="barBox">
|
||||
<div class="bar"><img src="./images/color_bar.png" style="width:{{item.per}}%;height:6px;" alt="bar" /></div>
|
||||
<div class="status">{{item.poll_count}} ({{item.per}}%)</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</script>
|
||||
<script id="entry-template-members" type="text/x-handlebars-template">
|
||||
{{#each members as |member memberid|}}
|
||||
{{#if member.isImage}}
|
||||
<li><img src="{{member.profile_image}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
|
||||
{{else}}
|
||||
<li><img class="dummy" src="{{dummy_profile}}" width="16" height="16" /> <a href="#popup_menu_area" class="member_{{member.member_srl}}" onclick="return false">{{member.nick_name}}</a></li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if isPage}}
|
||||
<input type="button" id="btn_load_more_{{poll_item_srl}}" value="More..." onclick="showPollMemberNext({{poll_srl}},{{poll_item_srl}});return false;" style="width:100%;" class="btn poll_button" />
|
||||
{{/if}}
|
||||
</script>
|
||||
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/poll/skins/default/form/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
|
||||
<table cellspacing="0" class="simple_poll">
|
||||
<tr>
|
||||
<td id="poll_content_{$poll_srl}_result" class="poll_content">
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_result_button" style="width:100%;display: none;">
|
||||
<td colspan="3" class="poll_button">
|
||||
<div>
|
||||
<input type="button" value="{$lang->btn_poll_gotovote}" class="btn poll_button _poll_screen _srl_{$poll_srl}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="poll_{$poll_srl}_gotoresult_button" style="width:100%;display: none;">
|
||||
<td colspan="3" class="poll_button">
|
||||
<div>
|
||||
<input type="button" value="{$lang->btn_poll_gotoresult}" class="btn poll_button _gotoresult_screen _srl_{$poll_srl}" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
38
widgets/pollWidget/skins/simple/skin.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<skin version="0.2">
|
||||
<title xml:lang="ko">설문조사 간단한 스킨</title>
|
||||
<title xml:lang="vi">Skin thăm dò đơn giản</title>
|
||||
<title xml:lang="jp">アンケート調査の簡単スキン</title>
|
||||
<title xml:lang="zh-CN">投票系统简易皮肤</title>
|
||||
<title xml:lang="zh-TW">投票系統簡單面板</title>
|
||||
<title xml:lang="tr">Oylama Sistem Dış Görünümü</title>
|
||||
<description xml:lang="ko">설문조사 간단한 스킨</description>
|
||||
<description xml:lang="vi">Skin hiển thị thăm dò đơn giản.</description>
|
||||
<description xml:lang="jp">アンケート調査の簡単スキン</description>
|
||||
<description xml:lang="zh-CN">投票系统简易皮肤。</description>
|
||||
<description xml:lang="zh-TW">投票系統簡單面板。</description>
|
||||
<description xml:lang="tr">Oylama Sistemi Dış Görünümü</description>
|
||||
<version>2.0</version>
|
||||
<date>2015-06-09</date>
|
||||
|
||||
<author email_address="developers@xpressengine.com" link="http://xpressengine.com/">
|
||||
<name xml:lang="ko">NAVER</name>
|
||||
<name xml:lang="vi">NAVER</name>
|
||||
<name xml:lang="jp">NAVER</name>
|
||||
<name xml:lang="zh-CN">NAVER</name>
|
||||
<name xml:lang="zh-TW">NAVER</name>
|
||||
<name xml:lang="tr">NAVER</name>
|
||||
</author>
|
||||
|
||||
<colorset>
|
||||
<color name="normal">
|
||||
<title xml:lang="ko">기본</title>
|
||||
<title xml:lang="vi">Mặc định</title>
|
||||
<title xml:lang="zh-CN">默认</title>
|
||||
<title xml:lang="jp">デフォルト</title>
|
||||
<title xml:lang="en">Default</title>
|
||||
<title xml:lang="zh-TW">預設</title>
|
||||
<title xml:lang="tr">Varsayılan</title>
|
||||
</color>
|
||||
</colorset>
|
||||
</skin>
|
||||