issue 47 Refactore the 'poll_maker' editor component.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8479 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-06-15 03:01:05 +00:00
parent 4a50363cb1
commit 9142149a3a
11 changed files with 209 additions and 216 deletions

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file /modules/editor/components/poll_maker/lang/en.lang.php * @file /modules/editor/components/poll_maker/lang/en.lang.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief editor module > language pack of poll_maker component * @brief editor module > language pack of poll_maker component
**/ **/
$lang->poll_title = "Title"; $lang->poll_title = "Title";
$lang->poll_item = "Items"; $lang->poll_item = "Items";
$lang->poll_stop_date = "Expiration Date"; $lang->poll_stop_date = "Expiration Date";
$lang->poll_chk_count = "Number of Checking Item"; $lang->poll_chk_count = "Number of Checking Item";
$lang->cmd_add_poll = "Add Poll"; $lang->cmd_add_poll = "Add a poll";
$lang->cmd_del_poll = "Delete Poll"; $lang->cmd_del_poll = "Delete this poll";
$lang->cmd_add_item = "Add Item"; $lang->cmd_add_item = "Add an item";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = "You cannot modify the poll. You need to delete it if you want to create a new poll."; $lang->msg_poll_cannot_modify = "You cannot modify the poll. You need to delete it if you want to create a new poll.";
?>
/* file : en.lang.php */

View file

@ -1,19 +1,20 @@
<?php <?php
/** /**
* @file /modules/editor/components/poll_maker/lang/en.lang.php * @file /modules/editor/components/poll_maker/lang/en.lang.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief editor module > language pack of poll_maker component * @brief editor module > language pack of poll_maker component
**/ **/
$lang->poll_title = "Titulo"; $lang->poll_title = "Titulo";
$lang->poll_item = "Temas"; $lang->poll_item = "Temas";
$lang->poll_stop_date = "Fecha de Expiracion"; $lang->poll_stop_date = "Fecha de Expiracion";
$lang->poll_chk_count = "Numero de Comprobacion de Partida"; $lang->poll_chk_count = "Numero de Comprobacion de Partida";
$lang->cmd_add_poll = "Anadir Encuesta"; $lang->cmd_add_poll = "Anadir Encuesta";
$lang->cmd_del_poll = "Borrar encuesta"; $lang->cmd_del_poll = "Borrar encuesta";
$lang->cmd_add_item = "Anadir Tema"; $lang->cmd_add_item = "Anadir Tema";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = "No se puede modificar la encuesta. Por lo que debe suprimirse para crear una nueva encuesta"; $lang->msg_poll_cannot_modify = "No se puede modificar la encuesta. Por lo que debe suprimirse para crear una nueva encuesta";
?> /* file : en.lang.php */

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file modules/editor/components/urllink/lang/jp.lang.php * @file modules/editor/components/urllink/lang/jp.lang.php
* @author NHN (developers@xpressengine.com) 翻訳RisaPapa、ミニミ * @author NHN (developers@xpressengine.com) 翻訳RisaPapa、ミニミ
* @brief ウィジウィグエディターeditorモジュール > アンケート調査言語パッケージ * @brief ウィジウィグエディターeditorモジュール > アンケート調査言語パッケージ
**/ **/
$lang->poll_title = "タイトル"; $lang->poll_title = "タイトル";
$lang->poll_item = "項目"; $lang->poll_item = "項目";
$lang->poll_stop_date = "終了日"; $lang->poll_stop_date = "終了日";
$lang->poll_chk_count = "選択項目数"; $lang->poll_chk_count = "選択項目数";
$lang->cmd_add_poll = "アンケート追加"; $lang->cmd_add_poll = "アンケート追加";
$lang->cmd_del_poll = "アンケート削除"; $lang->cmd_del_poll = "アンケート削除";
$lang->cmd_add_item = "項目追加"; $lang->cmd_add_item = "項目追加";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = 'アンケートは修正出来ません。削除後、改めて新しく作成して下さい。'; $lang->msg_poll_cannot_modify = 'アンケートは修正出来ません。削除後、改めて新しく作成して下さい。';
?>
/* file : jp.lang.php */

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file modules/editor/components/urllink/lang/ko.lang.php * @file modules/editor/components/urllink/lang/ko.lang.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief 위지윅에디터(editor) 모듈 > 설문조사 컴포넌트의 언어팩 * @brief 위지윅에디터(editor) 모듈 > 설문조사 컴포넌트의 언어팩
**/ **/
$lang->poll_title = '제목'; $lang->poll_title = '제목';
$lang->poll_item = '항목'; $lang->poll_item = '항목';
$lang->poll_stop_date = '종료 일자'; $lang->poll_stop_date = '종료 일자';
$lang->poll_chk_count = '선택항목 수'; $lang->poll_chk_count = '선택항목 수';
$lang->cmd_add_poll = '설문 추가'; $lang->cmd_add_poll = '설문 추가';
$lang->cmd_del_poll = '설문 제거'; $lang->cmd_del_poll = '설문 제거';
$lang->cmd_add_item = '항목 추가'; $lang->cmd_add_item = '항목 추가';
$lang->cmd_del_item = '마지막 항목 제거';
$lang->msg_poll_cannot_modify = '설문조사는 수정하실 수 없습니다. 삭제 후 다시 생성하셔야 합니다.'; $lang->msg_poll_cannot_modify = '설문조사는 수정할 수 없습니다. 삭제 후 다시 생성하셔야 합니다.';
?>
/* file : ko.lang.php */

View file

@ -13,6 +13,7 @@
$lang->cmd_add_poll = "Добавить опрос"; $lang->cmd_add_poll = "Добавить опрос";
$lang->cmd_del_poll = "Удалить опрос"; $lang->cmd_del_poll = "Удалить опрос";
$lang->cmd_add_item = "Добавить пункт"; $lang->cmd_add_item = "Добавить пункт";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = "Вы не можете изменить этот опрос. Его следует удалить для того, чтобы создать новый."; $lang->msg_poll_cannot_modify = "Вы не можете изменить этот опрос. Его следует удалить для того, чтобы создать новый.";
?> ?>

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file /modules/editor/components/poll_maker/lang/en.lang.php * @file /modules/editor/components/poll_maker/lang/tr.lang.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief editor module > language pack of poll_maker component * @brief editor module > language pack of poll_maker component
**/ **/
$lang->poll_title = "Başlık"; $lang->poll_title = "Başlık";
$lang->poll_item = "Parça"; $lang->poll_item = "Parça";
$lang->poll_stop_date = "Sonlandırma Tarihi"; $lang->poll_stop_date = "Sonlandırma Tarihi";
$lang->poll_chk_count = "Denetlenen Parça Sayısı"; $lang->poll_chk_count = "Denetlenen Parça Sayısı";
$lang->cmd_add_poll = "Oylama Ekle"; $lang->cmd_add_poll = "Oylama Ekle";
$lang->cmd_del_poll = "Parçayı Sil"; $lang->cmd_del_poll = "Parçayı Sil";
$lang->cmd_add_item = "Parça Ekle"; $lang->cmd_add_item = "Parça Ekle";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = "Oylamayı düzenleyemezsiniz. Yeni oylama oluşturmak için, oylamanın silinmesi gerekiyor."; $lang->msg_poll_cannot_modify = "Oylamayı düzenleyemezsiniz. Yeni oylama oluşturmak için, oylamanın silinmesi gerekiyor.";
?>
/* file : tr.lang.php */

View file

@ -1,20 +1,22 @@
<?php <?php
/* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ /**
░░ * @File : common/lang/vi.lang.php ░░ * @File : common/lang/vi.lang.php
░░ * @Author : NHN (developers@xpressengine.com) ░░ * @Author : NHN (developers@xpressengine.com)
░░ * @Trans : Đào Đức Duy (ducduy.dao.vn@vietxe.net) ░░ * @Trans : Đào Đức Duy (ducduy.dao.vn@vietxe.net)
░░ * @Website: http://vietxe.net ░░ * @Website: http://vietxe.net
░░ * @Brief : Vietnamese Language Pack (Only basic words are included here) ░░ * @Brief : Vietnamese Language Pack (Only basic words are included here)
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ */ */
$lang->poll_title = "Tiêu đề"; $lang->poll_title = "Tiêu đề";
$lang->poll_item = "Mục"; $lang->poll_item = "Mục";
$lang->poll_stop_date = "Ngày hết hạn"; $lang->poll_stop_date = "Ngày hết hạn";
$lang->poll_chk_count = "Số phiếu"; $lang->poll_chk_count = "Số phiếu";
$lang->cmd_add_poll = "Tạo thăm dò"; $lang->cmd_add_poll = "Tạo thăm dò";
$lang->cmd_del_poll = "Xóa thăm dò"; $lang->cmd_del_poll = "Xóa thăm dò";
$lang->cmd_add_item = "Thêm mục"; $lang->cmd_add_item = "Thêm mục";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = "Bạn không thể sửa đổi được. Nó sẽ được xóa để tạo cuộc thăm dò mới."; $lang->msg_poll_cannot_modify = "Bạn không thể sửa đổi được. Nó sẽ được xóa để tạo cuộc thăm dò mới.";
?>
/* file : vi.lang.php */

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file /modules/editor/components/urllink/lang/zh-CN.lang.php * @file /modules/editor/components/urllink/lang/zh-CN.lang.php
* @author NHN (developers@xpressengine.com) * @author NHN (developers@xpressengine.com)
* @brief 网页编辑器(editor) 模块 > 投票调查组件语言包 * @brief 网页编辑器(editor) 模块 > 投票调查组件语言包
**/ **/
$lang->poll_title = "标题"; $lang->poll_title = "标题";
$lang->poll_item = "项目"; $lang->poll_item = "项目";
$lang->poll_stop_date = "结束日期"; $lang->poll_stop_date = "结束日期";
$lang->poll_chk_count = "选择项目数"; $lang->poll_chk_count = "选择项目数";
$lang->cmd_add_poll = "添加投票"; $lang->cmd_add_poll = "添加投票";
$lang->cmd_del_poll = "解除投票"; $lang->cmd_del_poll = "解除投票";
$lang->cmd_add_item = "添加项目"; $lang->cmd_add_item = "添加项目";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = '投票调查不提供修改功能。必须删除后再生成'; $lang->msg_poll_cannot_modify = '投票调查不提供修改功能。必须删除后再生成';
?>
/* file : zh-CN.lang.php */

View file

@ -1,18 +1,20 @@
<?php <?php
/** /**
* @file /modules/editor/components/urllink/lang/zh-TW.lang.php * @file /modules/editor/components/urllink/lang/zh-TW.lang.php
* @author NHN (developers@xpressengine.com) 翻譯royallin * @author NHN (developers@xpressengine.com) 翻譯royallin
* @brief 網頁編輯器(editor) 模組 > 投票調查組件語言 * @brief 網頁編輯器(editor) 模組 > 投票調查組件語言
**/ **/
$lang->poll_title = "標題"; $lang->poll_title = "標題";
$lang->poll_item = "項目"; $lang->poll_item = "項目";
$lang->poll_stop_date = "結束日期"; $lang->poll_stop_date = "結束日期";
$lang->poll_chk_count = "選擇項目數"; $lang->poll_chk_count = "選擇項目數";
$lang->cmd_add_poll = "新增投票"; $lang->cmd_add_poll = "新增投票";
$lang->cmd_del_poll = "刪除投票"; $lang->cmd_del_poll = "刪除投票";
$lang->cmd_add_item = "新增項目"; $lang->cmd_add_item = "新增項目";
$lang->cmd_del_item = "Delete last item";
$lang->msg_poll_cannot_modify = '投票調查不提供修改功能。必須刪除後再新增'; $lang->msg_poll_cannot_modify = '投票調查不提供修改功能。必須刪除後再新增';
?>
/* file : zh-TW.lang.php */

View file

@ -89,16 +89,17 @@
</tr> </tr>
</table> </table>
<a href="#" onclick="doPollAddItem(this); return false;" class="button black small"><span>{$lang->cmd_add_item}</span></a> <button type="button" class="_add_item">{$lang->cmd_add_item}</button>
<a href="#" onclick="doPollDelete(this); return false;" class="button red small"><span>{$lang->cmd_del_poll}</span></a> <button type="button" class="_del_item">{$lang->cmd_del_item}</button>
<button type="button" class="_del_poll">{$lang->cmd_del_poll}</button>
</div> </div>
</div> </div>
<div id="popFooter"> <div id="popFooter">
<span class="button black strong"><input type="submit" value="{$lang->cmd_submit}" /></span> <span class="button black strong"><input type="submit" value="{$lang->cmd_submit}" /></span>
<a href="#" onclick="doPollAdd(); return false;" class="button blue"><span>{$lang->cmd_add_poll}</span></a> <button type="button" id="add_poll">{$lang->cmd_add_poll}</button>
<a href="#" onclick="winopen('./?module=editor&amp;act=dispEditorComponentInfo&amp;component_name={$component_info->component_name}','ComponentInfo','left=10,top=10,width=10,height=10,resizable=no,scrollbars=no,toolbars=no');return false;" class="button"><span>{$lang->about_component}</span></a> <a href="./?module=editor&amp;act=dispEditorComponentInfo&amp;component_name={$component_info->component_name}" class="button _xe_popup"><span>{$lang->about_component}</span></a>
</div> </div>

View file

@ -2,30 +2,6 @@
* popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 block이 있는지 체크하여 * popup으로 열렸을 경우 부모창의 위지윅에디터에 select된 block이 있는지 체크하여
* 있으면 가져와서 원하는 곳에 삽입 * 있으면 가져와서 원하는 곳에 삽입
**/ **/
var poll_index = 1;
function setPoll() {
var node = opener.editorPrevNode;
if(node && node.getAttribute('editor_component')=='poll_maker') {
alert(msg_poll_cannot_modify);
window.close();
return;
}
var obj = xCreateElement("div");
var source = xGetElementById("poll_source");
var html = xInnerHtml(source);
html = html.replace(/tidx/g, poll_index);
xInnerHtml(obj, html);
obj.id = "poll_"+poll_index;
obj.className = "poll_box";
obj.style.display = "block";
source.parentNode.insertBefore(obj, source);
setFixedPopupSize();
}
/** /**
* 부모창의 위지윅에디터에 데이터를 삽입 * 부모창의 위지윅에디터에 데이터를 삽입
@ -52,93 +28,93 @@ function completeInsertPoll(ret_obj) {
return null; return null;
} }
xAddEventListener(window, "load", setPoll); jQuery(function($){
var $node, poll_last_idx = 1;
/** $node = $(opener.editorPrevNode);
* 설문 추가 if($node.length && $node.attr('editor_component') == 'poll_maker') {
**/ alert(msg_poll_cannot_modify);
function doPollAdd() { return window.close();
var obj = xCreateElement("div"); }
var source = xGetElementById("poll_source");
if(poll_index+1>8) return null;
poll_index++;
var html = xInnerHtml(source); // Add a new poll
html = html.replace(/tidx/g, poll_index); $('#add_poll').click(function(){
xInnerHtml(obj, html); addPoll();
setFixedPopupSize();
});
obj.id = "poll_"+poll_index; // Add a new item
obj.className = "poll_box"; $('button._add_item').click(function(){
obj.style.display = "block"; var $tr_src, $tr_new, $th, idx;
source.parentNode.insertBefore(obj, source); $tr_src = $(this).prev('table').find('>tbody>tr:last');
$tr_new = $tr_src.clone();
setFixedPopupSize(); match = $tr_src.find('td>input').attr('name').match(/item_(\d+)_(\d+)$/);
if(!match) return;
return null; match[2]++;
}
/** ($th=$tr_new.find('th')).html( $th.html().replace(/ \d+/, ' '+match[2]) );
* 항목 삭제 $tr_new.find('td>input').attr('name', 'item_'+match[1]+'_'+match[2]);
**/
function doPollDelete(obj) {
var pobj = xPrevSib(xPrevSib(obj)).lastChild.lastChild;
if(!pobj || typeof(pobj.id)=='undefined') return;
var tmp_arr = pobj.id.split('_');
var index = tmp_arr[1];
if(index==1) return;
pobj.parentNode.removeChild(pobj); $tr_src.after($tr_new);
var obj_list = xGetElementsByClassName('poll_box'); setFixedPopupSize();
for(var i=0;i<obj_list.length;i++) { });
var nobj = obj_list[i];
if(nobj.id == 'poll_source') continue;
var tmp_arr = nobj.id.split('_');
var index = tmp_arr[1];
nobj.id = 'poll_'+(i+1);
}
poll_index = i-1;
setFixedPopupSize(); // delete an item
} $('button._del_item').click(function(){
var $tr, match;
/** $tr = $(this).prevAll('table:first').find('>tbody>tr:last');
* 항목 추가 match = $tr.find('td>input').attr('name').match(/item_(\d+)_(\d+)/);
**/ if(!match || match[2] == 2) return;
function doPollAddItem(obj) {
var tbl = xPrevSib(obj);
var tbody = tbl.lastChild;
var tmp = tbody.firstChild;
var source = null;
while(tmp.nextSibling) {
tmp = tmp.nextSibling;
if(tmp.nodeName == "TR") source = tmp;
}
var new_obj = source.cloneNode(true); $tr.remove();
new_obj.className = source.className;
source.parentNode.appendChild(new_obj);
var html = xInnerHtml(new_obj); setFixedPopupSize();
var idx_match = html.match(/ ([0-9]+)</i); });
var idx = parseInt(idx_match[1],10);
var tmp = new_obj.firstChild; // delete a poll
while(tmp) { $('button._del_poll').click(function(){
if(tmp.nodeName == "TH") { $(this).parent('.poll_box').remove();
var html = xInnerHtml(tmp);
html = html.replace(/ ([0-9]+)/, ' '+(idx+1));
xInnerHtml(tmp, html);
} else if(tmp.nodeName == "TD") {
var html = xInnerHtml(tmp);
html = html.replace(/item_([0-9]+)_([0-9]+)/, 'item_$1_'+(idx+1));
xInnerHtml(tmp, html);
}
tmp = tmp.nextSibling;
}
setFixedPopupSize(); reindex();
});
return null; function reindex() {
} var $polls = $('.poll_box'); $inputs = $polls.find('input'), poll_idx = 0;
$inputs.attr('name', function(idx, val) {
if(/^checkcount_/.test(val)) poll_idx++;
return val.replace(/^([a-z]+_)(?:tidx|\d+)/, '$1'+poll_idx);
});
// If there are two or more polls, show 'delete poll' button.
// Otherwise hide the button.
if($polls.length > 1) {
$polls.find('button._del_poll').show();
} else {
$polls.find('button._del_poll').hide();
}
}
function addPoll() {
var $src = $('#poll_source');
$src.before(
$src.clone(true)
.removeAttr('id')
.addClass('poll_box')
.css('display', 'block')
);
reindex();
}
// add a poll
addPoll();
});
jQuery(window).load(setFixedPopupSize);